From e9ad59eba6d8ffd2cbf28520c237ccefd291a33c Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Fri, 29 Oct 2010 17:35:36 -0700 Subject: When the locale changes, flush the all apps list. Bug: 3032131 Change-Id: I47659a459044fdace0a3480d216b168c18f2de37 --- src/com/android/launcher2/LauncherApplication.java | 1 + src/com/android/launcher2/LauncherModel.java | 45 +++++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java index 8a18317bc..dab2b588a 100644 --- a/src/com/android/launcher2/LauncherApplication.java +++ b/src/com/android/launcher2/LauncherApplication.java @@ -52,6 +52,7 @@ public class LauncherApplication extends Application { filter = new IntentFilter(); filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE); filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); + filter.addAction(Intent.ACTION_LOCALE_CHANGED); registerReceiver(mModel, filter); // Register for changes to the favorites diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index aa259aa86..67aa31126 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -424,24 +424,41 @@ public class LauncherModel extends BroadcastReceiver { String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages)); // Then, rebind everything. - boolean runLoader = true; - if (mCallbacks != null) { - Callbacks callbacks = mCallbacks.get(); - if (callbacks != null) { - // If they're paused, we can skip loading, because they'll do it again anyway - if (callbacks.setLoadOnResume()) { - runLoader = false; - } - } - } - if (runLoader) { - startLoader(mApp, false); - } - + startLoaderFromBackground(); } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) { String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); enqueuePackageUpdated(new PackageUpdatedTask( PackageUpdatedTask.OP_UNAVAILABLE, packages)); + } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) { + // If we have changed locale we need to clear out the labels in all apps. + // Do this here because if the launcher activity is running it will be restarted. + // If it's not running startLoaderFromBackground will merely tell it that it needs + // to reload. Either way, mAllAppsLoaded will be cleared so it re-reads everything + // next time. + mAllAppsLoaded = false; + startLoaderFromBackground(); + } + } + + /** + * When the launcher is in the background, it's possible for it to miss paired + * configuration changes. So whenever we trigger the loader from the background + * tell the launcher that it needs to re-run the loader when it comes back instead + * of doing it now. + */ + public void startLoaderFromBackground() { + boolean runLoader = false; + if (mCallbacks != null) { + Callbacks callbacks = mCallbacks.get(); + if (callbacks != null) { + // Only actually run the loader if they're not paused. + if (!callbacks.setLoadOnResume()) { + runLoader = true; + } + } + } + if (runLoader) { + startLoader(mApp, false); } } -- cgit v1.2.3