tweaked root request on/off preference UI
This commit is contained in:
parent
805b823a5f
commit
331c4956d7
|
@ -107,7 +107,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
||||||
mItemOnOff.setAlphabeticShortcut('t');
|
mItemOnOff.setAlphabeticShortcut('t');
|
||||||
|
|
||||||
mItem = menu.add(0, 4, Menu.NONE, getString(R.string.menu_settings));
|
mItem = menu.add(0, 4, Menu.NONE, getString(R.string.menu_settings));
|
||||||
mItem.setIcon(R.drawable.ic_menu_register);
|
mItem.setIcon(R.drawable.ic_menu_settings);
|
||||||
|
|
||||||
mItem = menu.add(0, 7, Menu.NONE, getString(R.string.menu_verify));
|
mItem = menu.add(0, 7, Menu.NONE, getString(R.string.menu_verify));
|
||||||
mItem.setIcon(R.drawable.ic_menu_check);
|
mItem.setIcon(R.drawable.ic_menu_check);
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
public class SettingsPreferences
|
public class SettingsPreferences
|
||||||
|
@ -27,11 +28,13 @@ public class SettingsPreferences
|
||||||
private CheckBoxPreference prefcBTransProxyAll = null;
|
private CheckBoxPreference prefcBTransProxyAll = null;
|
||||||
private Preference prefTransProxyApps = null;
|
private Preference prefTransProxyApps = null;
|
||||||
private CheckBoxPreference prefHiddenServices = null;
|
private CheckBoxPreference prefHiddenServices = null;
|
||||||
|
private CheckBoxPreference prefRequestRoot = null;
|
||||||
|
|
||||||
private boolean hasRoot = false;
|
private boolean hasRoot = false;
|
||||||
|
|
||||||
|
|
||||||
private final static int HIDDEN_SERVICE_PREF_IDX = 6;
|
private final static int HIDDEN_SERVICE_PREF_IDX = 6;
|
||||||
|
private final static int TRANSPROXY_GROUP_IDX = 1;
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
@ -55,27 +58,31 @@ public class SettingsPreferences
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
int REQUEST_ROOT_IDX = 1;
|
||||||
|
int GENERAL_GROUP_IDX = 0;
|
||||||
|
|
||||||
int transProxyGroupIdx = 1;
|
prefRequestRoot = ((CheckBoxPreference)((PreferenceCategory)getPreferenceScreen().getPreference(GENERAL_GROUP_IDX)).getPreference(REQUEST_ROOT_IDX));
|
||||||
|
prefRequestRoot.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
if (!hasRoot)
|
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(0));
|
||||||
{
|
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(1);
|
||||||
getPreferenceScreen().getPreference(transProxyGroupIdx).setEnabled(false);
|
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(2);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(0));
|
|
||||||
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(1);
|
|
||||||
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(2);
|
|
||||||
|
|
||||||
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
|
||||||
|
|
||||||
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
|
|
||||||
|
|
||||||
prefCBTransProxy.setOnPreferenceClickListener(this);
|
prefCBTransProxy.setOnPreferenceClickListener(this);
|
||||||
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
||||||
prefTransProxyApps.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()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +112,23 @@ public class SettingsPreferences
|
||||||
|
|
||||||
setResult(1010);
|
setResult(1010);
|
||||||
|
|
||||||
if (preference == prefTransProxyApps)
|
if (preference == prefRequestRoot)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (prefRequestRoot.isChecked())
|
||||||
|
{
|
||||||
|
boolean canRoot = TorServiceUtils.isRootPossible();
|
||||||
|
|
||||||
|
getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX).setEnabled(canRoot);
|
||||||
|
prefRequestRoot.setChecked(canRoot);
|
||||||
|
|
||||||
|
if (!canRoot)
|
||||||
|
{
|
||||||
|
Toast.makeText(this, R.string.wizard_permissions_no_root_msg, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (preference == prefTransProxyApps)
|
||||||
{
|
{
|
||||||
startActivity(new Intent(this, AppManager.class));
|
startActivity(new Intent(this, AppManager.class));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue