Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +16 −10 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final ContentObserver mShowWeatherObserver = new ContentObserver(null) { @Override public void onChange(boolean change) { setDateWeatherVisibility(); setWeatherVisibility(); } }; Loading Loading @@ -236,6 +236,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS updateDoubleLineClock(); setDateWeatherVisibility(); setWeatherVisibility(); mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener( mKeyguardUnlockAnimationListener); Loading Loading @@ -266,6 +267,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusArea.removeView(mDateWeatherView); addDateWeatherView(index); } setDateWeatherVisibility(); setWeatherVisibility(); } int index = mStatusArea.indexOfChild(mSmartspaceView); if (index >= 0) { Loading Loading @@ -487,16 +490,19 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } private void setDateWeatherVisibility() { if (mDateWeatherView != null || mWeatherView != null) { mUiExecutor.execute(() -> { if (mDateWeatherView != null) { mUiExecutor.execute(() -> { mDateWeatherView.setVisibility( clockHasCustomWeatherDataDisplay() ? View.GONE : View.VISIBLE); }); } } private void setWeatherVisibility() { if (mWeatherView != null) { mUiExecutor.execute(() -> { mWeatherView.setVisibility( mSmartspaceController.isWeatherEnabled() ? View.VISIBLE : View.GONE); } }); } } Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -48,8 +48,10 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockEvents; import com.android.systemui.plugins.ClockFaceConfig; import com.android.systemui.plugins.ClockFaceController; import com.android.systemui.plugins.ClockFaceEvents; import com.android.systemui.plugins.ClockTickRate; import com.android.systemui.plugins.log.LogBuffer; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.clocks.AnimatableClockView; Loading Loading @@ -185,6 +187,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { when(mClockController.getAnimations()).thenReturn(mClockAnimations); when(mClockRegistry.createCurrentClock()).thenReturn(mClockController); when(mClockEventController.getClock()).thenReturn(mClockController); when(mSmallClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false)); when(mLargeClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false)); mSliceView = new View(getContext()); when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView); Loading Loading @@ -366,6 +372,28 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { assertEquals(View.VISIBLE, mFakeWeatherView.getVisibility()); } @Test public void testChangeClockDateWeatherEnabled_SetsDateWeatherViewVisibility() { ArgumentCaptor<ClockRegistry.ClockChangeListener> listenerArgumentCaptor = ArgumentCaptor.forClass(ClockRegistry.ClockChangeListener.class); when(mSmartspaceController.isEnabled()).thenReturn(true); when(mSmartspaceController.isDateWeatherDecoupled()).thenReturn(true); when(mSmartspaceController.isWeatherEnabled()).thenReturn(true); mController.init(); mExecutor.runAllReady(); assertEquals(View.VISIBLE, mFakeDateView.getVisibility()); when(mSmallClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true)); when(mLargeClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true)); verify(mClockRegistry).registerClockChangeListener(listenerArgumentCaptor.capture()); listenerArgumentCaptor.getValue().onCurrentClockChanged(); mExecutor.runAllReady(); assertEquals(View.GONE, mFakeDateView.getVisibility()); } @Test public void testGetClock_nullClock_returnsNull() { when(mClockEventController.getClock()).thenReturn(null); Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +16 −10 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final ContentObserver mShowWeatherObserver = new ContentObserver(null) { @Override public void onChange(boolean change) { setDateWeatherVisibility(); setWeatherVisibility(); } }; Loading Loading @@ -236,6 +236,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS updateDoubleLineClock(); setDateWeatherVisibility(); setWeatherVisibility(); mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener( mKeyguardUnlockAnimationListener); Loading Loading @@ -266,6 +267,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusArea.removeView(mDateWeatherView); addDateWeatherView(index); } setDateWeatherVisibility(); setWeatherVisibility(); } int index = mStatusArea.indexOfChild(mSmartspaceView); if (index >= 0) { Loading Loading @@ -487,16 +490,19 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } private void setDateWeatherVisibility() { if (mDateWeatherView != null || mWeatherView != null) { mUiExecutor.execute(() -> { if (mDateWeatherView != null) { mUiExecutor.execute(() -> { mDateWeatherView.setVisibility( clockHasCustomWeatherDataDisplay() ? View.GONE : View.VISIBLE); }); } } private void setWeatherVisibility() { if (mWeatherView != null) { mUiExecutor.execute(() -> { mWeatherView.setVisibility( mSmartspaceController.isWeatherEnabled() ? View.VISIBLE : View.GONE); } }); } } Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -48,8 +48,10 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockEvents; import com.android.systemui.plugins.ClockFaceConfig; import com.android.systemui.plugins.ClockFaceController; import com.android.systemui.plugins.ClockFaceEvents; import com.android.systemui.plugins.ClockTickRate; import com.android.systemui.plugins.log.LogBuffer; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.clocks.AnimatableClockView; Loading Loading @@ -185,6 +187,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { when(mClockController.getAnimations()).thenReturn(mClockAnimations); when(mClockRegistry.createCurrentClock()).thenReturn(mClockController); when(mClockEventController.getClock()).thenReturn(mClockController); when(mSmallClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false)); when(mLargeClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false)); mSliceView = new View(getContext()); when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView); Loading Loading @@ -366,6 +372,28 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { assertEquals(View.VISIBLE, mFakeWeatherView.getVisibility()); } @Test public void testChangeClockDateWeatherEnabled_SetsDateWeatherViewVisibility() { ArgumentCaptor<ClockRegistry.ClockChangeListener> listenerArgumentCaptor = ArgumentCaptor.forClass(ClockRegistry.ClockChangeListener.class); when(mSmartspaceController.isEnabled()).thenReturn(true); when(mSmartspaceController.isDateWeatherDecoupled()).thenReturn(true); when(mSmartspaceController.isWeatherEnabled()).thenReturn(true); mController.init(); mExecutor.runAllReady(); assertEquals(View.VISIBLE, mFakeDateView.getVisibility()); when(mSmallClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true)); when(mLargeClockController.getConfig()) .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true)); verify(mClockRegistry).registerClockChangeListener(listenerArgumentCaptor.capture()); listenerArgumentCaptor.getValue().onCurrentClockChanged(); mExecutor.runAllReady(); assertEquals(View.GONE, mFakeDateView.getVisibility()); } @Test public void testGetClock_nullClock_returnsNull() { when(mClockEventController.getClock()).thenReturn(null); Loading