summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aaron Liu <aaronjli@google.com> 2023-02-13 17:57:10 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-02-13 17:57:10 +0000
commitdbed209ffb93044f8281ae218619b56e4af2d90a (patch)
tree5424703485e71b48fa253d4006530d1edb363bf8
parent9f085a9111ace34d4c9a2dbe4bd383be02ca212d (diff)
parent7f13362d07d3bbc978c6d1225f8cbfd1ed6ef451 (diff)
Merge "Add initial corner radius to pin button." into tm-qpr-dev
-rw-r--r--packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java7
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/NumPadAnimatorTest.kt56
2 files changed, 62 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java
index 41111e3d3c6c..b30a0e010e4b 100644
--- a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java
+++ b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java
@@ -51,6 +51,7 @@ class NumPadAnimator {
private float mStartRadius;
private float mEndRadius;
private int mHeight;
+ private boolean mInitialized;
private static final int EXPAND_ANIMATION_MS = 100;
private static final int EXPAND_COLOR_ANIMATION_MS = 50;
@@ -95,9 +96,13 @@ class NumPadAnimator {
mHeight = height;
mStartRadius = height / 2f;
mEndRadius = height / 4f;
- mBackground.setCornerRadius(mStartRadius);
mExpandAnimator.setFloatValues(mStartRadius, mEndRadius);
mContractAnimator.setFloatValues(mEndRadius, mStartRadius);
+ // Set initial corner radius.
+ if (!mInitialized) {
+ mBackground.setCornerRadius(mStartRadius);
+ mInitialized = true;
+ }
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/NumPadAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/NumPadAnimatorTest.kt
new file mode 100644
index 000000000000..9fcb9c8f1662
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/keyguard/NumPadAnimatorTest.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.keyguard
+
+import android.graphics.drawable.Drawable
+import android.graphics.drawable.GradientDrawable
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.Mockito.anyFloat
+import org.mockito.Mockito.never
+import org.mockito.Mockito.reset
+import org.mockito.Mockito.verify
+import org.mockito.MockitoAnnotations
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper
+class NumPadAnimatorTest : SysuiTestCase() {
+ @Mock lateinit var background: GradientDrawable
+ @Mock lateinit var buttonImage: Drawable
+ private lateinit var underTest: NumPadAnimator
+
+ @Before
+ fun setup() {
+ MockitoAnnotations.initMocks(this)
+ underTest = NumPadAnimator(context, background, 0, buttonImage)
+ }
+
+ @Test
+ fun testOnLayout() {
+ underTest.onLayout(100)
+ verify(background).cornerRadius = 50f
+ reset(background)
+ underTest.onLayout(100)
+ verify(background, never()).cornerRadius = anyFloat()
+ }
+}