1) Adds a layout for multi-biometric selection in BiometricEnrollActivity 2) Adds widgets for checkboxes 3) Shows ConfirmLock*/ChooseLock* for multi-biometric devices in BiometricEnrollActivity 4) finish()'s when loses foreground 5) Adds default string for ChooseLock* and multi-biometrics, e.g. "Set up Password + Biometrics", as well as associated plumbing to bring the user back to BiometricEnrollActivity once the credential is enrolled 6) When max templates enrolled, checkbox becomes disabled and description string is updated Bug: 162341940 Bug: 152242790 Fixes: 161742393 No effect on existing devices with the following: Test: adb shell am start -a android.settings.BIOMETRIC_ENROLL Test: SUW Test: make -j RunSettingsRoboTests Exempt-From-Owner-Approval: Biometric-related change to EncryptionInterstitial Change-Id: I855460d50228ace24d4ec5fbe330f02ab406cc02
116 lines
3.8 KiB
Java
116 lines
3.8 KiB
Java
/*
|
|
* Copyright (C) 2020 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;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.widget.CheckBox;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.StringRes;
|
|
|
|
import com.android.settings.R;
|
|
|
|
/**
|
|
* Widget contain space for an icon, title, description, and checkbox. On devices with multiple
|
|
* biometric sensors, allows users to choose sensors during {@link BiometricEnrollActivity}.
|
|
*/
|
|
public class BiometricEnrollCheckbox extends LinearLayout {
|
|
|
|
@NonNull private final CheckBox mCheckBox;
|
|
@NonNull private final TextView mDescriptionView;
|
|
@Nullable private View.OnClickListener mListener;
|
|
|
|
public BiometricEnrollCheckbox(Context context) {
|
|
this(context, null /* attrs */);
|
|
}
|
|
|
|
public BiometricEnrollCheckbox(Context context,
|
|
@Nullable AttributeSet attrs) {
|
|
this(context, attrs, 0 /* defStyleAttr */);
|
|
}
|
|
|
|
public BiometricEnrollCheckbox(Context context, @Nullable AttributeSet attrs,
|
|
int defStyleAttr) {
|
|
this(context, attrs, defStyleAttr, 0 /* defStyleRes */);
|
|
}
|
|
|
|
public BiometricEnrollCheckbox(Context context, AttributeSet attrs, int defStyleAttr,
|
|
int defStyleRes) {
|
|
super(context, attrs, defStyleAttr, defStyleRes);
|
|
|
|
LayoutInflater.from(context).inflate(R.layout.biometric_enroll_checkbox,
|
|
this, true /* attachToRoot */);
|
|
|
|
mCheckBox = findViewById(R.id.checkbox);
|
|
final ImageView iconView = findViewById(R.id.icon);
|
|
final TextView titleView = findViewById(R.id.title);
|
|
mDescriptionView = findViewById(R.id.description);
|
|
|
|
setOnClickListener(view -> {
|
|
if (isEnabled()) {
|
|
mCheckBox.toggle();
|
|
}
|
|
if (mListener != null) {
|
|
mListener.onClick(view);
|
|
}
|
|
});
|
|
|
|
final TypedArray a = context
|
|
.obtainStyledAttributes(attrs, R.styleable.BiometricEnrollCheckbox);
|
|
try {
|
|
final Drawable icon =
|
|
a.getDrawable(R.styleable.BiometricEnrollCheckbox_icon);
|
|
final CharSequence title =
|
|
a.getText(R.styleable.BiometricEnrollCheckbox_title);
|
|
final CharSequence description =
|
|
a.getText(R.styleable.BiometricEnrollCheckbox_description);
|
|
iconView.setImageDrawable(icon);
|
|
titleView.setText(title);
|
|
mDescriptionView.setText(description);
|
|
} finally {
|
|
a.recycle();
|
|
}
|
|
}
|
|
|
|
public void setListener(View.OnClickListener listener) {
|
|
mListener = listener;
|
|
}
|
|
|
|
@Override
|
|
public void setEnabled(boolean enabled) {
|
|
super.setEnabled(enabled);
|
|
mCheckBox.setEnabled(enabled);
|
|
}
|
|
|
|
public boolean isChecked() {
|
|
return mCheckBox.isChecked();
|
|
}
|
|
|
|
public void setDescription(@StringRes int resId) {
|
|
mDescriptionView.setText(resId);
|
|
}
|
|
}
|