From 05ef74da5d68a055618f81e13aae061acee1ad49 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 10:09:38 -0500 Subject: [PATCH 01/45] Removed experimental per app language feature flag --- .../org/wordpress/android/AppInitializer.kt | 6 +-- .../android/ui/LocaleAwareActivity.kt | 23 +--------- .../android/ui/prefs/AppSettingsFragment.java | 27 +++--------- .../ui/prefs/ExperimentalFeaturesActivity.kt | 21 +--------- .../android/util/PerAppLocaleManager.kt | 42 +++++++------------ 5 files changed, 26 insertions(+), 93 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt index 47794b4c4e30..f4bc6eb1eca5 100644 --- a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt +++ b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt @@ -952,11 +952,7 @@ class AppInitializer @Inject constructor( override fun onConfigurationChanged(newConfig: Configuration) { // If per-app locale is enabled make sure the in-app locale is correct, // otherwise reapply in-app locale on configuration change - if (perAppLocaleManager.isPerAppLanguagePrefsEnabled()) { - perAppLocaleManager.checkAndUpdateOldLanguagePrefKey() - } else { - LocaleManager.setLocale(context) - } + perAppLocaleManager.checkAndUpdateOldLanguagePrefKey() } override fun onLowMemory() { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt index a5ec8bca5b63..300870d7967a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt @@ -3,9 +3,6 @@ package org.wordpress.android.ui import android.content.Context import android.content.res.Configuration import androidx.appcompat.app.AppCompatActivity -import org.wordpress.android.ui.prefs.AppPrefs -import org.wordpress.android.util.LocaleManager -import org.wordpress.android.util.PerAppLocaleManager /** * Newer versions of the AppCompat library no longer support locale changes at application level, @@ -27,29 +24,13 @@ abstract class LocaleAwareActivity : AppCompatActivity() { * Used to update locales on API 21 to API 25. */ override fun attachBaseContext(newBase: Context?) { - if (isPerAppLocaleEnabled()) { - super.attachBaseContext(newBase) - } else { - super.attachBaseContext(LocaleManager.setLocale(newBase)) - } + super.attachBaseContext(newBase) } /** * Used to update locales on API 26 and beyond. */ override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) { - if (isPerAppLocaleEnabled()) { - super.applyOverrideConfiguration(overrideConfiguration) - } else { - super.applyOverrideConfiguration(LocaleManager.updatedConfigLocale(baseContext, overrideConfiguration)) - } - } - - /** - * Ideally we would use [PerAppLocaleManager.isPerAppLanguagePrefsEnabled] here, but we - * can't inject [PerAppLocaleManager] into an abstract class - */ - private fun isPerAppLocaleEnabled(): Boolean { - return AppPrefs.getManualFeatureConfig(PerAppLocaleManager.EXPERIMENTAL_PER_APP_LANGUAGE_PREF_KEY) + super.applyOverrideConfiguration(overrideConfiguration) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index f7226a5d2a3a..bcfea2e40f7a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -49,7 +49,6 @@ import org.wordpress.android.ui.deeplinks.DeepLinkOpenWebLinksWithJetpackHelper; import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper; import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredBottomSheetFragment; -import org.wordpress.android.util.PerAppLocaleManager; import org.wordpress.android.ui.prefs.language.LocalePickerBottomSheet; import org.wordpress.android.ui.prefs.language.LocalePickerBottomSheet.LocalePickerCallback; import org.wordpress.android.ui.reader.services.update.ReaderUpdateLogic; @@ -64,6 +63,7 @@ import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.LocaleProvider; import org.wordpress.android.util.NetworkUtils; +import org.wordpress.android.util.PerAppLocaleManager; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.WPActivityUtils; import org.wordpress.android.util.WPPrefUtils; @@ -101,7 +101,6 @@ public class AppSettingsFragment extends PreferenceFragment private WPSwitchPreference mOpenWebLinksWithJetpack; private Preference mWhatsNew; - private Boolean mIsPerAppLanguagePrefsEnabled; @Inject SiteStore mSiteStore; @Inject AccountStore mAccountStore; @@ -125,8 +124,6 @@ public void onCreate(@Nullable Bundle savedInstanceState) { ((WordPress) getActivity().getApplication()).component().inject(this); mDispatcher.register(this); - mIsPerAppLanguagePrefsEnabled = mPerAppLocaleManager.isPerAppLanguagePrefsEnabled(); - addPreferencesFromResource(R.xml.app_settings); findPreference(getString(R.string.pref_key_send_usage)).setOnPreferenceChangeListener( @@ -259,11 +256,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, mLanguagePreference = (WPPreference) findPreference(getString(R.string.pref_key_language)); mLanguagePreference.setOnPreferenceChangeListener(this); mLanguagePreference.setOnPreferenceClickListener(this); - if (mIsPerAppLanguagePrefsEnabled) { - mLanguagePreference.setSummary(mPerAppLocaleManager.getCurrentLocaleDisplayName()); - } else { - mLanguagePreference.setSummary(mLocaleProvider.getAppLanguageDisplayString()); - } + mLanguagePreference.setSummary(mPerAppLocaleManager.getCurrentLocaleDisplayName()); return view; } @@ -436,10 +429,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { return false; } - if (preference == mLanguagePreference) { - changeLanguage(newValue.toString()); - return false; - } else if (preference == mOptimizedImage) { + if (preference == mOptimizedImage) { AppPrefs.setImageOptimize((Boolean) newValue); mImageMaxSizePref.setEnabled((Boolean) newValue); Map properties = new HashMap<>(); @@ -648,9 +638,8 @@ private boolean handleFeatureAnnouncementClick() { } private boolean handleAppLocalePickerClick() { - // if per-app language preferences are enabled and the device is on API 33+, take the user to the - // system app settings to change the language - if (mIsPerAppLanguagePrefsEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + // if the device is on API 33+, take the user to the system app settings to change the language + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { mPerAppLocaleManager.openAppLanguageSettings(getContext()); return true; } else if (getActivity() instanceof AppCompatActivity) { @@ -678,11 +667,7 @@ private void reattachLocalePickerCallback() { @Override public void onLocaleSelected(@NonNull String languageCode) { - if (mIsPerAppLanguagePrefsEnabled) { - mPerAppLocaleManager.setCurrentLocaleByLanguageCode(languageCode); - } else { - onPreferenceChange(mLanguagePreference, languageCode); - } + mPerAppLocaleManager.setCurrentLocaleByLanguageCode(languageCode); } private void handleOpenLinksInJetpack(Boolean newValue) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/ExperimentalFeaturesActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/ExperimentalFeaturesActivity.kt index 5ab5227464f4..736f7baf388a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/ExperimentalFeaturesActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/ExperimentalFeaturesActivity.kt @@ -32,7 +32,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.ViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow @@ -40,14 +39,11 @@ import kotlinx.coroutines.flow.update import org.wordpress.android.R import org.wordpress.android.ui.compose.theme.AppThemeM3 import org.wordpress.android.ui.compose.unit.Margin -import org.wordpress.android.util.PerAppLocaleManager import org.wordpress.android.util.extensions.setContent -import javax.inject.Inject val experimentalFeatures = listOf( Feature(key = "experimental_block_editor"), Feature(key = "experimental_block_editor_theme_styles"), - Feature(key = PerAppLocaleManager.EXPERIMENTAL_PER_APP_LANGUAGE_PREF_KEY) ) data class Feature( @@ -55,10 +51,7 @@ data class Feature( val key: String, ) -@HiltViewModel -class FeatureViewModel @Inject constructor( - private val perAppLocaleManager: PerAppLocaleManager -) : ViewModel() { +class FeatureViewModel : ViewModel() { private val _switchStates = MutableStateFlow>(emptyMap()) val switchStates: StateFlow> = _switchStates.asStateFlow() @@ -76,18 +69,6 @@ class FeatureViewModel @Inject constructor( AppPrefs.setManualFeatureConfig(enabled, key) } } - - featureToggled(key, enabled) - } - - private fun featureToggled(key: String, enabled: Boolean) { - if (key == PerAppLocaleManager.EXPERIMENTAL_PER_APP_LANGUAGE_PREF_KEY) { - if (enabled) { - perAppLocaleManager.performMigrationIfNecessary() - } else { - perAppLocaleManager.resetApplicationLocale() - } - } } } diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index d6958dcde54b..b59c4c9fe2a6 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -77,33 +77,27 @@ class PerAppLocaleManager @Inject constructor( * Previously the app locale was stored in SharedPreferences, so here we migrate to AndroidX per-app language prefs */ fun performMigrationIfNecessary() { - if (isPerAppLanguagePrefsEnabled()) { - if (isApplicationLocaleEmpty()) { - val prefKey = LocaleManager.getLocalePrefKeyString() - val previousLanguage = appPrefsWrapper.getPrefString(prefKey, "") - if (previousLanguage?.isNotEmpty() == true) { - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" - ) - setCurrentLocaleByLanguageCode(previousLanguage) - } else { - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: setting default locale" - ) - setCurrentLocaleByLanguageCode(Locale.getDefault().language) - } + if (isApplicationLocaleEmpty()) { + val prefKey = LocaleManager.getLocalePrefKeyString() + val previousLanguage = appPrefsWrapper.getPrefString(prefKey, "") + if (previousLanguage?.isNotEmpty() == true) { + appLogWrapper.d( + AppLog.T.SETTINGS, + "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" + ) + setCurrentLocaleByLanguageCode(previousLanguage) } else { - checkAndUpdateOldLanguagePrefKey() + appLogWrapper.d( + AppLog.T.SETTINGS, + "PerAppLocaleManager: setting default locale" + ) + setCurrentLocaleByLanguageCode(Locale.getDefault().language) } + } else { + checkAndUpdateOldLanguagePrefKey() } } - fun isPerAppLanguagePrefsEnabled(): Boolean { - return appPrefsWrapper.getManualFeatureConfig(EXPERIMENTAL_PER_APP_LANGUAGE_PREF_KEY) - } - /** * Open the app settings dialog so the user can change the app language. * Note that the per-app language setting is only available in API 33+ @@ -117,8 +111,4 @@ class PerAppLocaleManager @Inject constructor( context.startActivity(intent) } } - - companion object { - const val EXPERIMENTAL_PER_APP_LANGUAGE_PREF_KEY = "experimental_per_app_language_prefs" - } } From d29660807e25591864baae3f326092d50aaeadfe Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 10:19:44 -0500 Subject: [PATCH 02/45] Moved language change to PerAppLocaleManager --- .../android/ui/prefs/AppSettingsFragment.java | 41 +------------------ .../android/util/PerAppLocaleManager.kt | 40 +++++++++++++++++- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index bcfea2e40f7a..9522a579d8d1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -13,7 +13,6 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.preference.SwitchPreference; -import android.text.TextUtils; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -51,8 +50,6 @@ import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredBottomSheetFragment; import org.wordpress.android.ui.prefs.language.LocalePickerBottomSheet; import org.wordpress.android.ui.prefs.language.LocalePickerBottomSheet.LocalePickerCallback; -import org.wordpress.android.ui.reader.services.update.ReaderUpdateLogic; -import org.wordpress.android.ui.reader.services.update.ReaderUpdateServiceStarter; import org.wordpress.android.ui.utils.UiHelpers; import org.wordpress.android.ui.whatsnew.FeatureAnnouncementDialogFragment; import org.wordpress.android.ui.whatsnew.FeatureAnnouncementProvider; @@ -60,7 +57,6 @@ import org.wordpress.android.util.AppThemeUtils; import org.wordpress.android.util.BuildConfigWrapper; import org.wordpress.android.util.JetpackBrandingUtils; -import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.LocaleProvider; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.PerAppLocaleManager; @@ -71,9 +67,7 @@ import org.wordpress.android.viewmodel.ContextProvider; import java.util.Collections; -import java.util.EnumSet; import java.util.HashMap; -import java.util.Locale; import java.util.Map; import javax.inject.Inject; @@ -493,39 +487,6 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { return super.onOptionsItemSelected(item); } - private void changeLanguage(String languageCode) { - if (mLanguagePreference == null || TextUtils.isEmpty(languageCode)) { - return; - } - - if (LocaleManager.isSameLanguage(languageCode)) { - return; - } - - LocaleManager.setNewLocale(WordPress.getContext(), languageCode); - WordPress.updateContextLocale(); - mContextProvider.refreshContext(); - - // Track language change on Analytics because we have both the device language and app selected language - // data in Tracks metadata. - Map properties = new HashMap<>(); - properties.put("app_locale", Locale.getDefault()); - AnalyticsTracker.track(Stat.ACCOUNT_SETTINGS_LANGUAGE_CHANGED, properties); - - // Language is now part of metadata, so we need to refresh them - AnalyticsUtils.refreshMetadata(mAccountStore, mSiteStore); - - // Refresh the app - Intent refresh = new Intent(getActivity(), getActivity().getClass()); - startActivity(refresh); - getActivity().setResult(LANGUAGE_CHANGED); - getActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - getActivity().finish(); - - // update Reader tags as they need be localized - ReaderUpdateServiceStarter.startService(WordPress.getContext(), EnumSet.of(ReaderUpdateLogic.UpdateTask.TAGS)); - } - private boolean handleDevicePreferenceClick() { try { // open specific app info screen @@ -667,7 +628,7 @@ private void reattachLocalePickerCallback() { @Override public void onLocaleSelected(@NonNull String languageCode) { - mPerAppLocaleManager.setCurrentLocaleByLanguageCode(languageCode); + mPerAppLocaleManager.onLanguageChanged(languageCode); } private void handleOpenLinksInJetpack(Boolean newValue) { diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index b59c4c9fe2a6..edefcc22de66 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -8,8 +8,16 @@ import android.provider.Settings import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatDelegate import androidx.core.os.LocaleListCompat +import org.wordpress.android.WordPress.Companion.getContext +import org.wordpress.android.analytics.AnalyticsTracker +import org.wordpress.android.fluxc.store.AccountStore +import org.wordpress.android.fluxc.store.SiteStore import org.wordpress.android.fluxc.utils.AppLogWrapper import org.wordpress.android.ui.prefs.AppPrefsWrapper +import org.wordpress.android.ui.reader.services.update.ReaderUpdateLogic.UpdateTask +import org.wordpress.android.ui.reader.services.update.ReaderUpdateServiceStarter +import org.wordpress.android.util.analytics.AnalyticsUtils +import java.util.EnumSet import java.util.Locale import javax.inject.Inject @@ -20,6 +28,8 @@ import javax.inject.Inject class PerAppLocaleManager @Inject constructor( private val appPrefsWrapper: AppPrefsWrapper, private val appLogWrapper: AppLogWrapper, + private val siteStore: SiteStore, + private val accountStore: AccountStore, ) { private fun getCurrentLocale(): Locale { return if (isApplicationLocaleEmpty()) { @@ -31,6 +41,8 @@ class PerAppLocaleManager @Inject constructor( fun getCurrentLocaleDisplayName(): String = getCurrentLocale().displayName + fun getCurrentLocaleLanguageCode(): String = getCurrentLocale().language + /** * Important: this should only be called after Activity.onCreate() * https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getApplicationLocales() @@ -65,7 +77,7 @@ class PerAppLocaleManager @Inject constructor( AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList()) } - fun setCurrentLocaleByLanguageCode(languageCode: String) { + private fun setCurrentLocaleByLanguageCode(languageCode: String) { // We shouldn't have to replace "_" with "-" but this is in order to work with our existing language picker // on pre-Android 13 devices val appLocale = LocaleListCompat.forLanguageTags(languageCode.replace("_", "-")) @@ -111,4 +123,30 @@ class PerAppLocaleManager @Inject constructor( context.startActivity(intent) } } + + /** + * Called when the device language is changed from our in-app language picker + * TODO: Detect when language changed from app settings dialog + */ + fun onLanguageChanged(languageCode: String) { + if (languageCode.isEmpty()) { + return + } + + if (languageCode.equals(getCurrentLocaleLanguageCode()).not()) { + setCurrentLocaleByLanguageCode(languageCode) + } + + // Track language change on Analytics because we have both the device language and app selected language + // data in Tracks metadata. + val properties: MutableMap = HashMap() + properties["app_locale"] = languageCode + AnalyticsTracker.track(AnalyticsTracker.Stat.ACCOUNT_SETTINGS_LANGUAGE_CHANGED, properties) + + // Language is now part of metadata, so we need to refresh them + AnalyticsUtils.refreshMetadata(accountStore, siteStore) + + // update Reader tags as they need be localized + ReaderUpdateServiceStarter.startService(getContext(), EnumSet.of(UpdateTask.TAGS)) + } } From e9110cbe0f6fde1fe1516c10bd1af8e3f17ff6b7 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 10:20:40 -0500 Subject: [PATCH 03/45] Updated comment --- .../wordpress/android/ui/LocaleAwareActivity.kt | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt index 300870d7967a..6e6507746610 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt @@ -5,19 +5,9 @@ import android.content.res.Configuration import androidx.appcompat.app.AppCompatActivity /** - * Newer versions of the AppCompat library no longer support locale changes at application level, - * so this activity is used to help handle those changes at activity level. - * Reference: https://issuetracker.google.com/issues/141869006#comment9 - * - * All the actual logic is inside the LocaleManager class, which should be used directly in cases where - * extending from this class is not possible/preferable. - * - * Note: please be mindful of the principle of favoring composition over inheritance and refrain from - * building upon this class unless it's absolutely necessary. - * * Update Dec 2024: We've added experimental support for per-app language preferences which - * will eventually negate the need for this class. Instead of extending from this class, we - * should extend from AppCompatActivity once this feature is out of the experimental phase. + * negate the need for this class. Instead of extending from this class, we should extend + * from AppCompatActivity. */ abstract class LocaleAwareActivity : AppCompatActivity() { /** From a0d8a8105989977def473cbb80ec4b49292e9ec2 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 10:25:50 -0500 Subject: [PATCH 04/45] Removed string res --- WordPress/src/main/res/values/strings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index f684997cc9d3..76db2f186275 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -963,7 +963,6 @@ Experimental Features Experimental block editor Experimental block editor styles - Experimental per-app language preferences Debug Settings From 7d1b932d603acef54c33d0a109eeb19d3bfae100 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 10:43:55 -0500 Subject: [PATCH 05/45] Updated comments --- .../src/main/java/org/wordpress/android/AppInitializer.kt | 3 +-- .../main/java/org/wordpress/android/ui/LocaleAwareActivity.kt | 4 ++-- .../java/org/wordpress/android/util/PerAppLocaleManager.kt | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt index f4bc6eb1eca5..e3b7fb142355 100644 --- a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt +++ b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt @@ -950,8 +950,7 @@ class AppInitializer @Inject constructor( */ private inner class MemoryAndConfigChangeMonitor : ComponentCallbacks2 { override fun onConfigurationChanged(newConfig: Configuration) { - // If per-app locale is enabled make sure the in-app locale is correct, - // otherwise reapply in-app locale on configuration change + // Make sure the in-app locale is correct perAppLocaleManager.checkAndUpdateOldLanguagePrefKey() } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt index 6e6507746610..15afe4f33862 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt @@ -5,8 +5,8 @@ import android.content.res.Configuration import androidx.appcompat.app.AppCompatActivity /** - * Update Dec 2024: We've added experimental support for per-app language preferences which - * negate the need for this class. Instead of extending from this class, we should extend + * Update Dec 2024: We've added support for per-app language preferences which negate + * the need for this class. Instead of extending from this class, we should extend * from AppCompatActivity. */ abstract class LocaleAwareActivity : AppCompatActivity() { diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index edefcc22de66..822abcb43cf8 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -133,6 +133,7 @@ class PerAppLocaleManager @Inject constructor( return } + // Only update if the language is different if (languageCode.equals(getCurrentLocaleLanguageCode()).not()) { setCurrentLocaleByLanguageCode(languageCode) } From 3dfe5de15a714c315d124656f2bbc9bc62afd967 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:07:00 -0500 Subject: [PATCH 06/45] First pass at removing LocaleAwareActivity.kt --- .../android/designsystem/DesignSystemActivity.kt | 4 ++-- .../android/ui/AddQuickPressShortcutActivity.java | 2 +- .../org/wordpress/android/ui/AppLogViewerActivity.java | 2 +- .../android/ui/JetpackConnectionResultActivity.java | 2 +- .../org/wordpress/android/ui/LocaleAwareActivity.kt | 2 +- .../android/ui/ShareIntentReceiverActivity.java | 2 +- .../java/org/wordpress/android/ui/WPLaunchActivity.kt | 2 +- .../java/org/wordpress/android/ui/WebViewActivity.java | 2 +- .../wordpress/android/ui/about/UnifiedAboutActivity.kt | 4 ++-- .../org/wordpress/android/ui/accounts/HelpActivity.kt | 4 ++-- .../wordpress/android/ui/accounts/LoginActivity.java | 8 ++++---- .../android/ui/accounts/LoginEpilogueActivity.java | 4 ++-- .../ui/accounts/LoginMagicLinkInterceptActivity.java | 4 ++-- .../ui/accounts/PostSignupInterstitialActivity.kt | 4 ++-- .../android/ui/accounts/SignupEpilogueActivity.java | 4 ++-- .../ui/activitylog/detail/ActivityLogDetailActivity.kt | 4 ++-- .../ui/activitylog/list/ActivityLogListActivity.kt | 4 ++-- .../blazecampaigns/BlazeCampaignParentActivity.kt | 4 ++-- .../blaze/blazepromote/BlazePromoteParentActivity.kt | 4 ++-- .../promptslist/BloggingPromptsListActivity.kt | 4 ++-- .../android/ui/comments/CommentsDetailActivity.java | 8 ++++---- .../ui/comments/unified/UnifiedCommentsActivity.kt | 4 ++-- .../comments/unified/UnifiedCommentsDetailsActivity.kt | 4 ++-- .../ui/comments/unified/UnifiedCommentsEditActivity.kt | 4 ++-- .../android/ui/debug/DebugSettingsActivity.kt | 4 ++-- .../android/ui/debug/cookies/DebugCookiesActivity.kt | 4 ++-- .../deeplinks/DeepLinkingIntentReceiverActivity.java | 8 ++++---- .../android/ui/domains/DomainRegistrationActivity.kt | 4 ++-- .../android/ui/domains/DomainsDashboardActivity.kt | 4 ++-- .../android/ui/engagement/EngagedPeopleListActivity.kt | 4 ++-- .../android/ui/history/HistoryDetailActivity.kt | 4 ++-- .../jetpack/backup/download/BackupDownloadActivity.kt | 4 ++-- .../android/ui/jetpack/restore/RestoreActivity.kt | 4 ++-- .../remoteplugin/JetpackRemoteInstallActivity.kt | 4 ++-- .../wordpress/android/ui/main/ChooseSiteActivity.kt | 4 ++-- .../java/org/wordpress/android/ui/main/MeActivity.kt | 4 ++-- .../org/wordpress/android/ui/main/WPMainActivity.java | 4 ++-- .../ui/main/feedbackform/FeedbackFormActivity.kt | 4 ++-- .../jetpack/migration/JetpackMigrationViewModel.kt | 2 +- .../android/ui/media/MediaBrowserActivity.java | 4 ++-- .../android/ui/media/MediaPreviewActivity.java | 4 ++-- .../android/ui/media/MediaSettingsActivity.java | 4 ++-- .../android/ui/mediapicker/MediaPickerActivity.kt | 4 ++-- .../ui/notifications/NotificationsDetailActivity.java | 8 ++++---- .../wordpress/android/ui/pages/PageParentActivity.kt | 4 ++-- .../org/wordpress/android/ui/pages/PagesActivity.kt | 4 ++-- .../android/ui/people/PeopleManagementActivity.java | 4 ++-- .../android/ui/photopicker/PhotoPickerActivity.java | 4 ++-- .../org/wordpress/android/ui/plans/PlansActivity.kt | 4 ++-- .../android/ui/plugins/PluginBrowserActivity.java | 4 ++-- .../android/ui/plugins/PluginDetailActivity.java | 4 ++-- .../org/wordpress/android/ui/posts/EditPostActivity.kt | 4 ++-- .../android/ui/posts/PostSettingsTagsActivity.java | 4 ++-- .../wordpress/android/ui/posts/PostsListActivity.kt | 4 ++-- .../android/ui/posts/SelectCategoriesActivity.java | 4 ++-- .../android/ui/prefs/AccountSettingsActivity.java | 4 ++-- .../wordpress/android/ui/prefs/AppSettingsActivity.kt | 4 ++-- .../android/ui/prefs/BlogPreferencesActivity.java | 4 ++-- .../wordpress/android/ui/prefs/MyProfileActivity.java | 4 ++-- .../android/ui/prefs/SiteSettingsTagListActivity.java | 4 ++-- .../prefs/categories/detail/CategoryDetailActivity.kt | 4 ++-- .../ui/prefs/categories/list/CategoriesListActivity.kt | 4 ++-- .../notifications/NotificationsSettingsActivity.kt | 4 ++-- .../android/ui/publicize/PublicizeListActivity.java | 4 ++-- .../android/ui/qrcodeauth/QRCodeAuthActivity.kt | 4 ++-- .../android/ui/reader/ReaderCommentListActivity.java | 10 +++++----- .../android/ui/reader/ReaderPhotoViewerActivity.java | 4 ++-- .../android/ui/reader/ReaderPostListActivity.java | 4 ++-- .../android/ui/reader/ReaderPostPagerActivity.java | 8 ++++---- .../android/ui/reader/ReaderSearchActivity.kt | 4 ++-- .../android/ui/reader/ReaderSubsActivity.java | 4 ++-- .../android/ui/reader/ReaderUserListActivity.java | 4 ++-- .../android/ui/reader/ReaderVideoViewerActivity.java | 4 ++-- .../discover/interests/ReaderInterestsActivity.kt | 4 ++-- .../ui/selfhostedusers/SelfHostedUsersActivity.kt | 4 ++-- .../android/ui/sitecreation/SiteCreationActivity.kt | 4 ++-- .../android/ui/stats/StatsConnectJetpackActivity.kt | 4 ++-- .../android/ui/stats/refresh/StatsActivity.kt | 4 ++-- .../android/ui/stats/refresh/StatsViewAllActivity.kt | 4 ++-- .../stats/refresh/lists/detail/StatsDetailActivity.kt | 4 ++-- .../insights/management/InsightsManagementActivity.kt | 4 ++-- .../alltime/StatsAllTimeWidgetConfigureActivity.kt | 4 ++-- .../minified/StatsMinifiedWidgetConfigureActivity.kt | 4 ++-- .../widget/today/StatsTodayWidgetConfigureActivity.kt | 4 ++-- .../widget/views/StatsViewsWidgetConfigureActivity.kt | 4 ++-- .../widget/weeks/StatsWeekWidgetConfigureActivity.kt | 4 ++-- .../ui/stockmedia/StockMediaPickerActivity.java | 6 +++--- .../android/ui/suggestion/SuggestionActivity.kt | 4 ++-- .../android/ui/themes/ThemeBrowserActivity.java | 4 ++-- 89 files changed, 184 insertions(+), 184 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/designsystem/DesignSystemActivity.kt b/WordPress/src/main/java/org/wordpress/android/designsystem/DesignSystemActivity.kt index cdfca9f87357..4266ff70ae13 100644 --- a/WordPress/src/main/java/org/wordpress/android/designsystem/DesignSystemActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/designsystem/DesignSystemActivity.kt @@ -5,10 +5,10 @@ import android.os.Bundle import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.util.extensions.setContent -class DesignSystemActivity : LocaleAwareActivity() { +class DesignSystemActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java index dcaa0d31f6d5..563b9fb1cb92 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java @@ -44,7 +44,7 @@ import javax.inject.Inject; -public class AddQuickPressShortcutActivity extends LocaleAwareActivity { +public class AddQuickPressShortcutActivity extends AppCompatActivity { public String[] blogNames; public int[] siteIds; public String[] blogUrls; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java index 3ec77481e49c..1cbf808b91dc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java @@ -35,7 +35,7 @@ /** * views the activity log (see utils/AppLog.java) */ -public class AppLogViewerActivity extends LocaleAwareActivity { +public class AppLogViewerActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java index f83839062fbc..2f3c1432046e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java @@ -39,7 +39,7 @@ *

* Redirects users to the stats activity if the jetpack connection was succesful */ -public class JetpackConnectionResultActivity extends LocaleAwareActivity { +public class JetpackConnectionResultActivity extends AppCompatActivity { private static final String ALREADY_CONNECTED = "already-connected"; private static final String REASON_PARAM = "reason"; private static final String SOURCE_PARAM = "source"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt index 15afe4f33862..1e5f793112b9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt @@ -9,7 +9,7 @@ import androidx.appcompat.app.AppCompatActivity * the need for this class. Instead of extending from this class, we should extend * from AppCompatActivity. */ -abstract class LocaleAwareActivity : AppCompatActivity() { +abstract class AppCompatActivity : AppCompatActivity() { /** * Used to update locales on API 21 to API 25. */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java index 28edf0b25bab..c856e10d5118 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java @@ -43,7 +43,7 @@ * Moreover it lists what actions the user can perform and redirects the user to the activity, * along with the content passed in the intent. */ -public class ShareIntentReceiverActivity extends LocaleAwareActivity implements ShareIntentFragmentListener { +public class ShareIntentReceiverActivity extends AppCompatActivity implements ShareIntentFragmentListener { private static final String SHARE_LAST_USED_BLOG_ID_KEY = "wp-settings-share-last-used-text-blogid"; private static final String KEY_SELECTED_SITE_LOCAL_ID = "KEY_SELECTED_SITE_LOCAL_ID"; private static final String KEY_SHARE_ACTION_ID = "KEY_SHARE_ACTION_ID"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt index 79ad71aaca2b..2dd91a1b440a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt @@ -12,7 +12,7 @@ import org.wordpress.android.util.ProfilingUtils import org.wordpress.android.util.ToastUtils @SuppressLint("CustomSplashScreen") -class WPLaunchActivity : LocaleAwareActivity() { +class WPLaunchActivity : AppCompatActivity() { /* * this the main (default) activity, which does nothing more than launch the * previously active activity on startup - note that it's defined in the diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java index c71e716e6f3d..92a3c9af3b46 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java @@ -25,7 +25,7 @@ /** * Basic activity for displaying a WebView. */ -public abstract class WebViewActivity extends LocaleAwareActivity { +public abstract class WebViewActivity extends AppCompatActivity { /** * Primary webview used to display content. */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/about/UnifiedAboutActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/about/UnifiedAboutActivity.kt index 0d79d353b1dd..da3f5ae91f47 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/about/UnifiedAboutActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/about/UnifiedAboutActivity.kt @@ -5,13 +5,13 @@ import com.automattic.about.model.AboutConfigProvider import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.about.UnifiedAboutNavigationAction.Dismiss import org.wordpress.android.ui.about.UnifiedAboutNavigationAction.OpenBlog import org.wordpress.android.viewmodel.observeEvent import javax.inject.Inject -class UnifiedAboutActivity : LocaleAwareActivity(), AboutConfigProvider { +class UnifiedAboutActivity : AppCompatActivity(), AboutConfigProvider { @Inject lateinit var viewModel: UnifiedAboutViewModel diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt index 373d3ebac9bc..058631609ba1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt @@ -35,7 +35,7 @@ import org.wordpress.android.support.ZendeskHelper import org.wordpress.android.ui.ActivityId import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.AppLogViewerActivity -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.debug.DebugSettingsActivity import org.wordpress.android.ui.main.utils.MeGravatarLoader import org.wordpress.android.ui.prefs.AppPrefs @@ -50,7 +50,7 @@ import javax.inject.Inject import android.R as AndroidR @AndroidEntryPoint -class HelpActivity : LocaleAwareActivity() { +class HelpActivity : AppCompatActivity() { @Inject lateinit var accountStore: AccountStore diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index bb4aee4850b8..c57298505ded 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java @@ -9,6 +9,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; @@ -49,7 +50,6 @@ import org.wordpress.android.support.ZendeskHelper; import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.ui.JetpackConnectionSource; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.accounts.HelpActivity.Origin; import org.wordpress.android.ui.accounts.LoginNavigationEvents.ShowNoJetpackSites; @@ -87,15 +87,15 @@ import javax.inject.Inject; +import static org.wordpress.android.util.ActivityUtils.hideKeyboard; + import dagger.android.AndroidInjector; import dagger.android.DispatchingAndroidInjector; import dagger.android.HasAndroidInjector; import dagger.hilt.android.AndroidEntryPoint; -import static org.wordpress.android.util.ActivityUtils.hideKeyboard; - @AndroidEntryPoint -public class LoginActivity extends LocaleAwareActivity implements ConnectionCallbacks, OnConnectionFailedListener, +public class LoginActivity extends AppCompatActivity implements ConnectionCallbacks, OnConnectionFailedListener, Callback, LoginListener, GoogleListener, LoginPrologueListener, HasAndroidInjector, BasicDialogPositiveClickInterface { public static final String ARG_JETPACK_CONNECT_SOURCE = "ARG_JETPACK_CONNECT_SOURCE"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java index 79f8c6140185..03e4f978d998 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java @@ -4,6 +4,7 @@ import android.os.Bundle; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; @@ -12,7 +13,6 @@ import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.accounts.LoginNavigationEvents.CloseWithResultOk; import org.wordpress.android.ui.accounts.LoginNavigationEvents.CreateNewSite; @@ -35,7 +35,7 @@ import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint -public class LoginEpilogueActivity extends LocaleAwareActivity implements LoginEpilogueListener { +public class LoginEpilogueActivity extends AppCompatActivity implements LoginEpilogueListener { public static final String EXTRA_DO_LOGIN_UPDATE = "EXTRA_DO_LOGIN_UPDATE"; public static final String EXTRA_SHOW_AND_RETURN = "EXTRA_SHOW_AND_RETURN"; public static final String ARG_OLD_SITES_IDS = "ARG_OLD_SITES_IDS"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java index b9c04c8eb213..4c0cbb58d67b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java @@ -5,10 +5,10 @@ import android.os.Bundle; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.login.LoginAnalyticsListener; import org.wordpress.android.ui.JetpackConnectionSource; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.main.WPMainActivity; import javax.inject.Inject; @@ -20,7 +20,7 @@ * or signup based on deep link scheme, host, and parameters. */ @AndroidEntryPoint -public class LoginMagicLinkInterceptActivity extends LocaleAwareActivity { +public class LoginMagicLinkInterceptActivity extends AppCompatActivity { private static final String PARAMETER_FLOW = "flow"; private static final String PARAMETER_FLOW_JETPACK = "jetpack"; private static final String PARAMETER_SOURCE = "source"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt index fb54be449500..a0a3feb0dd0a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt @@ -8,7 +8,7 @@ import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.databinding.PostSignupInterstitialActivityBinding import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.jetpackoverlay.individualplugin.WPJetpackIndividualPluginFragment import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel @@ -21,7 +21,7 @@ import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel. import javax.inject.Inject @AndroidEntryPoint -class PostSignupInterstitialActivity : LocaleAwareActivity() { +class PostSignupInterstitialActivity : AppCompatActivity() { @Inject lateinit var viewModelFactory: ViewModelProvider.Factory private lateinit var viewModel: PostSignupInterstitialViewModel diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java index dae2831880dc..3bf57c44f271 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java @@ -3,12 +3,12 @@ import android.os.Bundle; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentTransaction; import org.wordpress.android.R; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.accounts.signup.SignupEpilogueFragment; import org.wordpress.android.ui.accounts.signup.SignupEpilogueListener; @@ -17,7 +17,7 @@ import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint -public class SignupEpilogueActivity extends LocaleAwareActivity implements SignupEpilogueListener { +public class SignupEpilogueActivity extends AppCompatActivity implements SignupEpilogueListener { public static final String EXTRA_SIGNUP_DISPLAY_NAME = "EXTRA_SIGNUP_DISPLAY_NAME"; public static final String EXTRA_SIGNUP_EMAIL_ADDRESS = "EXTRA_SIGNUP_EMAIL_ADDRESS"; public static final String EXTRA_SIGNUP_IS_EMAIL = "EXTRA_SIGNUP_IS_EMAIL"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt index 568c3712edf5..a97d83af50e1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt @@ -5,12 +5,12 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.ActivityLogDetailActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes import android.R as AndroidR @AndroidEntryPoint -class ActivityLogDetailActivity : LocaleAwareActivity() { +class ActivityLogDetailActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt index fac1258d5ada..aad049b6cd1c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt @@ -9,7 +9,7 @@ import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.databinding.ActivityLogListActivityBinding import org.wordpress.android.models.JetpackPoweredScreen -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.ScrollableViewInitializedListener import org.wordpress.android.ui.activitylog.detail.ActivityLogDetailActivity @@ -27,7 +27,7 @@ import javax.inject.Inject import android.R as AndroidR @AndroidEntryPoint -class ActivityLogListActivity : LocaleAwareActivity(), ScrollableViewInitializedListener { +class ActivityLogListActivity : AppCompatActivity(), ScrollableViewInitializedListener { @Inject lateinit var jetpackBrandingUtils: JetpackBrandingUtils diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/BlazeCampaignParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/BlazeCampaignParentActivity.kt index 76f3d042d1a1..4011cffa7fd7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/BlazeCampaignParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/BlazeCampaignParentActivity.kt @@ -4,7 +4,7 @@ import android.os.Bundle import androidx.activity.viewModels import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.blaze.blazecampaigns.campaigndetail.CampaignDetailFragment import org.wordpress.android.ui.blaze.blazecampaigns.campaignlisting.CampaignListingFragment import org.wordpress.android.util.extensions.getParcelableCompat @@ -13,7 +13,7 @@ import org.wordpress.android.util.extensions.getParcelableExtraCompat const val ARG_EXTRA_BLAZE_CAMPAIGN_PAGE = "blaze_campaign_page" @AndroidEntryPoint -class BlazeCampaignParentActivity : LocaleAwareActivity() { +class BlazeCampaignParentActivity : AppCompatActivity() { private val viewModel: CampaignViewModel by viewModels() private var campaignPage: BlazeCampaignPage? = null diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt index 3660fa62a21b..56516e97759a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt @@ -4,7 +4,7 @@ import android.os.Bundle import androidx.activity.viewModels import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.blaze.BlazeFlowSource import org.wordpress.android.ui.blaze.BlazeUIModel import org.wordpress.android.ui.blaze.BlazeUiState @@ -20,7 +20,7 @@ const val ARG_BLAZE_FLOW_SOURCE = "blaze_flow_source" const val ARG_BLAZE_SHOULD_SHOW_OVERLAY = "blaze_flow_should_show_overlay" @AndroidEntryPoint -class BlazePromoteParentActivity : LocaleAwareActivity() { +class BlazePromoteParentActivity : AppCompatActivity() { private val viewModel: BlazeViewModel by viewModels() private var shouldShowOverlay = false private var source: BlazeFlowSource = BlazeFlowSource.DASHBOARD_CARD diff --git a/WordPress/src/main/java/org/wordpress/android/ui/bloggingprompts/promptslist/BloggingPromptsListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/bloggingprompts/promptslist/BloggingPromptsListActivity.kt index 4492bdc88912..cd2f23c20c74 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/bloggingprompts/promptslist/BloggingPromptsListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/bloggingprompts/promptslist/BloggingPromptsListActivity.kt @@ -11,14 +11,14 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.bloggingprompts.promptslist.compose.BloggingPromptsListScreen import org.wordpress.android.ui.compose.theme.AppThemeM3 import org.wordpress.android.ui.posts.PostUtils import org.wordpress.android.util.extensions.setContent @AndroidEntryPoint -class BloggingPromptsListActivity : LocaleAwareActivity() { +class BloggingPromptsListActivity : AppCompatActivity() { private val viewModel: BloggingPromptsListViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java index 346897f63d4c..77543537c991 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java @@ -11,6 +11,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager.widget.ViewPager; import org.greenrobot.eventbus.Subscribe; @@ -28,7 +29,6 @@ import org.wordpress.android.fluxc.store.CommentStore.OnCommentChanged; import org.wordpress.android.models.CommentList; import org.wordpress.android.ui.CollapseFullScreenDialogFragment; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.ScrollableViewInitializedListener; import org.wordpress.android.ui.comments.unified.CommentConstants; import org.wordpress.android.ui.comments.unified.CommentsStoreAdapter; @@ -43,10 +43,10 @@ import javax.inject.Inject; -import dagger.hilt.android.AndroidEntryPoint; - import static org.wordpress.android.ui.comments.unified.CommentConstants.COMMENTS_PER_PAGE; +import dagger.hilt.android.AndroidEntryPoint; + /** * @deprecated * Comments are being refactored as part of Comments Unification project. If you are adding any @@ -55,7 +55,7 @@ @Deprecated @AndroidEntryPoint @SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"}) -public class CommentsDetailActivity extends LocaleAwareActivity +public class CommentsDetailActivity extends AppCompatActivity implements OnLoadMoreListener, CommentActions.OnCommentActionListener, ScrollableViewInitializedListener { public static final String COMMENT_ID_EXTRA = "commentId"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsActivity.kt index 468adecc10b0..ddbb645f2166 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsActivity.kt @@ -13,7 +13,7 @@ import org.wordpress.android.WordPress import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat.COMMENT_FILTER_CHANGED import org.wordpress.android.databinding.UnifiedCommentActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.comments.unified.CommentFilter.ALL import org.wordpress.android.ui.comments.unified.CommentFilter.APPROVED import org.wordpress.android.ui.comments.unified.CommentFilter.PENDING @@ -27,7 +27,7 @@ import javax.inject.Inject import android.R as AndroidR import com.google.android.material.R as MaterialR -class UnifiedCommentsActivity : LocaleAwareActivity() { +class UnifiedCommentsActivity : AppCompatActivity() { @Inject lateinit var viewModelFactory: ViewModelProvider.Factory diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsDetailsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsDetailsActivity.kt index ecf927abc872..aa3f2fa785de 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsDetailsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsDetailsActivity.kt @@ -4,9 +4,9 @@ import android.os.Bundle import androidx.viewpager2.widget.ViewPager2 import org.wordpress.android.WordPress import org.wordpress.android.databinding.UnifiedCommentsDetailsActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity -class UnifiedCommentsDetailsActivity : LocaleAwareActivity() { +class UnifiedCommentsDetailsActivity : AppCompatActivity() { private var binding: UnifiedCommentsDetailsActivityBinding? = null private lateinit var pagerAdapter: UnifiedCommentsDetailPagerAdapter diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsEditActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsEditActivity.kt index d8a4e70dab6f..7f4ca3bf0db8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsEditActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/UnifiedCommentsEditActivity.kt @@ -7,11 +7,11 @@ import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.databinding.UnifiedCommentsEditActivityBinding import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.util.extensions.getParcelableExtraCompat import org.wordpress.android.util.extensions.getSerializableExtraCompat -class UnifiedCommentsEditActivity : LocaleAwareActivity() { +class UnifiedCommentsEditActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/debug/DebugSettingsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/debug/DebugSettingsActivity.kt index bd2ed4d6c75d..7530d497e515 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/debug/DebugSettingsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/debug/DebugSettingsActivity.kt @@ -9,14 +9,14 @@ import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.databinding.DebugSettingsActivityBinding import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.debug.previews.PreviewFragmentActivity.Companion.previewFragmentInActivity import org.wordpress.android.viewmodel.observeEvent import javax.inject.Inject import android.R as AndroidR @AndroidEntryPoint -class DebugSettingsActivity : LocaleAwareActivity() { +class DebugSettingsActivity : AppCompatActivity() { @Inject lateinit var viewModelFactory: ViewModelProvider.Factory diff --git a/WordPress/src/main/java/org/wordpress/android/ui/debug/cookies/DebugCookiesActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/debug/cookies/DebugCookiesActivity.kt index a4cdcc6179b1..d998d516e4e6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/debug/cookies/DebugCookiesActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/debug/cookies/DebugCookiesActivity.kt @@ -3,10 +3,10 @@ package org.wordpress.android.ui.debug.cookies import android.os.Bundle import android.view.MenuItem import org.wordpress.android.databinding.DebugCookiesActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR -class DebugCookiesActivity : LocaleAwareActivity() { +class DebugCookiesActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(DebugCookiesActivityBinding.inflate(layoutInflater).root) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java index 045e9d457b48..b705acfe9101 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java @@ -8,10 +8,10 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.ViewModelProvider; import org.wordpress.android.ui.ActivityLauncherWrapper; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureFullScreenOverlayFragment; import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureFullScreenOverlayViewModel; @@ -27,11 +27,11 @@ import javax.inject.Inject; -import dagger.hilt.android.AndroidEntryPoint; - import static org.wordpress.android.WordPress.getContext; import static org.wordpress.android.ui.main.WPMainActivity.ARG_BYPASS_MIGRATION; +import dagger.hilt.android.AndroidEntryPoint; + /** * An activity to handle deep linking and intercepting links like: *

@@ -40,7 +40,7 @@ * Redirects users to the reader activity along with IDs passed in the intent */ @AndroidEntryPoint -public class DeepLinkingIntentReceiverActivity extends LocaleAwareActivity { +public class DeepLinkingIntentReceiverActivity extends AppCompatActivity { @Inject DeepLinkNavigator mDeeplinkNavigator; @Inject DeepLinkUriUtils mDeepLinkUriUtils; @Inject ViewModelProvider.Factory mViewModelFactory; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt index 946730b9d311..b7fea869d283 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt @@ -10,7 +10,7 @@ import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.databinding.DomainRegistrationActivityBinding import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.ScrollableViewInitializedListener import org.wordpress.android.ui.domains.DomainRegistrationCheckoutWebViewActivity.OpenCheckout.CheckoutDetails import org.wordpress.android.ui.domains.DomainRegistrationCheckoutWebViewActivity.OpenPlans.PlanDetails @@ -26,7 +26,7 @@ import javax.inject.Inject import android.R as AndroidR @AndroidEntryPoint -class DomainRegistrationActivity : LocaleAwareActivity(), ScrollableViewInitializedListener { +class DomainRegistrationActivity : AppCompatActivity(), ScrollableViewInitializedListener { enum class DomainRegistrationPurpose { AUTOMATED_TRANSFER, CTA_DOMAIN_CREDIT_REDEMPTION, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsDashboardActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsDashboardActivity.kt index eedb9b041fdb..8536f954b158 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsDashboardActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainsDashboardActivity.kt @@ -3,10 +3,10 @@ package org.wordpress.android.ui.domains import android.os.Bundle import android.view.MenuItem import org.wordpress.android.databinding.DomainsDashboardActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR -class DomainsDashboardActivity : LocaleAwareActivity() { +class DomainsDashboardActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(DomainsDashboardActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListActivity.kt index fbf82600b5d3..337742517d9a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListActivity.kt @@ -5,13 +5,13 @@ import android.view.MenuItem import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.databinding.EngagedPeopleListActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.util.analytics.AnalyticsUtilsWrapper import org.wordpress.android.util.extensions.getParcelableExtraCompat import javax.inject.Inject import android.R as AndroidR -class EngagedPeopleListActivity : LocaleAwareActivity() { +class EngagedPeopleListActivity : AppCompatActivity() { @Inject lateinit var analyticsUtilsWrapper: AnalyticsUtilsWrapper diff --git a/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt index 09f053a4982a..7b8537fbd8d7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt @@ -6,12 +6,12 @@ import org.wordpress.android.R import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat import org.wordpress.android.databinding.HistoryDetailActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.history.HistoryListItem.Revision import org.wordpress.android.util.extensions.getParcelableCompat import org.wordpress.android.util.extensions.onBackPressedCompat -class HistoryDetailActivity : LocaleAwareActivity() { +class HistoryDetailActivity : AppCompatActivity() { companion object { const val KEY_HISTORY_DETAIL_FRAGMENT = "history_detail_fragment" } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/backup/download/BackupDownloadActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/backup/download/BackupDownloadActivity.kt index be6b84522c4d..caa252938fae 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/backup/download/BackupDownloadActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/backup/download/BackupDownloadActivity.kt @@ -3,10 +3,10 @@ package org.wordpress.android.ui.jetpack.backup.download import android.os.Bundle import android.view.MenuItem import org.wordpress.android.databinding.BackupDownloadActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR -class BackupDownloadActivity : LocaleAwareActivity() { +class BackupDownloadActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(BackupDownloadActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/restore/RestoreActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/restore/RestoreActivity.kt index 859bbfd34a4d..7a739671fed7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/restore/RestoreActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/restore/RestoreActivity.kt @@ -3,10 +3,10 @@ package org.wordpress.android.ui.jetpack.restore import android.os.Bundle import android.view.MenuItem import org.wordpress.android.databinding.RestoreActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR -class RestoreActivity : LocaleAwareActivity() { +class RestoreActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(RestoreActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/jetpackplugininstall/remoteplugin/JetpackRemoteInstallActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/jetpackplugininstall/remoteplugin/JetpackRemoteInstallActivity.kt index 07faece920ba..8e358b2b8cc1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/jetpackplugininstall/remoteplugin/JetpackRemoteInstallActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/jetpackplugininstall/remoteplugin/JetpackRemoteInstallActivity.kt @@ -15,7 +15,7 @@ import org.wordpress.android.login.LoginMode import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.JetpackConnectionSource import org.wordpress.android.ui.JetpackConnectionWebViewActivity -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.accounts.HelpActivity import org.wordpress.android.ui.accounts.LoginActivity @@ -32,7 +32,7 @@ import org.wordpress.android.util.extensions.onBackPressedCompat import org.wordpress.android.util.extensions.setContent @AndroidEntryPoint -class JetpackRemoteInstallActivity : LocaleAwareActivity() { +class JetpackRemoteInstallActivity : AppCompatActivity() { private val viewModel: JetpackRemoteInstallViewModel by viewModels() public override fun onCreate(savedInstanceState: Bundle?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/ChooseSiteActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/ChooseSiteActivity.kt index ba1dd84c0b22..c135a6572e46 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/ChooseSiteActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/ChooseSiteActivity.kt @@ -26,7 +26,7 @@ import org.wordpress.android.fluxc.store.SiteStore import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged import org.wordpress.android.fluxc.store.SiteStore.OnSiteRemoved import org.wordpress.android.ui.ActivityId -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.mysite.SelectedSiteRepository import org.wordpress.android.ui.prefs.AppPrefsWrapper @@ -43,7 +43,7 @@ import org.wordpress.android.widgets.WPDialogSnackbar import javax.inject.Inject @AndroidEntryPoint -class ChooseSiteActivity : LocaleAwareActivity() { +class ChooseSiteActivity : AppCompatActivity() { private val viewModel: SiteViewModel by viewModels() private val adapter = ChooseSiteAdapter() private val mode by lazy { SitePickerMode.valueOf(intent.getStringExtra(KEY_SITE_PICKER_MODE)!!) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt index 91d0a0207aa1..d8f742b5d13c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt @@ -5,13 +5,13 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.prefs.AppSettingsFragment.LANGUAGE_CHANGED import android.R as AndroidR @AndroidEntryPoint -class MeActivity : LocaleAwareActivity() { +class MeActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.me_activity) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index ea9f02ba0cb1..57154cce875d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -80,7 +80,7 @@ import org.wordpress.android.ui.ActivityNavigator; import org.wordpress.android.ui.JetpackConnectionSource; import org.wordpress.android.ui.JetpackConnectionWebViewActivity; -import org.wordpress.android.ui.LocaleAwareActivity; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.ui.PagePostCreationSourcesDetail; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.Shortcut; @@ -202,7 +202,7 @@ * Main activity which hosts sites, reader, me and notifications pages */ @AndroidEntryPoint -public class WPMainActivity extends LocaleAwareActivity implements +public class WPMainActivity extends AppCompatActivity implements OnPageListener, BottomNavController, BasicDialogPositiveClickInterface, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/feedbackform/FeedbackFormActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/feedbackform/FeedbackFormActivity.kt index c187a28ddc15..167d6710859f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/feedbackform/FeedbackFormActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/feedbackform/FeedbackFormActivity.kt @@ -8,11 +8,11 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import dagger.hilt.android.AndroidEntryPoint -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes @AndroidEntryPoint -class FeedbackFormActivity : LocaleAwareActivity() { +class FeedbackFormActivity : AppCompatActivity() { private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt index 29584be672ee..dda1b9350851 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt @@ -240,7 +240,7 @@ class JetpackMigrationViewModel @Inject constructor( migrationAnalyticsTracker.trackPleaseDeleteWordPressScreenShown() // We need to manually apply the app language for the Compose UI since the host JetpackMigrationActivity - // does not inherit from LocaleAwareActivity on purpose, in order to avoid possible issues + // does not inherit from AppCompatActivity on purpose, in order to avoid possible issues // when the Ui mode (dark/light) and the language are manually set by the user. emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 5896abf4dc14..20f6bbcc3704 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -30,6 +30,7 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView.OnQueryTextListener; @@ -64,7 +65,6 @@ import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged; import org.wordpress.android.push.NotificationType; import org.wordpress.android.ui.ActivityId; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper; import org.wordpress.android.ui.media.MediaGridFragment.MediaFilter; @@ -109,7 +109,7 @@ /** * The main activity in which the user can browse their media. */ -public class MediaBrowserActivity extends LocaleAwareActivity implements MediaGridListener, +public class MediaBrowserActivity extends AppCompatActivity implements MediaGridListener, OnQueryTextListener, OnActionExpandListener, WPMediaUtils.LaunchCameraCallback { public static final String ARG_BROWSER_TYPE = "media_browser_type"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java index 4a23c5d37a0d..f89c6c52fa12 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java @@ -15,6 +15,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityOptionsCompat; @@ -30,7 +31,6 @@ import org.wordpress.android.fluxc.model.MediaModel; import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.fluxc.store.MediaStore; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.ToastUtils; @@ -41,7 +41,7 @@ import javax.inject.Inject; -public class MediaPreviewActivity extends LocaleAwareActivity implements MediaPreviewFragment.OnMediaTappedListener { +public class MediaPreviewActivity extends AppCompatActivity implements MediaPreviewFragment.OnMediaTappedListener { private static final String ARG_ID_OR_URL_LIST = "id_list"; private static final String ARG_PREVIEW_TYPE = "preview_type"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java index b1fe511abc3b..b74a3cc30e2d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java @@ -71,7 +71,7 @@ import org.wordpress.android.fluxc.store.MediaStore; import org.wordpress.android.fluxc.store.MediaStore.MediaPayload; import org.wordpress.android.fluxc.store.MediaStore.OnMediaChanged; -import org.wordpress.android.ui.LocaleAwareActivity; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaPreviewActivity.MediaPreviewSwiped; import org.wordpress.android.ui.utils.AuthenticationUtils; @@ -109,7 +109,7 @@ import static org.wordpress.android.editor.EditorImageMetaData.ARG_EDITOR_IMAGE_METADATA; -public class MediaSettingsActivity extends LocaleAwareActivity +public class MediaSettingsActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback { private static final String ARG_MEDIA_LOCAL_ID = "media_local_id"; private static final String ARG_ID_LIST = "id_list"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/MediaPickerActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/MediaPickerActivity.kt index 4732b8ddac8e..c1075c513e08 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/MediaPickerActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/MediaPickerActivity.kt @@ -15,7 +15,7 @@ import org.wordpress.android.databinding.PhotoPickerActivityBinding import org.wordpress.android.fluxc.Dispatcher import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.store.MediaStore -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes.IMAGE_EDITOR_EDIT_IMAGE import org.wordpress.android.ui.RequestCodes.MEDIA_LIBRARY import org.wordpress.android.ui.RequestCodes.PHOTO_PICKER @@ -55,7 +55,7 @@ import java.io.File import javax.inject.Inject import android.R as AndroidR -class MediaPickerActivity : LocaleAwareActivity(), MediaPickerListener { +class MediaPickerActivity : AppCompatActivity(), MediaPickerListener { private var mediaCapturePath: String? = null private lateinit var mediaPickerSetup: MediaPickerSetup diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java index a85d3c1ee5ab..a43db3bf36cb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java @@ -11,6 +11,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.lifecycle.Lifecycle; @@ -36,7 +37,6 @@ import org.wordpress.android.push.GCMMessageHandler; import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.ui.CollapseFullScreenDialogFragment; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.ScrollableViewInitializedListener; import org.wordpress.android.ui.WPWebViewActivity; import org.wordpress.android.ui.comments.CommentActions; @@ -76,17 +76,17 @@ import javax.inject.Inject; -import dagger.hilt.android.AndroidEntryPoint; - import static org.wordpress.android.models.Note.NOTE_COMMENT_LIKE_TYPE; import static org.wordpress.android.models.Note.NOTE_COMMENT_TYPE; import static org.wordpress.android.models.Note.NOTE_FOLLOW_TYPE; import static org.wordpress.android.models.Note.NOTE_LIKE_TYPE; import static org.wordpress.android.ui.notifications.services.NotificationsUpdateServiceStarter.IS_TAPPED_ON_NOTIFICATION; +import dagger.hilt.android.AndroidEntryPoint; + @AndroidEntryPoint @SuppressWarnings("deprecation") -public class NotificationsDetailActivity extends LocaleAwareActivity implements +public class NotificationsDetailActivity extends AppCompatActivity implements CommentActions.OnNoteCommentActionListener, BasicFragmentDialog.BasicDialogPositiveClickInterface, ScrollableViewInitializedListener { private static final String ARG_TITLE = "activityTitle"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt index d30b477d80ba..4ee33effe5c7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt @@ -2,9 +2,9 @@ package org.wordpress.android.ui.pages import android.os.Bundle import org.wordpress.android.databinding.PagesParentActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity -class PageParentActivity : LocaleAwareActivity() { +class PageParentActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding = PagesParentActivityBinding.inflate(layoutInflater) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt index 60fd832f768c..d363323fa3ee 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt @@ -8,7 +8,7 @@ import org.wordpress.android.WordPress import org.wordpress.android.databinding.PagesActivityBinding import org.wordpress.android.push.NotificationType import org.wordpress.android.push.NotificationsProcessingService.ARG_NOTIFICATION_TYPE -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.notifications.SystemNotificationsTracker import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogNegativeClickInterface import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogPositiveClickInterface @@ -23,7 +23,7 @@ const val EXTRA_PAGE_REMOTE_ID_KEY = "extra_page_remote_id_key" const val EXTRA_PAGE_PARENT_ID_KEY = "extra_page_parent_id_key" const val EXTRA_PAGE_LIST_TYPE_KEY = "extra_page_list_type_key" -class PagesActivity : LocaleAwareActivity(), +class PagesActivity : AppCompatActivity(), BasicDialogPositiveClickInterface, BasicDialogNegativeClickInterface, PostResolutionOverlayListener { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java index ca3a29e92275..a3d331cc95f3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java @@ -9,6 +9,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -29,7 +30,6 @@ import org.wordpress.android.fluxc.store.SiteStore.OnUserRolesChanged; import org.wordpress.android.models.PeopleListFilter; import org.wordpress.android.models.Person; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.people.utils.PeopleUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.NetworkUtils; @@ -44,7 +44,7 @@ import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint -public class PeopleManagementActivity extends LocaleAwareActivity +public class PeopleManagementActivity extends AppCompatActivity implements PeopleListFragment.OnPersonSelectedListener, PeopleListFragment.OnFetchPeopleListener { private static final String KEY_PEOPLE_LIST_FRAGMENT = "people-list-fragment"; private static final String KEY_PERSON_DETAIL_FRAGMENT = "person-detail-fragment"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java index db908316a905..b5ced93084ca 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java @@ -11,6 +11,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -23,7 +24,6 @@ import org.wordpress.android.fluxc.store.MediaStore; import org.wordpress.android.imageeditor.preview.PreviewImageFragment; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaBrowserActivity; import org.wordpress.android.ui.media.MediaBrowserType; @@ -52,7 +52,7 @@ * {@link org.wordpress.android.ui.mediapicker.MediaPickerActivity} */ @Deprecated -public class PhotoPickerActivity extends LocaleAwareActivity +public class PhotoPickerActivity extends AppCompatActivity implements PhotoPickerFragment.PhotoPickerListener { private static final String PICKER_FRAGMENT_TAG = "picker_fragment_tag"; private static final String KEY_MEDIA_CAPTURE_PATH = "media_capture_path"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt index c903e7517a24..558b7ffe82a6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import org.wordpress.android.databinding.PlansActivityBinding import org.wordpress.android.fluxc.model.plans.PlanOffersModel import org.wordpress.android.ui.FullScreenDialogFragment -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.plans.PlansListFragment.PlansListInterface import org.wordpress.android.util.StringUtils -class PlansActivity : LocaleAwareActivity(), PlansListInterface { +class PlansActivity : AppCompatActivity(), PlansListInterface { public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(PlansActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java index 7fa8d41dbede..fb50e8c9f829 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java @@ -18,6 +18,7 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.Toolbar; @@ -37,7 +38,6 @@ import org.wordpress.android.fluxc.model.plugin.ImmutablePluginModel; import org.wordpress.android.models.networkresource.ListState; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.ColorUtils; @@ -59,7 +59,7 @@ import javax.inject.Inject; -public class PluginBrowserActivity extends LocaleAwareActivity +public class PluginBrowserActivity extends AppCompatActivity implements SearchView.OnQueryTextListener, MenuItem.OnActionExpandListener { @Inject ViewModelProvider.Factory mViewModelFactory; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java index af0326208eeb..c1cf20f2db42 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java @@ -63,7 +63,7 @@ import org.wordpress.android.fluxc.store.SiteStore.OnPlansFetched; import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.domains.DomainRegistrationActivity; import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose; @@ -103,7 +103,7 @@ import static org.wordpress.android.ui.plans.PlanUtilsKt.isDomainCreditAvailable; import static org.wordpress.android.util.DomainRegistrationUtilsKt.requestEmailValidation; -public class PluginDetailActivity extends LocaleAwareActivity implements OnDomainRegistrationRequestedListener, +public class PluginDetailActivity extends AppCompatActivity implements OnDomainRegistrationRequestedListener, BasicDialogPositiveClickInterface { public static final String KEY_PLUGIN_SLUG = "KEY_PLUGIN_SLUG"; private static final String KEY_IS_CONFIGURING_PLUGIN = "KEY_IS_CONFIGURING_PLUGIN"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt index 1f7e03f7c192..8a3dd57e2a5a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt @@ -123,7 +123,7 @@ import org.wordpress.android.networking.ConnectionChangeReceiver.ConnectionChang import org.wordpress.android.support.ZendeskHelper import org.wordpress.android.ui.ActivityId import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.PrivateAtCookieRefreshProgressDialog.Companion.dismissIfNecessary import org.wordpress.android.ui.PrivateAtCookieRefreshProgressDialog.Companion.isShowing import org.wordpress.android.ui.PrivateAtCookieRefreshProgressDialog.Companion.showIfNecessary @@ -263,7 +263,7 @@ import javax.inject.Inject import kotlin.math.max @Suppress("LargeClass") -class EditPostActivity : LocaleAwareActivity(), EditorFragmentActivity, EditorImageSettingsListener, +class EditPostActivity : AppCompatActivity(), EditorFragmentActivity, EditorImageSettingsListener, EditorImagePreviewListener, EditorEditMediaListener, EditorDragAndDropListener, EditorFragmentListener, ActivityCompat.OnRequestPermissionsResultCallback, PhotoPickerListener, EditorPhotoPickerListener, EditorMediaListener, EditPostActivityHook, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java index ae34f0b4a455..b05a8b8f4522 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java @@ -8,17 +8,17 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.SiteModel; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.extensions.CompatExtensionsKt; -public class PostSettingsTagsActivity extends LocaleAwareActivity implements TagsSelectedListener { +public class PostSettingsTagsActivity extends AppCompatActivity implements TagsSelectedListener { public static final String KEY_TAGS = "KEY_TAGS"; public static final String KEY_SELECTED_TAGS = "KEY_SELECTED_TAGS"; private SiteModel mSite; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt index e065f764c6bd..b3f5f94162b1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt @@ -32,7 +32,7 @@ import org.wordpress.android.push.NotificationType import org.wordpress.android.push.NotificationsProcessingService.ARG_NOTIFICATION_TYPE import org.wordpress.android.ui.ActivityId import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.ScrollableViewInitializedListener import org.wordpress.android.ui.blaze.BlazeFeatureUtils @@ -70,7 +70,7 @@ const val EXTRA_TARGET_POST_LOCAL_ID = "targetPostLocalId" const val STATE_KEY_PREVIEW_STATE = "stateKeyPreviewState" const val STATE_KEY_BOTTOMSHEET_POST_ID = "stateKeyBottomSheetPostId" -class PostsListActivity : LocaleAwareActivity(), +class PostsListActivity : AppCompatActivity(), EditPostActivityHook, PrepublishingBottomSheetListener, BasicDialogPositiveClickInterface, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java index 1c6c93ad2fa0..ae79a5445987 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java @@ -14,6 +14,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -34,7 +35,6 @@ import org.wordpress.android.fluxc.store.TaxonomyStore.OnTermUploaded; import org.wordpress.android.fluxc.store.TaxonomyStore.RemoteTermPayload; import org.wordpress.android.models.CategoryNode; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; @@ -52,7 +52,7 @@ import static org.wordpress.android.ui.posts.EditPostActivityConstants.EXTRA_POST_LOCAL_ID; import static org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper; -public class SelectCategoriesActivity extends LocaleAwareActivity { +public class SelectCategoriesActivity extends AppCompatActivity { public static final String KEY_SELECTED_CATEGORY_IDS = "KEY_SELECTED_CATEGORY_IDS"; private ListView mListView; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java index 4905c930cea7..f7ce4e61261b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java @@ -6,15 +6,15 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.R; -import org.wordpress.android.ui.LocaleAwareActivity; import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint -public class AccountSettingsActivity extends LocaleAwareActivity { +public class AccountSettingsActivity extends AppCompatActivity { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.kt index 14a44a5ae931..f70e298e0948 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.kt @@ -6,10 +6,10 @@ import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.databinding.AppSettingsActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity @AndroidEntryPoint -class AppSettingsActivity : LocaleAwareActivity() { +class AppSettingsActivity : AppCompatActivity() { private lateinit var binding: AppSettingsActivityBinding public override fun onCreate(savedInstanceState: Bundle?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java index 19f8339409d5..c8fc3a8d1b8c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java @@ -7,6 +7,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.apache.commons.text.StringEscapeUtils; @@ -23,7 +24,6 @@ import org.wordpress.android.fluxc.store.SiteStore.OnSiteDeleted; import org.wordpress.android.fluxc.store.SiteStore.OnSiteRemoved; import org.wordpress.android.networking.ConnectionChangeReceiver; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; @@ -33,7 +33,7 @@ /** * Activity for configuring blog specific settings. */ -public class BlogPreferencesActivity extends LocaleAwareActivity { +public class BlogPreferencesActivity extends AppCompatActivity { private static final String KEY_SETTINGS_FRAGMENT = "settings-fragment"; private SiteModel mSite; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java index 764528c999e2..f62839913e5f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java @@ -6,17 +6,17 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.Dispatcher; import org.wordpress.android.fluxc.store.AccountStore; -import org.wordpress.android.ui.LocaleAwareActivity; import javax.inject.Inject; -public class MyProfileActivity extends LocaleAwareActivity { +public class MyProfileActivity extends AppCompatActivity { @Inject Dispatcher mDispatcher; @Inject AccountStore mAccountStore; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java index 25994867ac1a..6bfdef2eb1a4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java @@ -21,6 +21,7 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.FragmentTransaction; @@ -43,7 +44,6 @@ import org.wordpress.android.fluxc.store.TaxonomyStore; import org.wordpress.android.fluxc.store.TaxonomyStore.OnTaxonomyChanged; import org.wordpress.android.ui.ActionableEmptyView; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; @@ -60,7 +60,7 @@ import javax.inject.Inject; -public class SiteSettingsTagListActivity extends LocaleAwareActivity +public class SiteSettingsTagListActivity extends AppCompatActivity implements SearchView.OnQueryTextListener, MenuItem.OnActionExpandListener, SiteSettingsTagDetailFragment.OnTagDetailListener { @Inject Dispatcher mDispatcher; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/detail/CategoryDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/detail/CategoryDetailActivity.kt index 12e8445daf9d..d6c98627bb54 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/detail/CategoryDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/detail/CategoryDetailActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.CategoryDetailActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class CategoryDetailActivity : LocaleAwareActivity() { +class CategoryDetailActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(CategoryDetailActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/list/CategoriesListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/list/CategoriesListActivity.kt index e06d19813d64..3c94594c202d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/list/CategoriesListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/categories/list/CategoriesListActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.SiteSettingsCategoriesListActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class CategoriesListActivity : LocaleAwareActivity() { +class CategoriesListActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(SiteSettingsCategoriesListActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.kt index 32a4f5910436..c0d489e47e93 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.kt @@ -20,7 +20,7 @@ import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat.NOTIFICATION_SETTINGS_APP_NOTIFICATIONS_DISABLED import org.wordpress.android.analytics.AnalyticsTracker.Stat.NOTIFICATION_SETTINGS_APP_NOTIFICATIONS_ENABLED import org.wordpress.android.modules.APPLICATION_SCOPE -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.notifications.NotificationEvents.NotificationsSettingsStatusChanged import org.wordpress.android.ui.prefs.notifications.PrefMainSwitchToolbarView.MainSwitchToolbarListener import org.wordpress.android.ui.prefs.notifications.usecase.UpdateNotificationSettingsUseCase @@ -29,7 +29,7 @@ import javax.inject.Named import android.R as AndroidR @AndroidEntryPoint -class NotificationsSettingsActivity : LocaleAwareActivity(), MainSwitchToolbarListener { +class NotificationsSettingsActivity : AppCompatActivity(), MainSwitchToolbarListener { @Inject lateinit var updateNotificationSettingsUseCase: UpdateNotificationSettingsUseCase diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java index 20eae91206d1..e39921ec1f7d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java @@ -9,6 +9,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; @@ -29,7 +30,6 @@ import org.wordpress.android.models.PublicizeConnection; import org.wordpress.android.models.PublicizeService; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.ScrollableViewInitializedListener; import org.wordpress.android.ui.publicize.PublicizeConstants.ConnectAction; import org.wordpress.android.ui.publicize.adapters.PublicizeServiceAdapter; @@ -48,7 +48,7 @@ import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint -public class PublicizeListActivity extends LocaleAwareActivity +public class PublicizeListActivity extends AppCompatActivity implements PublicizeActions.OnPublicizeActionListener, PublicizeServiceAdapter.OnServiceClickListener, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/qrcodeauth/QRCodeAuthActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/qrcodeauth/QRCodeAuthActivity.kt index 11b63c0223b6..0b1f9f546958 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/qrcodeauth/QRCodeAuthActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/qrcodeauth/QRCodeAuthActivity.kt @@ -5,10 +5,10 @@ import android.content.Intent import android.os.Bundle import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.QrcodeauthActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity @AndroidEntryPoint -class QRCodeAuthActivity : LocaleAwareActivity() { +class QRCodeAuthActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java index 9f99c10cd9cb..2cd1ee9e41d5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java @@ -20,6 +20,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentManager; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; @@ -55,7 +56,6 @@ import org.wordpress.android.ui.CollapseFullScreenDialogFragment.OnCollapseListener; import org.wordpress.android.ui.CollapseFullScreenDialogFragment.OnConfirmListener; import org.wordpress.android.ui.CommentFullScreenDialogFragment; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.comments.unified.CommentIdentifier.ReaderCommentIdentifier; import org.wordpress.android.ui.comments.unified.UnifiedCommentsEditActivity; @@ -96,17 +96,17 @@ import javax.inject.Inject; -import dagger.hilt.android.AndroidEntryPoint; -import kotlin.Unit; - import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_REPLY; import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_END; import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_START; import static org.wordpress.android.ui.reader.FollowConversationUiStateKt.FOLLOW_CONVERSATION_UI_STATE_FLAGS_KEY; import static org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper; +import dagger.hilt.android.AndroidEntryPoint; +import kotlin.Unit; + @AndroidEntryPoint -public class ReaderCommentListActivity extends LocaleAwareActivity implements OnConfirmListener, +public class ReaderCommentListActivity extends AppCompatActivity implements OnConfirmListener, OnCollapseListener { private static final String KEY_REPLY_TO_COMMENT_ID = "reply_to_comment_id"; private static final String KEY_HAS_UPDATED_COMMENTS = "has_updated_comments"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java index 1a8b72744da6..64f32f93a194 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java @@ -12,6 +12,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -19,7 +20,6 @@ import androidx.viewpager.widget.ViewPager; import org.wordpress.android.R; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.reader.models.ReaderImageList; import org.wordpress.android.ui.reader.utils.ReaderImageScanner; import org.wordpress.android.ui.reader.views.ReaderPhotoView.PhotoViewListener; @@ -33,7 +33,7 @@ * Full-screen photo viewer - uses a ViewPager to enable scrolling between images in a blog * post, but also supports viewing a single image */ -public class ReaderPhotoViewerActivity extends LocaleAwareActivity +public class ReaderPhotoViewerActivity extends AppCompatActivity implements PhotoViewListener { private String mInitialImageUrl; private boolean mIsPrivate; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index ba69c23927b3..5e6b57244b0a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -13,6 +13,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; @@ -34,7 +35,6 @@ import org.wordpress.android.models.ReaderBlog; import org.wordpress.android.models.ReaderTag; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.mysite.SelectedSiteRepository; import org.wordpress.android.ui.posts.EditPostActivity; @@ -55,7 +55,7 @@ * serves as the host for ReaderPostListFragment when showing blog preview & tag preview */ @AndroidEntryPoint -public class ReaderPostListActivity extends LocaleAwareActivity { +public class ReaderPostListActivity extends AppCompatActivity { private String mSource; private ReaderPostListType mPostListType; private long mSiteId; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index 3519185e7cb5..ebec0f3cd69f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -16,6 +16,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; @@ -40,7 +41,6 @@ import org.wordpress.android.models.ReaderPost; import org.wordpress.android.models.ReaderTag; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.WPLaunchActivity; import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenInReader; @@ -98,11 +98,11 @@ import javax.inject.Inject; -import dagger.hilt.android.AndroidEntryPoint; - import static org.wordpress.android.ui.main.WPMainActivity.ARG_OPEN_PAGE; import static org.wordpress.android.ui.main.WPMainActivity.ARG_READER; +import dagger.hilt.android.AndroidEntryPoint; + /* * shows reader post detail fragments in a ViewPager - primarily used for easy swiping between * posts with a specific tag or in a specific blog, but can also be used to show a single @@ -117,7 +117,7 @@ * Will also handle jumping to the comments section, liking a commend and liking a post directly */ @AndroidEntryPoint -public class ReaderPostPagerActivity extends LocaleAwareActivity { +public class ReaderPostPagerActivity extends AppCompatActivity { /** * Type of URL intercepted */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSearchActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSearchActivity.kt index 63a8a4809421..b3b9e09f4f17 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSearchActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSearchActivity.kt @@ -5,7 +5,7 @@ import android.os.Bundle import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.WordPress -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.reader.tracker.ReaderTracker import org.wordpress.android.ui.reader.tracker.ReaderTrackerType.MAIN_READER import org.wordpress.android.util.JetpackBrandingUtils @@ -17,7 +17,7 @@ import javax.inject.Inject * into new tested classes without requiring us to change the search behavior. */ @AndroidEntryPoint -class ReaderSearchActivity : LocaleAwareActivity() { +class ReaderSearchActivity : AppCompatActivity() { @Inject lateinit var readerTracker: ReaderTracker diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java index e572199e46f8..84893d3c9b51 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java @@ -14,6 +14,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -38,7 +39,6 @@ import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.models.ReaderTag; import org.wordpress.android.models.ReaderTagType; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.prefs.AppPrefs; import org.wordpress.android.ui.reader.ReaderEvents.FollowedBlogsFetched; @@ -71,7 +71,7 @@ * activity which shows the user's subscriptions - includes * followed tags and followed blogs */ -public class ReaderSubsActivity extends LocaleAwareActivity +public class ReaderSubsActivity extends AppCompatActivity implements ReaderTagAdapter.TagDeletedListener, ReaderTagAdapter.TagAddedListener { private EditText mEditAdd; private FloatingActionButton mFabButton; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java index c6fa07fe2bce..cc31935f5ddb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java @@ -4,6 +4,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; @@ -15,7 +16,6 @@ import org.wordpress.android.datasets.ReaderUserTable; import org.wordpress.android.models.ReaderPost; import org.wordpress.android.models.ReaderUserList; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.reader.adapters.ReaderUserAdapter; import org.wordpress.android.ui.reader.utils.ReaderUtils; import org.wordpress.android.ui.reader.views.ReaderRecyclerView; @@ -25,7 +25,7 @@ /* * displays a list of users who like a specific reader post */ -public class ReaderUserListActivity extends LocaleAwareActivity { +public class ReaderUserListActivity extends AppCompatActivity { private ReaderRecyclerView mRecyclerView; private ReaderUserAdapter mAdapter; private AppBarLayout mAppBarLayout; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java index 2017aedd13b0..87ae7abc2e21 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java @@ -9,10 +9,10 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.R; import org.wordpress.android.fluxc.network.UserAgent; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.helpers.WebChromeClientWithVideoPoster; import javax.inject.Inject; @@ -20,7 +20,7 @@ /** * Full screen video player for the reader */ -public class ReaderVideoViewerActivity extends LocaleAwareActivity { +public class ReaderVideoViewerActivity extends AppCompatActivity { private String mVideoUrl; private WebView mWebView; private ProgressBar mProgress; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsActivity.kt index 1259e9ccf0db..2fe660bf07a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsActivity.kt @@ -4,10 +4,10 @@ import android.os.Bundle import android.view.MenuItem import org.wordpress.android.R import org.wordpress.android.databinding.ReaderInterestsActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR -class ReaderInterestsActivity : LocaleAwareActivity() { +class ReaderInterestsActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt index 4a625cad5837..7b4d5889a813 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt @@ -9,13 +9,13 @@ import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.util.ToastUtils import org.wordpress.android.util.extensions.getSerializableCompat import org.wordpress.android.util.extensions.getSerializableExtraCompat @AndroidEntryPoint -class SelfHostedUsersActivity : LocaleAwareActivity() { +class SelfHostedUsersActivity : AppCompatActivity() { private val viewModel by viewModels() private var site: SiteModel? = null diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt index 38ebaa1b95c2..a97b7564197c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt @@ -16,7 +16,7 @@ import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.ActivityLauncherWrapper import org.wordpress.android.ui.ActivityLauncherWrapper.Companion.CAMPAIGN_SITE_CREATION import org.wordpress.android.ui.ActivityLauncherWrapper.Companion.JETPACK_PACKAGE_NAME -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.accounts.HelpActivity.Origin import org.wordpress.android.ui.domains.DomainRegistrationCheckoutWebViewActivity.OpenCheckout import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureFullScreenOverlayFragment @@ -71,7 +71,7 @@ import javax.inject.Inject import android.R as AndroidR @AndroidEntryPoint -class SiteCreationActivity : LocaleAwareActivity(), +class SiteCreationActivity : AppCompatActivity(), IntentsScreenListener, SiteNameScreenListener, DomainsScreenListener, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsConnectJetpackActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsConnectJetpackActivity.kt index 50eb02fe11ca..ed9af96b58da 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsConnectJetpackActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsConnectJetpackActivity.kt @@ -17,7 +17,7 @@ import org.wordpress.android.fluxc.store.AccountStore import org.wordpress.android.fluxc.store.AccountStore.OnAccountChanged import org.wordpress.android.ui.JetpackConnectionSource.STATS import org.wordpress.android.ui.JetpackConnectionWebViewActivity -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.WPWebViewActivity import org.wordpress.android.util.AppLog import org.wordpress.android.util.AppLog.T.API @@ -30,7 +30,7 @@ import android.R as AndroidR * An activity that shows when user tries to open Stats without Jetpack connected. * It offers a link to the Jetpack connection flow. */ -class StatsConnectJetpackActivity : LocaleAwareActivity() { +class StatsConnectJetpackActivity : AppCompatActivity() { private var mIsJetpackConnectStarted = false @Inject diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt index c814de1dfacb..2d55a5f73cc8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt @@ -12,7 +12,7 @@ import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.push.NotificationType import org.wordpress.android.push.NotificationsProcessingService.ARG_NOTIFICATION_TYPE import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper import org.wordpress.android.ui.stats.StatsTimeframe import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom @@ -22,7 +22,7 @@ import javax.inject.Inject import android.R as AndroidR @AndroidEntryPoint -class StatsActivity : LocaleAwareActivity() { +class StatsActivity : AppCompatActivity() { @Inject lateinit var statsSiteProvider: StatsSiteProvider diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllActivity.kt index 297b50cd96b5..869ee28f1205 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllActivity.kt @@ -10,13 +10,13 @@ import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat import org.wordpress.android.databinding.StatsViewAllActivityBinding import org.wordpress.android.fluxc.network.utils.StatsGranularity -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.stats.StatsViewType import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDateProvider.SelectedDate import android.R as AndroidR @AndroidEntryPoint -class StatsViewAllActivity : LocaleAwareActivity() { +class StatsViewAllActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt index a78ff06f39f4..2ce3ef109c2d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/StatsDetailActivity.kt @@ -12,7 +12,7 @@ import org.wordpress.android.WordPress import org.wordpress.android.databinding.StatsDetailActivityBinding import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.network.utils.StatsGranularity -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.stats.StatsViewType import org.wordpress.android.ui.stats.refresh.StatsViewAllFragment import org.wordpress.android.ui.stats.refresh.lists.StatsListFragment @@ -28,7 +28,7 @@ const val POST_TITLE = "POST_TITLE" const val POST_URL = "POST_URL" @AndroidEntryPoint -class StatsDetailActivity : LocaleAwareActivity() { +class StatsDetailActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding = StatsDetailActivityBinding.inflate(layoutInflater) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementActivity.kt index a18f9d33803d..70987c2d8893 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementActivity.kt @@ -5,11 +5,11 @@ import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R import org.wordpress.android.databinding.InsightsManagementActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class InsightsManagementActivity : LocaleAwareActivity() { +class InsightsManagementActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(InsightsManagementActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/StatsAllTimeWidgetConfigureActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/StatsAllTimeWidgetConfigureActivity.kt index 87085cd229c0..19faf302c1d0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/StatsAllTimeWidgetConfigureActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/alltime/StatsAllTimeWidgetConfigureActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.StatsAllTimeWidgetConfigureActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class StatsAllTimeWidgetConfigureActivity : LocaleAwareActivity() { +class StatsAllTimeWidgetConfigureActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(StatsAllTimeWidgetConfigureActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureActivity.kt index 26053234979c..0ed01717ca58 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.StatsMinifiedWidgetConfigureActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class StatsMinifiedWidgetConfigureActivity : LocaleAwareActivity() { +class StatsMinifiedWidgetConfigureActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(StatsMinifiedWidgetConfigureActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/StatsTodayWidgetConfigureActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/StatsTodayWidgetConfigureActivity.kt index 368e42e2f790..819c87639b15 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/StatsTodayWidgetConfigureActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/StatsTodayWidgetConfigureActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.StatsTodayWidgetConfigureActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class StatsTodayWidgetConfigureActivity : LocaleAwareActivity() { +class StatsTodayWidgetConfigureActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(StatsTodayWidgetConfigureActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/StatsViewsWidgetConfigureActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/StatsViewsWidgetConfigureActivity.kt index 06d48b356310..7e23d55837a4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/StatsViewsWidgetConfigureActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/StatsViewsWidgetConfigureActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.StatsViewsWidgetConfigureActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class StatsViewsWidgetConfigureActivity : LocaleAwareActivity() { +class StatsViewsWidgetConfigureActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(StatsViewsWidgetConfigureActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/StatsWeekWidgetConfigureActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/StatsWeekWidgetConfigureActivity.kt index 4a70596d0e8b..5fdc3e87b929 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/StatsWeekWidgetConfigureActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/StatsWeekWidgetConfigureActivity.kt @@ -4,11 +4,11 @@ import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.databinding.StatsWeekViewsWidgetConfigureActivityBinding -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import android.R as AndroidR @AndroidEntryPoint -class StatsWeekWidgetConfigureActivity : LocaleAwareActivity() { +class StatsWeekWidgetConfigureActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) with(StatsWeekViewsWidgetConfigureActivityBinding.inflate(layoutInflater)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java index 389882465d63..acd004107e20 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.Toolbar; import androidx.core.text.HtmlCompat; @@ -41,7 +42,6 @@ import org.wordpress.android.fluxc.store.StockMediaStore.FetchStockMediaListPayload; import org.wordpress.android.fluxc.store.StockMediaStore.OnStockMediaListFetched; import org.wordpress.android.ui.ActionableEmptyView; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaPreviewActivity; import org.wordpress.android.ui.photopicker.MediaPickerConstants; @@ -56,8 +56,8 @@ import org.wordpress.android.util.PhotonUtils; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; -import org.wordpress.android.util.extensions.ViewExtensionsKt; import org.wordpress.android.util.WPLinkMovementMethod; +import org.wordpress.android.util.extensions.ViewExtensionsKt; import org.wordpress.android.util.image.ImageManager; import org.wordpress.android.util.image.ImageType; @@ -68,7 +68,7 @@ import javax.inject.Inject; -public class StockMediaPickerActivity extends LocaleAwareActivity implements SearchView.OnQueryTextListener { +public class StockMediaPickerActivity extends AppCompatActivity implements SearchView.OnQueryTextListener { private static final int MIN_SEARCH_QUERY_SIZE = 3; private static final String TAG_RETAINED_FRAGMENT = "retained_fragment"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/suggestion/SuggestionActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/suggestion/SuggestionActivity.kt index 7648211bec4a..42f7bdd597b3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/suggestion/SuggestionActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/suggestion/SuggestionActivity.kt @@ -17,7 +17,7 @@ import org.wordpress.android.WordPress import org.wordpress.android.databinding.SuggestUsersActivityBinding import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.networking.ConnectionChangeReceiver.ConnectionChangeEvent -import org.wordpress.android.ui.LocaleAwareActivity +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.ui.suggestion.FinishAttempt.NotExactlyOneAvailable import org.wordpress.android.ui.suggestion.FinishAttempt.OnlyOneAvailable import org.wordpress.android.ui.suggestion.adapters.SuggestionAdapter @@ -29,7 +29,7 @@ import org.wordpress.android.util.extensions.onBackPressedCompat import org.wordpress.android.widgets.SuggestionAutoCompleteText import javax.inject.Inject -class SuggestionActivity : LocaleAwareActivity() { +class SuggestionActivity : AppCompatActivity() { private var suggestionAdapter: SuggestionAdapter? = null private var siteId: Long? = null diff --git a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java index b1c3505aeceb..03058c2dd8d3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java @@ -13,6 +13,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.FragmentManager; @@ -38,7 +39,6 @@ import org.wordpress.android.fluxc.store.ThemeStore.SiteThemePayload; import org.wordpress.android.models.JetpackPoweredScreen; import org.wordpress.android.ui.ActivityId; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.ScrollableViewInitializedListener; import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredBottomSheetFragment; import org.wordpress.android.ui.prefs.AppPrefs; @@ -60,7 +60,7 @@ import dagger.hilt.android.AndroidEntryPoint; @AndroidEntryPoint -public class ThemeBrowserActivity extends LocaleAwareActivity implements ThemeBrowserFragmentCallback, +public class ThemeBrowserActivity extends AppCompatActivity implements ThemeBrowserFragmentCallback, ScrollableViewInitializedListener { public static final int ACTIVATE_THEME = 1; public static final String THEME_ID = "theme_id"; From 7576fbb3982c6c8ca126eda4db0e401059f8a93c Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:08:14 -0500 Subject: [PATCH 07/45] Second pass at removing LocaleAwareActivity.kt --- .../wordpress/android/ui/main/WPMainActivity.java | 14 +++++++------- .../android/ui/plugins/PluginDetailActivity.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 57154cce875d..b40dc6de29cf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -20,6 +20,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NotificationManagerCompat; import androidx.core.app.RemoteInput; import androidx.fragment.app.Fragment; @@ -80,7 +81,6 @@ import org.wordpress.android.ui.ActivityNavigator; import org.wordpress.android.ui.JetpackConnectionSource; import org.wordpress.android.ui.JetpackConnectionWebViewActivity; -import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.ui.PagePostCreationSourcesDetail; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.Shortcut; @@ -126,7 +126,6 @@ import org.wordpress.android.ui.prefs.AppSettingsActivity; import org.wordpress.android.ui.prefs.AppSettingsFragment; import org.wordpress.android.ui.prefs.SiteSettingsFragment; -import org.wordpress.android.util.PerAppLocaleManager; import org.wordpress.android.ui.prefs.privacy.banner.PrivacyBannerFragment; import org.wordpress.android.ui.quickstart.QuickStartMySitePrompts; import org.wordpress.android.ui.quickstart.QuickStartTracker; @@ -154,6 +153,7 @@ import org.wordpress.android.util.DeviceUtils; import org.wordpress.android.util.FluxCUtils; import org.wordpress.android.util.NetworkUtils; +import org.wordpress.android.util.PerAppLocaleManager; import org.wordpress.android.util.ProfilingUtils; import org.wordpress.android.util.QuickStartUtils; import org.wordpress.android.util.QuickStartUtilsWrapper; @@ -186,11 +186,6 @@ import javax.inject.Inject; -import dagger.hilt.android.AndroidEntryPoint; -import kotlin.Unit; -import kotlin.jvm.functions.Function0; -import kotlin.jvm.functions.Function3; - import static androidx.lifecycle.Lifecycle.State.STARTED; import static org.wordpress.android.WordPress.SITE; import static org.wordpress.android.fluxc.store.SiteStore.CompleteQuickStartVariant.NEXT_STEPS; @@ -198,6 +193,11 @@ import static org.wordpress.android.push.NotificationsProcessingService.ARG_NOTIFICATION_TYPE; import static org.wordpress.android.ui.JetpackConnectionSource.NOTIFICATIONS; +import dagger.hilt.android.AndroidEntryPoint; +import kotlin.Unit; +import kotlin.jvm.functions.Function0; +import kotlin.jvm.functions.Function3; + /** * Main activity which hosts sites, reader, me and notifications pages */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java index c1cf20f2db42..2d9492605696 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java @@ -21,6 +21,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.text.HtmlCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentTransaction; @@ -63,7 +64,6 @@ import org.wordpress.android.fluxc.store.SiteStore.OnPlansFetched; import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged; import org.wordpress.android.ui.ActivityLauncher; -import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.domains.DomainRegistrationActivity; import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose; From 18a731a15d048fdf7b1862b0f9943ecd642a540d Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:10:15 -0500 Subject: [PATCH 08/45] Fixed detekt errors --- .../main/java/org/wordpress/android/ui/LocaleAwareActivity.kt | 2 +- .../main/java/org/wordpress/android/util/PerAppLocaleManager.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt index 1e5f793112b9..15afe4f33862 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt @@ -9,7 +9,7 @@ import androidx.appcompat.app.AppCompatActivity * the need for this class. Instead of extending from this class, we should extend * from AppCompatActivity. */ -abstract class AppCompatActivity : AppCompatActivity() { +abstract class LocaleAwareActivity : AppCompatActivity() { /** * Used to update locales on API 21 to API 25. */ diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 822abcb43cf8..4eb5a11db067 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -126,7 +126,7 @@ class PerAppLocaleManager @Inject constructor( /** * Called when the device language is changed from our in-app language picker - * TODO: Detect when language changed from app settings dialog + * TODO Detect when language changed from app settings dialog */ fun onLanguageChanged(languageCode: String) { if (languageCode.isEmpty()) { From 97f1914aed088b083cd82fc7649839647c71638f Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:29:28 -0500 Subject: [PATCH 09/45] Fixed lint errors --- .../org/wordpress/android/ui/AddQuickPressShortcutActivity.java | 1 + .../main/java/org/wordpress/android/ui/AppLogViewerActivity.java | 1 + .../wordpress/android/ui/JetpackConnectionResultActivity.java | 1 + .../org/wordpress/android/ui/ShareIntentReceiverActivity.java | 1 + .../src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt | 1 + .../src/main/java/org/wordpress/android/ui/WebViewActivity.java | 1 + 6 files changed, 6 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java index 563b9fb1cb92..a78d27798830 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java @@ -19,6 +19,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutManagerCompat; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java index 1cbf808b91dc..75e4477962cf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java @@ -19,6 +19,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.text.HtmlCompat; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java index 2f3c1432046e..d1df0b10f01a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java @@ -8,6 +8,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.R; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java index c856e10d5118..1b8558ba4d03 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java @@ -8,6 +8,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.TaskStackBuilder; import androidx.preference.PreferenceManager; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt index 2dd91a1b440a..d768c4431a89 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.kt @@ -3,6 +3,7 @@ package org.wordpress.android.ui import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity import com.google.android.material.dialog.MaterialAlertDialogBuilder import org.wordpress.android.R import org.wordpress.android.WordPress diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java index 92a3c9af3b46..c12b4ca51b32 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java @@ -10,6 +10,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.R; From d2abbf1981444c0575e521d8d446fa8e315d6d84 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:31:11 -0500 Subject: [PATCH 10/45] Removed LocaleAwareActivity.kt --- .../android/ui/LocaleAwareActivity.kt | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt deleted file mode 100644 index 15afe4f33862..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ /dev/null @@ -1,26 +0,0 @@ -package org.wordpress.android.ui - -import android.content.Context -import android.content.res.Configuration -import androidx.appcompat.app.AppCompatActivity - -/** - * Update Dec 2024: We've added support for per-app language preferences which negate - * the need for this class. Instead of extending from this class, we should extend - * from AppCompatActivity. - */ -abstract class LocaleAwareActivity : AppCompatActivity() { - /** - * Used to update locales on API 21 to API 25. - */ - override fun attachBaseContext(newBase: Context?) { - super.attachBaseContext(newBase) - } - - /** - * Used to update locales on API 26 and beyond. - */ - override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) { - super.applyOverrideConfiguration(overrideConfiguration) - } -} From ab18a7c697267d803f1ef8b83edafde2d178e099 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:34:19 -0500 Subject: [PATCH 11/45] Fixed detekt error --- .../main/java/org/wordpress/android/util/PerAppLocaleManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 822abcb43cf8..4eb5a11db067 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -126,7 +126,7 @@ class PerAppLocaleManager @Inject constructor( /** * Called when the device language is changed from our in-app language picker - * TODO: Detect when language changed from app settings dialog + * TODO Detect when language changed from app settings dialog */ fun onLanguageChanged(languageCode: String) { if (languageCode.isEmpty()) { From 38b3baf1674f2c519308ec9b4ca09278c3b400f4 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 14:31:53 -0500 Subject: [PATCH 12/45] Fixed checkstyle import errors --- .../wordpress/android/ui/accounts/LoginActivity.java | 4 ++-- .../android/ui/comments/CommentsDetailActivity.java | 4 ++-- .../deeplinks/DeepLinkingIntentReceiverActivity.java | 4 ++-- .../org/wordpress/android/ui/main/WPMainActivity.java | 10 +++++----- .../android/ui/media/MediaSettingsActivity.java | 2 +- .../ui/notifications/NotificationsDetailActivity.java | 4 ++-- .../android/ui/reader/ReaderCommentListActivity.java | 6 +++--- .../android/ui/reader/ReaderPostPagerActivity.java | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index c57298505ded..deda35fc37fc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java @@ -87,13 +87,13 @@ import javax.inject.Inject; -import static org.wordpress.android.util.ActivityUtils.hideKeyboard; - import dagger.android.AndroidInjector; import dagger.android.DispatchingAndroidInjector; import dagger.android.HasAndroidInjector; import dagger.hilt.android.AndroidEntryPoint; +import static org.wordpress.android.util.ActivityUtils.hideKeyboard; + @AndroidEntryPoint public class LoginActivity extends AppCompatActivity implements ConnectionCallbacks, OnConnectionFailedListener, Callback, LoginListener, GoogleListener, LoginPrologueListener, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java index 77543537c991..bf5fafea28e1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java @@ -43,10 +43,10 @@ import javax.inject.Inject; -import static org.wordpress.android.ui.comments.unified.CommentConstants.COMMENTS_PER_PAGE; - import dagger.hilt.android.AndroidEntryPoint; +import static org.wordpress.android.ui.comments.unified.CommentConstants.COMMENTS_PER_PAGE; + /** * @deprecated * Comments are being refactored as part of Comments Unification project. If you are adding any diff --git a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java index b705acfe9101..48b2ccbdccee 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java @@ -27,11 +27,11 @@ import javax.inject.Inject; +import dagger.hilt.android.AndroidEntryPoint; + import static org.wordpress.android.WordPress.getContext; import static org.wordpress.android.ui.main.WPMainActivity.ARG_BYPASS_MIGRATION; -import dagger.hilt.android.AndroidEntryPoint; - /** * An activity to handle deep linking and intercepting links like: *

diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index b40dc6de29cf..b187af605256 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -186,6 +186,11 @@ import javax.inject.Inject; +import dagger.hilt.android.AndroidEntryPoint; +import kotlin.Unit; +import kotlin.jvm.functions.Function0; +import kotlin.jvm.functions.Function3; + import static androidx.lifecycle.Lifecycle.State.STARTED; import static org.wordpress.android.WordPress.SITE; import static org.wordpress.android.fluxc.store.SiteStore.CompleteQuickStartVariant.NEXT_STEPS; @@ -193,11 +198,6 @@ import static org.wordpress.android.push.NotificationsProcessingService.ARG_NOTIFICATION_TYPE; import static org.wordpress.android.ui.JetpackConnectionSource.NOTIFICATIONS; -import dagger.hilt.android.AndroidEntryPoint; -import kotlin.Unit; -import kotlin.jvm.functions.Function0; -import kotlin.jvm.functions.Function3; - /** * Main activity which hosts sites, reader, me and notifications pages */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java index b74a3cc30e2d..db13656067d9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java @@ -46,6 +46,7 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityOptionsCompat; @@ -71,7 +72,6 @@ import org.wordpress.android.fluxc.store.MediaStore; import org.wordpress.android.fluxc.store.MediaStore.MediaPayload; import org.wordpress.android.fluxc.store.MediaStore.OnMediaChanged; -import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaPreviewActivity.MediaPreviewSwiped; import org.wordpress.android.ui.utils.AuthenticationUtils; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java index a43db3bf36cb..6d7feb152a4b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java @@ -76,14 +76,14 @@ import javax.inject.Inject; +import dagger.hilt.android.AndroidEntryPoint; + import static org.wordpress.android.models.Note.NOTE_COMMENT_LIKE_TYPE; import static org.wordpress.android.models.Note.NOTE_COMMENT_TYPE; import static org.wordpress.android.models.Note.NOTE_FOLLOW_TYPE; import static org.wordpress.android.models.Note.NOTE_LIKE_TYPE; import static org.wordpress.android.ui.notifications.services.NotificationsUpdateServiceStarter.IS_TAPPED_ON_NOTIFICATION; -import dagger.hilt.android.AndroidEntryPoint; - @AndroidEntryPoint @SuppressWarnings("deprecation") public class NotificationsDetailActivity extends AppCompatActivity implements diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java index 2cd1ee9e41d5..916fb5f6c361 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java @@ -96,15 +96,15 @@ import javax.inject.Inject; +import kotlin.Unit; +import dagger.hilt.android.AndroidEntryPoint; + import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_REPLY; import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_END; import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_START; import static org.wordpress.android.ui.reader.FollowConversationUiStateKt.FOLLOW_CONVERSATION_UI_STATE_FLAGS_KEY; import static org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper; -import dagger.hilt.android.AndroidEntryPoint; -import kotlin.Unit; - @AndroidEntryPoint public class ReaderCommentListActivity extends AppCompatActivity implements OnConfirmListener, OnCollapseListener { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index ebec0f3cd69f..88825b9c7c20 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -98,11 +98,11 @@ import javax.inject.Inject; +import dagger.hilt.android.AndroidEntryPoint; + import static org.wordpress.android.ui.main.WPMainActivity.ARG_OPEN_PAGE; import static org.wordpress.android.ui.main.WPMainActivity.ARG_READER; -import dagger.hilt.android.AndroidEntryPoint; - /* * shows reader post detail fragments in a ViewPager - primarily used for easy swiping between * posts with a specific tag or in a specific blog, but can also be used to show a single From 51f7470a08ae235a65a7699a7672f81c6b8b9713 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 07:31:55 -0500 Subject: [PATCH 13/45] Removed mLocaleProvider --- .../org/wordpress/android/ui/prefs/AppSettingsFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index 9522a579d8d1..037c9567e951 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -57,7 +57,6 @@ import org.wordpress.android.util.AppThemeUtils; import org.wordpress.android.util.BuildConfigWrapper; import org.wordpress.android.util.JetpackBrandingUtils; -import org.wordpress.android.util.LocaleProvider; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.PerAppLocaleManager; import org.wordpress.android.util.ToastUtils; @@ -103,7 +102,6 @@ public class AppSettingsFragment extends PreferenceFragment @Inject FeatureAnnouncementProvider mFeatureAnnouncementProvider; @Inject BuildConfigWrapper mBuildConfigWrapper; @Inject JetpackBrandingUtils mJetpackBrandingUtils; - @Inject LocaleProvider mLocaleProvider; @Inject DeepLinkOpenWebLinksWithJetpackHelper mOpenWebLinksWithJetpackHelper; @Inject UiHelpers mUiHelpers; @Inject JetpackFeatureRemovalPhaseHelper mJetpackFeatureRemovalPhaseHelper; From 8b5b827d101eecc49897114cf22f4d183337de22 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 07:37:58 -0500 Subject: [PATCH 14/45] Use binary comparison --- .../main/java/org/wordpress/android/util/PerAppLocaleManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 4eb5a11db067..15b799b233df 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -134,7 +134,7 @@ class PerAppLocaleManager @Inject constructor( } // Only update if the language is different - if (languageCode.equals(getCurrentLocaleLanguageCode()).not()) { + if (languageCode != getCurrentLocaleLanguageCode()) { setCurrentLocaleByLanguageCode(languageCode) } From b9e5c5d958ecc8140dc93885dec73ce74b49b959 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 07:40:38 -0500 Subject: [PATCH 15/45] Removed extra space in comment --- .../org/wordpress/android/ui/prefs/AppSettingsFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index 037c9567e951..2bc319f1c6c2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -597,7 +597,7 @@ private boolean handleFeatureAnnouncementClick() { } private boolean handleAppLocalePickerClick() { - // if the device is on API 33+, take the user to the system app settings to change the language + // if the device is on API 33+, take the user to the system app settings to change the language if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { mPerAppLocaleManager.openAppLanguageSettings(getContext()); return true; From c62e604d8dd43c38ab6c176259595b97068cb110 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 07:43:19 -0500 Subject: [PATCH 16/45] Make fun private --- .../main/java/org/wordpress/android/util/PerAppLocaleManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 15b799b233df..5abfc8ef09ab 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -41,7 +41,7 @@ class PerAppLocaleManager @Inject constructor( fun getCurrentLocaleDisplayName(): String = getCurrentLocale().displayName - fun getCurrentLocaleLanguageCode(): String = getCurrentLocale().language + private fun getCurrentLocaleLanguageCode(): String = getCurrentLocale().language /** * Important: this should only be called after Activity.onCreate() From e37697ddb0655aae4e8a8313b286ca6568464b5d Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 12:21:53 -0500 Subject: [PATCH 17/45] Removed JetpackMigrationLanguageUtil --- .../migration/JetpackMigrationViewModel.kt | 7 ------- .../android/ui/mysite/menu/MenuViewModel.kt | 7 ------- .../util/JetpackMigrationLanguageUtil.kt | 17 ----------------- .../migration/JetpackMigrationViewModelTest.kt | 12 ------------ .../android/ui/mysite/menu/MenuViewModelTest.kt | 3 --- 5 files changed, 46 deletions(-) delete mode 100644 WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt index dda1b9350851..62cbc9bee148 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt @@ -66,13 +66,11 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.AppLog import org.wordpress.android.util.AppLog.T import org.wordpress.android.util.WPAvatarUtilsWrapper -import org.wordpress.android.util.JetpackMigrationLanguageUtil import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SiteUtilsWrapper import org.wordpress.android.util.config.PreventDuplicateNotifsFeatureConfig import org.wordpress.android.viewmodel.ContextProvider import org.wordpress.android.viewmodel.ScopedViewModel -import java.util.Locale import javax.inject.Inject import javax.inject.Named @@ -91,7 +89,6 @@ class JetpackMigrationViewModel @Inject constructor( private val accountStore: AccountStore, private val siteStore: SiteStore, private val localeManagerWrapper: LocaleManagerWrapper, - private val jetpackMigrationLanguageUtil: JetpackMigrationLanguageUtil, ) : ScopedViewModel(mainDispatcher) { private val _actionEvents = Channel(Channel.BUFFERED) val actionEvents = _actionEvents.receiveAsFlow() @@ -203,10 +200,6 @@ class JetpackMigrationViewModel @Inject constructor( } } - fun setAppLanguage(locale: Locale) { - jetpackMigrationLanguageUtil.applyLanguage(locale.language) - } - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) fun initNotificationsScreenUi(): Notifications { migrationAnalyticsTracker.trackNotificationsScreenShown() diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt index 7fcfbd3f2e11..9bcf986e059f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt @@ -27,7 +27,6 @@ import org.wordpress.android.ui.mysite.items.listitem.SiteItemsBuilder import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.quickstart.QuickStartEvent import org.wordpress.android.ui.utils.UiHelpers -import org.wordpress.android.util.JetpackMigrationLanguageUtil import org.wordpress.android.util.LONG_DURATION_MS import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SHORT_DURATION_MS @@ -37,7 +36,6 @@ import org.wordpress.android.util.merge import org.wordpress.android.viewmodel.ContextProvider import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.ScopedViewModel -import java.util.Locale import javax.inject.Inject import javax.inject.Named @@ -47,7 +45,6 @@ const val MENU_ITEM_TRACKING_PARAMETER = "item" class MenuViewModel @Inject constructor( private val blazeFeatureUtils: BlazeFeatureUtils, private val jetpackCapabilitiesUseCase: JetpackCapabilitiesUseCase, - private val jetpackMigrationLanguageUtil: JetpackMigrationLanguageUtil, private val listItemActionHandler: ListItemActionHandler, private val localeManagerWrapper: LocaleManagerWrapper, private val quickStartRepository: QuickStartRepository, @@ -268,10 +265,6 @@ class MenuViewModel @Inject constructor( } } - fun setAppLanguage(locale: Locale) { - jetpackMigrationLanguageUtil.applyLanguage(locale.language) - } - override fun onCleared() { jetpackCapabilitiesUseCase.clear() super.onCleared() diff --git a/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt b/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt deleted file mode 100644 index b1a4621326b2..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.wordpress.android.util - -import org.wordpress.android.WordPress -import org.wordpress.android.viewmodel.ContextProvider -import javax.inject.Inject - -class JetpackMigrationLanguageUtil @Inject constructor( - private val contextProvider: ContextProvider, -) { - fun applyLanguage(languageCode: String) { - if (languageCode.isEmpty()) return - - LocaleManager.setNewLocale(WordPress.getContext(), languageCode) - WordPress.updateContextLocale() - contextProvider.refreshContext() - } -} diff --git a/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt index 6e33aee504e3..14c18e3ec165 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt @@ -41,12 +41,10 @@ import org.wordpress.android.ui.main.jetpack.migration.JetpackMigrationViewModel import org.wordpress.android.ui.prefs.AppPrefsWrapper import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.WPAvatarUtilsWrapper -import org.wordpress.android.util.JetpackMigrationLanguageUtil import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SiteUtilsWrapper import org.wordpress.android.util.config.PreventDuplicateNotifsFeatureConfig import org.wordpress.android.viewmodel.ContextProvider -import java.util.Locale @ExperimentalCoroutinesApi @RunWith(MockitoJUnitRunner::class) @@ -64,7 +62,6 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { private val accountStore: AccountStore = mock() private val siteStore: SiteStore = mock() private val localeManagerWrapper: LocaleManagerWrapper = mock() - private val jetpackMigrationLanguageUtil: JetpackMigrationLanguageUtil = mock() private val dispatcher: Dispatcher = mock() private lateinit var classToTest: JetpackMigrationViewModel @@ -87,7 +84,6 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { accountStore = accountStore, siteStore = siteStore, localeManagerWrapper = localeManagerWrapper, - jetpackMigrationLanguageUtil = jetpackMigrationLanguageUtil, ) classToTest.refreshAppTheme.observeForever(refreshAppThemeObserver) classToTest.refreshAppLanguage.observeForever(refreshAppLanguageObserver) @@ -122,14 +118,6 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { verify(refreshAppLanguageObserver).onChanged(language) } - @Test - fun `Should delegate language change to util`() { - val locale = Locale.US - classToTest.setAppLanguage(locale) - - verify(jetpackMigrationLanguageUtil).applyLanguage(locale.language) - } - @Test fun `Should emit refresh app theme when when welcome screen is shown with user flags`() { classToTest.initWelcomeScreenUi(WelcomeScreenData(flags = mapOf("theme" to "dark")), false) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt index 8a0f8f58fdb1..e0c8d71c5029 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt @@ -28,7 +28,6 @@ import org.wordpress.android.ui.mysite.items.listitem.SiteItemsBuilder import org.wordpress.android.ui.utils.ListItemInteraction import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.ui.utils.UiString -import org.wordpress.android.util.JetpackMigrationLanguageUtil import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.viewmodel.ContextProvider @@ -38,7 +37,6 @@ import org.wordpress.android.viewmodel.ContextProvider class MenuViewModelTest : BaseUnitTest() { private val blazeFeatureUtils: BlazeFeatureUtils = mock() private val jetpackCapabilitiesUseCase: JetpackCapabilitiesUseCase = mock() - private val jetpackMigrationLanguageUtil: JetpackMigrationLanguageUtil = mock() private val listItemActionHandler: ListItemActionHandler = mock() private val localeManagerWrapper: LocaleManagerWrapper = mock() private val quickStartRepository: QuickStartRepository = mock() @@ -63,7 +61,6 @@ class MenuViewModelTest : BaseUnitTest() { viewModel = MenuViewModel( blazeFeatureUtils, jetpackCapabilitiesUseCase, - jetpackMigrationLanguageUtil, listItemActionHandler, localeManagerWrapper, quickStartRepository, From e3e2528285cbfa0fc9682b11da9f3051aa770ec8 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 12:28:44 -0500 Subject: [PATCH 18/45] First pass at removing lanuage from Jetpack migration --- .../migration/JetpackMigrationFragment.kt | 11 ++------ .../migration/JetpackMigrationViewModel.kt | 25 ------------------- .../android/ui/mysite/menu/MenuActivity.kt | 11 ++------ .../android/ui/mysite/menu/MenuViewModel.kt | 18 ------------- .../JetpackMigrationViewModelTest.kt | 2 -- .../ui/mysite/menu/MenuViewModelTest.kt | 5 ---- 6 files changed, 4 insertions(+), 68 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationFragment.kt index 1eec59122e75..6d993b09f5d9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationFragment.kt @@ -10,9 +10,9 @@ import androidx.activity.addCallback import androidx.compose.animation.Crossfade import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels @@ -26,7 +26,6 @@ import org.wordpress.android.fluxc.Dispatcher import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.accounts.HelpActivity.Origin.JETPACK_MIGRATION_HELP import org.wordpress.android.ui.compose.theme.AppThemeM3 -import org.wordpress.android.ui.compose.utils.LocaleAwareComposable import org.wordpress.android.ui.main.jetpack.migration.JetpackMigrationViewModel.JetpackMigrationActionEvent import org.wordpress.android.ui.main.jetpack.migration.JetpackMigrationViewModel.JetpackMigrationActionEvent.CompleteFlow import org.wordpress.android.ui.main.jetpack.migration.JetpackMigrationViewModel.JetpackMigrationActionEvent.FallbackToLogin @@ -45,7 +44,6 @@ import org.wordpress.android.ui.main.jetpack.migration.compose.state.Notificatio import org.wordpress.android.ui.main.jetpack.migration.compose.state.WelcomeStep import org.wordpress.android.ui.utils.PreMigrationDeepLinkData import org.wordpress.android.util.AppThemeUtils -import org.wordpress.android.util.LocaleManager import org.wordpress.android.util.UriWrapper import org.wordpress.android.util.WPPermissionUtils import org.wordpress.android.util.extensions.getParcelableCompat @@ -65,12 +63,7 @@ class JetpackMigrationFragment : Fragment() { ): View = ComposeView(requireContext()).apply { setContent { AppThemeM3 { - val userLanguage by viewModel.refreshAppLanguage.observeAsState("") - - LocaleAwareComposable( - locale = LocaleManager.languageLocale(userLanguage), - onLocaleChange = viewModel::setAppLanguage - ) { + CompositionLocalProvider { JetpackMigrationScreen() } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt index 62cbc9bee148..3f030ede4aa9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt @@ -66,7 +66,6 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.AppLog import org.wordpress.android.util.AppLog.T import org.wordpress.android.util.WPAvatarUtilsWrapper -import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SiteUtilsWrapper import org.wordpress.android.util.config.PreventDuplicateNotifsFeatureConfig import org.wordpress.android.viewmodel.ContextProvider @@ -88,7 +87,6 @@ class JetpackMigrationViewModel @Inject constructor( private val migrationAnalyticsTracker: ContentMigrationAnalyticsTracker, private val accountStore: AccountStore, private val siteStore: SiteStore, - private val localeManagerWrapper: LocaleManagerWrapper, ) : ScopedViewModel(mainDispatcher) { private val _actionEvents = Channel(Channel.BUFFERED) val actionEvents = _actionEvents.receiveAsFlow() @@ -96,9 +94,6 @@ class JetpackMigrationViewModel @Inject constructor( private val _refreshAppTheme = MutableLiveData() val refreshAppTheme: LiveData = _refreshAppTheme - private val _refreshAppLanguage = MutableLiveData() - val refreshAppLanguage: LiveData = _refreshAppLanguage - private var isStarted = false private val migrationStateFlow = MutableStateFlow(Initial) private val continueClickedFlow = MutableStateFlow(false) @@ -170,7 +165,6 @@ class JetpackMigrationViewModel @Inject constructor( } if (data.flags.isNotEmpty()) { - emitLanguageRefreshIfNeeded(extractLanguageFromFlagsMap(data.flags)) _refreshAppTheme.value = Unit } @@ -186,20 +180,6 @@ class JetpackMigrationViewModel @Inject constructor( ) } - private fun extractLanguageFromFlagsMap(userPrefs: Map): String { - val languageKey = localeManagerWrapper.getLocalePrefKeyString() - return userPrefs[languageKey] as? String ?: "" - } - - private fun emitLanguageRefreshIfNeeded(languageCode: String) { - if (languageCode.isNotEmpty()) { - val shouldEmitLanguageRefresh = !localeManagerWrapper.isSameLanguage(languageCode) - if (shouldEmitLanguageRefresh) { - _refreshAppLanguage.value = languageCode - } - } - } - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) fun initNotificationsScreenUi(): Notifications { migrationAnalyticsTracker.trackNotificationsScreenShown() @@ -232,11 +212,6 @@ class JetpackMigrationViewModel @Inject constructor( fun initPleaseDeleteWordPressAppScreenUi(): Delete { migrationAnalyticsTracker.trackPleaseDeleteWordPressScreenShown() - // We need to manually apply the app language for the Compose UI since the host JetpackMigrationActivity - // does not inherit from AppCompatActivity on purpose, in order to avoid possible issues - // when the Ui mode (dark/light) and the language are manually set by the user. - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) - return Delete( primaryActionButton = DeletePrimaryButton(::onGotItClicked), secondaryActionButton = DeleteSecondaryButton { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt index 52a5d3071fbf..13e9ea104384 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuActivity.kt @@ -34,11 +34,11 @@ import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -59,7 +59,6 @@ import org.wordpress.android.R import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.ActivityNavigator import org.wordpress.android.ui.compose.theme.AppThemeM3 -import org.wordpress.android.ui.compose.utils.LocaleAwareComposable import org.wordpress.android.ui.compose.utils.uiStringText import org.wordpress.android.ui.mysite.SiteNavigationAction import org.wordpress.android.ui.mysite.items.listitem.ListItemAction @@ -69,7 +68,6 @@ import org.wordpress.android.ui.quickstart.QuickStartMySitePrompts import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom import org.wordpress.android.ui.utils.ListItemInteraction import org.wordpress.android.ui.utils.UiString -import org.wordpress.android.util.LocaleManager import org.wordpress.android.util.QuickStartUtilsWrapper import org.wordpress.android.util.SnackbarItem import org.wordpress.android.util.SnackbarSequencer @@ -96,12 +94,7 @@ class MenuActivity : AppCompatActivity() { initObservers() setContent { AppThemeM3 { - val userLanguage by viewModel.refreshAppLanguage.observeAsState("") - - LocaleAwareComposable( - locale = LocaleManager.languageLocale(userLanguage), - onLocaleChange = viewModel::setAppLanguage - ) { + CompositionLocalProvider { viewModel.start(intent.getParcelableExtraCompat(KEY_QUICK_START_EVENT)) MenuScreen( onBackPressed = onBackPressedDispatcher::onBackPressed diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt index 9bcf986e059f..c68ab699eb2a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/menu/MenuViewModel.kt @@ -28,7 +28,6 @@ import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.quickstart.QuickStartEvent import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.util.LONG_DURATION_MS -import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SHORT_DURATION_MS import org.wordpress.android.util.SnackbarItem import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper @@ -46,7 +45,6 @@ class MenuViewModel @Inject constructor( private val blazeFeatureUtils: BlazeFeatureUtils, private val jetpackCapabilitiesUseCase: JetpackCapabilitiesUseCase, private val listItemActionHandler: ListItemActionHandler, - private val localeManagerWrapper: LocaleManagerWrapper, private val quickStartRepository: QuickStartRepository, private val selectedSiteRepository: SelectedSiteRepository, private val siteItemsBuilder: SiteItemsBuilder, @@ -63,9 +61,6 @@ class MenuViewModel @Inject constructor( val onQuickStartMySitePrompts = quickStartRepository.onQuickStartMySitePrompts - private val _refreshAppLanguage = MutableLiveData() - val refreshAppLanguage: LiveData = _refreshAppLanguage - private val _uiState = MutableStateFlow(MenuViewState(items = emptyList())) val uiState: StateFlow = _uiState @@ -78,10 +73,6 @@ class MenuViewModel @Inject constructor( private var quickStartEvent: QuickStartEvent? = null private var isStarted = false - init { - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) - } - fun start(quickStartEvent: QuickStartEvent? = null) { if (isStarted) { return @@ -256,15 +247,6 @@ class MenuViewModel @Inject constructor( _snackbar.emit(snackbarMessage) } - private fun emitLanguageRefreshIfNeeded(languageCode: String) { - if (languageCode.isNotEmpty()) { - val shouldEmitLanguageRefresh = !localeManagerWrapper.isSameLanguage(languageCode) - if (shouldEmitLanguageRefresh) { - _refreshAppLanguage.value = languageCode - } - } - } - override fun onCleared() { jetpackCapabilitiesUseCase.clear() super.onCleared() diff --git a/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt index 14c18e3ec165..906248a3d4f5 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt @@ -83,10 +83,8 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { migrationAnalyticsTracker = contentMigrationAnalyticsTracker, accountStore = accountStore, siteStore = siteStore, - localeManagerWrapper = localeManagerWrapper, ) classToTest.refreshAppTheme.observeForever(refreshAppThemeObserver) - classToTest.refreshAppLanguage.observeForever(refreshAppLanguageObserver) } // region ViewModel diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt index e0c8d71c5029..15cb573beeaf 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt @@ -1,6 +1,5 @@ package org.wordpress.android.ui.mysite.menu -import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOf @@ -42,7 +41,6 @@ class MenuViewModelTest : BaseUnitTest() { private val quickStartRepository: QuickStartRepository = mock() private val selectedSiteRepository: SelectedSiteRepository = mock() private val siteItemsBuilder: SiteItemsBuilder = mock() - private val refreshAppLanguageObserver: Observer = mock() private val contextProvider: ContextProvider = mock() private val uiHelpers: UiHelpers = mock() private val analyticsTrackerWrapper: AnalyticsTrackerWrapper = mock() @@ -62,7 +60,6 @@ class MenuViewModelTest : BaseUnitTest() { blazeFeatureUtils, jetpackCapabilitiesUseCase, listItemActionHandler, - localeManagerWrapper, quickStartRepository, selectedSiteRepository, siteItemsBuilder, @@ -71,8 +68,6 @@ class MenuViewModelTest : BaseUnitTest() { testDispatcher(), analyticsTrackerWrapper ) - - viewModel.refreshAppLanguage.observeForever(refreshAppLanguageObserver) } @Test From 0b35a8f420584727b730f1e64a25fdc6ee335820 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 12:31:15 -0500 Subject: [PATCH 19/45] Second pass at removing lanuage from Jetpack migration --- .../org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt index 15cb573beeaf..c62a0615db31 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/menu/MenuViewModelTest.kt @@ -27,7 +27,6 @@ import org.wordpress.android.ui.mysite.items.listitem.SiteItemsBuilder import org.wordpress.android.ui.utils.ListItemInteraction import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.ui.utils.UiString -import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.viewmodel.ContextProvider @@ -37,7 +36,6 @@ class MenuViewModelTest : BaseUnitTest() { private val blazeFeatureUtils: BlazeFeatureUtils = mock() private val jetpackCapabilitiesUseCase: JetpackCapabilitiesUseCase = mock() private val listItemActionHandler: ListItemActionHandler = mock() - private val localeManagerWrapper: LocaleManagerWrapper = mock() private val quickStartRepository: QuickStartRepository = mock() private val selectedSiteRepository: SelectedSiteRepository = mock() private val siteItemsBuilder: SiteItemsBuilder = mock() @@ -52,7 +50,6 @@ class MenuViewModelTest : BaseUnitTest() { @Before fun setUp() = test { - whenever(localeManagerWrapper.getLanguage()).thenReturn("") whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site) initJetpackCapabilities(scanPurchased = false, backupPurchased = false) From 586324cf1466b6cf71da37cb2f6d0fdea0acfa6b Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 12:35:30 -0500 Subject: [PATCH 20/45] Removed language from JetpackMigrationViewModelTest --- .../JetpackMigrationViewModelTest.kt | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt index 906248a3d4f5..444ba5fe49b6 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt @@ -41,7 +41,6 @@ import org.wordpress.android.ui.main.jetpack.migration.JetpackMigrationViewModel import org.wordpress.android.ui.prefs.AppPrefsWrapper import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.WPAvatarUtilsWrapper -import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SiteUtilsWrapper import org.wordpress.android.util.config.PreventDuplicateNotifsFeatureConfig import org.wordpress.android.viewmodel.ContextProvider @@ -50,7 +49,6 @@ import org.wordpress.android.viewmodel.ContextProvider @RunWith(MockitoJUnitRunner::class) class JetpackMigrationViewModelTest : BaseUnitTest() { private val refreshAppThemeObserver: Observer = mock() - private val refreshAppLanguageObserver: Observer = mock() private val siteUtilsWrapper: SiteUtilsWrapper = mock() private val avatarUtilsWrapper: WPAvatarUtilsWrapper = mock() private val appPrefsWrapper: AppPrefsWrapper = mock() @@ -61,7 +59,6 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { private val contextProvider: ContextProvider = mock() private val accountStore: AccountStore = mock() private val siteStore: SiteStore = mock() - private val localeManagerWrapper: LocaleManagerWrapper = mock() private val dispatcher: Dispatcher = mock() private lateinit var classToTest: JetpackMigrationViewModel @@ -69,7 +66,6 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { @Before fun setUp() { whenever(avatarUtilsWrapper.rewriteAvatarUrlWithResource(any(), any())).thenReturn("") - whenever(localeManagerWrapper.getLanguage()).thenReturn("") classToTest = JetpackMigrationViewModel( mainDispatcher = testDispatcher(), dispatcher = dispatcher, @@ -93,29 +89,6 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { assertThat(classToTest.uiState.first()).isInstanceOf(Loading::class.java) } - @Test - fun `Should emit event to refresh the language when welcome screen is shown with language data to apply`() { - val (languagePrefKey, languagePrefValue) = "it" to "language-pref" - val welcomeScreenData = WelcomeScreenData(flags = mapOf(languagePrefKey to languagePrefValue)) - whenever(localeManagerWrapper.getLocalePrefKeyString()).thenReturn(languagePrefKey) - whenever(localeManagerWrapper.isSameLanguage(languagePrefValue)).thenReturn(false) - - classToTest.initWelcomeScreenUi(welcomeScreenData, false) - - verify(refreshAppLanguageObserver).onChanged(languagePrefValue) - } - - @Test - fun `Should emit event to refresh the language when delete wp app screen is shown and language is not applied`() { - val language = "it" - whenever(localeManagerWrapper.getLanguage()).thenReturn(language) - whenever(localeManagerWrapper.isSameLanguage(language)).thenReturn(false) - - classToTest.initPleaseDeleteWordPressAppScreenUi() - - verify(refreshAppLanguageObserver).onChanged(language) - } - @Test fun `Should emit refresh app theme when when welcome screen is shown with user flags`() { classToTest.initWelcomeScreenUi(WelcomeScreenData(flags = mapOf("theme" to "dark")), false) From e7f0947c65a6f446d88087ce06bc8bbd571c7ae1 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Mon, 16 Dec 2024 08:34:19 -0500 Subject: [PATCH 21/45] Updated TODO --- .../java/org/wordpress/android/util/PerAppLocaleManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 5abfc8ef09ab..e37a2ec80685 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -124,9 +124,10 @@ class PerAppLocaleManager @Inject constructor( } } + @Suppress("ForbiddenComment") /** * Called when the device language is changed from our in-app language picker - * TODO Detect when language changed from app settings dialog + * TODO: Detect when language changed from app settings dialog */ fun onLanguageChanged(languageCode: String) { if (languageCode.isEmpty()) { From f68eb08dd62435b3d883bd85b5d32caefb86e84f Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 07:21:45 -0500 Subject: [PATCH 22/45] Removed WPLocaleTestRule and updateContextLocale --- .../ui/screenshots/JPScreenshotTest.java | 4 +- .../ui/screenshots/WPLocaleTestRule.java | 61 ------------------- .../ui/screenshots/WPScreenshotTest.java | 4 +- .../org/wordpress/android/AppInitializer.kt | 17 ------ .../java/org/wordpress/android/WordPress.kt | 7 --- 5 files changed, 2 insertions(+), 91 deletions(-) delete mode 100644 WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPLocaleTestRule.java diff --git a/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/JPScreenshotTest.java b/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/JPScreenshotTest.java index c7d2ee6d2448..d13b6e416524 100644 --- a/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/JPScreenshotTest.java +++ b/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/JPScreenshotTest.java @@ -65,9 +65,7 @@ public class JPScreenshotTest extends BaseTest { @ClassRule public static final RuleChain LOCALE_TEST_RULES = RuleChain // Run fastlane's official LocaleTestRule (which switches device language + sets up screengrab) first - .outerRule(new LocaleTestRule()) - // Run our own rule (which handles our in-app locale switching logic) second - .around(new WPLocaleTestRule()); + .outerRule(new LocaleTestRule()); // Note: running this as a static @ClassRule as part of the above RuleChain doesn't seem to work // (apparently that would make those run too early?), but running it as @Rule does fix the issue. diff --git a/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPLocaleTestRule.java b/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPLocaleTestRule.java deleted file mode 100644 index a0cb044a1575..000000000000 --- a/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPLocaleTestRule.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.wordpress.android.ui.screenshots; - -import android.content.Context; - -import androidx.test.core.app.ApplicationProvider; - -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.wordpress.android.WordPress; -import org.wordpress.android.util.LocaleManager; - -import java.util.Locale; - -import tools.fastlane.screengrab.locale.LocaleUtil; - -public class WPLocaleTestRule implements TestRule { - private String mTestLocaleCode; - - public WPLocaleTestRule() { - this(LocaleUtil.getTestLocale()); - } - - public WPLocaleTestRule(String testLocaleCode) { - // Parse as `Locale` then back to `String`, to ensure that when we get `fr-FR` as input - // (which is what is expected to be passed via fastlane's Screengrab and `LocaleUtil.getTestLocale()`), - // we get `fr_FR` (the locale code format expected by `java.util.Locale` and our `LocaleManager`) back. - Locale locale = LocaleUtil.localeFromString(testLocaleCode); - if (locale != null) { - mTestLocaleCode = locale.toString(); - } - } - - @Override - public Statement apply(final Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - String original = null; - try { - if (mTestLocaleCode != null) { - original = changeLocale(mTestLocaleCode); - } - base.evaluate(); - } finally { - if (original != null) { - changeLocale(original); - } - } - } - }; - } - - private static String changeLocale(String localeCode) { - Context context = ApplicationProvider.getApplicationContext(); - String original = LocaleManager.getLanguage(context); - LocaleManager.setNewLocale(context, localeCode); - WordPress.updateContextLocale(context); - return original; - } -} diff --git a/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPScreenshotTest.java b/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPScreenshotTest.java index d19c503815a7..c809d53cd1b9 100644 --- a/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPScreenshotTest.java +++ b/WordPress/src/androidTest/java/org/wordpress/android/ui/screenshots/WPScreenshotTest.java @@ -49,9 +49,7 @@ public class WPScreenshotTest extends BaseTest { @ClassRule public static final RuleChain LOCALE_TEST_RULES = RuleChain // Run fastlane's official LocaleTestRule (which switches device language + sets up screengrab) first - .outerRule(new LocaleTestRule()) - // Run our own rule (which handles our in-app locale switching logic) second - .around(new WPLocaleTestRule()); + .outerRule(new LocaleTestRule()); // Note: running this as a static @ClassRule as part of the above RuleChain doesn't seem to work // (apparently that would make those run too early?), but running it as @Rule does fix the issue. diff --git a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt index e3b7fb142355..abbcc8a7ea95 100644 --- a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt +++ b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt @@ -97,7 +97,6 @@ import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.DateTimeUtils import org.wordpress.android.util.EncryptedLogging import org.wordpress.android.util.FluxCUtils -import org.wordpress.android.util.LocaleManager import org.wordpress.android.util.NetworkUtils import org.wordpress.android.util.PackageUtils import org.wordpress.android.util.PerAppLocaleManager @@ -1086,21 +1085,5 @@ class AppInitializer @Inject constructor( } return bitmapCache as BitmapLruCache } - - /** - * Update locale of the static context when language is changed. - * - * When calling this method the application context **must** be already initialized. - * This is already the case in `Activity`, `Fragment` or `View`. - * - * When called from other places (E.g. a `TestRule`) we should provide it in the [appContext] parameter. - */ - fun updateContextLocale(appContext: Context? = null) { - val context = appContext ?: run { - check(context != null) { "Context must be initialized before calling updateContextLocale" } - return@run context - } - this.context = LocaleManager.setLocale(context) - } } } diff --git a/WordPress/src/main/java/org/wordpress/android/WordPress.kt b/WordPress/src/main/java/org/wordpress/android/WordPress.kt index 52975c1294b8..b54862e5a89d 100644 --- a/WordPress/src/main/java/org/wordpress/android/WordPress.kt +++ b/WordPress/src/main/java/org/wordpress/android/WordPress.kt @@ -1,7 +1,6 @@ package org.wordpress.android import android.app.Application -import android.content.Context import coil.decode.VideoFrameDecoder import com.android.volley.RequestQueue import dagger.hilt.EntryPoints @@ -59,12 +58,6 @@ abstract class WordPress : Application(), coil.ImageLoaderFactory { @JvmStatic fun getContext() = AppInitializer.context!! - @JvmStatic - @JvmOverloads - fun updateContextLocale(appContext: Context? = null) { - AppInitializer.updateContextLocale(appContext) - } - @JvmStatic fun getRestClientUtils() = AppInitializer.restClientUtils From efd62a1cc8bc7a5035d80244d6f4900a00a7b549 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 11:59:41 -0500 Subject: [PATCH 23/45] Removed unused code from LocaleManager --- .../wordpress/android/util/LocaleManager.java | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java index be01e24b1b95..3ca3e5b06951 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -48,38 +48,6 @@ public static Context setLocale(Context context) { return updateResources(context, getLanguage(context)); } - /** - * Apply locale to the provided configuration. - * - * @param context current context used to access Shared Preferences. - * @param configuration configuration that the locale should be applied to. - */ - @SuppressLint("AppBundleLocaleChanges") - public static Configuration updatedConfigLocale(Context context, Configuration configuration) { - Locale locale = languageLocale(getLanguage(context)); - Locale.setDefault(locale); - - // NOTE: Earlier versions of Android require both of these to be set, otherwise - // RTL may not be implemented properly. - configuration.setLocale(locale); - - return configuration; - } - - /** - * Change the active locale to the language provided. Save the updated language - * settings to sharedPreferences. - * - * @param context The current context - * @param language The 2-letter language code (example "en") to switch to - */ - public static void setNewLocale(Context context, String language) { - if (isSameLanguage(language)) { - return; - } - saveLanguageToPref(context, language); - updateResources(context, language); - } /** * Compare the language for the current context with another language. @@ -132,20 +100,6 @@ public static String getLanguage(Context context) { return langID; } - /** - * Save the updated language to SharedPreferences. - * Use commit() instead of apply() to ensure the language preference is saved instantly - * as the app may be restarted immediately. - * - * @param context The current context - * @param language The 2-letter language code (example "en") - */ - @SuppressLint("ApplySharedPref") - private static void saveLanguageToPref(Context context, String language) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - prefs.edit().putString(LANGUAGE_KEY, language).commit(); - } - /** * Update resources for the current session. * From 392dc0a2c8737705fbd8c88e62b274c0f6e7d061 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 12:19:28 -0500 Subject: [PATCH 24/45] Fixed nullability issues in LocaleManager --- .../wordpress/android/util/LocaleManager.java | 55 ++++++++----------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java index 3ca3e5b06951..0c2549a437b2 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -15,7 +15,6 @@ import java.text.Collator; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -37,18 +36,18 @@ public class LocaleManager { /** * Pattern to split a language string (to parse the language and region values). */ - private static Pattern languageSplitter = Pattern.compile("_"); + private static final Pattern LANGUAGE_SPLITTER = Pattern.compile("_"); /** * Activate the locale associated with the provided context. * * @param context The current context. */ - public static Context setLocale(Context context) { + @NonNull + public static Context setLocale(@NonNull Context context) { return updateResources(context, getLanguage(context)); } - /** * Compare the language for the current context with another language. * @@ -66,7 +65,8 @@ public static boolean isSameLanguage(@NonNull String language) { * * @return The 2-letter language code (example "en") */ - public static String getLanguage(Context context) { + @NonNull + public static String getLanguage(@NonNull Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getString(LANGUAGE_KEY, LanguageUtils.getCurrentDeviceLanguageCode()); } @@ -76,7 +76,7 @@ public static String getLanguage(Context context) { * Language IDs, used only by WordPress, are integer values that map to a language code. * http://bit.ly/2H7gksN **/ - public static @NonNull String getLanguageWordPressId(Context context) { + public static @NonNull String getLanguageWordPressId(@NonNull Context context) { final String deviceLanguageCode = LanguageUtils.getPatchedCurrentDeviceLanguage(context); Map languageCodeToID = LocaleManager.generateLanguageMap(context); @@ -108,7 +108,8 @@ public static String getLanguage(Context context) { * @return The modified context containing the updated localized resources */ @SuppressLint("AppBundleLocaleChanges") - private static Context updateResources(Context context, String language) { + @NonNull + private static Context updateResources(@NonNull Context context, @NonNull String language) { Locale locale = languageLocale(language); Locale.setDefault(locale); @@ -136,6 +137,7 @@ private static Context updateResources(Context context, String language) { * %,d likes * */ + @NonNull public static Locale getSafeLocale(@Nullable Context context) { Locale baseLocale; if (context == null) { @@ -154,12 +156,13 @@ public static Locale getSafeLocale(@Nullable Context context) { * @param languageCode The language code (example "en" or "es-US"). If null or empty will return * the current default locale. */ + @NonNull public static Locale languageLocale(@Nullable String languageCode) { - if (TextUtils.isEmpty(languageCode)) { + if (languageCode == null || TextUtils.isEmpty(languageCode)) { return Locale.getDefault(); } // Attempt to parse language and region codes. - String[] opts = languageSplitter.split(languageCode, 0); + String[] opts = LANGUAGE_SPLITTER.split(languageCode, 0); if (opts.length > 1) { return new Locale(opts[0], opts[1]); } else { @@ -170,7 +173,8 @@ public static Locale languageLocale(@Nullable String languageCode) { /** * Creates a map from language codes to WordPress language IDs. */ - public static Map generateLanguageMap(Context context) { + @NonNull + public static Map generateLanguageMap(@NonNull Context context) { String[] languageIds = context.getResources().getStringArray(R.array.lang_ids); String[] languageCodes = context.getResources().getStringArray(R.array.language_codes); @@ -186,8 +190,10 @@ public static Map generateLanguageMap(Context context) { * Generates display strings for given language codes. Used as entries in language preference. */ @Nullable - public static Triple createSortedLanguageDisplayStrings(CharSequence[] languageCodes, - Locale locale) { + public static Triple createSortedLanguageDisplayStrings( + @Nullable CharSequence[] languageCodes, + @NonNull Locale locale + ) { if (languageCodes == null || languageCodes.length < 1) { return null; } @@ -199,7 +205,7 @@ public static Triple createSortedLanguageDisplaySt getLanguageString(languageCodes[i].toString(), locale)) + "__" + languageCodes[i]); } - Collections.sort(entryStrings, Collator.getInstance(locale)); + entryStrings.sort(Collator.getInstance(locale)); String[] sortedEntries = new String[languageCodes.length]; String[] sortedValues = new String[languageCodes.length]; @@ -217,29 +223,12 @@ public static Triple createSortedLanguageDisplaySt return new Triple<>(sortedEntries, sortedValues, detailStrings); } - /** - * Generates detail display strings in the currently selected locale. Used as detail text - * in language preference dialog. - */ - @Nullable - public static String[] createLanguageDetailDisplayStrings(CharSequence[] languageCodes) { - if (languageCodes == null || languageCodes.length < 1) { - return null; - } - - String[] detailStrings = new String[languageCodes.length]; - for (int i = 0; i < languageCodes.length; ++i) { - detailStrings[i] = StringUtils.capitalize(getLanguageString( - languageCodes[i].toString(), languageLocale(languageCodes[i].toString()))); - } - - return detailStrings; - } /** * Return a non-null display string for a given language code. */ - public static String getLanguageString(String languageCode, Locale displayLocale) { + @NonNull + public static String getLanguageString(@Nullable String languageCode, @NonNull Locale displayLocale) { if (languageCode == null || languageCode.length() < 2 || languageCode.length() > 6) { return ""; } @@ -254,7 +243,7 @@ public static String getLanguageString(String languageCode, Locale displayLocale return displayLanguage; } - public static String getLocalePrefKeyString() { + public static @NonNull String getLocalePrefKeyString() { return LANGUAGE_KEY; } } From 7f29466993ae41d65841e08918cdfe79672fc091 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 12:27:42 -0500 Subject: [PATCH 25/45] Rename .java to .kt --- .../android/util/{LocaleManager.java => LocaleManager.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename WordPress/src/main/java/org/wordpress/android/util/{LocaleManager.java => LocaleManager.kt} (100%) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt similarity index 100% rename from WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java rename to WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt From 814a9d5b586501915ae2211802d1a02f925eeb92 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 12:27:42 -0500 Subject: [PATCH 26/45] First pass at converting LocaleManager to Kotlin --- .../wordpress/android/util/LocaleManager.kt | 235 +++++++++--------- 1 file changed, 113 insertions(+), 122 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 0c2549a437b2..87000405835d 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -1,51 +1,39 @@ -package org.wordpress.android.util; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.SharedPreferences; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.text.TextUtils; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.preference.PreferenceManager; - -import org.wordpress.android.R; - -import java.text.Collator; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Pattern; - -import kotlin.Triple; +package org.wordpress.android.util + +import android.annotation.SuppressLint +import android.content.Context +import android.content.res.Configuration +import android.text.TextUtils +import androidx.preference.PreferenceManager +import org.wordpress.android.R +import java.text.Collator +import java.util.Locale +import java.util.regex.Pattern /** * Helper class for working with localized strings. Ensures updates to the users * selected language is properly saved and resources appropriately updated for the * android version. */ -public class LocaleManager { +object LocaleManager { /** * Key used for saving the language selection to shared preferences. */ - private static final String LANGUAGE_KEY = "language-pref"; + private const val LOCALE_PREF_KEY_STRING: String = "language-pref" /** * Pattern to split a language string (to parse the language and region values). */ - private static final Pattern LANGUAGE_SPLITTER = Pattern.compile("_"); + private val LANGUAGE_SPLITTER: Pattern = Pattern.compile("_") /** * Activate the locale associated with the provided context. * * @param context The current context. */ - @NonNull - public static Context setLocale(@NonNull Context context) { - return updateResources(context, getLanguage(context)); + @JvmStatic + fun setLocale(context: Context): Context { + return updateResources(context, getLanguage(context)) } /** @@ -54,9 +42,9 @@ public class LocaleManager { * @param language The language to compare * @return True if the languages are the same, else false */ - public static boolean isSameLanguage(@NonNull String language) { - Locale newLocale = languageLocale(language); - return Locale.getDefault().toString().equals(newLocale.toString()); + fun isSameLanguage(language: String): Boolean { + val newLocale = languageLocale(language) + return Locale.getDefault().toString() == newLocale.toString() } /** @@ -65,39 +53,35 @@ public class LocaleManager { * * @return The 2-letter language code (example "en") */ - @NonNull - public static String getLanguage(@NonNull Context context) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - return prefs.getString(LANGUAGE_KEY, LanguageUtils.getCurrentDeviceLanguageCode()); + @JvmStatic + fun getLanguage(context: Context): String { + val prefs = PreferenceManager.getDefaultSharedPreferences(context) + return prefs.getString(LOCALE_PREF_KEY_STRING, LanguageUtils.getCurrentDeviceLanguageCode())!! } /** * Convert the device language code (codes defined by ISO 639-1) to a Language ID. * Language IDs, used only by WordPress, are integer values that map to a language code. * http://bit.ly/2H7gksN - **/ - public static @NonNull String getLanguageWordPressId(@NonNull Context context) { - final String deviceLanguageCode = LanguageUtils.getPatchedCurrentDeviceLanguage(context); + */ + fun getLanguageWordPressId(context: Context): String { + val deviceLanguageCode = LanguageUtils.getPatchedCurrentDeviceLanguage(context) - Map languageCodeToID = LocaleManager.generateLanguageMap(context); - String langID = null; + val languageCodeToID = generateLanguageMap(context) + var langID: String? = null if (languageCodeToID.containsKey(deviceLanguageCode)) { - langID = languageCodeToID.get(deviceLanguageCode); + langID = languageCodeToID[deviceLanguageCode] } else { - int pos = deviceLanguageCode.indexOf("_"); + val pos = deviceLanguageCode.indexOf("_") if (pos > -1) { - String newLang = deviceLanguageCode.substring(0, pos); + val newLang = deviceLanguageCode.substring(0, pos) if (languageCodeToID.containsKey(newLang)) { - langID = languageCodeToID.get(newLang); + langID = languageCodeToID[newLang] } } } - if (langID == null) { - // fallback to device language code if there is no match - langID = deviceLanguageCode; - } - return langID; + return langID ?: deviceLanguageCode } /** @@ -108,142 +92,149 @@ public class LocaleManager { * @return The modified context containing the updated localized resources */ @SuppressLint("AppBundleLocaleChanges") - @NonNull - private static Context updateResources(@NonNull Context context, @NonNull String language) { - Locale locale = languageLocale(language); - Locale.setDefault(locale); + private fun updateResources(context: Context, language: String): Context { + val locale = languageLocale(language) + Locale.setDefault(locale) - Resources res = context.getResources(); - Configuration config = new Configuration(res.getConfiguration()); + val res = context.resources + val config = Configuration(res.configuration) // NOTE: Earlier versions of Android require both of these to be set, otherwise // RTL may not be implemented properly. - config.setLocale(locale); - context = context.createConfigurationContext(config); - - return context; + config.setLocale(locale) + return context.createConfigurationContext(config) } /** * Method gets around a bug in the java.util.Formatter for API 7.x as detailed here * [https://bugs.openjdk.java.net/browse/JDK-8167567]. Any strings that contain * locale-specific grouping separators should use: - * + * ` * String.format(LocaleManager.getSafeLocale(context), baseString, val) - * - *

+ * * An example of a string that contains locale-specific grouping separators: - * + * ` * %,d likes - * + ` * */ - @NonNull - public static Locale getSafeLocale(@Nullable Context context) { - Locale baseLocale; + @JvmStatic + fun getSafeLocale(context: Context?): Locale { + val baseLocale: Locale if (context == null) { - baseLocale = Locale.getDefault(); + baseLocale = Locale.getDefault() } else { - Configuration config = context.getResources().getConfiguration(); - baseLocale = config.getLocales().get(0); + val config = context.resources.configuration + baseLocale = config.locales[0] } - return languageLocale(baseLocale.getLanguage()); + return languageLocale(baseLocale.language) } /** * Gets a locale for the given language code. * * @param languageCode The language code (example "en" or "es-US"). If null or empty will return - * the current default locale. + * the current default locale. */ - @NonNull - public static Locale languageLocale(@Nullable String languageCode) { + @JvmStatic + fun languageLocale(languageCode: String?): Locale { if (languageCode == null || TextUtils.isEmpty(languageCode)) { - return Locale.getDefault(); + return Locale.getDefault() } // Attempt to parse language and region codes. - String[] opts = LANGUAGE_SPLITTER.split(languageCode, 0); - if (opts.length > 1) { - return new Locale(opts[0], opts[1]); + val opts = LANGUAGE_SPLITTER.split(languageCode, 0) + return if (opts.size > 1) { + Locale(opts[0], opts[1]) } else { - return new Locale(opts[0]); + Locale(opts[0]) } } /** * Creates a map from language codes to WordPress language IDs. */ - @NonNull - public static Map generateLanguageMap(@NonNull Context context) { - String[] languageIds = context.getResources().getStringArray(R.array.lang_ids); - String[] languageCodes = context.getResources().getStringArray(R.array.language_codes); - - Map languageMap = new HashMap<>(); - for (int i = 0; i < languageIds.length && i < languageCodes.length; ++i) { - languageMap.put(languageCodes[i], languageIds[i]); + @JvmStatic + fun generateLanguageMap(context: Context): Map { + val languageIds = context.resources.getStringArray(R.array.lang_ids) + val languageCodes = context.resources.getStringArray(R.array.language_codes) + + val languageMap: MutableMap = HashMap() + var i = 0 + while (i < languageIds.size && i < languageCodes.size) { + languageMap[languageCodes[i]] = languageIds[i] + ++i } - return languageMap; + return languageMap } /** * Generates display strings for given language codes. Used as entries in language preference. */ - @Nullable - public static Triple createSortedLanguageDisplayStrings( - @Nullable CharSequence[] languageCodes, - @NonNull Locale locale - ) { - if (languageCodes == null || languageCodes.length < 1) { - return null; + fun createSortedLanguageDisplayStrings( + languageCodes: Array?, + locale: Locale + ): Triple, Array, Array>? { + if (languageCodes.isNullOrEmpty()) { + return null } - ArrayList entryStrings = new ArrayList<>(languageCodes.length); - for (int i = 0; i < languageCodes.length; ++i) { + val entryStrings = ArrayList(languageCodes.size) + for (i in languageCodes.indices) { // "__" is used to sort the language code with the display string so both arrays are sorted at the same time - entryStrings.add(i, StringUtils.capitalize( - getLanguageString(languageCodes[i].toString(), locale)) + "__" + languageCodes[i]); + entryStrings.add( + i, StringUtils.capitalize( + getLanguageString(languageCodes[i].toString(), locale) + ) + "__" + languageCodes[i] + ) } - entryStrings.sort(Collator.getInstance(locale)); + entryStrings.sortWith(Collator.getInstance(locale)) - String[] sortedEntries = new String[languageCodes.length]; - String[] sortedValues = new String[languageCodes.length]; - String[] detailStrings = new String[languageCodes.length]; + val sortedEntries = arrayOfNulls(languageCodes.size) + val sortedValues = arrayOfNulls(languageCodes.size) + val detailStrings = arrayOfNulls(languageCodes.size) - for (int i = 0; i < entryStrings.size(); ++i) { + for (i in entryStrings.indices) { // now, we can split the sorted array to extract the display string and the language code - String[] split = entryStrings.get(i).split("__"); - sortedEntries[i] = split[0]; - sortedValues[i] = split[1]; + val split = + entryStrings[i].split("__".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() + sortedEntries[i] = split[0] + sortedValues[i] = split[1] detailStrings[i] = - StringUtils.capitalize(getLanguageString(sortedValues[i], languageLocale(sortedValues[i]))); + StringUtils.capitalize( + getLanguageString( + sortedValues[i], languageLocale( + sortedValues[i] + ) + ) + ) } - return new Triple<>(sortedEntries, sortedValues, detailStrings); + return Triple(sortedEntries, sortedValues, detailStrings) } /** * Return a non-null display string for a given language code. */ - @NonNull - public static String getLanguageString(@Nullable String languageCode, @NonNull Locale displayLocale) { - if (languageCode == null || languageCode.length() < 2 || languageCode.length() > 6) { - return ""; + @JvmStatic + fun getLanguageString(languageCode: String?, displayLocale: Locale): String { + if (languageCode == null || languageCode.length < 2 || languageCode.length > 6) { + return "" } - Locale languageLocale = languageLocale(languageCode); - String displayLanguage = StringUtils.capitalize(languageLocale.getDisplayLanguage(displayLocale)); - String displayCountry = languageLocale.getDisplayCountry(displayLocale); + val languageLocale = languageLocale(languageCode) + val displayLanguage = + StringUtils.capitalize(languageLocale.getDisplayLanguage(displayLocale)) + val displayCountry = languageLocale.getDisplayCountry(displayLocale) if (!TextUtils.isEmpty(displayCountry)) { - return displayLanguage + " (" + displayCountry + ")"; + return "$displayLanguage ($displayCountry)" } - return displayLanguage; + return displayLanguage } - public static @NonNull String getLocalePrefKeyString() { - return LANGUAGE_KEY; - } + @JvmStatic + fun getLocalePrefKeyString(): String = LOCALE_PREF_KEY_STRING } From bbc411adf71adf9112e3d5573085ced4a5739bf3 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 12:34:56 -0500 Subject: [PATCH 27/45] Second pass at converting LocaleManager to Kotlin --- .../main/java/org/wordpress/android/util/LocaleProvider.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt index bd7421505142..d9a08ea58974 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt @@ -13,9 +13,9 @@ class LocaleProvider @Inject constructor() { } fun createSortedLocalizedLanguageDisplayStrings( - availableLocales: Array, + availableLocales: Array, targetLocale: Locale - ): Triple, Array, Array>? { + ): Triple, Array, Array>? { return LocaleManager.createSortedLanguageDisplayStrings(availableLocales, targetLocale) } } From 579057f753576cb1f017e38b341477fe00a0b9b0 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 12:43:55 -0500 Subject: [PATCH 28/45] Third pass at converting LocaleManager to Kotlin --- .../android/ui/prefs/language/LocalePickerViewModel.kt | 8 ++++---- .../main/java/org/wordpress/android/util/LocaleManager.kt | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt index 8c23773a4985..3daea0144e4c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt @@ -158,10 +158,10 @@ class LocalePickerViewModel @Inject constructor( for (i in availableLocalesData.first.indices) { cachedLocales.add( LocaleRow( - sortedEntries[i], - sortedLocalizedEntries[i], - sortedValues[i], - ClickAction(sortedValues[i], this::clickItem) + sortedEntries[i] ?: "", + sortedLocalizedEntries[i] ?: "", + sortedValues[i] ?: "", + ClickAction(sortedValues[i] ?: "", this::clickItem) ) ) } diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 87000405835d..232ed92a4f0a 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -171,6 +171,7 @@ object LocaleManager { /** * Generates display strings for given language codes. Used as entries in language preference. */ + @JvmStatic fun createSortedLanguageDisplayStrings( languageCodes: Array?, locale: Locale From b01f6bc5509eabf3d287b667fdfcbaa8371a7525 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 13:35:33 -0500 Subject: [PATCH 29/45] Fourth pass at converting LocaleManager to Kotlin --- .../org/wordpress/android/util/LocaleManager.kt | 16 +++++++++------- .../org/wordpress/android/util/LocaleProvider.kt | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 232ed92a4f0a..9fb71953e684 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -175,7 +175,7 @@ object LocaleManager { fun createSortedLanguageDisplayStrings( languageCodes: Array?, locale: Locale - ): Triple, Array, Array>? { + ): Triple, Array, Array>? { if (languageCodes.isNullOrEmpty()) { return null } @@ -192,9 +192,9 @@ object LocaleManager { entryStrings.sortWith(Collator.getInstance(locale)) - val sortedEntries = arrayOfNulls(languageCodes.size) - val sortedValues = arrayOfNulls(languageCodes.size) - val detailStrings = arrayOfNulls(languageCodes.size) + val sortedEntries = Array(languageCodes.size) { "" } + val sortedValues = Array(languageCodes.size) { "" } + val detailStrings = Array(languageCodes.size) { "" } for (i in entryStrings.indices) { // now, we can split the sorted array to extract the display string and the language code @@ -220,6 +220,7 @@ object LocaleManager { * Return a non-null display string for a given language code. */ @JvmStatic + @Suppress("MagicNumber") fun getLanguageString(languageCode: String?, displayLocale: Locale): String { if (languageCode == null || languageCode.length < 2 || languageCode.length > 6) { return "" @@ -230,10 +231,11 @@ object LocaleManager { StringUtils.capitalize(languageLocale.getDisplayLanguage(displayLocale)) val displayCountry = languageLocale.getDisplayCountry(displayLocale) - if (!TextUtils.isEmpty(displayCountry)) { - return "$displayLanguage ($displayCountry)" + return if (!TextUtils.isEmpty(displayCountry)) { + "$displayLanguage ($displayCountry)" + } else { + displayLanguage } - return displayLanguage } @JvmStatic diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt index d9a08ea58974..121ecfc82e34 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleProvider.kt @@ -15,7 +15,7 @@ class LocaleProvider @Inject constructor() { fun createSortedLocalizedLanguageDisplayStrings( availableLocales: Array, targetLocale: Locale - ): Triple, Array, Array>? { + ): Triple, Array, Array>? { return LocaleManager.createSortedLanguageDisplayStrings(availableLocales, targetLocale) } } From f0b571b65080d0003e87f49637029bd2f770d0fc Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 13:58:27 -0500 Subject: [PATCH 30/45] Removed unnecessary elvis ops --- .../android/ui/prefs/language/LocalePickerViewModel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt index 3daea0144e4c..8c23773a4985 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocalePickerViewModel.kt @@ -158,10 +158,10 @@ class LocalePickerViewModel @Inject constructor( for (i in availableLocalesData.first.indices) { cachedLocales.add( LocaleRow( - sortedEntries[i] ?: "", - sortedLocalizedEntries[i] ?: "", - sortedValues[i] ?: "", - ClickAction(sortedValues[i] ?: "", this::clickItem) + sortedEntries[i], + sortedLocalizedEntries[i], + sortedValues[i], + ClickAction(sortedValues[i], this::clickItem) ) ) } From 58be3db13b3df049445c19aa711c7fcfb68d6d4e Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 13:59:50 -0500 Subject: [PATCH 31/45] Added comment --- .../java/org/wordpress/android/util/PerAppLocaleManager.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index e37a2ec80685..0067c1fbfacb 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -73,6 +73,10 @@ class PerAppLocaleManager @Inject constructor( } } + /** + * This routine can be helpful during development to reset the app locale + */ + @Suppress("unused") fun resetApplicationLocale() { AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList()) } From a75a91b46760476d16518b0e94eaf41f916e8e1c Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 14:27:10 -0500 Subject: [PATCH 32/45] First pass at removing language shared preference --- .../UserFlagsProviderHelper.kt | 3 --- .../org/wordpress/android/util/LocaleManager.kt | 11 ++--------- .../wordpress/android/util/LocaleManagerWrapper.kt | 1 - .../wordpress/android/util/PerAppLocaleManager.kt | 13 ++++++++----- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt b/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt index 5d8a75087824..747a7cefeca9 100644 --- a/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt @@ -8,14 +8,12 @@ import org.wordpress.android.localcontentmigration.LocalContentEntityData.UserFl import org.wordpress.android.ui.prefs.AppPrefs.DeletablePrefKey import org.wordpress.android.ui.prefs.AppPrefs.UndeletablePrefKey import org.wordpress.android.ui.prefs.AppPrefsWrapper -import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.viewmodel.ContextProvider import javax.inject.Inject class UserFlagsProviderHelper @Inject constructor( private val appPrefsWrapper: AppPrefsWrapper, contextProvider: ContextProvider, - localeManagerWrapper: LocaleManagerWrapper ) : LocalDataProviderHelper { override fun getData(localEntityId: Int?): LocalContentEntityData = UserFlagsData( @@ -73,6 +71,5 @@ class UserFlagsProviderHelper @Inject constructor( contextProvider.getContext().getString(R.string.pref_key_app_theme), contextProvider.getContext().getString(R.string.pref_key_initial_screen), contextProvider.getContext().getString(R.string.pref_key_send_crash), - localeManagerWrapper.getLocalePrefKeyString() ) } diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 9fb71953e684..1ebda071db9b 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -6,6 +6,7 @@ import android.content.res.Configuration import android.text.TextUtils import androidx.preference.PreferenceManager import org.wordpress.android.R +import org.wordpress.android.util.PerAppLocaleManager.Companion.OLD_LOCALE_PREF_KEY_STRING import java.text.Collator import java.util.Locale import java.util.regex.Pattern @@ -16,11 +17,6 @@ import java.util.regex.Pattern * android version. */ object LocaleManager { - /** - * Key used for saving the language selection to shared preferences. - */ - private const val LOCALE_PREF_KEY_STRING: String = "language-pref" - /** * Pattern to split a language string (to parse the language and region values). */ @@ -56,7 +52,7 @@ object LocaleManager { @JvmStatic fun getLanguage(context: Context): String { val prefs = PreferenceManager.getDefaultSharedPreferences(context) - return prefs.getString(LOCALE_PREF_KEY_STRING, LanguageUtils.getCurrentDeviceLanguageCode())!! + return prefs.getString(OLD_LOCALE_PREF_KEY_STRING, LanguageUtils.getCurrentDeviceLanguageCode())!! } /** @@ -237,7 +233,4 @@ object LocaleManager { displayLanguage } } - - @JvmStatic - fun getLocalePrefKeyString(): String = LOCALE_PREF_KEY_STRING } diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt index 60e3c47b0f7d..e4331f27c23c 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt @@ -12,7 +12,6 @@ class LocaleManagerWrapper fun getTimeZone(): TimeZone = TimeZone.getDefault() fun getCurrentCalendar(): Calendar = Calendar.getInstance(getLocale()) fun getLanguage(): String = LocaleManager.getLanguage(context) - fun getLocalePrefKeyString(): String = LocaleManager.getLocalePrefKeyString() fun isSameLanguage(language: String): Boolean = LocaleManager.isSameLanguage(language) fun setLocale(context: Context): Context = LocaleManager.setLocale(context) } diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 0067c1fbfacb..c29766aa4b14 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -61,11 +61,10 @@ class PerAppLocaleManager @Inject constructor( * this once the per-app language pref is no longer experimental. */ fun checkAndUpdateOldLanguagePrefKey() { - val prefKey = LocaleManager.getLocalePrefKeyString() - val inAppLanguage = appPrefsWrapper.getPrefString(prefKey, "") + val inAppLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") val perAppLanguage = getCurrentLocale().language if (perAppLanguage.isNotEmpty() && inAppLanguage.equals(perAppLanguage).not()) { - appPrefsWrapper.setPrefString(prefKey, perAppLanguage) + appPrefsWrapper.setPrefString(OLD_LOCALE_PREF_KEY_STRING, perAppLanguage) appLogWrapper.d( AppLog.T.SETTINGS, "PerAppLocaleManager: changed inAppLanguage from $inAppLanguage to $perAppLanguage" @@ -94,8 +93,7 @@ class PerAppLocaleManager @Inject constructor( */ fun performMigrationIfNecessary() { if (isApplicationLocaleEmpty()) { - val prefKey = LocaleManager.getLocalePrefKeyString() - val previousLanguage = appPrefsWrapper.getPrefString(prefKey, "") + val previousLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") if (previousLanguage?.isNotEmpty() == true) { appLogWrapper.d( AppLog.T.SETTINGS, @@ -155,4 +153,9 @@ class PerAppLocaleManager @Inject constructor( // update Reader tags as they need be localized ReaderUpdateServiceStarter.startService(getContext(), EnumSet.of(UpdateTask.TAGS)) } + + companion object { + // Key previously used for saving the language selection to shared preferences. + const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" + } } From 0ec991d2319b242d0322457e0c4787631828388d Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 14:46:02 -0500 Subject: [PATCH 33/45] Second pass at removing language shared preference --- .../android/util/PerAppLocaleManager.kt | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index c29766aa4b14..64b3b415eb70 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -31,29 +31,6 @@ class PerAppLocaleManager @Inject constructor( private val siteStore: SiteStore, private val accountStore: AccountStore, ) { - private fun getCurrentLocale(): Locale { - return if (isApplicationLocaleEmpty()) { - Locale.getDefault() - } else { - getApplicationLocaleList()[0] ?: Locale.getDefault() - } - } - - fun getCurrentLocaleDisplayName(): String = getCurrentLocale().displayName - - private fun getCurrentLocaleLanguageCode(): String = getCurrentLocale().language - - /** - * Important: this should only be called after Activity.onCreate() - * https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getApplicationLocales() - */ - private fun getApplicationLocaleList() = AppCompatDelegate.getApplicationLocales() - - private fun isApplicationLocaleEmpty(): Boolean { - val locales = getApplicationLocaleList() - return (locales.isEmpty || locales == LocaleListCompat.getEmptyLocaleList()) - } - /** * We want to make sure the language pref for the in-app locale (old implementation) is set * to the same locale as the AndroidX per-app locale. This way LocaleManager.getLanguage - @@ -92,7 +69,8 @@ class PerAppLocaleManager @Inject constructor( * Previously the app locale was stored in SharedPreferences, so here we migrate to AndroidX per-app language prefs */ fun performMigrationIfNecessary() { - if (isApplicationLocaleEmpty()) { + val locales = AppCompatDelegate.getApplicationLocales() + if (locales.isEmpty || locales == LocaleListCompat.getEmptyLocaleList()) { val previousLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") if (previousLanguage?.isNotEmpty() == true) { appLogWrapper.d( @@ -157,5 +135,18 @@ class PerAppLocaleManager @Inject constructor( companion object { // Key previously used for saving the language selection to shared preferences. const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" + + private fun getCurrentLocale(): Locale { + val locales = AppCompatDelegate.getApplicationLocales() + return if (locales.isEmpty || locales == LocaleListCompat.getEmptyLocaleList()) { + Locale.getDefault() + } else { + locales[0] ?: Locale.getDefault() + } + } + + fun getCurrentLocaleDisplayName(): String = getCurrentLocale().displayName + + fun getCurrentLocaleLanguageCode(): String = getCurrentLocale().language } } From 715af69323984fbf0f560e6663235e913ad7fd7c Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 15:16:16 -0500 Subject: [PATCH 34/45] Changed LocaleManager to rely on PerAppLocaleManager for the current language code --- .../push/NotificationsProcessingService.java | 2 +- .../services/NotificationsUpdateJobService.java | 2 +- .../services/NotificationsUpdateService.java | 2 +- .../wordpress/android/ui/posts/EditPostActivity.kt | 2 +- .../android/ui/prefs/AppSettingsFragment.java | 2 +- .../discover/interests/ReaderInterestsFragment.kt | 2 +- .../reader/services/update/ReaderUpdateLogic.java | 2 +- .../org/wordpress/android/util/LocaleManager.kt | 14 ++++++-------- .../wordpress/android/util/LocaleManagerWrapper.kt | 2 +- .../wordpress/android/util/PerAppLocaleManager.kt | 1 + 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/push/NotificationsProcessingService.java b/WordPress/src/main/java/org/wordpress/android/push/NotificationsProcessingService.java index 54db41f9624e..2e2922fd02a6 100644 --- a/WordPress/src/main/java/org/wordpress/android/push/NotificationsProcessingService.java +++ b/WordPress/src/main/java/org/wordpress/android/push/NotificationsProcessingService.java @@ -532,7 +532,7 @@ private void getNoteFromNoteId(String noteId, RestRequest.Listener listener, } HashMap params = new HashMap<>(); - params.put("locale", LocaleManager.getLanguage(mContext)); + params.put("locale", LocaleManager.getLanguage()); WordPress.getRestClientUtils().getNotification(params, noteId, listener, errorListener); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java index f2ed15e62076..b677a56eb16f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java @@ -42,7 +42,7 @@ public boolean onStopJob(JobParameters params) { public void onCreate() { super.onCreate(); AppLog.i(AppLog.T.NOTIFS, "notifications update job service > created"); - mNotificationsUpdateLogic = new NotificationsUpdateLogic(LocaleManager.getLanguage(this), this); + mNotificationsUpdateLogic = new NotificationsUpdateLogic(LocaleManager.getLanguage(), this); } @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java index a674050a24cc..c5a4b6015e11 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java @@ -28,7 +28,7 @@ public IBinder onBind(Intent intent) { public void onCreate() { super.onCreate(); AppLog.i(AppLog.T.NOTIFS, "notifications update service > created"); - mNotificationsUpdateLogic = new NotificationsUpdateLogic(LocaleManager.getLanguage(this), this); + mNotificationsUpdateLogic = new NotificationsUpdateLogic(LocaleManager.getLanguage(), this); } @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt index 8a3dd57e2a5a..a0909e541fdd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt @@ -2571,7 +2571,7 @@ class EditPostActivity : AppCompatActivity(), EditorFragmentActivity, EditorImag get() { val postType = if (isPage) "page" else "post" val featuredImageId = editPostRepository.featuredImageId.toInt() - val languageString = LocaleManager.getLanguage(this@EditPostActivity) + val languageString = LocaleManager.getLanguage() val wpcomLocaleSlug = languageString.replace("_", "-").lowercase() // this.mIsXPostsCapable may return true for non-WP.com sites, but the app only supports xPosts for P2-based diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index 2bc319f1c6c2..6d9fcf91c0f2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -248,7 +248,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, mLanguagePreference = (WPPreference) findPreference(getString(R.string.pref_key_language)); mLanguagePreference.setOnPreferenceChangeListener(this); mLanguagePreference.setOnPreferenceClickListener(this); - mLanguagePreference.setSummary(mPerAppLocaleManager.getCurrentLocaleDisplayName()); + mLanguagePreference.setSummary(PerAppLocaleManager.Companion.getCurrentLocaleDisplayName()); return view; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsFragment.kt index cad0696f0433..20f5935adcdf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsFragment.kt @@ -109,7 +109,7 @@ class ReaderInterestsFragment : Fragment(R.layout.reader_interests_fragment_layo } viewModel.start( - LocaleManager.getLanguage(WordPress.getContext()), + LocaleManager.getLanguage(), parentViewModel, entryPoint ) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateLogic.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateLogic.java index 9af7b113c7db..d6ea3d0a2455 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateLogic.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateLogic.java @@ -64,7 +64,7 @@ public enum UpdateTask { public ReaderUpdateLogic(Context context, WordPress app, ServiceCompletionListener listener) { mCompletionListener = listener; app.component().inject(this); - mLanguage = LocaleManager.getLanguage(app); + mLanguage = LocaleManager.getLanguage(); mContext = context; } diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 1ebda071db9b..4ed6ea34137a 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -4,9 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.content.res.Configuration import android.text.TextUtils -import androidx.preference.PreferenceManager import org.wordpress.android.R -import org.wordpress.android.util.PerAppLocaleManager.Companion.OLD_LOCALE_PREF_KEY_STRING import java.text.Collator import java.util.Locale import java.util.regex.Pattern @@ -29,7 +27,7 @@ object LocaleManager { */ @JvmStatic fun setLocale(context: Context): Context { - return updateResources(context, getLanguage(context)) + return updateResources(context, getLanguage()) } /** @@ -43,16 +41,16 @@ object LocaleManager { return Locale.getDefault().toString() == newLocale.toString() } + @Suppress("ForbiddenComment") /** - * If the user has selected a language other than the device default, return that - * language code, else just return the device default language code. + * This is simply a wrapper for the per-app language code. + * TODO: Remove this and directly call PerAppLocaleManager * * @return The 2-letter language code (example "en") */ @JvmStatic - fun getLanguage(context: Context): String { - val prefs = PreferenceManager.getDefaultSharedPreferences(context) - return prefs.getString(OLD_LOCALE_PREF_KEY_STRING, LanguageUtils.getCurrentDeviceLanguageCode())!! + fun getLanguage(): String { + return PerAppLocaleManager.getCurrentLocaleLanguageCode() } /** diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt index e4331f27c23c..25afbb0d14a3 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt @@ -11,7 +11,7 @@ class LocaleManagerWrapper fun getLocale(): Locale = Locale.getDefault() fun getTimeZone(): TimeZone = TimeZone.getDefault() fun getCurrentCalendar(): Calendar = Calendar.getInstance(getLocale()) - fun getLanguage(): String = LocaleManager.getLanguage(context) + fun getLanguage(): String = LocaleManager.getLanguage() fun isSameLanguage(language: String): Boolean = LocaleManager.isSameLanguage(language) fun setLocale(context: Context): Context = LocaleManager.setLocale(context) } diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 64b3b415eb70..39a359fa7e51 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -132,6 +132,7 @@ class PerAppLocaleManager @Inject constructor( ReaderUpdateServiceStarter.startService(getContext(), EnumSet.of(UpdateTask.TAGS)) } + companion object { // Key previously used for saving the language selection to shared preferences. const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" From 3863459df67888835ac387996af64b2672902e35 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 15:35:07 -0500 Subject: [PATCH 35/45] Removed setLocale --- .../NotificationsUpdateJobService.java | 6 ---- .../services/NotificationsUpdateService.java | 6 ---- .../discover/ReaderDiscoverJobService.kt | 6 ---- .../discover/ReaderDiscoverService.kt | 6 ---- .../update/ReaderUpdateJobService.java | 7 ---- .../services/update/ReaderUpdateService.java | 7 ---- .../wordpress/android/util/LocaleManager.kt | 33 ------------------- .../android/util/LocaleManagerWrapper.kt | 1 - .../android/viewmodel/ContextProvider.kt | 5 --- 9 files changed, 77 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java index b677a56eb16f..6a40704dc184 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateJobService.java @@ -2,7 +2,6 @@ import android.app.job.JobParameters; import android.app.job.JobService; -import android.content.Context; import org.wordpress.android.ui.notifications.NotificationsListFragment; import org.wordpress.android.util.AppLog; @@ -14,11 +13,6 @@ public class NotificationsUpdateJobService extends JobService implements NotificationsUpdateLogic.ServiceCompletionListener { private NotificationsUpdateLogic mNotificationsUpdateLogic; - @Override - protected void attachBaseContext(Context newBase) { - super.attachBaseContext(LocaleManager.setLocale(newBase)); - } - @Override public boolean onStartJob(JobParameters params) { String noteId = null; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java index c5a4b6015e11..d1a037e0644f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/services/NotificationsUpdateService.java @@ -1,7 +1,6 @@ package org.wordpress.android.ui.notifications.services; import android.app.Service; -import android.content.Context; import android.content.Intent; import android.os.IBinder; @@ -14,11 +13,6 @@ public class NotificationsUpdateService extends Service implements NotificationsUpdateLogic.ServiceCompletionListener { private NotificationsUpdateLogic mNotificationsUpdateLogic; - @Override - protected void attachBaseContext(Context newBase) { - super.attachBaseContext(LocaleManager.setLocale(newBase)); - } - @Override public IBinder onBind(Intent intent) { return null; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverJobService.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverJobService.kt index 418b14ae67f5..c248d653939c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverJobService.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverJobService.kt @@ -2,7 +2,6 @@ package org.wordpress.android.ui.reader.services.discover import android.app.job.JobParameters import android.app.job.JobService -import android.content.Context import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope @@ -12,7 +11,6 @@ import org.wordpress.android.ui.reader.services.ServiceCompletionListener import org.wordpress.android.ui.reader.services.discover.ReaderDiscoverLogic.DiscoverTasks import org.wordpress.android.util.AppLog import org.wordpress.android.util.AppLog.T.READER -import org.wordpress.android.util.LocaleManager import javax.inject.Inject import javax.inject.Named import kotlin.coroutines.CoroutineContext @@ -31,10 +29,6 @@ class ReaderDiscoverJobService : JobService(), ServiceCompletionListener, Corout override val coroutineContext: CoroutineContext get() = ioDispatcher + job - override fun attachBaseContext(newBase: Context) { - super.attachBaseContext(LocaleManager.setLocale(newBase)) - } - override fun onStartJob(params: JobParameters): Boolean { AppLog.i(READER, "reader discover job service > started") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverService.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverService.kt index d34ca7f8da7e..e480981ff643 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverService.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverService.kt @@ -1,7 +1,6 @@ package org.wordpress.android.ui.reader.services.discover import android.app.Service -import android.content.Context import android.content.Intent import android.os.IBinder import dagger.hilt.android.AndroidEntryPoint @@ -14,7 +13,6 @@ import org.wordpress.android.ui.reader.services.discover.ReaderDiscoverLogic.Dis import org.wordpress.android.ui.reader.services.discover.ReaderDiscoverServiceStarter.ARG_DISCOVER_TASK import org.wordpress.android.util.AppLog import org.wordpress.android.util.AppLog.T.READER -import org.wordpress.android.util.LocaleManager import org.wordpress.android.util.extensions.getSerializableExtraCompat import javax.inject.Inject import javax.inject.Named @@ -41,10 +39,6 @@ class ReaderDiscoverService : Service(), ServiceCompletionListener, CoroutineSco return null } - override fun attachBaseContext(newBase: Context) { - super.attachBaseContext(LocaleManager.setLocale(newBase)) - } - override fun onCreate() { super.onCreate() AppLog.i(READER, "reader discover service > created") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateJobService.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateJobService.java index 64058405812e..a2f153cf2c3f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateJobService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateJobService.java @@ -2,12 +2,10 @@ import android.app.job.JobParameters; import android.app.job.JobService; -import android.content.Context; import org.wordpress.android.WordPress; import org.wordpress.android.ui.reader.services.ServiceCompletionListener; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.LocaleManager; import java.util.EnumSet; @@ -16,11 +14,6 @@ public class ReaderUpdateJobService extends JobService implements ServiceCompletionListener { private ReaderUpdateLogic mReaderUpdateLogic; - @Override - protected void attachBaseContext(Context newBase) { - super.attachBaseContext(LocaleManager.setLocale(newBase)); - } - @Override public boolean onStartJob(JobParameters params) { AppLog.i(AppLog.T.READER, "reader job service > started"); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateService.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateService.java index 5569b40bfc58..aa4451f84640 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/update/ReaderUpdateService.java @@ -1,14 +1,12 @@ package org.wordpress.android.ui.reader.services.update; import android.app.Service; -import android.content.Context; import android.content.Intent; import android.os.IBinder; import org.wordpress.android.WordPress; import org.wordpress.android.ui.reader.services.ServiceCompletionListener; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.LocaleManager; import java.util.EnumSet; @@ -28,11 +26,6 @@ public IBinder onBind(Intent intent) { return null; } - @Override - protected void attachBaseContext(Context newBase) { - super.attachBaseContext(LocaleManager.setLocale(newBase)); - } - @Override public void onCreate() { super.onCreate(); diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 4ed6ea34137a..89990a305eef 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -1,8 +1,6 @@ package org.wordpress.android.util -import android.annotation.SuppressLint import android.content.Context -import android.content.res.Configuration import android.text.TextUtils import org.wordpress.android.R import java.text.Collator @@ -20,16 +18,6 @@ object LocaleManager { */ private val LANGUAGE_SPLITTER: Pattern = Pattern.compile("_") - /** - * Activate the locale associated with the provided context. - * - * @param context The current context. - */ - @JvmStatic - fun setLocale(context: Context): Context { - return updateResources(context, getLanguage()) - } - /** * Compare the language for the current context with another language. * @@ -78,27 +66,6 @@ object LocaleManager { return langID ?: deviceLanguageCode } - /** - * Update resources for the current session. - * - * @param context The current active context - * @param language The 2-letter language code (example "en") - * @return The modified context containing the updated localized resources - */ - @SuppressLint("AppBundleLocaleChanges") - private fun updateResources(context: Context, language: String): Context { - val locale = languageLocale(language) - Locale.setDefault(locale) - - val res = context.resources - val config = Configuration(res.configuration) - - // NOTE: Earlier versions of Android require both of these to be set, otherwise - // RTL may not be implemented properly. - config.setLocale(locale) - return context.createConfigurationContext(config) - } - /** * Method gets around a bug in the java.util.Formatter for API 7.x as detailed here * [https://bugs.openjdk.java.net/browse/JDK-8167567]. Any strings that contain diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt index 25afbb0d14a3..151fae6a8758 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt @@ -13,5 +13,4 @@ class LocaleManagerWrapper fun getCurrentCalendar(): Calendar = Calendar.getInstance(getLocale()) fun getLanguage(): String = LocaleManager.getLanguage() fun isSameLanguage(language: String): Boolean = LocaleManager.isSameLanguage(language) - fun setLocale(context: Context): Context = LocaleManager.setLocale(context) } diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/ContextProvider.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/ContextProvider.kt index 04c0af3557f4..001054380da9 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/ContextProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/ContextProvider.kt @@ -1,16 +1,11 @@ package org.wordpress.android.viewmodel import android.content.Context -import org.wordpress.android.util.LocaleManager import javax.inject.Inject import javax.inject.Singleton @Singleton class ContextProvider @Inject constructor(private var context: Context) { - fun refreshContext() { - this.context = LocaleManager.setLocale(this.context) - } - fun getContext(): Context = context } From 5bd1ed3eacc330409f16a15849a6cd0459fee66d Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 15:38:01 -0500 Subject: [PATCH 36/45] Updated comment --- .../src/main/java/org/wordpress/android/util/LocaleManager.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 89990a305eef..714980c87ad2 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -8,9 +8,7 @@ import java.util.Locale import java.util.regex.Pattern /** - * Helper class for working with localized strings. Ensures updates to the users - * selected language is properly saved and resources appropriately updated for the - * android version. + * Helper class for working with localized strings */ object LocaleManager { /** From 5fa7c80a96febaa57c9a74240b1f6a338978a9d1 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 15:39:29 -0500 Subject: [PATCH 37/45] Removed updating the language shared pref --- .../org/wordpress/android/AppInitializer.kt | 3 +-- .../android/util/PerAppLocaleManager.kt | 23 +------------------ 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt index abbcc8a7ea95..a5af3e64975a 100644 --- a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt +++ b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt @@ -949,8 +949,7 @@ class AppInitializer @Inject constructor( */ private inner class MemoryAndConfigChangeMonitor : ComponentCallbacks2 { override fun onConfigurationChanged(newConfig: Configuration) { - // Make sure the in-app locale is correct - perAppLocaleManager.checkAndUpdateOldLanguagePrefKey() + // Do nothing } override fun onLowMemory() { diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 39a359fa7e51..e97c37c1990a 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -31,24 +31,6 @@ class PerAppLocaleManager @Inject constructor( private val siteStore: SiteStore, private val accountStore: AccountStore, ) { - /** - * We want to make sure the language pref for the in-app locale (old implementation) is set - * to the same locale as the AndroidX per-app locale. This way LocaleManager.getLanguage - - * which is used throughout the app - returns the correct language code. We can remove - * this once the per-app language pref is no longer experimental. - */ - fun checkAndUpdateOldLanguagePrefKey() { - val inAppLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") - val perAppLanguage = getCurrentLocale().language - if (perAppLanguage.isNotEmpty() && inAppLanguage.equals(perAppLanguage).not()) { - appPrefsWrapper.setPrefString(OLD_LOCALE_PREF_KEY_STRING, perAppLanguage) - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: changed inAppLanguage from $inAppLanguage to $perAppLanguage" - ) - } - } - /** * This routine can be helpful during development to reset the app locale */ @@ -62,7 +44,6 @@ class PerAppLocaleManager @Inject constructor( // on pre-Android 13 devices val appLocale = LocaleListCompat.forLanguageTags(languageCode.replace("_", "-")) AppCompatDelegate.setApplicationLocales(appLocale) - checkAndUpdateOldLanguagePrefKey() } /** @@ -85,8 +66,6 @@ class PerAppLocaleManager @Inject constructor( ) setCurrentLocaleByLanguageCode(Locale.getDefault().language) } - } else { - checkAndUpdateOldLanguagePrefKey() } } @@ -135,7 +114,7 @@ class PerAppLocaleManager @Inject constructor( companion object { // Key previously used for saving the language selection to shared preferences. - const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" + private const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" private fun getCurrentLocale(): Locale { val locales = AppCompatDelegate.getApplicationLocales() From 03cac31113f80df9439370bc229cf5b814878f84 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 15:52:55 -0500 Subject: [PATCH 38/45] Added TODO --- .../src/main/java/org/wordpress/android/util/LocaleManager.kt | 4 +++- .../java/org/wordpress/android/util/PerAppLocaleManager.kt | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 714980c87ad2..0d86ebe605c1 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -64,6 +64,7 @@ object LocaleManager { return langID ?: deviceLanguageCode } + @Suppress("ForbiddenComment") /** * Method gets around a bug in the java.util.Formatter for API 7.x as detailed here * [https://bugs.openjdk.java.net/browse/JDK-8167567]. Any strings that contain @@ -74,7 +75,8 @@ object LocaleManager { * An example of a string that contains locale-specific grouping separators: * ` * %,d likes - ` * + `* + * TODO: This is a workaround for a bug in API 7, which we no longer support. Investigate removing this. */ @JvmStatic fun getSafeLocale(context: Context?): Locale { diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index e97c37c1990a..084cc65e1f09 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -111,9 +111,8 @@ class PerAppLocaleManager @Inject constructor( ReaderUpdateServiceStarter.startService(getContext(), EnumSet.of(UpdateTask.TAGS)) } - companion object { - // Key previously used for saving the language selection to shared preferences. + // Key previously used for saving the language selection to shared preferences private const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" private fun getCurrentLocale(): Locale { From 394943fead0144ec21a52c3fedde0129847e6ba2 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Tue, 17 Dec 2024 16:01:18 -0500 Subject: [PATCH 39/45] Remove language pref during migration --- .../java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt | 4 ++-- .../java/org/wordpress/android/util/PerAppLocaleManager.kt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt index 2300c40b1437..4c0e962cc801 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefsWrapper.kt @@ -460,8 +460,8 @@ class AppPrefsWrapper @Inject constructor(val buildConfigWrapper: BuildConfigWra return AppPrefs.prefs().getString(key, defValue) } - fun setPrefString(key: String, value: String) { - AppPrefs.prefs().edit().putString(key, value).apply() + fun removePref(key: String) { + AppPrefs.prefs().edit().remove(key).apply() } fun getDebugBooleanPref(key: String, default: Boolean = false) = diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 084cc65e1f09..f157a6d7e217 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -59,6 +59,7 @@ class PerAppLocaleManager @Inject constructor( "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" ) setCurrentLocaleByLanguageCode(previousLanguage) + appPrefsWrapper.removePref(OLD_LOCALE_PREF_KEY_STRING) } else { appLogWrapper.d( AppLog.T.SETTINGS, From ca88e3728faedc1e80fb0a0ba22852105d173fd4 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Wed, 18 Dec 2024 07:27:37 -0500 Subject: [PATCH 40/45] Minor cleanup --- .../android/util/PerAppLocaleManager.kt | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index f157a6d7e217..0e6e6d52ce81 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -31,14 +31,6 @@ class PerAppLocaleManager @Inject constructor( private val siteStore: SiteStore, private val accountStore: AccountStore, ) { - /** - * This routine can be helpful during development to reset the app locale - */ - @Suppress("unused") - fun resetApplicationLocale() { - AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList()) - } - private fun setCurrentLocaleByLanguageCode(languageCode: String) { // We shouldn't have to replace "_" with "-" but this is in order to work with our existing language picker // on pre-Android 13 devices @@ -50,23 +42,14 @@ class PerAppLocaleManager @Inject constructor( * Previously the app locale was stored in SharedPreferences, so here we migrate to AndroidX per-app language prefs */ fun performMigrationIfNecessary() { - val locales = AppCompatDelegate.getApplicationLocales() - if (locales.isEmpty || locales == LocaleListCompat.getEmptyLocaleList()) { - val previousLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") - if (previousLanguage?.isNotEmpty() == true) { - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" - ) - setCurrentLocaleByLanguageCode(previousLanguage) - appPrefsWrapper.removePref(OLD_LOCALE_PREF_KEY_STRING) - } else { - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: setting default locale" - ) - setCurrentLocaleByLanguageCode(Locale.getDefault().language) - } + val previousLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") + if (previousLanguage?.isNotEmpty() == true) { + appLogWrapper.d( + AppLog.T.SETTINGS, + "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" + ) + setCurrentLocaleByLanguageCode(previousLanguage) + appPrefsWrapper.removePref(OLD_LOCALE_PREF_KEY_STRING) } } @@ -87,7 +70,7 @@ class PerAppLocaleManager @Inject constructor( @Suppress("ForbiddenComment") /** * Called when the device language is changed from our in-app language picker - * TODO: Detect when language changed from app settings dialog + * TODO: Detect when language changed from system app settings dialog */ fun onLanguageChanged(languageCode: String) { if (languageCode.isEmpty()) { @@ -112,8 +95,16 @@ class PerAppLocaleManager @Inject constructor( ReaderUpdateServiceStarter.startService(getContext(), EnumSet.of(UpdateTask.TAGS)) } + /** + * This routine can be helpful during development to reset the app locale + */ + @Suppress("unused") + fun resetApplicationLocale() { + AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList()) + } + companion object { - // Key previously used for saving the language selection to shared preferences + // Key previously used for saving the language selection to shared preferences private const val OLD_LOCALE_PREF_KEY_STRING: String = "language-pref" private fun getCurrentLocale(): Locale { From ef7288846d30a986b6b7f168a1e660b494fb15f6 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 19 Dec 2024 07:58:03 -0500 Subject: [PATCH 41/45] Minor cleanup --- .../wordpress/android/util/LocaleManager.kt | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 9fb71953e684..213deae1d2db 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -19,12 +19,15 @@ object LocaleManager { /** * Key used for saving the language selection to shared preferences. */ - private const val LOCALE_PREF_KEY_STRING: String = "language-pref" + private const val LOCALE_PREF_KEY_STRING = "language-pref" /** * Pattern to split a language string (to parse the language and region values). */ - private val LANGUAGE_SPLITTER: Pattern = Pattern.compile("_") + private val LANGUAGE_SPLITTER = Pattern.compile("_") + + private const val MIN_LANGUAGE_CODE_LENGTH = 2 + private const val MAX_LANGUAGE_CODE_LENGTH = 6 /** * Activate the locale associated with the provided context. @@ -109,13 +112,13 @@ object LocaleManager { * Method gets around a bug in the java.util.Formatter for API 7.x as detailed here * [https://bugs.openjdk.java.net/browse/JDK-8167567]. Any strings that contain * locale-specific grouping separators should use: - * ` - * String.format(LocaleManager.getSafeLocale(context), baseString, val) + * + * `String.format(LocaleManager.getSafeLocale(context), baseString, val)` * * An example of a string that contains locale-specific grouping separators: - * ` - * %,d likes - ` * + * + * ` %,d likes ` + * */ @JvmStatic fun getSafeLocale(context: Context?): Locale { @@ -158,7 +161,7 @@ object LocaleManager { val languageIds = context.resources.getStringArray(R.array.lang_ids) val languageCodes = context.resources.getStringArray(R.array.language_codes) - val languageMap: MutableMap = HashMap() + val languageMap = hashMapOf() var i = 0 while (i < languageIds.size && i < languageCodes.size) { languageMap[languageCodes[i]] = languageIds[i] @@ -220,9 +223,11 @@ object LocaleManager { * Return a non-null display string for a given language code. */ @JvmStatic - @Suppress("MagicNumber") fun getLanguageString(languageCode: String?, displayLocale: Locale): String { - if (languageCode == null || languageCode.length < 2 || languageCode.length > 6) { + if (languageCode == null || + languageCode.length < MIN_LANGUAGE_CODE_LENGTH + || languageCode.length > MAX_LANGUAGE_CODE_LENGTH + ) { return "" } From 980b8d6353b5cad824d005f603907322e821632d Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 19 Dec 2024 08:15:42 -0500 Subject: [PATCH 42/45] Minor cleanup p2 --- .../java/org/wordpress/android/util/LocaleManager.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 213deae1d2db..324f113a0a63 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -201,8 +201,10 @@ object LocaleManager { for (i in entryStrings.indices) { // now, we can split the sorted array to extract the display string and the language code - val split = - entryStrings[i].split("__".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() + val split = entryStrings[i] + .split("__".toRegex()) + .dropLastWhile { it.isEmpty() } + .toTypedArray() sortedEntries[i] = split[0] sortedValues[i] = split[1] detailStrings[i] = @@ -224,8 +226,8 @@ object LocaleManager { */ @JvmStatic fun getLanguageString(languageCode: String?, displayLocale: Locale): String { - if (languageCode == null || - languageCode.length < MIN_LANGUAGE_CODE_LENGTH + if (languageCode == null + || languageCode.length < MIN_LANGUAGE_CODE_LENGTH || languageCode.length > MAX_LANGUAGE_CODE_LENGTH ) { return "" From 826d2270545a39fd1980dc306a570b8d3e30a9ca Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 19 Dec 2024 10:01:40 -0500 Subject: [PATCH 43/45] Removed language detection from PersonalizationViewModel, removed isSameLanguage --- .../personalization/PersonalizationViewModel.kt | 12 ------------ .../java/org/wordpress/android/util/LocaleManager.kt | 10 ---------- .../wordpress/android/util/LocaleManagerWrapper.kt | 1 - 3 files changed, 23 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationViewModel.kt index 8df784930ae2..082efe6b6de0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationViewModel.kt @@ -7,7 +7,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineDispatcher import org.wordpress.android.modules.BG_THREAD import org.wordpress.android.ui.mysite.SelectedSiteRepository -import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.viewmodel.ScopedViewModel import javax.inject.Inject import javax.inject.Named @@ -20,7 +19,6 @@ class PersonalizationViewModel @Inject constructor( private val selectedSiteRepository: SelectedSiteRepository, private val shortcutsPersonalizationViewModelSlice: ShortcutsPersonalizationViewModelSlice, private val dashboardCardPersonalizationViewModelSlice: DashboardCardPersonalizationViewModelSlice, - private val localeManagerWrapper: LocaleManagerWrapper ) : ScopedViewModel(bgDispatcher) { val uiState = dashboardCardPersonalizationViewModelSlice.uiState val shortcutsState = shortcutsPersonalizationViewModelSlice.uiState @@ -32,7 +30,6 @@ class PersonalizationViewModel @Inject constructor( val appLanguage = _appLanguage as LiveData init { - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) shortcutsPersonalizationViewModelSlice.initialize(viewModelScope) dashboardCardPersonalizationViewModelSlice.initialize(viewModelScope) } @@ -67,13 +64,4 @@ class PersonalizationViewModel @Inject constructor( val siteId = selectedSiteRepository.getSelectedSite()!!.siteId shortcutsPersonalizationViewModelSlice.addShortcut(shortcutState,siteId) } - - private fun emitLanguageRefreshIfNeeded(languageCode: String) { - if (languageCode.isNotEmpty()) { - val shouldEmitLanguageRefresh = !localeManagerWrapper.isSameLanguage(languageCode) - if (shouldEmitLanguageRefresh) { - _appLanguage.value = languageCode - } - } - } } diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index a13a7ab50e4b..21dd06286d0f 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -19,16 +19,6 @@ object LocaleManager { private const val MIN_LANGUAGE_CODE_LENGTH = 2 private const val MAX_LANGUAGE_CODE_LENGTH = 6 - /** - * Compare the language for the current context with another language. - * - * @param language The language to compare - * @return True if the languages are the same, else false - */ - fun isSameLanguage(language: String): Boolean { - val newLocale = languageLocale(language) - return Locale.getDefault().toString() == newLocale.toString() - } @Suppress("ForbiddenComment") /** diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt index 151fae6a8758..0e24a3281caa 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManagerWrapper.kt @@ -12,5 +12,4 @@ class LocaleManagerWrapper fun getTimeZone(): TimeZone = TimeZone.getDefault() fun getCurrentCalendar(): Calendar = Calendar.getInstance(getLocale()) fun getLanguage(): String = LocaleManager.getLanguage() - fun isSameLanguage(language: String): Boolean = LocaleManager.isSameLanguage(language) } From 0dbf35b92b9a590f887fdc071675cf9b19916cdd Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 19 Dec 2024 10:12:18 -0500 Subject: [PATCH 44/45] Updated comment --- .../java/org/wordpress/android/util/PerAppLocaleManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt index 0e6e6d52ce81..dc51b00f2b7d 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -39,7 +39,8 @@ class PerAppLocaleManager @Inject constructor( } /** - * Previously the app locale was stored in SharedPreferences, so here we migrate to AndroidX per-app language prefs + * Previously the app locale was stored in SharedPreferences, so here we migrate to AndroidX per-app language prefs. + * This was added in our Jan 2025 release and can be removed after a few subsequent releases. */ fun performMigrationIfNecessary() { val previousLanguage = appPrefsWrapper.getPrefString(OLD_LOCALE_PREF_KEY_STRING, "") From 6c20c6aeaea472261a6959cbd468dd069b071d7e Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 20 Dec 2024 07:40:04 -0500 Subject: [PATCH 45/45] Simplify splitting language display name and code --- .../main/java/org/wordpress/android/util/LocaleManager.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt index 21dd06286d0f..ff1c1534e89d 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.kt @@ -152,10 +152,7 @@ object LocaleManager { for (i in entryStrings.indices) { // now, we can split the sorted array to extract the display string and the language code - val split = entryStrings[i] - .split("__".toRegex()) - .dropLastWhile { it.isEmpty() } - .toTypedArray() + val split = entryStrings[i].split("__") sortedEntries[i] = split[0] sortedValues[i] = split[1] detailStrings[i] =