mirror of
https://github.com/gsantner/dandelion
synced 2025-12-15 08:41:10 +01:00
Proxy tor preset
This commit is contained in:
parent
52d6947d3e
commit
c94a511ace
14 changed files with 106 additions and 60 deletions
|
|
@ -78,12 +78,12 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
setPreferenceSummaries();
|
||||
sharedPreferences.edit().putBoolean(getString(R.string.pref_key__proxy_was_enabled),
|
||||
sharedPreferences.getBoolean(getString(R.string.pref_key__proxy_enabled), false)).apply();
|
||||
sharedPreferences.getBoolean(getString(R.string.pref_key__http_proxy_enabled), false)).apply();
|
||||
}
|
||||
|
||||
private void setPreferenceSummaries() {
|
||||
String[] editTextKeys = new String[]{
|
||||
getString(R.string.pref_key__proxy_host), getString(R.string.pref_key__proxy_port)
|
||||
getString(R.string.pref_key__http_proxy_host), getString(R.string.pref_key__http_proxy_port)
|
||||
};
|
||||
for (String key : editTextKeys) {
|
||||
EditTextPreference p = (EditTextPreference) findPreference(key);
|
||||
|
|
@ -98,9 +98,9 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
key.equals(getString(R.string.pref_key__font_size)) ||
|
||||
key.equals(getString(R.string.pref_key__load_images)) ||
|
||||
key.equals(getString(R.string.pref_key__intellihide_toolbars)) ||
|
||||
key.equals(getString(R.string.pref_key__proxy_enabled)) ||
|
||||
key.equals(getString(R.string.pref_key__proxy_host)) ||
|
||||
key.equals(getString(R.string.pref_key__proxy_port)) ||
|
||||
key.equals(getString(R.string.pref_key__http_proxy_enabled)) ||
|
||||
key.equals(getString(R.string.pref_key__http_proxy_host)) ||
|
||||
key.equals(getString(R.string.pref_key__http_proxy_port)) ||
|
||||
key.startsWith("pref_key__visibility_nav__"))) {
|
||||
((SettingsActivity) getActivity()).setActivityRestartRequired();
|
||||
}
|
||||
|
|
@ -123,8 +123,11 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
||||
App app = ((App) getActivity().getApplication());
|
||||
AppSettings appSettings = app.getSettings();
|
||||
Intent intent = new Intent(getActivity(), MainActivity.class);
|
||||
String podDomain = ((App) getActivity().getApplication()).getSettings().getPodDomain();
|
||||
String podDomain = appSettings.getPodDomain();
|
||||
|
||||
switch (preference.getTitleRes()) {
|
||||
case R.string.pref_title__personal_settings: {
|
||||
intent.setAction(MainActivity.ACTION_OPEN_URL);
|
||||
|
|
@ -158,6 +161,11 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
.show();
|
||||
return true;
|
||||
}
|
||||
case R.string.pref_title__http_proxy_load_tor_preset: {
|
||||
((EditTextPreference)findPreference(getString(R.string.pref_key__http_proxy_host))).setText("127.0.0.1");
|
||||
((EditTextPreference)findPreference(getString(R.string.pref_key__http_proxy_port))).setText("8118");
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
intent = null;
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ public class AppSettings {
|
|||
@SuppressLint("CommitPrefEdits")
|
||||
public void setProxyEnabled(boolean enabled) {
|
||||
//commit instead of apply because the app is likely to be killed before apply is called.
|
||||
prefApp.edit().putBoolean(context.getString(R.string.pref_key__proxy_enabled), enabled).commit();
|
||||
prefApp.edit().putBoolean(context.getString(R.string.pref_key__http_proxy_enabled), enabled).commit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -211,7 +211,7 @@ public class AppSettings {
|
|||
* @return whether proxy is enabled or not
|
||||
*/
|
||||
public boolean isProxyEnabled() {
|
||||
return getBoolean(prefApp, R.string.pref_key__proxy_enabled, false);
|
||||
return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false);
|
||||
}
|
||||
|
||||
public boolean wasProxyEnabled() {
|
||||
|
|
@ -235,9 +235,12 @@ public class AppSettings {
|
|||
* @return proxy host
|
||||
*/
|
||||
public String getProxyHost() {
|
||||
return getString(prefApp, R.string.pref_key__proxy_host, "");
|
||||
return getString(prefApp, R.string.pref_key__http_proxy_host, "");
|
||||
}
|
||||
|
||||
public void setProxyHttpHost(String value) {
|
||||
setString(prefApp, R.string.pref_key__http_proxy_host, value);
|
||||
}
|
||||
/**
|
||||
* Default value: 0
|
||||
*
|
||||
|
|
@ -245,13 +248,17 @@ public class AppSettings {
|
|||
*/
|
||||
public int getProxyPort() {
|
||||
try {
|
||||
return Integer.parseInt(getString(prefApp, R.string.pref_key__proxy_port, "0"));
|
||||
return Integer.parseInt(getString(prefApp, R.string.pref_key__http_proxy_port, "0"));
|
||||
} catch (Exception e) {
|
||||
setString(prefApp, R.string.pref_key__proxy_port, "0");
|
||||
setString(prefApp, R.string.pref_key__http_proxy_port, "0");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setProxyHttpPort(int value) {
|
||||
setInt(prefApp, R.string.pref_key__http_proxy_port, value);
|
||||
}
|
||||
|
||||
public boolean isIntellihideToolbars() {
|
||||
return getBoolean(prefApp, R.string.pref_key__intellihide_toolbars, false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue