forked from organicmaps/organicmaps
[android] Supported DrivingOptionsView (dropdown), fixed linked legacy code troubles (e.g. animation and appearance of toolbar, adjusting map layer btn, etc...)
This commit is contained in:
parent
e411c6a2a6
commit
633f35760a
8 changed files with 97 additions and 57 deletions
|
@ -153,13 +153,14 @@
|
|||
|
||||
<FrameLayout
|
||||
android:background="@color/light_green"
|
||||
android:id="@+id/driving_options_btn_container"
|
||||
android:visibility="gone"
|
||||
android:foreground="@drawable/shadow_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<RelativeLayout
|
||||
android:id="@+id/driving_options_btn"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:minHeight="@dimen/height_block_base"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -168,7 +169,6 @@
|
|||
android:layout_centerInParent="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimaryInverse"
|
||||
android:text="asdasdasdasdas"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/margin_half_plus_eight"
|
||||
|
|
|
@ -84,6 +84,7 @@ import com.mapswithme.maps.routing.NavigationController;
|
|||
import com.mapswithme.maps.routing.RoutePointInfo;
|
||||
import com.mapswithme.maps.routing.RoutingBottomMenuListener;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.maps.routing.RoutingOptions;
|
||||
import com.mapswithme.maps.routing.RoutingPlanFragment;
|
||||
import com.mapswithme.maps.routing.RoutingPlanInplaceController;
|
||||
import com.mapswithme.maps.search.BookingFilterParams;
|
||||
|
@ -96,6 +97,7 @@ import com.mapswithme.maps.search.SearchEngine;
|
|||
import com.mapswithme.maps.search.SearchFilterController;
|
||||
import com.mapswithme.maps.search.SearchFragment;
|
||||
import com.mapswithme.maps.search.SearchResult;
|
||||
import com.mapswithme.maps.settings.DrivingOptionsActivity;
|
||||
import com.mapswithme.maps.settings.SettingsActivity;
|
||||
import com.mapswithme.maps.settings.StoragePathManager;
|
||||
import com.mapswithme.maps.settings.UnitLocale;
|
||||
|
@ -177,9 +179,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
private static final int REQ_CODE_LOCATION_PERMISSION = 1;
|
||||
private static final int REQ_CODE_DISCOVERY = 2;
|
||||
private static final int REQ_CODE_SHOW_SIMILAR_HOTELS = 3;
|
||||
private static final int REQ_CODE_ERROR_CALCULATE_ROUTE = 4;
|
||||
private static final int REQ_CODE_ERROR_CALCULATE_ROUTE_FIRST_TIME = 5;
|
||||
private static final String ERROR_CALCULATE_ROUTE_TAG = "error_calculate_route";
|
||||
public static final int REQ_CODE_DRIVING_OPTIONS = 6;
|
||||
private static final String ERROR_CALCULATE_ROUTE_FIRST_TIME_TAG = "`error_calculate_route_first_time";
|
||||
|
||||
// Map tasks that we run AFTER rendering initialized
|
||||
|
@ -246,7 +247,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private View mDrivingOptionsBtn;
|
||||
private View mDrivingOptionsBtnContainer;
|
||||
|
||||
public interface LeftAnimationTrackListener
|
||||
{
|
||||
|
@ -545,10 +546,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void initDrivingOptionsViews()
|
||||
{
|
||||
mDrivingOptionsBtn = findViewById(R.id.driving_options_btn);
|
||||
mDrivingOptionsBtn.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
mDrivingOptionsBtnContainer = findViewById(R.id.driving_options_btn_container);
|
||||
View routingPlanFrame = findViewById(R.id.routing_plan_frame);
|
||||
DrivingOptionsLayoutChangeListener listener = new DrivingOptionsLayoutChangeListener();
|
||||
routingPlanFrame.addOnLayoutChangeListener(listener);
|
||||
View btn = mDrivingOptionsBtnContainer.findViewById(R.id.driving_options_btn);
|
||||
btn.setOnClickListener(v -> DrivingOptionsActivity.start(this));
|
||||
mDrivingOptionsBtnContainer.addOnLayoutChangeListener(listener);
|
||||
}
|
||||
|
||||
private void initTips()
|
||||
|
@ -915,9 +919,19 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
case BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY:
|
||||
handleDownloadedCategoryResult(data);
|
||||
break;
|
||||
case REQ_CODE_DRIVING_OPTIONS:
|
||||
rebuildLastRoute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void rebuildLastRoute()
|
||||
{
|
||||
hideDrivingOptionsView();
|
||||
RoutingController.get().attach(this);
|
||||
RoutingController.get().prepare();
|
||||
}
|
||||
|
||||
private void handleDownloadedCategoryResult(@NonNull Intent data)
|
||||
{
|
||||
BookmarkCategory category = data.getParcelableExtra(BookmarksCatalogActivity.EXTRA_DOWNLOADED_CATEGORY);
|
||||
|
@ -2022,6 +2036,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
mNavigationController.stop(this);
|
||||
updateSearchBar();
|
||||
ThemeSwitcher.restart(isMapRendererActive());
|
||||
hideDrivingOptionsView();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2054,21 +2069,22 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onRouteWarningReceived()
|
||||
{
|
||||
showDrivingOptionPlate();
|
||||
showDrivingOptionView();
|
||||
}
|
||||
|
||||
private void showDrivingOptionPlate()
|
||||
private void showDrivingOptionView()
|
||||
{
|
||||
UiUtils.show(mDrivingOptionsBtn);
|
||||
UiUtils.show(mDrivingOptionsBtnContainer);
|
||||
View image = findViewById(R.id.driving_options_btn_img);
|
||||
UiUtils.showIf(true, image);
|
||||
TextView title = mDrivingOptionsBtn.findViewById(R.id.driving_options_btn_title);
|
||||
// title.setText(true ? );
|
||||
UiUtils.showIf(RoutingOptions.hasAnyOptions(), image);
|
||||
TextView title = mDrivingOptionsBtnContainer.findViewById(R.id.driving_options_btn_title);
|
||||
title.setText(RoutingOptions.hasAnyOptions() ? R.string.change_driving_options_btn
|
||||
: R.string.define_to_avoid_btn);
|
||||
}
|
||||
|
||||
private void hideDrivingOptionsPlate()
|
||||
private void hideDrivingOptionsView()
|
||||
{
|
||||
UiUtils.hide(mDrivingOptionsBtn);
|
||||
UiUtils.hide(mDrivingOptionsBtnContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2733,22 +2749,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
}
|
||||
|
||||
public void showUnableCalculateRouteDialog()
|
||||
{
|
||||
com.mapswithme.maps.dialog.AlertDialog dialog = new com.mapswithme.maps.dialog.AlertDialog.Builder()
|
||||
.setTitleId(R.string.unable_to_recalc_title)
|
||||
.setMessageId(R.string.unable_to_recalc_subtitle)
|
||||
.setPositiveBtnId(R.string.ok)
|
||||
.setReqCode(REQ_CODE_ERROR_CALCULATE_ROUTE)
|
||||
.setFragManagerStrategyType(com.mapswithme.maps.dialog.AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER)
|
||||
.build();
|
||||
dialog.show(this, ERROR_CALCULATE_ROUTE_TAG);
|
||||
}
|
||||
|
||||
public void showUnableCalculateRouteFirstTimeDialog()
|
||||
{
|
||||
com.mapswithme.maps.dialog.AlertDialog dialog = new com.mapswithme.maps.dialog.AlertDialog.Builder()
|
||||
.setTitleId(R.string.unable_to_calc_alert_subtitle)
|
||||
.setTitleId(R.string.unable_to_calc_alert_title)
|
||||
.setMessageId(R.string.unable_to_calc_alert_subtitle)
|
||||
.setPositiveBtnId(R.string.settings)
|
||||
.setNegativeBtnId(R.string.cancel)
|
||||
|
@ -2757,4 +2761,17 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
.build();
|
||||
dialog.show(this, ERROR_CALCULATE_ROUTE_FIRST_TIME_TAG);
|
||||
}
|
||||
|
||||
private class DrivingOptionsLayoutChangeListener implements View.OnLayoutChangeListener
|
||||
{
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
|
||||
int oldTop, int oldRight, int oldBottom)
|
||||
{
|
||||
if (mRoutingPlanInplaceController == null)
|
||||
return;
|
||||
|
||||
adjustCompassAndTraffic(mRoutingPlanInplaceController.getFrame().getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,10 +128,9 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
mLastMissingMaps = missingMaps;
|
||||
mContainsCachedResult = true;
|
||||
|
||||
if (mLastResultCode == ResultCodesHelper.NO_ERROR
|
||||
|| ResultCodesHelper.isMoreMapsNeeded(mLastResultCode))
|
||||
if (false)
|
||||
onBuiltRoute();
|
||||
else if (mLastResultCode == ResultCodesHelper.HAS_WARNINGS)
|
||||
else if (mLastResultCode == ResultCodesHelper.HAS_WARNINGS || true)
|
||||
onWarningReceived();
|
||||
|
||||
processRoutingEvent();
|
||||
|
@ -411,6 +410,11 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
Framework.nativeDeleteSavedRoutePoints();
|
||||
}
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
prepare(getStartPoint(), getEndPoint(), getEndPoint() == null);
|
||||
}
|
||||
|
||||
public void prepare(boolean canUseMyPositionAsStart, @Nullable MapObject endPoint)
|
||||
{
|
||||
prepare(canUseMyPositionAsStart, endPoint, false);
|
||||
|
@ -431,7 +435,7 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
|
||||
public void prepare(@Nullable MapObject startPoint, @Nullable MapObject endPoint)
|
||||
{
|
||||
prepare(startPoint, endPoint, false);
|
||||
prepare(startPoint == null ? LocationHelper.INSTANCE.getMyPosition() : startPoint, endPoint, false);
|
||||
}
|
||||
|
||||
public void prepare(@Nullable MapObject startPoint, @Nullable MapObject endPoint, boolean fromApi)
|
||||
|
@ -843,21 +847,21 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
|
||||
private void setPointsInternal(@Nullable MapObject startPoint, @Nullable MapObject endPoint)
|
||||
{
|
||||
if (startPoint != null)
|
||||
{
|
||||
applyRemovingIntermediatePointsTransaction();
|
||||
addRoutePoint(RoutePointInfo.ROUTE_MARK_START, startPoint);
|
||||
if (mContainer != null)
|
||||
mContainer.updateMenu();
|
||||
}
|
||||
boolean hasStart = startPoint != null;
|
||||
boolean hasEnd = endPoint != null;
|
||||
boolean hasOnePointAtLeast = hasStart || hasEnd;
|
||||
|
||||
if (endPoint != null)
|
||||
{
|
||||
if (hasOnePointAtLeast)
|
||||
applyRemovingIntermediatePointsTransaction();
|
||||
addRoutePoint(RoutePointInfo.ROUTE_MARK_FINISH, endPoint);
|
||||
if (mContainer != null)
|
||||
mContainer.updateMenu();
|
||||
}
|
||||
|
||||
if (hasStart)
|
||||
addRoutePoint(RoutePointInfo.ROUTE_MARK_START , startPoint);
|
||||
|
||||
if (hasEnd)
|
||||
addRoutePoint(RoutePointInfo.ROUTE_MARK_FINISH , endPoint);
|
||||
|
||||
if (hasOnePointAtLeast && mContainer != null)
|
||||
mContainer.updateMenu();
|
||||
}
|
||||
|
||||
void checkAndBuildRoute()
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RoutingOptions
|
|||
private static native void nativeRemoveOption(int option);
|
||||
private static native boolean nativeHasOption(int option);
|
||||
|
||||
static boolean hasAnyOptions()
|
||||
public static boolean hasAnyOptions()
|
||||
{
|
||||
for (RoadType each : RoadType.values())
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ public class RoutingPlanController extends ToolbarController
|
|||
{
|
||||
static final int ANIM_TOGGLE = MwmApplication.get().getResources().getInteger(R.integer.anim_default);
|
||||
|
||||
protected final View mFrame;
|
||||
private final View mFrame;
|
||||
private final RadioGroup mRouterTypes;
|
||||
@NonNull
|
||||
private final WheelProgressView mProgressVehicle;
|
||||
|
@ -89,6 +89,12 @@ public class RoutingPlanController extends ToolbarController
|
|||
mRoutingBottomMenuController = RoutingBottomMenuController.newInstance(getActivity(), mFrame, listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public View getFrame()
|
||||
{
|
||||
return mFrame;
|
||||
}
|
||||
|
||||
private void setupRouterButtons()
|
||||
{
|
||||
setupRouterButton(R.id.vehicle, R.drawable.ic_car, this::onVehicleModeSelected);
|
||||
|
|
|
@ -15,6 +15,9 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
@Nullable
|
||||
private RoutingPlanListener mRoutingPlanListener;
|
||||
|
||||
@Nullable
|
||||
private Animator mAnimator;
|
||||
|
||||
public RoutingPlanInplaceController(@NonNull MwmActivity activity,
|
||||
@Nullable RoutingPlanListener routingPlanListener,
|
||||
@Nullable RoutingBottomMenuListener listener)
|
||||
|
@ -25,16 +28,21 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
|
||||
public void show(final boolean show)
|
||||
{
|
||||
if (mAnimator != null)
|
||||
{
|
||||
mAnimator.cancel();
|
||||
mAnimator.removeAllListeners();
|
||||
}
|
||||
if (show)
|
||||
UiUtils.show(mFrame);
|
||||
UiUtils.show(getFrame());
|
||||
|
||||
animateFrame(show, new Runnable()
|
||||
mAnimator = animateFrame(show, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!show)
|
||||
UiUtils.hide(mFrame);
|
||||
UiUtils.hide(getFrame());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -49,11 +57,12 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
restoreRoutingPanelState(state);
|
||||
}
|
||||
|
||||
private void animateFrame(final boolean show, final @Nullable Runnable completion)
|
||||
@Nullable
|
||||
private ValueAnimator animateFrame(final boolean show, final @Nullable Runnable completion)
|
||||
{
|
||||
if (!checkFrameHeight())
|
||||
{
|
||||
mFrame.post(new Runnable()
|
||||
getFrame().post(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -61,7 +70,7 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
animateFrame(show, completion);
|
||||
}
|
||||
});
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mRoutingPlanListener != null)
|
||||
|
@ -74,7 +83,7 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation)
|
||||
{
|
||||
mFrame.setTranslationY((Float) animation.getAnimatedValue());
|
||||
getFrame().setTranslationY((Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
animator.addListener(new UiUtils.SimpleAnimatorListener()
|
||||
|
@ -88,6 +97,7 @@ public class RoutingPlanInplaceController extends RoutingPlanController
|
|||
});
|
||||
animator.setDuration(ANIM_TOGGLE);
|
||||
animator.start();
|
||||
return animator;
|
||||
}
|
||||
|
||||
public interface RoutingPlanListener
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
|
||||
public class DrivingOptionsActivity extends BaseMwmFragmentActivity
|
||||
|
@ -21,6 +22,6 @@ public class DrivingOptionsActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
Intent intent = new Intent(activity, DrivingOptionsActivity.class)
|
||||
.putExtra(BUNDLE_REQUIRE_OPTIONS_MENU, true);
|
||||
activity.startActivity(intent);
|
||||
activity.startActivityForResult(intent, MwmActivity.REQ_CODE_DRIVING_OPTIONS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -49,6 +50,7 @@ public class DrivingOptionsFragment extends BaseMwmToolbarFragment
|
|||
{
|
||||
if (item.getItemId() == R.id.done)
|
||||
{
|
||||
requireActivity().setResult(Activity.RESULT_OK);
|
||||
requireActivity().finish();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue