New widget due date list preference

pull/996/head
Alex Baker 5 years ago
parent 9ce5a727b8
commit 352910a3bc

@ -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
}

@ -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);

@ -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() {

@ -117,7 +117,6 @@
<string name="tmrw">غدا</string>
<string name="yest">أمس</string>
<string name="sync_SPr_interval_title">تحيين في الخلفية</string>
<string name="widget_show_due_date">أظهر تواريخ الإستحقاق</string>
<string name="widget_show_checkboxes">إظهار مربعات التعليم</string>
<string name="widget_show_header">إظهار الهايدر</string>
<string name="widget_show_settings">إظهار الإعدادات</string>

@ -288,7 +288,6 @@
<string name="tmrw">Утре</string>
<string name="yest">Вчера</string>
<string name="sync_SPr_interval_title">Синхронзиране във фонов режим</string>
<string name="widget_show_due_date">Покажи крайните дати</string>
<string name="widget_show_checkboxes">Покажи отметки</string>
<string name="widget_show_header">Покажи хедър</string>
<string name="widget_show_settings">Покажи настройки</string>

@ -181,7 +181,6 @@
<string name="tmrw">Zítra</string>
<string name="yest">Včera</string>
<string name="sync_SPr_interval_title">Synchronizace na pozadí</string>
<string name="widget_show_due_date">Ukázat data splnění</string>
<string name="widget_show_checkboxes">Ukázat zaškrtávací políčka</string>
<string name="widget_show_header">Zobraz záhlaví</string>
<string name="widget_show_settings">Ukaž nastavení</string>

@ -283,7 +283,6 @@
<string name="tmrw">Morg.</string>
<string name="yest">Gest.</string>
<string name="sync_SPr_interval_title">Hintergrund-Synchronisierung</string>
<string name="widget_show_due_date">Zeige Fälligkeitsdatum</string>
<string name="widget_show_checkboxes">Checkboxen anzeigen</string>
<string name="widget_show_header">Kopf anzeigen</string>
<string name="widget_show_settings">Einstellungen anzeigen</string>

@ -289,7 +289,6 @@
<string name="tmrw">Mñna</string>
<string name="yest">Ayer</string>
<string name="sync_SPr_interval_title">Sincronización en segundo plano</string>
<string name="widget_show_due_date">Mostrar fechas de vencimiento</string>
<string name="widget_show_checkboxes">Mostrar casillas de verificación</string>
<string name="widget_show_header">Mostrar encabezado</string>
<string name="widget_show_settings">Mostrar configuración</string>
@ -586,8 +585,6 @@
<string name="widget_empty_space_open_list">Lista abierta</string>
<string name="widget_empty_space_do_nothing">No hagas nada</string>
<string name="widget_empty_space_on_click">Al hacer clic</string>
<string name="widget_empty_space">Espacio vacío</string>
<string name="widget_show_menu">Mostrar el menú</string>
<string name="widget_hide_background">Ocultar fondo</string>
<string name="widget_due_date_underneath">La fecha de vencimiento debajo del título</string>
</resources>

@ -293,7 +293,6 @@
<string name="tmrw">Bihar</string>
<string name="yest">Atzo</string>
<string name="sync_SPr_interval_title">Bigarren planoko sinkronizazioa</string>
<string name="widget_show_due_date">Erakutsi epemuga datak</string>
<string name="widget_show_checkboxes">Erakutsi markaketa-koadroak</string>
<string name="widget_show_header">Erakutsi goiburua</string>
<string name="widget_show_settings">Erakutsi ezarpenak</string>

@ -175,7 +175,6 @@
<string name="tmrw">فردا</string>
<string name="yest">دیروز</string>
<string name="sync_SPr_interval_title">سینک پیش زمینه</string>
<string name="widget_show_due_date">نمایش تاریخ موعود</string>
<string name="widget_show_checkboxes">نمایش محل تیک</string>
<string name="widget_show_header">نمایش سربرگ</string>
<string name="widget_show_settings">نمایش تنظیمات</string>

@ -275,7 +275,6 @@
<string name="tmrw">Huominen</string>
<string name="yest">Eilinen</string>
<string name="sync_SPr_interval_title">Tausta synkronointi</string>
<string name="widget_show_due_date">Näytä määräpäivät</string>
<string name="widget_show_checkboxes">Näytä valintaruudut</string>
<string name="widget_show_header">Näytä otsikot</string>
<string name="widget_show_settings">Näytä asetukset</string>

@ -274,7 +274,6 @@
<string name="tmrw">Demain</string>
<string name="yest">Hier</string>
<string name="sync_SPr_interval_title">Synchro. en arrière-plan</string>
<string name="widget_show_due_date">Montrer les dates d\'échéance</string>
<string name="widget_show_checkboxes">Montrer les cases à cocher</string>
<string name="widget_show_header">Montrer l\'en-tête</string>
<string name="widget_show_settings">Voir les paramètres</string>
@ -579,10 +578,8 @@
<string name="settings_default">Par défaut</string>
<string name="widget_id">ID du widget: %d</string>
<string name="widget_show_menu">Afficher le menu</string>
<string name="widget_due_date_underneath">Date d\'échéance sous le titre</string>
<string name="widget_empty_space_open_list">Liste ouverte</string>
<string name="widget_empty_space_do_nothing">Ne rien faire</string>
<string name="widget_empty_space">Espace vide</string>
<string name="widget_hide_background">Cacher fond</string>
<string name="widget_empty_space_on_click">Sur clic</string>
</resources>

@ -197,7 +197,6 @@
<string name="tmrw">Mñna</string>
<string name="yest">Ayer</string>
<string name="sync_SPr_interval_title">Sincronización en segundo plano</string>
<string name="widget_show_due_date">Mostrar fechas de vencimiento</string>
<string name="widget_show_checkboxes">Mostrar casillas de verificación</string>
<string name="widget_show_header">Mostrar encabezado</string>
<string name="widget_show_settings">Mostrar configuración</string>

@ -288,7 +288,6 @@
<string name="tmrw">Holn</string>
<string name="yest">Tegn</string>
<string name="sync_SPr_interval_title">Szinkronizáció a háttérben</string>
<string name="widget_show_due_date">Határidők megjelenítése</string>
<string name="widget_show_checkboxes">Jelölőnégyzetek megjelenítése</string>
<string name="widget_show_header">Fejléc megjelenítése</string>
<string name="widget_show_settings">Beállítások megjelenítése</string>
@ -582,5 +581,4 @@
<string name="settings_default">Alapértelmezett</string>
<string name="widget_id">Widget azonosító: %d</string>
<string name="widget_show_menu">Menü mutatása</string>
<string name="widget_due_date_underneath">Határidő a cím alatt</string>
</resources>

@ -212,7 +212,6 @@
<string name="tmrw">Bsk</string>
<string name="yest">Kmrn</string>
<string name="sync_SPr_interval_title">Sinkronisasi latar belakang</string>
<string name="widget_show_due_date">Tampilkan tanggal jatuh tempo</string>
<string name="widget_show_checkboxes">Tampilkan kotak centang</string>
<string name="widget_show_header">Tampilkan tajuk</string>
<string name="widget_show_settings">Tampilkan pengaturan</string>

@ -287,7 +287,6 @@
<string name="tmrw">Domani</string>
<string name="yest">Ieri</string>
<string name="sync_SPr_interval_title">Sincronizzazione eseguita in background</string>
<string name="widget_show_due_date">Mostra scadenze</string>
<string name="widget_show_checkboxes">Mostra caselle selezione</string>
<string name="widget_show_header">Mostra intestazione</string>
<string name="widget_show_settings">Mostra impostazioni</string>

@ -323,7 +323,6 @@
<string name="tmrw">מחר</string>
<string name="yest">אתמול</string>
<string name="sync_SPr_interval_title">סנכרון ברקע</string>
<string name="widget_show_due_date">הצג תאריכי יעד</string>
<string name="widget_show_checkboxes">הצג תיבות סימון</string>
<string name="widget_show_header">הצג כותרת</string>
<string name="widget_show_settings">הצג הגדרות</string>

@ -286,7 +286,6 @@
<string name="tmrw">明日</string>
<string name="yest">昨日</string>
<string name="sync_SPr_interval_title">バックグラウンド同期</string>
<string name="widget_show_due_date">期限を表示</string>
<string name="widget_show_checkboxes">チェックボックスを表示</string>
<string name="widget_show_header">ヘッダーを表示</string>
<string name="widget_show_settings">設定を表示</string>

@ -290,7 +290,6 @@
<string name="tmrw">내일</string>
<string name="yest">어제</string>
<string name="sync_SPr_interval_title">백그라운드 동기화</string>
<string name="widget_show_due_date">완료 예정일 표시</string>
<string name="widget_show_checkboxes">체크박스 표시</string>
<string name="widget_show_header">헤더 표시</string>
<string name="widget_show_settings">설정버튼 표시</string>

@ -285,7 +285,6 @@
<string name="tmrw">Ryt</string>
<string name="yest">Vakar</string>
<string name="sync_SPr_interval_title">Foninis sinchronizavimas</string>
<string name="widget_show_due_date">Rodyti pabaigos terminus</string>
<string name="widget_show_checkboxes">Rodyti žymimus kvadratėlius</string>
<string name="widget_show_header">Rodyti antraštę</string>
<string name="widget_show_settings">Rodyti nustatymus</string>

@ -124,7 +124,6 @@
<string name="tomorrow">I morgen</string>
<string name="yesterday">I går</string>
<string name="sync_SPr_interval_title">Bakgrunnssynkronisering</string>
<string name="widget_show_due_date">Vis tidsfrister</string>
<string name="widget_show_checkboxes">Vis avkryssingsbokser</string>
<string name="widget_show_settings">Vis innstillinger</string>
<string name="notifications"> Varsler</string>
@ -539,7 +538,6 @@
<string name="invalid_username_or_password">Ugyldig brukernavn eller passord</string>
<string name="theme_system_default">Systemforvalg</string>
<string name="back">Tilbake</string>
<string name="widget_due_date_underneath">Tidsfristdato under tittel</string>
<string name="widget_hide_background">Skjul bakgrunn</string>
<string name="select_all">Velg alt</string>
<string name="share">Del</string>
@ -550,7 +548,6 @@
<string name="widget_empty_space_open_list">Åpne liste</string>
<string name="widget_empty_space_do_nothing">Ikke gjør noe</string>
<string name="widget_empty_space_on_click">Ved klikk</string>
<string name="widget_empty_space">Tomrom</string>
<string name="menu_discard_changes">Forkast endringer</string>
<string name="widget_show_menu">Vis meny</string>
</resources>

@ -284,7 +284,6 @@
<string name="tmrw">mrgn</string>
<string name="yest">gisteren</string>
<string name="sync_SPr_interval_title">Achtergrond synchronisatie</string>
<string name="widget_show_due_date">Toon einddatums</string>
<string name="widget_show_checkboxes">Toon vinkboxjes</string>
<string name="widget_show_header">Toon titel</string>
<string name="widget_show_settings">Toon instellingen</string>
@ -579,10 +578,8 @@
<string name="settings_default">Standaardwaarde</string>
<string name="widget_id">Widget ID: %d</string>
<string name="widget_show_menu">Toon menu</string>
<string name="widget_due_date_underneath">Einddatum onder de titel</string>
<string name="widget_empty_space_open_list">Open lijst</string>
<string name="widget_empty_space_do_nothing">Doe niets</string>
<string name="widget_empty_space_on_click">Als je klikt</string>
<string name="widget_empty_space">Lege ruimte</string>
<string name="widget_hide_background">Verberg achtergrond</string>
</resources>

@ -300,7 +300,6 @@
<string name="tmrw">jtr</string>
<string name="yest">wcz</string>
<string name="sync_SPr_interval_title">Synchronizacja w tle</string>
<string name="widget_show_due_date">Pokaż terminy</string>
<string name="widget_show_checkboxes">Pokaż przyciski wyboru</string>
<string name="widget_show_header">Pokaż nagłówek</string>
<string name="widget_show_settings">Pokaż ustawienia</string>

@ -286,7 +286,6 @@
<string name="tmrw">Amanhã</string>
<string name="yest">Ontem</string>
<string name="sync_SPr_interval_title">Sincronização em segundo plano</string>
<string name="widget_show_due_date">Mostrar vencimentos</string>
<string name="widget_show_checkboxes">Mostrar tarefas ocultas</string>
<string name="widget_show_header">Mostrar ocultas</string>
<string name="widget_show_settings">Configurações</string>

@ -272,7 +272,6 @@
<string name="tmrw">Amanhã</string>
<string name="yest">Ontem</string>
<string name="sync_SPr_interval_title">Sincronização em segundo plano</string>
<string name="widget_show_due_date">Mostrar datas limite</string>
<string name="widget_show_checkboxes">Mostrar caixas de seleção</string>
<string name="widget_show_header">Mostrar cabeçalho</string>
<string name="widget_show_settings">Definições:</string>

@ -306,7 +306,6 @@
<string name="tmrw">Завтра</string>
<string name="yest">Вчера</string>
<string name="sync_SPr_interval_title">Фоновая синхронизация</string>
<string name="widget_show_due_date">Показать даты</string>
<string name="widget_show_checkboxes">Показать кнопки для галочек</string>
<string name="widget_show_header">Показать заголовок</string>
<string name="widget_show_settings">Показать настройки</string>

@ -286,7 +286,6 @@
<string name="tmrw">Zajtra</string>
<string name="yest">Včera</string>
<string name="sync_SPr_interval_title">Synchronizácia na pozadí</string>
<string name="widget_show_due_date">Ukázať dátumy vypršania </string>
<string name="widget_show_checkboxes">Ukázať zaškrtávacie políčka </string>
<string name="widget_show_header">Ukázať záhlavia </string>
<string name="widget_show_settings">Ukázať nastavenia</string>

@ -197,7 +197,6 @@
<string name="tmrw">Imorgon</string>
<string name="yest">Igår</string>
<string name="sync_SPr_interval_title">Bakgrundssynkronisering</string>
<string name="widget_show_due_date">Visa förfallodatum</string>
<string name="widget_show_checkboxes">Visa kryssrutor</string>
<string name="widget_show_header">Visa rubrik</string>
<string name="widget_show_settings">Visa ikon för inställningar</string>

@ -291,7 +291,6 @@
<string name="tmrw">Yarın</string>
<string name="yest">Dün</string>
<string name="sync_SPr_interval_title">Arka planda eşzamanla</string>
<string name="widget_show_due_date">Bitiş tarihlerini göster</string>
<string name="widget_show_checkboxes">Onay kutularını göster</string>
<string name="widget_show_header">Başlığı göster</string>
<string name="widget_show_settings">Ayarları göster</string>

@ -303,7 +303,6 @@
<string name="tmrw">Звтр</string>
<string name="yest">Вчр</string>
<string name="sync_SPr_interval_title">Фонова синхронізація</string>
<string name="widget_show_due_date">Показувати дату виконання</string>
<string name="widget_show_checkboxes">Показати кнопки для галочок</string>
<string name="widget_show_header">Показати заголовок</string>
<string name="widget_show_settings">Показати налаштування</string>

@ -274,7 +274,6 @@
<string name="tmrw">明天</string>
<string name="yest">昨天</string>
<string name="sync_SPr_interval_title">后台同步</string>
<string name="widget_show_due_date">显示截止日期</string>
<string name="widget_show_checkboxes">显示复选框</string>
<string name="widget_show_header">显示标题</string>
<string name="widget_show_settings">显示设置</string>
@ -575,8 +574,6 @@
<string name="settings_default">默认</string>
<string name="widget_id">部件ID: %d</string>
<string name="widget_show_menu">显示菜单</string>
<string name="widget_due_date_underneath">标题下方显示截止日期</string>
<string name="widget_empty_space">空白空间</string>
<string name="widget_empty_space_open_list">打开列表</string>
<string name="widget_empty_space_do_nothing">什么也不做</string>
<string name="widget_empty_space_on_click">点击时</string>

@ -176,7 +176,6 @@
<string name="tmrw">明天</string>
<string name="yest">昨天</string>
<string name="sync_SPr_interval_title">後台同步</string>
<string name="widget_show_due_date">顯示到期日</string>
<string name="widget_show_checkboxes">顯示核取方塊</string>
<string name="widget_show_header">顯示標頭</string>
<string name="widget_show_settings">顯示設定</string>

@ -132,6 +132,18 @@
<item>1</item>
</string-array>
<string-array name="widget_due_date_position_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="widget_due_date_position">
<item>@string/widget_due_date_after_title</item>
<item>@string/widget_due_date_below_title</item>
<item>@string/widget_due_date_hidden</item>
</string-array>
<string-array name="EPr_default_urgency_values">
<!-- urgency: labels that map EPr_default_urgency items to index in TEA_urgency. -->
<item>0</item>
@ -286,10 +298,10 @@
<string name="p_widget_show_header">widget-show-header-</string>
<string name="p_widget_show_settings">widget-show-settings-</string>
<string name="p_widget_show_menu">widget-show-menu-</string>
<string name="p_widget_due_date_underneath">widget-due-date-underneath-</string>
<string name="p_widget_header_opacity">widget-header-opacity-</string>
<string name="p_widget_empty_space_opacity">widget-empty-space-opacity-</string>
<string name="p_widget_empty_space_click">widget-empty-space-click-</string>
<string name="p_widget_due_date_position">widget-due-date-position-</string>
<string name="p_widget_spacing">widget-spacing-</string>
<string name="p_dashclock_filter">dashclock_filter</string>
<string name="p_default_remote_list">default_remote_list</string>

@ -302,9 +302,7 @@ File %1$s contained %2$s.\n\n
<string name="tmrw">Tmrw</string>
<string name="yest">Yest</string>
<string name="sync_SPr_interval_title">Background sync</string>
<string name="widget_show_due_date">Show due dates</string>
<string name="widget_show_checkboxes">Show checkboxes</string>
<string name="widget_due_date_underneath">Due date below title</string>
<string name="widget_hide_background">Hide background</string>
<string name="widget_show_header">Show header</string>
<string name="widget_show_settings">Show settings</string>
@ -419,6 +417,9 @@ File %1$s contained %2$s.\n\n
<string name="widget_empty_space_on_click">On click</string>
<string name="widget_empty_space_do_nothing">Do nothing</string>
<string name="widget_empty_space_open_list">Open list</string>
<string name="widget_due_date_after_title">After title</string>
<string name="widget_due_date_below_title">Below title</string>
<string name="widget_due_date_hidden">Hidden</string>
<string name="clear_completed_tasks_confirmation">Clear completed tasks?</string>
<string name="copy_multiple_tasks_confirmation">%s copied</string>
<string name="delete_multiple_tasks_confirmation">%s deleted</string>

@ -90,6 +90,14 @@
android:title="@string/row_spacing"
android:summary="%s" />
<ListPreference
android:defaultValue="0"
android:key="@string/p_widget_due_date_position"
android:title="@string/due_date"
android:entryValues="@array/widget_due_date_position_values"
android:entries="@array/widget_due_date_position"
android:summary="%s" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/p_widget_show_description"
@ -109,15 +117,6 @@
android:key="@string/p_widget_show_full_task_title"
android:title="@string/EPr_fullTask_title" />
<SwitchPreferenceCompat
android:key="@string/p_widget_show_due_date"
android:title="@string/widget_show_due_date" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="@string/p_widget_due_date_underneath"
android:title="@string/widget_due_date_underneath" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/widget_footer_settings">

Loading…
Cancel
Save