From 83a36b327a14e042da1a7807dcd9cad6d483e941 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Thu, 27 Aug 2020 14:52:57 +1000 Subject: [PATCH] Use default shared preferences for UI mode utils. --- .../securesms/loki/dialogs/ChangeUiModeDialog.kt | 2 +- .../securesms/loki/utilities/UiModeUtilities.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/dialogs/ChangeUiModeDialog.kt b/src/org/thoughtcrime/securesms/loki/dialogs/ChangeUiModeDialog.kt index b9e2127fd9..964b254ab7 100644 --- a/src/org/thoughtcrime/securesms/loki/dialogs/ChangeUiModeDialog.kt +++ b/src/org/thoughtcrime/securesms/loki/dialogs/ChangeUiModeDialog.kt @@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities class ChangeUiModeDialog : DialogFragment() { companion object { - public const val TAG = "ChangeUiModeDialog" + const val TAG = "ChangeUiModeDialog" } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { diff --git a/src/org/thoughtcrime/securesms/loki/utilities/UiModeUtilities.kt b/src/org/thoughtcrime/securesms/loki/utilities/UiModeUtilities.kt index 0a24e5777a..9bc926050b 100644 --- a/src/org/thoughtcrime/securesms/loki/utilities/UiModeUtilities.kt +++ b/src/org/thoughtcrime/securesms/loki/utilities/UiModeUtilities.kt @@ -3,18 +3,18 @@ package org.thoughtcrime.securesms.loki.utilities import android.content.Context import android.content.res.Configuration import androidx.appcompat.app.AppCompatDelegate +import androidx.preference.PreferenceManager /** * Day/night UI mode related utilities. * @see Official Documentation */ object UiModeUtilities { - private const val PREF_FILE_NAME = "UiModeUtilities" private const val PREF_KEY_SELECTED_UI_MODE = "SELECTED_UI_MODE" @JvmStatic public fun setUserSelectedUiMode(context: Context, uiMode: UiMode) { - val prefs = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE) + val prefs = PreferenceManager.getDefaultSharedPreferences(context) prefs.edit() .putString(PREF_KEY_SELECTED_UI_MODE, uiMode.name) .apply() @@ -23,7 +23,7 @@ object UiModeUtilities { @JvmStatic 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)!! var selectedUiMode: UiMode try {