diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-12-19 11:25:34 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-12-22 00:17:24 +0300 |
commit | c66a96fffff939a0f5dbedb7eda8f7967a079ff9 (patch) | |
tree | f2b384416828069e1af4fc4e366c04b735a0ed8b /app/src/main | |
parent | 969b35bb7a0cc79427b8d85b48c2cf6e5aca0a8d (diff) |
Highlight current board in drawer
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main')
5 files changed, 57 insertions, 2 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 06fa3186b..93ca02044 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -654,6 +654,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener startActivity(ArchivedBoardsActvitiy.createIntent(MainActivity.this, mainViewModel.getCurrentAccount())); break; default: + binding.navigationView.setCheckedItem(item); setCurrentBoard(boardsList.get(item.getItemId())); break; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/DrawerMenuUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/DrawerMenuUtil.java index 1a88bec97..43a9e6299 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/util/DrawerMenuUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/DrawerMenuUtil.java @@ -39,7 +39,9 @@ public class DrawerMenuUtil { SubMenu boardsMenu = menu.addSubMenu(R.string.simple_boards); int index = 0; for (Board board : boards) { - MenuItem m = boardsMenu.add(Menu.NONE, index++, Menu.NONE, board.getTitle()).setIcon(ViewUtil.getTintedImageView(context, R.drawable.circle_grey600_36dp, board.getColor())); + MenuItem m = boardsMenu + .add(Menu.NONE, index++, Menu.NONE, board.getTitle()).setIcon(ViewUtil.getTintedImageView(context, R.drawable.circle_grey600_36dp, board.getColor())) + .setCheckable(true); if (currentServerVersionIsSupported) { if (board.isPermissionManage()) { AppCompatImageButton contextMenu = new AppCompatImageButton(context); diff --git a/app/src/main/res/drawable-v21/bg_navdrawer_item.xml b/app/src/main/res/drawable-v21/bg_navdrawer_item.xml new file mode 100644 index 000000000..a366c0d23 --- /dev/null +++ b/app/src/main/res/drawable-v21/bg_navdrawer_item.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<ripple xmlns:android="http://schemas.android.com/apk/res/android" + android:color="?colorControlHighlight"> + + <item + android:id="@android:id/mask" + android:left="@dimen/spacer_1x" + android:right="@dimen/spacer_1x"> + + <shape android:shape="rectangle"> + <!-- value of color is irrelevant, but solid needs to be defined for mask to work --> + <solid android:color="@color/bg_highlighted" /> + <corners android:radius="@dimen/spacer_1hx" /> + </shape> + </item> + + <item + android:left="@dimen/spacer_1x" + android:right="@dimen/spacer_1x"> + + <selector> + <item android:state_selected="true"> + <shape android:shape="rectangle"> + <corners android:radius="@dimen/spacer_1hx" /> + <solid android:color="@color/bg_highlighted" /> + </shape> + </item> + + <item> + <shape android:shape="rectangle"> + <corners android:radius="@dimen/spacer_1hx" /> + </shape> + </item> + </selector> + </item> + +</ripple>
\ No newline at end of file diff --git a/app/src/main/res/drawable/bg_navdrawer_item.xml b/app/src/main/res/drawable/bg_navdrawer_item.xml new file mode 100644 index 000000000..b12a86343 --- /dev/null +++ b/app/src/main/res/drawable/bg_navdrawer_item.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android" android:left="@dimen/spacer_1x" android:right="@dimen/spacer_1x"> + + <item android:state_selected="true"> + <shape android:shape="rectangle"> + <solid android:color="@color/bg_highlighted" /> + </shape> + </item> + + <item> + <shape android:shape="rectangle" /> + </item> + +</selector>
\ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0692fb8d6..2634e94e5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -220,6 +220,7 @@ android:background="?attr/colorPrimary" android:fitsSystemWindows="false" android:theme="@style/NavigationView" - app:headerLayout="@layout/nav_header_main" /> + app:headerLayout="@layout/nav_header_main" + app:itemBackground="@drawable/bg_navdrawer_item" /> </androidx.drawerlayout.widget.DrawerLayout> |