diff options
4 files changed, 49 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index ea14b64b8b18..5c9dd5ec26e7 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -237,23 +237,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusArea = mView.findViewById(R.id.keyguard_status_area); if (mSmartspaceController.isEnabled()) { - mSmartspaceView = mSmartspaceController.buildAndConnectView(mView); View ksv = mView.findViewById(R.id.keyguard_slice_view); int ksvIndex = mStatusArea.indexOfChild(ksv); ksv.setVisibility(View.GONE); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - MATCH_PARENT, WRAP_CONTENT); - - mStatusArea.addView(mSmartspaceView, ksvIndex, lp); - int startPadding = getContext().getResources() - .getDimensionPixelSize(R.dimen.below_clock_padding_start); - int endPadding = getContext().getResources() - .getDimensionPixelSize(R.dimen.below_clock_padding_end); - mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0); - + addSmartspaceView(ksvIndex); updateClockLayout(); - mKeyguardUnlockAnimationController.setLockscreenSmartspace(mSmartspaceView); } mSecureSettings.registerContentObserverForUser( @@ -287,6 +276,30 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mKeyguardUnlockAnimationListener); } + void onLocaleListChanged() { + if (mSmartspaceController.isEnabled()) { + int index = mStatusArea.indexOfChild(mSmartspaceView); + if (index >= 0) { + mStatusArea.removeView(mSmartspaceView); + addSmartspaceView(index); + } + } + } + + private void addSmartspaceView(int index) { + mSmartspaceView = mSmartspaceController.buildAndConnectView(mView); + LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( + MATCH_PARENT, WRAP_CONTENT); + mStatusArea.addView(mSmartspaceView, index, lp); + int startPadding = getContext().getResources().getDimensionPixelSize( + R.dimen.below_clock_padding_start); + int endPadding = getContext().getResources().getDimensionPixelSize( + R.dimen.below_clock_padding_end); + mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0); + + mKeyguardUnlockAnimationController.setLockscreenSmartspace(mSmartspaceView); + } + /** * Apply dp changes on font/scale change */ diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java index 083f2fe53d17..8921780fdacf 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java @@ -224,6 +224,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV @Override public void onLocaleListChanged() { refreshTime(); + mKeyguardClockSwitchController.onLocaleListChanged(); } @Override diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java index fe9e75c4ce00..5db2cf49636c 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java @@ -229,13 +229,22 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { @Test public void testSmartspaceEnabledRemovesKeyguardStatusArea() { when(mSmartspaceController.isEnabled()).thenReturn(true); - when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView); mController.init(); assertEquals(View.GONE, mSliceView.getVisibility()); } @Test + public void onLocaleListChangedRebuildsSmartspaceView() { + when(mSmartspaceController.isEnabled()).thenReturn(true); + mController.init(); + + mController.onLocaleListChanged(); + // Should be called once on initial setup, then once again for locale change + verify(mSmartspaceController, times(2)).buildAndConnectView(mView); + } + + @Test public void testSmartspaceDisabledShowsKeyguardStatusArea() { when(mSmartspaceController.isEnabled()).thenReturn(false); mController.init(); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java index 650a5d0a8712..70025230fa83 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java @@ -25,6 +25,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; import com.android.systemui.statusbar.policy.KeyguardStateController; import org.junit.Before; @@ -117,4 +118,16 @@ public class KeyguardStatusViewControllerTest extends SysuiTestCase { verify(mKeyguardStatusView).setChildrenTranslationYExcludingMediaView(translationY); } + + @Test + public void onLocaleListChangedNotifiesClockSwitchController() { + ArgumentCaptor<ConfigurationListener> configurationListenerArgumentCaptor = + ArgumentCaptor.forClass(ConfigurationListener.class); + + mController.onViewAttached(); + verify(mConfigurationController).addCallback(configurationListenerArgumentCaptor.capture()); + + configurationListenerArgumentCaptor.getValue().onLocaleListChanged(); + verify(mKeyguardClockSwitchController).onLocaleListChanged(); + } } |