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
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -224,6 +224,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
|
||||
@Override
|
||||
public void onLocaleListChanged() {
|
||||
refreshTime();
|
||||
mKeyguardClockSwitchController.onLocaleListChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -229,12 +229,21 @@ 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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user