From 3dfe5de15a714c315d124656f2bbc9bc62afd967 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 11:07:00 -0500 Subject: [PATCH 01/23] 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 02/23] 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 03/23] 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 04/23] 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 05/23] 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 38b3baf1674f2c519308ec9b4ca09278c3b400f4 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 14:31:53 -0500 Subject: [PATCH 06/23] 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 f647806c425882fa738b3cf85d2905e59eca04c9 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 15:17:35 -0500 Subject: [PATCH 07/23] Removed unused code from LocaleManager --- .../wordpress/android/util/LocaleManager.java | 37 ------------------- 1 file changed, 37 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..ce210b07f393 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -48,24 +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. @@ -263,25 +245,6 @@ 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. */ From f42c7bb68a8c84ea765653f4912b1021c1236379 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 15:38:37 -0500 Subject: [PATCH 08/23] Removed storing language in prefs --- .../ui/screenshots/WPLocaleTestRule.java | 61 ------------------- .../org/wordpress/android/AppInitializer.kt | 7 +-- .../UserFlagsProviderHelper.kt | 1 - .../migration/JetpackMigrationViewModel.kt | 6 -- .../android/ui/prefs/AppPrefsWrapper.kt | 12 ++-- .../util/JetpackMigrationLanguageUtil.kt | 1 - .../wordpress/android/util/LocaleManager.java | 49 ++------------- .../android/util/LocaleManagerWrapper.kt | 1 - .../android/util/PerAppLocaleManager.kt | 36 ++++------- 9 files changed, 25 insertions(+), 149 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/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/main/java/org/wordpress/android/AppInitializer.kt b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt index e3b7fb142355..bd06ec964df0 100644 --- a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt +++ b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt @@ -100,7 +100,6 @@ 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 import org.wordpress.android.util.ProfilingUtils import org.wordpress.android.util.QuickStartUtils import org.wordpress.android.util.RateLimitedTask @@ -232,9 +231,6 @@ class AppInitializer @Inject constructor( @Inject lateinit var jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper - @Inject - lateinit var perAppLocaleManager: PerAppLocaleManager - private lateinit var applicationLifecycleMonitor: ApplicationLifecycleMonitor @Suppress("DEPRECATION") @@ -950,8 +946,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/localcontentmigration/UserFlagsProviderHelper.kt b/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt index 5d8a75087824..c8e94cc28d54 100644 --- a/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt @@ -73,6 +73,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/ui/main/jetpack/migration/JetpackMigrationViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModel.kt index dda1b9350851..09fd83d5ed80 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 @@ -173,7 +173,6 @@ class JetpackMigrationViewModel @Inject constructor( } if (data.flags.isNotEmpty()) { - emitLanguageRefreshIfNeeded(extractLanguageFromFlagsMap(data.flags)) _refreshAppTheme.value = Unit } @@ -189,11 +188,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) 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..f2ae2c3bfb4d 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,10 +460,6 @@ 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 getDebugBooleanPref(key: String, default: Boolean = false) = buildConfigWrapper.isDebug() && AppPrefs.getRawBoolean({ key }, default) @@ -487,6 +483,14 @@ class AppPrefsWrapper @Inject constructor(val buildConfigWrapper: BuildConfigWra AppPrefs.putStringSet(prefKey, set) } + fun removePref(key: String) { + AppPrefs.prefs().edit().remove(key).apply() + } + + fun setPrefString(key: String, value: String) { + AppPrefs.prefs().edit().putString(key, value).apply() + } + var savedPrivacyBannerSettings: Boolean get() = getBoolean(AppPrefs.DeletablePrefKey.HAS_SAVED_PRIVACY_SETTINGS, false) set(value) = AppPrefs.setBoolean(AppPrefs.DeletablePrefKey.HAS_SAVED_PRIVACY_SETTINGS, value) diff --git a/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt b/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt index b1a4621326b2..0c53dbab674e 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt @@ -10,7 +10,6 @@ class JetpackMigrationLanguageUtil @Inject constructor( fun applyLanguage(languageCode: String) { if (languageCode.isEmpty()) return - LocaleManager.setNewLocale(WordPress.getContext(), languageCode) WordPress.updateContextLocale() contextProvider.refreshContext() } 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 ce210b07f393..b051d4d1092d 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -2,14 +2,12 @@ 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; @@ -29,11 +27,6 @@ * android version. */ public class LocaleManager { - /** - * Key used for saving the language selection to shared preferences. - */ - private static final String LANGUAGE_KEY = "language-pref"; - /** * Pattern to split a language string (to parse the language and region values). */ @@ -48,21 +41,6 @@ public static Context setLocale(Context context) { return updateResources(context, getLanguage(context)); } - /** - * 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. * @@ -75,14 +53,13 @@ public static boolean isSameLanguage(@NonNull String language) { } /** - * If the user has selected a language other than the device default, return that - * language code, else just return the device default language code. + * Previously the app stored the language code in shared preferences, but now we use + * per-app language preferences so just return the device default language code. * - * @return The 2-letter language code (example "en") + * TODO remove this routine */ public static String getLanguage(Context context) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - return prefs.getString(LANGUAGE_KEY, LanguageUtils.getCurrentDeviceLanguageCode()); + return LanguageUtils.getCurrentDeviceLanguageCode(); } /** @@ -114,20 +91,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. * @@ -262,8 +225,4 @@ public static String getLanguageString(String languageCode, Locale displayLocale } return displayLanguage; } - - public static String getLocalePrefKeyString() { - return LANGUAGE_KEY; - } } 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 4eb5a11db067..f1e5ef1ff029 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -55,24 +55,9 @@ class PerAppLocaleManager @Inject constructor( } /** - * 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. + * This can be helpful during development to reset the app locale back to the default */ - fun checkAndUpdateOldLanguagePrefKey() { - val prefKey = LocaleManager.getLocalePrefKeyString() - val inAppLanguage = appPrefsWrapper.getPrefString(prefKey, "") - val perAppLanguage = getCurrentLocale().language - if (perAppLanguage.isNotEmpty() && inAppLanguage.equals(perAppLanguage).not()) { - appPrefsWrapper.setPrefString(prefKey, perAppLanguage) - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: changed inAppLanguage from $inAppLanguage to $perAppLanguage" - ) - } - } - + @Suppress("unused") fun resetApplicationLocale() { AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList()) } @@ -82,22 +67,22 @@ class PerAppLocaleManager @Inject constructor( // on pre-Android 13 devices val appLocale = LocaleListCompat.forLanguageTags(languageCode.replace("_", "-")) AppCompatDelegate.setApplicationLocales(appLocale) - checkAndUpdateOldLanguagePrefKey() } /** - * Previously the app locale was stored in SharedPreferences, so here we migrate to AndroidX per-app language prefs + * Check the old language pref to see if the user previously changed the language, and if so make sure + * that the per-app language is set to the same language. */ fun performMigrationIfNecessary() { if (isApplicationLocaleEmpty()) { - val prefKey = LocaleManager.getLocalePrefKeyString() - val previousLanguage = appPrefsWrapper.getPrefString(prefKey, "") + val previousLanguage = appPrefsWrapper.getPrefString(OLD_LANGUAGE_PREF_KEY, "") if (previousLanguage?.isNotEmpty() == true) { appLogWrapper.d( AppLog.T.SETTINGS, "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" ) setCurrentLocaleByLanguageCode(previousLanguage) + appPrefsWrapper.removePref(OLD_LANGUAGE_PREF_KEY) } else { appLogWrapper.d( AppLog.T.SETTINGS, @@ -105,8 +90,6 @@ class PerAppLocaleManager @Inject constructor( ) setCurrentLocaleByLanguageCode(Locale.getDefault().language) } - } else { - checkAndUpdateOldLanguagePrefKey() } } @@ -134,7 +117,7 @@ class PerAppLocaleManager @Inject constructor( } // Only update if the language is different - if (languageCode.equals(getCurrentLocaleLanguageCode()).not()) { + if ((languageCode != getCurrentLocaleLanguageCode())) { setCurrentLocaleByLanguageCode(languageCode) } @@ -150,4 +133,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. + private const val OLD_LANGUAGE_PREF_KEY: String = "language-pref" + } } From c9789331aa9c234fb40d59a434605eb09cf095c4 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 16:03:33 -0500 Subject: [PATCH 09/23] Removed JetpackMigrationLanguageUtil.kt --- .../migration/JetpackMigrationViewModel.kt | 4 +--- .../android/ui/mysite/menu/MenuViewModel.kt | 4 +--- .../android/util/JetpackMigrationLanguageUtil.kt | 16 ---------------- 3 files changed, 2 insertions(+), 22 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 09fd83d5ed80..8cd3bbb5fc1b 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.JetpackMigrationLanguageUtil import org.wordpress.android.util.LocaleManagerWrapper import org.wordpress.android.util.SiteUtilsWrapper import org.wordpress.android.util.config.PreventDuplicateNotifsFeatureConfig @@ -91,7 +90,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() @@ -198,7 +196,7 @@ class JetpackMigrationViewModel @Inject constructor( } fun setAppLanguage(locale: Locale) { - jetpackMigrationLanguageUtil.applyLanguage(locale.language) + // TODO remove this } @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) 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..c38dfa402de4 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 @@ -47,7 +46,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, @@ -269,7 +267,7 @@ class MenuViewModel @Inject constructor( } fun setAppLanguage(locale: Locale) { - jetpackMigrationLanguageUtil.applyLanguage(locale.language) + // TODO remove this } override fun 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 0c53dbab674e..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/util/JetpackMigrationLanguageUtil.kt +++ /dev/null @@ -1,16 +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 - - WordPress.updateContextLocale() - contextProvider.refreshContext() - } -} From 4cd64f3dab9f92c6260a44f92b557d7bcb91b1ed Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 12 Dec 2024 16:08:38 -0500 Subject: [PATCH 10/23] Removed locale from Jetpack migration --- .../migration/JetpackMigrationFragment.kt | 11 ++------- .../migration/JetpackMigrationViewModel.kt | 24 ------------------- 2 files changed, 2 insertions(+), 33 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 8cd3bbb5fc1b..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,12 +66,10 @@ 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 import org.wordpress.android.viewmodel.ScopedViewModel -import java.util.Locale import javax.inject.Inject import javax.inject.Named @@ -89,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() @@ -97,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) @@ -186,19 +180,6 @@ class JetpackMigrationViewModel @Inject constructor( ) } - private fun emitLanguageRefreshIfNeeded(languageCode: String) { - if (languageCode.isNotEmpty()) { - val shouldEmitLanguageRefresh = !localeManagerWrapper.isSameLanguage(languageCode) - if (shouldEmitLanguageRefresh) { - _refreshAppLanguage.value = languageCode - } - } - } - - fun setAppLanguage(locale: Locale) { - // TODO remove this - } - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) fun initNotificationsScreenUi(): Notifications { migrationAnalyticsTracker.trackNotificationsScreenShown() @@ -231,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 { From 562c7bad47c3115b3301af22bcfdd2c3f5ca814d Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 08:05:44 -0500 Subject: [PATCH 11/23] Removed LANGUAGE_CHANGED --- .../wordpress/android/ui/main/MeActivity.kt | 19 ------------------- .../android/ui/main/WPMainActivity.java | 17 ----------------- .../android/ui/prefs/AppSettingsFragment.java | 2 -- .../android/util/PerAppLocaleManager.kt | 7 +++++++ 4 files changed, 7 insertions(+), 38 deletions(-) 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 d8f742b5d13c..4e5a4bca8e1e 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 @@ -1,13 +1,10 @@ package org.wordpress.android.ui.main -import android.content.Intent import android.os.Bundle import android.view.MenuItem import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R 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 @@ -24,20 +21,4 @@ class MeActivity : AppCompatActivity() { } return super.onOptionsItemSelected(item) } - - @Suppress("DEPRECATION", "OVERRIDE_DEPRECATION") - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - when (requestCode) { - RequestCodes.APP_SETTINGS -> { - if (resultCode == LANGUAGE_CHANGED) { - // Refresh the app - val refresh = Intent(this, this.javaClass) - startActivity(refresh) - setResult(LANGUAGE_CHANGED) - finish() - } - } - } - } } 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 b187af605256..926759d4e7c6 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 @@ -8,7 +8,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.HapticFeedbackConstants; @@ -124,7 +123,6 @@ import org.wordpress.android.ui.posts.QuickStartPromptDialogFragment.QuickStartPromptClickInterface; import org.wordpress.android.ui.prefs.AppPrefs; 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.ui.prefs.privacy.banner.PrivacyBannerFragment; import org.wordpress.android.ui.quickstart.QuickStartMySitePrompts; @@ -1465,9 +1463,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } break; case RequestCodes.APP_SETTINGS: - if (resultCode == AppSettingsFragment.LANGUAGE_CHANGED) { - appLanguageChanged(); - } break; case RequestCodes.NOTE_DETAIL: if (getNotificationsListFragment() != null) { @@ -1499,18 +1494,6 @@ private void handleUpdateResult(int resultCode, int updateType) { } } - private void appLanguageChanged() { - // Recreate this activity (much like a configuration change) - // We need to post this call to UI thread, since it's called from onActivityResult and the call interferes with - // onResume that is called right afterwards. - new Handler(Looper.getMainLooper()).post(this::recreate); - - // When language changed we need to reset the shared prefs reader tag since if we have it stored - // it's fields can be in a different language and we can get odd behaviors since we will generally fail - // to get the ReaderTag.equals method recognize the equality based on the ReaderTag.getLabel method. - AppPrefs.setReaderTag(null); - } - private void startWithNewAccount() { mGCMRegistrationScheduler.scheduleRegistration(); ReaderUpdateServiceStarter.startService(this, EnumSet.of(UpdateTask.TAGS, UpdateTask.FOLLOWED_BLOGS)); 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..9eb9fb30759a 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 @@ -76,8 +76,6 @@ public class AppSettingsFragment extends PreferenceFragment implements OnPreferenceClickListener, Preference.OnPreferenceChangeListener, LocalePickerCallback { - public static final int LANGUAGE_CHANGED = 1000; - private WPPreference mLanguagePreference; private ListPreference mAppThemePreference; private ListPreference mInitialScreenPreference; 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 f1e5ef1ff029..bd7e2bbff6c5 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -13,6 +13,7 @@ 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.AppPrefs 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 @@ -130,6 +131,12 @@ class PerAppLocaleManager @Inject constructor( // Language is now part of metadata, so we need to refresh them AnalyticsUtils.refreshMetadata(accountStore, siteStore) + + // When language changed we need to reset the shared prefs reader tag since if we have it stored + // it's fields can be in a different language and we can get odd behaviors since we will generally fail + // to get the ReaderTag.equals method recognize the equality based on the ReaderTag.getLabel method. + AppPrefs.setReaderTag(null) + // update Reader tags as they need be localized ReaderUpdateServiceStarter.startService(getContext(), EnumSet.of(UpdateTask.TAGS)) } From e71c2eb8b578796590df7c98e58d0c45996eeab3 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 08:16:30 -0500 Subject: [PATCH 12/23] Removed unused import --- .../android/localcontentmigration/UserFlagsProviderHelper.kt | 2 -- 1 file changed, 2 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 c8e94cc28d54..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( From d002d2fcfa83a75568079f1d1d5cf30f8c67c1d9 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 08:20:06 -0500 Subject: [PATCH 13/23] Removed LocaleAwareComposable --- .../android/ui/compose/utils/ComposeUtils.kt | 50 ------------------- .../android/ui/mysite/menu/MenuActivity.kt | 11 +--- .../android/ui/mysite/menu/MenuViewModel.kt | 5 -- .../PersonalizationActivity.kt | 9 +--- 4 files changed, 4 insertions(+), 71 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/compose/utils/ComposeUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/compose/utils/ComposeUtils.kt index 41e13d4aa480..39b35346175d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/compose/utils/ComposeUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/compose/utils/ComposeUtils.kt @@ -1,18 +1,9 @@ package org.wordpress.android.ui.compose.utils -import android.annotation.SuppressLint -import android.content.res.Configuration import androidx.compose.material.LocalContentAlpha import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.compose.ui.unit.LayoutDirection import org.wordpress.android.ui.compose.components.ContentAlphaProvider -import org.wordpress.android.util.extensions.isRtl -import org.wordpress.android.util.extensions.primaryLocale -import java.util.Locale /** * Utility function that returns a Composable function that wraps the [content] inside a [ContentAlphaProvider] @@ -26,47 +17,6 @@ fun withFullContentAlpha(content: @Composable () -> Unit): @Composable () -> Uni ) } -/** - * Utility function that wraps the [content] inside a [CompositionLocalProvider] overriding the [LocalContext] - * configuration with the specified [locale] when the specified language should apply. - * Useful to apply a custom language to Compose UIs that do not respond correctly to app language changes. - * @param locale The locale to be used in the [LocalContext] configuration override. - * @param onLocaleChange Callback to be invoked when the locale is overridden, useful to update other app components. - * @param content The Composable function to be rendered with the overridden locale. - */ - -@Composable -@Suppress("DEPRECATION") -@SuppressLint("AppBundleLocaleChanges") -fun LocaleAwareComposable( - locale: Locale = Locale.getDefault(), - onLocaleChange: (Locale) -> Unit = {}, - content: @Composable () -> Unit, -) { - val context = LocalContext.current - val resources = context.resources - val configuration = resources.configuration - - val currentLocale = context.primaryLocale - if (currentLocale != locale) { - val newConfiguration = Configuration(configuration).apply { - setLocale(locale) - } - - val newContext = context.createConfigurationContext(newConfiguration) - val newLayoutDirection = if (newConfiguration.isRtl()) LayoutDirection.Rtl else LayoutDirection.Ltr - onLocaleChange(locale) - CompositionLocalProvider( - LocalContext provides newContext, - LocalLayoutDirection provides newLayoutDirection, - ) { - content() - } - } else { - content() - } -} - /** * Indicates whether the currently selected theme is light. * @return true if the current theme is light 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..48f90a947ed5 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 c38dfa402de4..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 @@ -36,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 @@ -266,10 +265,6 @@ class MenuViewModel @Inject constructor( } } - fun setAppLanguage(locale: Locale) { - // TODO remove this - } - override fun onCleared() { jetpackCapabilitiesUseCase.clear() super.onCleared() diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt index 207f4e13e400..6edb539a2d1f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/personalization/PersonalizationActivity.kt @@ -33,6 +33,7 @@ import androidx.compose.material3.TabRow import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar 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 @@ -54,11 +55,9 @@ import androidx.compose.ui.unit.sp import dagger.hilt.android.AndroidEntryPoint import org.wordpress.android.R 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.items.listitem.ListItemAction import org.wordpress.android.ui.utils.UiString -import org.wordpress.android.util.LocaleManager @AndroidEntryPoint class PersonalizationActivity : AppCompatActivity() { @@ -68,11 +67,7 @@ class PersonalizationActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContent { AppThemeM3 { - val language by viewModel.appLanguage.observeAsState("") - - LocaleAwareComposable( - locale = LocaleManager.languageLocale(language), - ) { + CompositionLocalProvider{ viewModel.start() PersonalizationScreen() } From bbe4f961975924ebdb4f9bd576158ed3ac4c8656 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 08:24:37 -0500 Subject: [PATCH 14/23] Removed unused var --- .../java/org/wordpress/android/ui/prefs/AppSettingsFragment.java | 1 - 1 file changed, 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 9eb9fb30759a..58a3b67a4137 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 @@ -78,7 +78,6 @@ public class AppSettingsFragment extends PreferenceFragment implements OnPreferenceClickListener, Preference.OnPreferenceChangeListener, LocalePickerCallback { private WPPreference mLanguagePreference; private ListPreference mAppThemePreference; - private ListPreference mInitialScreenPreference; // This Device settings private WPSwitchPreference mOptimizedImage; From 521ad211ead52dfc9d223719aba8dd774d770f06 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 09:22:09 -0500 Subject: [PATCH 15/23] Updated getLanguageCode --- .../android/models/recommend/RecommendApiCallsProvider.kt | 2 +- .../android/push/NotificationsProcessingService.java | 2 +- .../cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt | 2 +- .../org/wordpress/android/ui/mysite/menu/MenuViewModel.kt | 2 +- .../ui/mysite/personalization/PersonalizationViewModel.kt | 2 +- .../services/NotificationsUpdateJobService.java | 2 +- .../services/NotificationsUpdateService.java | 2 +- .../org/wordpress/android/ui/posts/EditPostActivity.kt | 2 +- .../reader/discover/interests/ReaderInterestsFragment.kt | 2 +- .../android/ui/reader/repository/ReaderPostRepository.kt | 2 +- .../ui/reader/services/discover/ReaderDiscoverLogic.kt | 2 +- .../ui/reader/services/search/ReaderSearchLogic.java | 2 +- .../ui/reader/services/update/ReaderUpdateLogic.java | 2 +- .../java/org/wordpress/android/util/LocaleManager.java | 8 +++----- .../org/wordpress/android/util/LocaleManagerWrapper.kt | 2 +- .../models/recommend/RecommendApiCallsProviderTest.kt | 2 +- .../jetpack/migration/JetpackMigrationViewModelTest.kt | 4 ++-- .../sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt | 2 +- .../wordpress/android/ui/mysite/menu/MenuViewModelTest.kt | 2 +- 19 files changed, 22 insertions(+), 24 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt b/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt index e324f64e5679..aec40a9d417b 100644 --- a/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt @@ -38,7 +38,7 @@ class RecommendApiCallsProvider @Inject constructor( logErrorAndTrack(source, "getRecommendTemplate > No Network available") cont.resume(Failure(contextProvider.getContext().getString(R.string.no_network_message))) } else { - val language = localeManagerWrapper.getLanguage() + val language = localeManagerWrapper.getLanguageCode() val endPointPath = "/mobile/share-app-link?app=$appName&locale=$language" val listener = Listener { jsonObject -> 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..3217c9f4f12c 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.getLanguageCode()); WordPress.getRestClientUtils().getNotification(params, noteId, listener, errorListener); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt index dab700fd2656..609534f5910f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt @@ -75,7 +75,7 @@ class WpSotw2023NudgeCardViewModelSlice @Inject constructor( val now = dateTimeUtilsWrapper.getInstantNow() val isDateEligible = now.isAfter(eventTime) - val currentLanguage = localeManagerWrapper.getLanguage() + val currentLanguage = localeManagerWrapper.getLanguageCode() val isLanguageEligible = currentLanguage.startsWith(TARGET_LANGUAGE, ignoreCase = true) return featureConfig.isEnabled() && 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..d38264a1a520 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 @@ -79,7 +79,7 @@ class MenuViewModel @Inject constructor( private var isStarted = false init { - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) + emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguageCode()) } fun start(quickStartEvent: QuickStartEvent? = null) { 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..97f4bdd59eac 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 @@ -32,7 +32,7 @@ class PersonalizationViewModel @Inject constructor( val appLanguage = _appLanguage as LiveData init { - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) + emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguageCode()) shortcutsPersonalizationViewModelSlice.initialize(viewModelScope) dashboardCardPersonalizationViewModelSlice.initialize(viewModelScope) } 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..002b784f79e6 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.getLanguageCode(), 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..473f7744af5e 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.getLanguageCode(), 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..0975269f6832 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.getLanguageCode() 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/reader/discover/interests/ReaderInterestsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsFragment.kt index cad0696f0433..8e734c8958a2 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.getLanguageCode(), parentViewModel, entryPoint ) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt index 503682566dbb..2ccc31eb96e5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt @@ -93,7 +93,7 @@ class ReaderPostRepository @Inject constructor( sb.append("&before=").append(UrlUtils.urlEncode(beforeDate)) } sb.append("&meta=site,likes") - sb.append("&lang=").append(localeManagerWrapper.getLanguage()) + sb.append("&lang=").append(localeManagerWrapper.getLanguageCode()) val listener = RestRequest.Listener { jsonObject: JSONObject? -> // remember when this tag was updated if newer posts were requested diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt index 8678093db272..a39e9deb16c7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt @@ -120,7 +120,7 @@ class ReaderDiscoverLogic @Inject constructor( AppLog.e(READER, volleyError) resultListener.onUpdateResult(FAILED) } - params["_locale"] = localeManagerWrapper.getLanguage() + params["_locale"] = localeManagerWrapper.getLanguageCode() val endpoint = if (readerDiscoverNewEndpointFeatureConfig.isEnabled()) { "read/streams/discover" } else { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java index b865a00e28ec..f2c6976e7321 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java @@ -38,7 +38,7 @@ public void startSearch(@NonNull final String query, final int offset, Object co + "&number=" + ReaderConstants.READER_MAX_SEARCH_RESULTS_TO_REQUEST + "&offset=" + offset + "&meta=site,likes" - + "&lang=" + mLocaleManagerWrapper.getLanguage(); + + "&lang=" + mLocaleManagerWrapper.getLanguageCode(); RestRequest.Listener listener = jsonObject -> { if (jsonObject != null) { 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..74483b56d7fc 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.getLanguageCode(); mContext = context; } 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 b051d4d1092d..bd629a2e1cc9 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -38,7 +38,7 @@ public class LocaleManager { * @param context The current context. */ public static Context setLocale(Context context) { - return updateResources(context, getLanguage(context)); + return updateResources(context, getLanguageCode()); } /** @@ -55,11 +55,9 @@ public static boolean isSameLanguage(@NonNull String language) { /** * Previously the app stored the language code in shared preferences, but now we use * per-app language preferences so just return the device default language code. - * - * TODO remove this routine */ - public static String getLanguage(Context context) { - return LanguageUtils.getCurrentDeviceLanguageCode(); + public static String getLanguageCode() { + return Locale.getDefault().getLanguage(); } /** 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..be1f536ed446 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 getLanguageCode(): String = LocaleManager.getLanguageCode() fun isSameLanguage(language: String): Boolean = LocaleManager.isSameLanguage(language) fun setLocale(context: Context): Context = LocaleManager.setLocale(context) } diff --git a/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt b/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt index ddf347895251..b6514b2fe28e 100644 --- a/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt @@ -72,7 +72,7 @@ class RecommendApiCallsProviderTest : BaseUnitTest() { whenever(networkUtilsWrapper.isNetworkAvailable()).thenReturn(true) whenever(contextProvider.getContext()).thenReturn(context) whenever(restClientProvider.getRestClientUtilsV2()).thenReturn(restClientUtils) - whenever(localeManagerWrapper.getLanguage()).thenReturn("en") + whenever(localeManagerWrapper.getLanguageCode()).thenReturn("en") whenever(jsonObject.optString("name")).thenReturn("wordpress") listenerCaptor = argumentCaptor() 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..5bfe29867319 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 @@ -72,7 +72,7 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { @Before fun setUp() { whenever(avatarUtilsWrapper.rewriteAvatarUrlWithResource(any(), any())).thenReturn("") - whenever(localeManagerWrapper.getLanguage()).thenReturn("") + whenever(localeManagerWrapper.getLanguageCode()).thenReturn("") classToTest = JetpackMigrationViewModel( mainDispatcher = testDispatcher(), dispatcher = dispatcher, @@ -114,7 +114,7 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { @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.getLanguageCode()).thenReturn(language) whenever(localeManagerWrapper.isSameLanguage(language)).thenReturn(false) classToTest.initPleaseDeleteWordPressAppScreenUi() diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt index 2886c4708dbe..6298a87ae1ad 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt @@ -165,7 +165,7 @@ class WpSotw2023NudgeCardViewModelSliceTest : BaseUnitTest() { val date = if (isDateAfterEvent) "2023-12-12T00:00:01Z" else "2021-12-11T00:00:00Z" whenever(dateTimeUtilsWrapper.getInstantNow()).thenReturn(Instant.parse(date)) val language = if (isLanguageEnglish) "en_US" else "fr_FR" - whenever(localeManagerWrapper.getLanguage()).thenReturn(language) + whenever(localeManagerWrapper.getLanguageCode()).thenReturn(language) } } 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..5e4f13d76ef4 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 @@ -56,7 +56,7 @@ class MenuViewModelTest : BaseUnitTest() { @Before fun setUp() = test { - whenever(localeManagerWrapper.getLanguage()).thenReturn("") + whenever(localeManagerWrapper.getLanguageCode()).thenReturn("") whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site) initJetpackCapabilities(scanPurchased = false, backupPurchased = false) From 303536d46836a82fd2b92a3d0cdbbe8b0fd8a294 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 09:26:23 -0500 Subject: [PATCH 16/23] Revert "Updated getLanguageCode" This reverts commit 521ad211ead52dfc9d223719aba8dd774d770f06. --- .../android/models/recommend/RecommendApiCallsProvider.kt | 2 +- .../android/push/NotificationsProcessingService.java | 2 +- .../cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt | 2 +- .../org/wordpress/android/ui/mysite/menu/MenuViewModel.kt | 2 +- .../ui/mysite/personalization/PersonalizationViewModel.kt | 2 +- .../services/NotificationsUpdateJobService.java | 2 +- .../services/NotificationsUpdateService.java | 2 +- .../org/wordpress/android/ui/posts/EditPostActivity.kt | 2 +- .../reader/discover/interests/ReaderInterestsFragment.kt | 2 +- .../android/ui/reader/repository/ReaderPostRepository.kt | 2 +- .../ui/reader/services/discover/ReaderDiscoverLogic.kt | 2 +- .../ui/reader/services/search/ReaderSearchLogic.java | 2 +- .../ui/reader/services/update/ReaderUpdateLogic.java | 2 +- .../java/org/wordpress/android/util/LocaleManager.java | 8 +++++--- .../org/wordpress/android/util/LocaleManagerWrapper.kt | 2 +- .../models/recommend/RecommendApiCallsProviderTest.kt | 2 +- .../jetpack/migration/JetpackMigrationViewModelTest.kt | 4 ++-- .../sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt | 2 +- .../wordpress/android/ui/mysite/menu/MenuViewModelTest.kt | 2 +- 19 files changed, 24 insertions(+), 22 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt b/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt index aec40a9d417b..e324f64e5679 100644 --- a/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/models/recommend/RecommendApiCallsProvider.kt @@ -38,7 +38,7 @@ class RecommendApiCallsProvider @Inject constructor( logErrorAndTrack(source, "getRecommendTemplate > No Network available") cont.resume(Failure(contextProvider.getContext().getString(R.string.no_network_message))) } else { - val language = localeManagerWrapper.getLanguageCode() + val language = localeManagerWrapper.getLanguage() val endPointPath = "/mobile/share-app-link?app=$appName&locale=$language" val listener = Listener { jsonObject -> 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 3217c9f4f12c..54db41f9624e 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.getLanguageCode()); + params.put("locale", LocaleManager.getLanguage(mContext)); WordPress.getRestClientUtils().getNotification(params, noteId, listener, errorListener); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt index 609534f5910f..dab700fd2656 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSlice.kt @@ -75,7 +75,7 @@ class WpSotw2023NudgeCardViewModelSlice @Inject constructor( val now = dateTimeUtilsWrapper.getInstantNow() val isDateEligible = now.isAfter(eventTime) - val currentLanguage = localeManagerWrapper.getLanguageCode() + val currentLanguage = localeManagerWrapper.getLanguage() val isLanguageEligible = currentLanguage.startsWith(TARGET_LANGUAGE, ignoreCase = true) return featureConfig.isEnabled() && 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 d38264a1a520..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 @@ -79,7 +79,7 @@ class MenuViewModel @Inject constructor( private var isStarted = false init { - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguageCode()) + emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) } fun start(quickStartEvent: QuickStartEvent? = null) { 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 97f4bdd59eac..8df784930ae2 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 @@ -32,7 +32,7 @@ class PersonalizationViewModel @Inject constructor( val appLanguage = _appLanguage as LiveData init { - emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguageCode()) + emitLanguageRefreshIfNeeded(localeManagerWrapper.getLanguage()) shortcutsPersonalizationViewModelSlice.initialize(viewModelScope) dashboardCardPersonalizationViewModelSlice.initialize(viewModelScope) } 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 002b784f79e6..f2ed15e62076 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.getLanguageCode(), this); + mNotificationsUpdateLogic = new NotificationsUpdateLogic(LocaleManager.getLanguage(this), 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 473f7744af5e..a674050a24cc 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.getLanguageCode(), this); + mNotificationsUpdateLogic = new NotificationsUpdateLogic(LocaleManager.getLanguage(this), 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 0975269f6832..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 @@ -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.getLanguageCode() + val languageString = LocaleManager.getLanguage(this@EditPostActivity) 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/reader/discover/interests/ReaderInterestsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/discover/interests/ReaderInterestsFragment.kt index 8e734c8958a2..cad0696f0433 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.getLanguageCode(), + LocaleManager.getLanguage(WordPress.getContext()), parentViewModel, entryPoint ) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt index 2ccc31eb96e5..503682566dbb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/repository/ReaderPostRepository.kt @@ -93,7 +93,7 @@ class ReaderPostRepository @Inject constructor( sb.append("&before=").append(UrlUtils.urlEncode(beforeDate)) } sb.append("&meta=site,likes") - sb.append("&lang=").append(localeManagerWrapper.getLanguageCode()) + sb.append("&lang=").append(localeManagerWrapper.getLanguage()) val listener = RestRequest.Listener { jsonObject: JSONObject? -> // remember when this tag was updated if newer posts were requested diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt index a39e9deb16c7..8678093db272 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt @@ -120,7 +120,7 @@ class ReaderDiscoverLogic @Inject constructor( AppLog.e(READER, volleyError) resultListener.onUpdateResult(FAILED) } - params["_locale"] = localeManagerWrapper.getLanguageCode() + params["_locale"] = localeManagerWrapper.getLanguage() val endpoint = if (readerDiscoverNewEndpointFeatureConfig.isEnabled()) { "read/streams/discover" } else { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java index f2c6976e7321..b865a00e28ec 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/search/ReaderSearchLogic.java @@ -38,7 +38,7 @@ public void startSearch(@NonNull final String query, final int offset, Object co + "&number=" + ReaderConstants.READER_MAX_SEARCH_RESULTS_TO_REQUEST + "&offset=" + offset + "&meta=site,likes" - + "&lang=" + mLocaleManagerWrapper.getLanguageCode(); + + "&lang=" + mLocaleManagerWrapper.getLanguage(); RestRequest.Listener listener = jsonObject -> { if (jsonObject != null) { 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 74483b56d7fc..9af7b113c7db 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.getLanguageCode(); + mLanguage = LocaleManager.getLanguage(app); mContext = context; } 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 bd629a2e1cc9..b051d4d1092d 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -38,7 +38,7 @@ public class LocaleManager { * @param context The current context. */ public static Context setLocale(Context context) { - return updateResources(context, getLanguageCode()); + return updateResources(context, getLanguage(context)); } /** @@ -55,9 +55,11 @@ public static boolean isSameLanguage(@NonNull String language) { /** * Previously the app stored the language code in shared preferences, but now we use * per-app language preferences so just return the device default language code. + * + * TODO remove this routine */ - public static String getLanguageCode() { - return Locale.getDefault().getLanguage(); + public static String getLanguage(Context context) { + return LanguageUtils.getCurrentDeviceLanguageCode(); } /** 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 be1f536ed446..e4331f27c23c 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 getLanguageCode(): String = LocaleManager.getLanguageCode() + fun getLanguage(): String = LocaleManager.getLanguage(context) fun isSameLanguage(language: String): Boolean = LocaleManager.isSameLanguage(language) fun setLocale(context: Context): Context = LocaleManager.setLocale(context) } diff --git a/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt b/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt index b6514b2fe28e..ddf347895251 100644 --- a/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/models/recommend/RecommendApiCallsProviderTest.kt @@ -72,7 +72,7 @@ class RecommendApiCallsProviderTest : BaseUnitTest() { whenever(networkUtilsWrapper.isNetworkAvailable()).thenReturn(true) whenever(contextProvider.getContext()).thenReturn(context) whenever(restClientProvider.getRestClientUtilsV2()).thenReturn(restClientUtils) - whenever(localeManagerWrapper.getLanguageCode()).thenReturn("en") + whenever(localeManagerWrapper.getLanguage()).thenReturn("en") whenever(jsonObject.optString("name")).thenReturn("wordpress") listenerCaptor = argumentCaptor() 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 5bfe29867319..6e33aee504e3 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 @@ -72,7 +72,7 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { @Before fun setUp() { whenever(avatarUtilsWrapper.rewriteAvatarUrlWithResource(any(), any())).thenReturn("") - whenever(localeManagerWrapper.getLanguageCode()).thenReturn("") + whenever(localeManagerWrapper.getLanguage()).thenReturn("") classToTest = JetpackMigrationViewModel( mainDispatcher = testDispatcher(), dispatcher = dispatcher, @@ -114,7 +114,7 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { @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.getLanguageCode()).thenReturn(language) + whenever(localeManagerWrapper.getLanguage()).thenReturn(language) whenever(localeManagerWrapper.isSameLanguage(language)).thenReturn(false) classToTest.initPleaseDeleteWordPressAppScreenUi() diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt index 6298a87ae1ad..2886c4708dbe 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewModelSliceTest.kt @@ -165,7 +165,7 @@ class WpSotw2023NudgeCardViewModelSliceTest : BaseUnitTest() { val date = if (isDateAfterEvent) "2023-12-12T00:00:01Z" else "2021-12-11T00:00:00Z" whenever(dateTimeUtilsWrapper.getInstantNow()).thenReturn(Instant.parse(date)) val language = if (isLanguageEnglish) "en_US" else "fr_FR" - whenever(localeManagerWrapper.getLanguageCode()).thenReturn(language) + whenever(localeManagerWrapper.getLanguage()).thenReturn(language) } } 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 5e4f13d76ef4..8a0f8f58fdb1 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 @@ -56,7 +56,7 @@ class MenuViewModelTest : BaseUnitTest() { @Before fun setUp() = test { - whenever(localeManagerWrapper.getLanguageCode()).thenReturn("") + whenever(localeManagerWrapper.getLanguage()).thenReturn("") whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site) initJetpackCapabilities(scanPurchased = false, backupPurchased = false) From fc8cbfd24eec2d932579deb2cddd26baa2dd2aaf Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 09:32:05 -0500 Subject: [PATCH 17/23] Removed context from getLanguage() --- .../push/NotificationsProcessingService.java | 2 +- .../NotificationsUpdateJobService.java | 2 +- .../services/NotificationsUpdateService.java | 2 +- .../android/ui/posts/EditPostActivity.kt | 2 +- .../interests/ReaderInterestsFragment.kt | 2 +- .../services/update/ReaderUpdateLogic.java | 2 +- .../wordpress/android/util/LocaleManager.java | 20 +++++++++---------- .../android/util/LocaleManagerWrapper.kt | 2 +- 8 files changed, 16 insertions(+), 18 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/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.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java index b051d4d1092d..b5ad43603365 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -38,7 +38,7 @@ public class LocaleManager { * @param context The current context. */ public static Context setLocale(Context context) { - return updateResources(context, getLanguage(context)); + return updateResources(context, getLanguage()); } /** @@ -52,16 +52,6 @@ public static boolean isSameLanguage(@NonNull String language) { return Locale.getDefault().toString().equals(newLocale.toString()); } - /** - * Previously the app stored the language code in shared preferences, but now we use - * per-app language preferences so just return the device default language code. - * - * TODO remove this routine - */ - public static String getLanguage(Context context) { - return 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. @@ -91,6 +81,14 @@ public static String getLanguage(Context context) { return langID; } + /** + * Previously the app stored the language code in shared preferences, but now we use + * per-app language preferences so just return the device default language code. + */ + public static String getLanguage() { + return LanguageUtils.getCurrentDeviceLanguageCode(); + } + /** * Update resources for the current session. * 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) } From 8f1f4dac6af9a553a7ce8a95c1e8019a19686749 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 09:40:41 -0500 Subject: [PATCH 18/23] Moved getLanguage --- .../wordpress/android/util/LocaleManager.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 b5ad43603365..832443259248 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -41,6 +41,14 @@ public static Context setLocale(Context context) { return updateResources(context, getLanguage()); } + /** + * Previously the app stored the language code in shared preferences, but now we use + * per-app language preferences so just return the device default language code. + */ + public static String getLanguage() { + return LanguageUtils.getCurrentDeviceLanguageCode(); + } + /** * Compare the language for the current context with another language. * @@ -81,14 +89,6 @@ public static boolean isSameLanguage(@NonNull String language) { return langID; } - /** - * Previously the app stored the language code in shared preferences, but now we use - * per-app language preferences so just return the device default language code. - */ - public static String getLanguage() { - return LanguageUtils.getCurrentDeviceLanguageCode(); - } - /** * Update resources for the current session. * From 700d9b137c0169fef91267c824fe55edc0e9433f Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 09:46:47 -0500 Subject: [PATCH 19/23] Removed setLocale --- .../org/wordpress/android/AppInitializer.kt | 3 +- .../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.java | 34 ------------------- .../android/util/LocaleManagerWrapper.kt | 1 - .../android/viewmodel/ContextProvider.kt | 5 --- 10 files changed, 1 insertion(+), 80 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt b/WordPress/src/main/java/org/wordpress/android/AppInitializer.kt index bd06ec964df0..e0cdac094920 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.ProfilingUtils @@ -1095,7 +1094,7 @@ class AppInitializer @Inject constructor( check(context != null) { "Context must be initialized before calling updateContextLocale" } return@run context } - this.context = LocaleManager.setLocale(context) + this.context = context } } } 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.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java index 832443259248..950eeeb0f14b 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -1,9 +1,7 @@ package org.wordpress.android.util; -import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Configuration; -import android.content.res.Resources; import android.text.TextUtils; import androidx.annotation.NonNull; @@ -32,15 +30,6 @@ public class LocaleManager { */ private static Pattern languageSplitter = Pattern.compile("_"); - /** - * Activate the locale associated with the provided context. - * - * @param context The current context. - */ - public static Context setLocale(Context context) { - return updateResources(context, getLanguage()); - } - /** * Previously the app stored the language code in shared preferences, but now we use * per-app language preferences so just return the device default language code. @@ -89,29 +78,6 @@ public static boolean isSameLanguage(@NonNull String language) { return langID; } - /** - * 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 static Context updateResources(Context context, String language) { - Locale locale = languageLocale(language); - Locale.setDefault(locale); - - Resources res = context.getResources(); - Configuration config = new Configuration(res.getConfiguration()); - - // 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; - } - /** * 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 cded03011280371cf04863b0320f533e4c940e4a Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 10:07:49 -0500 Subject: [PATCH 20/23] Made getLanguageCode static --- .../android/ui/prefs/AppSettingsFragment.java | 2 +- .../wordpress/android/util/LocaleManager.java | 6 +- .../android/util/PerAppLocaleManager.kt | 63 +++++++------------ 3 files changed, 25 insertions(+), 46 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 6ceed6189ffd..8f4fce4ea12b 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 @@ -245,7 +245,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.getLanguageCode()); return view; } 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 950eeeb0f14b..afab4dc1255a 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java +++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java @@ -31,11 +31,11 @@ public class LocaleManager { private static Pattern languageSplitter = Pattern.compile("_"); /** - * Previously the app stored the language code in shared preferences, but now we use - * per-app language preferences so just return the device default language code. + * Previously the app stored the language code in shared preferences, but now + * we use per-app language preferences */ public static String getLanguage() { - return LanguageUtils.getCurrentDeviceLanguageCode(); + return PerAppLocaleManager.Companion.getLanguageCode(); } /** 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 f4d4e806ef53..89a9faf1af2f 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -32,29 +32,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()) - } - /** * This can be helpful during development to reset the app locale back to the default */ @@ -75,22 +52,14 @@ class PerAppLocaleManager @Inject constructor( * that the per-app language is set to the same language. */ fun performMigrationIfNecessary() { - if (isApplicationLocaleEmpty()) { - val previousLanguage = appPrefsWrapper.getPrefString(OLD_LANGUAGE_PREF_KEY, "") - if (previousLanguage?.isNotEmpty() == true) { - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" - ) - setCurrentLocaleByLanguageCode(previousLanguage) - appPrefsWrapper.removePref(OLD_LANGUAGE_PREF_KEY) - } else { - appLogWrapper.d( - AppLog.T.SETTINGS, - "PerAppLocaleManager: setting default locale" - ) - setCurrentLocaleByLanguageCode(Locale.getDefault().language) - } + val previousLanguage = appPrefsWrapper.getPrefString(OLD_LANGUAGE_PREF_KEY, "") + if (previousLanguage?.isNotEmpty() == true) { + appLogWrapper.d( + AppLog.T.SETTINGS, + "PerAppLocaleManager: performing migration to AndroidX per-app language prefs" + ) + setCurrentLocaleByLanguageCode(previousLanguage) + appPrefsWrapper.removePref(OLD_LANGUAGE_PREF_KEY) } } @@ -118,7 +87,7 @@ class PerAppLocaleManager @Inject constructor( } // Only update if the language is different - if (languageCode != getCurrentLocaleLanguageCode()) { + if (languageCode != getLanguageCode()) { setCurrentLocaleByLanguageCode(languageCode) } @@ -131,7 +100,6 @@ class PerAppLocaleManager @Inject constructor( // Language is now part of metadata, so we need to refresh them AnalyticsUtils.refreshMetadata(accountStore, siteStore) - // When language changed we need to reset the shared prefs reader tag since if we have it stored // it's fields can be in a different language and we can get odd behaviors since we will generally fail // to get the ReaderTag.equals method recognize the equality based on the ReaderTag.getLabel method. @@ -142,7 +110,18 @@ class PerAppLocaleManager @Inject constructor( } companion object { - // Key previously used for saving the language selection to shared preferences. + // Key previously used for saving the language selection to shared preferences. + // before we switched to per-app language preferences private const val OLD_LANGUAGE_PREF_KEY: String = "language-pref" + + fun getLanguageCode(): String { + val appLocales = AppCompatDelegate.getApplicationLocales() + val locale = if (appLocales.isEmpty or (appLocales == LocaleListCompat.getEmptyLocaleList())) { + Locale.getDefault() + } else { + appLocales[0] ?: Locale.getDefault() + } + return locale.language + } } } From 0ef3bc7a4633da7c89cefc2f9a84e0ff426ef2f7 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 10:31:14 -0500 Subject: [PATCH 21/23] Fixed the language display name in settings --- .../wordpress/android/ui/prefs/AppSettingsFragment.java | 2 +- .../org/wordpress/android/util/PerAppLocaleManager.kt | 9 ++++++--- 2 files changed, 7 insertions(+), 4 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 8f4fce4ea12b..406416658693 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 @@ -245,7 +245,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(PerAppLocaleManager.Companion.getLanguageCode()); + mLanguagePreference.setSummary(PerAppLocaleManager.Companion.getLanguageDisplayName()); return view; } 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 89a9faf1af2f..31bfbf368d49 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/PerAppLocaleManager.kt @@ -114,14 +114,17 @@ class PerAppLocaleManager @Inject constructor( // before we switched to per-app language preferences private const val OLD_LANGUAGE_PREF_KEY: String = "language-pref" - fun getLanguageCode(): String { + private fun getLocale(): Locale { val appLocales = AppCompatDelegate.getApplicationLocales() - val locale = if (appLocales.isEmpty or (appLocales == LocaleListCompat.getEmptyLocaleList())) { + return if (appLocales.isEmpty or (appLocales == LocaleListCompat.getEmptyLocaleList())) { Locale.getDefault() } else { appLocales[0] ?: Locale.getDefault() } - return locale.language } + + fun getLanguageCode() = getLocale().language + + fun getLanguageDisplayName() = getLocale().displayName } } From d72f5724c66022808c52d7a3b45816fd729a306b Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 10:33:14 -0500 Subject: [PATCH 22/23] Fixed JetpackMigrationViewModelTest --- .../JetpackMigrationViewModelTest.kt | 26 ------------------- 1 file changed, 26 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 6e33aee504e3..d936b9ee01d0 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 @@ -86,11 +83,8 @@ class JetpackMigrationViewModelTest : BaseUnitTest() { migrationAnalyticsTracker = contentMigrationAnalyticsTracker, accountStore = accountStore, siteStore = siteStore, - localeManagerWrapper = localeManagerWrapper, - jetpackMigrationLanguageUtil = jetpackMigrationLanguageUtil, ) classToTest.refreshAppTheme.observeForever(refreshAppThemeObserver) - classToTest.refreshAppLanguage.observeForever(refreshAppLanguageObserver) } // region ViewModel @@ -99,18 +93,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" @@ -122,14 +104,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) From 7256d668345dd42f6b51f6d7a9e64f596b7bfad3 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Fri, 13 Dec 2024 10:34:20 -0500 Subject: [PATCH 23/23] Fixed MenuViewModelTest --- .../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 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,