Merge "Change reset page to be SUW style"
This commit is contained in:
committed by
Android (Google) Code Review
commit
414c212909
@@ -21,7 +21,7 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
@@ -31,6 +31,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -61,8 +62,9 @@ import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settings.password.ConfirmLockPattern;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.setupwizardlib.TemplateLayout;
|
||||
import com.android.setupwizardlib.template.ButtonFooterMixin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -79,8 +81,10 @@ import java.util.List;
|
||||
public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutListener {
|
||||
private static final String TAG = "MasterClear";
|
||||
|
||||
@VisibleForTesting static final int KEYGUARD_REQUEST = 55;
|
||||
@VisibleForTesting static final int CREDENTIAL_CONFIRM_REQUEST = 56;
|
||||
@VisibleForTesting
|
||||
static final int KEYGUARD_REQUEST = 55;
|
||||
@VisibleForTesting
|
||||
static final int CREDENTIAL_CONFIRM_REQUEST = 56;
|
||||
|
||||
private static final String KEY_SHOW_ESIM_RESET_CHECKBOX
|
||||
= "masterclear.allow_retain_esim_profiles_after_fdr";
|
||||
@@ -89,27 +93,41 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
static final String ERASE_ESIMS_EXTRA = "erase_esim";
|
||||
|
||||
private View mContentView;
|
||||
@VisibleForTesting Button mInitiateButton;
|
||||
@VisibleForTesting
|
||||
Button mInitiateButton;
|
||||
private View mExternalStorageContainer;
|
||||
@VisibleForTesting CheckBox mExternalStorage;
|
||||
@VisibleForTesting
|
||||
CheckBox mExternalStorage;
|
||||
private View mEsimStorageContainer;
|
||||
@VisibleForTesting CheckBox mEsimStorage;
|
||||
@VisibleForTesting ScrollView mScrollView;
|
||||
@VisibleForTesting
|
||||
CheckBox mEsimStorage;
|
||||
@VisibleForTesting
|
||||
ScrollView mScrollView;
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
mInitiateButton.setEnabled(hasReachedBottom(mScrollView));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().setTitle(R.string.master_clear_short_title);
|
||||
private void setUpActionBarAndTitle() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
Log.e(TAG, "No activity attached, skipping setUpActionBarAndTitle");
|
||||
return;
|
||||
}
|
||||
final ActionBar actionBar = activity.getActionBar();
|
||||
if (actionBar == null) {
|
||||
Log.e(TAG, "No actionbar, skipping setUpActionBarAndTitle");
|
||||
return;
|
||||
}
|
||||
actionBar.hide();
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||
* component as a subactivity
|
||||
*
|
||||
* @param request the request code to be returned once confirmation finishes
|
||||
* @return true if confirmation launched
|
||||
*/
|
||||
@@ -189,8 +207,8 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
Account[] accounts = am.getAccountsByType(accountType);
|
||||
if (accounts != null && accounts.length > 0) {
|
||||
final Intent requestAccountConfirmation = new Intent()
|
||||
.setPackage(packageName)
|
||||
.setComponent(new ComponentName(packageName, className));
|
||||
.setPackage(packageName)
|
||||
.setComponent(new ComponentName(packageName, className));
|
||||
// Check to make sure that the intent is supported.
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
final ResolveInfo resolution = pm.resolveActivity(requestAccountConfirmation, 0);
|
||||
@@ -259,8 +277,9 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void establishInitialState() {
|
||||
mInitiateButton = mContentView.findViewById(R.id.initiate_master_clear);
|
||||
mInitiateButton.setOnClickListener(mInitiateListener);
|
||||
setUpActionBarAndTitle();
|
||||
setUpInitiateButton();
|
||||
|
||||
mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container);
|
||||
mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||
mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
|
||||
@@ -334,7 +353,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
mScrollView.setOnScrollChangeListener(new OnScrollChangeListener() {
|
||||
@Override
|
||||
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX,
|
||||
int oldScrollY) {
|
||||
int oldScrollY) {
|
||||
if (v instanceof ScrollView && hasReachedBottom((ScrollView) v)) {
|
||||
mInitiateButton.setEnabled(true);
|
||||
mScrollView.setOnScrollChangeListener(null);
|
||||
@@ -360,8 +379,8 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
}
|
||||
ContentResolver cr = context.getContentResolver();
|
||||
return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0
|
||||
|| Settings.Global.getInt(
|
||||
cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
||||
|| Settings.Global.getInt(
|
||||
cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -388,21 +407,36 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
return diff <= 0;
|
||||
}
|
||||
|
||||
private void setUpInitiateButton() {
|
||||
if (mInitiateButton != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
|
||||
final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
|
||||
buttonFooterMixin.removeAllViews();
|
||||
buttonFooterMixin.addSpace();
|
||||
buttonFooterMixin.addSpace();
|
||||
mInitiateButton = buttonFooterMixin.addButton(R.string.master_clear_button_text,
|
||||
R.style.SuwGlifButton_Primary);
|
||||
mInitiateButton.setOnClickListener(mInitiateListener);
|
||||
}
|
||||
|
||||
private void getContentDescription(View v, StringBuffer description) {
|
||||
if (v.getVisibility() != View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
if (v instanceof ViewGroup) {
|
||||
ViewGroup vGroup = (ViewGroup) v;
|
||||
for (int i = 0; i < vGroup.getChildCount(); i++) {
|
||||
View nextChild = vGroup.getChildAt(i);
|
||||
getContentDescription(nextChild, description);
|
||||
}
|
||||
} else if (v instanceof TextView) {
|
||||
TextView vText = (TextView) v;
|
||||
description.append(vText.getText());
|
||||
description.append(","); // Allow Talkback to pause between sections.
|
||||
}
|
||||
if (v.getVisibility() != View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
if (v instanceof ViewGroup) {
|
||||
ViewGroup vGroup = (ViewGroup) v;
|
||||
for (int i = 0; i < vGroup.getChildCount(); i++) {
|
||||
View nextChild = vGroup.getChildAt(i);
|
||||
getContentDescription(nextChild, description);
|
||||
}
|
||||
} else if (v instanceof TextView) {
|
||||
TextView vText = (TextView) v;
|
||||
description.append(vText.getText());
|
||||
description.append(","); // Allow Talkback to pause between sections.
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isExtStorageEncrypted() {
|
||||
@@ -412,7 +446,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
|
||||
private void loadAccountList(final UserManager um) {
|
||||
View accountsLabel = mContentView.findViewById(R.id.accounts_label);
|
||||
LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts);
|
||||
LinearLayout contents = (LinearLayout) mContentView.findViewById(R.id.accounts);
|
||||
contents.removeAllViews();
|
||||
|
||||
Context context = getActivity();
|
||||
@@ -421,7 +455,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
|
||||
|
||||
AccountManager mgr = AccountManager.get(context);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater)context.getSystemService(
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
int accountsCount = 0;
|
||||
|
||||
@@ -16,18 +16,23 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.service.oemlock.OemLockManager;
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -37,8 +42,9 @@ import android.widget.TextView;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.setupwizardlib.TemplateLayout;
|
||||
import com.android.setupwizardlib.template.ButtonFooterMixin;
|
||||
|
||||
/**
|
||||
* Confirm and execute a reset of the device to a clean "just out of the box"
|
||||
@@ -51,6 +57,7 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
* This is the confirmation screen.
|
||||
*/
|
||||
public class MasterClearConfirm extends InstrumentedFragment {
|
||||
private final static String TAG = "MasterClearConfirm";
|
||||
|
||||
private View mContentView;
|
||||
private boolean mEraseSdCard;
|
||||
@@ -103,9 +110,11 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
||||
mProgressDialog.show();
|
||||
|
||||
// need to prevent orientation changes as we're about to go into
|
||||
// a long IO request, so we won't be able to access inflate resources on flash
|
||||
// a long IO request, so we won't be able to access inflate resources on
|
||||
// flash
|
||||
mOldOrientation = getActivity().getRequestedOrientation();
|
||||
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
getActivity().setRequestedOrientation(
|
||||
ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
}
|
||||
}.execute();
|
||||
} else {
|
||||
@@ -140,8 +149,29 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
||||
* Configure the UI for the final confirmation interaction
|
||||
*/
|
||||
private void establishFinalConfirmationState() {
|
||||
mContentView.findViewById(R.id.execute_master_clear)
|
||||
.setOnClickListener(mFinalClickListener);
|
||||
final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
|
||||
|
||||
final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
|
||||
buttonFooterMixin.removeAllViews();
|
||||
buttonFooterMixin.addSpace();
|
||||
buttonFooterMixin.addSpace();
|
||||
buttonFooterMixin.addButton(R.string.master_clear_button_text,
|
||||
R.style.SuwGlifButton_Primary).setOnClickListener(mFinalClickListener);
|
||||
}
|
||||
|
||||
private void setUpActionBarAndTitle() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
Log.e(TAG, "No activity attached, skipping setUpActionBarAndTitle");
|
||||
return;
|
||||
}
|
||||
final ActionBar actionBar = activity.getActionBar();
|
||||
if (actionBar == null) {
|
||||
Log.e(TAG, "No actionbar, skipping setUpActionBarAndTitle");
|
||||
return;
|
||||
}
|
||||
actionBar.hide();
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,6 +190,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
||||
return new View(getActivity());
|
||||
}
|
||||
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
|
||||
setUpActionBarAndTitle();
|
||||
establishFinalConfirmationState();
|
||||
setAccessibilityTitle();
|
||||
return mContentView;
|
||||
@@ -167,8 +198,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
||||
|
||||
private void setAccessibilityTitle() {
|
||||
CharSequence currentTitle = getActivity().getTitle();
|
||||
TextView confirmationMessage =
|
||||
(TextView) mContentView.findViewById(R.id.master_clear_confirm);
|
||||
TextView confirmationMessage = mContentView.findViewById(R.id.master_clear_confirm);
|
||||
if (confirmationMessage != null) {
|
||||
String accessibleText = new StringBuilder(currentTitle).append(",").append(
|
||||
confirmationMessage.getText()).toString();
|
||||
|
||||
Reference in New Issue
Block a user