Merge "Hide description text view if there is overlap." into udc-dev
This commit is contained in:
@@ -96,4 +96,6 @@
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/udfps_enroll_view" />
|
||||
</com.google.android.setupdesign.GlifLayout>
|
@@ -18,6 +18,7 @@
|
||||
<com.google.android.setupdesign.GlifLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/setup_wizard_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -41,10 +42,11 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:layout_gravity="center_horizontal|bottom">
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
tools:ignore="Suspicious0dp">
|
||||
|
||||
<!-- Animation res MUST be set in code -->
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
@@ -59,6 +61,9 @@
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
app:lottie_speed=".85" />
|
||||
|
||||
<include layout="@layout/udfps_enroll_view" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
|
@@ -261,6 +261,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
int rotation = getApplicationContext().getDisplay().getRotation();
|
||||
final GlifLayout layout = (GlifLayout) getLayoutInflater().inflate(
|
||||
R.layout.udfps_enroll_enrolling, null, false);
|
||||
final UdfpsEnrollView udfpsEnrollView = layout.findViewById(R.id.udfps_animation_view);
|
||||
updateUdfpsEnrollView(udfpsEnrollView, props.get(0));
|
||||
switch (rotation) {
|
||||
case Surface.ROTATION_90:
|
||||
final LinearLayout layoutContainer = layout.findViewById(
|
||||
@@ -276,66 +278,52 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
? 0 : (int) getResources().getDimension(
|
||||
R.dimen.rotation_90_enroll_padding_end), 0);
|
||||
layoutContainer.setLayoutParams(lp);
|
||||
if (FeatureFlagUtils.isEnabled(getApplicationContext(),
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS)) {
|
||||
final UdfpsEnrollView udfpsEnrollView = addUdfpsEnrollView(props.get(0));
|
||||
layout.addView(udfpsEnrollView);
|
||||
setOnHoverListener(true, layout, udfpsEnrollView);
|
||||
}
|
||||
|
||||
setOnHoverListener(true, layout, udfpsEnrollView);
|
||||
setContentView(layout, lp);
|
||||
break;
|
||||
|
||||
case Surface.ROTATION_0:
|
||||
case Surface.ROTATION_180:
|
||||
if (FeatureFlagUtils.isEnabled(getApplicationContext(),
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS)) {
|
||||
final UdfpsEnrollView udfpsEnrollView = addUdfpsEnrollView(props.get(0));
|
||||
// In the portrait mode, set layout_container's height 0, so it's
|
||||
// always shown at the bottom of the screen.
|
||||
// Add udfps enroll view into layout_container instead of
|
||||
// udfps_enroll_enrolling, so that when the content is too long to
|
||||
// make udfps_enroll_enrolling larger than the screen, udfps enroll
|
||||
// view could still be set to right position by setting bottom margin to
|
||||
// its parent view (layout_container) because it's always at the
|
||||
// bottom of the screen.
|
||||
final FrameLayout portraitLayoutContainer = layout.findViewById(
|
||||
R.id.layout_container);
|
||||
final ViewGroup.LayoutParams containerLp =
|
||||
portraitLayoutContainer.getLayoutParams();
|
||||
containerLp.height = 0;
|
||||
// In the portrait mode, layout_container's height is 0, so it's
|
||||
// always shown at the bottom of the screen.
|
||||
final FrameLayout portraitLayoutContainer = layout.findViewById(
|
||||
R.id.layout_container);
|
||||
|
||||
// In the portrait mode, the title and lottie animation view may
|
||||
// overlap when title needs three lines, so adding some paddings
|
||||
// between them, and adjusting the fp progress view here accordingly.
|
||||
final int layoutLottieAnimationPadding = (int) getResources()
|
||||
.getDimension(R.dimen.udfps_lottie_padding_top);
|
||||
portraitLayoutContainer.setPadding(0,
|
||||
layoutLottieAnimationPadding, 0, 0);
|
||||
final ImageView progressView = udfpsEnrollView.findViewById(
|
||||
R.id.udfps_enroll_animation_fp_progress_view);
|
||||
progressView.setPadding(0, -(layoutLottieAnimationPadding),
|
||||
0, layoutLottieAnimationPadding);
|
||||
final ImageView fingerprintView = udfpsEnrollView.findViewById(
|
||||
R.id.udfps_enroll_animation_fp_view);
|
||||
fingerprintView.setPadding(0, -layoutLottieAnimationPadding,
|
||||
0, layoutLottieAnimationPadding);
|
||||
// In the portrait mode, the title and lottie animation view may
|
||||
// overlap when title needs three lines, so adding some paddings
|
||||
// between them, and adjusting the fp progress view here accordingly.
|
||||
final int layoutLottieAnimationPadding = (int) getResources()
|
||||
.getDimension(R.dimen.udfps_lottie_padding_top);
|
||||
portraitLayoutContainer.setPadding(0,
|
||||
layoutLottieAnimationPadding, 0, 0);
|
||||
final ImageView progressView = udfpsEnrollView.findViewById(
|
||||
R.id.udfps_enroll_animation_fp_progress_view);
|
||||
progressView.setPadding(0, -(layoutLottieAnimationPadding),
|
||||
0, layoutLottieAnimationPadding);
|
||||
final ImageView fingerprintView = udfpsEnrollView.findViewById(
|
||||
R.id.udfps_enroll_animation_fp_view);
|
||||
fingerprintView.setPadding(0, -layoutLottieAnimationPadding,
|
||||
0, layoutLottieAnimationPadding);
|
||||
|
||||
portraitLayoutContainer.addView(udfpsEnrollView);
|
||||
setOnHoverListener(false, layout, udfpsEnrollView);
|
||||
}
|
||||
// TODO(b/260970216) Instead of hiding the description text view, we should
|
||||
// make the header view scrollable if the text is too long.
|
||||
// If description text view has overlap with udfps progress view, hide it.
|
||||
View view = layout.getDescriptionTextView();
|
||||
layout.getViewTreeObserver().addOnDrawListener(() -> {
|
||||
if (view.getVisibility() == View.VISIBLE
|
||||
&& hasOverlap(view, udfpsEnrollView)) {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
setOnHoverListener(false, layout, udfpsEnrollView);
|
||||
setContentView(layout);
|
||||
break;
|
||||
|
||||
case Surface.ROTATION_270:
|
||||
default:
|
||||
if (FeatureFlagUtils.isEnabled(getApplicationContext(),
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS)) {
|
||||
final UdfpsEnrollView udfpsEnrollView = addUdfpsEnrollView(props.get(0));
|
||||
layout.addView(udfpsEnrollView);
|
||||
setOnHoverListener(true, layout, udfpsEnrollView);
|
||||
}
|
||||
|
||||
setOnHoverListener(true, layout, udfpsEnrollView);
|
||||
setContentView(layout);
|
||||
break;
|
||||
}
|
||||
@@ -1235,10 +1223,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
}
|
||||
}
|
||||
|
||||
private UdfpsEnrollView addUdfpsEnrollView(FingerprintSensorPropertiesInternal udfpsProps) {
|
||||
UdfpsEnrollView udfpsEnrollView = (UdfpsEnrollView) getLayoutInflater().inflate(
|
||||
R.layout.udfps_enroll_view, null, false);
|
||||
|
||||
private UdfpsEnrollView updateUdfpsEnrollView(UdfpsEnrollView udfpsEnrollView,
|
||||
FingerprintSensorPropertiesInternal udfpsProps) {
|
||||
DisplayInfo displayInfo = new DisplayInfo();
|
||||
getDisplay().getDisplayInfo(displayInfo);
|
||||
mScaleFactor = mUdfpsUtils.getScaleFactor(displayInfo);
|
||||
@@ -1305,6 +1291,24 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
: R.id.sud_layout_content).setOnHoverListener(onHoverListener);
|
||||
}
|
||||
|
||||
|
||||
@VisibleForTesting boolean hasOverlap(View view1, View view2) {
|
||||
int[] firstPosition = new int[2];
|
||||
int[] secondPosition = new int[2];
|
||||
|
||||
view1.getLocationOnScreen(firstPosition);
|
||||
view2.getLocationOnScreen(secondPosition);
|
||||
|
||||
// Rect constructor parameters: left, top, right, bottom
|
||||
Rect rectView1 = new Rect(firstPosition[0], firstPosition[1],
|
||||
firstPosition[0] + view1.getMeasuredWidth(),
|
||||
firstPosition[1] + view1.getMeasuredHeight());
|
||||
Rect rectView2 = new Rect(secondPosition[0], secondPosition[1],
|
||||
secondPosition[0] + view2.getMeasuredWidth(),
|
||||
secondPosition[1] + view2.getMeasuredHeight());
|
||||
return rectView1.intersect(rectView2);
|
||||
}
|
||||
|
||||
public static class IconTouchDialog extends InstrumentedDialogFragment {
|
||||
|
||||
@Override
|
||||
|
@@ -161,22 +161,20 @@ public class UdfpsEnrollView extends FrameLayout implements UdfpsEnrollHelper.Li
|
||||
MarginLayoutParams marginLayoutParams = (MarginLayoutParams) getLayoutParams();
|
||||
FrameLayout.LayoutParams params = (LayoutParams) getLayoutParams();
|
||||
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
|
||||
parentView.getViewTreeObserver().addOnDrawListener(() -> {
|
||||
final int[] coords = parentView.getLocationOnScreen();
|
||||
final int parentLeft = coords[0];
|
||||
final int parentTop = coords[1];
|
||||
final int parentRight = parentLeft + parentView.getWidth();
|
||||
params.gravity = Gravity.RIGHT | Gravity.TOP;
|
||||
final int rightMargin = parentRight - rotatedBounds.right - getPaddingX();
|
||||
final int topMargin = rotatedBounds.top - parentTop - getPaddingY();
|
||||
if (marginLayoutParams.rightMargin == rightMargin
|
||||
&& marginLayoutParams.topMargin == topMargin) {
|
||||
return;
|
||||
}
|
||||
marginLayoutParams.rightMargin = rightMargin;
|
||||
marginLayoutParams.topMargin = topMargin;
|
||||
setLayoutParams(params);
|
||||
});
|
||||
final int[] coords = parentView.getLocationOnScreen();
|
||||
final int parentLeft = coords[0];
|
||||
final int parentTop = coords[1];
|
||||
final int parentRight = parentLeft + parentView.getWidth();
|
||||
params.gravity = Gravity.RIGHT | Gravity.TOP;
|
||||
final int rightMargin = parentRight - rotatedBounds.right - getPaddingX();
|
||||
final int topMargin = rotatedBounds.top - parentTop - getPaddingY();
|
||||
if (marginLayoutParams.rightMargin == rightMargin
|
||||
&& marginLayoutParams.topMargin == topMargin) {
|
||||
return;
|
||||
}
|
||||
marginLayoutParams.rightMargin = rightMargin;
|
||||
marginLayoutParams.topMargin = topMargin;
|
||||
setLayoutParams(params);
|
||||
} else {
|
||||
final int[] coords = parentView.getLocationOnScreen();
|
||||
final int parentLeft = coords[0];
|
||||
|
@@ -53,7 +53,6 @@ import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Vibrator;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
@@ -203,8 +202,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void fingerprintUdfpsOverlayEnrollment_showOverlayPortrait() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
when(mMockDisplay.getRotation()).thenReturn(Surface.ROTATION_0);
|
||||
|
||||
@@ -216,8 +213,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void fingerprintUdfpsOverlayEnrollment_showOverlayLandscape() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
when(mMockDisplay.getRotation()).thenReturn(Surface.ROTATION_90);
|
||||
|
||||
@@ -229,8 +224,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void fingerprintUdfpsOverlayEnrollment_usesCorrectProgressBarFillColor() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
final TypedArray ta = mActivity.obtainStyledAttributes(null,
|
||||
R.styleable.BiometricsEnrollView, R.attr.biometricsEnrollStyle,
|
||||
@@ -250,9 +243,7 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void fingerprintUdfpsOverlayEnrollment_checkViewOverlapPortrait() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
when(mMockDisplay.getRotation()).thenReturn(Surface.ROTATION_90);
|
||||
when(mMockDisplay.getRotation()).thenReturn(Surface.ROTATION_0);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
|
||||
final GlifLayout defaultLayout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||
@@ -294,9 +285,9 @@ public class FingerprintEnrollEnrollingTest {
|
||||
udfpsEnrollView.getViewTreeObserver().addOnDrawListener(() -> {
|
||||
udfpsEnrollView.getLocationOnScreen(udfpsEnrollViewPosition);
|
||||
rectUdfpsEnrollView.set(new Rect(udfpsEnrollViewPosition[0],
|
||||
udfpsEnrollViewPosition[1], udfpsEnrollViewPosition[0]
|
||||
+ udfpsEnrollView.getWidth(), udfpsEnrollViewPosition[1]
|
||||
+ udfpsEnrollView.getHeight()));
|
||||
udfpsEnrollViewPosition[1], udfpsEnrollViewPosition[0]
|
||||
+ udfpsEnrollView.getWidth(), udfpsEnrollViewPosition[1]
|
||||
+ udfpsEnrollView.getHeight()));
|
||||
});
|
||||
|
||||
lottieAnimationContainer.getViewTreeObserver().addOnDrawListener(() -> {
|
||||
@@ -320,10 +311,36 @@ public class FingerprintEnrollEnrollingTest {
|
||||
.intersect(rectUdfpsEnrollView.get())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fingerprintUdfpsOverlayEnrollment_descriptionViewGoneWithOverlap() {
|
||||
initializeActivityWithoutCreate(TYPE_UDFPS_OPTICAL);
|
||||
doReturn(true).when(mActivity).hasOverlap(any(), any());
|
||||
when(mMockDisplay.getRotation()).thenReturn(Surface.ROTATION_0);
|
||||
createActivity();
|
||||
|
||||
final GlifLayout defaultLayout = spy(mActivity.findViewById(R.id.setup_wizard_layout));
|
||||
final TextView descriptionTextView = defaultLayout.getDescriptionTextView();
|
||||
|
||||
defaultLayout.getViewTreeObserver().dispatchOnDraw();
|
||||
assertThat(descriptionTextView.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fingerprintUdfpsOverlayEnrollment_descriptionViewVisibleWithoutOverlap() {
|
||||
initializeActivityWithoutCreate(TYPE_UDFPS_OPTICAL);
|
||||
doReturn(false).when(mActivity).hasOverlap(any(), any());
|
||||
when(mMockDisplay.getRotation()).thenReturn(Surface.ROTATION_0);
|
||||
createActivity();
|
||||
|
||||
final GlifLayout defaultLayout = spy(mActivity.findViewById(R.id.setup_wizard_layout));
|
||||
final TextView descriptionTextView = defaultLayout.getDescriptionTextView();
|
||||
|
||||
defaultLayout.getViewTreeObserver().dispatchOnDraw();
|
||||
assertThat(descriptionTextView.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forwardEnrollProgressEvents() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
|
||||
EnrollListener listener = new EnrollListener(mActivity);
|
||||
@@ -337,8 +354,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void forwardEnrollHelpEvents() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
|
||||
EnrollListener listener = new EnrollListener(mActivity);
|
||||
@@ -352,8 +367,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void forwardEnrollAcquiredEvents() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
|
||||
EnrollListener listener = new EnrollListener(mActivity);
|
||||
@@ -368,8 +381,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void forwardEnrollPointerDownEvents() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
|
||||
EnrollListener listener = new EnrollListener(mActivity);
|
||||
@@ -383,8 +394,6 @@ public class FingerprintEnrollEnrollingTest {
|
||||
|
||||
@Test
|
||||
public void forwardEnrollPointerUpEvents() {
|
||||
FeatureFlagUtils.setEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, true);
|
||||
initializeActivityFor(TYPE_UDFPS_OPTICAL);
|
||||
|
||||
EnrollListener listener = new EnrollListener(mActivity);
|
||||
|
Reference in New Issue
Block a user