From ab03edcedbdae24f36b626c2dc8a16703eca033f Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Sun, 29 Dec 2024 13:28:48 +0400 Subject: [PATCH] Respect Arabic setting for Audio Manager This patch applies a temporary fix for the audio manager screen not respecting the proper locale. The entire method of enforcing locale within the app needs to be revisited in the near future in sha' Allah. --- .../java/com/quran/labs/androidquran/QuranApplication.kt | 5 +++-- .../quran/labs/androidquran/common/ui/LanguageEnforcer.kt | 7 +++++++ .../mobile/feature/downloadmanager/AudioManagerActivity.kt | 4 +++- .../downloadmanager/SheikhAudioDownloadsActivity.kt | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 common/ui/core/src/main/java/com/quran/labs/androidquran/common/ui/LanguageEnforcer.kt diff --git a/app/src/main/java/com/quran/labs/androidquran/QuranApplication.kt b/app/src/main/java/com/quran/labs/androidquran/QuranApplication.kt index 613f6f4bd5..b5085407fc 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranApplication.kt +++ b/app/src/main/java/com/quran/labs/androidquran/QuranApplication.kt @@ -6,6 +6,7 @@ import android.content.res.Resources import androidx.appcompat.app.AppCompatDelegate import androidx.work.Configuration import androidx.work.WorkManager +import com.quran.labs.androidquran.common.ui.LanguageEnforcer import com.quran.labs.androidquran.core.worker.QuranWorkerFactory import com.quran.labs.androidquran.di.component.application.ApplicationComponent import com.quran.labs.androidquran.di.component.application.DaggerApplicationComponent @@ -18,7 +19,7 @@ import timber.log.Timber import java.util.Locale import javax.inject.Inject -open class QuranApplication : Application(), QuranApplicationComponentProvider { +open class QuranApplication : Application(), QuranApplicationComponentProvider, LanguageEnforcer { lateinit var applicationComponent: ApplicationComponent @Inject lateinit var quranWorkerFactory: QuranWorkerFactory @@ -58,7 +59,7 @@ open class QuranApplication : Application(), QuranApplicationComponentProvider { ) } - fun refreshLocale( + override fun refreshLocale( context: Context, force: Boolean ) { diff --git a/common/ui/core/src/main/java/com/quran/labs/androidquran/common/ui/LanguageEnforcer.kt b/common/ui/core/src/main/java/com/quran/labs/androidquran/common/ui/LanguageEnforcer.kt new file mode 100644 index 0000000000..ce56d137d0 --- /dev/null +++ b/common/ui/core/src/main/java/com/quran/labs/androidquran/common/ui/LanguageEnforcer.kt @@ -0,0 +1,7 @@ +package com.quran.labs.androidquran.common.ui + +import android.content.Context + +interface LanguageEnforcer { + fun refreshLocale(context: Context, force: Boolean) +} diff --git a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt index cc134707ee..f67c414906 100644 --- a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt +++ b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt @@ -20,6 +20,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.quran.labs.androidquran.common.audio.model.QariItem +import com.quran.labs.androidquran.common.ui.LanguageEnforcer import com.quran.labs.androidquran.common.ui.core.QuranTheme import com.quran.mobile.di.QuranApplicationComponentProvider import com.quran.mobile.feature.downloadmanager.di.DownloadManagerComponentInterface @@ -30,13 +31,14 @@ import com.quran.mobile.feature.downloadmanager.ui.common.DownloadManagerToolbar import kotlinx.collections.immutable.persistentListOf import javax.inject.Inject - class AudioManagerActivity : ComponentActivity() { @Inject lateinit var audioManagerPresenter: AudioManagerPresenter override fun onCreate(savedInstanceState: Bundle?) { + (application as? LanguageEnforcer)?.refreshLocale(this, false) + super.onCreate(savedInstanceState) val injector = (application as? QuranApplicationComponentProvider) diff --git a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/SheikhAudioDownloadsActivity.kt b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/SheikhAudioDownloadsActivity.kt index 7b147b0a89..34fba39817 100644 --- a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/SheikhAudioDownloadsActivity.kt +++ b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/SheikhAudioDownloadsActivity.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.core.app.ActivityCompat import com.quran.common.search.SearchTextUtil +import com.quran.labs.androidquran.common.ui.LanguageEnforcer import com.quran.labs.androidquran.common.ui.core.QuranTheme import com.quran.mobile.di.QuranApplicationComponentProvider import com.quran.mobile.feature.downloadmanager.di.DownloadManagerComponentInterface @@ -66,6 +67,8 @@ class SheikhAudioDownloadsActivity : ComponentActivity() { } override fun onCreate(savedInstanceState: Bundle?) { + (application as? LanguageEnforcer)?.refreshLocale(this, false) + super.onCreate(savedInstanceState) qariId = intent.getIntExtra(EXTRA_QARI_ID, -1) if (qariId < 0) {