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

Commit 992b220d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9f5900ba,Ie861d3e8

* changes:
  Rename BandController. Make GridModel top level.
  Move ContentLock and ViewAutoScroller into sel pkg.
parents 789533ef fcff0b0a
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.documentsui.roots.LoadRootTask;
import com.android.documentsui.roots.ProvidersAccess;
import com.android.documentsui.selection.MutableSelection;
import com.android.documentsui.selection.SelectionManager;
import com.android.documentsui.selection.addons.ContentLock;
import com.android.documentsui.sidebar.EjectRootTask;
import com.android.documentsui.ui.Snackbars;

@@ -101,7 +102,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>

    private Runnable mDisplayStateChangedListener;

    private DirectoryReloadLock mDirectoryReloadLock;
    private ContentLock mContentLock;

    @Override
    public void registerDisplayStateChangedListener(Runnable l) {
@@ -539,8 +540,8 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
    }

    @Override
    public ActionHandler reset(DirectoryReloadLock reloadLock) {
        mDirectoryReloadLock = reloadLock;
    public ActionHandler reset(ContentLock reloadLock) {
        mContentLock = reloadLock;
        mActivity.getLoaderManager().destroyLoader(LOADER_ID);
        return this;
    }
@@ -588,7 +589,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
                        contentsUri,
                        mState.sortModel,
                        mInjector.fileTypeLookup,
                        mDirectoryReloadLock,
                        mContentLock,
                        mSearchMgr.isSearching());
            }
        }
+2 −3
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.documentsui;
import android.annotation.IntDef;
import android.app.PendingIntent;
import android.content.ContentProvider;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
@@ -30,7 +29,7 @@ import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.dirlist.DocumentDetails;
import com.android.documentsui.selection.Selection;
import com.android.documentsui.selection.addons.ContentLock;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -158,5 +157,5 @@ public interface ActionHandler {
     * Allow action handler to be initialized in a new scope.
     * @return this
     */
    <T extends ActionHandler> T reset(DirectoryReloadLock reloadLock);
    <T extends ActionHandler> T reset(ContentLock contentLock);
}
+5 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.documentsui.base.FilteringCursorWrapper;
import com.android.documentsui.base.Lookup;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.roots.RootCursorWrapper;
import com.android.documentsui.selection.addons.ContentLock;
import com.android.documentsui.sorting.SortModel;

