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

Commit 7025de73 authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski Committed by Android (Google) Code Review
Browse files

Merge "Show a snackbar for archived files when can't be quick viewed." into arc-apps

parents 9e743064 179f0695
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -149,6 +149,8 @@

    <!-- Toast shown when no app can be found to open the selected document [CHAR LIMIT=48] -->
    <string name="toast_no_application">Can\u2019t open file</string>
    <!-- Toast notifying that it's impossible to open files inside archives [CHAR LIMIT=48] -->
    <string name="toast_view_in_archives_unsupported">Cannot open files in archives</string>
    <!-- Toast shown when some of the selected documents failed to be deleted [CHAR LIMIT=48] -->
    <string name="toast_failed_delete">Unable to delete some documents</string>

+1 −1
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ public class ActionHandler<T extends Activity & Addons> extends AbstractActionHa
        }

        if (doc.isInArchive()) {
            Log.w(TAG, "Can't view archived files.");
            mDialogs.showViewInArchivesUnsupported();
            return false;
        }

+12 −0
Original line number Diff line number Diff line
@@ -51,6 +51,11 @@ public interface DialogController {
            throw new UnsupportedOperationException();
        }

        @Override
        public void showViewInArchivesUnsupported() {
            throw new UnsupportedOperationException();
        }

        @Override
        public void showDocumentsClipped(int size) {
            throw new UnsupportedOperationException();
@@ -60,6 +65,7 @@ public interface DialogController {
    void confirmDelete(List<DocumentInfo> docs, ConfirmationCallback callback);
    void showFileOperationStatus(int status, int opType, int docCount);
    void showNoApplicationFound();
    void showViewInArchivesUnsupported();
    void showDocumentsClipped(int size);

    // Should be private, but Java doesn't like me treating an interface like a mini-package.
@@ -149,6 +155,12 @@ public interface DialogController {
                    mActivity, R.string.toast_no_application, Snackbar.LENGTH_SHORT).show();
        }

        @Override
        public void showViewInArchivesUnsupported() {
            Snackbars.makeSnackbar(mActivity, R.string.toast_view_in_archives_unsupported,
                    Snackbar.LENGTH_SHORT).show();
        }

        @Override
        public void showDocumentsClipped(int size) {
            Snackbars.showDocumentsClipped(mActivity, size);
+7 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.test.mock.MockContentResolver;

import com.android.documentsui.FocusManager;
import com.android.documentsui.Injector;
import com.android.documentsui.archives.ArchivesProvider;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.State;
@@ -52,6 +53,7 @@ public class TestEnv {
    public static DocumentInfo FILE_APK;
    public static DocumentInfo FILE_PARTIAL;
    public static DocumentInfo FILE_ARCHIVE;
    public static DocumentInfo FILE_IN_ARCHIVE;
    public static DocumentInfo FILE_VIRTUAL;

    public final TestScheduledExecutorService mExecutor;
@@ -60,6 +62,7 @@ public class TestEnv {
    public final TestDocumentsAccess docs = new TestDocumentsAccess();
    public final TestFocusHandler focusHandler = new TestFocusHandler();
    public final TestModel model;
    public final TestModel archiveModel;
    public final SelectionManager selectionMgr;
    public final TestSearchViewManager searchViewManager;
    public final Injector injector;
@@ -73,6 +76,7 @@ public class TestEnv {
        mExecutor = new TestScheduledExecutorService();
        features = new TestFeatures();
        model = new TestModel(authority, features);
        archiveModel = new TestModel(ArchivesProvider.AUTHORITY, features);
        selectionMgr = SelectionManagers.createTestInstance();
        searchViewManager = new TestSearchViewManager();
        injector = new Injector(
@@ -131,10 +135,8 @@ public class TestEnv {
                "UbuntuFlappyBird.iso",
                Document.FLAG_SUPPORTS_DELETE
                        | Document.FLAG_PARTIAL);
        FILE_ARCHIVE = model.createFile(
                "whatsinthere.zip",
                Document.FLAG_ARCHIVE
                        | Document.FLAG_SUPPORTS_DELETE);
        FILE_ARCHIVE = model.createFile("whatsinthere.zip");
        FILE_IN_ARCHIVE = archiveModel.createFile("whatsinthere.png");
        FILE_VIRTUAL = model.createDocument(
                "virtualdoc.vnd",
                "application/vnd.google-apps.document",
@@ -142,6 +144,7 @@ public class TestEnv {
                        | Document.FLAG_SUPPORTS_DELETE
                        | Document.FLAG_SUPPORTS_RENAME);

        archiveModel.update();
        model.update();
    }

+10 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public class TestDialogController implements DialogController {
    private boolean mFileOpFailed;
    private boolean mNoApplicationFound;
    private boolean mDocumentsClipped;
    private boolean mViewInArchivesUnsupported;

    public TestDialogController() {
        // by default, always confirm
@@ -52,6 +53,11 @@ public class TestDialogController implements DialogController {
        mNoApplicationFound = true;
    }

    @Override
    public void showViewInArchivesUnsupported() {
        mViewInArchivesUnsupported = true;
    }

    @Override
    public void showDocumentsClipped(int size) {
        mDocumentsClipped = true;
@@ -65,6 +71,10 @@ public class TestDialogController implements DialogController {
        Assert.assertFalse(mNoApplicationFound);
    }

    public void assertViewInArchivesShownUnsupported() {
        Assert.assertTrue(mViewInArchivesUnsupported);
    }

    public void assertDocumentsClippedNotShown() {
        Assert.assertFalse(mDocumentsClipped);
    }
Loading