Fragmentize "Factory reset" setting screen.
Split the screen into 2 fragments. Bug: 3148480
This commit is contained in:
@@ -7,3 +7,6 @@
|
|||||||
-keep class com.android.settings.bluetooth.*
|
-keep class com.android.settings.bluetooth.*
|
||||||
-keep class com.android.settings.applications.*
|
-keep class com.android.settings.applications.*
|
||||||
-keep class com.android.settings.inputmethod.*
|
-keep class com.android.settings.inputmethod.*
|
||||||
|
-keep class com.android.settings.MasterClear
|
||||||
|
-keep class com.android.settings.MasterClearConfirm
|
||||||
|
|
||||||
|
@@ -1,29 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||||
/*
|
|
||||||
**
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** Copyright (C) 2008 The Android Open Source Project
|
you may not use this file except in compliance with the License.
|
||||||
**
|
You may obtain a copy of the License at
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
** you may not use this file except in compliance with the License.
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
** You may obtain a copy of the License at
|
|
||||||
**
|
Unless required by applicable law or agreed to in writing, software
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
**
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
See the License for the specific language governing permissions and
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
limitations under the License.
|
||||||
** 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"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/info_layout">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dip"
|
android:layout_height="0dip"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -42,13 +44,14 @@
|
|||||||
<CheckBox android:id="@+id/erase_external"
|
<CheckBox android:id="@+id/erase_external"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:duplicateParentState="true" />
|
android:duplicateParentState="true" />
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -70,7 +73,8 @@
|
|||||||
android:id="@+id/initiate_master_clear"
|
android:id="@+id/initiate_master_clear"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginTop="20dip"
|
android:layout_marginTop="20dip"
|
||||||
android:layout_width="150dip"
|
android:layout_marginBottom="12dip"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/master_clear_button_text"
|
android:text="@string/master_clear_button_text"
|
||||||
android:gravity="center" />
|
android:gravity="center" />
|
39
res/layout/master_clear_confirm.xml
Normal file
39
res/layout/master_clear_confirm.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 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:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="@string/master_clear_final_desc" />
|
||||||
|
|
||||||
|
<Button android:id="@+id/execute_master_clear"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="40dip"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/master_clear_final_button_text"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
** Copyright (C) 2008 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"
|
|
||||||
style="@style/info_layout">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:text="@string/master_clear_final_desc" />
|
|
||||||
|
|
||||||
<Button android:id="@+id/execute_master_clear"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="40dip"
|
|
||||||
android:layout_width="150dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/master_clear_final_button_text"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@@ -1608,6 +1608,8 @@
|
|||||||
<string name="master_clear_gesture_explanation">You must draw your unlock pattern to confirm a factory data reset.</string>
|
<string name="master_clear_gesture_explanation">You must draw your unlock pattern to confirm a factory data reset.</string>
|
||||||
<!-- Master clear failed message -->
|
<!-- Master clear failed message -->
|
||||||
<string name="master_clear_failed">No reset was performed because the System Clear service is not available.</string>
|
<string name="master_clear_failed">No reset was performed because the System Clear service is not available.</string>
|
||||||
|
<!-- Master clear confirmation screen title [CHAR LIMIT=30] -->
|
||||||
|
<string name="master_clear_confirm_title">Confirm reset</string>
|
||||||
|
|
||||||
<!-- Media Format -->
|
<!-- Media Format -->
|
||||||
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
||||||
|
@@ -33,15 +33,11 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/personal_data_section_title">
|
android:title="@string/personal_data_section_title"/>
|
||||||
<!-- Factory reset -->
|
<!-- Factory reset -->
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/master_clear_title"
|
android:title="@string/master_clear_title"
|
||||||
android:summary="@string/master_clear_summary">
|
android:summary="@string/master_clear_summary"
|
||||||
<intent android:action="android.intent.action.MAIN"
|
android:fragment="com.android.settings.MasterClear" />
|
||||||
android:targetPackage="com.android.settings"
|
|
||||||
android:targetClass="com.android.settings.MasterClear" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -16,21 +16,28 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
|
||||||
|
|
||||||
public class ChooseLockSettingsHelper {
|
public class ChooseLockSettingsHelper {
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
private Fragment mFragment;
|
||||||
|
|
||||||
public ChooseLockSettingsHelper(Activity activity) {
|
public ChooseLockSettingsHelper(Activity activity) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mLockPatternUtils = new LockPatternUtils(activity);
|
mLockPatternUtils = new LockPatternUtils(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChooseLockSettingsHelper(Activity activity, Fragment fragment) {
|
||||||
|
this(activity);
|
||||||
|
mFragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
public LockPatternUtils utils() {
|
public LockPatternUtils utils() {
|
||||||
return mLockPatternUtils;
|
return mLockPatternUtils;
|
||||||
}
|
}
|
||||||
@@ -76,7 +83,11 @@ public class ChooseLockSettingsHelper {
|
|||||||
intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message);
|
intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message);
|
||||||
intent.putExtra(ConfirmLockPattern.FOOTER_TEXT, details);
|
intent.putExtra(ConfirmLockPattern.FOOTER_TEXT, details);
|
||||||
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
|
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
|
||||||
|
if (mFragment != null) {
|
||||||
|
mFragment.startActivityForResult(intent, request);
|
||||||
|
} else {
|
||||||
mActivity.startActivityForResult(intent, request);
|
mActivity.startActivityForResult(intent, request);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +100,11 @@ public class ChooseLockSettingsHelper {
|
|||||||
if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
|
if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPassword");
|
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPassword");
|
||||||
|
if (mFragment != null) {
|
||||||
|
mFragment.startActivityForResult(intent, request);
|
||||||
|
} else {
|
||||||
mActivity.startActivityForResult(intent, request);
|
mActivity.startActivityForResult(intent, request);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,14 +16,18 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import com.android.internal.os.storage.ExternalStorageFormatter;
|
import com.android.settings.R;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
@@ -34,44 +38,20 @@ import android.widget.CheckBox;
|
|||||||
* has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING
|
* has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING
|
||||||
* ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is
|
* ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is
|
||||||
* locked, et cetera, then the confirmation sequence is abandoned.
|
* locked, et cetera, then the confirmation sequence is abandoned.
|
||||||
|
*
|
||||||
|
* This is the initial screen.
|
||||||
*/
|
*/
|
||||||
public class MasterClear extends Activity {
|
public class MasterClear extends Fragment {
|
||||||
|
|
||||||
private static final int KEYGUARD_REQUEST = 55;
|
private static final int KEYGUARD_REQUEST = 55;
|
||||||
|
|
||||||
private LayoutInflater mInflater;
|
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
|
||||||
private LockPatternUtils mLockUtils;
|
|
||||||
|
|
||||||
private View mInitialView;
|
private View mContentView;
|
||||||
private Button mInitiateButton;
|
private Button mInitiateButton;
|
||||||
private View mExternalStorageContainer;
|
private View mExternalStorageContainer;
|
||||||
private CheckBox mExternalStorage;
|
private CheckBox mExternalStorage;
|
||||||
|
|
||||||
private View mFinalView;
|
|
||||||
private Button mFinalButton;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The user has gone through the multiple confirmation, so now we go ahead
|
|
||||||
* and invoke the Checkin Service to reset the device to its factory-default
|
|
||||||
* state (rebooting in the process).
|
|
||||||
*/
|
|
||||||
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (Utils.isMonkeyRunning()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mExternalStorage.isChecked()) {
|
|
||||||
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
|
|
||||||
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
|
|
||||||
startService(intent);
|
|
||||||
} else {
|
|
||||||
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
|
||||||
// Intent handling is asynchronous -- assume it will happen soon.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||||
* component as a subactivity
|
* component as a subactivity
|
||||||
@@ -79,14 +59,15 @@ public class MasterClear extends Activity {
|
|||||||
* @return true if confirmation launched
|
* @return true if confirmation launched
|
||||||
*/
|
*/
|
||||||
private boolean runKeyguardConfirmation(int request) {
|
private boolean runKeyguardConfirmation(int request) {
|
||||||
return new ChooseLockSettingsHelper(this)
|
Resources res = getActivity().getResources();
|
||||||
|
return new ChooseLockSettingsHelper(getActivity(), this)
|
||||||
.launchConfirmationActivity(request,
|
.launchConfirmationActivity(request,
|
||||||
getText(R.string.master_clear_gesture_prompt),
|
res.getText(R.string.master_clear_gesture_prompt),
|
||||||
getText(R.string.master_clear_gesture_explanation));
|
res.getText(R.string.master_clear_gesture_explanation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
if (requestCode != KEYGUARD_REQUEST) {
|
if (requestCode != KEYGUARD_REQUEST) {
|
||||||
@@ -96,41 +77,34 @@ public class MasterClear extends Activity {
|
|||||||
// If the user entered a valid keyguard trace, present the final
|
// If the user entered a valid keyguard trace, present the final
|
||||||
// confirmation prompt; otherwise, go back to the initial state.
|
// confirmation prompt; otherwise, go back to the initial state.
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
establishFinalConfirmationState();
|
showFinalConfirmation();
|
||||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
|
||||||
finish();
|
|
||||||
} else {
|
} else {
|
||||||
establishInitialState();
|
establishInitialState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showFinalConfirmation() {
|
||||||
|
Preference preference = new Preference(getActivity());
|
||||||
|
preference.setFragment(MasterClearConfirm.class.getName());
|
||||||
|
preference.setTitle(R.string.master_clear_confirm_title);
|
||||||
|
preference.getExtras().putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
||||||
|
((PreferenceActivity) getActivity()).onPreferenceStartFragment(null, preference);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the user clicks to begin the reset sequence, we next require a
|
* If the user clicks to begin the reset sequence, we next require a
|
||||||
* keyguard confirmation if the user has currently enabled one. If there
|
* keyguard confirmation if the user has currently enabled one. If there
|
||||||
* is no keyguard available, we simply go to the final confirmation prompt.
|
* is no keyguard available, we simply go to the final confirmation prompt.
|
||||||
*/
|
*/
|
||||||
private Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
|
private Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
||||||
establishFinalConfirmationState();
|
showFinalConfirmation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the UI for the final confirmation interaction
|
|
||||||
*/
|
|
||||||
private void establishFinalConfirmationState() {
|
|
||||||
if (mFinalView == null) {
|
|
||||||
mFinalView = mInflater.inflate(R.layout.master_clear_final, null);
|
|
||||||
mFinalButton =
|
|
||||||
(Button) mFinalView.findViewById(R.id.execute_master_clear);
|
|
||||||
mFinalButton.setOnClickListener(mFinalClickListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(mFinalView);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In its initial state, the activity presents a button for the user to
|
* In its initial state, the activity presents a button for the user to
|
||||||
* click in order to initiate a confirmation sequence. This method is
|
* click in order to initiate a confirmation sequence. This method is
|
||||||
@@ -144,16 +118,13 @@ public class MasterClear extends Activity {
|
|||||||
* to change contents.
|
* to change contents.
|
||||||
*/
|
*/
|
||||||
private void establishInitialState() {
|
private void establishInitialState() {
|
||||||
if (mInitialView == null) {
|
mInitiateButton = (Button) mContentView.findViewById(R.id.initiate_master_clear);
|
||||||
mInitialView = mInflater.inflate(R.layout.master_clear_primary, null);
|
|
||||||
mInitiateButton =
|
|
||||||
(Button) mInitialView.findViewById(R.id.initiate_master_clear);
|
|
||||||
mInitiateButton.setOnClickListener(mInitiateListener);
|
mInitiateButton.setOnClickListener(mInitiateListener);
|
||||||
mExternalStorageContainer =
|
mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container);
|
||||||
mInitialView.findViewById(R.id.erase_external_container);
|
mExternalStorage = (CheckBox) mContentView.findViewById(R.id.erase_external);
|
||||||
mExternalStorage =
|
|
||||||
(CheckBox) mInitialView.findViewById(R.id.erase_external);
|
|
||||||
mExternalStorageContainer.setOnClickListener(new View.OnClickListener() {
|
mExternalStorageContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mExternalStorage.toggle();
|
mExternalStorage.toggle();
|
||||||
@@ -161,31 +132,11 @@ public class MasterClear extends Activity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setContentView(mInitialView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
super.onCreate(savedState);
|
Bundle savedInstanceState) {
|
||||||
|
mContentView = inflater.inflate(R.layout.master_clear, null);
|
||||||
mInitialView = null;
|
|
||||||
mFinalView = null;
|
|
||||||
mInflater = LayoutInflater.from(this);
|
|
||||||
mLockUtils = new LockPatternUtils(this);
|
|
||||||
|
|
||||||
establishInitialState();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Abandon all progress through the confirmation sequence by returning
|
|
||||||
* to the initial view any time the activity is interrupted (e.g. by
|
|
||||||
* idle timeout).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
if (!isFinishing()) {
|
|
||||||
establishInitialState();
|
establishInitialState();
|
||||||
}
|
return mContentView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
95
src/com/android/settings/MasterClearConfirm.java
Normal file
95
src/com/android/settings/MasterClearConfirm.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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;
|
||||||
|
|
||||||
|
import com.android.internal.os.storage.ExternalStorageFormatter;
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm and execute a reset of the device to a clean "just out of the box"
|
||||||
|
* state. Multiple confirmations are required: first, a general "are you sure
|
||||||
|
* you want to do this?" prompt, followed by a keyguard pattern trace if the user
|
||||||
|
* has defined one, followed by a final strongly-worded "THIS WILL ERASE EVERYTHING
|
||||||
|
* ON THE PHONE" prompt. If at any time the phone is allowed to go to sleep, is
|
||||||
|
* locked, et cetera, then the confirmation sequence is abandoned.
|
||||||
|
*
|
||||||
|
* This is the confirmation screen.
|
||||||
|
*/
|
||||||
|
public class MasterClearConfirm extends Fragment {
|
||||||
|
|
||||||
|
private View mContentView;
|
||||||
|
private boolean mEraseSdCard;
|
||||||
|
private Button mFinalButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user has gone through the multiple confirmation, so now we go ahead
|
||||||
|
* and invoke the Checkin Service to reset the device to its factory-default
|
||||||
|
* state (rebooting in the process).
|
||||||
|
*/
|
||||||
|
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
||||||
|
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (Utils.isMonkeyRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mEraseSdCard) {
|
||||||
|
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
|
||||||
|
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
|
||||||
|
getActivity().startService(intent);
|
||||||
|
} else {
|
||||||
|
getActivity().sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||||
|
// Intent handling is asynchronous -- assume it will happen soon.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the UI for the final confirmation interaction
|
||||||
|
*/
|
||||||
|
private void establishFinalConfirmationState() {
|
||||||
|
mFinalButton = (Button) mContentView.findViewById(R.id.execute_master_clear);
|
||||||
|
mFinalButton.setOnClickListener(mFinalClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
|
||||||
|
establishFinalConfirmationState();
|
||||||
|
return mContentView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Bundle args = getArguments();
|
||||||
|
mEraseSdCard = args != null ? args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA) : false;
|
||||||
|
}
|
||||||
|
}
|
@@ -98,7 +98,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showEraseBackupDialog() {
|
private void showEraseBackupDialog() {
|
||||||
|
Reference in New Issue
Block a user