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

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

Merge "Move archive support library to DocumentsUI."

parents 55a161a4 c88c5884
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -108,6 +108,13 @@
            android:authorities="com.android.documentsui.lastAccessed"
            android:exported="false"/>

        <provider
            android:name=".archives.ArchivesProvider"
            android:authorities="com.android.documentsui.archives"
            android:grantUriPermissions="true"
            android:permission="android.permission.MANAGE_DOCUMENTS"
            android:exported="true"/>

        <receiver android:name=".PackageReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
+20 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.MenuManager.SelectionDetails;
import com.android.documentsui.NavigationViewManager.Breadcrumb;
import com.android.documentsui.SearchViewManager.SearchManagerListener;
import com.android.documentsui.archives.ArchivesProvider;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.EventHandler;
import com.android.documentsui.base.Events;
@@ -79,6 +80,7 @@ import com.android.documentsui.sorting.SortModel;
import com.android.documentsui.ui.DialogController;
import com.android.documentsui.ui.MessageBuilder;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -410,10 +412,26 @@ public abstract class BaseActivity
    @Override
    public void openContainerDocument(DocumentInfo doc) {
        assert(doc.isContainer());
        DocumentInfo currentDoc = null;

        notifyDirectoryNavigated(doc.derivedUri);
        if (doc.isDirectory()) {
            // Regular directory.
            currentDoc = doc;
        } else if (doc.isArchive()) {
            // Archive.
            try {
                currentDoc = DocumentInfo.fromUri(getContentResolver(),
                        ArchivesProvider.buildUriForArchive(doc.derivedUri));
            } catch (FileNotFoundException e) {
                // Should never happen, as queryDocument() on ArchivesProvider's root
                // document never throws.
            }
        }

        assert(currentDoc != null);
        notifyDirectoryNavigated(currentDoc.derivedUri);
        mState.pushDocument(currentDoc);

        mState.pushDocument(doc);
        // Show an opening animation only if pressing "back" would get us back to the
        // previous directory. Especially after opening a root document, pressing
        // back, wouldn't go to the previous root, but close the activity.
+501 −0

File added.

Preview size limit exceeded, changes collapsed.

+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.documentsui.archives;

import android.net.Uri;

class ArchiveId {
    private final static char DELIMITER = '#';

    public final Uri mArchiveUri;
    public final String mPath;

    public ArchiveId(Uri archiveUri, String path) {
        mArchiveUri = archiveUri;
        mPath = path;
        assert(!mPath.isEmpty());
    }

    static public ArchiveId fromDocumentId(String documentId) {
        final int delimiterPosition = documentId.indexOf(DELIMITER);
        assert(delimiterPosition != -1);
        return new ArchiveId(Uri.parse(documentId.substring(0, delimiterPosition)),
                documentId.substring((delimiterPosition + 1)));
    }

    public String toDocumentId() {
        return mArchiveUri.toString() + DELIMITER + mPath;
    }
};
+315 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading