diff options
| author | 2023-05-05 23:18:23 +0000 | |
|---|---|---|
| committer | 2023-05-05 23:18:23 +0000 | |
| commit | 3146826cf00125304b9db58ff3d4b97de4f6c65c (patch) | |
| tree | 76e49015d1e91f6ad2c18c08dd527c30ec1037b6 | |
| parent | 5bfe44b049d9dd5b41e92db6df82078b085fae1e (diff) | |
| parent | 31f53679b17e31277e7c3386608a3ccea1ba496c (diff) | |
Merge "Fix weather clock clipped when swiping in Lockscreen" into udc-dev
5 files changed, 65 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index d8bf570954df..676f342775ef 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -179,6 +179,20 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } /** + * Set alpha directly to mView will clip clock, so we set alpha to clock face instead + */ + public void setAlpha(float alpha) { + ClockController clock = getClock(); + if (clock != null) { + clock.getLargeClock().getView().setAlpha(alpha); + clock.getSmallClock().getView().setAlpha(alpha); + } + if (mStatusArea != null) { + mStatusArea.setAlpha(alpha); + } + } + + /** * Attach the controller to the view it relates to. */ @Override diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java index d8e1eb0f0860..23136097f41f 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java @@ -135,4 +135,31 @@ public class KeyguardStatusView extends GridLayout { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Trace.endSection(); } + + /** + * Clock content will be clipped when goes beyond bounds, + * so we setAlpha for all views except clock + */ + public void setAlpha(float alpha, boolean excludeClock) { + if (!excludeClock) { + setAlpha(alpha); + return; + } + if (alpha == 1 || alpha == 0) { + setAlpha(alpha); + } + for (int i = 0; i < getChildCount(); i++) { + View child = getChildAt(i); + if (child == mStatusViewContainer) { + for (int j = 0; j < mStatusViewContainer.getChildCount(); j++) { + View innerChild = mStatusViewContainer.getChildAt(j); + if (innerChild != mClockView) { + innerChild.setAlpha(alpha); + } + } + } else { + child.setAlpha(alpha); + } + } + } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java index 794eeda86b0f..af474661a67d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java @@ -180,7 +180,8 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV */ public void setAlpha(float alpha) { if (!mKeyguardVisibilityHelper.isVisibilityAnimating()) { - mView.setAlpha(alpha); + mView.setAlpha(alpha, true); + mKeyguardClockSwitchController.setAlpha(alpha); } } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java index fb738454fc71..d8e2a3842e85 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java @@ -134,6 +134,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { private KeyguardClockSwitchController mController; private View mSliceView; + private LinearLayout mStatusArea; private FakeExecutor mExecutor; @Before @@ -195,8 +196,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mSliceView = new View(getContext()); when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView); - when(mView.findViewById(R.id.keyguard_status_area)).thenReturn( - new LinearLayout(getContext())); + mStatusArea = new LinearLayout(getContext()); + when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea); } @Test @@ -401,6 +402,15 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { assertNull(mController.getClock()); } + @Test + public void testSetAlpha_setClockAlphaForCLockFace() { + mController.onViewAttached(); + mController.setAlpha(0.5f); + verify(mLargeClockView).setAlpha(0.5f); + verify(mSmallClockView).setAlpha(0.5f); + assertEquals(0.5f, mStatusArea.getAlpha(), 0.0f); + } + private void verifyAttachment(VerificationMode times) { verify(mClockRegistry, times).registerClockChangeListener( any(ClockRegistry.ClockChangeListener.class)); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.kt index 508aea51b666..a8c281c24700 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.kt @@ -24,6 +24,8 @@ class KeyguardStatusViewTest : SysuiTestCase() { get() = keyguardStatusView.findViewById(R.id.status_view_media_container) private val statusViewContainer: ViewGroup get() = keyguardStatusView.findViewById(R.id.status_view_container) + private val clockView: ViewGroup + get() = keyguardStatusView.findViewById(R.id.keyguard_clock_container) private val childrenExcludingMedia get() = statusViewContainer.children.filter { it != mediaView } @@ -56,4 +58,12 @@ class KeyguardStatusViewTest : SysuiTestCase() { assertThat(it.translationY).isEqualTo(translationY) } } + + @Test + fun setAlphaExcludeClock() { + keyguardStatusView.setAlpha(0.5f, /* excludeClock= */true) + assertThat(statusViewContainer.alpha).isNotEqualTo(0.5f) + assertThat(mediaView.alpha).isEqualTo(0.5f) + assertThat(clockView.alpha).isNotEqualTo(0.5f) + } } |