Commit 2e737418 authored by Mygod's avatar Mygod

Fix excess unsaved prompt

AppManager's sub-activity should maintain dirty flags by themselves. Fix #1032.
parent 022b6da9
......@@ -167,7 +167,7 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
val (enabled, apps) = if (i < 0) (proxiedAppString, "")
else (proxiedAppString.substring(0, i), proxiedAppString.substring(i + 1))
bypassSwitch.setChecked(enabled.toBoolean)
app.editor.putString(Key.individual, apps).apply()
app.editor.putString(Key.individual, apps).putBoolean(Key.dirty, true).apply()
Toast.makeText(this, R.string.action_import_msg, Toast.LENGTH_SHORT).show()
appListView.setVisibility(View.GONE)
loadingView.setVisibility(View.VISIBLE)
......@@ -205,16 +205,18 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
toolbar.inflateMenu(R.menu.app_manager_menu)
toolbar.setOnMenuItemClickListener(this)
if (!app.settings.getBoolean(Key.proxyApps, false)) app.editor.putBoolean(Key.proxyApps, true).apply()
if (!app.settings.getBoolean(Key.proxyApps, false))
app.editor.putBoolean(Key.proxyApps, true).putBoolean(Key.dirty, true).apply()
findViewById(R.id.onSwitch).asInstanceOf[Switch]
.setOnCheckedChangeListener((_, checked) => {
app.editor.putBoolean(Key.proxyApps, checked).apply()
app.editor.putBoolean(Key.proxyApps, checked).putBoolean(Key.dirty, true).apply()
finish()
})
bypassSwitch = findViewById(R.id.bypassSwitch).asInstanceOf[Switch]
bypassSwitch.setChecked(app.settings.getBoolean(Key.bypass, false))
bypassSwitch.setOnCheckedChangeListener((_, checked) => app.editor.putBoolean(Key.bypass, checked).apply())
bypassSwitch.setOnCheckedChangeListener((_, checked) =>
app.editor.putBoolean(Key.bypass, checked).putBoolean(Key.dirty, true).apply())
initProxiedApps()
loadingView = findViewById(R.id.loading)
......
......@@ -63,7 +63,7 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe
}
override def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String): Unit =
if (findPreference(key) != null) app.editor.putBoolean(Key.dirty, true).apply()
if (key != Key.proxyApps && findPreference(key) != null) app.editor.putBoolean(Key.dirty, true).apply()
override def onDestroy() {
app.settings.unregisterOnSharedPreferenceChangeListener(this)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment