Fix bug #2987804 (Provide a better UI for selecting the Backup account)
- make the "Backup account" toggle follow the state of "Back up my data" - reset Backup account in preferences if needed Change-Id: Ifdffb9d268a062f6f5ec617bca82699cc46e2b3a
This commit is contained in:
@@ -50,7 +50,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
private PreferenceScreen mConfigure;
|
private PreferenceScreen mConfigure;
|
||||||
|
|
||||||
private static final int DIALOG_ERASE_BACKUP = 2;
|
private static final int DIALOG_ERASE_BACKUP = 2;
|
||||||
private int mDialogType;
|
private int mDialogType;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -73,6 +73,14 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
updateToggles();
|
updateToggles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
// Refresh UI
|
||||||
|
updateToggles();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
if (mConfirmDialog != null && mConfirmDialog.isShowing()) {
|
if (mConfirmDialog != null && mConfirmDialog.isShowing()) {
|
||||||
@@ -105,7 +113,6 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,25 +154,36 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
Settings.Secure.BACKUP_AUTO_RESTORE, 1) == 1);
|
Settings.Secure.BACKUP_AUTO_RESTORE, 1) == 1);
|
||||||
mAutoRestore.setEnabled(backupEnabled);
|
mAutoRestore.setEnabled(backupEnabled);
|
||||||
|
|
||||||
mConfigure.setEnabled(configIntent != null);
|
final boolean configureEnabled = (configIntent != null) && backupEnabled;
|
||||||
|
mConfigure.setEnabled(configureEnabled);
|
||||||
mConfigure.setIntent(configIntent);
|
mConfigure.setIntent(configIntent);
|
||||||
if (configSummary != null) {
|
setConfigureSummary(configSummary);
|
||||||
mConfigure.setSummary(configSummary);
|
}
|
||||||
|
|
||||||
|
private void setConfigureSummary(String summary) {
|
||||||
|
if (summary != null) {
|
||||||
|
mConfigure.setSummary(summary);
|
||||||
} else {
|
} else {
|
||||||
mConfigure.setSummary(R.string.backup_configure_account_default_summary);
|
mConfigure.setSummary(R.string.backup_configure_account_default_summary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateConfigureSummary() {
|
||||||
|
try {
|
||||||
|
String transport = mBackupManager.getCurrentTransport();
|
||||||
|
String summary = mBackupManager.getDestinationString(transport);
|
||||||
|
setConfigureSummary(summary);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// Not much we can do here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
//updateProviders();
|
//updateProviders();
|
||||||
if (mDialogType == DIALOG_ERASE_BACKUP) {
|
if (mDialogType == DIALOG_ERASE_BACKUP) {
|
||||||
setBackupEnabled(false);
|
setBackupEnabled(false);
|
||||||
}
|
updateConfigureSummary();
|
||||||
} else {
|
|
||||||
if (mDialogType == DIALOG_ERASE_BACKUP) {
|
|
||||||
mBackup.setChecked(true);
|
|
||||||
mAutoRestore.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialogType = 0;
|
mDialogType = 0;
|
||||||
@@ -188,5 +206,6 @@ public class PrivacySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
mBackup.setChecked(enable);
|
mBackup.setChecked(enable);
|
||||||
mAutoRestore.setEnabled(enable);
|
mAutoRestore.setEnabled(enable);
|
||||||
|
mConfigure.setEnabled(enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user