Show the accounts on the factory reset screen.
Bug: 2823530 Change-Id: Idbf46aa59f3c529a3a3ef2d7d4e607822b34f51d
This commit is contained in:
@@ -35,6 +35,22 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/master_clear_desc" />
|
||||
<TextView android:id="@+id/accounts_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/master_clear_accounts" />
|
||||
<LinearLayout android:id="@+id/accounts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/master_clear_desc_erase_external_storage" />
|
||||
<LinearLayout android:id="@+id/erase_external_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
23
res/layout/master_clear_account.xml
Normal file
23
res/layout/master_clear_account.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:drawablePadding="5dip"
|
||||
android:gravity="center_vertical" />
|
||||
|
@@ -1597,11 +1597,14 @@
|
||||
<!-- SD card & phone storage settings screen, setting option summary text under Internal phone storage heading -->
|
||||
<string name="master_clear_summary" product="default">Erases all data on phone</string>
|
||||
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
|
||||
<string name="master_clear_desc" product="tablet">"This will erase all data from your tablet\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and application data and settings</li>\n<li>Downloaded applications</li>\n\nTo clear all data on this tablet the <b>USB storage</b> needs to be erased.\n\n"</string>
|
||||
<string name="master_clear_desc" product="tablet">"This will erase all data from your tablet\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and application data and settings</li>\n<li>Downloaded applications</li>"</string>
|
||||
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
|
||||
<string name="master_clear_desc" product="nosdcard">"This will erase all data from your phone\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and application data and settings</li>\n<li>Downloaded applications</li>\n\nTo clear all data on this phone the <b>USB storage</b> needs to be erased.\n\n"</string>
|
||||
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset -->
|
||||
<string name="master_clear_desc" product="default">"This will erase all data from your phone\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and application data and settings</li>\n<li>Downloaded applications</li>\n\nTo also clear music, pictures, and other user data, the <b>SD card</b> needs to be erased.\n\n"</string>
|
||||
<string name="master_clear_desc" product="default">"This will erase all data from your phone\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and application data and settings</li>\n<li>Downloaded applications"</li></string>
|
||||
<!-- SD card & phone storage settings screen, instructions and list of current accounts. The list of accounts follows this text[CHAR LIMIT=NONE] -->
|
||||
<string name="master_clear_accounts" product="default">"\n\nYou are currently signed into the following accounts:\n"</string>
|
||||
<!-- SD card & phone storage settings screen, instructions about whether to also erase the external storage (SD card) when erasing the internal storage [CHAR LIMIT=NONE] -->
|
||||
<string name="master_clear_desc_erase_external_storage" product="nosdcard">"\n\nTo also clear music, pictures, and other user data, the <b>USB storage</b> needs to be erased."</string>
|
||||
<string name="master_clear_desc_erase_external_storage" product="default">"\n\nTo also clear music, pictures, and other user data, the <b>SD card</b> needs to be erased."</string>
|
||||
<!-- SD card & phone storage settings screen, label for check box to erase USB storage [CHAR LIMIT=30] -->
|
||||
<string name="erase_external_storage" product="nosdcard">Erase USB storage</string>
|
||||
<!-- SD card & phone storage settings screen, label for check box to erase SD card [CHAR LIMIT=30] -->
|
||||
|
@@ -18,18 +18,27 @@ package com.android.settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Confirm and execute a reset of the device to a clean "just out of the box"
|
||||
@@ -42,6 +51,7 @@ import android.widget.CheckBox;
|
||||
* This is the initial screen.
|
||||
*/
|
||||
public class MasterClear extends Fragment {
|
||||
private static final String TAG = "MasterClear";
|
||||
|
||||
private static final int KEYGUARD_REQUEST = 55;
|
||||
|
||||
@@ -130,12 +140,72 @@ public class MasterClear extends Fragment {
|
||||
mExternalStorage.toggle();
|
||||
}
|
||||
});
|
||||
|
||||
loadAccountList();
|
||||
}
|
||||
|
||||
private void loadAccountList() {
|
||||
View accountsLabel = mContentView.findViewById(R.id.accounts_label);
|
||||
LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts);
|
||||
|
||||
Context context = getActivity();
|
||||
|
||||
AccountManager mgr = AccountManager.get(context);
|
||||
Account[] accounts = mgr.getAccounts();
|
||||
final int N = accounts.length;
|
||||
if (N == 0) {
|
||||
accountsLabel.setVisibility(View.GONE);
|
||||
contents.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater)context.getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
AuthenticatorDescription[] descs = AccountManager.get(context).getAuthenticatorTypes();
|
||||
final int M = descs.length;
|
||||
|
||||
for (int i=0; i<N; i++) {
|
||||
Account account = accounts[i];
|
||||
AuthenticatorDescription desc = null;
|
||||
for (int j=0; j<M; j++) {
|
||||
if (account.type.equals(descs[j].type)) {
|
||||
desc = descs[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (desc == null) {
|
||||
Log.w(TAG, "No descriptor for account name=" + account.name
|
||||
+ " type=" + account.type);
|
||||
continue;
|
||||
}
|
||||
Drawable icon;
|
||||
try {
|
||||
Context authContext = context.createPackageContext(desc.packageName, 0);
|
||||
icon = authContext.getResources().getDrawable(desc.iconId);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, "No icon for account type " + desc.type);
|
||||
icon = null;
|
||||
}
|
||||
|
||||
TextView child = (TextView)inflater.inflate(R.layout.master_clear_account,
|
||||
contents, false);
|
||||
child.setText(account.name);
|
||||
if (icon != null) {
|
||||
child.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||
}
|
||||
contents.addView(child);
|
||||
}
|
||||
|
||||
accountsLabel.setVisibility(View.VISIBLE);
|
||||
contents.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mContentView = inflater.inflate(R.layout.master_clear, null);
|
||||
|
||||
establishInitialState();
|
||||
return mContentView;
|
||||
}
|
||||
|
Reference in New Issue
Block a user