Need to update the largeIcon for notifications when we're reapplying the views.
Bug: 3298062 Change-Id: I6bb72c0b93e00a9de8cc2633ac07add0a572a20f
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar;
|
||||
import android.app.Notification;
|
||||
import android.os.IBinder;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.internal.statusbar.StatusBarNotification;
|
||||
|
||||
@@ -36,6 +37,7 @@ public class NotificationData {
|
||||
public View row; // the outer expanded view
|
||||
public View content; // takes the click events and sends the PendingIntent
|
||||
public View expanded; // the inflated RemoteViews
|
||||
public ImageView largeIcon;
|
||||
public Entry() {}
|
||||
public Entry(IBinder key, StatusBarNotification n, StatusBarIconView ic) {
|
||||
this.key = key;
|
||||
@@ -88,6 +90,7 @@ public class NotificationData {
|
||||
entry.content = content;
|
||||
entry.expanded = expanded;
|
||||
entry.icon = icon;
|
||||
entry.largeIcon = null; // TODO add support for large icons
|
||||
return add(entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -635,16 +635,15 @@ public class TabletStatusBar extends StatusBar implements
|
||||
|
||||
// Can we just reapply the RemoteViews in place? If when didn't change, the order
|
||||
// didn't change.
|
||||
boolean contentsUnchanged = notification.isOngoing() == oldNotification.isOngoing()
|
||||
&& oldEntry.expanded != null
|
||||
&& contentView != null
|
||||
&& oldContentView != null
|
||||
boolean contentsUnchanged = oldEntry.expanded != null
|
||||
&& contentView != null && oldContentView != null
|
||||
&& contentView.getPackage() != null
|
||||
&& oldContentView.getPackage() != null
|
||||
&& oldContentView.getPackage().equals(contentView.getPackage())
|
||||
&& oldContentView.getLayoutId() == contentView.getLayoutId();
|
||||
ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent();
|
||||
boolean orderUnchanged = notification.notification.when==oldNotification.notification.when;
|
||||
boolean orderUnchanged = notification.notification.when==oldNotification.notification.when
|
||||
&& notification.isOngoing() == oldNotification.isOngoing();
|
||||
boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1;
|
||||
if (contentsUnchanged && (orderUnchanged || isLastAnyway)) {
|
||||
if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key);
|
||||
@@ -668,6 +667,13 @@ public class TabletStatusBar extends StatusBar implements
|
||||
handleNotificationError(key, notification, "Couldn't update icon: " + ic);
|
||||
return;
|
||||
}
|
||||
// Update the large icon
|
||||
if (notification.notification.largeIcon != null) {
|
||||
oldEntry.largeIcon.setImageBitmap(notification.notification.largeIcon);
|
||||
} else {
|
||||
oldEntry.largeIcon.getLayoutParams().width = 0;
|
||||
oldEntry.largeIcon.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (key == mNotificationPeekKey) {
|
||||
// must update the peek window
|
||||
@@ -1286,6 +1292,7 @@ public class TabletStatusBar extends StatusBar implements
|
||||
entry.row = row;
|
||||
entry.content = content;
|
||||
entry.expanded = expanded;
|
||||
entry.largeIcon = largeIcon;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BIN
tests/StatusBar/res/drawable-mdpi/pineapple2.png
Normal file
BIN
tests/StatusBar/res/drawable-mdpi/pineapple2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -238,7 +238,7 @@
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/when_midnight"
|
||||
style="@style/FieldContents.Disabled"
|
||||
style="@style/FieldContents"
|
||||
android:text="midnight"
|
||||
/>
|
||||
<RadioButton
|
||||
@@ -604,6 +604,11 @@
|
||||
style="@style/FieldContents"
|
||||
android:text="pineapple"
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/large_icon_pineapple2"
|
||||
style="@style/FieldContents"
|
||||
android:text="pineapple2"
|
||||
/>
|
||||
</RadioGroup>
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.statusbartest;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
@@ -190,8 +192,14 @@ public class NotificationBuilderTest extends Activity
|
||||
|
||||
// when
|
||||
switch (getRadioChecked(R.id.group_when)) {
|
||||
case R.id.when_midnight:
|
||||
case R.id.when_midnight: {
|
||||
GregorianCalendar c = new GregorianCalendar();
|
||||
c.set(GregorianCalendar.HOUR_OF_DAY, 0);
|
||||
c.set(GregorianCalendar.MINUTE, 0);
|
||||
c.set(GregorianCalendar.SECOND, 0);
|
||||
b.setWhen(c.getTimeInMillis());
|
||||
break;
|
||||
}
|
||||
case R.id.when_now:
|
||||
b.setWhen(System.currentTimeMillis());
|
||||
break;
|
||||
@@ -276,6 +284,9 @@ public class NotificationBuilderTest extends Activity
|
||||
case R.id.large_icon_pineapple:
|
||||
b.setLargeIcon(loadBitmap(R.drawable.pineapple));
|
||||
break;
|
||||
case R.id.large_icon_pineapple2:
|
||||
b.setLargeIcon(loadBitmap(R.drawable.pineapple2));
|
||||
break;
|
||||
}
|
||||
|
||||
// sound TODO
|
||||
|
||||
Reference in New Issue
Block a user