fix for setting root and transproxy preferences

This commit is contained in:
Nathan Freitas 2015-04-09 01:28:38 -04:00
parent 23a28f5a6f
commit 9974654c08
3 changed files with 11 additions and 19 deletions

View File

@ -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>

View File

@ -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"/>

View File

@ -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,25 +93,16 @@ 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()));
}
prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(0));
prefHiddenServices.setOnPreferenceClickListener(this);
@ -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)