Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3851fa9c authored by Christopher Tate's avatar Christopher Tate
Browse files

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
parent e83af902
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -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
            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" />
+14 −9
Original line number Diff line number Diff line
@@ -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" />
+33 −7
Original line number Diff line number Diff line
@@ -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
        //