Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7875655e authored by Jacky Wang's avatar Jacky Wang Committed by Android (Google) Code Review
Browse files

Merge "Add common APIs for settings datastore" into main

parents f6fcb8c0 59fa415f
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -99,6 +99,37 @@ abstract class SettingsStore(protected val contentResolver: ContentResolver) :
        contentResolver.unregisterContentObserver(contentObserver)
    }

    /** Gets the boolean value of given key. */
    fun getBoolean(key: String): Boolean? = getValue(key, Boolean::class.javaObjectType)

    /** Sets boolean value for given key, null value means delete the key from data store. */
    fun setBoolean(key: String, value: Boolean?) =
        setValue(key, Boolean::class.javaObjectType, value)

    /** Gets the float value of given key. */
    fun getFloat(key: String): Float? = getValue(key, Float::class.javaObjectType)

    /** Sets float value for given key, null value means delete the key from data store. */
    fun setFloat(key: String, value: Float?) = setValue(key, Float::class.javaObjectType, value)

    /** Gets the int value of given key. */
    fun getInt(key: String): Int? = getValue(key, Int::class.javaObjectType)

    /** Sets int value for given key, null value means delete the key from data store. */
    fun setInt(key: String, value: Int?) = setValue(key, Int::class.javaObjectType, value)

    /** Gets the long value of given key. */
    fun getLong(key: String): Long? = getValue(key, Long::class.javaObjectType)

    /** Sets long value for given key, null value means delete the key from data store. */
    fun setLong(key: String, value: Long?) = setValue(key, Long::class.javaObjectType, value)

    /** Gets the string value of given key. */
    fun getString(key: String): String? = getValue(key, String::class.javaObjectType)

    /** Sets string value for given key, null value means delete the key from data store. */
    fun setString(key: String, value: String?) = setValue(key, String::class.javaObjectType, value)

    /** Tag for logging. */
    abstract val tag: String
}