diff --git a/android/res/drawable-hdpi/ic_taxi_logo_rutaxi.png b/android/res/drawable-hdpi/ic_taxi_logo_rutaxi.png new file mode 100644 index 0000000000..f6c3d4c270 Binary files /dev/null and b/android/res/drawable-hdpi/ic_taxi_logo_rutaxi.png differ diff --git a/android/res/drawable-mdpi/ic_taxi_logo_rutaxi.png b/android/res/drawable-mdpi/ic_taxi_logo_rutaxi.png new file mode 100644 index 0000000000..2a2d86e7d9 Binary files /dev/null and b/android/res/drawable-mdpi/ic_taxi_logo_rutaxi.png differ diff --git a/android/res/drawable-xhdpi/ic_taxi_logo_rutaxi.png b/android/res/drawable-xhdpi/ic_taxi_logo_rutaxi.png new file mode 100644 index 0000000000..2e56eddd14 Binary files /dev/null and b/android/res/drawable-xhdpi/ic_taxi_logo_rutaxi.png differ diff --git a/android/res/drawable-xxhdpi/ic_taxi_logo_rutaxi.png b/android/res/drawable-xxhdpi/ic_taxi_logo_rutaxi.png new file mode 100644 index 0000000000..e0e32f3d70 Binary files /dev/null and b/android/res/drawable-xxhdpi/ic_taxi_logo_rutaxi.png differ diff --git a/android/res/drawable-xxxhdpi/ic_taxi_logo_rutaxi.png b/android/res/drawable-xxxhdpi/ic_taxi_logo_rutaxi.png new file mode 100644 index 0000000000..ea502bea23 Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_taxi_logo_rutaxi.png differ diff --git a/android/res/values/donottranslate.xml b/android/res/values/donottranslate.xml index 34b457df20..09316ee10c 100644 --- a/android/res/values/donottranslate.xml +++ b/android/res/values/donottranslate.xml @@ -92,4 +92,5 @@ pref_opt_out_mopub pref_opt_out_flurry + RuTaxi diff --git a/android/src/com/mapswithme/maps/taxi/DefaultFormatPriceStrategy.java b/android/src/com/mapswithme/maps/taxi/DefaultFormatPriceStrategy.java new file mode 100644 index 0000000000..c5d19330e9 --- /dev/null +++ b/android/src/com/mapswithme/maps/taxi/DefaultFormatPriceStrategy.java @@ -0,0 +1,13 @@ +package com.mapswithme.maps.taxi; + +import android.support.annotation.NonNull; + +class DefaultFormatPriceStrategy implements FormatPriceStrategy +{ + @NonNull + @Override + public String format(@NonNull TaxiInfo.Product product) + { + return product.getPrice(); + } +} diff --git a/android/src/com/mapswithme/maps/taxi/FormatPriceStrategy.java b/android/src/com/mapswithme/maps/taxi/FormatPriceStrategy.java new file mode 100644 index 0000000000..a90ca4c57f --- /dev/null +++ b/android/src/com/mapswithme/maps/taxi/FormatPriceStrategy.java @@ -0,0 +1,9 @@ +package com.mapswithme.maps.taxi; + +import android.support.annotation.NonNull; + +interface FormatPriceStrategy +{ + @NonNull + String format(@NonNull TaxiInfo.Product product); +} diff --git a/android/src/com/mapswithme/maps/taxi/LocaleDependentFormatPriceStrategy.java b/android/src/com/mapswithme/maps/taxi/LocaleDependentFormatPriceStrategy.java new file mode 100644 index 0000000000..e4e33c573a --- /dev/null +++ b/android/src/com/mapswithme/maps/taxi/LocaleDependentFormatPriceStrategy.java @@ -0,0 +1,15 @@ +package com.mapswithme.maps.taxi; + +import android.support.annotation.NonNull; + +import com.mapswithme.util.Utils; + +class LocaleDependentFormatPriceStrategy implements FormatPriceStrategy +{ + @NonNull + @Override + public String format(@NonNull TaxiInfo.Product product) + { + return Utils.formatCurrencyString(product.getPrice(), product.getCurrency()); + } +} diff --git a/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java b/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java index 817fb8c042..3f28fb0caa 100644 --- a/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java +++ b/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java @@ -10,6 +10,7 @@ import android.widget.TextView; import com.mapswithme.maps.R; import com.mapswithme.maps.routing.RoutingController; +import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; import java.util.List; @@ -53,35 +54,21 @@ public class TaxiAdapter extends PagerAdapter String separator; // We ignore all Yandex.Taxi product names until they do support of passing product parameters // to their app via deeplink. - if (mType == TaxiType.YANDEX || mType == TaxiType.MAXIM) - { - name.setText(mType.getTitle()); - separator = " • ~"; - } - else - { - name.setText(product.getName()); - separator = " • "; - } - TextView timeAndPrice = (TextView) v.findViewById(R.id.arrival_time_price); + boolean isApproxPrice = mType.isApproximatePrice(); + name.setText(isApproxPrice ? mContext.getString(mType.getTitle()) : product.getName()); + separator = UiUtils.PHRASE_SEPARATOR + (isApproxPrice ? UiUtils.APPROXIMATE_SYMBOL : ""); + TextView timeAndPriceView = (TextView) v.findViewById(R.id.arrival_time_price); int time = Integer.parseInt(product.getTime()); CharSequence waitTime = RoutingController.formatRoutingTime(mContext, time, R.dimen.text_size_body_3); - timeAndPrice.setText(mContext.getString(R.string.taxi_wait, waitTime + separator - + formatPrice(product))); + String formattedPrice = mType.getFormatPriceStrategy().format(product); + String timeAndPriceValue = waitTime + separator + formattedPrice; + String timeAndPrice = mContext.getString(mType.getWaitingTemplateResId(), timeAndPriceValue); + timeAndPriceView.setText(timeAndPrice); container.addView(v, 0); return v; } - @NonNull - private String formatPrice(@NonNull TaxiInfo.Product product) - { - if (mType == TaxiType.YANDEX) - return Utils.formatCurrencyString(product.getPrice(), product.getCurrency()); - // For Uber and Maxim we don't do formatting, because Uber and Maxim does it on its side. - return product.getPrice(); - } - @Override public void destroyItem(ViewGroup container, int position, Object object) { diff --git a/android/src/com/mapswithme/maps/taxi/TaxiType.java b/android/src/com/mapswithme/maps/taxi/TaxiType.java index 894d024973..497cdb3580 100644 --- a/android/src/com/mapswithme/maps/taxi/TaxiType.java +++ b/android/src/com/mapswithme/maps/taxi/TaxiType.java @@ -7,6 +7,11 @@ import android.support.annotation.StringRes; import com.mapswithme.maps.R; import com.mapswithme.util.Utils; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; + public enum TaxiType { UBER @@ -41,7 +46,7 @@ public enum TaxiType return "Uber"; } }, - YANDEX + YANDEX(new LocaleDependentFormatPriceStrategy()) { @NonNull public String getPackageName() @@ -105,7 +110,7 @@ public enum TaxiType return "Maxim"; } }, - RUTAXI + RUTAXI(R.string.place_page_starting_from, new LocaleDependentFormatPriceStrategy()) { @NonNull public String getPackageName() @@ -122,13 +127,13 @@ public enum TaxiType @DrawableRes public int getIcon() { - return R.drawable.ic_taxi_logo_maksim; + return R.drawable.ic_taxi_logo_rutaxi; } @StringRes public int getTitle() { - return R.string.maxim_taxi_title; + return R.string.rutaxi_title; } @NonNull @@ -138,6 +143,30 @@ public enum TaxiType } }; + private static final Collection APPROXIMATE_PRICE_TAXI_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList(YANDEX, MAXIM, RUTAXI))); + + @StringRes + private final int mWaitingTemplateResId; + @NonNull + private final FormatPriceStrategy mFormatPriceStrategy; + + TaxiType(@StringRes int waitingTemplateResId, @NonNull FormatPriceStrategy strategy) + { + mWaitingTemplateResId = waitingTemplateResId; + mFormatPriceStrategy = strategy; + } + + TaxiType(@NonNull FormatPriceStrategy strategy) + { + this(R.string.taxi_wait, strategy); + } + + TaxiType() + { + this(R.string.taxi_wait, new DefaultFormatPriceStrategy()); + } + @NonNull public abstract String getPackageName(); @@ -152,4 +181,22 @@ public enum TaxiType @NonNull public abstract String getProviderName(); + + @StringRes + public int getWaitingTemplateResId() + { + return mWaitingTemplateResId; + } + + public boolean isApproximatePrice() + { + return APPROXIMATE_PRICE_TAXI_TYPES.contains(this); + } + + // For Uber and Maxim we don't do formatting, because Uber and Maxim does it on its side. + @NonNull + public FormatPriceStrategy getFormatPriceStrategy() + { + return mFormatPriceStrategy; + } } diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java index 8285ab1298..55a7e7cb18 100644 --- a/android/src/com/mapswithme/util/UiUtils.java +++ b/android/src/com/mapswithme/util/UiUtils.java @@ -46,6 +46,7 @@ public final class UiUtils private static final int DEFAULT_TINT_COLOR = Color.parseColor("#20000000"); public static final int NO_ID = -1; public static final String PHRASE_SEPARATOR = " • "; + public static final String APPROXIMATE_SYMBOL = "~"; private static float sScreenDensity; public static void addStatusBarOffset(@NonNull View view)