Merge "Simplify KeyguardBottomAreaView reinflation logic" into qt-dev

This commit is contained in:
Lucas Dupin
2019-04-29 22:12:55 +00:00
committed by Android (Google) Code Review
6 changed files with 13 additions and 49 deletions

View File

@@ -143,11 +143,6 @@ public class KeyguardIndicationController implements StateListener,
StatusBarStateController statusBarStateController, StatusBarStateController statusBarStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor) { KeyguardUpdateMonitor keyguardUpdateMonitor) {
mContext = context; mContext = context;
mIndicationArea = indicationArea;
mTextView = indicationArea.findViewById(R.id.keyguard_indication_text);
mInitialTextColorState = mTextView != null ?
mTextView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
mDisclosure = indicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure);
mLockIcon = lockIcon; mLockIcon = lockIcon;
mShadeController = shadeController; mShadeController = shadeController;
mAccessibilityController = accessibilityController; mAccessibilityController = accessibilityController;
@@ -172,6 +167,7 @@ public class KeyguardIndicationController implements StateListener,
mDevicePolicyManager = (DevicePolicyManager) context.getSystemService( mDevicePolicyManager = (DevicePolicyManager) context.getSystemService(
Context.DEVICE_POLICY_SERVICE); Context.DEVICE_POLICY_SERVICE);
setIndicationArea(indicationArea);
updateDisclosure(); updateDisclosure();
mKeyguardUpdateMonitor.registerCallback(getKeyguardCallback()); mKeyguardUpdateMonitor.registerCallback(getKeyguardCallback());
@@ -180,17 +176,13 @@ public class KeyguardIndicationController implements StateListener,
mUnlockMethodCache.addListener(this); mUnlockMethodCache.addListener(this);
} }
/** public void setIndicationArea(ViewGroup indicationArea) {
* Used by {@link com.android.systemui.statusbar.phone.StatusBar} to give the indication mIndicationArea = indicationArea;
* controller a chance to unregister itself as a receiver. mTextView = indicationArea.findViewById(R.id.keyguard_indication_text);
* mInitialTextColorState = mTextView != null ?
* //TODO: This can probably be converted to a fragment and not have to be manually recreated mTextView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
*/ mDisclosure = indicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure);
public void destroy() { updateIndication(false /* animate */);
mKeyguardUpdateMonitor.removeCallback(mTickReceiver);
mKeyguardUpdateMonitor.removeCallback(getKeyguardCallback());
mStatusBarStateController.removeCallback(this);
mUnlockMethodCache.removeListener(this);
} }
private boolean handleLockLongClick(View view) { private boolean handleLockLongClick(View view) {

View File

@@ -133,7 +133,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private FlashlightController mFlashlightController; private FlashlightController mFlashlightController;
private PreviewInflater mPreviewInflater; private PreviewInflater mPreviewInflater;
private KeyguardIndicationController mIndicationController;
private AccessibilityController mAccessibilityController; private AccessibilityController mAccessibilityController;
private StatusBar mStatusBar; private StatusBar mStatusBar;
private KeyguardAffordanceHelper mAffordanceHelper; private KeyguardAffordanceHelper mAffordanceHelper;
@@ -221,7 +220,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
}; };
public void initFrom(KeyguardBottomAreaView oldBottomArea) { public void initFrom(KeyguardBottomAreaView oldBottomArea) {
setKeyguardIndicationController(oldBottomArea.mIndicationController);
setStatusBar(oldBottomArea.mStatusBar); setStatusBar(oldBottomArea.mStatusBar);
} }
@@ -707,15 +705,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
} }
}; };
public void setKeyguardIndicationController(
KeyguardIndicationController keyguardIndicationController) {
mIndicationController = keyguardIndicationController;
}
public void showTransientIndication(int id) {
mIndicationController.showTransientIndication(id);
}
public void updateLeftAffordance() { public void updateLeftAffordance() {
updateLeftAffordanceIcon(); updateLeftAffordanceIcon();
updateLeftPreview(); updateLeftPreview();

View File

@@ -337,6 +337,7 @@ public class NotificationPanelView extends PanelView implements
* work, check the current id with the cached id. * work, check the current id with the cached id.
*/ */
private int mThemeResId; private int mThemeResId;
private KeyguardIndicationController mKeyguardIndicationController;
@Inject @Inject
public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs, public NotificationPanelView(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
@@ -516,6 +517,7 @@ public class NotificationPanelView extends PanelView implements
mKeyguardBottomArea.initFrom(oldBottomArea); mKeyguardBottomArea.initFrom(oldBottomArea);
addView(mKeyguardBottomArea, index); addView(mKeyguardBottomArea, index);
initBottomArea(); initBottomArea();
mKeyguardIndicationController.setIndicationArea(mKeyguardBottomArea);
onDozeAmountChanged(mStatusBarStateController.getDozeAmount(), onDozeAmountChanged(mStatusBarStateController.getDozeAmount(),
mStatusBarStateController.getInterpolatedDozeAmount()); mStatusBarStateController.getInterpolatedDozeAmount());
@@ -535,7 +537,8 @@ public class NotificationPanelView extends PanelView implements
} }
public void setKeyguardIndicationController(KeyguardIndicationController indicationController) { public void setKeyguardIndicationController(KeyguardIndicationController indicationController) {
mKeyguardBottomArea.setKeyguardIndicationController(indicationController); mKeyguardIndicationController = indicationController;
mKeyguardIndicationController.setIndicationArea(mKeyguardBottomArea);
} }
@Override @Override
@@ -3045,7 +3048,7 @@ public class NotificationPanelView extends PanelView implements
} }
public void showTransientIndication(int id) { public void showTransientIndication(int id) {
mKeyguardBottomArea.showTransientIndication(id); mKeyguardIndicationController.showTransientIndication(id);
} }
@Override @Override

