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

Commit d35446ab authored by Aga Wronska's avatar Aga Wronska Committed by Android (Google) Code Review
Browse files

Merge "Generate more descriptive delete confirmation message." into nyc-dev

parents 9d787161 824ac17a
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -211,13 +211,29 @@
    <!-- Text in the button asking user to deny access to a given directory. -->
    <string name="deny">Deny</string>
    <!-- Dialog text shown to users when asking if they want to delete files (a confirmation). -->
    <plurals name="delete_confirmation_message">
        <item quantity="one">Delete <xliff:g id="count" example="1">%1$d</xliff:g> file?</item>
        <item quantity="other">Delete <xliff:g id="count" example="3">%1$d</xliff:g> files?</item>
    </plurals>
    <!-- Label text showing user how many items are selected. Can be one or more elements. -->
    <plurals name="elements_selected">
        <item quantity="one"><xliff:g id="count" example="1">%1$d</xliff:g> selected</item>
        <item quantity="other"><xliff:g id="count" example="3">%1$d</xliff:g> selected</item>
    </plurals>

    <!-- Dialog text shown to users when asking if they want to delete a file (a confirmation) -->
    <string name="delete_filename_confirmation_message">Delete \"<xliff:g id="name" example="cat.jpg">%1$s</xliff:g>\"?</string>
    <!-- Dialog text shown to users when asking if they want to delete a folder (a confirmation) -->
    <string name="delete_foldername_confirmation_message">Delete folder \"<xliff:g id="name" example="Photos">%1$s</xliff:g>\" and its contents?</string>
    <!-- Dialog text shown to users when asking if they want to delete files (a confirmation). -->
    <plurals name="delete_files_confirmation_message">
        <item quantity="one">Delete <xliff:g id="count" example="1">%1$d</xliff:g> file?</item>
        <item quantity="other">Delete <xliff:g id="count" example="3">%1$d</xliff:g> files?</item>
    </plurals>
    <!-- Dialog text shown to users when asking if they want to delete folders (a confirmation). -->
    <plurals name="delete_folders_confirmation_message">
        <item quantity="one">Delete <xliff:g id="count" example="1">%1$d</xliff:g> folder and its contents?</item>
        <item quantity="other">Delete <xliff:g id="count" example="3">%1$d</xliff:g> folders and their contents?</item>
    </plurals>
    <!-- Dialog text shown to users when asking if they want to delete mixed type items: files and folders (a confirmation). -->
    <plurals name="delete_items_confirmation_message">
        <item quantity="one">Delete <xliff:g id="count" example="1">%1$d</xliff:g> item?</item>
        <item quantity="other">Delete <xliff:g id="count" example="3">%1$d</xliff:g> items?</item>
    </plurals>
</resources>
+34 −5
Original line number Diff line number Diff line
@@ -688,6 +688,39 @@ public class DirectoryFragment extends Fragment
        }.execute(selected);
    }

    private String generateDeleteMessage(final List<DocumentInfo> docs) {
        String message;
        int dirsCount = 0;

        for (DocumentInfo doc : docs) {
            if (doc.isDirectory()) {
                ++dirsCount;
            }
        }

        if (docs.size() == 1) {
            // Deleteing 1 file xor 1 folder in cwd
            message = dirsCount == 0
                    ? getActivity().getString(R.string.delete_filename_confirmation_message,
                            docs.get(0).displayName)
                    : getActivity().getString(R.string.delete_foldername_confirmation_message,
                            docs.get(0).displayName);
        } else if (dirsCount == 0) {
            // Deleting only files in cwd
            message = Shared.getQuantityString(getActivity(),
                    R.plurals.delete_files_confirmation_message, docs.size());
        } else if (dirsCount == docs.size()) {
            // Deleting only folders in cwd
            message = Shared.getQuantityString(getActivity(),
                    R.plurals.delete_folders_confirmation_message, docs.size());
        } else {
            // Deleting mixed items (files and folders) in cwd
            message = Shared.getQuantityString(getActivity(),
                    R.plurals.delete_items_confirmation_message, docs.size());
        }
        return message;
    }

    private void deleteDocuments(final Selection selected) {
        assert(!selected.isEmpty());

@@ -698,11 +731,7 @@ public class DirectoryFragment extends Fragment

                TextView message =
                        (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null);
                message.setText(
                        Shared.getQuantityString(
                                getActivity(),
                                R.plurals.delete_confirmation_message,
                                docs.size()));
                message.setText(generateDeleteMessage(docs));

                // This "insta-hides" files that are being deleted, because
                // the delete operation may be not execute immediately (it