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

Commit ac3e63e5 authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski
Browse files

Enable Open With in the overflow menu.

Along the way fix Open With to be disabled for files in archives.

Bug: 33133918
Test: Unit tests + tested manually.

Change-Id: I7820d1fd74e85d7f499d6657e5c8a9ab92122706
parent 700f9716
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@
        android:id="@+id/menu_open"
        android:title="@string/menu_open"
        android:showAsAction="always" />
    <item
        android:id="@+id/menu_open_with"
        android:title="@string/menu_open_with"
        android:showAsAction="never" />
    <item
        android:id="@+id/menu_share"
        android:icon="@drawable/ic_menu_share"
@@ -38,7 +42,6 @@
        android:title="@string/menu_copy"
        android:showAsAction="never"
        android:visible="false" />

    <item
        android:id="@+id/menu_extract_to"
        android:title="@string/menu_extract"
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public abstract class MenuManager {
    /** @see ActionModeController */
    public void updateActionMenu(Menu menu, SelectionDetails selection) {
        updateOpenInActionMode(menu.findItem(R.id.menu_open), selection);
        updateOpenWith(menu.findItem(R.id.menu_open_with), selection);
        updateDelete(menu.findItem(R.id.menu_delete), selection);
        updateShare(menu.findItem(R.id.menu_share), selection);
        updateRename(menu.findItem(R.id.menu_rename), selection);
@@ -313,6 +314,8 @@ public abstract class MenuManager {
        boolean canPasteInto();

        boolean canExtract();

        boolean canOpenWith();
    }

    public static class DirectoryDetails {
+1 −1
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa

    @Override
    public void showChooserForDoc(DocumentInfo doc) {
        assert(!doc.isContainer());
        assert(!doc.isDirectory());

        if (manageDocument(doc)) {
            Log.w(TAG, "Open with is not yet supported for managed doc.");
+1 −2
Original line number Diff line number Diff line
@@ -144,8 +144,7 @@ public final class MenuManager extends com.android.documentsui.MenuManager {

    @Override
    protected void updateOpenWith(MenuItem openWith, SelectionDetails selectionDetails) {
        openWith.setEnabled(selectionDetails.size() == 1
                && !selectionDetails.containsPartialFiles());
        openWith.setEnabled(selectionDetails.canOpenWith());
    }

    @Override
+5 −0
Original line number Diff line number Diff line
@@ -134,4 +134,9 @@ public class SelectionMetadata
    public boolean canPasteInto() {
        return mDirectoryCount == 1 && mWritableDirectoryCount == 1 && size() == 1;
    }

    @Override
    public boolean canOpenWith() {
        return size() == 1 && mInArchiveCount == 0 && mPartialCount == 0;
    }
}
Loading