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

Commit f44e5120 authored by Aga Wronska's avatar Aga Wronska Committed by android-build-merger
Browse files

Merge "Hide \'select all\' menu option when ALLOW_MULTIPLE intent is not...

Merge "Hide \'select all\' menu option when ALLOW_MULTIPLE intent is not passed in DocumentsActivity. Make \'select all\' select only enabled files." into nyc-dev
am: 2209860

* commit '2209860597ce73a45b3925d3bd71cf54e9fa6296':
  Hide 'select all' menu option when ALLOW_MULTIPLE intent is not passed in DocumentsActivity. Make 'select all' select only enabled files.

Change-Id: Iba4338bf85c954bb330911408da050cd653b25d8
parents 9f221c93 2463eeeb
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

@@ -1064,8 +1065,19 @@ public class DirectoryFragment extends Fragment
    }

    public void selectAllFiles() {
        // Exclude disabled files
        List<String> enabled = new ArrayList<String>();
        for (String id : mAdapter.getModelIds()) {
            Cursor cursor = getModel().getItem(id);
            String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
            int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
            if (isDocumentEnabled(docMimeType, docFlags)) {
                enabled.add(id);
            }
        }

        // Only select things currently visible in the adapter.
        boolean changed = mSelectionManager.setItemsSelected(mAdapter.getModelIds(), true);
        boolean changed = mSelectionManager.setItemsSelected(enabled, true);
        if (changed) {
            updateDisplayState();
        }
+4 −0
Original line number Diff line number Diff line
@@ -148,11 +148,15 @@ public abstract class FragmentTuner {
            MenuItem share = menu.findItem(R.id.menu_share);
            MenuItem delete = menu.findItem(R.id.menu_delete);
            MenuItem rename = menu.findItem(R.id.menu_rename);
            MenuItem selectAll = menu.findItem(R.id.menu_select_all);

            open.setVisible(true);
            share.setVisible(false);
            delete.setVisible(false);
            rename.setVisible(false);
            selectAll.setVisible(mState.allowMultiple);

            Menus.disableHiddenItems(menu);
        }

        @Override