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

Commit 2cdf9778 authored by Richard MacGregor's avatar Richard MacGregor
Browse files

Folders now use volume color

Folders within a volume now use the color which represents that volume
for icons.

Change-Id: I11dec343e0f7951ab3ea6f90cd1bad83f51fcc78
parent 1b2b437e
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ public class FileSystemObjectAdapter
    private OnSelectionChangedListener mOnSelectionChangedListener;
    private final ViewOutlineProvider mIconViewOutlineProvider;

    private int mPrimaryColor;

    //The resource of the item icon
    private static final int RESOURCE_ITEM_ICON = R.id.navigation_view_item_icon;
    //The resource of the item name
@@ -141,6 +143,7 @@ public class FileSystemObjectAdapter
        this.mRequests = new WeakHashMap<ImageView, GetProviderIconTask>();
        this.mPickable = pickable;
        mRes = context.getResources();
        mPrimaryColor = mRes.getColor(R.color.default_primary);

        mIconViewOutlineProvider = new ViewOutlineProvider() {
            @Override
@@ -451,6 +454,15 @@ public class FileSystemObjectAdapter
        }
    }

    /**
     * Method that sets the primary color for the current volume
     *
     * @param color hex color of to be used as primary color for the current volume
     */
    public void setPrimaryColor(int color) {
        mPrimaryColor = color;
    }

    private void setIcon(ImageView view, FileSystemObject fso) {
        // Cancel any previous loads to view
        mIconHolder.cancel(view);
@@ -484,13 +496,12 @@ public class FileSystemObjectAdapter
    // TODO: change folder colors depending on current volume (root, local, sdcard, usb, etc.)
    private void setFolderIcon(ImageView view, int iconId) {
        float opacity = mRes.getFloat(R.float_type.navigation_view_icon_circle_opacity);
        int folderPrimaryColor = mRes.getColor(R.color.default_primary);
        int transparentColor = Color.argb(
                Math.round(((float) 0xFF) * opacity),
                Color.red(folderPrimaryColor),
                Color.green(folderPrimaryColor),
                Color.blue(folderPrimaryColor));
        setIcon(mRes, view, mRes.getDrawable(iconId), folderPrimaryColor,
                Color.red(mPrimaryColor),
                Color.green(mPrimaryColor),
                Color.blue(mPrimaryColor));
        setIcon(mRes, view, mRes.getDrawable(iconId), mPrimaryColor,
                R.drawable.ic_icon_background, transparentColor);
    }

+1 −0
Original line number Diff line number Diff line
@@ -1869,6 +1869,7 @@ public class NavigationFragment extends Fragment
        mainActivity.getWindow().setStatusBarColor(statusBarColor);

        mToolBar.setBackgroundColor(backgroundColor);
        getCurrentNavigationView().setPrimaryColor(backgroundColor);

        if (mOnDirectoryChangedListener != null) {
            mOnDirectoryChangedListener.onDirectoryChanged(item);
+12 −1
Original line number Diff line number Diff line
@@ -1458,6 +1458,17 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe
        return this.mCurrentDir;
    }

    /**
     * Method that sets the primary color for the current volume
     *
     * @param color hex color of to be used as primary color for the current volume
     */
    public void setPrimaryColor(int color) {
        if (this.mAdapter != null) {
            this.mAdapter.setPrimaryColor(color);
        }
    }

    /**
     * Method that creates a ChRooted environment, protecting the user to break anything
     * in the device