Move proxy pref values out of strings

This commit is contained in:
Dominik Schürmann
2015-08-24 00:37:38 +02:00
parent 5e2f24520b
commit 7ba0b93ceb
5 changed files with 19 additions and 13 deletions

View File

@@ -114,6 +114,11 @@ public final class Constants {
public static final String DARK = "dark";
public static final String DEFAULT = Constants.Pref.Theme.LIGHT;
}
public static final class ProxyType {
public static final String TYPE_HTTP = "proxyHttp";
public static final String TYPE_SOCKS = "proxySocks";
}
}
/**

View File

@@ -286,16 +286,19 @@ public class Preferences {
}
public Proxy.Type getProxyType() {
final String typeHttp = mResources.getString(R.string.pref_proxy_type_value_http);
final String typeSocks = mResources.getString(R.string.pref_proxy_type_value_socks);
final String typeHttp = Pref.ProxyType.TYPE_HTTP;
final String typeSocks = Pref.ProxyType.TYPE_SOCKS;
String type = mSharedPreferences.getString(Pref.PROXY_TYPE, typeHttp);
if (type.equals(typeHttp)) return Proxy.Type.HTTP;
else if (type.equals(typeSocks)) return Proxy.Type.SOCKS;
else { // shouldn't happen
Log.e(Constants.TAG, "Invalid Proxy Type in preferences");
return null;
switch (type) {
case typeHttp:
return Proxy.Type.HTTP;
case typeSocks:
return Proxy.Type.SOCKS;
default: // shouldn't happen
Log.e(Constants.TAG, "Invalid Proxy Type in preferences");
return null;
}
}