38 lines
1.2 KiB
Kotlin
38 lines
1.2 KiB
Kotlin
package com.stevesoltys.backup.settings
|
|
|
|
import android.content.Context
|
|
import android.net.Uri
|
|
import android.preference.PreferenceManager.getDefaultSharedPreferences
|
|
|
|
private const val PREF_KEY_BACKUP_URI = "backupUri"
|
|
private const val PREF_KEY_DEVICE_NAME = "deviceName"
|
|
private const val PREF_KEY_BACKUP_PASSWORD = "backupLegacyPassword"
|
|
|
|
fun setBackupFolderUri(context: Context, uri: Uri) {
|
|
getDefaultSharedPreferences(context)
|
|
.edit()
|
|
.putString(PREF_KEY_BACKUP_URI, uri.toString())
|
|
.apply()
|
|
}
|
|
|
|
fun getBackupFolderUri(context: Context): Uri? {
|
|
val uriStr = getDefaultSharedPreferences(context).getString(PREF_KEY_BACKUP_URI, null)
|
|
?: return null
|
|
return Uri.parse(uriStr)
|
|
}
|
|
|
|
fun setDeviceName(context: Context, name: String) {
|
|
getDefaultSharedPreferences(context)
|
|
.edit()
|
|
.putString(PREF_KEY_DEVICE_NAME, name)
|
|
.apply()
|
|
}
|
|
|
|
fun getDeviceName(context: Context): String? {
|
|
return getDefaultSharedPreferences(context).getString(PREF_KEY_DEVICE_NAME, null)
|
|
}
|
|
|
|
@Deprecated("Replaced by KeyManager#getBackupKey()")
|
|
fun getBackupPassword(context: Context): String? {
|
|
return getDefaultSharedPreferences(context).getString(PREF_KEY_BACKUP_PASSWORD, null)
|
|
}
|