summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server
diff options
context:
space:
mode:
authorMichael Webster <miketwebster@gmail.com>2010-07-24 18:26:17 -0400
committerSteve Kondik <shade@chemlab.org>2010-07-26 23:36:13 -0400
commitdd3351db185f88c9be527cc72a9e393ad967c56b (patch)
tree0ac01715013f1aa5cf8e17b4d6b6ed11b3402603 /services/java/com/android/server
parent21c263c47ff0ae84549bb350a81670bc60bb09c5 (diff)
downloadframeworks_base-dd3351db185f88c9be527cc72a9e393ad967c56b.zip
frameworks_base-dd3351db185f88c9be527cc72a9e393ad967c56b.tar.gz
frameworks_base-dd3351db185f88c9be527cc72a9e393ad967c56b.tar.bz2
Add color pull-down notification view.
Fix notification service so that apps that pass non-standard notification views will have their text colored according to user customization. Clean up existing code from status bar customizations.
Diffstat (limited to 'services/java/com/android/server')
-rw-r--r--services/java/com/android/server/status/StatusBarService.java142
-rw-r--r--services/java/com/android/server/status/TrackingPatternView.java27
2 files changed, 138 insertions, 31 deletions
diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java
index bfa3232..a8ede5b 100644
--- a/services/java/com/android/server/status/StatusBarService.java
+++ b/services/java/com/android/server/status/StatusBarService.java
@@ -55,6 +55,7 @@ import android.view.WindowManager;
import android.view.WindowManagerImpl;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.ScrollView;
@@ -71,7 +72,7 @@ import android.provider.Settings;
import java.lang.reflect.Field;
import android.graphics.PorterDuff.Mode;
-import android.widget.Toast;
+import android.graphics.drawable.StateListDrawable;
/**
@@ -110,8 +111,6 @@ public class StatusBarService extends IStatusBar.Stub
private static final int OP_EXPAND = 5;
private static final int OP_TOGGLE = 6;
private static final int OP_DISABLE = 7;
- private static final int NOT_BAR_STOCK = 10;
- private static final int NOT_BAR_CUSTOM = 11;
private class PendingOp {
IBinder key;
@@ -242,9 +241,16 @@ public class StatusBarService extends IStatusBar.Stub
private int notificationTitleColor = blackColor;
private int notificationTextColor = blackColor;
private int notificationTimeColor = blackColor;
- int notBarType = 0;
- int colorMask;
- Mode PDMode = Mode.SCREEN;
+ boolean custNotBar = false;
+ boolean custExpBar = false;
+ int notifBarColorMask;
+ int expBarColorMask;
+ Mode notifPDMode = Mode.SCREEN;
+ Mode expPDMode = Mode.SCREEN;
+ Drawable closerDrawable;
+ Drawable expBarBackDrawable;
+ Drawable expBarHeadDrawable;
+ Drawable expBarNotifTitleDrawable;
// for disabling the status bar
@@ -293,18 +299,14 @@ public class StatusBarService extends IStatusBar.Stub
}
mStatusBarView = sb;
mDateView = (DateView)sb.findViewById(R.id.date);
- switch (notBarType) {
- case NOT_BAR_STOCK:
- break; // this is on startup, bgdrawable is already set thru xml layout;
- case NOT_BAR_CUSTOM:
+
+ if (custNotBar) {
mStatusBarView.setBackgroundDrawable(res.getDrawable(com.android.internal.R.drawable.statusbar_background_sq,
- colorMask, PDMode));
+ notifBarColorMask, notifPDMode));
mDateView.setBackgroundDrawable(res.getDrawable(com.android.internal.R.drawable.statusbar_background_sq,
- colorMask, PDMode));
- break;
- }
- mStatusBarView.refreshDrawableState();
- mDateView.refreshDrawableState();
+ notifBarColorMask, notifPDMode));
+ mDateView.setPadding(6, 0, 6, 0);
+ }
mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons);
mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
@@ -327,7 +329,13 @@ public class StatusBarService extends IStatusBar.Stub
mPlmnLabel = (TextView)expanded.findViewById(R.id.plmnLabel);
mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);
-
+ if (custExpBar) {
+ mExpandedView.findViewById(R.id.exp_view_lin_layout).
+ setBackgroundDrawable(expBarHeadDrawable);
+ mNoNotificationsTitle.setBackgroundDrawable(expBarNotifTitleDrawable);
+ mOngoingTitle.setBackgroundDrawable(expBarNotifTitleDrawable);
+ mLatestTitle.setBackgroundDrawable(expBarNotifTitleDrawable);
+ }
mOngoingTitle.setVisibility(View.GONE);
mLatestTitle.setVisibility(View.GONE);
@@ -340,8 +348,14 @@ public class StatusBarService extends IStatusBar.Stub
com.android.internal.R.layout.status_bar_tracking, null);
mTrackingView.mService = this;
mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close);
+ if (custExpBar) {
+ ImageView iv = (ImageView)mTrackingView.findViewById(R.id.close_image);
+ mCloseView.removeAllViews();
+ iv.setImageDrawable(closerDrawable);
+ iv.setColorFilter(expBarColorMask, expPDMode);
+ mCloseView.addView(iv);
+ }
mCloseView.mService = this;
-
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
// add the more icon for the notifications
@@ -867,7 +881,8 @@ public class StatusBarService extends IStatusBar.Stub
};
View makeNotificationView(StatusBarNotification notification, ViewGroup parent) {
- NotificationData n = notification.data;
+ Resources res = mContext.getResources();
+ NotificationData n = notification.data;
RemoteViews remoteViews = n.contentView;
if (remoteViews == null) {
return null;
@@ -877,9 +892,22 @@ public class StatusBarService extends IStatusBar.Stub
LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(com.android.internal.R.layout.status_bar_latest_event, parent, false);
-
- // bind the click event to the content area
ViewGroup content = (ViewGroup)row.findViewById(com.android.internal.R.id.content);
+ if (custExpBar) {
+ StateListDrawable sld = new StateListDrawable();
+ int stateFocused = android.R.attr.state_focused;
+ int statePressed = android.R.attr.state_pressed;
+ Drawable colornormal = res.getDrawable(com.android.internal.R.drawable.status_bar_item_background_normal_cust);
+ Drawable colorfocused = res.getDrawable(com.android.internal.R.drawable.status_bar_item_background_focus_cust);
+ Drawable colorpressed = res.getDrawable(com.android.internal.R.drawable.status_bar_item_background_pressed_cust);
+ sld.addState(new int[] {stateFocused}, colorfocused);
+ sld.addState(new int[] {statePressed}, colorpressed);
+ sld.addState(new int[] {}, colornormal);
+ sld.mutate();
+ sld.setColorFilter(expBarColorMask, expPDMode);
+ content.setBackgroundDrawable(sld);
+
+ }
content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
content.setOnFocusChangeListener(mFocusChangeListener);
PendingIntent contentIntent = n.contentIntent;
@@ -900,7 +928,7 @@ public class StatusBarService extends IStatusBar.Stub
return null;
}
- //Try-catch cause it does not work with QuickSettings, possibly other apps too :( (Won't work thru XML as well)
+ boolean customview = false;
try {
TextView tv1 = (TextView) child.findViewById(com.android.internal.R.id.title);
TextView tv2 = (TextView) child.findViewById(com.android.internal.R.id.text);
@@ -910,8 +938,45 @@ public class StatusBarService extends IStatusBar.Stub
tv3.setTextColor(notificationTimeColor);
}
catch (Exception e) {
+ customview = true;
}
+ // This will try to handle text color for custom notifications from apps
+ // This only works if the notification's view hierarchy is 2 layers deep or less
+ // Applies the same color to all views (no distinguishing title from body - but better than nothing
+ if (customview) {
+ int viewcount;
+ int i;
+ int j;
+ View current;
+ ViewGroup vg = (ViewGroup)child;
+ viewcount = vg.getChildCount();
+ for (i = 0; i < viewcount; i++) {
+ try {
+ current = (View) vg.getChildAt(i);
+ ViewGroup childasvg = (ViewGroup)current;
+ int subchildcount = childasvg.getChildCount();
+ if (subchildcount > 0) {
+ for (j = 0; j < subchildcount; j++) {
+ try {
+ TextView subtv = (TextView) childasvg.getChildAt(j);
+ subtv.setTextColor(notificationTextColor);
+ } catch (Exception e){
+ }
+ }
+
+ } else {
+ try {
+ TextView tv = (TextView) current;
+ tv.setTextColor(notificationTextColor);
+ } catch (Exception e) {
+ }
+ }
+ }
+ catch (Exception e) {
+ }
+ }
+ }
content.addView(child);
row.setDrawingCacheEnabled(true);
@@ -1948,15 +2013,36 @@ public class StatusBarService extends IStatusBar.Stub
}
private void getNotBarConfig() {
- int ret[];
+ Resources res = mContext.getResources();
+ /*
+ * Setup color and bar type for notification strip
+ */
boolean useCustom = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NOTIF_BAR_CUSTOM, 0) == 1;
- colorMask = Settings.System.getInt(mContext.getContentResolver(),
+ notifBarColorMask = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NOTIF_BAR_COLOR, whiteColor);
- if (!useCustom) {
- notBarType = NOT_BAR_STOCK;
+ if (useCustom) {
+ custNotBar = true;
} else {
- notBarType = NOT_BAR_CUSTOM;
- }
+ custNotBar = false;
+ }
+ /*
+ * Setup colors for expanded notification drawables
+ */
+ boolean useCustomExp = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.NOTIF_EXPANDED_BAR_CUSTOM, 0) == 1;
+ expBarColorMask = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.NOTIF_EXPANDED_BAR_COLOR, whiteColor);
+ int noalpha = expBarColorMask | 0xFF000000;
+ if (useCustomExp) {
+ closerDrawable = res.getDrawable(com.android.internal.R.drawable.status_bar_close_on_cust);
+ expBarHeadDrawable = res.getDrawable(com.android.internal.R.drawable.status_bar_header_background_cust,
+ expBarColorMask, expPDMode);
+ expBarNotifTitleDrawable = res.getDrawable(com.android.internal.R.drawable.title_bar_portrait_cust,
+ noalpha, expPDMode); // always solid
+ custExpBar = true;
+ } else {
+ custExpBar = false;
+ }
}
}
diff --git a/services/java/com/android/server/status/TrackingPatternView.java b/services/java/com/android/server/status/TrackingPatternView.java
index 2c91aa4..46648af 100644
--- a/services/java/com/android/server/status/TrackingPatternView.java
+++ b/services/java/com/android/server/status/TrackingPatternView.java
@@ -17,7 +17,9 @@
package com.android.server.status;
import android.content.Context;
+import android.content.res.Resources;
import android.content.res.TypedArray;
+import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.View;
@@ -25,6 +27,10 @@ import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.graphics.PorterDuff.Mode;
+import android.graphics.drawable.BitmapDrawable;
+
public class TrackingPatternView extends View {
private Bitmap mTexture;
@@ -34,9 +40,7 @@ public class TrackingPatternView extends View {
public TrackingPatternView(Context context, AttributeSet attrs) {
super(context, attrs);
-
- mTexture = BitmapFactory.decodeResource(getResources(),
- com.android.internal.R.drawable.status_bar_background);
+ setTexture();
mTextureWidth = mTexture.getWidth();
mTextureHeight = mTexture.getHeight();
@@ -67,4 +71,21 @@ public class TrackingPatternView extends View {
x += textureWidth;
}
}
+
+ private void setTexture() {
+ boolean useCustomExp = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.NOTIF_EXPANDED_BAR_CUSTOM, 0) == 1;
+ int expBarColorMask = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.NOTIF_EXPANDED_BAR_COLOR, 0xFF000000);
+ if (useCustomExp) {
+ Bitmap tempbm = BitmapFactory.decodeResource(getResources(),
+ com.android.internal.R.drawable.status_bar_background_cust);
+ Bitmap mutable = Bitmap.createBitmap(tempbm.getWidth(), tempbm.getHeight(), Bitmap.Config.ARGB_8888);
+ mutable.eraseColor(expBarColorMask);
+ mTexture = mutable;
+ } else {
+ mTexture = BitmapFactory.decodeResource(getResources(),
+ com.android.internal.R.drawable.status_bar_background);
+ }
+ }
}