mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Use default shared preferences for UI mode utils.
This commit is contained in:
parent
1cc1afb8bf
commit
83a36b327a
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities
|
|||||||
class ChangeUiModeDialog : DialogFragment() {
|
class ChangeUiModeDialog : DialogFragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public const val TAG = "ChangeUiModeDialog"
|
const val TAG = "ChangeUiModeDialog"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
@ -3,18 +3,18 @@ package org.thoughtcrime.securesms.loki.utilities
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Day/night UI mode related utilities.
|
* Day/night UI mode related utilities.
|
||||||
* @see <a href="https://developer.android.com/guide/topics/ui/look-and-feel/darktheme">Official Documentation</a>
|
* @see <a href="https://developer.android.com/guide/topics/ui/look-and-feel/darktheme">Official Documentation</a>
|
||||||
*/
|
*/
|
||||||
object UiModeUtilities {
|
object UiModeUtilities {
|
||||||
private const val PREF_FILE_NAME = "UiModeUtilities"
|
|
||||||
private const val PREF_KEY_SELECTED_UI_MODE = "SELECTED_UI_MODE"
|
private const val PREF_KEY_SELECTED_UI_MODE = "SELECTED_UI_MODE"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun setUserSelectedUiMode(context: Context, uiMode: UiMode) {
|
public fun setUserSelectedUiMode(context: Context, uiMode: UiMode) {
|
||||||
val prefs = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putString(PREF_KEY_SELECTED_UI_MODE, uiMode.name)
|
.putString(PREF_KEY_SELECTED_UI_MODE, uiMode.name)
|
||||||
.apply()
|
.apply()
|
||||||
@ -23,7 +23,7 @@ object UiModeUtilities {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun getUserSelectedUiMode(context: Context): UiMode {
|
public fun getUserSelectedUiMode(context: Context): UiMode {
|
||||||
val prefs = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val selectedUiModeName = prefs.getString(PREF_KEY_SELECTED_UI_MODE, UiMode.SYSTEM_DEFAULT.name)!!
|
val selectedUiModeName = prefs.getString(PREF_KEY_SELECTED_UI_MODE, UiMode.SYSTEM_DEFAULT.name)!!
|
||||||
var selectedUiMode: UiMode
|
var selectedUiMode: UiMode
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user