am cdadef36: am b77f53b2: Get the IconMerger working again.

This commit is contained in:
Joe Onorato
2010-06-02 22:40:48 -07:00
committed by Android Git Automerger
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.os.Handler;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.View;
import android.widget.LinearLayout;
import com.android.systemui.R;
public class IconMerger extends LinearLayout {
PhoneStatusBarService service;
private static final String TAG = "IconMerger";
private StatusBarIconView mMoreView;
public IconMerger(Context context, AttributeSet 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
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (true) {
return;
}
final int maxWidth = r - l;
final int N = getChildCount();
@@ -51,13 +66,12 @@ public class IconMerger extends LinearLayout {
}
// find the first visible one that isn't the more icon
View moreView = null;
final StatusBarIconView moreView = mMoreView;
int fitLeft = -1;
int startIndex = -1;
for (i=0; i<N; i++) {
final View child = getChildAt(i);
if (com.android.internal.R.drawable.stat_notify_more == child.getId()) {
moreView = child;
if (child == moreView) {
startIndex = i+1;
}
else if (child.getVisibility() != GONE) {
@@ -67,7 +81,11 @@ public class IconMerger extends LinearLayout {
}
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
@@ -85,14 +103,14 @@ public class IconMerger extends LinearLayout {
int breakingPoint = fitLeft + extra + adjust;
int number = 0;
for (i=startIndex; i<N; i++) {
final View child = getChildAt(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 = 0; // XXX this.service.getIconNumberForView(child);
int n = child.getStatusBarIcon().number;
if (n == 0) {
number += 1;
} else if (n > 0) {

View File

@@ -233,7 +233,6 @@ public class PhoneStatusBarService extends StatusBarService {
mStatusBarView = sb;
mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons);
mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
mNotificationIcons.service = this;
mIcons = (LinearLayout)sb.findViewById(R.id.icons);
mTickerView = sb.findViewById(R.id.ticker);
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);
// 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
setAreThereNotifications();
mDateView.setVisibility(View.INVISIBLE);
@@ -414,13 +419,13 @@ public class PhoneStatusBarService extends StatusBarService {
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
}
private int chooseIconIndex(boolean isOngoing, int index) {
final int ongoingSize = mOngoing.size();
private int chooseIconIndex(boolean isOngoing, int viewIndex) {
final int latestSize = mLatest.size();
if (!isOngoing) {
index = mLatest.size() + index;
if (isOngoing) {
return latestSize + (mOngoing.size() - viewIndex);
} else {
return latestSize - viewIndex;
}
return (ongoingSize + latestSize) - index - 1;
}
View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) {

View File

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