From 352910a3bc8b90f473ac8c5dfce6594e50eb5a9e Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Wed, 15 Apr 2020 12:26:39 -0500 Subject: [PATCH] New widget due date list preference --- .../preferences/fragments/ScrollableWidget.kt | 7 +++---- .../tasks/widget/ScrollableViewsFactory.java | 11 +++++------ .../org/tasks/widget/WidgetPreferences.java | 11 +++++------ app/src/main/res/values-ar/strings.xml | 1 - app/src/main/res/values-bg-rBG/strings.xml | 1 - app/src/main/res/values-cs/strings.xml | 1 - app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 5 +---- app/src/main/res/values-eu/strings.xml | 1 - app/src/main/res/values-fa/strings.xml | 1 - app/src/main/res/values-fi/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 3 --- app/src/main/res/values-gl/strings.xml | 1 - app/src/main/res/values-hu/strings.xml | 4 +--- app/src/main/res/values-id/strings.xml | 1 - app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values-iw/strings.xml | 1 - app/src/main/res/values-ja/strings.xml | 1 - app/src/main/res/values-ko/strings.xml | 1 - app/src/main/res/values-lt/strings.xml | 1 - app/src/main/res/values-nb/strings.xml | 3 --- app/src/main/res/values-nl/strings.xml | 3 --- app/src/main/res/values-pl/strings.xml | 1 - app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-pt/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 1 - app/src/main/res/values-sk/strings.xml | 1 - app/src/main/res/values-sv/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 1 - app/src/main/res/values-uk/strings.xml | 1 - app/src/main/res/values-zh-rCN/strings.xml | 3 --- app/src/main/res/values-zh-rTW/strings.xml | 1 - app/src/main/res/values/keys.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 5 +++-- app/src/main/res/xml/preferences_widget.xml | 17 ++++++++--------- 35 files changed, 39 insertions(+), 70 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 f7567b311..0d43acf1c 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt @@ -74,14 +74,13 @@ class ScrollableWidget : InjectingPreferenceFragment() { } setupSlider(R.string.p_widget_font_size, 16) - val showDueDate = setupCheckbox(R.string.p_widget_show_due_date) - setupCheckbox(R.string.p_widget_due_date_underneath, false).dependency = showDueDate.key setupCheckbox(R.string.p_widget_show_checkboxes) 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 setupList(R.string.p_widget_spacing) setupList(R.string.p_widget_empty_space_click) + setupList(R.string.p_widget_due_date_position, widgetPreferences.dueDatePosition.toString()) val showHeader = setupCheckbox(R.string.p_widget_show_header) val showSettings = setupCheckbox(R.string.p_widget_show_settings) showSettings.dependency = showHeader.key @@ -187,11 +186,11 @@ class ScrollableWidget : InjectingPreferenceFragment() { return preference } - private fun setupList(resId: Int): ListPreference { + private fun setupList(resId: Int, defaultValue: String = "0"): ListPreference { val preference = findPreference(resId) as ListPreference val key = getString(resId) + appWidgetId preference.key = key - preference.value = preferences.getStringValue(key) ?: "0" + preference.value = preferences.getStringValue(key) ?: defaultValue return preference } diff --git a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java index 45a1f0b27..9fc8cdd9d 100644 --- a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java +++ b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java @@ -47,6 +47,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { private final int indentPadding; private boolean showDueDates; + private boolean bottomDueDate; private boolean showCheckboxes; private float textSize; private float dueDateTextSize; @@ -200,10 +201,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { } int horizontalPadding = (int) context.getResources().getDimension(R.dimen.widget_padding); int verticalPadding = widgetPreferences.getWidgetSpacing(); - int textBottomPadding = - showDueDates && task.hasDueDate() && widgetPreferences.dueDateBelowTitle() - ? 0 - : verticalPadding; + int textBottomPadding = bottomDueDate && task.hasDueDate() ? 0 : verticalPadding; row.setViewPadding(R.id.widget_complete_box, horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); if (showCheckboxes) { row.setViewVisibility(R.id.widget_complete_box, View.VISIBLE); @@ -267,7 +265,6 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { } private void formatDueDate(RemoteViews row, Task task) { - boolean bottomDueDate = widgetPreferences.dueDateBelowTitle(); int dueDateRes = bottomDueDate ? R.id.widget_due_bottom : R.id.widget_due_end; row.setViewVisibility(bottomDueDate ? R.id.widget_due_end : R.id.widget_due_bottom, View.GONE); if (task.hasDueDate()) { @@ -291,7 +288,9 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { ContextCompat.getColor(context, isDark ? R.color.white_87 : R.color.black_87); textColorSecondary = ContextCompat.getColor(context, isDark ? R.color.white_60 : R.color.black_60); - showDueDates = widgetPreferences.showDueDate(); + int dueDatePosition = widgetPreferences.getDueDatePosition(); + showDueDates = dueDatePosition != 2; + bottomDueDate = dueDatePosition == 1; showCheckboxes = widgetPreferences.showCheckboxes(); textSize = widgetPreferences.getFontSize(); dueDateTextSize = Math.max(10, textSize - 2); diff --git a/app/src/main/java/org/tasks/widget/WidgetPreferences.java b/app/src/main/java/org/tasks/widget/WidgetPreferences.java index 59546fc20..5d6a949b5 100644 --- a/app/src/main/java/org/tasks/widget/WidgetPreferences.java +++ b/app/src/main/java/org/tasks/widget/WidgetPreferences.java @@ -18,10 +18,6 @@ public class WidgetPreferences { this.widgetId = widgetId; } - boolean showDueDate() { - return preferences.getBoolean(getKey(R.string.p_widget_show_due_date), true); - } - boolean showHeader() { return preferences.getBoolean(getKey(R.string.p_widget_show_header), true); } @@ -50,8 +46,11 @@ public class WidgetPreferences { return preferences.getBoolean(getKey(R.string.p_widget_show_full_description), false); } - boolean dueDateBelowTitle() { - return preferences.getBoolean(getKey(R.string.p_widget_due_date_underneath), false); + public int getDueDatePosition() { + int defaultValue = + preferences.getBoolean(getKey(R.string.p_widget_show_due_date), true) ? 0 : 2; + return preferences.getIntegerFromString( + getKey(R.string.p_widget_due_date_position), defaultValue); } int getWidgetSpacing() { diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 8c43c3b52..ff6335a1e 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -117,7 +117,6 @@ غدا أمس تحيين في الخلفية - أظهر تواريخ الإستحقاق إظهار مربعات التعليم إظهار الهايدر إظهار الإعدادات diff --git a/app/src/main/res/values-bg-rBG/strings.xml b/app/src/main/res/values-bg-rBG/strings.xml index 357e18701..c891ead25 100644 --- a/app/src/main/res/values-bg-rBG/strings.xml +++ b/app/src/main/res/values-bg-rBG/strings.xml @@ -288,7 +288,6 @@ Утре Вчера Синхронзиране във фонов режим - Покажи крайните дати Покажи отметки Покажи хедър Покажи настройки diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 1d713b604..f95003abc 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -181,7 +181,6 @@ Zítra Včera Synchronizace na pozadí - Ukázat data splnění Ukázat zaškrtávací políčka Zobraz záhlaví Ukaž nastavení diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index c1549ab2f..1960181fd 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -283,7 +283,6 @@ Morg. Gest. Hintergrund-Synchronisierung - Zeige Fälligkeitsdatum Checkboxen anzeigen Kopf anzeigen Einstellungen anzeigen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9f4bc8495..b1e0faaad 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -289,7 +289,6 @@ Mñna Ayer Sincronización en segundo plano - Mostrar fechas de vencimiento Mostrar casillas de verificación Mostrar encabezado Mostrar configuración @@ -586,8 +585,6 @@ Lista abierta No hagas nada Al hacer clic - Espacio vacío Mostrar el menú Ocultar fondo - La fecha de vencimiento debajo del título - \ No newline at end of file + diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index fbcaf43cd..971939678 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -293,7 +293,6 @@ Bihar Atzo Bigarren planoko sinkronizazioa - Erakutsi epemuga datak Erakutsi markaketa-koadroak Erakutsi goiburua Erakutsi ezarpenak diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 85103820a..0c915de4e 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -175,7 +175,6 @@ فردا دیروز سینک پیش زمینه - نمایش تاریخ موعود نمایش محل تیک نمایش سربرگ نمایش تنظیمات diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 9b7ec7880..8d77c88a8 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -275,7 +275,6 @@ Huominen Eilinen Tausta synkronointi - Näytä määräpäivät Näytä valintaruudut Näytä otsikot Näytä asetukset diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 7668a7a96..b5c3ad511 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -274,7 +274,6 @@ Demain Hier Synchro. en arrière-plan - Montrer les dates d\'échéance Montrer les cases à cocher Montrer l\'en-tête Voir les paramètres @@ -579,10 +578,8 @@ Par défaut ID du widget: %d Afficher le menu - Date d\'échéance sous le titre Liste ouverte Ne rien faire - Espace vide Cacher fond Sur clic \ No newline at end of file diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index 158e51716..549008810 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -197,7 +197,6 @@ Mñna Ayer Sincronización en segundo plano - Mostrar fechas de vencimiento Mostrar casillas de verificación Mostrar encabezado Mostrar configuración diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 47b6ad604..405c5e928 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -288,7 +288,6 @@ Holn Tegn Szinkronizáció a háttérben - Határidők megjelenítése Jelölőnégyzetek megjelenítése Fejléc megjelenítése Beállítások megjelenítése @@ -582,5 +581,4 @@ Alapértelmezett Widget azonosító: %d Menü mutatása - Határidő a cím alatt - \ No newline at end of file + diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index 780180cec..5eb562e65 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -212,7 +212,6 @@ Bsk Kmrn Sinkronisasi latar belakang - Tampilkan tanggal jatuh tempo Tampilkan kotak centang Tampilkan tajuk Tampilkan pengaturan diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9c3a749e8..f95e0fd47 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -287,7 +287,6 @@ Domani Ieri Sincronizzazione eseguita in background - Mostra scadenze Mostra caselle selezione Mostra intestazione Mostra impostazioni diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 004389a14..25eb203b2 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -323,7 +323,6 @@ מחר אתמול סנכרון ברקע - הצג תאריכי יעד הצג תיבות סימון הצג כותרת הצג הגדרות diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 06c761203..05725aaef 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -286,7 +286,6 @@ 明日 昨日 バックグラウンド同期 - 期限を表示 チェックボックスを表示 ヘッダーを表示 設定を表示 diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 021b8b3c0..0672fefbf 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -290,7 +290,6 @@ 내일 어제 백그라운드 동기화 - 완료 예정일 표시 체크박스 표시 헤더 표시 설정버튼 표시 diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 47f7267bf..14b30d09e 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -285,7 +285,6 @@ Ryt Vakar Foninis sinchronizavimas - Rodyti pabaigos terminus Rodyti žymimus kvadratėlius Rodyti antraštę Rodyti nustatymus diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 83e1bfb97..3bc9f4958 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -124,7 +124,6 @@ I morgen I går Bakgrunnssynkronisering - Vis tidsfrister Vis avkryssingsbokser Vis innstillinger Varsler @@ -539,7 +538,6 @@ Ugyldig brukernavn eller passord Systemforvalg Tilbake - Tidsfristdato under tittel Skjul bakgrunn Velg alt Del @@ -550,7 +548,6 @@ Åpne liste Ikke gjør noe Ved klikk - Tomrom Forkast endringer Vis meny \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 49d9ad94f..ea867ddef 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -284,7 +284,6 @@ mrgn gisteren Achtergrond synchronisatie - Toon einddatums Toon vinkboxjes Toon titel Toon instellingen @@ -579,10 +578,8 @@ Standaardwaarde Widget ID: %d Toon menu - Einddatum onder de titel Open lijst Doe niets Als je klikt - Lege ruimte Verberg achtergrond \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 0eb7a3011..2c5df2d77 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -300,7 +300,6 @@ jtr wcz Synchronizacja w tle - Pokaż terminy Pokaż przyciski wyboru Pokaż nagłówek Pokaż ustawienia diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 7599ae646..da9409bdd 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -286,7 +286,6 @@ Amanhã Ontem Sincronização em segundo plano - Mostrar vencimentos Mostrar tarefas ocultas Mostrar ocultas Configurações diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 25fc33948..8bd2893c3 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -272,7 +272,6 @@ Amanhã Ontem Sincronização em segundo plano - Mostrar datas limite Mostrar caixas de seleção Mostrar cabeçalho Definições: diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 33b957ad4..2573ba3b1 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -306,7 +306,6 @@ Завтра Вчера Фоновая синхронизация - Показать даты Показать кнопки для галочек Показать заголовок Показать настройки diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 814fb9d28..4919b30fe 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -286,7 +286,6 @@ Zajtra Včera Synchronizácia na pozadí - Ukázať dátumy vypršania Ukázať zaškrtávacie políčka Ukázať záhlavia Ukázať nastavenia diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 553522588..7d2266af9 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -197,7 +197,6 @@ Imorgon Igår Bakgrundssynkronisering - Visa förfallodatum Visa kryssrutor Visa rubrik Visa ikon för inställningar diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 2d3d0c46a..6817fcd0e 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -291,7 +291,6 @@ Yarın Dün Arka planda eşzamanla - Bitiş tarihlerini göster Onay kutularını göster Başlığı göster Ayarları göster diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index c31cca37b..ef3387d83 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -303,7 +303,6 @@ Звтр Вчр Фонова синхронізація - Показувати дату виконання Показати кнопки для галочок Показати заголовок Показати налаштування diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 15600ce1a..a9b986a69 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -274,7 +274,6 @@ 明天 昨天 后台同步 - 显示截止日期 显示复选框 显示标题 显示设置 @@ -575,8 +574,6 @@ 默认 部件ID: %d 显示菜单 - 标题下方显示截止日期 - 空白空间 打开列表 什么也不做 点击时 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index fe9865921..05b4dcb03 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -176,7 +176,6 @@ 明天 昨天 後台同步 - 顯示到期日 顯示核取方塊 顯示標頭 顯示設定 diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 2d18a50ea..3a75383da 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -132,6 +132,18 @@ 1 + + 0 + 1 + 2 + + + + @string/widget_due_date_after_title + @string/widget_due_date_below_title + @string/widget_due_date_hidden + + 0 @@ -286,10 +298,10 @@ widget-show-header- widget-show-settings- widget-show-menu- - widget-due-date-underneath- widget-header-opacity- widget-empty-space-opacity- widget-empty-space-click- + widget-due-date-position- 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 dad8a3eaa..98075651b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -302,9 +302,7 @@ File %1$s contained %2$s.\n\n Tmrw Yest Background sync - Show due dates Show checkboxes - Due date below title Hide background Show header Show settings @@ -419,6 +417,9 @@ File %1$s contained %2$s.\n\n On click Do nothing Open list + After title + Below title + Hidden 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 3aa3e671b..473bf7145 100644 --- a/app/src/main/res/xml/preferences_widget.xml +++ b/app/src/main/res/xml/preferences_widget.xml @@ -90,6 +90,14 @@ android:title="@string/row_spacing" android:summary="%s" /> + + - - - -