Fingerprint Introduction FragmentActivity

Introducing MVVM architecture & fragments to biometric settings.
Here, we modify the first page of FingerprintEnrollIntroduction to use
new MVVM with Fragment architecture.

And with this new architecture, unit test and screen order will be
easier to be written or changed.

Bug: 236072782
Test: atest FingerprintEnrollmentViewModelTest AutoCredentialViewModelTest
	    FingerprintEnrollIntroViewModelTest FingerprintRepositoryTest
Change-Id: Icf12c91625db86c2c99081a0108203e607e77f74
This commit is contained in:
Milton Wu
2022-09-14 14:26:05 +08:00
parent 45be6bae05
commit b9b8b8a512
30 changed files with 3319 additions and 1 deletions

View File

@@ -0,0 +1,99 @@
/*
* Copyright (C) 2022 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.biometrics2.ui.model;
import static com.android.settings.biometrics.BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY;
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.android.settings.SetupWizardUtils;
import com.google.android.setupcompat.util.WizardManagerHelper;
/**
* Biometric enrollment generic intent data, which includes
* 1. isSuw
* 2. isAfterSuwOrSuwSuggestedAction
* 3. theme
* 4. isFromSettingsSummery
* 5. a helper method, getSetupWizardExtras
*/
public final class EnrollmentRequest {
private final boolean mIsSuw;
private final boolean mIsAfterSuwOrSuwSuggestedAction;
private final boolean mIsFromSettingsSummery;
private final int mTheme;
private final Bundle mSuwExtras;
public EnrollmentRequest(@NonNull Intent intent, @NonNull Context context) {
mIsSuw = WizardManagerHelper.isAnySetupWizard(intent);
mIsAfterSuwOrSuwSuggestedAction = WizardManagerHelper.isDeferredSetupWizard(intent)
|| WizardManagerHelper.isPortalSetupWizard(intent)
|| intent.getBooleanExtra(EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW, false);
mSuwExtras = getSuwExtras(mIsSuw, intent);
mIsFromSettingsSummery = intent.getBooleanExtra(EXTRA_FROM_SETTINGS_SUMMARY, false);
mTheme = SetupWizardUtils.getTheme(context, intent);
}
public boolean isSuw() {
return mIsSuw;
}
public boolean isAfterSuwOrSuwSuggestedAction() {
return mIsAfterSuwOrSuwSuggestedAction;
}
public boolean isFromSettingsSummery() {
return mIsFromSettingsSummery;
}
public int getTheme() {
return mTheme;
}
@NonNull
public Bundle getSuwExtras() {
return new Bundle(mSuwExtras);
}
/**
* Returns a string representation of the object
*/
@Override
public String toString() {
return getClass().getSimpleName() + ":{isSuw:" + mIsSuw
+ ", isAfterSuwOrSuwSuggestedAction:" + mIsAfterSuwOrSuwSuggestedAction
+ ", isFromSettingsSummery:" + mIsFromSettingsSummery
+ "}";
}
@NonNull
private static Bundle getSuwExtras(boolean isSuw, @NonNull Intent intent) {
final Intent toIntent = new Intent();
if (isSuw) {
SetupWizardUtils.copySetupExtras(intent, toIntent);
}
return toIntent.getExtras() != null ? toIntent.getExtras() : new Bundle();
}
}