From 1af33fcb64f99a6834fcc88efb3923bb048cc9f2 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 20 Apr 2020 14:43:18 -0500 Subject: [PATCH] Add ripples to header buttons --- app/src/main/java/org/tasks/themes/ThemeColor.java | 4 ++++ app/src/main/java/org/tasks/widget/TasksWidget.java | 12 ++++++++++++ .../main/res/drawable/widget_ripple_circle_dark.xml | 3 +++ .../main/res/drawable/widget_ripple_circle_light.xml | 3 +++ app/src/main/res/drawable/widget_ripple_dark.xml | 3 +++ app/src/main/res/drawable/widget_ripple_light.xml | 3 +++ 6 files changed, 28 insertions(+) create mode 100644 app/src/main/res/drawable/widget_ripple_circle_dark.xml create mode 100644 app/src/main/res/drawable/widget_ripple_circle_light.xml create mode 100644 app/src/main/res/drawable/widget_ripple_dark.xml create mode 100644 app/src/main/res/drawable/widget_ripple_light.xml diff --git a/app/src/main/java/org/tasks/themes/ThemeColor.java b/app/src/main/java/org/tasks/themes/ThemeColor.java index 14d8a7c54..482f890f2 100644 --- a/app/src/main/java/org/tasks/themes/ThemeColor.java +++ b/app/src/main/java/org/tasks/themes/ThemeColor.java @@ -351,6 +351,10 @@ public class ThemeColor implements Pickable { return hintOnPrimary; } + public boolean isDark() { + return isDark; + } + public void apply(Toolbar toolbar) { toolbar.setBackgroundColor(getPrimaryColor()); toolbar.setNavigationIcon(colorDrawable(toolbar.getNavigationIcon(), colorOnPrimary)); diff --git a/app/src/main/java/org/tasks/widget/TasksWidget.java b/app/src/main/java/org/tasks/widget/TasksWidget.java index 30fcd23e5..e2153ea5e 100644 --- a/app/src/main/java/org/tasks/widget/TasksWidget.java +++ b/app/src/main/java/org/tasks/widget/TasksWidget.java @@ -105,6 +105,8 @@ public class TasksWidget extends InjectingAppWidgetProvider { Filter filter = defaultFilterProvider.getFilterFromPreference(filterId); remoteViews.setTextViewText(R.id.widget_title, filter.listingTitle); remoteViews.setRemoteAdapter(R.id.list_view, rvIntent); + setRipple( + remoteViews, color, R.id.widget_button, R.id.widget_change_list, R.id.widget_reconfigure); remoteViews.setOnClickPendingIntent(R.id.widget_title, getOpenListIntent(context, filter, id)); remoteViews.setOnClickPendingIntent(R.id.widget_button, getNewTaskIntent(context, filter, id)); remoteViews.setOnClickPendingIntent(R.id.widget_change_list, getChooseListIntent(context, filter, id)); @@ -119,6 +121,16 @@ public class TasksWidget extends InjectingAppWidgetProvider { return remoteViews; } + private void setRipple(RemoteViews rv, ThemeColor color, int... views) { + int drawableRes = + color.isDark() + ? R.drawable.widget_ripple_circle_light + : R.drawable.widget_ripple_circle_dark; + for (int view : views) { + rv.setInt(view, "setBackgroundResource", drawableRes); + } + } + private @ColorInt int getBackgroundColor(int themeIndex) { int background; if (themeIndex == 1) { diff --git a/app/src/main/res/drawable/widget_ripple_circle_dark.xml b/app/src/main/res/drawable/widget_ripple_circle_dark.xml new file mode 100644 index 000000000..40070582d --- /dev/null +++ b/app/src/main/res/drawable/widget_ripple_circle_dark.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable/widget_ripple_circle_light.xml b/app/src/main/res/drawable/widget_ripple_circle_light.xml new file mode 100644 index 000000000..40070582d --- /dev/null +++ b/app/src/main/res/drawable/widget_ripple_circle_light.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable/widget_ripple_dark.xml b/app/src/main/res/drawable/widget_ripple_dark.xml new file mode 100644 index 000000000..40070582d --- /dev/null +++ b/app/src/main/res/drawable/widget_ripple_dark.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable/widget_ripple_light.xml b/app/src/main/res/drawable/widget_ripple_light.xml new file mode 100644 index 000000000..40070582d --- /dev/null +++ b/app/src/main/res/drawable/widget_ripple_light.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file