summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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
commit3851fa9c8d180ca636e69b25f84fdcc294150009 (patch)
tree07bb8da05949e5481ece0c38c091fd0df6ff4263
parente83af902c4ed1f0f1afb1b4f6f26a8003aca4954 (diff)
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
-rw-r--r--packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml33
-rw-r--r--packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml23
-rw-r--r--packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java40
3 files changed, 67 insertions, 29 deletions
diff --git a/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml b/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml
index 7dfa53efdabb..6504435fada3 100644
--- a/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml
+++ b/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml
@@ -21,13 +21,15 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
- android:padding="16dp" >
+ android:orientation="vertical" >
- <ScrollView
+ <ScrollView
android:layout_height="0dp"
android:layout_weight="1"
- android:layout_width="match_parent">
+ android:layout_width="match_parent"
+ android:padding="16dp"
+ android:clipToPadding="false" >
+
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
@@ -76,24 +78,29 @@
</LinearLayout>
</ScrollView>
+ <!-- button bar divider -->
+ <View android:background="?android:attr/dividerHorizontal"
+ android:layout_height="1dp"
+ android:layout_width="match_parent" />
+
+ <!-- button bar -->
<LinearLayout android:orientation="horizontal"
+ style="?android:attr/buttonBarStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom">
- <Button android:id="@+id/button_allow"
- android:filterTouchesWhenObscured="true"
- android:text="@string/allow_backup_button_label"
- android:layout_below="@id/package_name"
+ <Button android:id="@+id/button_deny"
+ style="?android:attr/buttonBarButtonStyle"
+ android:text="@string/deny_backup_button_label"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1" />
- <Button android:id="@+id/button_deny"
- android:text="@string/deny_backup_button_label"
- android:layout_below="@id/package_name"
- android:layout_toRightOf="@id/button_allow"
- android:layout_alignTop="@id/button_allow"
+ <Button android:id="@+id/button_allow"
+ style="?android:attr/buttonBarButtonStyle"
+ android:filterTouchesWhenObscured="true"
+ android:text="@string/allow_backup_button_label"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1" />
diff --git a/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml b/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml
index 4927cbb7c9d3..3522e7cb2ef8 100644
--- a/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml
+++ b/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml
@@ -76,24 +76,29 @@
</LinearLayout>
</ScrollView>
+ <!-- button bar divider -->
+ <View android:background="?android:attr/dividerHorizontal"
+ android:layout_height="1dp"
+ android:layout_width="match_parent" />
+
+ <!-- button bar -->
<LinearLayout android:orientation="horizontal"
+ style="?android:attr/buttonBarStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom">
- <Button android:id="@+id/button_allow"
- android:filterTouchesWhenObscured="true"
- android:text="@string/allow_restore_button_label"
- android:layout_below="@id/package_name"
+ <Button android:id="@+id/button_deny"
+ style="?android:attr/buttonBarButtonStyle"
+ android:text="@string/deny_restore_button_label"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1" />
- <Button android:id="@+id/button_deny"
- android:text="@string/deny_restore_button_label"
- android:layout_below="@id/package_name"
- android:layout_toRightOf="@id/button_allow"
- android:layout_alignTop="@id/button_allow"
+ <Button android:id="@+id/button_allow"
+ style="?android:attr/buttonBarButtonStyle"
+ android:filterTouchesWhenObscured="true"
+ android:text="@string/allow_restore_button_label"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1" />
diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java
index f65a62f1c665..5448e0b1dc9b 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
//