diff --git a/app/src/main/java/io/legado/app/utils/PreferencesExtensions.kt b/app/src/main/java/io/legado/app/utils/PreferencesExtensions.kt index b8370d526..58498a28a 100644 --- a/app/src/main/java/io/legado/app/utils/PreferencesExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/PreferencesExtensions.kt @@ -1,11 +1,57 @@ +@file:Suppress("unused") + package io.legado.app.utils import android.content.SharedPreferences import androidx.core.content.edit +fun SharedPreferences.getString(key: String): String? { + return getString(key, null) +} + +fun SharedPreferences.putString(key: String, value: String) { + edit { + putString(key, value) + } +} + +fun SharedPreferences.getBoolean(key: String): Boolean { + return getBoolean(key, false) +} + +fun SharedPreferences.putBoolean(key: String, value: Boolean) { + edit { + putBoolean(key, value) + } +} + +fun SharedPreferences.getInt(key: String): Int { + return getInt(key, 0) +} + +fun SharedPreferences.putInt(key: String, value: Int) { + edit { + putInt(key, value) + } +} + +fun SharedPreferences.getLong(key: String): Long { + return getLong(key, 0) +} + fun SharedPreferences.putLong(key: String, value: Long) { edit { putLong(key, value) } +} + +fun SharedPreferences.getFloat(key: String): Float { + return getFloat(key, 0f) +} + +fun SharedPreferences.putFloat(key: String, value: Float) { + edit { + putFloat(key, value) + } } \ No newline at end of file