Merge "Add accessibility for Face"
This commit is contained in:
46
res/layout/face_enroll_accessibility_toggle.xml
Normal file
46
res/layout/face_enroll_accessibility_toggle.xml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2018 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingStart="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/title"/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/toggle"
|
||||||
|
android:checked="true"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -18,6 +18,7 @@
|
|||||||
<com.google.android.setupdesign.GlifLayout
|
<com.google.android.setupdesign.GlifLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:FaceEnrollAccessibilitySwitch="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
style="?attr/face_layout_theme"
|
style="?attr/face_layout_theme"
|
||||||
android:id="@+id/setup_wizard_layout"
|
android:id="@+id/setup_wizard_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -59,6 +60,41 @@
|
|||||||
|
|
||||||
</com.google.android.setupdesign.view.FillContentLayout>
|
</com.google.android.setupdesign.view.FillContentLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/accessibility_button"
|
||||||
|
style="@style/SuwGlifButton.Secondary"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/security_settings_face_enroll_introduction_accessibility" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:id="@+id/accessibility_layout"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="invisible">
|
||||||
|
|
||||||
|
<com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
|
||||||
|
android:id="@+id/toggle_diversity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_diversity"/>
|
||||||
|
|
||||||
|
<com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
|
||||||
|
android:id="@+id/toggle_vision"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_vision"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.setupdesign.GlifLayout>
|
</com.google.android.setupdesign.GlifLayout>
|
||||||
|
@@ -146,6 +146,11 @@
|
|||||||
<attr name="thickness" format="dimension" />
|
<attr name="thickness" format="dimension" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- For Face enroll accessibility toggle -->
|
||||||
|
<declare-styleable name="FaceEnrollAccessibilityToggle">
|
||||||
|
<attr name="messageText" format="reference" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
<!-- For TwoStatesButtonPreference -->
|
<!-- For TwoStatesButtonPreference -->
|
||||||
<declare-styleable name="TwoStateButtonPreference">
|
<declare-styleable name="TwoStateButtonPreference">
|
||||||
<attr name="textOn" format="reference" />
|
<attr name="textOn" format="reference" />
|
||||||
|
@@ -877,6 +877,12 @@
|
|||||||
<string name="security_settings_face_preference_summary_none">Tap to set up face authentication</string>
|
<string name="security_settings_face_preference_summary_none">Tap to set up face authentication</string>
|
||||||
<!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=32] -->
|
<!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=32] -->
|
||||||
<string name="security_settings_face_preference_title">Face authentication</string>
|
<string name="security_settings_face_preference_title">Face authentication</string>
|
||||||
|
<!-- Button shown which shows accessibility toggles for face enrollment when clicked. [CHAR LIMIT=32] -->
|
||||||
|
<string name="security_settings_face_enroll_introduction_accessibility">Use accessibility setup</string>
|
||||||
|
<!-- Message shown for a toggle which when disabled, allows the user to enroll using a simpler flow for accessibility [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="security_settings_face_enroll_introduction_accessibility_diversity"></string>
|
||||||
|
<!-- Message shown for a toggle which when disabled, allows the user to enroll using a simpler flow for accessibility [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="security_settings_face_enroll_introduction_accessibility_vision"></string>
|
||||||
<!-- Button text to cancel enrollment from the introduction [CHAR LIMIT=22] -->
|
<!-- Button text to cancel enrollment from the introduction [CHAR LIMIT=22] -->
|
||||||
<string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
|
<string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
|
||||||
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
|
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
|
||||||
|
@@ -40,8 +40,10 @@ import com.google.android.setupdesign.GlifLayout;
|
|||||||
*/
|
*/
|
||||||
public abstract class BiometricEnrollBase extends InstrumentedActivity
|
public abstract class BiometricEnrollBase extends InstrumentedActivity
|
||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
|
|
||||||
|
|
||||||
|
public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
|
||||||
|
public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
|
||||||
|
public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the choose fingerprint wizard to indicate the wizard is
|
* Used by the choose fingerprint wizard to indicate the wizard is
|
||||||
|
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.settings.biometrics.face;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Switch;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A layout that contains a start-justified title, and an end-justified switch.
|
||||||
|
*/
|
||||||
|
public class FaceEnrollAccessibilityToggle extends LinearLayout {
|
||||||
|
|
||||||
|
private Switch mSwitch;
|
||||||
|
|
||||||
|
public FaceEnrollAccessibilityToggle(Context context) {
|
||||||
|
this(context, null /* attrs */);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FaceEnrollAccessibilityToggle(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FaceEnrollAccessibilityToggle(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
|
LayoutInflater.from(context).inflate(R.layout.face_enroll_accessibility_toggle,
|
||||||
|
this, true /* attachToRoot */);
|
||||||
|
|
||||||
|
final TypedArray a =
|
||||||
|
context.obtainStyledAttributes(attrs, R.styleable.FaceEnrollAccessibilityToggle);
|
||||||
|
try {
|
||||||
|
final CharSequence title =
|
||||||
|
a.getText(R.styleable.FaceEnrollAccessibilityToggle_messageText);
|
||||||
|
final TextView titleTextView = findViewById(R.id.title);
|
||||||
|
titleTextView.setText(title);
|
||||||
|
} finally {
|
||||||
|
a.recycle();
|
||||||
|
}
|
||||||
|
mSwitch = findViewById(R.id.toggle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChecked() {
|
||||||
|
return mSwitch.isChecked();
|
||||||
|
}
|
||||||
|
}
|
@@ -29,11 +29,12 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||||
import com.android.settings.biometrics.BiometricEnrollSidecar;
|
import com.android.settings.biometrics.BiometricEnrollSidecar;
|
||||||
import com.android.settings.biometrics.BiometricErrorDialog;
|
import com.android.settings.biometrics.BiometricErrorDialog;
|
||||||
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
|
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
|
public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||||
@@ -46,6 +47,8 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
private Interpolator mLinearOutSlowInInterpolator;
|
private Interpolator mLinearOutSlowInInterpolator;
|
||||||
private FaceEnrollPreviewFragment mPreviewFragment;
|
private FaceEnrollPreviewFragment mPreviewFragment;
|
||||||
|
|
||||||
|
private ArrayList<Integer> mDisabledFeatures = new ArrayList<>();
|
||||||
|
|
||||||
private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() {
|
private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onEnrolled() {
|
public void onEnrolled() {
|
||||||
@@ -91,6 +94,13 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
Button skipButton = findViewById(R.id.skip_button);
|
Button skipButton = findViewById(R.id.skip_button);
|
||||||
skipButton.setOnClickListener(this);
|
skipButton.setOnClickListener(this);
|
||||||
|
|
||||||
|
if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_DIVERSITY, true)) {
|
||||||
|
mDisabledFeatures.add(FaceManager.FEATURE_REQUIRE_REQUIRE_DIVERSITY);
|
||||||
|
}
|
||||||
|
if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_VISION, true)) {
|
||||||
|
mDisabledFeatures.add(FaceManager.FEATURE_REQUIRE_ATTENTION);
|
||||||
|
}
|
||||||
|
|
||||||
startEnrollment();
|
startEnrollment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +124,12 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BiometricEnrollSidecar getSidecar() {
|
protected BiometricEnrollSidecar getSidecar() {
|
||||||
return new FaceEnrollSidecar();
|
final int[] disabledFeatures = new int[mDisabledFeatures.size()];
|
||||||
|
for (int i = 0; i < mDisabledFeatures.size(); i++) {
|
||||||
|
disabledFeatures[i] = mDisabledFeatures.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FaceEnrollSidecar(disabledFeatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -20,7 +20,9 @@ import android.app.admin.DevicePolicyManager;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.face.FaceManager;
|
import android.hardware.face.FaceManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
@@ -37,11 +39,22 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
|||||||
private static final String TAG = "FaceIntro";
|
private static final String TAG = "FaceIntro";
|
||||||
|
|
||||||
private FaceManager mFaceManager;
|
private FaceManager mFaceManager;
|
||||||
|
private FaceEnrollAccessibilityToggle mSwitchVision;
|
||||||
|
private FaceEnrollAccessibilityToggle mSwitchDiversity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mFaceManager = Utils.getFaceManagerOrNull(this);
|
mFaceManager = Utils.getFaceManagerOrNull(this);
|
||||||
|
final LinearLayout accessibilityLayout = findViewById(R.id.accessibility_layout);
|
||||||
|
final Button accessibilityButton = findViewById(R.id.accessibility_button);
|
||||||
|
accessibilityButton.setOnClickListener(view -> {
|
||||||
|
accessibilityButton.setVisibility(View.INVISIBLE);
|
||||||
|
accessibilityLayout.setVisibility(View.VISIBLE);
|
||||||
|
});
|
||||||
|
|
||||||
|
mSwitchVision = findViewById(R.id.toggle_vision);
|
||||||
|
mSwitchDiversity = findViewById(R.id.toggle_diversity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,7 +129,10 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent getEnrollingIntent() {
|
protected Intent getEnrollingIntent() {
|
||||||
return new Intent(this, FaceEnrollEnrolling.class);
|
final Intent intent = new Intent(this, FaceEnrollEnrolling.class);
|
||||||
|
intent.putExtra(EXTRA_KEY_REQUIRE_VISION, mSwitchVision.isChecked());
|
||||||
|
intent.putExtra(EXTRA_KEY_REQUIRE_DIVERSITY, mSwitchDiversity.isChecked());
|
||||||
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -24,13 +24,22 @@ import com.android.internal.logging.nano.MetricsProto;
|
|||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.biometrics.BiometricEnrollSidecar;
|
import com.android.settings.biometrics.BiometricEnrollSidecar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sidecar fragment to handle the state around face enrollment
|
* Sidecar fragment to handle the state around face enrollment
|
||||||
*/
|
*/
|
||||||
public class FaceEnrollSidecar extends BiometricEnrollSidecar {
|
public class FaceEnrollSidecar extends BiometricEnrollSidecar {
|
||||||
|
|
||||||
|
private final int[] mDisabledFeatures;
|
||||||
|
|
||||||
private FaceManager mFaceManager;
|
private FaceManager mFaceManager;
|
||||||
|
|
||||||
|
public FaceEnrollSidecar(int[] disabledFeatures) {
|
||||||
|
mDisabledFeatures = Arrays.copyOf(disabledFeatures, disabledFeatures.length);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
@@ -43,9 +52,9 @@ public class FaceEnrollSidecar extends BiometricEnrollSidecar {
|
|||||||
if (mUserId != UserHandle.USER_NULL) {
|
if (mUserId != UserHandle.USER_NULL) {
|
||||||
mFaceManager.setActiveUser(mUserId);
|
mFaceManager.setActiveUser(mUserId);
|
||||||
}
|
}
|
||||||
// TODO: Send the list of disabled features
|
|
||||||
mFaceManager.enroll(mToken, mEnrollmentCancel,
|
mFaceManager.enroll(mToken, mEnrollmentCancel,
|
||||||
mEnrollmentCallback, new int[0] /* disabledFeatures */);
|
mEnrollmentCallback, mDisabledFeatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FaceManager.EnrollmentCallback mEnrollmentCallback
|
private FaceManager.EnrollmentCallback mEnrollmentCallback
|
||||||
|
Reference in New Issue
Block a user