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

Commit cdbbbe05 authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski
Browse files

Prevent double recreation of the failure dialog in DocumentsUI.

DialogFragment takes care of recreation on configuration change, so no
need to recreate it manually.

Bug: 26322214
Change-Id: I7c50a1c5bb1ba9fab34f6e8d31ed1e23e7edfbb7
parent 3a4922bb
Loading
Loading
Loading
Loading
+39 −41
Original line number Diff line number Diff line
@@ -89,22 +89,21 @@ public class FilesActivity extends BaseActivity {

        RootsFragment.show(getFragmentManager(), null);

        final Intent intent = getIntent();
        final Uri uri = intent.getData();

        if (mState.restored) {
            if (DEBUG) Log.d(TAG, "Restored instance for uri: " + getIntent().getData());
            if (DEBUG) Log.d(TAG, "Stack already resolved for uri: " + intent.getData());
            onCurrentDirectoryChanged(ANIM_NONE);
        } else {
            Intent intent = getIntent();
            Uri uri = intent.getData();

            if (DEBUG) Log.d(TAG, "Creating new instance for uri: " + uri);
        } else if (!mState.stack.isEmpty()) {
            // If a non-empty stack is present in our state it was read (presumably)
            // from EXTRA_STACK intent extra. In this case, we'll skip other means of
            // loading or restoring the stack.
            if (!mState.stack.isEmpty()) {
                if (DEBUG) Log.d(TAG, "Launching with non-empty stack.");
            //
            // When restoring from a stack, if a URI is present, it should only ever
            // be a launch URI. Launch URIs support sensible activity management, but
            // don't specify a real content target.
            if (DEBUG) Log.d(TAG, "Launching with non-empty stack.");
            checkState(uri == null || LauncherActivity.isLaunchUri(uri));
            onCurrentDirectoryChanged(ANIM_NONE);
        } else if (DocumentsContract.isRootUri(this, uri)) {
@@ -116,17 +115,17 @@ public class FilesActivity extends BaseActivity {
        } else {
            if (DEBUG) Log.d(TAG, "Launching into Home directory.");
            // If all else fails, try to load "Home" directory.
                uri = DocumentsContract.buildHomeUri();
                new RestoreRootTask(uri).executeOnExecutor(
                        ProviderExecutor.forAuthority(uri.getAuthority()));
            final Uri homeUri = DocumentsContract.buildHomeUri();
            new RestoreRootTask(homeUri).executeOnExecutor(
                    ProviderExecutor.forAuthority(homeUri.getAuthority()));
        }

            // TODO: Ensure we're handling CopyService errors correctly across all activities.
            // Show a failure dialog if there was a failed operation.
        final int failure = intent.getIntExtra(CopyService.EXTRA_FAILURE, 0);
        final int transferMode = intent.getIntExtra(CopyService.EXTRA_TRANSFER_MODE,
                CopyService.TRANSFER_MODE_COPY);
            if (failure != 0) {
        // DialogFragment takes care of restoring the dialog on configuration change.
        // Only show it manually for the first time (icicle is null).
        if (icicle == null && failure != 0) {
            final ArrayList<DocumentInfo> failedSrcList =
                    intent.getParcelableArrayListExtra(CopyService.EXTRA_SRC_LIST);
            FailureDialogFragment.show(
@@ -137,7 +136,6 @@ public class FilesActivity extends BaseActivity {
                    transferMode);
        }
    }
    }

    @Override
    State buildState() {