Skip to content

Commit 2efad93

Browse files
committed
Sync global download options with SettingsFragment
1 parent 520e620 commit 2efad93

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
package de.linux13524.ytldl.fragments
22

33

4+
import android.content.SharedPreferences
5+
import de.linux13524.ytldl.utils.PreferencesManager.syncPreferencesWithGlobalDownloadOptions
46
import android.os.Bundle
57
import androidx.preference.PreferenceFragmentCompat
6-
78
import de.linux13524.ytldl.R
89

9-
class SettingsFragment : PreferenceFragmentCompat() {
10+
class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener {
11+
override fun onSharedPreferenceChanged(p: SharedPreferences?, prefName: String?) {
12+
activity?.syncPreferencesWithGlobalDownloadOptions()
13+
}
1014

1115
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
1216
setPreferencesFromResource(R.xml.preferences, rootKey)
13-
//addPreferencesFromResource(R.xml.preferences)
17+
}
18+
19+
override fun onResume() {
20+
super.onResume()
21+
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
22+
}
23+
24+
override fun onPause() {
25+
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
26+
super.onPause()
1427
}
1528
}

0 commit comments

Comments
 (0)