fixes
This commit is contained in:
parent
a3be59bd02
commit
f7c7b8050f
2 changed files with 12 additions and 9 deletions
|
@ -264,18 +264,21 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
|||
}
|
||||
|
||||
binding.importExportSettings.setOnClickListener {
|
||||
var i = 0
|
||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle("Import/Export Settings")
|
||||
.setSingleChoiceItems(Location.entries.map { it.name }.toTypedArray(), 0) { dialog, which ->
|
||||
selectedImpExp = Location.entries[which].name
|
||||
i = which
|
||||
}
|
||||
.setPositiveButton("Import...") { dialog, _ ->
|
||||
openDocumentLauncher.launch("Select a file")
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton("Export...") { dialog, which ->
|
||||
savePrefsToDownloads(Location.entries[which].name,
|
||||
PrefManager.exportAllPrefs(Location.entries[which]),
|
||||
.setNegativeButton("Export...") { dialog, _ ->
|
||||
if (i < 0) return@setNegativeButton
|
||||
savePrefsToDownloads(Location.entries[i].name,
|
||||
PrefManager.exportAllPrefs(Location.entries[i]),
|
||||
this@SettingsActivity)
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
|
|
@ -94,12 +94,12 @@ object PrefManager {
|
|||
return try {
|
||||
val pref = getPrefLocation(prefName.data.prefLocation)
|
||||
when (prefName.data.type) {
|
||||
Boolean::class -> pref.getBoolean(prefName.name, prefName.data.default as Boolean) as T?
|
||||
Int::class -> pref.getInt(prefName.name, prefName.data.default as Int) as T?
|
||||
Float::class -> pref.getFloat(prefName.name, prefName.data.default as Float) as T?
|
||||
Long::class -> pref.getLong(prefName.name, prefName.data.default as Long) as T?
|
||||
String::class -> pref.getString(prefName.name, prefName.data.default as String?) as T?
|
||||
Set::class -> convertFromStringSet(pref.getStringSet(prefName.name, null), prefName.data.default) as T?
|
||||
Boolean::class -> pref.getBoolean(prefName.name, default as Boolean) as T?
|
||||
Int::class -> pref.getInt(prefName.name, default as Int) as T?
|
||||
Float::class -> pref.getFloat(prefName.name, default as Float) as T?
|
||||
Long::class -> pref.getLong(prefName.name, default as Long) as T?
|
||||
String::class -> pref.getString(prefName.name, default as String?) as T?
|
||||
Set::class -> convertFromStringSet(pref.getStringSet(prefName.name, null), default) as T?
|
||||
else -> deserialzeClass(prefName.name, default)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue