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

Commit 6a5c723a authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski
Browse files

Better naming for created archives.

If compressing only one file/directory use that file/directory's
name as the archive file name.

Test: Tested manually.
Bug: 20822019
Change-Id: Icb3e3d816204f300b3d97c7fe571e7568b5a9921
parent e37d996f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -314,4 +314,7 @@

    <!-- Text shown on button to open an application -->
    <string name="open_app">Open <xliff:g id="name" example="Cloud Storage">%1$s</xliff:g></string>

    <!-- File name of an archive file created when compressing files, without the file extension (.zip). -->
    <string name="new_archive_file_name">archive<xliff:g id="extension" example=".zip">%s</xliff:g></string>
</resources>
+15 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import javax.annotation.Nullable;
final class CompressJob extends CopyJob {

    private static final String TAG = "CompressJob";
    private static final String NEW_ARCHIVE_EXTENSION = ".zip";

    /**
     * Moves files to a destination identified by {@code destination}.
@@ -85,12 +86,23 @@ final class CompressJob extends CopyJob {

    @Override
    public boolean setUp() {
        if (!super.setUp()) {
            return false;
        }

        final ContentResolver resolver = appContext.getContentResolver();

        // TODO: Move this to DocumentsProvider.
        // TODO: Choose better dispaly name.

        String displayName;
        if (mResolvedDocs.size() == 1) {
            displayName = mResolvedDocs.get(0).displayName + NEW_ARCHIVE_EXTENSION;
        } else {
            displayName = service.getString(R.string.new_archive_file_name, NEW_ARCHIVE_EXTENSION);
        }

        final Uri archiveUri = DocumentsContract.createDocument(
                resolver, mDstInfo.derivedUri, "application/zip", "archive.zip");
                resolver, mDstInfo.derivedUri, "application/zip", displayName);

        try {
            mDstInfo = DocumentInfo.fromUri(resolver, ArchivesProvider.buildUriForArchive(
@@ -101,7 +113,7 @@ final class CompressJob extends CopyJob {
            return false;
        }

        return super.setUp();
        return true;
    }

    @Override