tweak root preferences

This commit is contained in:
Nathan Freitas 2016-10-29 11:33:45 -04:00
parent 4d66133894
commit d25b3d5de8
2 changed files with 16 additions and 4 deletions

View File

@ -15,9 +15,11 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.util.Log;
import org.torproject.android.OrbotApp;
import org.torproject.android.R;
import org.torproject.android.service.transproxy.TorTransProxy;
import org.torproject.android.ui.AppManager;
import org.torproject.android.service.util.TorServiceUtils;
@ -30,6 +32,8 @@ public class SettingsPreferences
private CheckBoxPreference prefCBTransProxy = null;
private CheckBoxPreference prefcBTransProxyAll = null;
private CheckBoxPreference prefcbTransTethering = null;
private Preference prefTransProxyFlush = null;
private Preference prefTransProxyApps = null;
@ -77,6 +81,7 @@ public class SettingsPreferences
prefCBTransProxy = (CheckBoxPreference) findPreference("pref_transparent");
prefcBTransProxyAll = (CheckBoxPreference) findPreference("pref_transparent_all");
prefcbTransTethering = (CheckBoxPreference) findPreference("pref_transparent_tethering");
prefTransProxyFlush = (Preference) findPreference("pref_transproxy_flush");
prefTransProxyFlush.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@ -105,8 +110,8 @@ public class SettingsPreferences
prefCBTransProxy.setEnabled(prefRequestRoot.isChecked());
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
prefcbTransTethering.setEnabled(prefCBTransProxy.isChecked());
if (prefCBTransProxy.isChecked())
prefTransProxyApps.setEnabled((!prefcBTransProxyAll.isChecked()));
@ -132,8 +137,16 @@ public class SettingsPreferences
if (prefRequestRoot.isChecked())
{
try {
TorTransProxy.testRoot();
prefCBTransProxy.setEnabled(true);
}
catch (Exception e)
{
Log.d(OrbotApp.TAG,"root not yet enabled");
}
}
}
else if (preference == prefTransProxyApps)

View File

@ -71,7 +71,6 @@ 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"/>