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

Commit eecb915c authored by Ben Lin's avatar Ben Lin
Browse files

Proper ActionMode clean up when spring opening directories.

Since ActionMode has an assert that it should be null when being reset,
there was a crash for the case of spring opening directories due to
actionMode.finish() not properly called before opening the directory.
This now ensures actionMode.finish() is called beforehand.

Test: Wrote ActionHandlerTest#testSpringOpenDirectory.

Bug: 32749167
Change-Id: Ifa39e9fcf02f4f848ea5cf4f26b01280d32a47c0
parent 991f3882
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -138,6 +138,11 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
        mActivity.startActivity(intent);
    }

    @Override
    public void springOpenDirectory(DocumentInfo doc) {
        throw new UnsupportedOperationException("Can't spring open directories.");
    }

    @Override
    public void openSettings(RootInfo root) {
        throw new UnsupportedOperationException("Can't open settings.");
+7 −0
Original line number Diff line number Diff line
@@ -68,6 +68,13 @@ public interface ActionHandler {

    boolean openDocument(DocumentDetails doc);

    /**
     * This is called when user hovers over a doc for enough time during a drag n' drop, to open a
     * folder that accepts drop. We should only open a container that's not an archive, since archives
     * do not accept dropping.
     */
    void springOpenDirectory(DocumentInfo doc);

    void showChooserForDoc(DocumentInfo doc);

    void openContainerDocument(DocumentInfo doc);
+0 −7
Original line number Diff line number Diff line
@@ -383,13 +383,6 @@ public abstract class BaseActivity
        invalidateOptionsMenu();
    }

    /**
     * This is called when user hovers over a doc for enough time during a drag n' drop, to open a
     * folder that accepts drop. We should only open a container that's not an archive.
     */
    public void springOpenDirectory(DocumentInfo doc) {
    }

    private void reloadSearch(String query) {
        FragmentManager fm = getFragmentManager();
        RootInfo root = getCurrentRoot();
+1 −1
Original line number Diff line number Diff line
@@ -897,7 +897,7 @@ public class DirectoryFragment extends Fragment
    public void onViewHovered(View view) {
        BaseActivity activity = mActivity;
        if (getModelId(view) != null) {
           activity.springOpenDirectory(getDestination(view));
            mActions.springOpenDirectory(getDestination(view));
        }
        activity.setRootsDrawerOpen(false);
    }
+7 −0
Original line number Diff line number Diff line
@@ -173,6 +173,13 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa
        return false;
    }

    @Override
    public void springOpenDirectory(DocumentInfo doc) {
        assert(doc.isDirectory());
        mActionModeAddons.finishActionMode();
        openContainerDocument(doc);
    }

    @Override
    public boolean viewDocument(DocumentDetails details) {
        DocumentInfo doc = mModel.getDocument(details.getModelId());
Loading