mirror of
https://github.com/gsantner/dandelion
synced 2024-11-21 20:02:07 +01:00
Added info Toasts to Proxy preference, that inform the user about required restart and successful preset setting
This commit is contained in:
parent
f08fb9e349
commit
30ca937461
5 changed files with 60 additions and 6 deletions
|
@ -7,7 +7,7 @@
|
|||
06l>> Firstname Lastname (E-Mail): Text
|
||||
07l>> Username (Link): Text
|
||||
08l>> Username (E-Mail): Text
|
||||
## 99l CONTRIBUTORS
|
||||
## 99l CONTRIBUTORS
|
||||
Martín Vukovic (martinvukovic@protonmail.com): Diaspora Native WebApp
|
||||
Gaukler Faun (https://github.com/scoute-dich): Diaspora Native WebApp additions
|
||||
Abhijith Balan (abhijithb21 AT openmailbox DOT org): Malayalam translation
|
||||
|
|
|
@ -511,11 +511,7 @@ public class MainActivity extends ThemedActivity
|
|||
* @return top fragment or null if there is none displayed
|
||||
*/
|
||||
private CustomFragment getTopFragment() {
|
||||
Fragment top = fm.findFragmentById(R.id.fragment_container);
|
||||
if (top != null) {
|
||||
return (CustomFragment) top;
|
||||
}
|
||||
return null;
|
||||
return (CustomFragment) fm.findFragmentById(R.id.fragment_container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,15 +14,18 @@ import android.preference.Preference;
|
|||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.ui.theme.ColorPalette;
|
||||
import com.github.dfa.diaspora_android.ui.theme.CustomFragment;
|
||||
import com.github.dfa.diaspora_android.ui.theme.ThemeHelper;
|
||||
import com.github.dfa.diaspora_android.ui.theme.ThemedActivity;
|
||||
import com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceFragment;
|
||||
|
@ -127,6 +130,31 @@ public class SettingsActivity extends ThemedActivity {
|
|||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
AppLog.d(this, "onBackPressed");
|
||||
ThemedPreferenceFragment top = getTopFragment();
|
||||
if(top != null && top.getFragmentTag().equals(SettingsFragmentProxy.TAG)) {
|
||||
AppLog.d(this, "top was proxy");
|
||||
ProxyHandler.ProxySettings newProxySettings = getAppSettings().getProxySettings();
|
||||
if(oldProxySettings.isEnabled() && !newProxySettings.isEnabled()) {
|
||||
AppLog.d(this, "proxy disabled");
|
||||
Toast.makeText(this, R.string.toast__proxy_disabled__restart_required, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
AppLog.d(this, "top is null: "+(top == null));
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fragment which is currently displayed in R.id.fragment_container
|
||||
*
|
||||
* @return top fragment or null if there is none displayed
|
||||
*/
|
||||
private ThemedPreferenceFragment getTopFragment() {
|
||||
return (ThemedPreferenceFragment) getFragmentManager().findFragmentById(R.id.settings__fragment_container);
|
||||
}
|
||||
|
||||
public static class SettingsFragmentMaster extends ThemedPreferenceFragment {
|
||||
public static final String TAG = "com.github.dfa.diaspora_android.settings.SettingsFragmentMaster";
|
||||
|
||||
|
@ -212,6 +240,11 @@ public class SettingsActivity extends ThemedActivity {
|
|||
}
|
||||
return super.onPreferenceTreeClick(screen, preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SettingsFragmentThemes extends ThemedPreferenceFragment {
|
||||
|
@ -247,6 +280,11 @@ public class SettingsActivity extends ThemedActivity {
|
|||
return super.onPreferenceTreeClick(screen, preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a colorPicker Dialog
|
||||
*
|
||||
|
@ -329,6 +367,11 @@ public class SettingsActivity extends ThemedActivity {
|
|||
public void updateViewColors() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SettingsFragmentProxy extends ThemedPreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
@ -364,12 +407,18 @@ public class SettingsActivity extends ThemedActivity {
|
|||
if (appSettings.isKeyEqual(key, R.string.pref_key__http_proxy_load_tor_preset)) {
|
||||
appSettings.setProxyHttpHost("127.0.0.1");
|
||||
appSettings.setProxyHttpPort(8118);
|
||||
Toast.makeText(screen.getContext(), R.string.toast__proxy_orbot_preset_loaded, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onPreferenceTreeClick(screen, preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateViewColors() {
|
||||
|
||||
|
@ -399,5 +448,10 @@ public class SettingsActivity extends ThemedActivity {
|
|||
public void updateViewColors() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,4 +39,6 @@ public abstract class ThemedPreferenceFragment extends PreferenceFragment {
|
|||
}
|
||||
return super.onPreferenceTreeClick(screen, preference);
|
||||
}
|
||||
|
||||
public abstract String getFragmentTag();
|
||||
}
|
||||
|
|
|
@ -115,6 +115,8 @@
|
|||
<string name="pref_title__http_proxy_port">Port</string>
|
||||
<string name="HTTP" translatable="false">HTTP</string>
|
||||
<string name="SOCKS5" translatable="false">SOCKS5</string>
|
||||
<string name="toast__proxy_disabled__restart_required">App needs to restart to disable proxy usage</string>
|
||||
<string name="toast__proxy_orbot_preset_loaded">Orbot proxy preset loaded</string>
|
||||
|
||||
|
||||
<!-- Chrome custom tabs -->
|
||||
|
|
Loading…
Reference in a new issue