commit 9974654c0888694ca187209da782ffc83f479c49 Author: Nathan Freitas nathan@freitas.net Date: Thu Apr 9 01:28:38 2015 -0400
fix for setting root and transproxy preferences --- res/values/strings.xml | 2 +- res/xml/preferences.xml | 4 ++++ .../android/settings/SettingsPreferences.java | 24 +++++--------------- 3 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/res/values/strings.xml b/res/values/strings.xml index ede9174..0318cac 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -107,7 +107,7 @@ <string name="wizard_permissions_title">Permissions</string> <string name="wizard_permissions_root_msg1">You can optionally grant Orbot 'Superuser' access to enable advanced features, such as Transparent Proxying.</string> <string name="wizard_permissions_root_msg2">If you do not want to do this, please make sure to use apps made to work with Orbot</string> - <string name="wizard_permissions_no_root_msg">Your device does not appear to be rooted or provide 'Superuser' access.\n\nIn order to you to benefit from Tor, you will need to use apps built to work with Orbot, or that support HTTP or SOCKS proxy settings.\n\n</string> + <string name="wizard_permissions_no_root_msg">Your device does not appear to be rooted or provide root or 'Superuser' access.\n\nPlease try the 'Apps' mode on the main screen instead.</string> <!--TipsAndTricks screen--> <string name="wizard_tips_title">Orbot-Enabled Apps</string> <string name="wizard_tips_gibberbot">ChatSecure: Secure chat app with Off-the-Record Encryption</string> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index eabc9b3..d5a8a75 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -47,6 +47,7 @@ android:defaultValue="false" android:key="pref_transparent" android:title="@string/pref_trans_proxy_title" android:summary="@string/pref_trans_proxy_summary" +android:dependency="has_root" android:enabled="true"/>
<CheckBoxPreference @@ -54,6 +55,7 @@ android:defaultValue="false" android:key="pref_transparent_all" android:summary="@string/pref_transparent_all_summary" android:enabled="true" +android:dependency="has_root" android:title="@string/pref_transparent_all_title"/>
<Preference @@ -61,6 +63,7 @@ android:defaultValue="" android:key="pref_transparent_app_list" android:title="@string/pref_select_apps" android:summary="@string/pref_select_apps_summary" +android:dependency="has_root" android:enabled="true"/>
<CheckBoxPreference @@ -68,6 +71,7 @@ android:defaultValue="false" android:key="pref_transparent_tethering" android:summary="@string/pref_transparent_tethering_summary" android:enabled="true" +android:dependency="has_root" android:title="@string/pref_transparent_tethering_title"/>
diff --git a/src/org/torproject/android/settings/SettingsPreferences.java b/src/org/torproject/android/settings/SettingsPreferences.java index 0e7f837..147f84d 100644 --- a/src/org/torproject/android/settings/SettingsPreferences.java +++ b/src/org/torproject/android/settings/SettingsPreferences.java @@ -64,19 +64,18 @@ public class SettingsPreferences private void init () { - int REQUEST_ROOT_IDX = 1; int SET_LOCALE_IDX = 3;
int GENERAL_GROUP_IDX = 0; - prefRequestRoot = ((CheckBoxPreference)((PreferenceCategory)getPreferenceScreen().getPreference(GENERAL_GROUP_IDX)).getPreference(REQUEST_ROOT_IDX)); + prefRequestRoot = ((CheckBoxPreference)((PreferenceCategory)getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(0)); prefRequestRoot.setOnPreferenceClickListener(this);
prefLocale = (((PreferenceCategory)getPreferenceScreen().getPreference(GENERAL_GROUP_IDX)).getPreference(SET_LOCALE_IDX)); prefLocale.setOnPreferenceClickListener(this); - prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(0)); - prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(1); + prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(1)); + prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(2); prefTransProxyFlush = (Preference)((PreferenceCategory)this.getPreferenceScreen().getPreference(DEBUG_GROUP_IDX)).getPreference(8); prefTransProxyFlush.setOnPreferenceClickListener(new OnPreferenceClickListener() { @@ -94,24 +93,15 @@ public class SettingsPreferences }); - prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(2); + prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(3);
prefCBTransProxy.setOnPreferenceClickListener(this); prefcBTransProxyAll.setOnPreferenceClickListener(this); prefTransProxyApps.setOnPreferenceClickListener(this); - if (!hasRoot) - { - getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX).setEnabled(false); - } - else - { - - prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked()); - prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked())); - - } + prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked()); + prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked())); prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(0)); @@ -154,12 +144,10 @@ public class SettingsPreferences if (preference == prefRequestRoot) { - if (prefRequestRoot.isChecked()) { boolean canRoot = RootCommands.rootAccessGiven(); - getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX).setEnabled(canRoot); prefRequestRoot.setChecked(canRoot);
if (!canRoot)