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

Commit 5f2a9bab authored by Garfield Tan's avatar Garfield Tan
Browse files

Apply correct restoring logic.

We need to continue on the work left from last time, rather than blindly
believe everything is restored by Android.

Test: Manual test & auto test.
Bug: 38321082
Change-Id: Ic9f80ab16a203a1526c7d23d86512b841c750366
parent 98d558ea
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -508,6 +508,14 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>

    protected abstract void launchToDefaultLocation();

    protected void restoreRootAndDirectory() {
        if (!mState.stack.getRoot().isRecents() && mState.stack.isEmpty()) {
            mActivity.onRootPicked(mState.stack.getRoot());
        } else {
            mActivity.restoreRootAndDirectory();
        }
    }

    protected final void loadHomeDir() {
        loadRoot(Shared.getDefaultRootUri(mActivity));
    }
@@ -588,6 +596,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
     * from our concrete activity implementations.
     */
    public interface CommonAddons {
        void restoreRootAndDirectory();
        void refreshCurrentRootAndDirectory(@AnimationType int anim);
        void onRootPicked(RootInfo root);
        // TODO: Move this to PickAddons as multi-document picking is exclusive to that activity.
+11 −0
Original line number Diff line number Diff line
@@ -388,6 +388,17 @@ public abstract class BaseActivity
        mNavigator.update();
    }

    @Override
    public void restoreRootAndDirectory() {
        // We're trying to restore stuff in document stack from saved instance. If we didn't have a
        // chance to spawn a fragment before we need to do it now. However if we spawned a fragment
        // already, system will automatically restore the fragment for us so we don't need to do
        // that manually this time.
        if (DirectoryFragment.get(getFragmentManager()) == null) {
            refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE);
        }
    }

    /**
     * Refreshes the content of the director and the menu/action bar.
     * The current directory name and selection will get updated.
+1 −0
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa
        // previously stored state.
        if (mState.stack.isInitialized()) {
            if (DEBUG) Log.d(TAG, "Stack already resolved for uri: " + intent.getData());
            restoreRootAndDirectory();
            return;
        }

+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T
        // previously stored state.
        if (mState.stack.isInitialized()) {
            if (DEBUG) Log.d(TAG, "Stack already resolved for uri: " + intent.getData());
            restoreRootAndDirectory();
            return;
        }

+7 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public abstract class TestActivity extends AbstractBase {
    public TestEventListener<Intent> startService;
    public TestEventListener<Pair<IntentSender, Integer>> startIntentSender;
    public TestEventListener<RootInfo> rootPicked;
    public TestEventListener<Void> restoreRootAndDirectory;
    public TestEventListener<Integer> refreshCurrentRootAndDirectory;
    public TestEventListener<Boolean> setRootsDrawerOpen;
    public TestEventListener<Uri> notifyDirectoryNavigated;
@@ -83,6 +84,7 @@ public abstract class TestActivity extends AbstractBase {
        startService = new TestEventListener<>();
        startIntentSender = new TestEventListener<>();
        rootPicked = new TestEventListener<>();
        restoreRootAndDirectory = new TestEventListener<>();
        refreshCurrentRootAndDirectory =  new TestEventListener<>();
        setRootsDrawerOpen = new TestEventListener<>();
        notifyDirectoryNavigated = new TestEventListener<>();
@@ -152,6 +154,11 @@ public abstract class TestActivity extends AbstractBase {
        notifyDirectoryNavigated.accept(uri);
    }

    @Override
    public final void restoreRootAndDirectory() {
        restoreRootAndDirectory.accept(null);
    }

    @Override
    public final void refreshCurrentRootAndDirectory(int anim) {
        refreshCurrentRootAndDirectory.accept(anim);
Loading