forked from organicmaps/organicmaps
[android] Renamed all uber classes to taxi
This commit is contained in:
parent
408aacbda2
commit
e845eab892
18 changed files with 165 additions and 163 deletions
android
jni
res/layout
src/com/mapswithme
|
@ -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 \
|
||||
|
|
|
@ -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));
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
android:layout_height="wrap_content"/>
|
||||
|
||||
<include
|
||||
layout="@layout/uber_panel"
|
||||
layout="@layout/taxi_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
@ -38,4 +38,4 @@
|
|||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<include layout="@layout/altitude_chart_panel"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<include layout="@layout/uber_panel"/>
|
||||
<include layout="@layout/taxi_panel"/>
|
||||
|
||||
<include layout="@layout/start_button"/>
|
||||
|
||||
|
@ -25,4 +25,4 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/uber_panel"
|
||||
android:id="@+id/taxi_panel"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingEnd="@dimen/margin_base"
|
|
@ -72,11 +72,11 @@ import com.mapswithme.maps.settings.SettingsActivity;
|
|||
import com.mapswithme.maps.settings.StoragePathManager;
|
||||
import com.mapswithme.maps.settings.UnitLocale;
|
||||
import com.mapswithme.maps.sound.TtsPlayer;
|
||||
import com.mapswithme.maps.taxi.Taxi;
|
||||
import com.mapswithme.maps.taxi.TaxiInfo;
|
||||
import com.mapswithme.maps.traffic.TrafficManager;
|
||||
import com.mapswithme.maps.traffic.widget.TrafficButton;
|
||||
import com.mapswithme.maps.traffic.widget.TrafficButtonController;
|
||||
import com.mapswithme.maps.uber.Uber;
|
||||
import com.mapswithme.maps.uber.UberInfo;
|
||||
import com.mapswithme.maps.widget.FadeView;
|
||||
import com.mapswithme.maps.widget.menu.BaseMenu;
|
||||
import com.mapswithme.maps.widget.menu.MainMenu;
|
||||
|
@ -1611,7 +1611,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
final RoutingController controller = RoutingController.get();
|
||||
|
||||
if (controller.isBuilt() || controller.isUberRequestHandled())
|
||||
if (controller.isBuilt() || controller.isTaxiRequestHandled())
|
||||
{
|
||||
showLineFrame();
|
||||
|
||||
|
@ -1883,32 +1883,32 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUberInfoReceived(@NonNull UberInfo info)
|
||||
public void onTaxiInfoReceived(@NonNull TaxiInfo info)
|
||||
{
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.showUberInfo(info);
|
||||
fragment.showTaxiInfo(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoutingPlanInplaceController.showUberInfo(info);
|
||||
mRoutingPlanInplaceController.showTaxiInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUberError(@NonNull Uber.ErrorCode code)
|
||||
public void onTaxiError(@NonNull Taxi.ErrorCode code)
|
||||
{
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.showUberError(code);
|
||||
fragment.showTaxiError(code);
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoutingPlanInplaceController.showUberError(code);
|
||||
mRoutingPlanInplaceController.showTaxiError(code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ import com.mapswithme.maps.MwmActivity;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.uber.UberAdapter;
|
||||
import com.mapswithme.maps.uber.UberInfo;
|
||||
import com.mapswithme.maps.uber.UberLinks;
|
||||
import com.mapswithme.maps.taxi.TaxiAdapter;
|
||||
import com.mapswithme.maps.taxi.TaxiInfo;
|
||||
import com.mapswithme.maps.taxi.TaxiLinks;
|
||||
import com.mapswithme.maps.widget.DotPager;
|
||||
import com.mapswithme.util.Graphics;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
@ -47,7 +47,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
@NonNull
|
||||
private final View mAltitudeChartFrame;
|
||||
@NonNull
|
||||
private final View mUberFrame;
|
||||
private final View mTaxiFrame;
|
||||
@NonNull
|
||||
private final TextView mError;
|
||||
@NonNull
|
||||
|
@ -68,15 +68,15 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
private final ImageView mActionIcon;
|
||||
|
||||
@Nullable
|
||||
private UberInfo mUberInfo;
|
||||
private TaxiInfo mTaxiInfo;
|
||||
@Nullable
|
||||
private UberInfo.Product mUberProduct;
|
||||
private TaxiInfo.Product mTaxiProduct;
|
||||
|
||||
@NonNull
|
||||
static RoutingBottomMenuController newInstance(@NonNull Activity activity, @NonNull View frame)
|
||||
{
|
||||
View altitudeChartFrame = getViewById(activity, frame, R.id.altitude_chart_panel);
|
||||
View uberFrame = getViewById(activity, frame, R.id.uber_panel);
|
||||
View taxiFrame = getViewById(activity, frame, R.id.taxi_panel);
|
||||
TextView error = (TextView) getViewById(activity, frame, R.id.error);
|
||||
Button start = (Button) getViewById(activity, frame, R.id.start);
|
||||
ImageView altitudeChart = (ImageView) getViewById(activity, frame, R.id.altitude_chart);
|
||||
|
@ -85,7 +85,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
View actionFrame = getViewById(activity, frame, R.id.routing_action_frame);
|
||||
|
||||
return new RoutingBottomMenuController(activity, altitudeChartFrame,
|
||||
uberFrame, error, start,
|
||||
taxiFrame, error, start,
|
||||
altitudeChart,
|
||||
altitudeDifference,
|
||||
numbersFrame, actionFrame);
|
||||
|
@ -101,7 +101,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
|
||||
private RoutingBottomMenuController(@NonNull Activity context,
|
||||
@NonNull View altitudeChartFrame,
|
||||
@NonNull View uberFrame,
|
||||
@NonNull View taxiFrame,
|
||||
@NonNull TextView error,
|
||||
@NonNull Button start,
|
||||
@NonNull ImageView altitudeChart,
|
||||
|
@ -111,7 +111,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
{
|
||||
mContext = context;
|
||||
mAltitudeChartFrame = altitudeChartFrame;
|
||||
mUberFrame = uberFrame;
|
||||
mTaxiFrame = taxiFrame;
|
||||
mError = error;
|
||||
mStart = start;
|
||||
mAltitudeChart = altitudeChart;
|
||||
|
@ -130,12 +130,12 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
return !(UiUtils.isVisible(mActionButton) && UiUtils.isViewTouched(event, mActionButton));
|
||||
}
|
||||
});
|
||||
UiUtils.hide(mAltitudeChartFrame, mUberFrame, mActionFrame);
|
||||
UiUtils.hide(mAltitudeChartFrame, mTaxiFrame, mActionFrame);
|
||||
}
|
||||
|
||||
void showAltitudeChartAndRoutingDetails()
|
||||
{
|
||||
UiUtils.hide(mError, mUberFrame, mActionFrame);
|
||||
UiUtils.hide(mError, mTaxiFrame, mActionFrame);
|
||||
|
||||
showRouteAltitudeChart();
|
||||
showRoutingDetails();
|
||||
|
@ -150,29 +150,29 @@ final class RoutingBottomMenuController implements View.OnClickListener
|
|||
UiUtils.hide(mAltitudeChartFrame);
|
||||
}
|
||||
|
||||
void showUberInfo(@NonNull UberInfo info)
|
||||
void showTaxiInfo(@NonNull TaxiInfo info)
|
||||
{
|
||||
UiUtils.hide(mError, mAltitudeChartFrame, mActionFrame);
|
||||
|
||||
final List<UberInfo.Product> 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<TaxiInfo.Product> 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()
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
21
android/src/com/mapswithme/maps/taxi/Taxi.java
Normal file
21
android/src/com/mapswithme/maps/taxi/Taxi.java
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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<UberInfo.Product> mProducts;
|
||||
private final List<TaxiInfo.Product> mProducts;
|
||||
|
||||
public UberAdapter(@NonNull Context context, @NonNull List<UberInfo.Product> products)
|
||||
public TaxiAdapter(@NonNull Context context, @NonNull List<TaxiInfo.Product> 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);
|
|
@ -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<UberInfo> CREATOR = new Parcelable.Creator<UberInfo>()
|
||||
public static final Parcelable.Creator<TaxiInfo> CREATOR = new Parcelable.Creator<TaxiInfo>()
|
||||
{
|
||||
@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<Product> 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<Product> 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 +
|
||||
'}';
|
||||
}
|
|
@ -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;
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Add table
Reference in a new issue