add auto start option

This commit is contained in:
Max Lv
2012-12-17 11:51:22 +08:00
parent 17ae465395
commit 45fc2b4540
7 changed files with 124 additions and 77 deletions
+3 -61
View File
@@ -103,13 +103,10 @@ public class Shadowsocks extends PreferenceActivity implements
private static ProgressDialog mProgressDialog = null;
private CheckBoxPreference isGlobalProxyCheck;
private EditTextPreference proxyText;
private EditTextPreference portText;
private EditTextPreference remotePortText;
private EditTextPreference sitekeyText;
private CheckBoxPreference isGFWListCheck;
private CheckBoxPreference isRunningCheck;
private Preference proxyedApps;
private CheckBoxPreference isBypassAppsCheck;
@@ -159,32 +156,6 @@ public class Shadowsocks extends PreferenceActivity implements
}
private void disableAll() {
proxyText.setEnabled(false);
portText.setEnabled(false);
remotePortText.setEnabled(false);
sitekeyText.setEnabled(false);
proxyedApps.setEnabled(false);
isGFWListCheck.setEnabled(false);
isBypassAppsCheck.setEnabled(false);
isGlobalProxyCheck.setEnabled(false);
}
private void enableAll() {
proxyText.setEnabled(true);
portText.setEnabled(true);
remotePortText.setEnabled(true);
sitekeyText.setEnabled(true);
isGlobalProxyCheck.setEnabled(true);
isGFWListCheck.setEnabled(true);
if (!isGlobalProxyCheck.isChecked()) {
proxyedApps.setEnabled(true);
isBypassAppsCheck.setEnabled(true);
}
}
private boolean isTextEmpty(String s, String msg) {
if (s == null || s.length() <= 0) {
showAToast(msg);
@@ -208,9 +179,6 @@ public class Shadowsocks extends PreferenceActivity implements
sitekeyText = (EditTextPreference) findPreference("sitekey");
proxyedApps = findPreference("proxyedApps");
isRunningCheck = (CheckBoxPreference) findPreference("isRunning");
isGlobalProxyCheck = (CheckBoxPreference) findPreference("isGlobalProxy");
isGFWListCheck = (CheckBoxPreference) findPreference("isGFWList");
isBypassAppsCheck = (CheckBoxPreference) findPreference("isBypassApps");
if (mProgressDialog == null)
@@ -350,23 +318,14 @@ public class Shadowsocks extends PreferenceActivity implements
SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(this);
if (settings.getBoolean("isSystemProxy", false)) {
isGlobalProxyCheck.setEnabled(false);
isGFWListCheck.setEnabled(false);
if (settings.getBoolean("isGlobalProxy", false)) {
proxyedApps.setEnabled(false);
isBypassAppsCheck.setEnabled(false);
} else {
if (settings.getBoolean("isGlobalProxy", false)) {
proxyedApps.setEnabled(false);
isBypassAppsCheck.setEnabled(false);
} else {
proxyedApps.setEnabled(true);
isBypassAppsCheck.setEnabled(true);
}
proxyedApps.setEnabled(true);
isBypassAppsCheck.setEnabled(true);
}
sitekeyText.setEnabled(true);
Editor edit = settings.edit();
if (ShadowsocksService.isServiceStarted()) {
@@ -386,14 +345,6 @@ public class Shadowsocks extends PreferenceActivity implements
edit.commit();
if (settings.getBoolean("isRunning", false)) {
isRunningCheck.setChecked(true);
disableAll();
} else {
isRunningCheck.setChecked(false);
enableAll();
}
// Setup the initial values
if (!settings.getString("sitekey", "").equals(""))
@@ -448,15 +399,6 @@ public class Shadowsocks extends PreferenceActivity implements
}
}
if (key.equals("isRunning")) {
if (settings.getBoolean("isRunning", false)) {
disableAll();
isRunningCheck.setChecked(true);
} else {
isRunningCheck.setChecked(false);
enableAll();
}
}
if (key.equals("remotePort"))
if (settings.getString("remotePort", "").equals(""))