Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location handling cleanup #21527

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3dfe5de
First pass at removing LocaleAwareActivity.kt
nbradbury Dec 12, 2024
7576fbb
Second pass at removing LocaleAwareActivity.kt
nbradbury Dec 12, 2024
18a731a
Fixed detekt errors
nbradbury Dec 12, 2024
97f1914
Fixed lint errors
nbradbury Dec 12, 2024
d2abbf1
Removed LocaleAwareActivity.kt
nbradbury Dec 12, 2024
38b3baf
Fixed checkstyle import errors
nbradbury Dec 12, 2024
f647806
Removed unused code from LocaleManager
nbradbury Dec 12, 2024
f42c7bb
Removed storing language in prefs
nbradbury Dec 12, 2024
c978933
Removed JetpackMigrationLanguageUtil.kt
nbradbury Dec 12, 2024
4cd64f3
Removed locale from Jetpack migration
nbradbury Dec 12, 2024
562c7ba
Removed LANGUAGE_CHANGED
nbradbury Dec 13, 2024
e71c2eb
Removed unused import
nbradbury Dec 13, 2024
d002d2f
Removed LocaleAwareComposable
nbradbury Dec 13, 2024
bbe4f96
Removed unused var
nbradbury Dec 13, 2024
66a38eb
Merge branch 'feature/per-app-language-prefs' into nick/location-manager
nbradbury Dec 13, 2024
521ad21
Updated getLanguageCode
nbradbury Dec 13, 2024
303536d
Revert "Updated getLanguageCode"
nbradbury Dec 13, 2024
fc8cbfd
Removed context from getLanguage()
nbradbury Dec 13, 2024
8f1f4da
Moved getLanguage
nbradbury Dec 13, 2024
700d9b1
Removed setLocale
nbradbury Dec 13, 2024
cded030
Made getLanguageCode static
nbradbury Dec 13, 2024
0ef3bc7
Fixed the language display name in settings
nbradbury Dec 13, 2024
d72f572
Fixed JetpackMigrationViewModelTest
nbradbury Dec 13, 2024
7256d66
Fixed MenuViewModelTest
nbradbury Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

10 changes: 2 additions & 8 deletions WordPress/src/main/java/org/wordpress/android/AppInitializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ import org.wordpress.android.util.BuildConfigWrapper
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.EncryptedLogging
import org.wordpress.android.util.FluxCUtils
import org.wordpress.android.util.LocaleManager
import org.wordpress.android.util.NetworkUtils
import org.wordpress.android.util.PackageUtils
import org.wordpress.android.util.PerAppLocaleManager
import org.wordpress.android.util.ProfilingUtils
import org.wordpress.android.util.QuickStartUtils
import org.wordpress.android.util.RateLimitedTask
Expand Down Expand Up @@ -232,9 +230,6 @@ class AppInitializer @Inject constructor(
@Inject
lateinit var jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper

@Inject
lateinit var perAppLocaleManager: PerAppLocaleManager

private lateinit var applicationLifecycleMonitor: ApplicationLifecycleMonitor

@Suppress("DEPRECATION")
Expand Down Expand Up @@ -950,8 +945,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() {
Expand Down Expand Up @@ -1100,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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -73,6 +71,5 @@ class UserFlagsProviderHelper @Inject constructor(
contextProvider.getContext().getString(R.string.pref_key_app_theme),
contextProvider.getContext().getString(R.string.pref_key_initial_screen),
contextProvider.getContext().getString(R.string.pref_key_send_crash),
localeManagerWrapper.getLocalePrefKeyString()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ private void getNoteFromNoteId(String noteId, RestRequest.Listener listener,
}

HashMap<String, String> params = new HashMap<>();
params.put("locale", LocaleManager.getLanguage(mContext));
params.put("locale", LocaleManager.getLanguage());
WordPress.getRestClientUtils().getNotification(params, noteId, listener, errorListener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,7 +45,7 @@

import javax.inject.Inject;

public class AddQuickPressShortcutActivity extends LocaleAwareActivity {
public class AddQuickPressShortcutActivity extends AppCompatActivity {
public String[] blogNames;
public int[] siteIds;
public String[] blogUrls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -35,7 +36,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,7 +40,7 @@
* <p>
* 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";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -43,7 +44,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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,7 +13,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +26,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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -95,7 +95,7 @@
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading
Loading