Get the IconMerger working again.

Change-Id: I73719f4fd475a39d4c1245de45c6a13c31e6323b
This commit is contained in:
Joe Onorato
2010-05-28 19:59:51 -04:00
parent 87937dbcd1
commit b77f53b21c
3 changed files with 43 additions and 16 deletions

View File

@@ -19,22 +19,37 @@ package com.android.systemui.statusbar;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Slog;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.android.systemui.R;
public class IconMerger extends LinearLayout { public class IconMerger extends LinearLayout {
PhoneStatusBarService service; private static final String TAG = "IconMerger";
private StatusBarIconView mMoreView;
public IconMerger(Context context, AttributeSet attrs) { public IconMerger(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }
public void addMoreView(StatusBarIconView v, LinearLayout.LayoutParams lp) {
super.addView(v, lp);
mMoreView = v;
}
public void addView(StatusBarIconView v, int index, LinearLayout.LayoutParams lp) {
if (index == 0) {
throw new RuntimeException("Attempt to put view before the more view: " + v);
}
super.addView(v, index, lp);
}
@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);
if (true) {
return;
}
final int maxWidth = r - l; final int maxWidth = r - l;
final int N = getChildCount(); final int N = getChildCount();
@@ -51,13 +66,12 @@ public class IconMerger extends LinearLayout {
} }
// find the first visible one that isn't the more icon // find the first visible one that isn't the more icon
View moreView = null; final StatusBarIconView moreView = mMoreView;
int fitLeft = -1; int fitLeft = -1;
int startIndex = -1; int startIndex = -1;
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
final View child = getChildAt(i); final View child = getChildAt(i);
if (com.android.internal.R.drawable.stat_notify_more == child.getId()) { if (child == moreView) {
moreView = child;
startIndex = i+1; startIndex = i+1;
} }
else if (child.getVisibility() != GONE) { else if (child.getVisibility() != GONE) {
@@ -67,7 +81,11 @@ public class IconMerger extends LinearLayout {
} }
if (moreView == null || startIndex < 0) { if (moreView == null || startIndex < 0) {
throw new RuntimeException("Status Bar / IconMerger moreView == null"); 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 // if it fits without the more icon, then hide the more icon and update fitLeft
@@ -85,14 +103,14 @@ public class IconMerger extends LinearLayout {
int breakingPoint = fitLeft + extra + adjust; int breakingPoint = fitLeft + extra + adjust;
int number = 0; int number = 0;
for (i=startIndex; i<N; i++) { for (i=startIndex; i<N; i++) {
final View child = getChildAt(i); final StatusBarIconView child = (StatusBarIconView)getChildAt(i);
if (child.getVisibility() != GONE) { if (child.getVisibility() != GONE) {
int childLeft = child.getLeft(); int childLeft = child.getLeft();
int childRight = child.getRight(); int childRight = child.getRight();
if (childLeft < breakingPoint) { if (childLeft < breakingPoint) {
// hide this one // hide this one
child.layout(0, child.getTop(), 0, child.getBottom()); child.layout(0, child.getTop(), 0, child.getBottom());
int n = 0; // XXX this.service.getIconNumberForView(child); int n = child.getStatusBarIcon().number;
if (n == 0) { if (n == 0) {
number += 1; number += 1;
} else if (n > 0) { } else if (n > 0) {

View File

@@ -233,7 +233,6 @@ public class PhoneStatusBarService extends StatusBarService {
mStatusBarView = sb; mStatusBarView = sb;
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);
mNotificationIcons.service = this;
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);
mDateView = (DateView)sb.findViewById(R.id.date); mDateView = (DateView)sb.findViewById(R.id.date);
@@ -268,6 +267,12 @@ public class PhoneStatusBarService extends StatusBarService {
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
// the more notifications icon
StatusBarIconView moreView = new StatusBarIconView(this, "more");
moreView.set(new StatusBarIcon(null, R.drawable.stat_notify_more, 0));
mNotificationIcons.addMoreView(moreView,
new LinearLayout.LayoutParams(mIconWidth, mHeight));
// set the inital view visibility // set the inital view visibility
setAreThereNotifications(); setAreThereNotifications();
mDateView.setVisibility(View.INVISIBLE); mDateView.setVisibility(View.INVISIBLE);
@@ -414,13 +419,13 @@ public class PhoneStatusBarService extends StatusBarService {
updateExpandedViewPos(EXPANDED_LEAVE_ALONE); updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
} }
private int chooseIconIndex(boolean isOngoing, int index) { private int chooseIconIndex(boolean isOngoing, int viewIndex) {
final int ongoingSize = mOngoing.size();
final int latestSize = mLatest.size(); final int latestSize = mLatest.size();
if (!isOngoing) { if (isOngoing) {
index = mLatest.size() + index; return latestSize + (mOngoing.size() - viewIndex);
} else {
return latestSize - viewIndex;
} }
return (ongoingSize + latestSize) - index - 1;
} }
View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) { View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) {

View File

@@ -124,4 +124,8 @@ public class StatusBarIconView extends AnimatedImageView {
return null; return null;
} }
public StatusBarIcon getStatusBarIcon() {
return mIcon;
}
} }