From 76ccb864097d5e3831ba8101ffe2f796f3b68376 Mon Sep 17 00:00:00 2001 From: flauschtrud Date: Thu, 12 Dec 2024 16:01:06 +0100 Subject: [PATCH 1/3] Use left-aligned text instead of centered text in cooking mode for accessability reasons #257 --- .../fragment_cooking_assistant_page.xml | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/app/src/main/res/layout/fragment_cooking_assistant_page.xml b/app/src/main/res/layout/fragment_cooking_assistant_page.xml index a8b65b4e..5322a394 100644 --- a/app/src/main/res/layout/fragment_cooking_assistant_page.xml +++ b/app/src/main/res/layout/fragment_cooking_assistant_page.xml @@ -11,25 +11,16 @@ - - + android:padding="32dp"> @@ -38,14 +29,13 @@ android:id="@+id/cooking_assistant_text" android:layout_width="wrap_content" android:layout_height="wrap_content" + app:layout_constraintTop_toBottomOf="@id/cooking_assistant_title" + app:layout_constraintStart_toStartOf="parent" android:minHeight="@dimen/min_height_for_accessibility" - android:gravity="center" android:scrollbars="vertical" android:text="@{viewModel.text}" android:textAppearance="@style/TextAppearance.AppCompat.Large" /> - - From 50e19a2281ed50ea4ef6f34092f43b819ba7a41c Mon Sep 17 00:00:00 2001 From: flauschtrud Date: Fri, 13 Dec 2024 16:20:32 +0100 Subject: [PATCH 2/3] Only show the "not adjusted" message if the ingredient line contains any numbers at all #255 --- .../broccoli/recipe/RecipeModule.java | 8 ++++++ .../ingredients/ScaledQuantityBuilder.java | 21 +------------- app/src/main/res/values-b+sr+Latn/strings.xml | 1 - app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-el/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-hi/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-nb/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-pl/strings.xml | 1 - app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-ru/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-zh/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - .../ScaledQuantityBuilderTest.java | 28 +++++-------------- 21 files changed, 16 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/com/flauschcode/broccoli/recipe/RecipeModule.java b/app/src/main/java/com/flauschcode/broccoli/recipe/RecipeModule.java index 47adea7a..70b3196a 100644 --- a/app/src/main/java/com/flauschcode/broccoli/recipe/RecipeModule.java +++ b/app/src/main/java/com/flauschcode/broccoli/recipe/RecipeModule.java @@ -2,6 +2,8 @@ import android.app.Application; +import com.flauschcode.broccoli.recipe.ingredients.ScaledQuantityBuilder; + import javax.inject.Singleton; import dagger.Module; @@ -17,4 +19,10 @@ Compressor compressor(Application application) { return new Compressor(application); } + @Provides + @Singleton + ScaledQuantityBuilder scaledQuantityBuilder() { + return new ScaledQuantityBuilder(); + } + } diff --git a/app/src/main/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilder.java b/app/src/main/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilder.java index 77264e7d..b5962b38 100644 --- a/app/src/main/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilder.java +++ b/app/src/main/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilder.java @@ -1,25 +1,10 @@ package com.flauschcode.broccoli.recipe.ingredients; -import android.app.Application; - -import com.flauschcode.broccoli.R; - import java.text.DecimalFormat; import java.text.Normalizer; -import javax.inject.Inject; -import javax.inject.Singleton; - -@Singleton public class ScaledQuantityBuilder { - private final Application application; - - @Inject - public ScaledQuantityBuilder(Application application) { - this.application = application; - } - private static final DecimalFormat decimalFormat = new DecimalFormat("0.##"); public String from(String quantity, float scaleFactor) { @@ -40,7 +25,7 @@ public String from(String quantity, float scaleFactor) { return scale(quantity, scaleFactor); } catch (NumberFormatException e) { - return "(" + getNotScaledString() + ") " + quantity; + return quantity; } } @@ -108,8 +93,4 @@ private String prettyPrint(float f) { return f == i ? String.valueOf(i) : decimalFormat.format(f); } - private String getNotScaledString() { - return application.getString(R.string.unscaled); - } - } diff --git a/app/src/main/res/values-b+sr+Latn/strings.xml b/app/src/main/res/values-b+sr+Latn/strings.xml index a16340bf..ed2015c6 100644 --- a/app/src/main/res/values-b+sr+Latn/strings.xml +++ b/app/src/main/res/values-b+sr+Latn/strings.xml @@ -55,7 +55,6 @@ Za Količina u receptu Koeficijent skaliranja - nije prilagođeno Podeli Podeli sa %1$s Žao nam je, ovo nije uspelo. diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index cbb8941d..1163d5cb 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -46,7 +46,6 @@ Dieses Rezept hat noch keine Zutaten oder Anleitung. Kochen Zutaten anpassen - nicht angepasst Teilen Geteilt mit %1$s Das hat leider nicht funktioniert. diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 149d98d0..6660daa0 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -55,7 +55,6 @@ Pro Recipe amount Scaling factor - not adjusted Share Shared with %1$s Sorry, this did not work. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index bb9f01a0..ea5f8f6c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -56,7 +56,6 @@ Pro Cantidad de la receta Factor de escala - no ajustado Compartir Compartido con %1$s Lo sentimos, esto no ha funcionado. diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 166dccaf..3b96c63c 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -55,7 +55,6 @@ Pro Quantité de la recette Facteur d\'échelle - non ajusté Partager Partagé avec %1$s Désolé, cela n\'a pas fonctionné. diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index ae11d821..162b4d85 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -55,7 +55,6 @@ Pro Recipe amount Scaling factor - not adjusted Share Shared with %1$s Sorry, this did not work. diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index bf85f10c..b3a7fa19 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -55,7 +55,6 @@ Avanzato Quantità ricetta Fattore di scala - non personalizzato Condividi Condividi con %1$s Siamo spiacenti, si è verificato un errore. diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 2bf6b335..40b3cadf 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -55,7 +55,6 @@ פרו כמות במתכון מכפיל מידות - לא מותאם שתף ‏שתף באמצעות %1$s מצטער, הפעולה לא הצליחה diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 7a88f4fe..c7091209 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -55,7 +55,6 @@ プロ レシピの量 倍率 - 調整していない 共有 %1$sと共有 もし訳ありませんが、動作はが失敗しました。 diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 0dfccd77..b96f8408 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -55,7 +55,6 @@ Pro Oppskriftens mengde Skaleringsfaktor - ikke justert Del Delt med %1$s Beklager, dette fungerte ikke. diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index bf224b73..b7121fe1 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -55,7 +55,6 @@ Geavanceerd Recipe amount Schalingsfactor - ongewijzigd Delen Gedeeld met %1$s Sorry, dit is niet gelukt. diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 5c0e7cd3..59da9b24 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -55,7 +55,6 @@ Pro Recipe amount Współczynnik skalowania - niedostosowane Udostępnij Udostępniono przez %1$s Przepraszamy, ale to nie zadziałało. diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 4652d810..abd4c6d5 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -55,7 +55,6 @@ Profissional Quantidade da receita Proporção - não ajustado Compartilhar Compartilhado com %1$s Desculpe, isso não funcionou. diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index f57bc120..96497649 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -55,7 +55,6 @@ Сложный Количество рецептов Коэффициент масштабирования - не отрегулировано Поделиться Поделились с помощью %1$s К сожалению, это не работает. diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 8cfc848d..e903e47e 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -55,7 +55,6 @@ Pro Receptmängd Skalningsfaktor - ej justerad Share Shared with %1$s Tyvärr fungerade inte detta. diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 7ae8ba34..c5f29c3f 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -55,7 +55,6 @@ Profesyonel Tarif miktarı Ölçekleme faktörü - ölçeklenmemiş Paylaş %1$s ile paylaşıldı Üzgünüz, bu işlem başarısız oldu. diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 01f8fe4a..36402c59 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -55,7 +55,6 @@ 高级 食谱分量 比例倍数 - 未调整 分享 已与 %1$s 分享 抱歉,此操作不可用。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 460cbf34..2fcaf7ff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,7 +64,6 @@ Pro Recipe amount Scaling factor - not adjusted Share Shared with %1$s diff --git a/app/src/test/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilderTest.java b/app/src/test/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilderTest.java index e9dbe7dc..0245ec9b 100644 --- a/app/src/test/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilderTest.java +++ b/app/src/test/java/com/flauschcode/broccoli/recipe/ingredients/ScaledQuantityBuilderTest.java @@ -1,27 +1,16 @@ package com.flauschcode.broccoli.recipe.ingredients; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.when; - -import android.app.Application; -import com.flauschcode.broccoli.R; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ScaledQuantityBuilderTest { - @Mock - private Application application; - - @InjectMocks - private ScaledQuantityBuilder scaledQuantityBuilder; + private final ScaledQuantityBuilder scaledQuantityBuilder = new ScaledQuantityBuilder(); @Test public void scale_integer_quantity() { @@ -61,23 +50,20 @@ public void scale_fraction_range_quantity() { @Test public void scale_non_scalable_quantity() { - when(application.getString(R.string.unscaled)).thenReturn("not scaled"); String scaled = scaledQuantityBuilder.from("je 1", 2f); - assertThat(scaled, is("(not scaled) je 1")); + assertThat(scaled, is("je 1")); } @Test public void scale_missing_quantity() { - when(application.getString(R.string.unscaled)).thenReturn("not scaled"); String scaled = scaledQuantityBuilder.from("", 2f); - assertThat(scaled, is("(not scaled) ")); + assertThat(scaled, is("")); } @Test public void scale_incomplete_range() { - when(application.getString(R.string.unscaled)).thenReturn("not scaled"); String scaled = scaledQuantityBuilder.from("1-", 2f); - assertThat(scaled, is("(not scaled) 1-")); + assertThat(scaled, is("1-")); } } \ No newline at end of file From 648d9a56f96ce5f3dd76cd9f6e6f9c752314e596 Mon Sep 17 00:00:00 2001 From: flauschtrud Date: Fri, 13 Dec 2024 16:38:25 +0100 Subject: [PATCH 3/3] Use left-aligned text instead of centered text in cooking mode for accessability reasons #257 Reverted some changes that broke the ability to scroll the page's text. --- .../fragment_cooking_assistant_page.xml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/layout/fragment_cooking_assistant_page.xml b/app/src/main/res/layout/fragment_cooking_assistant_page.xml index 5322a394..f607f652 100644 --- a/app/src/main/res/layout/fragment_cooking_assistant_page.xml +++ b/app/src/main/res/layout/fragment_cooking_assistant_page.xml @@ -13,14 +13,23 @@ android:layout_height="match_parent" android:padding="32dp"> + + @@ -29,13 +38,13 @@ android:id="@+id/cooking_assistant_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@id/cooking_assistant_title" - app:layout_constraintStart_toStartOf="parent" android:minHeight="@dimen/min_height_for_accessibility" android:scrollbars="vertical" android:text="@{viewModel.text}" android:textAppearance="@style/TextAppearance.AppCompat.Large" /> + +