Restart the app to apply the new language setting.

This commit is contained in:
Greyson Parrelli
2025-12-22 10:46:39 -05:00
committed by jeffrey-signal
parent 952990c8af
commit 4c47f337ea
4 changed files with 12 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ import androidx.compose.ui.res.vectorResource
import androidx.fragment.app.viewModels
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.fragment.findNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.signal.core.ui.compose.DayNightPreviews
import org.signal.core.ui.compose.Previews
import org.signal.core.ui.compose.Rows
@@ -60,7 +61,11 @@ class AppearanceSettingsFragment : ComposeFragment() {
}
override fun onLanguageSelected(selection: String) {
viewModel.setLanguage(selection)
MaterialAlertDialogBuilder(requireContext())
.setMessage(R.string.preferences_language_change_confirmation_message)
.setPositiveButton(android.R.string.ok) { _, _ -> viewModel.setLanguage(selection) }
.setNegativeButton(android.R.string.cancel, null)
.show()
}
override fun onThemeSelected(selection: String) {

View File

@@ -5,6 +5,8 @@ import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import org.signal.core.util.AppUtil
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob
import org.thoughtcrime.securesms.keyvalue.SettingsValues.Theme
import org.thoughtcrime.securesms.keyvalue.SignalStore
@@ -28,6 +30,7 @@ class AppearanceSettingsViewModel : ViewModel() {
store.update { it.copy(language = language) }
SignalStore.settings.language = language
EmojiSearchIndexDownloadJob.scheduleImmediately()
AppUtil.restart(AppDependencies.application)
}
fun setMessageFontSize(size: Int) {

View File

@@ -599,7 +599,7 @@ public class TextSecurePreferences {
*/
@Deprecated
public static void setLanguage(Context context, String language) {
setStringPreference(context, LANGUAGE_PREF, language);
getSharedPreferences(context).edit().putString(LANGUAGE_PREF, language).commit();
}
@Deprecated

View File

@@ -4189,6 +4189,8 @@
<string name="preferences_normal">Normal</string>
<!-- Preference summary for compact navigation bar size -->
<string name="preferences_compact">Compact</string>
<!-- Dialog message body explaining that we have to restart the app in order to apply the user's new language setting. -->
<string name="preferences_language_change_confirmation_message">The app will restart to apply the new language setting.</string>
<string name="configurable_single_select__customize_option">Customize option</string>