Merge "Bring back the 'more notifications' icon." into ics-mr1
This commit is contained in:
committed by
Android (Google) Code Review
commit
ce33622aed
@@ -31,21 +31,35 @@
|
|||||||
<LinearLayout android:id="@+id/icons"
|
<LinearLayout android:id="@+id/icons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal">
|
android:paddingLeft="6dip"
|
||||||
|
android:paddingRight="6dip"
|
||||||
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons"
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_weight="1"
|
||||||
android:paddingLeft="6dip"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical"
|
>
|
||||||
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"
|
<LinearLayout android:id="@+id/statusIcons"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"/>
|
android:orientation="horizontal"/>
|
||||||
|
|
||||||
@@ -53,7 +67,7 @@
|
|||||||
android:id="@+id/signal_battery_cluster"
|
android:id="@+id/signal_battery_cluster"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginRight="6dp"
|
android:paddingLeft="2dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
>
|
>
|
||||||
@@ -66,7 +80,7 @@
|
|||||||
android:id="@+id/battery"
|
android:id="@+id/battery"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:paddingLeft="6dip"
|
android:paddingLeft="4dip"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -76,7 +90,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:paddingRight="6dip"
|
android:paddingLeft="6dip"
|
||||||
android:gravity="center_vertical|left"
|
android:gravity="center_vertical|left"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ViewDebug;
|
import android.view.ViewDebug;
|
||||||
@@ -75,6 +76,18 @@ public class StatusBarIconView extends AnimatedImageView {
|
|||||||
setScaleType(ImageView.ScaleType.CENTER);
|
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) {
|
private static boolean streq(String a, String b) {
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -30,113 +30,59 @@ import com.android.systemui.statusbar.StatusBarIconView;
|
|||||||
|
|
||||||
public class IconMerger extends LinearLayout {
|
public class IconMerger extends LinearLayout {
|
||||||
private static final String TAG = "IconMerger";
|
private static final String TAG = "IconMerger";
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
private int mIconSize;
|
private int mIconSize;
|
||||||
private StatusBarIconView mMoreView;
|
private View mMoreView;
|
||||||
private StatusBarIcon mMoreIcon = new StatusBarIcon(null, R.drawable.stat_notify_more, 0, 0,
|
|
||||||
null);
|
|
||||||
|
|
||||||
public IconMerger(Context context, AttributeSet attrs) {
|
public IconMerger(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
mIconSize = context.getResources().getDimensionPixelSize(
|
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);
|
if (DEBUG) {
|
||||||
mMoreView.set(mMoreIcon);
|
setBackgroundColor(0x800099FF);
|
||||||
super.addView(mMoreView, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addView(StatusBarIconView v, int index, LinearLayout.LayoutParams p) {
|
public void setOverflowIndicator(View v) {
|
||||||
super.addView(v, index+1, p);
|
mMoreView = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addView(StatusBarIconView v, int index) {
|
@Override
|
||||||
super.addView(v, index+1, new LinearLayout.LayoutParams(mIconSize, mIconSize));
|
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
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
super.onLayout(changed, l, t, r, b);
|
super.onLayout(changed, l, t, r, b);
|
||||||
|
checkOverflow(r - l);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkOverflow(int width) {
|
||||||
|
if (mMoreView == null) return;
|
||||||
|
|
||||||
final int maxWidth = r - l;
|
|
||||||
final int N = getChildCount();
|
final int N = getChildCount();
|
||||||
int i;
|
int visibleChildren = 0;
|
||||||
|
for (int i=0; i<N; i++) {
|
||||||
// get the rightmost one, and see if we even need to do anything
|
if (getChildAt(i).getVisibility() != GONE) visibleChildren++;
|
||||||
int fitRight = -1;
|
|
||||||
for (i=N-1; i>=0; i--) {
|
|
||||||
final View child = getChildAt(i);
|
|
||||||
if (child.getVisibility() != GONE) {
|
|
||||||
fitRight = child.getRight();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
final boolean overflowShown = (mMoreView.getVisibility() == View.VISIBLE);
|
||||||
// find the first visible one that isn't the more icon
|
// let's assume we have one more slot if the more icon is already showing
|
||||||
final StatusBarIconView moreView = mMoreView;
|
if (overflowShown) visibleChildren --;
|
||||||
int fitLeft = -1;
|
final boolean moreRequired = visibleChildren * mIconSize > width;
|
||||||
int startIndex = -1;
|
if (moreRequired != overflowShown) {
|
||||||
for (i=0; i<N; i++) {
|
post(new Runnable() {
|
||||||
final View child = getChildAt(i);
|
@Override
|
||||||
if (child == moreView) {
|
public void run() {
|
||||||
startIndex = i+1;
|
mMoreView.setVisibility(moreRequired ? View.VISIBLE : View.GONE);
|
||||||
}
|
|
||||||
else if (child.getVisibility() != GONE) {
|
|
||||||
fitLeft = child.getLeft();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mMoreIcon.number = number;
|
|
||||||
mMoreView.set(mMoreIcon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ public class PhoneStatusBar extends StatusBar {
|
|||||||
// icons
|
// icons
|
||||||
LinearLayout mIcons;
|
LinearLayout mIcons;
|
||||||
IconMerger mNotificationIcons;
|
IconMerger mNotificationIcons;
|
||||||
|
View mMoreIcon;
|
||||||
LinearLayout mStatusIcons;
|
LinearLayout mStatusIcons;
|
||||||
|
|
||||||
// expanded notifications
|
// expanded notifications
|
||||||
@@ -307,6 +308,8 @@ public class PhoneStatusBar extends StatusBar {
|
|||||||
mPixelFormat = PixelFormat.OPAQUE;
|
mPixelFormat = PixelFormat.OPAQUE;
|
||||||
mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons);
|
mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons);
|
||||||
mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
|
mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
|
||||||
|
mMoreIcon = sb.findViewById(R.id.moreIcon);
|
||||||
|
mNotificationIcons.setOverflowIndicator(mMoreIcon);
|
||||||
mIcons = (LinearLayout)sb.findViewById(R.id.icons);
|
mIcons = (LinearLayout)sb.findViewById(R.id.icons);
|
||||||
mTickerView = sb.findViewById(R.id.ticker);
|
mTickerView = sb.findViewById(R.id.ticker);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user