diff --git a/src/main/scala/com/github/shadowsocks/AppManager.scala b/src/main/scala/com/github/shadowsocks/AppManager.scala index 3aa828c9..e2cf7bb7 100644 --- a/src/main/scala/com/github/shadowsocks/AppManager.scala +++ b/src/main/scala/com/github/shadowsocks/AppManager.scala @@ -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) diff --git a/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala b/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala index 4cbdef10..9b3953fc 100644 --- a/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala +++ b/src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala @@ -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)