From fa55facca41051cffc31f2fa7a1cb041b282ab47 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 4 May 2020 15:10:58 -0500 Subject: [PATCH] Add option to disable widget subtask chip --- .../tasks/preferences/fragments/ScrollableWidget.kt | 1 + .../java/org/tasks/widget/ScrollableViewsFactory.java | 5 +++-- .../main/java/org/tasks/widget/WidgetPreferences.java | 4 ++++ app/src/main/res/values/keys.xml | 1 + app/src/main/res/xml/preferences_widget.xml | 11 +++++++++++ 5 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 4906ceca8..9f1b7ae86 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt @@ -76,6 +76,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_subtasks) 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 aa01fc41f..a347625b8 100644 --- a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java +++ b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java @@ -55,6 +55,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { private int hPad; private boolean handleDueDateClick; private boolean showDividers; + private boolean showSubtasks; private boolean isRtl; private List tasks = new ArrayList<>(); @@ -186,7 +187,6 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { row.setViewVisibility(R.id.widget_description, View.GONE); } - row.setOnClickFillInIntent( R.id.widget_row, new Intent(WidgetClickActivity.EDIT_TASK) @@ -211,7 +211,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { row.setViewVisibility(R.id.divider, View.GONE); } - if (taskContainer.hasChildren()) { + if (showSubtasks && taskContainer.hasChildren()) { row.setOnClickFillInIntent( R.id.subtask_button, new Intent(WidgetClickActivity.TOGGLE_SUBTASKS) @@ -309,6 +309,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { dueDateTextSize = Math.max(10, textSize - 2); filter = defaultFilterProvider.getFilterFromPreference(widgetPreferences.getFilterId()); showDividers = widgetPreferences.showDividers(); + showSubtasks = widgetPreferences.showSubtasks(); isRtl = locale.getDirectionality() == View.LAYOUT_DIRECTION_RTL; } } diff --git a/app/src/main/java/org/tasks/widget/WidgetPreferences.java b/app/src/main/java/org/tasks/widget/WidgetPreferences.java index ac8cbdd90..ceb071a70 100644 --- a/app/src/main/java/org/tasks/widget/WidgetPreferences.java +++ b/app/src/main/java/org/tasks/widget/WidgetPreferences.java @@ -49,6 +49,10 @@ public class WidgetPreferences { return getBoolean(R.string.p_widget_show_dividers, true); } + boolean showSubtasks() { + return getBoolean(R.string.p_widget_show_subtasks, true); + } + public int getDueDatePosition() { return getIntegerFromString(R.string.p_widget_due_date_position, 0); } diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index d019f2031..08143f868 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -302,6 +302,7 @@ widget-show-due-date- widget-show-full-task-title- widget-show-dividers- + widget-show-subtasks- widget-show-description- widget-show-full-description- widget-show-checkboxes- diff --git a/app/src/main/res/xml/preferences_widget.xml b/app/src/main/res/xml/preferences_widget.xml index 03379e693..8d413862d 100644 --- a/app/src/main/res/xml/preferences_widget.xml +++ b/app/src/main/res/xml/preferences_widget.xml @@ -124,6 +124,17 @@ + + + + + +