Loading packages/SystemUI/res/layout/status_bar.xml +6 −5 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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" Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +49 −11 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -62,8 +63,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, Loading @@ -72,7 +75,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 Loading @@ -82,7 +86,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); Loading @@ -98,6 +103,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener); mStackScroller.setHeadsUpAppearanceController(this); mClockView = clockView; mOperatorNameView = operatorNameView; mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class); mDarkIconDispatcher.addDarkReceiver(this); } Loading Loading @@ -213,18 +219,50 @@ 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 Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { private ExpandableNotificationRow mFirst; private HeadsUpStatusBarView mHeadsUpStatusBarView; private HeadsUpManagerPhone mHeadsUpManager; private View mOperatorNameView; @Before public void setUp() throws Exception { Loading @@ -70,13 +71,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); } Loading Loading @@ -122,6 +125,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 testDestroy() { reset(mHeadsUpManager); Loading Loading
packages/SystemUI/res/layout/status_bar.xml +6 −5 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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" Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +49 −11 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -62,8 +63,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, Loading @@ -72,7 +75,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 Loading @@ -82,7 +86,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); Loading @@ -98,6 +103,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener); mStackScroller.setHeadsUpAppearanceController(this); mClockView = clockView; mOperatorNameView = operatorNameView; mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class); mDarkIconDispatcher.addDarkReceiver(this); } Loading Loading @@ -213,18 +219,50 @@ 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 Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { private ExpandableNotificationRow mFirst; private HeadsUpStatusBarView mHeadsUpStatusBarView; private HeadsUpManagerPhone mHeadsUpManager; private View mOperatorNameView; @Before public void setUp() throws Exception { Loading @@ -70,13 +71,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); } Loading Loading @@ -122,6 +125,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 testDestroy() { reset(mHeadsUpManager); Loading