From 927b905f62ecb44d257009a5cd528cee17dc763d Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Wed, 15 Apr 2020 12:56:08 -0500 Subject: [PATCH] Add option to disable widget row dividers --- .../tasks/preferences/fragments/ScrollableWidget.kt | 1 + .../java/org/tasks/widget/ScrollableViewsFactory.java | 10 ++++++++-- .../main/java/org/tasks/widget/WidgetPreferences.java | 4 ++++ app/src/main/res/values/keys.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/preferences_widget.xml | 5 +++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt index 0d43acf1c..d65126151 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt @@ -75,6 +75,7 @@ class ScrollableWidget : InjectingPreferenceFragment() { setupSlider(R.string.p_widget_font_size, 16) setupCheckbox(R.string.p_widget_show_checkboxes) + setupCheckbox(R.string.p_widget_show_dividers) setupCheckbox(R.string.p_widget_show_full_task_title, false) val showDescription = setupCheckbox(R.string.p_widget_show_description, true) setupCheckbox(R.string.p_widget_show_full_description, false).dependency = showDescription.key diff --git a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java index 9fc8cdd9d..2cac3e100 100644 --- a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java +++ b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java @@ -218,8 +218,14 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { row.setViewPadding(R.id.widget_description, horizontalPadding, 0, horizontalPadding, textBottomPadding); } - int dividerColor = ContextCompat.getColor(context, theme == 0 ? R.color.black_12 : R.color.white_12); - row.setImageViewBitmap(R.id.divider, getSolidBackground(dividerColor)); + if (widgetPreferences.showDividers()) { + int dividerColor = + ContextCompat.getColor(context, theme == 0 ? R.color.black_12 : R.color.white_12); + row.setViewVisibility(R.id.divider, View.VISIBLE); + row.setImageViewBitmap(R.id.divider, getSolidBackground(dividerColor)); + } else { + row.setViewVisibility(R.id.divider, View.GONE); + } row.setInt( R.id.widget_row, "setLayoutDirection", Locale.getInstance(context).getDirectionality()); diff --git a/app/src/main/java/org/tasks/widget/WidgetPreferences.java b/app/src/main/java/org/tasks/widget/WidgetPreferences.java index 5d6a949b5..6b5cabc7c 100644 --- a/app/src/main/java/org/tasks/widget/WidgetPreferences.java +++ b/app/src/main/java/org/tasks/widget/WidgetPreferences.java @@ -46,6 +46,10 @@ public class WidgetPreferences { return preferences.getBoolean(getKey(R.string.p_widget_show_full_description), false); } + boolean showDividers() { + return preferences.getBoolean(getKey(R.string.p_widget_show_dividers), true); + } + public int getDueDatePosition() { int defaultValue = preferences.getBoolean(getKey(R.string.p_widget_show_due_date), true) ? 0 : 2; diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 3a75383da..e7a52e10f 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -292,6 +292,7 @@ widget-font-size- widget-show-due-date- widget-show-full-task-title- + widget-show-dividers- widget-show-description- widget-show-full-description- widget-show-checkboxes- diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 98075651b..0b0df62ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -307,6 +307,7 @@ File %1$s contained %2$s.\n\n Show header Show settings Show menu + Show dividers Notifications Silent Sound diff --git a/app/src/main/res/xml/preferences_widget.xml b/app/src/main/res/xml/preferences_widget.xml index 473bf7145..4ddff5a55 100644 --- a/app/src/main/res/xml/preferences_widget.xml +++ b/app/src/main/res/xml/preferences_widget.xml @@ -117,6 +117,11 @@ android:key="@string/p_widget_show_full_task_title" android:title="@string/EPr_fullTask_title" /> + +