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

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

Add boilerplate for compressing in DocumentsUI.

This CL adds strings, constants, and classes for compressing, which
for now do the same as copying.

Along the way it does the same to extracting.

Test: Tested manually.
Bug: 20822019
Change-Id: I9866166c635befae59b3fff13125bd563f71936a
(cherry picked from commit 4f225494)
parent 664025e3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@
        android:title="@string/menu_copy"
        android:showAsAction="never"
        android:visible="false" />
    <item
        android:id="@+id/menu_compress_to"
        android:title="@string/menu_compress"
        android:showAsAction="never"
        android:visible="false" />
    <item
        android:id="@+id/menu_extract_to"
        android:icon="@drawable/ic_menu_extract"
+21 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@
    <string name="menu_copy">Copy to\u2026</string>
    <!-- Menu item title that moves the selected documents [CHAR LIMIT=28] -->
    <string name="menu_move">Move to\u2026</string>
    <!-- Menu item title that compresses the selected documents [CHAR LIMIT=28] -->
    <string name="menu_compress">Compress to\u2026</string>
    <!-- Menu item title that extracts the selected documents [CHAR LIMIT=28] -->
    <string name="menu_extract">Extract to\u2026</string>
    <!-- Menu item that renames the selected document [CHAR LIMIT=28] -->
@@ -79,6 +81,10 @@
    <string name="button_select">Select</string>
    <!-- Button label that copies files to the current directory [CHAR LIMIT=24] -->
    <string name="button_copy">Copy</string>
    <!-- Button label that compresses files to the current directory [CHAR LIMIT=24] -->
    <string name="button_compress">Compress</string>
    <!-- Button label that extracts files to the current directory [CHAR LIMIT=24] -->
    <string name="button_extract">Extract</string>
    <!-- Button label that moves files to the current directory [CHAR LIMIT=24] -->
    <string name="button_move">Move</string>
    <!-- Button label that hides the error bar [CHAR LIMIT=24] -->
@@ -153,6 +159,17 @@
        <item quantity="one">Copying <xliff:g id="count" example="1">%1$d</xliff:g> file.</item>
        <item quantity="other">Copying <xliff:g id="count" example="3">%1$d</xliff:g> files.</item>
    </plurals>
    <!-- Toast shown when a file compressing is kicked off -->
    <plurals name="compress_begin">
        <item quantity="one">Compressing <xliff:g id="count" example="1">%1$d</xliff:g> file.</item>
        <item quantity="other">Compressing <xliff:g id="count" example="3">%1$d</xliff:g> files.</item>
    </plurals>
    <!-- Toast shown when a file extracting is kicked off -->
    <plurals name="extract_begin">
        <item quantity="one">Extracting <xliff:g id="count" example="1">%1$d</xliff:g> file.</item>
        <item quantity="other">Extracting <xliff:g id="count" example="3">%1$d</xliff:g> files.</item>
    </plurals>
    <!-- Toast shown when a file move is kicked off -->
    <plurals name="move_begin">
        <item quantity="one">Moving <xliff:g id="count" example="1">%1$d</xliff:g> file.</item>
        <item quantity="other">Moving <xliff:g id="count" example="3">%1$d</xliff:g> files.</item>
@@ -193,6 +210,10 @@
    <string name="close">Close</string>
    <!-- Contents of the copying failure alert dialog. [CHAR LIMIT=48] -->
    <string name="copy_failure_alert_content">These files weren\u2019t copied: <xliff:g id="list">%1$s</xliff:g></string>
    <!-- Contents of the compressing failure alert dialog. [CHAR LIMIT=48] -->
    <string name="compress_failure_alert_content">These files weren\u2019t compressed: <xliff:g id="list">%1$s</xliff:g></string>
    <!-- Contents of the extracting failure alert dialog. [CHAR LIMIT=48] -->
    <string name="extract_failure_alert_content">These files weren\u2019t extracted: <xliff:g id="list">%1$s</xliff:g></string>
    <!-- Contents of the moving failure alert dialog. [CHAR LIMIT=48] -->
    <string name="move_failure_alert_content">These files weren\u2019t moved: <xliff:g id="list">%1$s</xliff:g></string>
    <!-- Message shown to users when an operation to delete one or more files has failed. Presented in a dialog. [CHAR LIMIT=48] -->
