Update the names of the widgets when the locale changes.
Bug 1814373, Bug 2152730
This commit is contained in:
@@ -51,6 +51,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -105,6 +106,7 @@ class AppWidgetService extends IAppWidgetService.Stub
|
||||
}
|
||||
|
||||
Context mContext;
|
||||
Locale mLocale;
|
||||
PackageManager mPackageManager;
|
||||
AlarmManager mAlarmManager;
|
||||
ArrayList<Provider> mInstalledProviders = new ArrayList<Provider>();
|
||||
@@ -131,6 +133,11 @@ class AppWidgetService extends IAppWidgetService.Stub
|
||||
mContext.registerReceiver(mBroadcastReceiver,
|
||||
new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, null);
|
||||
|
||||
// Register for configuration changes so we can update the names
|
||||
// of the widgets when the locale changes.
|
||||
mContext.registerReceiver(mBroadcastReceiver,
|
||||
new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED), null, null);
|
||||
|
||||
// Register for broadcasts about package install, etc., so we can
|
||||
// update the provider list.
|
||||
IntentFilter filter = new IntentFilter();
|
||||
@@ -1046,6 +1053,22 @@ class AppWidgetService extends IAppWidgetService.Stub
|
||||
//Log.d(TAG, "received " + action);
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
||||
sendInitialBroadcasts();
|
||||
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
|
||||
Locale revised = Locale.getDefault();
|
||||
if (revised == null || mLocale == null ||
|
||||
!(revised.equals(mLocale))) {
|
||||
mLocale = revised;
|
||||
|
||||
synchronized (mAppWidgetIds) {
|
||||
int N = mInstalledProviders.size();
|
||||
for (int i=N-1; i>=0; i--) {
|
||||
Provider p = mInstalledProviders.get(i);
|
||||
String pkgName = p.info.provider.getPackageName();
|
||||
updateProvidersForPackageLocked(pkgName);
|
||||
}
|
||||
saveStateLocked();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Uri uri = intent.getData();
|
||||
if (uri == null) {
|
||||
|
||||
Reference in New Issue
Block a user