From e845eab892068134304a6bf4e7216f4d6918506e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Tue, 27 Jun 2017 17:53:14 +0300 Subject: [PATCH] [android] Renamed all uber classes to taxi --- android/jni/Android.mk | 2 +- .../maps/{uber/Uber.cpp => taxi/Taxi.cpp} | 48 ++++++------ android/res/layout/fragment_routing.xml | 4 +- android/res/layout/menu_route_plan_line.xml | 4 +- ...ber_pager_item.xml => taxi_pager_item.xml} | 0 .../layout/{uber_panel.xml => taxi_panel.xml} | 2 +- .../src/com/mapswithme/maps/MwmActivity.java | 18 ++--- .../routing/RoutingBottomMenuController.java | 61 +++++++-------- .../maps/routing/RoutingController.java | 76 +++++++++---------- .../maps/routing/RoutingPlanController.java | 14 ++-- .../maps/routing/RoutingPlanFragment.java | 12 +-- .../src/com/mapswithme/maps/taxi/Taxi.java | 21 +++++ .../TaxiAdapter.java} | 12 +-- .../UberInfo.java => taxi/TaxiInfo.java} | 20 ++--- .../UberLinks.java => taxi/TaxiLinks.java} | 6 +- .../src/com/mapswithme/maps/uber/Uber.java | 20 ----- android/src/com/mapswithme/util/Utils.java | 6 +- .../util/statistics/Statistics.java | 2 +- 18 files changed, 165 insertions(+), 163 deletions(-) rename android/jni/com/mapswithme/maps/{uber/Uber.cpp => taxi/Taxi.cpp} (76%) rename android/res/layout/{uber_pager_item.xml => taxi_pager_item.xml} (100%) rename android/res/layout/{uber_panel.xml => taxi_panel.xml} (98%) create mode 100644 android/src/com/mapswithme/maps/taxi/Taxi.java rename android/src/com/mapswithme/maps/{uber/UberAdapter.java => taxi/TaxiAdapter.java} (80%) rename android/src/com/mapswithme/maps/{uber/UberInfo.java => taxi/TaxiInfo.java} (85%) rename android/src/com/mapswithme/maps/{uber/UberLinks.java => taxi/TaxiLinks.java} (75%) delete mode 100644 android/src/com/mapswithme/maps/uber/Uber.java diff --git a/android/jni/Android.mk b/android/jni/Android.mk index ed3750fbd4..58814c95b8 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -96,7 +96,7 @@ LOCAL_SRC_FILES := \ com/mapswithme/maps/settings/UnitLocale.cpp \ com/mapswithme/maps/sound/tts.cpp \ com/mapswithme/maps/Sponsored.cpp \ - com/mapswithme/maps/uber/Uber.cpp \ + com/mapswithme/maps/taxi/Taxi.cpp \ com/mapswithme/maps/TrackRecorder.cpp \ com/mapswithme/maps/TrafficState.cpp \ com/mapswithme/maps/UserMarkHelper.cpp \ diff --git a/android/jni/com/mapswithme/maps/uber/Uber.cpp b/android/jni/com/mapswithme/maps/taxi/Taxi.cpp similarity index 76% rename from android/jni/com/mapswithme/maps/uber/Uber.cpp rename to android/jni/com/mapswithme/maps/taxi/Taxi.cpp index 5bdbfed868..840115a86a 100644 --- a/android/jni/com/mapswithme/maps/uber/Uber.cpp +++ b/android/jni/com/mapswithme/maps/taxi/Taxi.cpp @@ -5,47 +5,47 @@ namespace { -jclass g_uberClass; +jclass g_taxiClass; jclass g_productClass; jclass g_routingControllerClass; -jclass g_uberInfoClass; -jmethodID g_uberInfoConstructor; +jclass g_taxiInfoClass; +jmethodID g_taxiInfoConstructor; jobject g_routingControllerInstance; jmethodID g_productConstructor; jmethodID g_routingControllerGetMethod; -jmethodID g_uberInfoCallbackMethod; -jmethodID g_uberErrorCallbackMethod; -jclass g_uberLinksClass; -jmethodID g_uberLinksConstructor; +jmethodID g_taxiInfoCallbackMethod; +jmethodID g_taxiErrorCallbackMethod; +jclass g_taxiLinksClass; +jmethodID g_taxiLinksConstructor; uint64_t g_lastRequestId; void PrepareClassRefs(JNIEnv * env) { - if (g_uberClass) + if (g_taxiClass) return; - g_uberClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/uber/UberInfo"); - g_productClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/uber/UberInfo$Product"); + g_taxiClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/taxi/TaxiInfo"); + g_productClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/taxi/TaxiInfo$Product"); g_routingControllerClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/RoutingController"); g_productConstructor = jni::GetConstructorID( env, g_productClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); - g_uberInfoClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/uber/UberInfo"); + g_taxiInfoClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/taxi/TaxiInfo"); g_routingControllerGetMethod = jni::GetStaticMethodID( env, g_routingControllerClass, "get", "()Lcom/mapswithme/maps/routing/RoutingController;"); g_routingControllerInstance = env->CallStaticObjectMethod(g_routingControllerClass, g_routingControllerGetMethod); - g_uberInfoCallbackMethod = - jni::GetMethodID(env, g_routingControllerInstance, "onUberInfoReceived", - "(Lcom/mapswithme/maps/uber/UberInfo;)V"); - g_uberErrorCallbackMethod = jni::GetMethodID(env, g_routingControllerInstance, - "onUberError", "(Ljava/lang/String;)V"); - g_uberInfoConstructor = jni::GetConstructorID(env, g_uberInfoClass, - "([Lcom/mapswithme/maps/uber/UberInfo$Product;)V"); - g_uberLinksClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/uber/UberLinks"); - g_uberLinksConstructor = - jni::GetConstructorID(env, g_uberLinksClass, "(Ljava/lang/String;Ljava/lang/String;)V"); + g_taxiInfoCallbackMethod = + jni::GetMethodID(env, g_routingControllerInstance, "onTaxiInfoReceived", + "(Lcom/mapswithme/maps/taxi/TaxiInfo;)V"); + g_taxiErrorCallbackMethod = jni::GetMethodID(env, g_routingControllerInstance, + "onTaxiError", "(Ljava/lang/String;)V"); + g_taxiInfoConstructor = jni::GetConstructorID(env, g_taxiInfoClass, + "([Lcom/mapswithme/maps/taxi/TaxiInfo$Product;)V"); + g_taxiLinksClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/taxi/TaxiLinks"); + g_taxiLinksConstructor = + jni::GetConstructorID(env, g_taxiLinksClass, "(Ljava/lang/String;Ljava/lang/String;)V"); } void OnTaxiInfoReceived(taxi::ProvidersContainer const & products, uint64_t const requestId) @@ -99,7 +99,7 @@ void OnTaxiError(taxi::ErrorsContainer const & errors, uint64_t const requestId) extern "C" { -JNIEXPORT void JNICALL Java_com_mapswithme_maps_uber_Uber_nativeRequestUberProducts( +JNIEXPORT void JNICALL Java_com_mapswithme_maps_taxi_Taxi_nativeRequestTaxiProducts( JNIEnv * env, jclass clazz, jobject policy, jdouble srcLat, jdouble srcLon, jdouble dstLat, jdouble dstLon) { @@ -112,7 +112,7 @@ JNIEXPORT void JNICALL Java_com_mapswithme_maps_uber_Uber_nativeRequestUberProdu g_framework->RequestTaxiProducts(env, policy, from, to, &OnTaxiInfoReceived, &OnTaxiError); } -JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_uber_Uber_nativeGetUberLinks( +JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_taxi_Taxi_nativeGetUberLinks( JNIEnv * env, jclass clazz, jobject policy, jstring productId, jdouble srcLat, jdouble srcLon, jdouble dstLat, jdouble dstLon) { @@ -123,7 +123,7 @@ JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_uber_Uber_nativeGetUberLinks( taxi::RideRequestLinks const links = g_framework->GetTaxiLinks(env, policy, jni::ToNativeString(env, productId), from, to); - return env->NewObject(g_uberLinksClass, g_uberLinksConstructor, + return env->NewObject(g_taxiLinksClass, g_taxiLinksConstructor, jni::ToJavaString(env, links.m_deepLink), jni::ToJavaString(env, links.m_universalLink)); } diff --git a/android/res/layout/fragment_routing.xml b/android/res/layout/fragment_routing.xml index 390573b2de..7c2af75ca1 100644 --- a/android/res/layout/fragment_routing.xml +++ b/android/res/layout/fragment_routing.xml @@ -14,7 +14,7 @@ android:layout_height="wrap_content"/> @@ -38,4 +38,4 @@ android:visibility="gone" android:layout_width="match_parent" android:layout_height="48dp"/> - \ No newline at end of file + diff --git a/android/res/layout/menu_route_plan_line.xml b/android/res/layout/menu_route_plan_line.xml index 6205330c27..dd96059228 100644 --- a/android/res/layout/menu_route_plan_line.xml +++ b/android/res/layout/menu_route_plan_line.xml @@ -9,7 +9,7 @@ - + @@ -25,4 +25,4 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone"/> - \ No newline at end of file + diff --git a/android/res/layout/uber_pager_item.xml b/android/res/layout/taxi_pager_item.xml similarity index 100% rename from android/res/layout/uber_pager_item.xml rename to android/res/layout/taxi_pager_item.xml diff --git a/android/res/layout/uber_panel.xml b/android/res/layout/taxi_panel.xml similarity index 98% rename from android/res/layout/uber_panel.xml rename to android/res/layout/taxi_panel.xml index b2fefd32bc..1b1910b357 100644 --- a/android/res/layout/uber_panel.xml +++ b/android/res/layout/taxi_panel.xml @@ -2,7 +2,7 @@ products = info.getProducts(); - mUberInfo = info; - mUberProduct = products.get(0); - final PagerAdapter adapter = new UberAdapter(mContext, products); - DotPager pager = new DotPager.Builder(mContext, (ViewPager) mUberFrame.findViewById(R.id.pager), + final List products = info.getProducts(); + mTaxiInfo = info; + mTaxiProduct = products.get(0); + final PagerAdapter adapter = new TaxiAdapter(mContext, products); + DotPager pager = new DotPager.Builder(mContext, (ViewPager) mTaxiFrame.findViewById(R.id.pager), adapter) - .setIndicatorContainer((ViewGroup) mUberFrame.findViewById(R.id.indicator)) + .setIndicatorContainer((ViewGroup) mTaxiFrame.findViewById(R.id.indicator)) .setPageChangedListener(new DotPager.OnPageChangedListener() { @Override public void onPageChanged(int position) { - mUberProduct = products.get(position); + mTaxiProduct = products.get(position); } }).build(); pager.show(); setStartButton(); - UiUtils.show(mUberFrame); + UiUtils.show(mTaxiFrame); } void showAddStartFrame() @@ -209,20 +209,21 @@ final class RoutingBottomMenuController implements View.OnClickListener { if (RoutingController.get().isTaxiRouterType()) { - final boolean isUberInstalled = Utils.isUberInstalled(mContext); - mStart.setText(isUberInstalled ? R.string.taxi_order : R.string.install_app); + // TODO: add getting the link by provider (Yandex, Uber) + final boolean isTaxiInstalled = Utils.isUberInstalled(mContext); + mStart.setText(isTaxiInstalled ? R.string.taxi_order : R.string.install_app); mStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (mUberProduct != null) + if (mTaxiProduct != null) { - UberLinks links = RoutingController.get().getUberLink(mUberProduct.getProductId()); + TaxiLinks links = RoutingController.get().getTaxiLink(mTaxiProduct.getProductId()); if (links != null) { Utils.launchUber(mContext, links); - trackUberStatistics(isUberInstalled); + trackUberStatistics(isTaxiInstalled); } } } @@ -253,7 +254,7 @@ final class RoutingBottomMenuController implements View.OnClickListener void showError(@StringRes int message) { - UiUtils.hide(mUberFrame, mAltitudeChartFrame); + UiUtils.hide(mTaxiFrame, mAltitudeChartFrame); mError.setText(message); mError.setVisibility(View.VISIBLE); showStartButton(false); @@ -267,7 +268,7 @@ final class RoutingBottomMenuController implements View.OnClickListener void saveRoutingPanelState(@NonNull Bundle outState) { outState.putBoolean(STATE_ALTITUDE_CHART_SHOWN, UiUtils.isVisible(mAltitudeChartFrame)); - outState.putParcelable(STATE_TAXI_INFO, mUberInfo); + outState.putParcelable(STATE_TAXI_INFO, mTaxiInfo); } void restoreRoutingPanelState(@NonNull Bundle state) @@ -275,9 +276,9 @@ final class RoutingBottomMenuController implements View.OnClickListener if (state.getBoolean(STATE_ALTITUDE_CHART_SHOWN)) showAltitudeChartAndRoutingDetails(); - UberInfo info = state.getParcelable(STATE_TAXI_INFO); + TaxiInfo info = state.getParcelable(STATE_TAXI_INFO); if (info != null) - showUberInfo(info); + showTaxiInfo(info); } private void showRouteAltitudeChart() diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java index 800c46cdf0..cf0ddf1bd5 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingController.java @@ -21,9 +21,9 @@ import com.mapswithme.maps.R; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.downloader.MapManager; import com.mapswithme.maps.location.LocationHelper; -import com.mapswithme.maps.uber.Uber; -import com.mapswithme.maps.uber.UberInfo; -import com.mapswithme.maps.uber.UberLinks; +import com.mapswithme.maps.taxi.Taxi; +import com.mapswithme.maps.taxi.TaxiInfo; +import com.mapswithme.maps.taxi.TaxiLinks; import com.mapswithme.util.Config; import com.mapswithme.util.ConnectionState; import com.mapswithme.util.NetworkPolicy; @@ -66,8 +66,8 @@ public class RoutingController void showNavigation(boolean show); void showDownloader(boolean openDownloaded); void updateMenu(); - void onUberInfoReceived(@NonNull UberInfo info); - void onUberError(@NonNull Uber.ErrorCode code); + void onTaxiInfoReceived(@NonNull TaxiInfo info); + void onTaxiError(@NonNull Taxi.ErrorCode code); void onNavigationCancelled(); void onNavigationStarted(); void onAddedStop(); @@ -104,8 +104,8 @@ public class RoutingController private String[] mLastMissingMaps; @Nullable private RoutingInfo mCachedRoutingInfo; - private boolean mUberRequestHandled; - private boolean mUberPlanning; + private boolean mTaxiRequestHandled; + private boolean mTaxiPlanning; private boolean mInternetConnected; @SuppressWarnings("FieldCanBeLocal") @@ -220,7 +220,7 @@ public class RoutingController private void updateProgress() { - if (isUberPlanning()) + if (isTaxiPlanning()) return; if (mContainer != null) @@ -265,7 +265,7 @@ public class RoutingController if (mContainer != null) { - if (isUberPlanning()) + if (isTaxiPlanning()) mContainer.updateBuildProgress(0, mLastRouterType); mContainer.showNavigation(isNavigating()); @@ -284,7 +284,7 @@ public class RoutingController Framework.nativeRemoveRoute(); mLogger.d(TAG, "build"); - mUberRequestHandled = false; + mTaxiRequestHandled = false; mLastBuildProgress = 0; mInternetConnected = ConnectionState.isConnected(); @@ -293,11 +293,11 @@ public class RoutingController removeIntermediatePoints(); if (!mInternetConnected) { - completeUberRequest(); + completeTaxiRequest(); return; } if (mContainer != null) - requestUberInfo(); + requestTaxiInfo(); } setBuildState(BuildState.BUILDING); @@ -311,9 +311,9 @@ public class RoutingController Framework.nativeBuildRoute(); } - private void completeUberRequest() + private void completeTaxiRequest() { - mUberRequestHandled = true; + mTaxiRequestHandled = true; if (mContainer != null) { mContainer.updateBuildProgress(100, mLastRouterType); @@ -529,7 +529,7 @@ public class RoutingController mEndPoint = null; setPointsInternal(); mWaitingPoiPick = false; - mUberRequestHandled = false; + mTaxiRequestHandled = false; setBuildState(BuildState.NONE); setState(State.NONE); @@ -573,9 +573,9 @@ public class RoutingController return mState == State.PREPARE; } - boolean isUberPlanning() + boolean isTaxiPlanning() { - return isTaxiRouterType() && mUberPlanning; + return isTaxiRouterType() && mTaxiPlanning; } boolean isTaxiRouterType() @@ -619,9 +619,9 @@ public class RoutingController return mWaitingPoiPick; } - public boolean isUberRequestHandled() + public boolean isTaxiRequestHandled() { - return mUberRequestHandled; + return mTaxiRequestHandled; } boolean isInternetConnected() @@ -825,7 +825,7 @@ public class RoutingController { mLogger.d(TAG, "setRouterType: " + mLastRouterType + " -> " + router); - // Repeating tap on Uber icon should trigger the route building always, + // Repeating tap on Taxi icon should trigger the route building always, // because it may be "No internet connection, try later" case if (router == mLastRouterType && !isTaxiRouterType()) return; @@ -896,14 +896,14 @@ public class RoutingController return true; } - private void requestUberInfo() + private void requestTaxiInfo() { if (mStartPoint == null || mEndPoint == null) throw new AssertionError("Start and end points must be set to make a taxi request!"); - mUberPlanning = true; + mTaxiPlanning = true; - Uber.nativeRequestUberProducts(NetworkPolicy.newInstance(true /* canUse */), + Taxi.nativeRequestTaxiProducts(NetworkPolicy.newInstance(true /* canUse */), mStartPoint.getLat(), mStartPoint.getLon(), mEndPoint.getLat(), mEndPoint.getLon()); if (mContainer != null) @@ -911,46 +911,46 @@ public class RoutingController } @Nullable - UberLinks getUberLink(@NonNull String productId) + TaxiLinks getTaxiLink(@NonNull String productId) { if (mStartPoint == null || mEndPoint == null) return null; - return Uber.nativeGetUberLinks(NetworkPolicy.newInstance(true /* canUse */), productId, + return Taxi.nativeGetTaxiLinks(NetworkPolicy.newInstance(true /* canUse */), productId, mStartPoint.getLat(), mStartPoint.getLon(), mEndPoint.getLat(), mEndPoint.getLon()); } /** * Called from the native code - * @param info this object contains information about Uber products + * @param info this object contains information about Taxi products */ @MainThread - private void onUberInfoReceived(@NonNull UberInfo info) + private void onTaxiInfoReceived(@NonNull TaxiInfo info) { - mUberPlanning = false; - mLogger.d(TAG, "onUberInfoReceived uberInfo = " + info); + mTaxiPlanning = false; + mLogger.d(TAG, "onTaxiInfoReceived uberInfo = " + info); if (isTaxiRouterType() && mContainer != null) { - mContainer.onUberInfoReceived(info); - completeUberRequest(); + mContainer.onTaxiInfoReceived(info); + completeTaxiRequest(); } } /** * Called from the native code - * @param errorCode must match the one of the values in {@link com.mapswithme.maps.uber.Uber.ErrorCode} + * @param errorCode must match the one of the values in {@link Taxi.ErrorCode} */ @MainThread - private void onUberError(@NonNull String errorCode) + private void onTaxiError(@NonNull String errorCode) { - mUberPlanning = false; - Uber.ErrorCode code = Uber.ErrorCode.valueOf(errorCode); - mLogger.e(TAG, "onUberError error = " + code); + mTaxiPlanning = false; + Taxi.ErrorCode code = Taxi.ErrorCode.valueOf(errorCode); + mLogger.e(TAG, "onTaxiError error = " + code); if (isTaxiRouterType() && mContainer != null) { - mContainer.onUberError(code); - completeUberRequest(); + mContainer.onTaxiError(code); + completeTaxiRequest(); } } } diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java index a8a175c828..ee5f032a7c 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java @@ -14,8 +14,8 @@ import android.widget.RadioGroup; import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; -import com.mapswithme.maps.uber.Uber; -import com.mapswithme.maps.uber.UberInfo; +import com.mapswithme.maps.taxi.Taxi; +import com.mapswithme.maps.taxi.TaxiInfo; import com.mapswithme.maps.widget.RoutingToolbarButton; import com.mapswithme.maps.widget.ToolbarController; import com.mapswithme.maps.widget.WheelProgressView; @@ -189,7 +189,7 @@ public class RoutingPlanController extends ToolbarController updateProgressLabels(); - if (RoutingController.get().isUberRequestHandled()) + if (RoutingController.get().isTaxiRequestHandled()) { if (!RoutingController.get().isInternetConnected()) { @@ -200,7 +200,7 @@ public class RoutingPlanController extends ToolbarController return; } - if (!RoutingController.get().isBuilding() && !RoutingController.get().isUberPlanning()) + if (!RoutingController.get().isBuilding() && !RoutingController.get().isTaxiPlanning()) { button.complete(); return; @@ -217,12 +217,12 @@ public class RoutingPlanController extends ToolbarController return RoutingController.get().isTaxiRouterType(); } - public void showUberInfo(@NonNull UberInfo info) + public void showTaxiInfo(@NonNull TaxiInfo info) { - mRoutingBottomMenuController.showUberInfo(info); + mRoutingBottomMenuController.showTaxiInfo(info); } - public void showUberError(@NonNull Uber.ErrorCode code) + public void showTaxiError(@NonNull Taxi.ErrorCode code) { switch (code) { diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java b/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java index a539be0f60..a42d29e5d2 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java @@ -9,8 +9,8 @@ import android.view.ViewGroup; import com.mapswithme.maps.Framework; import com.mapswithme.maps.R; -import com.mapswithme.maps.uber.Uber; -import com.mapswithme.maps.uber.UberInfo; +import com.mapswithme.maps.taxi.Taxi; +import com.mapswithme.maps.taxi.TaxiInfo; import com.mapswithme.maps.base.BaseMwmFragment; import com.mapswithme.maps.base.OnBackPressListener; @@ -35,14 +35,14 @@ public class RoutingPlanFragment extends BaseMwmFragment mPlanController.updateBuildProgress(progress, router); } - public void showUberInfo(@NonNull UberInfo info) + public void showTaxiInfo(@NonNull TaxiInfo info) { - mPlanController.showUberInfo(info); + mPlanController.showTaxiInfo(info); } - public void showUberError(@NonNull Uber.ErrorCode code) + public void showTaxiError(@NonNull Taxi.ErrorCode code) { - mPlanController.showUberError(code); + mPlanController.showTaxiError(code); } public void showStartButton(boolean show) diff --git a/android/src/com/mapswithme/maps/taxi/Taxi.java b/android/src/com/mapswithme/maps/taxi/Taxi.java new file mode 100644 index 0000000000..a00f36ce9f --- /dev/null +++ b/android/src/com/mapswithme/maps/taxi/Taxi.java @@ -0,0 +1,21 @@ +package com.mapswithme.maps.taxi; + +import android.support.annotation.NonNull; + +import com.mapswithme.util.NetworkPolicy; + +public class Taxi +{ + public static native void nativeRequestTaxiProducts(@NonNull NetworkPolicy policy, double srcLat, + double srcLon, double dstLat, double dstLon); + + @NonNull + public static native TaxiLinks nativeGetTaxiLinks(@NonNull NetworkPolicy policy, + @NonNull String productId, double srcLon, + double srcLat, double dstLat, double dstLon); + + public enum ErrorCode + { + NoProducts, RemoteError + } +} diff --git a/android/src/com/mapswithme/maps/uber/UberAdapter.java b/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java similarity index 80% rename from android/src/com/mapswithme/maps/uber/UberAdapter.java rename to android/src/com/mapswithme/maps/taxi/TaxiAdapter.java index 7fb0a658b0..7f80cc355a 100644 --- a/android/src/com/mapswithme/maps/uber/UberAdapter.java +++ b/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java @@ -1,4 +1,4 @@ -package com.mapswithme.maps.uber; +package com.mapswithme.maps.taxi; import android.content.Context; import android.support.annotation.NonNull; @@ -13,14 +13,14 @@ import com.mapswithme.maps.routing.RoutingController; import java.util.List; -public class UberAdapter extends PagerAdapter +public class TaxiAdapter extends PagerAdapter { @NonNull private final Context mContext; @NonNull - private final List mProducts; + private final List mProducts; - public UberAdapter(@NonNull Context context, @NonNull List products) + public TaxiAdapter(@NonNull Context context, @NonNull List products) { mContext = context; mProducts = products; @@ -41,9 +41,9 @@ public class UberAdapter extends PagerAdapter @Override public Object instantiateItem(ViewGroup container, int position) { - UberInfo.Product product = mProducts.get(position); + TaxiInfo.Product product = mProducts.get(position); - View v = LayoutInflater.from(mContext).inflate(R.layout.uber_pager_item, container, false); + View v = LayoutInflater.from(mContext).inflate(R.layout.taxi_pager_item, container, false); TextView name = (TextView) v.findViewById(R.id.product_name); name.setText(product.getName()); TextView timeAndPrice = (TextView) v.findViewById(R.id.arrival_time_price); diff --git a/android/src/com/mapswithme/maps/uber/UberInfo.java b/android/src/com/mapswithme/maps/taxi/TaxiInfo.java similarity index 85% rename from android/src/com/mapswithme/maps/uber/UberInfo.java rename to android/src/com/mapswithme/maps/taxi/TaxiInfo.java index 26495f22ef..da9d5652a3 100644 --- a/android/src/com/mapswithme/maps/uber/UberInfo.java +++ b/android/src/com/mapswithme/maps/taxi/TaxiInfo.java @@ -1,4 +1,4 @@ -package com.mapswithme.maps.uber; +package com.mapswithme.maps.taxi; import android.os.Parcel; import android.os.Parcelable; @@ -8,32 +8,32 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class UberInfo implements Parcelable +public class TaxiInfo implements Parcelable { - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override - public UberInfo createFromParcel(Parcel source) + public TaxiInfo createFromParcel(Parcel source) { - return new UberInfo(source); + return new TaxiInfo(source); } @Override - public UberInfo[] newArray(int size) + public TaxiInfo[] newArray(int size) { - return new UberInfo[size]; + return new TaxiInfo[size]; } }; @NonNull private final List mProducts; - private UberInfo(@NonNull Product[] products) + private TaxiInfo(@NonNull Product[] products) { mProducts = new ArrayList<>(Arrays.asList(products)); } - private UberInfo(@NonNull Parcel parcel) + private TaxiInfo(@NonNull Parcel parcel) { List products = new ArrayList<>(); parcel.readTypedList(products, Product.CREATOR); @@ -49,7 +49,7 @@ public class UberInfo implements Parcelable @Override public String toString() { - return "UberInfo{" + + return "TaxiInfo{" + "mProducts=" + mProducts + '}'; } diff --git a/android/src/com/mapswithme/maps/uber/UberLinks.java b/android/src/com/mapswithme/maps/taxi/TaxiLinks.java similarity index 75% rename from android/src/com/mapswithme/maps/uber/UberLinks.java rename to android/src/com/mapswithme/maps/taxi/TaxiLinks.java index 5e7d63e80e..dc979bf399 100644 --- a/android/src/com/mapswithme/maps/uber/UberLinks.java +++ b/android/src/com/mapswithme/maps/taxi/TaxiLinks.java @@ -1,15 +1,15 @@ -package com.mapswithme.maps.uber; +package com.mapswithme.maps.taxi; import android.support.annotation.NonNull; -public class UberLinks +public class TaxiLinks { @NonNull private final String mDeepLink; @NonNull private final String mUniversalLink; - public UberLinks(@NonNull String deepLink, @NonNull String universalLink) + public TaxiLinks(@NonNull String deepLink, @NonNull String universalLink) { mDeepLink = deepLink; mUniversalLink = universalLink; diff --git a/android/src/com/mapswithme/maps/uber/Uber.java b/android/src/com/mapswithme/maps/uber/Uber.java deleted file mode 100644 index 4a3c715303..0000000000 --- a/android/src/com/mapswithme/maps/uber/Uber.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mapswithme.maps.uber; - -import android.support.annotation.NonNull; - -import com.mapswithme.util.NetworkPolicy; - -public class Uber -{ - public static native void nativeRequestUberProducts(@NonNull NetworkPolicy policy, double srcLat, - double srcLon, double dstLat, double dstLon); - - @NonNull - public static native UberLinks nativeGetUberLinks(@NonNull NetworkPolicy policy, - @NonNull String productId, double srcLon, double srcLat, double dstLat, double dstLon); - - public enum ErrorCode - { - NoProducts, RemoteError - } -} diff --git a/android/src/com/mapswithme/util/Utils.java b/android/src/com/mapswithme/util/Utils.java index f009c6bdc0..eff5ae2553 100644 --- a/android/src/com/mapswithme/util/Utils.java +++ b/android/src/com/mapswithme/util/Utils.java @@ -29,7 +29,7 @@ import com.mapswithme.maps.BuildConfig; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; import com.mapswithme.maps.activity.CustomNavigateUpListener; -import com.mapswithme.maps.uber.UberLinks; +import com.mapswithme.maps.taxi.TaxiLinks; import com.mapswithme.util.concurrency.UiThread; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; @@ -297,7 +297,7 @@ public class Utils } } - public static void launchUber(@NonNull Activity context, @NonNull UberLinks links) + public static void launchUber(@NonNull Activity context, @NonNull TaxiLinks links) { final Intent intent = new Intent(Intent.ACTION_VIEW); if (isUberInstalled(context)) @@ -307,7 +307,7 @@ public class Utils intent.setData(Uri.parse(links.getDeepLink())); } else { - // No Uber app! Open mobile website. + // No Taxi app! Open mobile website. intent.setData(Uri.parse(links.getUniversalLink())); } context.startActivity(intent); diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index 1a5120f176..202acc6a9c 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -523,7 +523,7 @@ public enum Statistics @Nullable Location location, boolean isUberInstalled) { Statistics.ParameterBuilder params = Statistics.params(); - params.add(Statistics.EventParam.PROVIDER, "Uber"); + params.add(Statistics.EventParam.PROVIDER, "Taxi"); 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");