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;
}
}

View File

@@ -34,8 +34,8 @@
<item>@string/pref_proxy_type_choice_socks</item>
</string-array>
<string-array name="pref_proxy_type_values" translatable="false">
<item>@string/pref_proxy_type_value_http</item>
<item>@string/pref_proxy_type_value_socks</item>
<item>"proxyHttp"</item>
<item>"proxySocks"</item>
</string-array>
<string-array name="rev_del_dialog_entries" translatable="true">
<item>@string/del_rev_dialog_choice_rev_upload</item>
@@ -67,6 +67,6 @@
</string-array>
<string-array name="theme_values" translatable="false">
<item>"dark"</item>
<item>"ligh"</item>
<item>"light"</item>
</string-array>
</resources>

View File

@@ -198,8 +198,6 @@
<!-- proxy type choices and values -->
<string name="pref_proxy_type_choice_http">"HTTP"</string>
<string name="pref_proxy_type_choice_socks">"SOCKS"</string>
<string name="pref_proxy_type_value_http">"proxyHttp"</string>
<string name="pref_proxy_type_value_socks">"proxySocks"</string>
<!-- OrbotHelper strings -->
<string name="orbot_ignore_tor">"Don\'t use Tor"</string>

View File

@@ -27,7 +27,7 @@
<ListPreference
android:entries="@array/pref_proxy_type_entries"
android:entryValues="@array/pref_proxy_type_values"
android:defaultValue="@string/pref_proxy_type_value_http"
android:defaultValue="proxyHttp"
android:key="proxyType"
android:persistent="true"
android:title="@string/pref_proxy_type_title" />