From 0324927b04d384797f2e03df5acb1edbba922f8d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Sep 2022 15:20:23 +0200 Subject: [PATCH] Create VectorLocaleProvider, to just read the current Locale from the SharedPreference --- .../app/core/platform/VectorBaseActivity.kt | 10 +++-- .../features/call/conference/JitsiService.kt | 4 +- .../call/dialpad/CallDialPadBottomSheet.kt | 4 +- .../features/call/dialpad/PstnDialActivity.kt | 1 - .../call/transfer/CallTransferPagerAdapter.kt | 4 +- .../configuration/VectorConfiguration.kt | 4 +- .../setup/KeysBackupSetupStep2Fragment.kt | 4 +- .../BootstrapEnterPassphraseFragment.kt | 4 +- .../app/features/home/HomeDetailFragment.kt | 4 +- .../notifications/NotificationUtils.kt | 1 - .../app/features/rageshake/BugReporter.kt | 4 +- .../app/features/settings/VectorLocale.kt | 7 ++-- .../features/settings/VectorLocaleProvider.kt | 41 +++++++++++++++++++ 13 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/settings/VectorLocaleProvider.kt diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index fbcfd69610..0b8d6698d2 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -84,7 +84,7 @@ import im.vector.app.features.rageshake.RageShake import im.vector.app.features.session.SessionListener import im.vector.app.features.settings.FontScalePreferences import im.vector.app.features.settings.FontScalePreferencesImpl -import im.vector.app.features.settings.VectorLocale +import im.vector.app.features.settings.VectorLocaleProvider import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.themes.ActivityOtherThemes import im.vector.app.features.themes.ThemeUtils @@ -156,7 +156,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver @Inject lateinit var rageShake: RageShake @Inject lateinit var buildMeta: BuildMeta @Inject lateinit var fontScalePreferences: FontScalePreferences - @Inject lateinit var vectorLocale: VectorLocale + @Inject lateinit var vectorLocale: VectorLocaleProvider // For debug only @Inject lateinit var debugReceiver: DebugReceiver @@ -178,8 +178,10 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver private val restorables = ArrayList() override fun attachBaseContext(base: Context) { - val fontScalePreferences = FontScalePreferencesImpl(PreferenceManager.getDefaultSharedPreferences(base), AndroidSystemSettingsProvider(base)) - val vectorConfiguration = VectorConfiguration(this, fontScalePreferences, vectorLocale) + val preferences = PreferenceManager.getDefaultSharedPreferences(base) + val fontScalePreferences = FontScalePreferencesImpl(preferences, AndroidSystemSettingsProvider(base)) + val vectorLocaleProvider = VectorLocaleProvider(preferences) + val vectorConfiguration = VectorConfiguration(this, fontScalePreferences, vectorLocaleProvider) super.attachBaseContext(vectorConfiguration.getLocalisedContext(base)) } diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt index bdb6cfb0d0..d14f358801 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt @@ -25,7 +25,7 @@ import im.vector.app.core.utils.toBase32String import im.vector.app.features.call.conference.jwt.JitsiJWTFactory import im.vector.app.features.displayname.getBestName import im.vector.app.features.raw.wellknown.getElementWellknown -import im.vector.app.features.settings.VectorLocale +import im.vector.app.features.settings.VectorLocaleProvider import im.vector.app.features.themes.ThemeProvider import okhttp3.Request import org.jitsi.meet.sdk.JitsiMeetUserInfo @@ -49,7 +49,7 @@ class JitsiService @Inject constructor( private val themeProvider: ThemeProvider, private val jitsiJWTFactory: JitsiJWTFactory, private val clock: Clock, - private val vectorLocale: VectorLocale, + private val vectorLocale: VectorLocaleProvider, ) { companion object { diff --git a/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt b/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt index be38f7d509..c157ee42b8 100644 --- a/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt @@ -25,7 +25,7 @@ import im.vector.app.R import im.vector.app.core.extensions.addChildFragment import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.databinding.BottomSheetCallDialPadBinding -import im.vector.app.features.settings.VectorLocale +import im.vector.app.features.settings.VectorLocaleProvider import javax.inject.Inject @AndroidEntryPoint @@ -44,7 +44,7 @@ class CallDialPadBottomSheet : VectorBaseBottomSheetDialogFragment