From 97f3a42dc5ce1f5e17bf09cc21515b5dd1b338ba Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Wed, 8 Jun 2022 10:24:01 -0400 Subject: [PATCH] Update view when locale changes Updating the locale would leave lockscreen smartspace showing the old locale. Need to force a rebuild of the view to reflect the update. Fixes: 225843613 Test: atest KeyguardStatusViewControllerTest KeyguardClockSwitchControllerTest Change-Id: If37e138925c7ea8cb13dad4fa2f687215d1a7ff9 --- .../KeyguardClockSwitchController.java | 37 +++++++++++++------ .../KeyguardStatusViewController.java | 1 + .../KeyguardClockSwitchControllerTest.java | 11 +++++- .../KeyguardStatusViewControllerTest.java | 13 +++++++ 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 ea14b64b8b182..5c9dd5ec26e76 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= 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 083f2fe53d179..8921780fdacfc 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 configurationListenerArgumentCaptor = + ArgumentCaptor.forClass(ConfigurationListener.class); + + mController.onViewAttached(); + verify(mConfigurationController).addCallback(configurationListenerArgumentCaptor.capture()); + + configurationListenerArgumentCaptor.getValue().onLocaleListChanged(); + verify(mKeyguardClockSwitchController).onLocaleListChanged(); + } }