fixed language switching api smaller than 33

This commit is contained in:
Denis Çerri 2023-02-22 13:03:01 +01:00
parent 3937dd6e4c
commit ad452de1ae
No known key found for this signature in database
GPG key ID: 95C43D517D830350
6 changed files with 21 additions and 5 deletions

View file

@ -120,7 +120,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$appCompatVer"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'com.google.android.material:material:1.7.0'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'

View file

@ -97,6 +97,14 @@
<!-- android:exported="false" />-->
<receiver android:name=".receiver.CancelDownloadNotificationReceiver" />
<service
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
android:enabled="false"
android:exported="false">
<meta-data
android:name="autoStoreLocales"
android:value="true" />
</service>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.deniscerri.ytdl.fileprovider"

View file

@ -132,14 +132,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
val preferences =
requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
val editor = preferences.edit()
language!!.summary = Locale(preferences.getString("app_language", "")!!).getDisplayLanguage(Locale(preferences.getString("app_language", "")!!))
if(language!!.value == null) language!!.value = Locale.getDefault().language
language!!.summary = Locale(language!!.value).getDisplayLanguage(Locale(language!!.value))
language!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("app_language", newValue.toString())
language!!.summary = Locale(newValue.toString()).getDisplayLanguage(Locale(newValue.toString()))
editor.apply()
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(newValue.toString()))
(requireActivity() as SettingsActivity).setLocale(newValue.toString())
true
}

View file

@ -15,6 +15,12 @@
android:layout_marginVertical="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:text="@string/sort_by"
android:paddingBottom="20dp"
android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/date"
android:layout_width="match_parent"

View file

@ -164,7 +164,7 @@
<string name="logs">Logs</string>
<string name="commands">Commands</string>
<string name="date_added">Date added</string>
<string name="update_ytdl_nightly">Download Nightly Version of yt-dlp</string>
<string name="update_ytdl_nightly">Nightly Version of yt-dlp</string>
<string name="adjust_audio">Adjust Audio</string>
<string name="file_name_template">Filename Template</string>
<string name="language">Language</string>

View file

@ -5,8 +5,11 @@
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:color">@android:color/transparent</item>
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
<item name="dialogCornerRadius">28dp</item>
</style>
<style name="AppTheme" parent="AppDefaultTheme" />
<style name="Toolbar" parent="Theme.Material3.DayNight.NoActionBar">
@ -45,5 +48,4 @@
<item name="android:layout_marginEnd">5dp</item>
<item name="android:layout_marginStart">5dp</item>
</style>
</resources>