mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-18 13:22:03 +00:00
avoid issues with prefChanged not changing
This commit is contained in:
parent
3dbd9c6ed9
commit
8247366bdd
4 changed files with 5 additions and 4 deletions
|
@ -53,6 +53,7 @@ import java.util.zip.ZipOutputStream
|
|||
class SettingsActivity : ComponentActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private val prefs by lazy { this.prefs() }
|
||||
val prefChanged = MutableStateFlow(0) // simple counter, as the only relevant information is that something changed
|
||||
fun prefChanged() = prefChanged.value++
|
||||
private val dictUriFlow = MutableStateFlow<Uri?>(null)
|
||||
private val cachedDictionaryFile by lazy { File(this.cacheDir.path + File.separator + "temp_dict") }
|
||||
private val crashReportFiles = MutableStateFlow<List<File>>(emptyList())
|
||||
|
@ -236,6 +237,6 @@ class SettingsActivity : ComponentActivity(), SharedPreferences.OnSharedPreferen
|
|||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(prefereces: SharedPreferences?, key: String?) {
|
||||
prefChanged.value++
|
||||
prefChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ fun LayoutEditDialog(
|
|||
LayoutUtilsCustom.getLayoutFile(newLayoutName, layoutType, ctx).writeText(it)
|
||||
LayoutUtilsCustom.onLayoutFileChanged()
|
||||
onEdited(newLayoutName)
|
||||
(ctx.getActivity() as? SettingsActivity)?.prefChanged?.value = 555
|
||||
(ctx.getActivity() as? SettingsActivity)?.prefChanged()
|
||||
KeyboardSwitcher.getInstance().setThemeNeedsReload()
|
||||
},
|
||||
confirmButtonText = stringResource(R.string.save),
|
||||
|
|
|
@ -168,7 +168,7 @@ fun BackupRestorePreference(setting: Setting) {
|
|||
val newDictBroadcast = Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION)
|
||||
ctx.getActivity()?.sendBroadcast(newDictBroadcast)
|
||||
LayoutUtilsCustom.onLayoutFileChanged()
|
||||
(ctx.getActivity() as? SettingsActivity)?.prefChanged?.value = 210 // for settings reload
|
||||
(ctx.getActivity() as? SettingsActivity)?.prefChanged()
|
||||
KeyboardSwitcher.getInstance().setThemeNeedsReload()
|
||||
}
|
||||
Preference(name = setting.title, onClick = { showDialog = true })
|
||||
|
|
|
@ -391,7 +391,7 @@ private fun MainLayoutRow(
|
|||
if (it == currentSubtype.mainLayoutName())
|
||||
setCurrentSubtype(currentSubtype.withoutLayout(LayoutType.MAIN))
|
||||
LayoutUtilsCustom.deleteLayout(it, LayoutType.MAIN, ctx)
|
||||
(ctx.getActivity() as? SettingsActivity)?.prefChanged?.value = 1234
|
||||
(ctx.getActivity() as? SettingsActivity)?.prefChanged()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue