Merge "Update fingerprint enrolling flow"
This commit is contained in:
committed by
Android (Google) Code Review
commit
554cc58a8d
@@ -82,15 +82,6 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/skip_button"
|
|
||||||
style="@style/SetupWizardButton.Negative"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:text="@string/skip_label"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@@ -71,14 +71,6 @@
|
|||||||
android:accessibilityLiveRegion="polite"
|
android:accessibilityLiveRegion="polite"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/skip_button"
|
|
||||||
style="@style/SetupWizardButton.Negative"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/skip_label"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.android.setupwizardlib.GlifLayout>
|
</com.android.setupwizardlib.GlifLayout>
|
||||||
|
@@ -237,12 +237,15 @@ public class FingerprintEnrollEnrolling extends FingerprintEnrollBase
|
|||||||
|
|
||||||
private void launchFinish(byte[] token) {
|
private void launchFinish(byte[] token) {
|
||||||
Intent intent = getFinishIntent();
|
Intent intent = getFinishIntent();
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
|
||||||
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||||
if (mUserId != UserHandle.USER_NULL) {
|
if (mUserId != UserHandle.USER_NULL) {
|
||||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.fingerprint;
|
package com.android.settings.fingerprint;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -32,19 +31,31 @@ import com.android.settings.Utils;
|
|||||||
*/
|
*/
|
||||||
public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
||||||
|
|
||||||
|
private static final int REQUEST_ADD_ANOTHER = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.fingerprint_enroll_finish);
|
setContentView(R.layout.fingerprint_enroll_finish);
|
||||||
setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
|
setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
Button addButton = (Button) findViewById(R.id.add_another_button);
|
Button addButton = (Button) findViewById(R.id.add_another_button);
|
||||||
|
|
||||||
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
|
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
|
||||||
|
boolean hideAddAnother = false;
|
||||||
|
if (fpm != null) {
|
||||||
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
|
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
|
||||||
int max = getResources().getInteger(
|
int max = getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
||||||
if (enrolled >= max) {
|
hideAddAnother = enrolled >= max;
|
||||||
/* Don't show "Add" button if too many fingerprints already added */
|
}
|
||||||
|
if (hideAddAnother) {
|
||||||
|
// Don't show "Add" button if too many fingerprints already added
|
||||||
addButton.setVisibility(View.INVISIBLE);
|
addButton.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
} else {
|
||||||
addButton.setOnClickListener(this);
|
addButton.setOnClickListener(this);
|
||||||
@@ -60,14 +71,21 @@ public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v.getId() == R.id.add_another_button) {
|
if (v.getId() == R.id.add_another_button) {
|
||||||
final Intent intent = getEnrollingIntent();
|
startActivityForResult(getEnrollingIntent(), REQUEST_ADD_ANOTHER);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
super.onClick(v);
|
super.onClick(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (requestCode == REQUEST_ADD_ANOTHER && resultCode != RESULT_CANCELED) {
|
||||||
|
setResult(resultCode, data);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.FINGERPRINT_ENROLL_FINISH;
|
return MetricsEvent.FINGERPRINT_ENROLL_FINISH;
|
||||||
|
@@ -16,26 +16,14 @@
|
|||||||
|
|
||||||
package com.android.settings.fingerprint;
|
package com.android.settings.fingerprint;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.FragmentManager;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
|
||||||
|
|
||||||
public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling {
|
public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling {
|
||||||
|
|
||||||
private static final String TAG_DIALOG = "dialog";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent getFinishIntent() {
|
protected Intent getFinishIntent() {
|
||||||
final Intent intent = new Intent(this, SetupFingerprintEnrollFinish.class);
|
final Intent intent = new Intent(this, SetupFingerprintEnrollFinish.class);
|
||||||
@@ -49,72 +37,8 @@ public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling
|
|||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initViews() {
|
|
||||||
super.initViews();
|
|
||||||
final Button skipButton = (Button) findViewById(R.id.skip_button);
|
|
||||||
skipButton.setVisibility(View.VISIBLE);
|
|
||||||
skipButton.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.skip_button:
|
|
||||||
new SkipDialog().show(getFragmentManager(), TAG_DIALOG);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
super.onClick(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.FINGERPRINT_ENROLLING_SETUP;
|
return MetricsEvent.FINGERPRINT_ENROLLING_SETUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SkipDialog extends InstrumentedDialogFragment {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(FragmentManager manager, String tag) {
|
|
||||||
if (manager.findFragmentByTag(tag) == null) {
|
|
||||||
super.show(manager, tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SkipDialog() {
|
|
||||||
// no-arg constructor for fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
return new AlertDialog.Builder(getActivity())
|
|
||||||
.setTitle(R.string.setup_fingerprint_enroll_enrolling_skip_title)
|
|
||||||
.setMessage(R.string.setup_fingerprint_enroll_enrolling_skip_message)
|
|
||||||
.setCancelable(false)
|
|
||||||
.setPositiveButton(R.string.skip_anyway_button_label,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null) {
|
|
||||||
activity.setResult(RESULT_SKIP);
|
|
||||||
activity.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.go_back_button_label,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return MetricsEvent.DIALOG_FINGERPRINT_CANCEL_SETUP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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.fingerprint;
|
||||||
|
|
||||||
|
import static android.support.test.InstrumentationRegistry.getTargetContext;
|
||||||
|
import static android.support.test.espresso.Espresso.onView;
|
||||||
|
import static android.support.test.espresso.action.ViewActions.click;
|
||||||
|
import static android.support.test.espresso.intent.Intents.intended;
|
||||||
|
import static android.support.test.espresso.intent.Intents.intending;
|
||||||
|
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
|
||||||
|
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Instrumentation.ActivityResult;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.support.test.espresso.intent.rule.IntentsTestRule;
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@SmallTest
|
||||||
|
public class FingerprintEnrollFinishTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public IntentsTestRule<FingerprintEnrollFinish> mActivityRule =
|
||||||
|
new IntentsTestRule<>(FingerprintEnrollFinish.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void clickAddAnother_shouldLaunchEnrolling() {
|
||||||
|
final ComponentName enrollingComponent = new ComponentName(
|
||||||
|
getTargetContext(),
|
||||||
|
FingerprintEnrollEnrolling.class);
|
||||||
|
|
||||||
|
intending(hasComponent(enrollingComponent))
|
||||||
|
.respondWith(new ActivityResult(Activity.RESULT_CANCELED, null));
|
||||||
|
|
||||||
|
onView(withId(R.id.add_another_button)).perform(click());
|
||||||
|
|
||||||
|
intended(hasComponent(enrollingComponent));
|
||||||
|
assertFalse(mActivityRule.getActivity().isFinishing());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void clickAddAnother_shouldPropagateResults() {
|
||||||
|
final ComponentName enrollingComponent = new ComponentName(
|
||||||
|
getTargetContext(),
|
||||||
|
FingerprintEnrollEnrolling.class);
|
||||||
|
|
||||||
|
intending(hasComponent(enrollingComponent))
|
||||||
|
.respondWith(new ActivityResult(Activity.RESULT_OK, null));
|
||||||
|
|
||||||
|
onView(withId(R.id.add_another_button)).perform(click());
|
||||||
|
|
||||||
|
intended(hasComponent(enrollingComponent));
|
||||||
|
assertTrue(mActivityRule.getActivity().isFinishing());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void clickNext_shouldFinish() {
|
||||||
|
onView(withId(R.id.next_button)).perform(click());
|
||||||
|
assertTrue(mActivityRule.getActivity().isFinishing());
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user