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/layout/fragment_cooking_assistant_page.xml b/app/src/main/res/layout/fragment_cooking_assistant_page.xml index a8b65b4e..f607f652 100644 --- a/app/src/main/res/layout/fragment_cooking_assistant_page.xml +++ b/app/src/main/res/layout/fragment_cooking_assistant_page.xml @@ -11,7 +11,7 @@ + android:padding="32dp"> 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