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

Commit e697f2cb authored by Richard MacGregor's avatar Richard MacGregor
Browse files

Fix breadcrumb for storage api providers

When long pressing on breadcrumb sections a toast should appear
listing the full path of the long pressed section.
This patch fixes this behavior when browsing a storage api provider.

Change-Id: I4d02a9c8813754be053d4b093f244b6a3d7c80dc
parent 2c00b583
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.cyanogenmod.filemanager.util.DialogHelper;
public class BreadcrumbItem extends TextView implements OnLongClickListener {

    private String mItemPath;
    private String mReadablePath;

    /**
     * Constructor of <code>BreadcrumbItem</code>.
@@ -98,12 +99,21 @@ public class BreadcrumbItem extends TextView implements OnLongClickListener {
        this.mItemPath = itemPath;
    }

    /**
     * Method that sets the readable path associated with with this breadcrumb item.
     *
     * @param readablePath The item path
     */
    protected void setReadablePath(String readablePath) {
        this.mReadablePath = readablePath;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean onLongClick(View v) {
        DialogHelper.showToast(getContext(), this.mItemPath, Toast.LENGTH_SHORT);
        DialogHelper.showToast(getContext(), this.mReadablePath, Toast.LENGTH_SHORT);
        return true;
    }

+7 −2
Original line number Diff line number Diff line
@@ -210,13 +210,16 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic

        if (StorageApiConsole.getStorageApiConsoleForPath(newPath) != null) {
            List<PathInfo> path = StorageProviderUtils.reconstructStorageApiFilePath(newPath);
            String readablePath = "";
            boolean first = true;
            for (PathInfo item : path) {
                if (!first) {
                    readablePath += File.separator;
                    this.mBreadcrumbBar.addView(createItemDivider());
                }
                first = false;
                this.mBreadcrumbBar.addView(createBreadcrumbItem(item));
                readablePath += item.getDisplayName();
                this.mBreadcrumbBar.addView(createBreadcrumbItem(item, readablePath));
            }
        } else {
            // The first is always the root (except if we are in a ChRooted environment)
@@ -303,6 +306,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
                        R.layout.breadcrumb_item, this.mBreadcrumbBar, false);
        item.setText(dir.getName().length() != 0 ? dir.getName() : dir.getPath());
        item.setItemPath(dir.getPath());
        item.setReadablePath(dir.getPath());
        item.setOnClickListener(this);
        return item;
    }
@@ -313,7 +317,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
     * @param info The current path info item
     * @return BreadcrumbItem The view create
     */
    private BreadcrumbItem createBreadcrumbItem(PathInfo info) {
    private BreadcrumbItem createBreadcrumbItem(PathInfo info, String readablePath) {
        LayoutInflater inflater =
                (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        BreadcrumbItem item =
@@ -321,6 +325,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
                        R.layout.breadcrumb_item, this.mBreadcrumbBar, false);
        item.setText(info.getDisplayName());
        item.setItemPath(info.getPath());
        item.setReadablePath(readablePath);
        item.setOnClickListener(this);
        return item;
    }