Loading core/java/android/provider/DocumentsContract.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -379,8 +379,18 @@ public final class DocumentsContract { * @see DocumentsProvider#queryChildDocuments(String, String[], String) * @see DocumentsProvider#queryChildDocuments(String, String[], String) * @hide * @hide */ */ public static final int FLAG_ARCHIVE = 1 << 15; public static final int FLAG_ARCHIVE = 1 << 15; /** * Flag indicating that a document is not complete, likely its * contents are being downloaded. Partial files cannot be opened, * copied, moved in the UI. But they can be deleted and retried * if they represent a failed download. * * @see #COLUMN_FLAGS * @hide */ public static final int FLAG_PARTIAL = 1 << 16; } } /** /** Loading packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java +12 −3 Original line number Original line Diff line number Diff line Loading @@ -440,6 +440,7 @@ public class DirectoryFragment extends Fragment private Selection mSelected = new Selection(); private Selection mSelected = new Selection(); private ActionMode mActionMode; private ActionMode mActionMode; private int mNoCopyCount = 0; private int mNoDeleteCount = 0; private int mNoDeleteCount = 0; private int mNoRenameCount = -1; private int mNoRenameCount = -1; private Menu mMenu; private Menu mMenu; Loading Loading @@ -471,6 +472,9 @@ public class DirectoryFragment extends Fragment // triggered on "silent" selection updates (i.e. we might be reacting to unfinalized // triggered on "silent" selection updates (i.e. we might be reacting to unfinalized // selection changes here) // selection changes here) final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS); final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS); if ((docFlags & Document.FLAG_PARTIAL) != 0) { mNoCopyCount += selected ? 1 : -1; } if ((docFlags & Document.FLAG_SUPPORTS_DELETE) == 0 if ((docFlags & Document.FLAG_SUPPORTS_DELETE) == 0 && (docFlags & Document.FLAG_SUPPORTS_DELETE) == 0) { && (docFlags & Document.FLAG_SUPPORTS_DELETE) == 0) { mNoDeleteCount += selected ? 1 : -1; mNoDeleteCount += selected ? 1 : -1; Loading Loading @@ -537,19 +541,24 @@ public class DirectoryFragment extends Fragment return true; return true; } } boolean canRenameSelection() { boolean canCopySelection() { return mNoRenameCount == 0 && mSelectionManager.getSelection().size() == 1; return mNoCopyCount == 0; } } boolean canDeleteSelection() { boolean canDeleteSelection() { return mNoDeleteCount == 0; return mNoDeleteCount == 0; } } boolean canRenameSelection() { return mNoRenameCount == 0 && mSelectionManager.getSelection().size() == 1; } private void updateActionMenu() { private void updateActionMenu() { assert(mMenu != null); assert(mMenu != null); // Delegate update logic to our owning action, since specialized logic is desired. // Delegate update logic to our owning action, since specialized logic is desired. mTuner.updateActionMenu(mMenu, mType, canDeleteSelection(), canRenameSelection()); mTuner.updateActionMenu( mMenu, mType, canCopySelection(), canDeleteSelection(), canRenameSelection()); Menus.disableHiddenItems(mMenu); Menus.disableHiddenItems(mMenu); } } Loading packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java +15 −8 Original line number Original line Diff line number Diff line Loading @@ -58,9 +58,9 @@ public abstract class FragmentTuner { } } } } public abstract void updateActionMenu( public abstract void updateActionMenu( Menu menu, @ResultType int dirType, boolean canDelete, boolean canRename); Menu menu, @ResultType int dirType, boolean canCopy, boolean canDelete, boolean canRename); // Subtly different from isDocumentEnabled. The reason may be illuminated as follows. // Subtly different from isDocumentEnabled. The reason may be illuminated as follows. // A folder is enabled such that it may be double clicked, even in settings // A folder is enabled such that it may be double clicked, even in settings Loading Loading @@ -140,7 +140,8 @@ public abstract class FragmentTuner { @Override @Override public void updateActionMenu( public void updateActionMenu( Menu menu, @ResultType int dirType, boolean canDelete, boolean canRename) { Menu menu, @ResultType int dirType, boolean canCopy, boolean canDelete, boolean canRename) { MenuItem open = menu.findItem(R.id.menu_open); MenuItem open = menu.findItem(R.id.menu_open); MenuItem share = menu.findItem(R.id.menu_share); MenuItem share = menu.findItem(R.id.menu_share); Loading Loading @@ -198,22 +199,28 @@ public abstract class FragmentTuner { @Override @Override public void updateActionMenu( public void updateActionMenu( Menu menu, @ResultType int dirType, boolean canDelete, boolean canRename) { Menu menu, @ResultType int dirType, boolean canCopy, boolean canDelete, boolean canRename) { MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard); MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard); MenuItem paste = menu.findItem(R.id.menu_paste_from_clipboard); MenuItem paste = menu.findItem(R.id.menu_paste_from_clipboard); copy.setEnabled(dirType != DirectoryFragment.TYPE_RECENT_OPEN); copy.setEnabled(canCopy); MenuItem rename = menu.findItem(R.id.menu_rename); MenuItem rename = menu.findItem(R.id.menu_rename); MenuItem moveTo = menu.findItem(R.id.menu_move_to); MenuItem copyTo = menu.findItem(R.id.menu_copy_to); copyTo.setVisible(true); moveTo.setVisible(true); rename.setVisible(true); rename.setVisible(true); copyTo.setEnabled(canCopy); moveTo.setEnabled(canCopy && canDelete); rename.setEnabled(canRename); rename.setEnabled(canRename); menu.findItem(R.id.menu_share).setVisible(true); menu.findItem(R.id.menu_share).setVisible(true); menu.findItem(R.id.menu_delete).setVisible(canDelete); menu.findItem(R.id.menu_delete).setVisible(canDelete); menu.findItem(R.id.menu_open).setVisible(false); menu.findItem(R.id.menu_open).setVisible(false); menu.findItem(R.id.menu_copy_to).setVisible(true); menu.findItem(R.id.menu_move_to).setVisible(true); menu.findItem(R.id.menu_move_to).setEnabled(canDelete); Menus.disableHiddenItems(menu, copy, paste); Menus.disableHiddenItems(menu, copy, paste); } } Loading packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,6 @@ public class DocumentInfo implements Durable, Parcelable { summary = null; summary = null; size = -1; size = -1; icon = 0; icon = 0; derivedUri = null; derivedUri = null; } } Loading Loading @@ -210,6 +209,7 @@ public class DocumentInfo implements Durable, Parcelable { + ", isContainer=" + isContainer() + ", isContainer=" + isContainer() + ", isDirectory=" + isDirectory() + ", isDirectory=" + isDirectory() + ", isArchive=" + isArchive() + ", isArchive=" + isArchive() + ", isPartial=" + isPartial() + ", isVirtualDocument=" + isVirtualDocument() + ", isVirtualDocument=" + isVirtualDocument() + ", isDeleteSupported=" + isDeleteSupported() + ", isDeleteSupported=" + isDeleteSupported() + ", isCreateSupported=" + isCreateSupported() + ", isCreateSupported=" + isCreateSupported() Loading Loading @@ -249,6 +249,10 @@ public class DocumentInfo implements Durable, Parcelable { return (flags & Document.FLAG_ARCHIVE) != 0; return (flags & Document.FLAG_ARCHIVE) != 0; } } public boolean isPartial() { return (flags & Document.FLAG_PARTIAL) != 0; } public boolean isContainer() { public boolean isContainer() { return isDirectory() || isArchive(); return isDirectory() || isArchive(); } } Loading Loading
core/java/android/provider/DocumentsContract.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -379,8 +379,18 @@ public final class DocumentsContract { * @see DocumentsProvider#queryChildDocuments(String, String[], String) * @see DocumentsProvider#queryChildDocuments(String, String[], String) * @hide * @hide */ */ public static final int FLAG_ARCHIVE = 1 << 15; public static final int FLAG_ARCHIVE = 1 << 15; /** * Flag indicating that a document is not complete, likely its * contents are being downloaded. Partial files cannot be opened, * copied, moved in the UI. But they can be deleted and retried * if they represent a failed download. * * @see #COLUMN_FLAGS * @hide */ public static final int FLAG_PARTIAL = 1 << 16; } } /** /** Loading
packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java +12 −3 Original line number Original line Diff line number Diff line Loading @@ -440,6 +440,7 @@ public class DirectoryFragment extends Fragment private Selection mSelected = new Selection(); private Selection mSelected = new Selection(); private ActionMode mActionMode; private ActionMode mActionMode; private int mNoCopyCount = 0; private int mNoDeleteCount = 0; private int mNoDeleteCount = 0; private int mNoRenameCount = -1; private int mNoRenameCount = -1; private Menu mMenu; private Menu mMenu; Loading Loading @@ -471,6 +472,9 @@ public class DirectoryFragment extends Fragment // triggered on "silent" selection updates (i.e. we might be reacting to unfinalized // triggered on "silent" selection updates (i.e. we might be reacting to unfinalized // selection changes here) // selection changes here) final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS); final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS); if ((docFlags & Document.FLAG_PARTIAL) != 0) { mNoCopyCount += selected ? 1 : -1; } if ((docFlags & Document.FLAG_SUPPORTS_DELETE) == 0 if ((docFlags & Document.FLAG_SUPPORTS_DELETE) == 0 && (docFlags & Document.FLAG_SUPPORTS_DELETE) == 0) { && (docFlags & Document.FLAG_SUPPORTS_DELETE) == 0) { mNoDeleteCount += selected ? 1 : -1; mNoDeleteCount += selected ? 1 : -1; Loading Loading @@ -537,19 +541,24 @@ public class DirectoryFragment extends Fragment return true; return true; } } boolean canRenameSelection() { boolean canCopySelection() { return mNoRenameCount == 0 && mSelectionManager.getSelection().size() == 1; return mNoCopyCount == 0; } } boolean canDeleteSelection() { boolean canDeleteSelection() { return mNoDeleteCount == 0; return mNoDeleteCount == 0; } } boolean canRenameSelection() { return mNoRenameCount == 0 && mSelectionManager.getSelection().size() == 1; } private void updateActionMenu() { private void updateActionMenu() { assert(mMenu != null); assert(mMenu != null); // Delegate update logic to our owning action, since specialized logic is desired. // Delegate update logic to our owning action, since specialized logic is desired. mTuner.updateActionMenu(mMenu, mType, canDeleteSelection(), canRenameSelection()); mTuner.updateActionMenu( mMenu, mType, canCopySelection(), canDeleteSelection(), canRenameSelection()); Menus.disableHiddenItems(mMenu); Menus.disableHiddenItems(mMenu); } } Loading
packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java +15 −8 Original line number Original line Diff line number Diff line Loading @@ -58,9 +58,9 @@ public abstract class FragmentTuner { } } } } public abstract void updateActionMenu( public abstract void updateActionMenu( Menu menu, @ResultType int dirType, boolean canDelete, boolean canRename); Menu menu, @ResultType int dirType, boolean canCopy, boolean canDelete, boolean canRename); // Subtly different from isDocumentEnabled. The reason may be illuminated as follows. // Subtly different from isDocumentEnabled. The reason may be illuminated as follows. // A folder is enabled such that it may be double clicked, even in settings // A folder is enabled such that it may be double clicked, even in settings Loading Loading @@ -140,7 +140,8 @@ public abstract class FragmentTuner { @Override @Override public void updateActionMenu( public void updateActionMenu( Menu menu, @ResultType int dirType, boolean canDelete, boolean canRename) { Menu menu, @ResultType int dirType, boolean canCopy, boolean canDelete, boolean canRename) { MenuItem open = menu.findItem(R.id.menu_open); MenuItem open = menu.findItem(R.id.menu_open); MenuItem share = menu.findItem(R.id.menu_share); MenuItem share = menu.findItem(R.id.menu_share); Loading Loading @@ -198,22 +199,28 @@ public abstract class FragmentTuner { @Override @Override public void updateActionMenu( public void updateActionMenu( Menu menu, @ResultType int dirType, boolean canDelete, boolean canRename) { Menu menu, @ResultType int dirType, boolean canCopy, boolean canDelete, boolean canRename) { MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard); MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard); MenuItem paste = menu.findItem(R.id.menu_paste_from_clipboard); MenuItem paste = menu.findItem(R.id.menu_paste_from_clipboard); copy.setEnabled(dirType != DirectoryFragment.TYPE_RECENT_OPEN); copy.setEnabled(canCopy); MenuItem rename = menu.findItem(R.id.menu_rename); MenuItem rename = menu.findItem(R.id.menu_rename); MenuItem moveTo = menu.findItem(R.id.menu_move_to); MenuItem copyTo = menu.findItem(R.id.menu_copy_to); copyTo.setVisible(true); moveTo.setVisible(true); rename.setVisible(true); rename.setVisible(true); copyTo.setEnabled(canCopy); moveTo.setEnabled(canCopy && canDelete); rename.setEnabled(canRename); rename.setEnabled(canRename); menu.findItem(R.id.menu_share).setVisible(true); menu.findItem(R.id.menu_share).setVisible(true); menu.findItem(R.id.menu_delete).setVisible(canDelete); menu.findItem(R.id.menu_delete).setVisible(canDelete); menu.findItem(R.id.menu_open).setVisible(false); menu.findItem(R.id.menu_open).setVisible(false); menu.findItem(R.id.menu_copy_to).setVisible(true); menu.findItem(R.id.menu_move_to).setVisible(true); menu.findItem(R.id.menu_move_to).setEnabled(canDelete); Menus.disableHiddenItems(menu, copy, paste); Menus.disableHiddenItems(menu, copy, paste); } } Loading
packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,6 @@ public class DocumentInfo implements Durable, Parcelable { summary = null; summary = null; size = -1; size = -1; icon = 0; icon = 0; derivedUri = null; derivedUri = null; } } Loading Loading @@ -210,6 +209,7 @@ public class DocumentInfo implements Durable, Parcelable { + ", isContainer=" + isContainer() + ", isContainer=" + isContainer() + ", isDirectory=" + isDirectory() + ", isDirectory=" + isDirectory() + ", isArchive=" + isArchive() + ", isArchive=" + isArchive() + ", isPartial=" + isPartial() + ", isVirtualDocument=" + isVirtualDocument() + ", isVirtualDocument=" + isVirtualDocument() + ", isDeleteSupported=" + isDeleteSupported() + ", isDeleteSupported=" + isDeleteSupported() + ", isCreateSupported=" + isCreateSupported() + ", isCreateSupported=" + isCreateSupported() Loading Loading @@ -249,6 +249,10 @@ public class DocumentInfo implements Durable, Parcelable { return (flags & Document.FLAG_ARCHIVE) != 0; return (flags & Document.FLAG_ARCHIVE) != 0; } } public boolean isPartial() { return (flags & Document.FLAG_PARTIAL) != 0; } public boolean isContainer() { public boolean isContainer() { return isDirectory() || isArchive(); return isDirectory() || isArchive(); } } Loading