Merge "Fixed a bug where the navigation notification would flicker" into oc-dev
This commit is contained in:
@@ -49,11 +49,11 @@ import com.android.systemui.statusbar.policy.RemoteInputView;
|
||||
*/
|
||||
public class NotificationContentView extends FrameLayout {
|
||||
|
||||
private static final int VISIBLE_TYPE_CONTRACTED = 0;
|
||||
private static final int VISIBLE_TYPE_EXPANDED = 1;
|
||||
private static final int VISIBLE_TYPE_HEADSUP = 2;
|
||||
public static final int VISIBLE_TYPE_CONTRACTED = 0;
|
||||
public static final int VISIBLE_TYPE_EXPANDED = 1;
|
||||
public static final int VISIBLE_TYPE_HEADSUP = 2;
|
||||
private static final int VISIBLE_TYPE_SINGLELINE = 3;
|
||||
private static final int VISIBLE_TYPE_AMBIENT = 4;
|
||||
public static final int VISIBLE_TYPE_AMBIENT = 4;
|
||||
private static final int VISIBLE_TYPE_AMBIENT_SINGLELINE = 5;
|
||||
public static final int UNDEFINED = -1;
|
||||
|
||||
@@ -928,7 +928,7 @@ public class NotificationContentView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private NotificationViewWrapper getVisibleWrapper(int visibleType) {
|
||||
public NotificationViewWrapper getVisibleWrapper(int visibleType) {
|
||||
switch (visibleType) {
|
||||
case VISIBLE_TYPE_EXPANDED:
|
||||
return mExpandedWrapper;
|
||||
@@ -1085,16 +1085,16 @@ public class NotificationContentView extends FrameLayout {
|
||||
mBeforeN = entry.targetSdk < Build.VERSION_CODES.N;
|
||||
updateAllSingleLineViews();
|
||||
if (mContractedChild != null) {
|
||||
mContractedWrapper.notifyContentUpdated(entry.row);
|
||||
mContractedWrapper.onContentUpdated(entry.row);
|
||||
}
|
||||
if (mExpandedChild != null) {
|
||||
mExpandedWrapper.notifyContentUpdated(entry.row);
|
||||
mExpandedWrapper.onContentUpdated(entry.row);
|
||||
}
|
||||
if (mHeadsUpChild != null) {
|
||||
mHeadsUpWrapper.notifyContentUpdated(entry.row);
|
||||
mHeadsUpWrapper.onContentUpdated(entry.row);
|
||||
}
|
||||
if (mAmbientChild != null) {
|
||||
mAmbientWrapper.notifyContentUpdated(entry.row);
|
||||
mAmbientWrapper.onContentUpdated(entry.row);
|
||||
}
|
||||
applyRemoteInput(entry);
|
||||
updateLegacy();
|
||||
|
||||
@@ -36,8 +36,8 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
super.notifyContentUpdated(row);
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
super.onContentUpdated(row);
|
||||
updateImageTag(row.getStatusBarNotification());
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ public class NotificationBigTextTemplateViewWrapper extends NotificationTemplate
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
// Reinspect the notification. Before the super call, because the super call also updates
|
||||
// the transformation types and we need to have our values set by then.
|
||||
resolveViews(row.getStatusBarNotification());
|
||||
super.notifyContentUpdated(row);
|
||||
super.onContentUpdated(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -128,8 +128,8 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
super.notifyContentUpdated(row);
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
super.onContentUpdated(row);
|
||||
mIsLowPriority = row.isLowPriority();
|
||||
mTransformLowPriorityTitle = !row.isChildInGroup() && !row.isSummaryWithChildren();
|
||||
ArraySet<View> previousViews = mTransformationHelper.getAllTransformingViews();
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.util.Assert;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
@@ -207,7 +206,8 @@ public class NotificationInflater {
|
||||
};
|
||||
applyRemoteView(result, reInflateFlags, flag, row, redactAmbient,
|
||||
isNewView, remoteViewClickHandler, callback, entry, privateLayout,
|
||||
privateLayout.getContractedChild(),
|
||||
privateLayout.getContractedChild(), privateLayout.getVisibleWrapper(
|
||||
NotificationContentView.VISIBLE_TYPE_CONTRACTED),
|
||||
runningInflations, applyCallback);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,9 @@ public class NotificationInflater {
|
||||
};
|
||||
applyRemoteView(result, reInflateFlags, flag, row,
|
||||
redactAmbient, isNewView, remoteViewClickHandler, callback, entry,
|
||||
privateLayout, privateLayout.getExpandedChild(), runningInflations,
|
||||
privateLayout, privateLayout.getExpandedChild(),
|
||||
privateLayout.getVisibleWrapper(
|
||||
NotificationContentView.VISIBLE_TYPE_EXPANDED), runningInflations,
|
||||
applyCallback);
|
||||
}
|
||||
}
|
||||
@@ -252,7 +254,9 @@ public class NotificationInflater {
|
||||
};
|
||||
applyRemoteView(result, reInflateFlags, flag, row,
|
||||
redactAmbient, isNewView, remoteViewClickHandler, callback, entry,
|
||||
privateLayout, privateLayout.getHeadsUpChild(), runningInflations,
|
||||
privateLayout, privateLayout.getHeadsUpChild(),
|
||||
privateLayout.getVisibleWrapper(
|
||||
NotificationContentView.VISIBLE_TYPE_HEADSUP), runningInflations,
|
||||
applyCallback);
|
||||
}
|
||||
}
|
||||
@@ -274,8 +278,9 @@ public class NotificationInflater {
|
||||
};
|
||||
applyRemoteView(result, reInflateFlags, flag, row,
|
||||
redactAmbient, isNewView, remoteViewClickHandler, callback, entry,
|
||||
publicLayout, publicLayout.getContractedChild(), runningInflations,
|
||||
applyCallback);
|
||||
publicLayout, publicLayout.getContractedChild(),
|
||||
publicLayout.getVisibleWrapper(NotificationContentView.VISIBLE_TYPE_CONTRACTED),
|
||||
runningInflations, applyCallback);
|
||||
}
|
||||
|
||||
flag = FLAG_REINFLATE_AMBIENT_VIEW;
|
||||
@@ -296,7 +301,8 @@ public class NotificationInflater {
|
||||
};
|
||||
applyRemoteView(result, reInflateFlags, flag, row,
|
||||
redactAmbient, isNewView, remoteViewClickHandler, callback, entry,
|
||||
newParent, newParent.getAmbientChild(), runningInflations,
|
||||
newParent, newParent.getAmbientChild(), newParent.getVisibleWrapper(
|
||||
NotificationContentView.VISIBLE_TYPE_AMBIENT), runningInflations,
|
||||
applyCallback);
|
||||
}
|
||||
|
||||
@@ -316,6 +322,7 @@ public class NotificationInflater {
|
||||
RemoteViews.OnClickHandler remoteViewClickHandler,
|
||||
@Nullable final InflationCallback callback, NotificationData.Entry entry,
|
||||
NotificationContentView parentLayout, View existingView,
|
||||
NotificationViewWrapper existingWrapper,
|
||||
final HashMap<Integer, CancellationSignal> runningInflations,
|
||||
ApplyCallback applyCallback) {
|
||||
RemoteViews.OnViewAppliedListener listener
|
||||
@@ -326,6 +333,8 @@ public class NotificationInflater {
|
||||
if (isNewView) {
|
||||
v.setIsRootNamespace(true);
|
||||
applyCallback.setResultView(v);
|
||||
} else if (existingWrapper != null) {
|
||||
existingWrapper.onReinflated();
|
||||
}
|
||||
runningInflations.remove(inflationId);
|
||||
finishIfDone(result, reInflateFlags, runningInflations, callback, row,
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.statusbar.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||
@@ -40,11 +39,11 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
// Reinspect the notification. Before the super call, because the super call also updates
|
||||
// the transformation types and we need to have our values set by then.
|
||||
resolveViews();
|
||||
super.notifyContentUpdated(row);
|
||||
super.onContentUpdated(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,11 +70,11 @@ public class NotificationMessagingTemplateViewWrapper extends NotificationTempla
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
// Reinspect the notification. Before the super call, because the super call also updates
|
||||
// the transformation types and we need to have our values set by then.
|
||||
resolveViews();
|
||||
super.notifyContentUpdated(row);
|
||||
super.onContentUpdated(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -133,11 +133,11 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
// Reinspect the notification. Before the super call, because the super call also updates
|
||||
// the transformation types and we need to have our values set by then.
|
||||
resolveTemplateViews(row.getStatusBarNotification());
|
||||
super.notifyContentUpdated(row);
|
||||
super.onContentUpdated(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,6 +66,7 @@ public abstract class NotificationViewWrapper implements TransformableView {
|
||||
mView = view;
|
||||
mRow = row;
|
||||
mDozer = createDozer(ctx);
|
||||
onReinflated();
|
||||
}
|
||||
|
||||
protected NotificationDozeHelper createDozer(Context ctx) {
|
||||
@@ -92,12 +93,15 @@ public abstract class NotificationViewWrapper implements TransformableView {
|
||||
* Notifies this wrapper that the content of the view might have changed.
|
||||
* @param row the row this wrapper is attached to
|
||||
*/
|
||||
public void notifyContentUpdated(ExpandableNotificationRow row) {
|
||||
public void onContentUpdated(ExpandableNotificationRow row) {
|
||||
mDarkInitialized = false;
|
||||
Drawable background = mView.getBackground();
|
||||
}
|
||||
|
||||
public void onReinflated() {
|
||||
if (shouldClearBackgroundOnReapply()) {
|
||||
mBackgroundColor = 0;
|
||||
}
|
||||
Drawable background = mView.getBackground();
|
||||
if (background instanceof ColorDrawable) {
|
||||
mBackgroundColor = ((ColorDrawable) background).getColor();
|
||||
mView.setBackground(null);
|
||||
|
||||
@@ -297,7 +297,7 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
} else {
|
||||
header.reapply(getContext(), mNotificationHeader);
|
||||
}
|
||||
mNotificationHeaderWrapper.notifyContentUpdated(mContainingNotification);
|
||||
mNotificationHeaderWrapper.onContentUpdated(mContainingNotification);
|
||||
recreateLowPriorityHeader(builder);
|
||||
recreateAmbientHeader(builder);
|
||||
updateHeaderVisibility(false /* animate */);
|
||||
@@ -316,14 +316,14 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
mNotificationHeaderAmbient = (ViewGroup) header.apply(getContext(), this);
|
||||
mNotificationHeaderWrapperAmbient = NotificationViewWrapper.wrap(getContext(),
|
||||
mNotificationHeaderAmbient, mContainingNotification);
|
||||
mNotificationHeaderWrapperAmbient.notifyContentUpdated(mContainingNotification);
|
||||
mNotificationHeaderWrapperAmbient.onContentUpdated(mContainingNotification);
|
||||
addView(mNotificationHeaderAmbient, 0);
|
||||
invalidate();
|
||||
} else {
|
||||
header.reapply(getContext(), mNotificationHeaderAmbient);
|
||||
}
|
||||
resetHeaderVisibilityIfNeeded(mNotificationHeaderAmbient, calculateDesiredHeader());
|
||||
mNotificationHeaderWrapperAmbient.notifyContentUpdated(mContainingNotification);
|
||||
mNotificationHeaderWrapperAmbient.onContentUpdated(mContainingNotification);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,7 +354,7 @@ public class NotificationChildrenContainer extends ViewGroup {
|
||||
} else {
|
||||
header.reapply(getContext(), mNotificationHeaderLowPriority);
|
||||
}
|
||||
mNotificationHeaderWrapperLowPriority.notifyContentUpdated(mContainingNotification);
|
||||
mNotificationHeaderWrapperLowPriority.onContentUpdated(mContainingNotification);
|
||||
resetHeaderVisibilityIfNeeded(mNotificationHeaderLowPriority, calculateDesiredHeader());
|
||||
} else {
|
||||
removeView(mNotificationHeaderLowPriority);
|
||||
|
||||
@@ -53,11 +53,14 @@ public class NotificationCustomViewWrapperTest extends SysuiTestCase {
|
||||
RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.custom_view_dark);
|
||||
View v = views.apply(mContext, null);
|
||||
NotificationViewWrapper wrap = NotificationCustomViewWrapper.wrap(mContext, v, mRow);
|
||||
wrap.notifyContentUpdated(mRow);
|
||||
Assert.assertTrue(wrap.getCustomBackgroundColor() != 0);
|
||||
wrap.onContentUpdated(mRow);
|
||||
Assert.assertTrue("No background set, when applying custom background view",
|
||||
wrap.getCustomBackgroundColor() != 0);
|
||||
views.reapply(mContext, v);
|
||||
wrap.notifyContentUpdated(mRow);
|
||||
Assert.assertTrue(wrap.getCustomBackgroundColor() != 0);
|
||||
wrap.onReinflated();
|
||||
wrap.onContentUpdated(mRow);
|
||||
Assert.assertTrue("Reapplying a custom remote view lost it's background!",
|
||||
wrap.getCustomBackgroundColor() != 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.view.View;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||
import com.android.systemui.statusbar.NotificationTestHelper;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -35,7 +36,9 @@ public class NotificationViewWrapperTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void constructor_doesntUseViewContext() throws Exception {
|
||||
new TestableNotificationViewWrapper(mContext, null /* view */, null /* row */);
|
||||
new TestableNotificationViewWrapper(mContext,
|
||||
new View(mContext),
|
||||
new NotificationTestHelper(getContext()).createRow());
|
||||
}
|
||||
|
||||
static class TestableNotificationViewWrapper extends NotificationViewWrapper {
|
||||
|
||||
Reference in New Issue
Block a user