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

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

Move archive support library to DocumentsUI.

This if the first step. The tests are not moved, and the original
support library is not deleted yet.

Besides, the new files are basically copy paste.

Change-Id: Ifaac019de00f2d00fe1a69f9a69e62b4d3602c24
Test: Not yet, but coming.
Bug: 31783726
parent 179fc5d4
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -108,6 +108,13 @@
            android:authorities="com.android.documentsui.lastAccessed"
            android:authorities="com.android.documentsui.lastAccessed"
            android:exported="false"/>
            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">
        <receiver android:name=".PackageReceiver">
            <intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
+20 −2
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ import android.view.View;
import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.NavigationViewManager.Breadcrumb;
import com.android.documentsui.NavigationViewManager.Breadcrumb;
import com.android.documentsui.SearchViewManager.SearchManagerListener;
import com.android.documentsui.SearchViewManager.SearchManagerListener;
import com.android.documentsui.archives.ArchivesProvider;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.Events;
import com.android.documentsui.base.Events;
import com.android.documentsui.base.LocalPreferences;
import com.android.documentsui.base.LocalPreferences;
@@ -74,6 +75,7 @@ import com.android.documentsui.sorting.SortController;
import com.android.documentsui.sorting.SortModel;
import com.android.documentsui.sorting.SortModel;
import com.android.documentsui.ui.DialogController;
import com.android.documentsui.ui.DialogController;


import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collection;
import java.util.Date;
import java.util.Date;
@@ -383,10 +385,26 @@ public abstract class BaseActivity


    protected void openContainerDocument(DocumentInfo doc) {
    protected void openContainerDocument(DocumentInfo doc) {
        assert(doc.isContainer());
        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
        // Show an opening animation only if pressing "back" would get us back to the
        // previous directory. Especially after opening a root document, pressing
        // previous directory. Especially after opening a root document, pressing
        // back, wouldn't go to the previous root, but close the activity.
        // 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 Original line 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