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