summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2011-11-15 09:20:56 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-15 09:20:56 -0800
commitce33622aed7fb25a14ef957cdc78b78cc4602be9 (patch)
tree6d0328c2f1763b862766ffbd3cf2ab36571b1ed9 /packages
parent538dc6acfd14ea59f0b294531f9417ca04ca621f (diff)
parent05e2414ef5a3a8fecbabc1f220c9925539d51f7a (diff)
downloadframeworks_base-ce33622aed7fb25a14ef957cdc78b78cc4602be9.zip
frameworks_base-ce33622aed7fb25a14ef957cdc78b78cc4602be9.tar.gz
frameworks_base-ce33622aed7fb25a14ef957cdc78b78cc4602be9.tar.bz2
Merge "Bring back the 'more notifications' icon." into ics-mr1
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/layout/status_bar.xml40
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/IconMerger.java118
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java3
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 af2c93c..b1aaade 100644
--- a/packages/SystemUI/res/layout/status_bar.xml
+++ b/packages/SystemUI/res/layout/status_bar.xml
@@ -31,21 +31,35 @@
<LinearLayout android:id="@+id/icons"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="horizontal">
-
- <com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons"
+ android:paddingLeft="6dip"
+ android:paddingRight="6dip"
+ android:orientation="horizontal"
+ >
+
+ <LinearLayout
android:layout_width="0dip"
- android:layout_weight="1"
android:layout_height="match_parent"
- android:layout_alignParentLeft="true"
- android:paddingLeft="6dip"
- android:gravity="center_vertical"
- android:orientation="horizontal"/>
-
+ android:layout_weight="1"
+ android:orientation="horizontal"
+ >
+ <com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon"
+ android:layout_width="@dimen/status_bar_icon_size"
+ android:layout_height="match_parent"
+ android:src="@drawable/stat_notify_more"
+ android:visibility="gone"
+ />
+
+ <com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentLeft="true"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"/>
+ </LinearLayout>
+
<LinearLayout android:id="@+id/statusIcons"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_alignParentRight="true"
android:gravity="center_vertical"
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"
/>
</LinearLayout>
@@ -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"
/>
</LinearLayout>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index 6997837..8228df5 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 20215bd..0640282 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<N; i++) {
- final View child = getChildAt(i);
- if (child == moreView) {
- startIndex = i+1;
- }
- else if (child.getVisibility() != GONE) {
- fitLeft = child.getLeft();
- break;
- }
- }
+ private void checkOverflow(int width) {
+ if (mMoreView == null) return;
- if (moreView == null || startIndex < 0) {
- return;
- /*
- throw new RuntimeException("Status Bar / IconMerger moreView == " + moreView
- + " startIndex=" + startIndex);
- */
- }
-
- // if it fits without the more icon, then hide the more icon and update fitLeft
- // so everything gets pushed left
- int adjust = 0;
- if (fitRight - fitLeft <= maxWidth) {
- adjust = fitLeft - moreView.getLeft();
- fitLeft -= adjust;
- fitRight -= adjust;
- moreView.layout(0, moreView.getTop(), 0, moreView.getBottom());
+ final int N = getChildCount();
+ int visibleChildren = 0;
+ for (int i=0; i<N; i++) {
+ if (getChildAt(i).getVisibility() != GONE) visibleChildren++;
}
- int extra = fitRight - r;
- int shift = -1;
-
- int breakingPoint = fitLeft + extra + adjust;
- int number = 0;
- for (i=startIndex; i<N; i++) {
- final StatusBarIconView child = (StatusBarIconView)getChildAt(i);
- if (child.getVisibility() != GONE) {
- int childLeft = child.getLeft();
- int childRight = child.getRight();
- if (childLeft < breakingPoint) {
- // hide this one
- child.layout(0, child.getTop(), 0, child.getBottom());
- int n = child.getStatusBarIcon().number;
- if (n == 0) {
- number += 1;
- } else if (n > 0) {
- number += n;
- }
- } else {
- // decide how much to shift by
- if (shift < 0) {
- shift = childLeft - fitLeft;
- }
- // shift this left by shift
- child.layout(childLeft-shift, child.getTop(),
- childRight-shift, child.getBottom());
+ final boolean overflowShown = (mMoreView.getVisibility() == View.VISIBLE);
+ // let's assume we have one more slot if the more icon is already showing
+ if (overflowShown) visibleChildren --;
+ final boolean moreRequired = visibleChildren * mIconSize > width;
+ if (moreRequired != overflowShown) {
+ post(new Runnable() {
+ @Override
+ public void run() {
+ mMoreView.setVisibility(moreRequired ? View.VISIBLE : View.GONE);
}
- }
+ });
}
-
- mMoreIcon.number = number;
- mMoreView.set(mMoreIcon);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 51fb262..b0554d0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -149,6 +149,7 @@ public class PhoneStatusBar extends StatusBar {
// icons
LinearLayout mIcons;
IconMerger mNotificationIcons;
+ View mMoreIcon;
LinearLayout mStatusIcons;
// expanded notifications
@@ -307,6 +308,8 @@ public class PhoneStatusBar extends StatusBar {
mPixelFormat = PixelFormat.OPAQUE;
mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons);
mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
+ mMoreIcon = sb.findViewById(R.id.moreIcon);
+ mNotificationIcons.setOverflowIndicator(mMoreIcon);
mIcons = (LinearLayout)sb.findViewById(R.id.icons);
mTickerView = sb.findViewById(R.id.ticker);