mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Migrated the previously chosen language in AppCompatDelegate
so that previously selected language will remains active.
This commit is contained in:
parent
1ad708c110
commit
c951dac7c2
@ -25,11 +25,13 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import androidx.core.os.ConfigurationCompat
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
@ -142,6 +144,16 @@ class KiwixMainActivity : CoreMainActivity() {
|
||||
handleNotificationIntent(intent)
|
||||
handleGetContentIntent(intent)
|
||||
activityKiwixMainBinding.root.applyEdgeToEdgeInsets()
|
||||
migratedToPerAppLanguage()
|
||||
}
|
||||
|
||||
private fun migratedToPerAppLanguage() {
|
||||
if (!sharedPreferenceUtil.perAppLanguageMigrated) {
|
||||
AppCompatDelegate.setApplicationLocales(
|
||||
LocaleListCompat.forLanguageTags(sharedPreferenceUtil.prefLanguage)
|
||||
)
|
||||
sharedPreferenceUtil.putPerAppLanguageMigration(true)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun migrateInternalToPublicAppDirectory() {
|
||||
|
@ -106,6 +106,9 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
|
||||
val prefIsAppDirectoryMigrated: Boolean
|
||||
get() = sharedPreferences.getBoolean(PREF_APP_DIRECTORY_TO_PUBLIC_MIGRATED, false)
|
||||
|
||||
val perAppLanguageMigrated: Boolean
|
||||
get() = sharedPreferences.getBoolean(PER_APP_LANGUAGE_MIGRATION, false)
|
||||
|
||||
val prefStorage: String
|
||||
get() {
|
||||
val storage = sharedPreferences.getString(PREF_STORAGE, null)
|
||||
@ -159,6 +162,9 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
|
||||
fun putPrefDeviceDefaultLanguage(language: String) =
|
||||
sharedPreferences.edit { putString(PREF_DEVICE_DEFAULT_LANG, language) }
|
||||
|
||||
fun putPerAppLanguageMigration(isMigrated: Boolean) =
|
||||
sharedPreferences.edit { putBoolean(PER_APP_LANGUAGE_MIGRATION, isMigrated) }
|
||||
|
||||
fun putPrefIsFirstRun(isFirstRun: Boolean) =
|
||||
sharedPreferences.edit { putBoolean(PREF_IS_FIRST_RUN, isFirstRun) }
|
||||
|
||||
@ -334,5 +340,6 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
|
||||
private const val PREF_LATER_CLICKED_MILLIS = "pref_later_clicked_millis"
|
||||
const val PREF_LAST_DONATION_POPUP_SHOWN_IN_MILLISECONDS =
|
||||
"pref_last_donation_shown_in_milliseconds"
|
||||
const val PER_APP_LANGUAGE_MIGRATION = "per_app_language_migration"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user