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

Commit 1b2b437e authored by Raj Yengisetty's avatar Raj Yengisetty
Browse files

Set Navigation Drawer header color based on current Directory

Change-Id: I6d0ff34eab2659b1fa36e2eb7460945cae29c2b5
parent c0c394e3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ public class NavigationDrawerAdapter extends BaseAdapter {
                break;
            case HEADER:
                convertView = layoutInflater.inflate(RESOURCE_HEADER, parent, false);
                View headerView = convertView.findViewById(R.id.header);
                headerView.setBackgroundColor(item.getSelectedColor());
                break;
            default:
                break;
+9 −3
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class NavigationDrawerController implements ResultCallback<ProviderInfoLi
        mLastRoot = 0;
        String title = null;
        String summary = null;
        int color;
        int color = mCtx.getResources().getColor(R.color.default_primary);

        // Determine display mode
        boolean showRoot = FileManagerApplication.getAccessMode().compareTo(AccessMode.SAFE) != 0;
@@ -128,12 +128,11 @@ public class NavigationDrawerController implements ResultCallback<ProviderInfoLi

        // Load Header
        mNavigationDrawerItemList.add(new NavigationDrawerItem(0, NavigationDrawerItemType.HEADER,
                null, null, 0, 0));
                null, null, 0, color));

        // Load Home and Favorites
        title = mCtx.getResources().getString(R.string.navigation_item_title_home);
        summary = null;
        color = mCtx.getResources().getColor(R.color.default_primary);
        mNavigationDrawerItemList.add(new NavigationDrawerItem(R.id.navigation_item_home,
                NavigationDrawerItemType.SINGLE, title, summary, R.drawable.ic_home, color));
        // TODO: Re-enable Favorites once we have a fragment for it
@@ -443,15 +442,22 @@ public class NavigationDrawerController implements ResultCallback<ProviderInfoLi
            volumePath = StorageHelper.getStorageVolumeFromPath(path);
        }

        NavigationDrawerItem selectedItem = null;
        for (NavigationDrawerItem item : mNavigationDrawerItemList) {
            if (item.getId() == id || (!TextUtils.isEmpty(volumePath) &&
                    TextUtils.equals(item.getSummary(), volumePath))) {
                mCurrentSelection = item.getId();
                item.setSelected(true);
                selectedItem = item;
                break;
            }
        }

         if (selectedItem != null) {
             int selectedColor = selectedItem.getSelectedColor();
             mNavigationDrawerItemList.get(0).setSelectedColor(selectedColor);
         }

        mAdapter.notifyDataSetChanged();
    }

+4 −0
Original line number Diff line number Diff line
@@ -115,6 +115,10 @@ public class NavigationDrawerItem {
        return mSelectedColor;
    }

    public void setSelectedColor(int selectedColor) {
        mSelectedColor = selectedColor;
    }

    public boolean isSelected() {
        return mSelected;
    }