import libcore.io.IoUtils;
@@ -74,7 +75,7 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {
            Uri uri,
            SortModel model,
            Lookup<String, String> fileTypeLookup,
            DirectoryReloadLock lock,
            ContentLock lock,
            boolean inSearchMode) {

        super(context, ProviderExecutor.forAuthority(root.authority));
@@ -226,10 +227,10 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {
    }

    private static final class LockingContentObserver extends ContentObserver {
        private final DirectoryReloadLock mLock;
        private final ContentLock mLock;
        private final Runnable mContentChangedCallback;

        public LockingContentObserver(DirectoryReloadLock lock, Runnable contentChangedCallback) {
        public LockingContentObserver(ContentLock lock, Runnable contentChangedCallback) {
            super(new Handler(Looper.getMainLooper()));
            mLock = lock;
            mContentChangedCallback = contentChangedCallback;
@@ -242,7 +243,7 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {

        @Override
        public void onChange(boolean selfChange) {
            mLock.tryUpdate(mContentChangedCallback);
            mLock.runWhenUnlocked(mContentChangedCallback);
        }
    }
}
+9 −7
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.documentsui.dirlist.DocumentsAdapter;
import com.android.documentsui.prefs.ScopedPreferences;
import com.android.documentsui.queries.SearchViewManager;
import com.android.documentsui.selection.SelectionManager;
import com.android.documentsui.selection.addons.ContentLock;
import com.android.documentsui.ui.DialogController;
import com.android.documentsui.ui.MessageBuilder;
import com.android.internal.annotations.VisibleForTesting;
@@ -131,20 +132,21 @@ public class Injector<T extends ActionHandler> {
    /**
     * Obtains action handler and resets it if necessary.
     *
     * @param reloadLock the lock held by
     *            {@link com.android.documentsui.selection.addons.BandController} to prevent loader
     *            from updating result during band selection. May be {@code null} if called from
     *            {@link com.android.documentsui.sidebar.RootsFragment}.
     * @param contentLock the lock held by
     *            {@link com.android.documentsui.selection.addons.BandSelector} and
     *            {@link com.android.documentsui.selection.addons.GestureSelector} to prevent loader
     *            from updating result during band/gesture selection. May be {@code null} if called
     *            from {@link com.android.documentsui.sidebar.RootsFragment}.
     * @return the action handler
     */
    public T getActionHandler(@Nullable DirectoryReloadLock reloadLock) {
    public T getActionHandler(@Nullable ContentLock contentLock) {

        // provide our friend, RootsFragment, early access to this special feature!
        if (reloadLock == null) {
        if (contentLock == null) {
            return actions;
        }

        return actions.reset(reloadLock);
        return actions.reset(contentLock);
    }

    /**
+11 −8
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ import com.android.documentsui.ActionHandler;
import com.android.documentsui.ActionModeController;
import com.android.documentsui.BaseActivity;
import com.android.documentsui.BaseActivity.RetainedState;
import com.android.documentsui.DirectoryReloadLock;
import com.android.documentsui.DocumentsApplication;
import com.android.documentsui.FocusManager;
import com.android.documentsui.Injector;
@@ -93,7 +92,8 @@ import com.android.documentsui.picker.PickActivity;
import com.android.documentsui.selection.Selection;
import com.android.documentsui.selection.SelectionManager;
import com.android.documentsui.selection.SelectionManager.SelectionPredicate;
import com.android.documentsui.selection.addons.BandController;
import com.android.documentsui.selection.addons.BandSelector;
import com.android.documentsui.selection.addons.ContentLock;
import com.android.documentsui.selection.addons.GestureSelector;
import com.android.documentsui.services.FileOperation;
import com.android.documentsui.services.FileOperationService;
@@ -159,7 +159,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On

    private SelectionMetadata mSelectionMetadata;
    private UserInputHandler<InputEvent> mInputHandler;
    private @Nullable BandController mBandController;
    private @Nullable BandSelector mBandController;
    private @Nullable DragHoverListener mDragHoverListener;
    private IconHelper mIconHelper;
    private SwipeRefreshLayout mRefreshLayout;
@@ -176,7 +176,9 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
    private View mProgressBar;

    private DirectoryState mLocalState;
    private DirectoryReloadLock mReloadLock = new DirectoryReloadLock();

    // Blocks loading/reloading of content while user is actively making selection.
    private ContentLock mContentLock = new ContentLock();

    private Runnable mBandSelectStarted;

@@ -344,7 +346,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On

        mSelectionMgr = mInjector.getSelectionManager(mAdapter, selectionPredicate);
        mFocusManager = mInjector.getFocusManager(mRecView, mModel);
        mActions = mInjector.getActionHandler(mReloadLock);
        mActions = mInjector.getActionHandler(mContentLock);

        mRecView.setAccessibilityDelegateCompat(
                new AccessibilityEventRouter(mRecView,
@@ -352,15 +354,16 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
        mSelectionMetadata = new SelectionMetadata(mModel::getItem);
        mSelectionMgr.addEventListener(mSelectionMetadata);

        GestureSelector gestureSel = GestureSelector.create(mSelectionMgr, mRecView, mReloadLock);
        GestureSelector gestureSel =
                GestureSelector.create(mSelectionMgr, mRecView, mContentLock);

        if (mState.allowMultiple) {
            mBandController = new BandController(
            mBandController = new BandSelector(
                    mRecView,
                    mAdapter,  // stableIds provider.
                    mSelectionMgr,
                    selectionPredicate,
                    mReloadLock);
                    mContentLock);

            mBandSelectStarted = mFocusManager::clearFocus;
            mBandController.addBandSelectStartedListener(mBandSelectStarted);
Loading