From 05e2414ef5a3a8fecbabc1f220c9925539d51f7a Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 10 Nov 2011 11:56:49 -0500 Subject: Bring back the 'more notifications' icon. In fact, there's even more going on here. Icons were appearing cut off because of the unusual width of icons on the right-hand side of the status bar; we now take extra steps to ensure that the IconMerger is only wide enough to show an integral number of icons. But that causes problems with the rest of the status bar the IconMerger makes itself thinner than the overall layout requires, so there's now a containing layout to absorb the additional horizontal space properly. Bug: 5136545 Change-Id: I8c4d1ee2bcd976c452510b33c196fbe0c3e8c660 --- packages/SystemUI/res/layout/status_bar.xml | 40 ++++--- .../systemui/statusbar/StatusBarIconView.java | 13 +++ .../systemui/statusbar/phone/IconMerger.java | 118 ++++++--------------- .../systemui/statusbar/phone/PhoneStatusBar.java | 3 + 4 files changed, 75 insertions(+), 99 deletions(-) diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index af2c93c19f5a..b1aaade7c914 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -31,21 +31,35 @@ - - + + - + android:layout_weight="1" + android:orientation="horizontal" + > + + + + + @@ -53,7 +67,7 @@ android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_marginRight="6dp" + android:paddingLeft="2dp" android:orientation="horizontal" android:gravity="center" > @@ -66,7 +80,7 @@ android:id="@+id/battery" android:layout_height="wrap_content" android:layout_width="wrap_content" - android:paddingLeft="6dip" + android:paddingLeft="4dip" /> @@ -76,7 +90,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" - android:paddingRight="6dip" + android:paddingLeft="6dip" android:gravity="center_vertical|left" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index 69978378d140..8228df5a1fcd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -25,6 +25,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.text.TextUtils; +import android.util.AttributeSet; import android.util.Slog; import android.util.Log; import android.view.ViewDebug; @@ -75,6 +76,18 @@ public class StatusBarIconView extends AnimatedImageView { setScaleType(ImageView.ScaleType.CENTER); } + public StatusBarIconView(Context context, AttributeSet attrs) { + super(context, attrs); + final Resources res = context.getResources(); + final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size); + final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size); + final float scale = (float)imageBounds / (float)outerBounds; + setScaleX(scale); + setScaleY(scale); + final float alpha = res.getFraction(R.dimen.status_bar_icon_drawing_alpha, 1, 1); + setAlpha(alpha); + } + private static boolean streq(String a, String b) { if (a == b) { return true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/IconMerger.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/IconMerger.java index 20215bd5cbf0..0640282422d9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/IconMerger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/IconMerger.java @@ -30,113 +30,59 @@ import com.android.systemui.statusbar.StatusBarIconView; public class IconMerger extends LinearLayout { private static final String TAG = "IconMerger"; + private static final boolean DEBUG = false; private int mIconSize; - private StatusBarIconView mMoreView; - private StatusBarIcon mMoreIcon = new StatusBarIcon(null, R.drawable.stat_notify_more, 0, 0, - null); + private View mMoreView; public IconMerger(Context context, AttributeSet attrs) { super(context, attrs); mIconSize = context.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.status_bar_icon_size); + R.dimen.status_bar_icon_size); - mMoreView = new StatusBarIconView(context, "more", null); - mMoreView.set(mMoreIcon); - super.addView(mMoreView, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize)); + if (DEBUG) { + setBackgroundColor(0x800099FF); + } } - public void addView(StatusBarIconView v, int index, LinearLayout.LayoutParams p) { - super.addView(v, index+1, p); + public void setOverflowIndicator(View v) { + mMoreView = v; } - public void addView(StatusBarIconView v, int index) { - super.addView(v, index+1, new LinearLayout.LayoutParams(mIconSize, mIconSize)); + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + // we need to constrain this to an integral multiple of our children + int width = getMeasuredWidth(); + setMeasuredDimension(width - (width % mIconSize), getMeasuredHeight()); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); + checkOverflow(r - l); + } - final int maxWidth = r - l; - final int N = getChildCount(); - int i; - - // get the rightmost one, and see if we even need to do anything - int fitRight = -1; - for (i=N-1; i>=0; i--) { - final View child = getChildAt(i); - if (child.getVisibility() != GONE) { - fitRight = child.getRight(); - break; - } - } - - // find the first visible one that isn't the more icon - final StatusBarIconView moreView = mMoreView; - int fitLeft = -1; - int startIndex = -1; - for (i=0; i