From 63bff6b58e0f63db7a9d9b85279da04b89587dfd Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 14 Apr 2020 16:33:38 -0500 Subject: [PATCH] Add option to open list when clicking empty space --- .../tasks/preferences/fragments/ScrollableWidget.kt | 1 + app/src/main/java/org/tasks/widget/TasksWidget.java | 5 +++++ .../main/java/org/tasks/widget/WidgetPreferences.java | 4 ++++ app/src/main/res/values/keys.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/preferences_widget.xml | 8 ++++++++ 6 files changed, 32 insertions(+) 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 e66fe4e13..72f02c887 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt @@ -70,6 +70,7 @@ class ScrollableWidget : InjectingPreferenceFragment() { val showDescription = setupCheckbox(R.string.p_widget_show_description, true) setupCheckbox(R.string.p_widget_show_full_description, false).dependency = showDescription.key setupList(R.string.p_widget_spacing) + setupList(R.string.p_widget_empty_space_click) val showHeader = setupCheckbox(R.string.p_widget_show_header) val showSettings = setupCheckbox(R.string.p_widget_show_settings) showSettings.dependency = showHeader.key diff --git a/app/src/main/java/org/tasks/widget/TasksWidget.java b/app/src/main/java/org/tasks/widget/TasksWidget.java index 832c5b714..729fbfa72 100644 --- a/app/src/main/java/org/tasks/widget/TasksWidget.java +++ b/app/src/main/java/org/tasks/widget/TasksWidget.java @@ -110,6 +110,11 @@ public class TasksWidget extends InjectingAppWidgetProvider { remoteViews.setOnClickPendingIntent(R.id.widget_change_list, getChooseListIntent(context, filter, id)); remoteViews.setOnClickPendingIntent( R.id.widget_reconfigure, getWidgetConfigIntent(context, id)); + if (widgetPreferences.openOnEmptySpaceClick()) { + remoteViews.setOnClickPendingIntent(R.id.empty_view, getOpenListIntent(context, filter, id)); + } else { + remoteViews.setOnClickPendingIntent(R.id.empty_view, null); + } remoteViews.setPendingIntentTemplate(R.id.list_view, getPendingIntentTemplate(context)); return remoteViews; } diff --git a/app/src/main/java/org/tasks/widget/WidgetPreferences.java b/app/src/main/java/org/tasks/widget/WidgetPreferences.java index d080f8e50..59546fc20 100644 --- a/app/src/main/java/org/tasks/widget/WidgetPreferences.java +++ b/app/src/main/java/org/tasks/widget/WidgetPreferences.java @@ -98,6 +98,10 @@ public class WidgetPreferences { return getAlphaValue(R.string.p_widget_empty_space_opacity); } + boolean openOnEmptySpaceClick() { + return preferences.getIntegerFromString(getKey(R.string.p_widget_empty_space_click), 0) == 1; + } + private int getAlphaValue(int resId) { return (int) ((preferences.getInt(getKey(resId), 100) / 100.0) * 255.0); } diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 356795d37..2d18a50ea 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -122,6 +122,16 @@ 2 + + @string/widget_empty_space_do_nothing + @string/widget_empty_space_open_list + + + + 0 + 1 + + 0 @@ -279,6 +289,7 @@ widget-due-date-underneath- widget-header-opacity- widget-empty-space-opacity- + widget-empty-space-click- widget-spacing- dashclock_filter default_remote_list diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6c6f155d8..c0ca4e6d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -413,6 +413,9 @@ File %1$s contained %2$s.\n\n Header settings Row settings Empty space + On click + Do nothing + Open list Clear completed tasks? %s copied %s deleted diff --git a/app/src/main/res/xml/preferences_widget.xml b/app/src/main/res/xml/preferences_widget.xml index c6ce44f06..1740a644f 100644 --- a/app/src/main/res/xml/preferences_widget.xml +++ b/app/src/main/res/xml/preferences_widget.xml @@ -107,6 +107,14 @@ app:seekBarIncrement="5" app:showSeekBarValue="true" /> + + \ No newline at end of file