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

Commit fa48ea40 authored by Steve McKay's avatar Steve McKay
Browse files

Improved encapsulation.

Eliminate public bindController holes.
Reduce visibility of add/remove/intersect methods.
Introduce new MutableSelection class that can be used by clients to manipulate copies of selection.

Bug: 64847011
Test: Passing.
Change-Id: I7dad0848a40f2cf82d768ab36fc935b279cd5ec7
parent 2d19a69f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ import com.android.documentsui.queries.SearchViewManager;
import com.android.documentsui.roots.GetRootDocumentTask;
import com.android.documentsui.roots.LoadRootTask;
import com.android.documentsui.roots.ProvidersAccess;
import com.android.documentsui.selection.Selection;
import com.android.documentsui.selection.MutableSelection;
import com.android.documentsui.selection.SelectionManager;
import com.android.documentsui.sidebar.EjectRootTask;
import com.android.documentsui.ui.Snackbars;
@@ -532,8 +532,8 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
        loadRoot(Shared.getDefaultRootUri(mActivity));
    }

    protected Selection getStableSelection() {
        Selection selection = new Selection();
    protected MutableSelection getStableSelection() {
        MutableSelection selection = new MutableSelection();
        mSelectionMgr.copySelection(selection);
        return selection;
    }
+0 −2
Original line number Diff line number Diff line
@@ -145,9 +145,7 @@ public class ActionModeController
        mActionMode = null;
        mMenu = null;

        // clear selection
        mSelectionMgr.clearSelection();
        mSelected.clear();

        // Reset window title back to activity title, i.e. Root name
        mActivity.getWindow().setTitle(mActivity.getTitle());
+0 −5
Original line number Diff line number Diff line
@@ -54,11 +54,6 @@ public final class DocsSelectionManager implements SelectionManager {
        return this;
    }

    @Override
    public void bindController(BandController controller) {
        mDelegate.bindController(controller);
    }

    @Override
    public void addEventListener(EventListener listener) {
        mDelegate.addEventListener(listener);
+3 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.Events;
import com.android.documentsui.base.Events.InputEvent;
import com.android.documentsui.base.State;
import com.android.documentsui.selection.MutableSelection;
import com.android.documentsui.selection.Selection;
import com.android.documentsui.selection.SelectionManager;

@@ -150,8 +151,8 @@ interface DragStartListener {
         * coordinates of the event, return a valid selection for drag and drop operation
         */
        @VisibleForTesting
        Selection getSelectionToBeCopied(String modelId, InputEvent event) {
            Selection selection = new Selection();
        MutableSelection getSelectionToBeCopied(String modelId, InputEvent event) {
            MutableSelection selection = new MutableSelection();
            // If CTRL-key is held down and there's other existing selection, add item to
            // selection (if not already selected)
            if (event.isCtrlKeyDown() && !mSelectionMgr.getSelection().contains(modelId)
+2 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.documentsui.files.ActionHandler.Addons;
import com.android.documentsui.inspector.InspectorActivity;
import com.android.documentsui.queries.SearchViewManager;
import com.android.documentsui.roots.ProvidersAccess;
import com.android.documentsui.selection.MutableSelection;
import com.android.documentsui.selection.Selection;
import com.android.documentsui.services.FileOperation;
import com.android.documentsui.services.FileOperationService;
@@ -220,7 +221,7 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa
    }

    private Selection getSelectedOrFocused() {
        final Selection selection = this.getStableSelection();
        final MutableSelection selection = this.getStableSelection();
        if (selection.isEmpty()) {
            String focusModelId = mFocusHandler.getFocusModelId();
            if (focusModelId != null) {
Loading