forked from organicmaps/organicmaps
[android] Taxi Maxim
This commit is contained in:
parent
c415bdd9ef
commit
ebcdca2b9b
7 changed files with 75 additions and 47 deletions
|
@ -22,10 +22,10 @@
|
|||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_marginStart="@dimen/margin_double"
|
||||
android:layout_marginLeft="@dimen/margin_double"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:layout_marginLeft="@dimen/margin_base"
|
||||
android:layout_toRightOf="@id/iv__logo"
|
||||
android:layout_toEndOf="@id/iv__logo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="64dp"/>
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.Activity;
|
|||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -167,7 +166,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
void showTaxiInfo(@NonNull TaxiInfo info)
|
||||
{
|
||||
UiUtils.hide(mError, mAltitudeChartFrame, mActionFrame, mTransitFrame);
|
||||
UiUtils.showTaxiIcon((ImageView) mTaxiFrame.findViewById(R.id.iv__logo), info.getType());
|
||||
TaxiManager.setTaxiIcon(mTaxiFrame.findViewById(R.id.iv__logo), info.getType());
|
||||
final List<TaxiInfo.Product> products = info.getProducts();
|
||||
mTaxiInfo = info;
|
||||
mTaxiProduct = products.get(0);
|
||||
|
|
|
@ -53,9 +53,9 @@ 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 == TaxiManager.PROVIDER_YANDEX)
|
||||
if (mType == TaxiManager.PROVIDER_YANDEX || mType == TaxiManager.PROVIDER_MAXIM)
|
||||
{
|
||||
name.setText(R.string.yandex_taxi_title);
|
||||
TaxiManager.setTaxiTitle(name, mType);
|
||||
separator = " • ~";
|
||||
}
|
||||
else
|
||||
|
@ -78,7 +78,7 @@ public class TaxiAdapter extends PagerAdapter
|
|||
{
|
||||
if (mType == TaxiManager.PROVIDER_YANDEX)
|
||||
return Utils.formatCurrencyString(product.getPrice(), product.getCurrency());
|
||||
// For Uber we don't do formatting, because Uber does it on its side.
|
||||
// For Uber and Maxim we don't do formatting, because Uber and Maxim does it on its side.
|
||||
return product.getPrice();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,10 @@ import android.support.annotation.IntDef;
|
|||
import android.support.annotation.MainThread;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
|
@ -27,11 +30,12 @@ public class TaxiManager
|
|||
{
|
||||
public static final int PROVIDER_UBER = 0;
|
||||
public static final int PROVIDER_YANDEX = 1;
|
||||
public static final int PROVIDER_MAXIM = 2;
|
||||
|
||||
public static final TaxiManager INSTANCE = new TaxiManager();
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ PROVIDER_UBER, PROVIDER_YANDEX })
|
||||
@IntDef({ PROVIDER_UBER, PROVIDER_YANDEX, PROVIDER_MAXIM })
|
||||
public @interface TaxiType {}
|
||||
|
||||
@NonNull
|
||||
|
@ -103,6 +107,42 @@ public class TaxiManager
|
|||
endPoint.getLon());
|
||||
}
|
||||
|
||||
public static void setTaxiIcon(@NonNull ImageView logo, @TaxiManager.TaxiType int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TaxiManager.PROVIDER_UBER:
|
||||
logo.setImageResource(R.drawable.ic_logo_uber);
|
||||
break;
|
||||
case TaxiManager.PROVIDER_YANDEX:
|
||||
logo.setImageResource(R.drawable.ic_logo_yandex_taxi);
|
||||
break;
|
||||
case TaxiManager.PROVIDER_MAXIM:
|
||||
logo.setImageResource(R.drawable.ic_taxi_logo_maksim);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTaxiTitle(@NonNull TextView title, @TaxiManager.TaxiType int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TaxiManager.PROVIDER_UBER:
|
||||
title.setText(R.string.uber);
|
||||
break;
|
||||
case TaxiManager.PROVIDER_YANDEX:
|
||||
title.setText(R.string.yandex_taxi_title);
|
||||
break;
|
||||
case TaxiManager.PROVIDER_MAXIM:
|
||||
title.setText(R.string.maxim_taxi_title);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getTaxiPackageName(@TaxiManager.TaxiType int type)
|
||||
{
|
||||
|
@ -112,6 +152,24 @@ public class TaxiManager
|
|||
return "com.ubercab";
|
||||
case TaxiManager.PROVIDER_YANDEX:
|
||||
return "ru.yandex.taxi";
|
||||
case TaxiManager.PROVIDER_MAXIM:
|
||||
return "maximzakaz";
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getTaxiStatisticsName(@TaxiManager.TaxiType int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TaxiManager.PROVIDER_UBER:
|
||||
return "Uber";
|
||||
case TaxiManager.PROVIDER_YANDEX:
|
||||
return "Yandex";
|
||||
case TaxiManager.PROVIDER_MAXIM:
|
||||
return "Maxim";
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
|
@ -132,6 +190,9 @@ public class TaxiManager
|
|||
case TaxiManager.PROVIDER_YANDEX:
|
||||
openMode = Utils.PartnerAppOpenMode.Indirect;
|
||||
break;
|
||||
case TaxiManager.PROVIDER_MAXIM:
|
||||
openMode = Utils.PartnerAppOpenMode.Direct;
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
|
|
|
@ -1450,8 +1450,8 @@ public class PlacePageView extends RelativeLayout
|
|||
// At this moment we display only a one taxi provider at the same time.
|
||||
@TaxiManager.TaxiType
|
||||
int type = taxiTypes.get(0);
|
||||
UiUtils.showTaxiIcon((ImageView) mTaxi.findViewById(R.id.iv__place_page_taxi), type);
|
||||
UiUtils.showTaxiTitle((TextView) mTaxi.findViewById(R.id.tv__place_page_taxi), type);
|
||||
TaxiManager.setTaxiIcon(mTaxi.findViewById(R.id.iv__place_page_taxi), type);
|
||||
TaxiManager.setTaxiTitle(mTaxi.findViewById(R.id.tv__place_page_taxi), type);
|
||||
Statistics.INSTANCE.trackTaxiEvent(Statistics.EventName.ROUTING_TAXI_SHOW_IN_PP, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -500,36 +500,6 @@ public final class UiUtils
|
|||
});
|
||||
}
|
||||
|
||||
public static void showTaxiIcon(@NonNull ImageView logo, @TaxiManager.TaxiType int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TaxiManager.PROVIDER_UBER:
|
||||
logo.setImageResource(R.drawable.ic_logo_uber);
|
||||
break;
|
||||
case TaxiManager.PROVIDER_YANDEX:
|
||||
logo.setImageResource(R.drawable.ic_logo_yandex_taxi);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showTaxiTitle(@NonNull TextView title, @TaxiManager.TaxiType int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TaxiManager.PROVIDER_UBER:
|
||||
title.setText(R.string.uber);
|
||||
break;
|
||||
case TaxiManager.PROVIDER_YANDEX:
|
||||
title.setText(R.string.yandex_taxi_title);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unsupported taxi type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
// utility class
|
||||
private UiUtils() {}
|
||||
}
|
||||
|
|
|
@ -609,7 +609,7 @@ public enum Statistics
|
|||
@Nullable Location location, @TaxiManager.TaxiType int type, boolean isAppInstalled)
|
||||
{
|
||||
Statistics.ParameterBuilder params = Statistics.params();
|
||||
params.add(Statistics.EventParam.PROVIDER, type == TaxiManager.PROVIDER_YANDEX ? "Yandex" : "Uber");
|
||||
params.add(Statistics.EventParam.PROVIDER, TaxiManager.getTaxiStatisticsName(type));
|
||||
|
||||
params.add(Statistics.EventParam.FROM_LAT, from != null ? String.valueOf(from.getLat()) : "N/A")
|
||||
.add(Statistics.EventParam.FROM_LON, from != null ? String.valueOf(from.getLon()) : "N/A");
|
||||
|
@ -625,16 +625,14 @@ public enum Statistics
|
|||
public void trackTaxiEvent(@NonNull String eventName, @TaxiManager.TaxiType int type)
|
||||
{
|
||||
Statistics.ParameterBuilder params = Statistics.params();
|
||||
params.add(Statistics.EventParam.PROVIDER,
|
||||
type == TaxiManager.PROVIDER_YANDEX ? "Yandex" : "Uber");
|
||||
params.add(Statistics.EventParam.PROVIDER, TaxiManager.getTaxiStatisticsName(type));
|
||||
trackEvent(eventName, params);
|
||||
}
|
||||
|
||||
public void trackTaxiError(@NonNull TaxiInfoError error)
|
||||
{
|
||||
Statistics.ParameterBuilder params = Statistics.params();
|
||||
params.add(Statistics.EventParam.PROVIDER,
|
||||
error.getType() == TaxiManager.PROVIDER_YANDEX ? "Yandex" : "Uber");
|
||||
params.add(Statistics.EventParam.PROVIDER, TaxiManager.getTaxiStatisticsName(error.getType()));
|
||||
params.add(ERROR_CODE, error.getCode().name());
|
||||
trackEvent(EventName.ROUTING_TAXI_ROUTE_BUILT, params);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue