| 
														
															@@ -4,14 +4,18 @@ import android.app.Activity 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import android.content.Context 
														 | 
														
														 | 
														
															 import android.content.Context 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import android.os.Build 
														 | 
														
														 | 
														
															 import android.os.Build 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.annotation.StringRes 
														 | 
														
														 | 
														
															 import androidx.annotation.StringRes 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import androidx.appcompat.app.AppCompatDelegate 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.runtime.Composable 
														 | 
														
														 | 
														
															 import androidx.compose.runtime.Composable 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.runtime.LaunchedEffect 
														 | 
														
														 | 
														
															 import androidx.compose.runtime.LaunchedEffect 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.runtime.ReadOnlyComposable 
														 | 
														
														 | 
														
															 import androidx.compose.runtime.ReadOnlyComposable 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.runtime.getValue 
														 | 
														
														 | 
														
															 import androidx.compose.runtime.getValue 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import androidx.compose.runtime.mutableStateOf 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.runtime.remember 
														 | 
														
														 | 
														
															 import androidx.compose.runtime.remember 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import androidx.compose.runtime.setValue 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.ui.platform.LocalContext 
														 | 
														
														 | 
														
															 import androidx.compose.ui.platform.LocalContext 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.compose.ui.res.stringResource 
														 | 
														
														 | 
														
															 import androidx.compose.ui.res.stringResource 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import androidx.core.app.ActivityCompat 
														 | 
														
														 | 
														
															 import androidx.core.app.ActivityCompat 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import androidx.core.os.LocaleListCompat 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.domain.ui.UiPreferences 
														 | 
														
														 | 
														
															 import eu.kanade.domain.ui.UiPreferences 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.domain.ui.model.TabletUiMode 
														 | 
														
														 | 
														
															 import eu.kanade.domain.ui.model.TabletUiMode 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.domain.ui.model.ThemeMode 
														 | 
														
														 | 
														
															 import eu.kanade.domain.ui.model.ThemeMode 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -19,10 +23,12 @@ import eu.kanade.domain.ui.model.setAppCompatDelegateThemeMode 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.presentation.more.settings.Preference 
														 | 
														
														 | 
														
															 import eu.kanade.presentation.more.settings.Preference 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.presentation.util.collectAsState 
														 | 
														
														 | 
														
															 import eu.kanade.presentation.util.collectAsState 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.tachiyomi.R 
														 | 
														
														 | 
														
															 import eu.kanade.tachiyomi.R 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import eu.kanade.tachiyomi.util.system.LocaleHelper 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import eu.kanade.tachiyomi.util.system.toast 
														 | 
														
														 | 
														
															 import eu.kanade.tachiyomi.util.system.toast 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import kotlinx.coroutines.flow.collectLatest 
														 | 
														
														 | 
														
															 import kotlinx.coroutines.flow.collectLatest 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import kotlinx.coroutines.flow.drop 
														 | 
														
														 | 
														
															 import kotlinx.coroutines.flow.drop 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import kotlinx.coroutines.flow.merge 
														 | 
														
														 | 
														
															 import kotlinx.coroutines.flow.merge 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.xmlpull.v1.XmlPullParser 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import uy.kohesive.injekt.Injekt 
														 | 
														
														 | 
														
															 import uy.kohesive.injekt.Injekt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import uy.kohesive.injekt.api.get 
														 | 
														
														 | 
														
															 import uy.kohesive.injekt.api.get 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.util.Date 
														 | 
														
														 | 
														
															 import java.util.Date 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -103,9 +109,30 @@ object SettingsAppearanceScreen : SearchableSettings { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         context: Context, 
														 | 
														
														 | 
														
															         context: Context, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         uiPreferences: UiPreferences, 
														 | 
														
														 | 
														
															         uiPreferences: UiPreferences, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ): Preference.PreferenceGroup { 
														 | 
														
														 | 
														
															     ): Preference.PreferenceGroup { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        val langs = remember { getLangs(context) } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        LaunchedEffect(currentLanguage) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            val locale = if (currentLanguage.isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                LocaleListCompat.getEmptyLocaleList() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                LocaleListCompat.forLanguageTags(currentLanguage) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            AppCompatDelegate.setApplicationLocales(locale) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return Preference.PreferenceGroup( 
														 | 
														
														 | 
														
															         return Preference.PreferenceGroup( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             title = stringResource(R.string.pref_category_display), 
														 | 
														
														 | 
														
															             title = stringResource(R.string.pref_category_display), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             preferenceItems = listOf( 
														 | 
														
														 | 
														
															             preferenceItems = listOf( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                Preference.PreferenceItem.BasicListPreference( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    value = currentLanguage, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    title = stringResource(R.string.pref_app_language), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    entries = langs, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    onValueChanged = { newValue -> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        currentLanguage = newValue 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        true 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    }, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 Preference.PreferenceItem.ListPreference( 
														 | 
														
														 | 
														
															                 Preference.PreferenceItem.ListPreference( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     pref = uiPreferences.tabletUiMode(), 
														 | 
														
														 | 
														
															                     pref = uiPreferences.tabletUiMode(), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     title = stringResource(R.string.pref_tablet_ui_mode), 
														 | 
														
														 | 
														
															                     title = stringResource(R.string.pref_tablet_ui_mode), 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -146,6 +173,31 @@ object SettingsAppearanceScreen : SearchableSettings { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             ), 
														 | 
														
														 | 
														
															             ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ) 
														 | 
														
														 | 
														
															         ) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private fun getLangs(context: Context): Map<String, String> { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        val langs = mutableListOf<Pair<String, String>>() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        val parser = context.resources.getXml(R.xml.locales_config) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        var eventType = parser.eventType 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        while (eventType != XmlPullParser.END_DOCUMENT) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (eventType == XmlPullParser.START_TAG && parser.name == "locale") { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                for (i in 0 until parser.attributeCount) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    if (parser.getAttributeName(i) == "name") { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        val langTag = parser.getAttributeValue(i) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        val displayName = LocaleHelper.getDisplayName(langTag) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        if (displayName.isNotEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                            langs.add(Pair(langTag, displayName)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            eventType = parser.next() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        langs.sortBy { it.second } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        langs.add(0, Pair("", context.getString(R.string.label_default))) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return langs.toMap() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 private val DateFormats = listOf( 
														 | 
														
														 | 
														
															 private val DateFormats = listOf( 
														 |