mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-08 12:06:52 +00:00
Use localized strings for UI mode dialog.
This commit is contained in:
parent
744e586cfe
commit
33876c2fc9
@ -1855,4 +1855,9 @@
|
|||||||
|
|
||||||
<string name="view_reset_secure_session_done_message">Secure session reset done</string>
|
<string name="view_reset_secure_session_done_message">Secure session reset done</string>
|
||||||
|
|
||||||
|
<string name="dialog_ui_mode_title">Application theme</string>
|
||||||
|
<string name="dialog_ui_mode_option_day">Day</string>
|
||||||
|
<string name="dialog_ui_mode_option_night">Night</string>
|
||||||
|
<string name="dialog_ui_mode_option_system_default">System default</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -4,10 +4,10 @@ import android.app.Dialog
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.loki.utilities.UiMode
|
import org.thoughtcrime.securesms.loki.utilities.UiMode
|
||||||
import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities
|
import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities
|
||||||
|
|
||||||
//TODO Use localized string resources.
|
|
||||||
class ChangeUiModeDialog : DialogFragment() {
|
class ChangeUiModeDialog : DialogFragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -17,7 +17,7 @@ class ChangeUiModeDialog : DialogFragment() {
|
|||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val context = requireContext()
|
val context = requireContext()
|
||||||
|
|
||||||
val displayNameList = UiMode.values().map { it.displayName }.toTypedArray()
|
val displayNameList = UiMode.values().map { getString(it.displayNameRes) }.toTypedArray()
|
||||||
val activeUiMode = UiModeUtilities.getUserSelectedUiMode(context)
|
val activeUiMode = UiModeUtilities.getUserSelectedUiMode(context)
|
||||||
|
|
||||||
return AlertDialog.Builder(context)
|
return AlertDialog.Builder(context)
|
||||||
@ -27,8 +27,8 @@ class ChangeUiModeDialog : DialogFragment() {
|
|||||||
dismiss()
|
dismiss()
|
||||||
requireActivity().recreate()
|
requireActivity().recreate()
|
||||||
}
|
}
|
||||||
.setTitle("Application theme")
|
.setTitle(R.string.dialog_ui_mode_title)
|
||||||
.setNegativeButton("Cancel") { _, _ -> dismiss() }
|
.setNegativeButton(R.string.cancel) { _, _ -> dismiss() }
|
||||||
.create()
|
.create()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,10 @@ 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.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import network.loki.messenger.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Day/night UI mode related utilities.
|
* Day/night UI mode related utilities.
|
||||||
@ -52,12 +54,12 @@ object UiModeUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Use localized string resources.
|
|
||||||
enum class UiMode(
|
enum class UiMode(
|
||||||
val displayName: String,
|
@StringRes
|
||||||
|
val displayNameRes: Int,
|
||||||
val nightModeValue: Int) {
|
val nightModeValue: Int) {
|
||||||
|
|
||||||
DAY("Day", AppCompatDelegate.MODE_NIGHT_NO),
|
DAY(R.string.dialog_ui_mode_option_day, AppCompatDelegate.MODE_NIGHT_NO),
|
||||||
NIGHT("Night", AppCompatDelegate.MODE_NIGHT_YES),
|
NIGHT(R.string.dialog_ui_mode_option_night, AppCompatDelegate.MODE_NIGHT_YES),
|
||||||
SYSTEM_DEFAULT("System default", AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
SYSTEM_DEFAULT(R.string.dialog_ui_mode_option_system_default, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user