Merge "Update notification shade text on zen change" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-19 17:11:25 +00:00
committed by Android (Google) Code Review
4 changed files with 35 additions and 4 deletions

View File

@@ -62,6 +62,10 @@ public class EmptyShadeView extends StackScrollerDecorView {
mEmptyText.setText(mText);
}
public int getTextResource() {
return mText;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();

View File

@@ -784,6 +784,12 @@ public class StatusBar extends SystemUI implements DemoMode,
// into fragments, but the rest here, it leaves some awkward lifecycle and whatnot.
mNotificationPanel = mStatusBarWindow.findViewById(R.id.notification_panel);
mStackScroller = mStatusBarWindow.findViewById(R.id.notification_stack_scroller);
mZenController.addCallback(new ZenModeController.Callback() {
@Override
public void onZenChanged(int zen) {
updateEmptyShadeView();
}
});
mActivityLaunchAnimator = new ActivityLaunchAnimator(mStatusBarWindow,
this,
mNotificationPanel,

View File

@@ -111,6 +111,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.function.BiConsumer;
/**
@@ -4039,14 +4040,21 @@ public class NotificationStackScrollLayout extends ViewGroup
public void updateEmptyShadeView(boolean visible) {
int oldVisibility = mEmptyShadeView.willBeGone() ? GONE : mEmptyShadeView.getVisibility();
int newVisibility = visible ? VISIBLE : GONE;
if (oldVisibility != newVisibility) {
boolean changedVisibility = oldVisibility != newVisibility;
if (changedVisibility || newVisibility != GONE) {
if (newVisibility != GONE) {
int oldText = mEmptyShadeView.getTextResource();
int newText;
if (mStatusBar.areNotificationsHidden()) {
mEmptyShadeView.setText(R.string.dnd_suppressing_shade_text);
newText = R.string.dnd_suppressing_shade_text;
} else {
mEmptyShadeView.setText(R.string.empty_shade_text);
newText = R.string.empty_shade_text;
}
if (changedVisibility || !Objects.equals(oldText, newText)) {
mEmptyShadeView.setText(newText);
showFooterView(mEmptyShadeView);
}
showFooterView(mEmptyShadeView);
} else {
hideFooterView(mEmptyShadeView, true);
}

View File

@@ -140,6 +140,19 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
verify(mEmptyShadeView).setText(R.string.empty_shade_text);
}
@Test
public void updateEmptyView_noNotificationsToDndSuppressing() {
mStackScroller.setEmptyShadeView(mEmptyShadeView);
when(mEmptyShadeView.willBeGone()).thenReturn(true);
when(mBar.areNotificationsHidden()).thenReturn(false);
mStackScroller.updateEmptyShadeView(true);
verify(mEmptyShadeView).setText(R.string.empty_shade_text);
when(mBar.areNotificationsHidden()).thenReturn(true);
mStackScroller.updateEmptyShadeView(true);
verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text);
}
@Test
@UiThreadTest
public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() {