From 08fe725c85e8b353d44c3ea3e93b281e1f6ec545 Mon Sep 17 00:00:00 2001 From: Faltenreich Date: Sun, 14 Jun 2020 12:05:59 +0200 Subject: [PATCH] Differentiate error for empty food list on active filters --- .../food/search/FoodSearchFragment.java | 19 +++++++++++++------ app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-es/strings.xml | 2 ++ app/src/main/res/values-fr/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/faltenreich/diaguard/feature/food/search/FoodSearchFragment.java b/app/src/main/java/com/faltenreich/diaguard/feature/food/search/FoodSearchFragment.java index 952435cb5..3d8a478f3 100644 --- a/app/src/main/java/com/faltenreich/diaguard/feature/food/search/FoodSearchFragment.java +++ b/app/src/main/java/com/faltenreich/diaguard/feature/food/search/FoodSearchFragment.java @@ -24,6 +24,7 @@ import com.faltenreich.diaguard.feature.preference.data.PreferenceStore; import com.faltenreich.diaguard.shared.data.database.dao.FoodDao; import com.faltenreich.diaguard.shared.data.database.entity.Food; +import com.faltenreich.diaguard.shared.data.primitive.StringUtils; import com.faltenreich.diaguard.shared.data.repository.FoodRepository; import com.faltenreich.diaguard.shared.event.Events; import com.faltenreich.diaguard.shared.event.data.FoodDeletedEvent; @@ -183,7 +184,9 @@ private void clear() { private void showEmptyList() { if (getContext() != null) { - if (NetworkingUtils.isOnline(getContext())) { + if (StringUtils.isBlank(searchView.getQuery())) { + showError(R.drawable.ic_settings, R.string.error_no_data, R.string.error_no_data_settings_desc, R.string.settings_open); + } else if (NetworkingUtils.isOnline(getContext())) { showError(R.drawable.ic_sad, R.string.error_no_data, R.string.error_no_data_desc, R.string.food_add_desc); } else { showError(R.drawable.ic_wifi, R.string.error_no_connection, R.string.error_no_connection_desc, R.string.try_again); @@ -220,12 +223,16 @@ void onFabClick() { @OnClick(R.id.food_search_empty_button) void onEmptyButtonClick() { - // Workaround since CONNECTIVITY_ACTION broadcasts cannot be caught since API level 24 - boolean wasNetworkError = emptyText.getText().toString().equals(getString(R.string.error_no_connection)); - if (wasNetworkError) { - newSearch(); + if (StringUtils.isBlank(searchView.getQuery())) { + openSettings(); } else { - createFood(); + // Workaround since CONNECTIVITY_ACTION broadcasts cannot be caught since API level 24 + boolean wasNetworkError = emptyText.getText().toString().equals(getString(R.string.error_no_connection)); + if (wasNetworkError) { + newSearch(); + } else { + createFood(); + } } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 571b21aa5..d47d539b3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -270,6 +270,7 @@ Geh online, um mehr Informationen zu erhalten Gähnende Leere? Versuche es mit einem anderen Suchbegriff oder erstelle ein + Ändere die Einstellungen für mehr Ergebnisse Keine App zum Senden von E-Mails gefunden Keine App zum Öffnen der Datei gefunden Speicherkarte nicht verfügbar @@ -379,5 +380,6 @@ Schließen Basalrate Grundbedarf an Insulin + Einstellungen öffnen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 005e3a2f8..419918b8f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -281,6 +281,7 @@ Vaya en línea para obtener más información Tener los bolsillos vacios? Pruebe otra consulta para mejorar sus resultados o + Cambiar la configuración para obtener más resultados Alimento Comida alimento Eliminar alimentos @@ -382,5 +383,6 @@ Cerrar Tasa basal Necesidades básicas de insulina + Abrir los ajustes diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index db4f090d9..c989d3830 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -279,6 +279,7 @@ Aller en ligne pour obtenir plus d\'informations Rien trouvé Essayez une autre requête pour améliorer vos résultats ou + Modifier les paramètres pour plus de résultats Aliment Alimentation commune Supprimer un aliment @@ -380,5 +381,6 @@ Fermer Débit de base Les besoins de base en insuline + Paramètres ouverts \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fb84df283..d53dbee5b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -434,6 +434,7 @@ Go online to get more information Gaping emptiness? Try another query to improve your results or + Change settings for more results No app found to send E-Mail No app found to open file SD card not available @@ -555,5 +556,6 @@ Close Basal rate Basic insulin needs + Open settings \ No newline at end of file