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

Commit 2c00b583 authored by Richard MacGregor's avatar Richard MacGregor Committed by Stephen Bird
Browse files

Fix breadcrumbs

Breadcrumbs now work with storage providers.

Change-Id: Ic288109c3f21efa7b70f5dd839c92f9628885181
parent 2e18c8a9
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2015 The CyanogenMod 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="15dp"
    android:height="32dp"
    android:viewportWidth="15"
    android:viewportHeight="32">

    <path
        android:fillColor="#FFFFFF"
        android:fillAlpha="0.26"
        android:strokeAlpha="0.26"
        android:pathData="M-7.5,13l8,8l-8,8V13z" />
</vector>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -19,4 +19,4 @@
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:contentDescription="@null"
  android:src="@drawable/ic_material_light_breadcrumb_divider" />
  android:src="@drawable/ic_breadcrumb" />
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@
    <drawable name="drawer_icon">@drawable/ic_material_light_navigation_drawer</drawable>

    <!-- The breadcrumb divider drawable -->
    <drawable name="breadcrumb_divider_drawable">@drawable/ic_material_light_breadcrumb_divider</drawable>
    <drawable name="breadcrumb_divider_drawable">@drawable/ic_breadcrumb</drawable>

    <!-- FileSystem locked drawable -->
    <drawable name="filesystem_locked_drawable">@drawable/ic_material_light_fs_locked</drawable>
+9 −0
Original line number Diff line number Diff line
@@ -296,4 +296,13 @@ public class StorageApiConsole extends VirtualConsole {
            return null;
        }
    }

    public static String getProviderNameFromFullPath(String fullPath) {
        String name = null;
        StorageApiConsole storageApiConsole = getStorageApiConsoleForPath(fullPath);
        if (storageApiConsole != null) {
            name = storageApiConsole.getStorageProviderInfo().getTitle();
        }
        return name;
    }
}
+54 −20
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.widget.ProgressBar;
import android.widget.RelativeLayout;

import com.cyanogenmod.filemanager.R;
import com.cyanogenmod.filemanager.console.storageapi.StorageApiConsole;
import com.cyanogenmod.filemanager.model.DiskUsage;
import com.cyanogenmod.filemanager.model.MountPoint;
import com.cyanogenmod.filemanager.tasks.FilesystemAsyncTask;
@@ -37,6 +38,8 @@ import com.cyanogenmod.filemanager.ui.ThemeManager.Theme;
import com.cyanogenmod.filemanager.util.FileHelper;
import com.cyanogenmod.filemanager.util.MountPointHelper;
import com.cyanogenmod.filemanager.util.StorageHelper;
import com.cyanogenmod.filemanager.util.StorageProviderUtils;
import com.cyanogenmod.filemanager.util.StorageProviderUtils.PathInfo;

import java.io.File;
import java.util.ArrayList;
@@ -205,9 +208,21 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
        //Remove all views
        this.mBreadcrumbBar.removeAllViews();

        if (StorageApiConsole.getStorageApiConsoleForPath(newPath) != null) {
            List<PathInfo> path = StorageProviderUtils.reconstructStorageApiFilePath(newPath);
            boolean first = true;
            for (PathInfo item : path) {
                if (!first) {
                    this.mBreadcrumbBar.addView(createItemDivider());
                }
                first = false;
                this.mBreadcrumbBar.addView(createBreadcrumbItem(item));
            }
        } else {
            // The first is always the root (except if we are in a ChRooted environment)
            if (!chRooted) {
            this.mBreadcrumbBar.addView(createBreadcrumbItem(new File(FileHelper.ROOT_DIRECTORY)));
                this.mBreadcrumbBar.addView(createBreadcrumbItem(
                        new File(FileHelper.ROOT_DIRECTORY)));
            }

            //Add the rest of the path
@@ -231,6 +246,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
                    this.mBreadcrumbBar.addView(createBreadcrumbItem(createFile(dirs, i)));
                }
            }
        }

        // Now apply the theme to the breadcrumb
        applyTheme();
@@ -291,6 +307,24 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
        return item;
    }

    /**
     * Method that creates a new split path.
     *
     * @param info The current path info item
     * @return BreadcrumbItem The view create
     */
    private BreadcrumbItem createBreadcrumbItem(PathInfo info) {
        LayoutInflater inflater =
                (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        BreadcrumbItem item =
                (BreadcrumbItem)inflater.inflate(
                        R.layout.breadcrumb_item, this.mBreadcrumbBar, false);
        item.setText(info.getDisplayName());
        item.setItemPath(info.getPath());
        item.setOnClickListener(this);
        return item;
    }

    /**
     * Method that creates the a new file reference for a partial
     * breadcrumb item.
Loading