+5 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public abstract class MenuManager {
        updateSelectAll(menu.findItem(R.id.menu_select_all));
        updateMoveTo(menu.findItem(R.id.menu_move_to), selection);
        updateCopyTo(menu.findItem(R.id.menu_copy_to), selection);
        updateCompressTo(menu.findItem(R.id.menu_compress_to), selection);
        updateExtractTo(menu.findItem(R.id.menu_extract_to), selection);

        Menus.disableHiddenItems(menu);
@@ -270,6 +271,10 @@ public abstract class MenuManager {
        copyTo.setVisible(false);
    }

    protected void updateCompressTo(MenuItem compressTo, SelectionDetails selectionDetails) {
        compressTo.setVisible(false);
    }

    protected void updateExtractTo(MenuItem extractTo, SelectionDetails selectionDetails) {
        extractTo.setVisible(false);
    }
+55 −1
Original line number Diff line number Diff line
@@ -163,10 +163,18 @@ public final class Metrics {
    // Do not change or rearrange these values, that will break historical data. Only add to the
    // list.
    // Do not use negative numbers or zero; clearcut only handles positive integers.
    //
    // Next available ID: 112
    private static final int FILEOP_OTHER = 1; // any file operation not listed below
    private static final int FILEOP_COPY_INTRA_PROVIDER = 2; // Copy within a provider
    private static final int FILEOP_COPY_SYSTEM_PROVIDER = 3; // Copy to a system provider.
    private static final int FILEOP_COPY_EXTERNAL_PROVIDER = 4; // Copy to a 3rd-party provider.
    private static final int FILEOP_COMPRESS_INTRA_PROVIDER = 106; // Compres within a provider
    private static final int FILEOP_COMPRESS_SYSTEM_PROVIDER = 107; // Compress to a system provider.
    private static final int FILEOP_COMPRESS_EXTERNAL_PROVIDER = 108; // Compress to a 3rd-party provider.
    private static final int FILEOP_EXTRACT_INTRA_PROVIDER = 109; // Extract within a provider
    private static final int FILEOP_EXTRACT_SYSTEM_PROVIDER = 110; // Extract to a system provider.
    private static final int FILEOP_EXTRACT_EXTERNAL_PROVIDER = 111; // Extract to a 3rd-party provider.
    private static final int FILEOP_MOVE_INTRA_PROVIDER = 5; // Move within a provider.
    private static final int FILEOP_MOVE_SYSTEM_PROVIDER = 6; // Move to a system provider.
    private static final int FILEOP_MOVE_EXTERNAL_PROVIDER = 7; // Move to a 3rd-party provider.
@@ -177,6 +185,8 @@ public final class Metrics {
    private static final int FILEOP_DELETE_ERROR = 101;
    private static final int FILEOP_MOVE_ERROR = 102;
    private static final int FILEOP_COPY_ERROR = 103;
    private static final int FILEOP_COMPRESS_ERROR = 112;
    private static final int FILEOP_EXTRACT_ERROR = 113;
    private static final int FILEOP_RENAME_ERROR = 104;
    private static final int FILEOP_CREATE_DIR_ERROR = 105;

@@ -185,6 +195,12 @@ public final class Metrics {
            FILEOP_COPY_INTRA_PROVIDER,
            FILEOP_COPY_SYSTEM_PROVIDER,
            FILEOP_COPY_EXTERNAL_PROVIDER,
            FILEOP_COMPRESS_INTRA_PROVIDER,
            FILEOP_COMPRESS_SYSTEM_PROVIDER,
            FILEOP_COMPRESS_EXTERNAL_PROVIDER,
            FILEOP_EXTRACT_INTRA_PROVIDER,
            FILEOP_EXTRACT_SYSTEM_PROVIDER,
            FILEOP_EXTRACT_EXTERNAL_PROVIDER,
            FILEOP_MOVE_INTRA_PROVIDER,
            FILEOP_MOVE_SYSTEM_PROVIDER,
            FILEOP_MOVE_EXTERNAL_PROVIDER,
@@ -193,6 +209,8 @@ public final class Metrics {
            FILEOP_CREATE_DIR,
            FILEOP_OTHER_ERROR,
            FILEOP_COPY_ERROR,
            FILEOP_COMPRESS_ERROR,
            FILEOP_EXTRACT_ERROR,
            FILEOP_MOVE_ERROR,
            FILEOP_DELETE_ERROR,
            FILEOP_RENAME_ERROR,
@@ -206,14 +224,20 @@ public final class Metrics {
    // Do not change or rearrange these values, that will break historical data. Only add to the
    // list.
    // Do not use negative numbers or zero; clearcut only handles positive integers.
    //
    // Next available ID: 7
    private static final int OPERATION_UNKNOWN = 1;
    private static final int OPERATION_COPY = 2;
    private static final int OPERATION_COMPRESS = 5;
    private static final int OPERATION_EXTRACT = 6;
    private static final int OPERATION_MOVE = 3;
    private static final int OPERATION_DELETE = 4;

    @IntDef(flag = true, value = {
            OPERATION_UNKNOWN,
            OPERATION_COPY,
            OPERATION_COMPRESS,
            OPERATION_EXTRACT,
            OPERATION_MOVE,
            OPERATION_DELETE
    })
@@ -267,6 +291,8 @@ public final class Metrics {
    // Do not change or rearrange these values, that will break historical data. Only add to the
    // list.
    // Do not use negative numbers or zero; clearcut only handles positive integers.
    //
    // Next available ID: 29
    public static final int USER_ACTION_OTHER = 1;
    public static final int USER_ACTION_GRID = 2;
    public static final int USER_ACTION_LIST = 3;
@@ -278,6 +304,8 @@ public final class Metrics {
    public static final int USER_ACTION_HIDE_SIZE = 9;
    public static final int USER_ACTION_SETTINGS = 10;
    public static final int USER_ACTION_COPY_TO = 11;
    public static final int USER_ACTION_COMPRESS_TO = 27;
    public static final int USER_ACTION_EXTRACT_TO = 28;
    public static final int USER_ACTION_MOVE_TO = 12;
    public static final int USER_ACTION_DELETE = 13;
    public static final int USER_ACTION_RENAME = 14;
@@ -306,6 +334,8 @@ public final class Metrics {
            USER_ACTION_HIDE_SIZE,
            USER_ACTION_SETTINGS,
            USER_ACTION_COPY_TO,
            USER_ACTION_COMPRESS_TO,
            USER_ACTION_EXTRACT_TO,
            USER_ACTION_MOVE_TO,
            USER_ACTION_DELETE,
            USER_ACTION_RENAME,
@@ -542,6 +572,12 @@ public final class Metrics {
            case FileOperationService.OPERATION_COPY:
                opCode = FILEOP_COPY_ERROR;
                break;
            case FileOperationService.OPERATION_COMPRESS:
                opCode = FILEOP_COMPRESS_ERROR;
                break;
            case FileOperationService.OPERATION_EXTRACT:
                opCode = FILEOP_EXTRACT_ERROR;
                break;
            case FileOperationService.OPERATION_DELETE:
                opCode = FILEOP_DELETE_ERROR;
                break;
@@ -911,6 +947,24 @@ public final class Metrics {
                    case PROVIDER_EXTERNAL:
                        return FILEOP_COPY_EXTERNAL_PROVIDER;
                }
            case FileOperationService.OPERATION_COMPRESS:
                switch (providerType) {
                    case PROVIDER_INTRA:
                        return FILEOP_COMPRESS_INTRA_PROVIDER;
                    case PROVIDER_SYSTEM:
                        return FILEOP_COMPRESS_SYSTEM_PROVIDER;
                    case PROVIDER_EXTERNAL:
                        return FILEOP_COMPRESS_EXTERNAL_PROVIDER;
                }
             case FileOperationService.OPERATION_EXTRACT:
                switch (providerType) {
                    case PROVIDER_INTRA:
                        return FILEOP_EXTRACT_INTRA_PROVIDER;
                    case PROVIDER_SYSTEM:
                        return FILEOP_EXTRACT_SYSTEM_PROVIDER;
                    case PROVIDER_EXTERNAL:
                        return FILEOP_EXTRACT_EXTERNAL_PROVIDER;
                }
            case FileOperationService.OPERATION_MOVE:
                switch (providerType) {
                    case PROVIDER_INTRA:
+6 −0
Original line number Diff line number Diff line
@@ -102,6 +102,12 @@ public class OperationDialogFragment extends DialogFragment {
                    case FileOperationService.OPERATION_COPY:
                        messageFormat = getString(R.string.copy_failure_alert_content);
                        break;
                    case FileOperationService.OPERATION_COMPRESS:
                        messageFormat = getString(R.string.compress_failure_alert_content);
                        break;
                    case FileOperationService.OPERATION_EXTRACT:
                        messageFormat = getString(R.string.extract_failure_alert_content);
                        break;
                    case FileOperationService.OPERATION_DELETE:
                        messageFormat = getString(R.string.delete_failure_alert_content);
                        break;
Loading