diff options
author | Christopher Tate <ctate@google.com> | 2011-08-05 12:28:15 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2011-08-05 13:18:08 -0700 |
commit | 3851fa9c8d180ca636e69b25f84fdcc294150009 (patch) | |
tree | 07bb8da05949e5481ece0c38c091fd0df6ff4263 /packages/BackupRestoreConfirmation/src | |
parent | e83af902c4ed1f0f1afb1b4f6f26a8003aca4954 (diff) | |
download | frameworks_base-3851fa9c8d180ca636e69b25f84fdcc294150009.zip frameworks_base-3851fa9c8d180ca636e69b25f84fdcc294150009.tar.gz frameworks_base-3851fa9c8d180ca636e69b25f84fdcc294150009.tar.bz2 |
Handle rotation gracefully in the backup/restore confirmation UI
We now don't automatically deny the operation if stopped, but instead
allow the activity to be destroyed and recreated as usual. We retain
the observer instance across that sequence so we keep getting progress
reports etc.
The UI now also uses the spiffy new button bar styles, and positions
the deny / confirm buttons according to ICS standards.
Bug 5115411
Change-Id: Ie760a0c8496c69f9d5881273a63ad5b5b76ff554
Diffstat (limited to 'packages/BackupRestoreConfirmation/src')
-rw-r--r-- | packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java index f65a62f..5448e0b 100644 --- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java @@ -48,6 +48,8 @@ public class BackupRestoreConfirmation extends Activity { static final String TAG = "BackupRestoreConfirmation"; static final boolean DEBUG = true; + static final String DID_ACKNOWLEDGE = "did_acknowledge"; + static final int MSG_START_BACKUP = 1; static final int MSG_BACKUP_PACKAGE = 2; static final int MSG_END_BACKUP = 3; @@ -149,7 +151,13 @@ public class BackupRestoreConfirmation extends Activity { mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE)); mHandler = new ObserverHandler(getApplicationContext()); - mObserver = new FullObserver(); + final Object oldObserver = getLastNonConfigurationInstance(); + if (oldObserver == null) { + mObserver = new FullObserver(mHandler); + } else { + mObserver = (FullObserver) oldObserver; + mObserver.setHandler(mHandler); + } setContentView(layoutId); @@ -189,16 +197,24 @@ public class BackupRestoreConfirmation extends Activity { mDenyButton.setEnabled(false); } }); + + // if we're a relaunch we may need to adjust button enable state + if (icicle != null) { + mDidAcknowledge = icicle.getBoolean(DID_ACKNOWLEDGE, false); + mAllowButton.setEnabled(!mDidAcknowledge); + mDenyButton.setEnabled(!mDidAcknowledge); + } } + // Preserve the restore observer callback binder across activity relaunch @Override - public void onStop() { - super.onStop(); + public Object onRetainNonConfigurationInstance() { + return mObserver; + } - // We explicitly equate departure from the UI with refusal. This includes the - // implicit configuration-changed stop/restart cycle. - sendAcknowledgement(mToken, false, null); - finish(); + @Override + protected void onSaveInstanceState(Bundle outState) { + outState.putBoolean(DID_ACKNOWLEDGE, mDidAcknowledge); } void sendAcknowledgement(int token, boolean allow, IFullBackupRestoreObserver observer) { @@ -230,6 +246,16 @@ public class BackupRestoreConfirmation extends Activity { * the notifications onto the main thread. */ class FullObserver extends IFullBackupRestoreObserver.Stub { + private Handler mHandler; + + public FullObserver(Handler h) { + mHandler = h; + } + + public void setHandler(Handler h) { + mHandler = h; + } + // // IFullBackupRestoreObserver implementation // |