summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2012-04-11 13:47:45 +0200
committerDanny Baumann <dannybaumann@web.de>2012-05-02 14:53:43 +0200
commita750cb3e114d402079f71aefb037511e53a47085 (patch)
tree5928458900c6e58052974bc94e960031b5989cb9
parent0521546b7df7186d21b0a43571171ae3c30b634f (diff)
downloadframeworks_base-a750cb3e114d402079f71aefb037511e53a47085.zip
frameworks_base-a750cb3e114d402079f71aefb037511e53a47085.tar.gz
frameworks_base-a750cb3e114d402079f71aefb037511e53a47085.tar.bz2
Applying theming to more framework items.
All dialogs and notifications should be covered now. Change-Id: If93f81991361165a00b5b1b03ffc323e3ab42c0b
-rw-r--r--core/java/android/content/SyncManager.java19
-rw-r--r--policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java19
-rw-r--r--policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java29
-rw-r--r--policy/src/com/android/internal/policy/impl/SimUnlockScreen.java20
-rw-r--r--services/java/com/android/server/DeviceStorageMonitorService.java21
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java19
-rw-r--r--services/java/com/android/server/ThrottleService.java17
-rw-r--r--services/java/com/android/server/UiModeManagerService.java20
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java21
9 files changed, 158 insertions, 27 deletions
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 5a83604..f62162a 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -17,6 +17,7 @@
package android.content;
import com.android.internal.R;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.util.ArrayUtils;
import android.accounts.Account;
@@ -131,6 +132,7 @@ public class SyncManager implements OnAccountsUpdateListener {
private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarm";
private Context mContext;
+ private Context mUiContext;
private volatile Account[] mAccounts = INITIAL_ACCOUNTS_ARRAY;
@@ -185,6 +187,12 @@ public class SyncManager implements OnAccountsUpdateListener {
}
};
+ private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ };
+
private BroadcastReceiver mBackgroundDataSettingChanged = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (getConnectivityManager().getBackgroundDataSetting()) {
@@ -356,6 +364,8 @@ public class SyncManager implements OnAccountsUpdateListener {
intentFilter.setPriority(100);
context.registerReceiver(mShutdownIntentReceiver, intentFilter);
+ ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);
+
if (!factoryTest) {
mNotificationMgr = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -868,6 +878,13 @@ public class SyncManager implements OnAccountsUpdateListener {
}
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
/**
* @hide
*/
@@ -2057,7 +2074,7 @@ public class SyncManager implements OnAccountsUpdateListener {
new Notification(R.drawable.stat_notify_sync_error,
mContext.getString(R.string.contentServiceSync),
System.currentTimeMillis());
- notification.setLatestEventInfo(mContext,
+ notification.setLatestEventInfo(getUiContext(),
mContext.getString(R.string.contentServiceSyncNotificationTitle),
String.format(tooManyDeletesDescFormat.toString(), authorityName),
pendingIntent);
diff --git a/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java b/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
index 2e7a78c..2e25ea6 100644
--- a/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
@@ -81,6 +81,14 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
private Context mUiContext;
private ProgressDialog mCheckingDialog;
+ private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ mCheckingDialog = null;
+ }
+ };
+
/**
* AccountUnlockScreen constructor.
* @param configuration
@@ -93,14 +101,6 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
mCallback = callback;
mLockPatternUtils = lockPatternUtils;
- ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- mUiContext = null;
- mCheckingDialog = null;
- }
- });
-
LayoutInflater.from(context).inflate(
R.layout.keyguard_screen_glogin_unlock, this, true);
@@ -153,7 +153,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
/** {@inheritDoc} */
public void onPause() {
-
+ mContext.unregisterReceiver(mThemeChangeReceiver);
}
/** {@inheritDoc} */
@@ -163,6 +163,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
mPassword.setText("");
mLogin.requestFocus();
mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
+ ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);
}
/** {@inheritDoc} */
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 7f79cc2..d635bce 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -17,6 +17,7 @@
package com.android.internal.policy.impl;
import com.android.internal.R;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.telephony.IccCard;
import com.android.internal.widget.LockPatternUtils;
@@ -28,6 +29,7 @@ import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -79,6 +81,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
private View mLockScreen;
private View mUnlockScreen;
+ private Context mUiContext;
+
private boolean mScreenOn = false;
private boolean mEnableFallback = false; // assume no fallback UI until we know better
@@ -187,6 +191,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
}
};
+ private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ };
+
/**
* @return Whether we are stuck on the lock screen because the sim is
* missing.
@@ -542,8 +552,16 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
}
@Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);
+ }
+
+ @Override
protected void onDetachedFromWindow() {
removeCallbacks(mRecreateRunnable);
+ mContext.unregisterReceiver(mThemeChangeReceiver);
+ mUiContext = null;
super.onDetachedFromWindow();
}
@@ -836,7 +854,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
timeoutInSeconds);
}
- final AlertDialog dialog = new AlertDialog.Builder(mContext)
+ final AlertDialog dialog = new AlertDialog.Builder(getUiContext())
.setTitle(null)
.setMessage(message)
.setNeutralButton(R.string.ok, null)
@@ -852,6 +870,13 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
dialog.show();
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
private void showAlmostAtAccountLoginDialog() {
int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000;
String message;
@@ -872,7 +897,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
timeoutInSeconds);
}
- final AlertDialog dialog = new AlertDialog.Builder(mContext)
+ final AlertDialog dialog = new AlertDialog.Builder(getUiContext())
.setTitle(null)
.setMessage(message)
.setNeutralButton(R.string.ok, null)
diff --git a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
index cfd985a..369161f 100644
--- a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
@@ -72,6 +72,14 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
+ private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ mSimUnlockProgressDialog = null;
+ }
+ };
+
public SimUnlockScreen(Context context, Configuration configuration,
KeyguardUpdateMonitor updateMonitor, KeyguardScreenCallback callback,
LockPatternUtils lockpatternutils) {
@@ -79,14 +87,6 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
mUpdateMonitor = updateMonitor;
mCallback = callback;
- ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- mUiContext = null;
- mSimUnlockProgressDialog = null;
- }
- });
-
mCreationOrientation = configuration.orientation;
mKeyboardHidden = configuration.hardKeyboardHidden;
mLockPatternUtils = lockpatternutils;
@@ -127,7 +127,8 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
/** {@inheritDoc} */
public void onPause() {
-
+ mContext.unregisterReceiver(mThemeChangeReceiver);
+ mUiContext = null;
}
/** {@inheritDoc} */
@@ -141,6 +142,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
mEnteredDigits = 0;
mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
+ ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);
}
/** {@inheritDoc} */
diff --git a/services/java/com/android/server/DeviceStorageMonitorService.java b/services/java/com/android/server/DeviceStorageMonitorService.java
index d056cf6..1568b1b 100644
--- a/services/java/com/android/server/DeviceStorageMonitorService.java
+++ b/services/java/com/android/server/DeviceStorageMonitorService.java
@@ -16,10 +16,13 @@
package com.android.server;
+import com.android.internal.app.ThemeUtils;
import com.android.server.am.ActivityManagerService;
+
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -76,6 +79,7 @@ class DeviceStorageMonitorService extends Binder {
private boolean mLowMemFlag=false;
private boolean mMemFullFlag=false;
private Context mContext;
+ private Context mUiContext;
private ContentResolver mContentResolver;
private long mTotalMemory; // on /data/data
private StatFs mDataFileStats;
@@ -302,6 +306,14 @@ class DeviceStorageMonitorService extends Binder {
mLastReportedFreeMemTime = 0;
mContext = context;
mContentResolver = mContext.getContentResolver();
+
+ ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context content, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
//create StatFs object
mDataFileStats = new StatFs(DATA_PATH);
mSystemFileStats = new StatFs(SYSTEM_PATH);
@@ -349,7 +361,7 @@ class DeviceStorageMonitorService extends Binder {
notification.icon = com.android.internal.R.drawable.stat_notify_disk_full;
notification.tickerText = title;
notification.flags |= Notification.FLAG_NO_CLEAR;
- notification.setLatestEventInfo(mContext, title, details, intent);
+ notification.setLatestEventInfo(getUiContext(), title, details, intent);
mNotificationMgr.notify(LOW_MEMORY_NOTIFICATION_ID, notification);
mContext.sendStickyBroadcast(mStorageLowIntent);
}
@@ -394,4 +406,11 @@ class DeviceStorageMonitorService extends Binder {
// force an early check
postCheckMemoryMsg(true, 0);
}
+
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
}
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index ecad3cc..8e50828 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -16,6 +16,7 @@
package com.android.server;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.HandlerCaller;
import com.android.internal.view.IInputContext;
@@ -33,6 +34,7 @@ import org.xmlpull.v1.XmlPullParserException;
import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -110,6 +112,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
static final long TIME_TO_RECONNECT = 10*1000;
final Context mContext;
+ private Context mUiContext;
final Handler mHandler;
final SettingsObserver mSettingsObserver;
final StatusBarManagerService mStatusBar;
@@ -466,6 +469,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
screenOnOffFilt.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.registerReceiver(new ScreenOnOffReceiver(), screenOnOffFilt);
+ ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
mStatusBar = statusBar;
statusBar.setIconVisibility("ime", false);
@@ -1501,7 +1511,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
void showInputMethodMenu() {
if (DEBUG) Slog.v(TAG, "Show switching menu");
- final Context context = mContext;
+ final Context context = getUiContext();
final PackageManager pm = context.getPackageManager();
@@ -1706,6 +1716,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return false;
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
// ----------------------------------------------------------------------
@Override
diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java
index a93a6ee..fb7b56c 100644
--- a/services/java/com/android/server/ThrottleService.java
+++ b/services/java/com/android/server/ThrottleService.java
@@ -50,6 +50,7 @@ import android.text.TextUtils;
import android.util.Slog;
import com.android.internal.R;
+import com.android.internal.app.ThemeUtils;
import com.android.internal.telephony.TelephonyProperties;
import java.io.BufferedWriter;
@@ -76,6 +77,7 @@ public class ThrottleService extends IThrottleManager.Stub {
private HandlerThread mThread;
private Context mContext;
+ private Context mUiContext;
private static final int INITIAL_POLL_DELAY_SEC = 90;
private static final int TESTING_POLLING_PERIOD_SEC = 60 * 1;
@@ -305,6 +307,13 @@ public class ThrottleService extends IThrottleManager.Stub {
}
}, new IntentFilter(ACTION_RESET));
+ ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
// use a new thread as we don't want to stall the system for file writes
mThread = new HandlerThread(TAG);
mThread.start();
@@ -339,6 +348,12 @@ public class ThrottleService extends IThrottleManager.Stub {
}
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
private static final int EVENT_REBOOT_RECOVERY = 0;
private static final int EVENT_POLICY_CHANGED = 1;
@@ -619,7 +634,7 @@ public class ThrottleService extends IThrottleManager.Stub {
}
mThrottlingNotification.flags = flags;
mThrottlingNotification.tickerText = title;
- mThrottlingNotification.setLatestEventInfo(mContext, title, message, pi);
+ mThrottlingNotification.setLatestEventInfo(getUiContext(), title, message, pi);
mNotificationManager.notify(mThrottlingNotification.icon, mThrottlingNotification);
}
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java
index 759b686..d9a6117 100644
--- a/services/java/com/android/server/UiModeManagerService.java
+++ b/services/java/com/android/server/UiModeManagerService.java
@@ -56,6 +56,7 @@ import java.util.Iterator;
import com.android.internal.R;
import com.android.internal.app.DisableCarModeActivity;
+import com.android.internal.app.ThemeUtils;
class UiModeManagerService extends IUiModeManager.Stub {
private static final String TAG = UiModeManager.class.getSimpleName();
@@ -77,6 +78,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
private static final String ACTION_UPDATE_NIGHT_MODE = "com.android.server.action.UPDATE_NIGHT_MODE";
private final Context mContext;
+ private Context mUiContext;
final Object mLock = new Object();
@@ -233,6 +235,13 @@ class UiModeManagerService extends IUiModeManager.Stub {
}
};
+ private final BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ };
+
// A LocationListener to initialize the network location provider. The location updates
// are handled through the passive location provider.
private final LocationListener mEmptyLocationListener = new LocationListener() {
@@ -326,6 +335,8 @@ class UiModeManagerService extends IUiModeManager.Stub {
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
mContext.registerReceiver(mUpdateLocationReceiver, filter);
+ ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);
+
PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
@@ -593,7 +604,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
n.flags = Notification.FLAG_ONGOING_EVENT;
n.when = 0;
n.setLatestEventInfo(
- mContext,
+ getUiContext(),
mContext.getString(R.string.car_mode_disable_notification_title),
mContext.getString(R.string.car_mode_disable_notification_message),
PendingIntent.getActivity(mContext, 0, carModeOffIntent, 0));
@@ -789,6 +800,13 @@ class UiModeManagerService extends IUiModeManager.Stub {
mComputedNightMode = nightMode;
}
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index afeb592..1690bcb 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -59,6 +59,7 @@ import android.util.EventLog;
import android.util.Log;
import android.util.Config;
import com.android.internal.app.IBatteryStats;
+import com.android.internal.app.ThemeUtils;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -201,6 +202,8 @@ public class WifiStateTracker extends NetworkStateTracker {
public static final int SUPPL_SCAN_HANDLING_NORMAL = 1;
public static final int SUPPL_SCAN_HANDLING_LIST_ONLY = 2;
+ private Context mUiContext;
+
private WifiMonitor mWifiMonitor;
private WifiInfo mWifiInfo;
private List<ScanResult> mScanResults;
@@ -421,6 +424,13 @@ public class WifiStateTracker extends NetworkStateTracker {
}
},new IntentFilter(ACTION_DHCP_RENEW));
+ ThemeUtils.registerThemeChangeReceiver(mContext, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mUiContext = null;
+ }
+ });
+
PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
mDhcpRenewWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);
@@ -2399,7 +2409,7 @@ public class WifiStateTracker extends NetworkStateTracker {
CharSequence details = mContext.getResources().getQuantityText(
com.android.internal.R.plurals.wifi_available_detailed, numNetworks);
mNotification.tickerText = title;
- mNotification.setLatestEventInfo(mContext, title, details, mNotification.contentIntent);
+ mNotification.setLatestEventInfo(getUiContext(), title, details, mNotification.contentIntent);
mNotificationRepeatTime = System.currentTimeMillis() + NOTIFICATION_REPEAT_DELAY_MS;
@@ -2430,7 +2440,14 @@ public class WifiStateTracker extends NetworkStateTracker {
mNotificationRepeatTime = 0;
mNumScansSinceNetworkStateChange = 0;
}
-
+
+ private Context getUiContext() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+ return mUiContext != null ? mUiContext : mContext;
+ }
+
@Override
public String toString() {
StringBuffer sb = new StringBuffer();