Merge "Fix overlap between operator name and heads-up notification"
This commit is contained in:
@@ -49,11 +49,6 @@
|
||||
android:paddingEnd="@dimen/status_bar_padding_end"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<ViewStub
|
||||
android:id="@+id/operator_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout="@layout/operator_name" />
|
||||
<FrameLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="0dp"
|
||||
@@ -70,6 +65,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:clipChildren="false"
|
||||
>
|
||||
<ViewStub
|
||||
android:id="@+id/operator_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout="@layout/operator_name" />
|
||||
|
||||
<com.android.systemui.statusbar.policy.Clock
|
||||
android:id="@+id/clock"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -48,6 +48,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
private final NotificationStackScrollLayout mStackScroller;
|
||||
private final HeadsUpStatusBarView mHeadsUpStatusBarView;
|
||||
private final View mClockView;
|
||||
private final View mOperatorNameView;
|
||||
private final DarkIconDispatcher mDarkIconDispatcher;
|
||||
private final NotificationPanelView mPanelView;
|
||||
private final Consumer<ExpandableNotificationRow>
|
||||
@@ -65,8 +66,10 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener =
|
||||
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
|
||||
-> updatePanelTranslation();
|
||||
private boolean mAnimationsEnabled = true;
|
||||
Point mPoint;
|
||||
|
||||
|
||||
public HeadsUpAppearanceController(
|
||||
NotificationIconAreaController notificationIconAreaController,
|
||||
HeadsUpManagerPhone headsUpManager,
|
||||
@@ -75,7 +78,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
statusbarView.findViewById(R.id.heads_up_status_bar_view),
|
||||
statusbarView.findViewById(R.id.notification_stack_scroller),
|
||||
statusbarView.findViewById(R.id.notification_panel),
|
||||
statusbarView.findViewById(R.id.clock));
|
||||
statusbarView.findViewById(R.id.clock),
|
||||
statusbarView.findViewById(R.id.operator_name_frame));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -85,7 +89,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
HeadsUpStatusBarView headsUpStatusBarView,
|
||||
NotificationStackScrollLayout stackScroller,
|
||||
NotificationPanelView panelView,
|
||||
View clockView) {
|
||||
View clockView,
|
||||
View operatorNameView) {
|
||||
mNotificationIconAreaController = notificationIconAreaController;
|
||||
mHeadsUpManager = headsUpManager;
|
||||
mHeadsUpManager.addListener(this);
|
||||
@@ -101,6 +106,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener);
|
||||
mStackScroller.setHeadsUpAppearanceController(this);
|
||||
mClockView = clockView;
|
||||
mOperatorNameView = operatorNameView;
|
||||
mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class);
|
||||
mDarkIconDispatcher.addDarkReceiver(this);
|
||||
|
||||
@@ -230,20 +236,52 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
mShown = isShown;
|
||||
if (isShown) {
|
||||
mHeadsUpStatusBarView.setVisibility(View.VISIBLE);
|
||||
CrossFadeHelper.fadeIn(mHeadsUpStatusBarView, CONTENT_FADE_DURATION /* duration */,
|
||||
CONTENT_FADE_DELAY /* delay */);
|
||||
CrossFadeHelper.fadeOut(mClockView, CONTENT_FADE_DURATION/* duration */,
|
||||
0 /* delay */, () -> mClockView.setVisibility(View.INVISIBLE));
|
||||
show(mHeadsUpStatusBarView);
|
||||
hide(mClockView, View.INVISIBLE);
|
||||
if (mOperatorNameView != null) {
|
||||
hide(mOperatorNameView, View.INVISIBLE);
|
||||
}
|
||||
} else {
|
||||
CrossFadeHelper.fadeIn(mClockView, CONTENT_FADE_DURATION /* duration */,
|
||||
CONTENT_FADE_DELAY /* delay */);
|
||||
CrossFadeHelper.fadeOut(mHeadsUpStatusBarView, CONTENT_FADE_DURATION/* duration */,
|
||||
0 /* delay */, () -> mHeadsUpStatusBarView.setVisibility(View.GONE));
|
||||
|
||||
show(mClockView);
|
||||
if (mOperatorNameView != null) {
|
||||
show(mOperatorNameView);
|
||||
}
|
||||
hide(mHeadsUpStatusBarView, View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the view and sets the state to endState when finished.
|
||||
*
|
||||
* @param view The view to hide.
|
||||
* @param endState One of {@link View#INVISIBLE} or {@link View#GONE}.
|
||||
* @see View#setVisibility(int)
|
||||
*
|
||||
*/
|
||||
private void hide(View view, int endState) {
|
||||
if (mAnimationsEnabled) {
|
||||
CrossFadeHelper.fadeOut(view, CONTENT_FADE_DURATION /* duration */,
|
||||
0 /* delay */, () -> view.setVisibility(endState));
|
||||
} else {
|
||||
view.setVisibility(endState);
|
||||
}
|
||||
}
|
||||
|
||||
private void show(View view) {
|
||||
if (mAnimationsEnabled) {
|
||||
CrossFadeHelper.fadeIn(view, CONTENT_FADE_DURATION /* duration */,
|
||||
CONTENT_FADE_DELAY /* delay */);
|
||||
} else {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setAnimationsEnabled(boolean enabled) {
|
||||
mAnimationsEnabled = enabled;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean isShown() {
|
||||
return mShown;
|
||||
|
||||
@@ -54,6 +54,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
||||
private ExpandableNotificationRow mFirst;
|
||||
private HeadsUpStatusBarView mHeadsUpStatusBarView;
|
||||
private HeadsUpManagerPhone mHeadsUpManager;
|
||||
private View mOperatorNameView;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -63,13 +64,15 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
||||
mHeadsUpStatusBarView = new HeadsUpStatusBarView(mContext, mock(View.class),
|
||||
mock(TextView.class));
|
||||
mHeadsUpManager = mock(HeadsUpManagerPhone.class);
|
||||
mOperatorNameView = new View(mContext);
|
||||
mHeadsUpAppearanceController = new HeadsUpAppearanceController(
|
||||
mock(NotificationIconAreaController.class),
|
||||
mHeadsUpManager,
|
||||
mHeadsUpStatusBarView,
|
||||
mStackScroller,
|
||||
mPanelView,
|
||||
new View(mContext));
|
||||
new View(mContext),
|
||||
mOperatorNameView);
|
||||
mHeadsUpAppearanceController.setExpandedHeight(0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -115,6 +118,22 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
||||
Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperatorNameViewUpdated() {
|
||||
mHeadsUpAppearanceController.setAnimationsEnabled(false);
|
||||
|
||||
mFirst.setPinned(true);
|
||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
||||
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
|
||||
mHeadsUpAppearanceController.onHeadsUpPinned(mFirst);
|
||||
Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility());
|
||||
|
||||
mFirst.setPinned(false);
|
||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
||||
mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst);
|
||||
Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderReadFromOldController() {
|
||||
mHeadsUpAppearanceController.setExpandedHeight(1.0f, 1.0f);
|
||||
@@ -125,6 +144,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
||||
mHeadsUpStatusBarView,
|
||||
mStackScroller,
|
||||
mPanelView,
|
||||
new View(mContext),
|
||||
new View(mContext));
|
||||
newController.readFrom(mHeadsUpAppearanceController);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user