Loading src/com/android/documentsui/AbstractActionHandler.java +16 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.documentsui.base.State; import com.android.documentsui.dirlist.AnimationView.AnimationType; import com.android.documentsui.dirlist.AnimationView; import com.android.documentsui.dirlist.DocumentDetails; import com.android.documentsui.dirlist.FocusHandler; import com.android.documentsui.files.LauncherActivity; import com.android.documentsui.queries.SearchViewManager; import com.android.documentsui.roots.LoadRootTask; Loading @@ -62,15 +63,18 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> protected final State mState; protected final RootsAccess mRoots; protected final DocumentsAccess mDocs; protected final FocusHandler mFocusHandler; protected final SelectionManager mSelectionMgr; protected final SearchViewManager mSearchMgr; protected final Lookup<String, Executor> mExecutors; public AbstractActionHandler( T activity, State state, RootsAccess roots, DocumentsAccess docs, FocusHandler focusHandler, SelectionManager selectionMgr, SearchViewManager searchMgr, Lookup<String, Executor> executors) { Loading @@ -78,6 +82,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> assert(activity != null); assert(state != null); assert(roots != null); assert(focusHandler != null); assert(selectionMgr != null); assert(searchMgr != null); assert(docs != null); Loading @@ -86,6 +91,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> mState = state; mRoots = roots; mDocs = docs; mFocusHandler = focusHandler; mSelectionMgr = selectionMgr; mSearchMgr = searchMgr; mExecutors = executors; Loading Loading @@ -231,6 +237,16 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> mActivity.refreshCurrentRootAndDirectory(anim); } @Override public void cutToClipboard() { throw new UnsupportedOperationException("Cut not supported!"); } @Override public void copyToClipboard() { throw new UnsupportedOperationException("Copy not supported!"); } @Override public void deleteSelectedDocuments() { throw new UnsupportedOperationException("Delete not supported!"); Loading src/com/android/documentsui/ActionHandler.java +7 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,13 @@ public interface ActionHandler { void openContainerDocument(DocumentInfo doc); void cutToClipboard(); void copyToClipboard(); /** * In general, selected = selection or single focused item */ void deleteSelectedDocuments(); void shareSelectedDocuments(); Loading src/com/android/documentsui/BaseActivity.java +8 −7 Original line number Diff line number Diff line Loading @@ -666,21 +666,22 @@ public abstract class BaseActivity<T extends ActionHandler> * locked, open/close it as appropriate. */ void toggleNavDrawerFocus() { boolean toogleHappened = false; if (mNavDrawerHasFocus) { mDrawer.setOpen(false); DirectoryFragment df = DirectoryFragment.get(getFragmentManager()); if (df != null) { df.requestFocus(); } assert (df != null); toogleHappened = df.requestFocus(); } else { mDrawer.setOpen(true); RootsFragment rf = RootsFragment.get(getFragmentManager()); if (rf != null) { rf.requestFocus(); } assert (rf != null); toogleHappened = rf.requestFocus(); } if (toogleHappened) { mNavDrawerHasFocus = !mNavDrawerHasFocus; } } /** * Pops the top entry off the directory stack, and returns the user to the previous directory. Loading src/com/android/documentsui/FocusManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,16 @@ public final class FocusManager implements FocusHandler { return mScope.lastFocusPosition; } @Override public @Nullable String getFocusModelId() { if (mScope.lastFocusPosition != RecyclerView.NO_POSITION) { DocumentHolder holder = (DocumentHolder) mScope.view .findViewHolderForAdapterPosition(mScope.lastFocusPosition); return holder.getModelId(); } return null; } /** * Finds the destination position where the focus should land for a given navigation event. * Loading src/com/android/documentsui/dirlist/DirectoryFragment.java +7 −31 Original line number Diff line number Diff line Loading @@ -633,11 +633,11 @@ public class DirectoryFragment extends Fragment return true; case R.id.menu_cut_to_clipboard: cutSelectedToClipboard(); mActions.cutToClipboard(); return true; case R.id.menu_copy_to_clipboard: copySelectedToClipboard(); mActions.copyToClipboard(); return true; case R.id.menu_paste_from_clipboard: Loading Loading @@ -838,34 +838,6 @@ public class DirectoryFragment extends Fragment mRecView.requestFocus(); } public void copySelectedToClipboard() { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_COPY_CLIPBOARD); Selection selection = mSelectionMgr.getSelection(new Selection()); if (selection.isEmpty()) { return; } mSelectionMgr.clearSelection(); mClipper.clipDocumentsForCopy(mModel::getItemUri, selection); Snackbars.showDocumentsClipped(getActivity(), selection.size()); } public void cutSelectedToClipboard() { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_CUT_CLIPBOARD); Selection selection = mSelectionMgr.getSelection(new Selection()); if (selection.isEmpty()) { return; } mSelectionMgr.clearSelection(); mClipper.clipDocumentsForCut(mModel::getItemUri, selection, mState.stack.peek()); Snackbars.showDocumentsClipped(getActivity(), selection.size()); } public void pasteFromClipboard() { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_PASTE_CLIPBOARD); Loading Loading @@ -920,8 +892,12 @@ public class DirectoryFragment extends Fragment /** * Attempts to restore focus on the directory listing. */ public void requestFocus() { public boolean requestFocus() { if (mSelectionMgr.hasSelection()) { return false; } mFocusManager.restoreLastFocus(); return true; } private void setupDragAndDropOnDocumentView(View view, Cursor cursor) { Loading Loading
src/com/android/documentsui/AbstractActionHandler.java +16 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.documentsui.base.State; import com.android.documentsui.dirlist.AnimationView.AnimationType; import com.android.documentsui.dirlist.AnimationView; import com.android.documentsui.dirlist.DocumentDetails; import com.android.documentsui.dirlist.FocusHandler; import com.android.documentsui.files.LauncherActivity; import com.android.documentsui.queries.SearchViewManager; import com.android.documentsui.roots.LoadRootTask; Loading @@ -62,15 +63,18 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> protected final State mState; protected final RootsAccess mRoots; protected final DocumentsAccess mDocs; protected final FocusHandler mFocusHandler; protected final SelectionManager mSelectionMgr; protected final SearchViewManager mSearchMgr; protected final Lookup<String, Executor> mExecutors; public AbstractActionHandler( T activity, State state, RootsAccess roots, DocumentsAccess docs, FocusHandler focusHandler, SelectionManager selectionMgr, SearchViewManager searchMgr, Lookup<String, Executor> executors) { Loading @@ -78,6 +82,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> assert(activity != null); assert(state != null); assert(roots != null); assert(focusHandler != null); assert(selectionMgr != null); assert(searchMgr != null); assert(docs != null); Loading @@ -86,6 +91,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> mState = state; mRoots = roots; mDocs = docs; mFocusHandler = focusHandler; mSelectionMgr = selectionMgr; mSearchMgr = searchMgr; mExecutors = executors; Loading Loading @@ -231,6 +237,16 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> mActivity.refreshCurrentRootAndDirectory(anim); } @Override public void cutToClipboard() { throw new UnsupportedOperationException("Cut not supported!"); } @Override public void copyToClipboard() { throw new UnsupportedOperationException("Copy not supported!"); } @Override public void deleteSelectedDocuments() { throw new UnsupportedOperationException("Delete not supported!"); Loading
src/com/android/documentsui/ActionHandler.java +7 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,13 @@ public interface ActionHandler { void openContainerDocument(DocumentInfo doc); void cutToClipboard(); void copyToClipboard(); /** * In general, selected = selection or single focused item */ void deleteSelectedDocuments(); void shareSelectedDocuments(); Loading
src/com/android/documentsui/BaseActivity.java +8 −7 Original line number Diff line number Diff line Loading @@ -666,21 +666,22 @@ public abstract class BaseActivity<T extends ActionHandler> * locked, open/close it as appropriate. */ void toggleNavDrawerFocus() { boolean toogleHappened = false; if (mNavDrawerHasFocus) { mDrawer.setOpen(false); DirectoryFragment df = DirectoryFragment.get(getFragmentManager()); if (df != null) { df.requestFocus(); } assert (df != null); toogleHappened = df.requestFocus(); } else { mDrawer.setOpen(true); RootsFragment rf = RootsFragment.get(getFragmentManager()); if (rf != null) { rf.requestFocus(); } assert (rf != null); toogleHappened = rf.requestFocus(); } if (toogleHappened) { mNavDrawerHasFocus = !mNavDrawerHasFocus; } } /** * Pops the top entry off the directory stack, and returns the user to the previous directory. Loading
src/com/android/documentsui/FocusManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,16 @@ public final class FocusManager implements FocusHandler { return mScope.lastFocusPosition; } @Override public @Nullable String getFocusModelId() { if (mScope.lastFocusPosition != RecyclerView.NO_POSITION) { DocumentHolder holder = (DocumentHolder) mScope.view .findViewHolderForAdapterPosition(mScope.lastFocusPosition); return holder.getModelId(); } return null; } /** * Finds the destination position where the focus should land for a given navigation event. * Loading
src/com/android/documentsui/dirlist/DirectoryFragment.java +7 −31 Original line number Diff line number Diff line Loading @@ -633,11 +633,11 @@ public class DirectoryFragment extends Fragment return true; case R.id.menu_cut_to_clipboard: cutSelectedToClipboard(); mActions.cutToClipboard(); return true; case R.id.menu_copy_to_clipboard: copySelectedToClipboard(); mActions.copyToClipboard(); return true; case R.id.menu_paste_from_clipboard: Loading Loading @@ -838,34 +838,6 @@ public class DirectoryFragment extends Fragment mRecView.requestFocus(); } public void copySelectedToClipboard() { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_COPY_CLIPBOARD); Selection selection = mSelectionMgr.getSelection(new Selection()); if (selection.isEmpty()) { return; } mSelectionMgr.clearSelection(); mClipper.clipDocumentsForCopy(mModel::getItemUri, selection); Snackbars.showDocumentsClipped(getActivity(), selection.size()); } public void cutSelectedToClipboard() { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_CUT_CLIPBOARD); Selection selection = mSelectionMgr.getSelection(new Selection()); if (selection.isEmpty()) { return; } mSelectionMgr.clearSelection(); mClipper.clipDocumentsForCut(mModel::getItemUri, selection, mState.stack.peek()); Snackbars.showDocumentsClipped(getActivity(), selection.size()); } public void pasteFromClipboard() { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_PASTE_CLIPBOARD); Loading Loading @@ -920,8 +892,12 @@ public class DirectoryFragment extends Fragment /** * Attempts to restore focus on the directory listing. */ public void requestFocus() { public boolean requestFocus() { if (mSelectionMgr.hasSelection()) { return false; } mFocusManager.restoreLastFocus(); return true; } private void setupDragAndDropOnDocumentView(View view, Cursor cursor) { Loading