View File

@@ -1166,18 +1166,6 @@ public class StatusBar extends SystemUI implements DemoMode,
@Override @Override
public void onThemeChanged() { public void onThemeChanged() {
// Recreate Indication controller because internal references changed
if (mKeyguardIndicationController != null) {
mKeyguardIndicationController.destroy();
}
mKeyguardIndicationController =
SystemUIFactory.getInstance().createKeyguardIndicationController(mContext,
mStatusBarWindow.findViewById(R.id.keyguard_indication_area),
mStatusBarWindow.findViewById(R.id.lock_icon));
mNotificationPanel.setKeyguardIndicationController(mKeyguardIndicationController);
mKeyguardIndicationController
.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
mKeyguardIndicationController.setVisible(mState == StatusBarState.KEYGUARD);
if (mStatusBarKeyguardViewManager != null) { if (mStatusBarKeyguardViewManager != null) {
mStatusBarKeyguardViewManager.onThemeChanged(); mStatusBarKeyguardViewManager.onThemeChanged();
} }

View File

@@ -284,10 +284,5 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
verify(mUnlockMethodCache).addListener(eq(mController)); verify(mUnlockMethodCache).addListener(eq(mController));
verify(mStatusBarStateController).addCallback(eq(mController)); verify(mStatusBarStateController).addCallback(eq(mController));
verify(mKeyguardUpdateMonitor, times(2)).registerCallback(any()); verify(mKeyguardUpdateMonitor, times(2)).registerCallback(any());
mController.destroy();
verify(mUnlockMethodCache).removeListener(eq(mController));
verify(mStatusBarStateController).removeCallback(eq(mController));
verify(mKeyguardUpdateMonitor, times(2)).removeCallback(any());
} }
} }

View File

@@ -22,8 +22,6 @@ class KeyguardBottomAreaTest : SysuiTestCase() {
@Mock @Mock
private lateinit var mStatusBar: StatusBar private lateinit var mStatusBar: StatusBar
@Mock
private lateinit var mKeyguardIndicationController: KeyguardIndicationController
private lateinit var mKeyguardBottomArea: KeyguardBottomAreaView private lateinit var mKeyguardBottomArea: KeyguardBottomAreaView
@Before @Before
@@ -32,7 +30,6 @@ class KeyguardBottomAreaTest : SysuiTestCase() {
mKeyguardBottomArea = LayoutInflater.from(mContext).inflate( mKeyguardBottomArea = LayoutInflater.from(mContext).inflate(
R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView
mKeyguardBottomArea.setStatusBar(mStatusBar) mKeyguardBottomArea.setStatusBar(mStatusBar)
mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController)
} }
@Test @Test