Skip to content

Commit

Permalink
Fix service reattaching on entering settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Dec 1, 2017
1 parent d3903cb commit 2f682ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 2f682ef

Please sign in to comment.