diff --git a/mobile/src/main/scala/com/github/shadowsocks/GlobalConfigFragment.scala b/mobile/src/main/scala/com/github/shadowsocks/GlobalConfigFragment.scala index 137e18d13f..1811b72768 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/GlobalConfigFragment.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/GlobalConfigFragment.scala @@ -32,10 +32,7 @@ import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers class GlobalConfigFragment extends PreferenceFragmentCompatDividers { override def onCreatePreferencesFix(bundle: Bundle, key: String) { getPreferenceManager.setPreferenceDataStore(app.dataStore) - app.dataStore.putString(Key.serviceMode, app.dataStore.serviceMode) // temporary workaround for support lib bug - app.dataStore.putString(Key.portProxy, app.dataStore.portProxy.toString) - app.dataStore.putString(Key.portLocalDns, app.dataStore.portLocalDns.toString) - app.dataStore.putString(Key.portTransproxy, app.dataStore.portTransproxy.toString) + app.dataStore.initGlobal() addPreferencesFromResource(R.xml.pref_global) val switch = findPreference(Key.isAutoConnect).asInstanceOf[SwitchPreference] switch.setOnPreferenceChangeListener((_, value) => { diff --git a/mobile/src/main/scala/com/github/shadowsocks/preference/OrmLitePreferenceDataStore.scala b/mobile/src/main/scala/com/github/shadowsocks/preference/OrmLitePreferenceDataStore.scala index 034bbfb870..cc3e2387be 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/preference/OrmLitePreferenceDataStore.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/preference/OrmLitePreferenceDataStore.scala @@ -125,4 +125,12 @@ final class OrmLitePreferenceDataStore(dbHelper: DBHelper) extends PreferenceDat def plugin_=(value: String): Unit = putString(Key.plugin, value) def dirty: Boolean = getBoolean(Key.dirty) def dirty_=(value: Boolean): Unit = putBoolean(Key.dirty, value) + + def initGlobal() { + // temporary workaround for support lib bug + if (getString(Key.serviceMode) == null) putString(Key.serviceMode, serviceMode) + if (getString(Key.portProxy) == null) putString(Key.portProxy, portProxy.toString) + if (getString(Key.portLocalDns) == null) putString(Key.portLocalDns, portLocalDns.toString) + if (getString(Key.portTransproxy) == null) putString(Key.portTransproxy, portTransproxy.toString) + } }