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

Fix custom app language selection issues across various android versions #7413

Merged
merged 16 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions WordPress/src/main/java/org/wordpress/android/WordPress.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
import org.wordpress.android.util.DateTimeUtils;
import org.wordpress.android.util.FluxCUtils;
import org.wordpress.android.util.HelpshiftHelper;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.PackageUtils;
import org.wordpress.android.util.ProfilingUtils;
import org.wordpress.android.util.RateLimitedTask;
import org.wordpress.android.util.VolleyUtils;
import org.wordpress.android.util.WPActivityUtils;
import org.wordpress.passcodelock.AbstractAppLock;
import org.wordpress.passcodelock.AppLockManager;

Expand Down Expand Up @@ -199,6 +199,11 @@ public static BitmapLruCache getBitmapCache() {
return mBitmapCache;
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocaleManager.setLocale(base));
}

@Override
public void onCreate() {
super.onCreate();
Expand Down Expand Up @@ -272,9 +277,6 @@ public void onLog(T tag, LogLevel logLevel, String message) {

initAnalytics(SystemClock.elapsedRealtime() - startDate);

// If users uses a custom locale set it on start of application
WPActivityUtils.applyLocale(getContext());

disableRtlLayoutDirectionOnSdk17();

// Allows vector drawable from resources (in selectors for instance) on Android < 21 (can cause issues
Expand Down Expand Up @@ -676,7 +678,7 @@ private class ApplicationLifecycleMonitor implements Application.ActivityLifecyc
@Override
public void onConfigurationChanged(final Configuration newConfig) {
// Reapply locale on configuration change
WPActivityUtils.applyLocale(getContext());
LocaleManager.setLocale(getContext());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
Expand Down Expand Up @@ -32,6 +33,7 @@
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.fluxc.tools.FluxCImageLoader;
import org.wordpress.android.ui.posts.EditPostActivity;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.ToastUtils;

Expand All @@ -50,6 +52,11 @@ public class AddQuickPressShortcutActivity extends ListActivity {
@Inject SiteStore mSiteStore;
@Inject FluxCImageLoader mImageLoader;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.wordpress.android.R;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.ToastUtils;

import java.util.ArrayList;
Expand All @@ -34,6 +35,11 @@ public class AppLogViewerActivity extends AppCompatActivity {
private static final int ID_SHARE = 1;
private static final int ID_COPY_TO_CLIPBOARD = 2;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
Expand All @@ -14,6 +15,7 @@
import org.wordpress.android.util.AnalyticsUtils;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.ToastUtils;

import javax.inject.Inject;
Expand All @@ -32,6 +34,11 @@ public class DeepLinkingIntentReceiverActivity extends AppCompatActivity {

@Inject AccountStore mAccountStore;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package org.wordpress.android.ui;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.helpshift.support.Support;

import org.wordpress.android.util.LocaleManager;

public class HelpshiftDeepLinkReceiver extends AppCompatActivity {
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
Expand All @@ -24,6 +25,7 @@
import org.wordpress.android.ui.media.MediaBrowserType;
import org.wordpress.android.util.AnalyticsUtils;
import org.wordpress.android.util.FluxCUtils;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.PermissionUtils;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.WPPermissionUtils;
Expand Down Expand Up @@ -60,6 +62,11 @@ protected void onNewIntent(Intent intent) {
refreshContent();
}

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
Expand All @@ -9,9 +10,15 @@
import org.wordpress.android.ui.prefs.AppPrefs;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.ToastUtils;

public class VisualEditorOptionsReceiver extends AppCompatActivity {
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.wordpress.android.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import org.wordpress.android.R;
import org.wordpress.android.WordPress;
import org.wordpress.android.ui.main.WPMainActivity;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.ProfilingUtils;
import org.wordpress.android.util.ToastUtils;

Expand All @@ -17,6 +19,11 @@ public class WPLaunchActivity extends AppCompatActivity {
* manifest to have no UI
*/

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -10,6 +11,7 @@
import android.webkit.WebView;

import org.wordpress.android.R;
import org.wordpress.android.util.LocaleManager;

import java.util.Map;

Expand All @@ -25,6 +27,11 @@ public abstract class WebViewActivity extends AppCompatActivity {

protected WebView mWebView;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
public void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_PROGRESS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.accounts;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
Expand All @@ -17,6 +18,7 @@
import org.wordpress.android.util.HelpshiftHelper;
import org.wordpress.android.util.HelpshiftHelper.MetadataKey;
import org.wordpress.android.util.HelpshiftHelper.Tag;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.widgets.WPTextView;

import javax.inject.Inject;
Expand All @@ -25,6 +27,11 @@ public class HelpActivity extends AppCompatActivity {
@Inject AccountStore mAccountStore;
@Inject SiteStore mSiteStore;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wordpress.android.ui.accounts;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
Expand Down Expand Up @@ -51,6 +52,7 @@
import org.wordpress.android.util.HelpshiftHelper;
import org.wordpress.android.util.HelpshiftHelper.Tag;
import org.wordpress.android.util.LanguageUtils;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.SelfSignedSSLUtils;
import org.wordpress.android.util.StringUtils;
Expand Down Expand Up @@ -92,6 +94,11 @@ private enum SmartLockHelperState {

@Inject DispatchingAndroidInjector<Fragment> mFragmentInjector;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
((WordPress) getApplication()).component().inject(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.accounts;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -10,6 +11,7 @@
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.accounts.login.LoginEpilogueFragment;
import org.wordpress.android.ui.accounts.login.LoginEpilogueListener;
import org.wordpress.android.util.LocaleManager;

import java.util.ArrayList;

Expand All @@ -22,6 +24,11 @@ public class LoginEpilogueActivity extends AppCompatActivity implements LoginEpi

@Inject AccountStore mAccountStore;

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package org.wordpress.android.ui.accounts;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;

import org.wordpress.android.R;
import org.wordpress.android.ui.accounts.signup.SiteCreationCreatingFragment;
import org.wordpress.android.util.LocaleManager;

public class NewBlogActivity extends AppCompatActivity {
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.wordpress.android.ui.accounts;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;

import org.wordpress.android.R;
import org.wordpress.android.ui.accounts.signup.SignupEpilogueFragment;
import org.wordpress.android.ui.accounts.signup.SignupEpilogueListener;
import org.wordpress.android.util.LocaleManager;

public class SignupEpilogueActivity extends AppCompatActivity implements SignupEpilogueListener {
public static final String EXTRA_SIGNUP_DISPLAY_NAME = "EXTRA_SIGNUP_DISPLAY_NAME";
Expand All @@ -17,6 +19,11 @@ public class SignupEpilogueActivity extends AppCompatActivity implements SignupE
public static final String MAGIC_SIGNUP_PARAMETER = "new_user";
public static final String MAGIC_SIGNUP_VALUE = "1";

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocaleManager.setLocale(newBase));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Loading