[android] del: Unused resources and obsolete code removed.

This commit is contained in:
Alexander Marchuk 2015-11-06 17:01:58 +03:00
parent 92985ec52c
commit af67d0356b
78 changed files with 0 additions and 704 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,003 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:drawable="@color/base_blue_light"/>
</ripple>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 906 B

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="3dp" />
<stroke
android:width="1dp"
android:color="@color/text_place_page_buttons" />
<solid android:color="@android:color/transparent" />
</shape>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="3dp" />
<stroke
android:width="1dp"
android:color="@color/text_place_page_buttons" />
<solid android:color="@android:color/transparent" />
</shape>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- FIXME -->
<item android:drawable="@drawable/bg_bottom_btn_active" android:state_pressed="true"/>
<item android:drawable="@drawable/bg_bottom_btn"/>
</selector>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:enterFadeDuration="200"
android:exitFadeDuration="200"
tools:ignore="UnusedAttribute">
<item android:state_pressed="true">
<bitmap android:gravity="center"
android:src="@drawable/ic_toolbar_active_vert"/>
</item>
<item android:drawable="@android:color/transparent"/>
</selector>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<bitmap android:gravity="center"
android:src="@drawable/ic_place_page_bookmark_button_selected"/>
</item>
<item android:state_checked="false">
<bitmap android:gravity="center"
android:src="@drawable/ic_place_page_bookmark_button"/>
</item>
</selector>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/menu_point_to_point_disabled"
android:state_enabled="false"/>
<item android:drawable="@drawable/ic_menu_point_to_point"/>
</selector>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_menu_point_to_point"
android:alpha="0.2"/>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/base_blue" android:state_pressed="true"/>
<item android:drawable="@color/base_blue" android:state_focused="true"/>
<item android:drawable="@color/base_blue_light"/>
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/layout__routing_setup"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
style="@style/MwmWidget.Floating.Panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:elevation="@dimen/appbar_elevation">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="@dimen/height_routing_info"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.mapswithme.maps.widget.WheelProgressView
android:id="@+id/wp__routing_progress"
android:layout_width="@dimen/base_block_size"
android:layout_height="@dimen/base_block_size"
android:layout_margin="@dimen/margin_quarter"
android:layout_weight="0"
android:background="?selectableItemBackgroundBorderless"
android:padding="@dimen/margin_quarter"
android:visibility="gone"
wheel:centerDrawable="@drawable/ic_close"
wheel:wheelProgressColor="@color/routing_blue"
wheel:wheelSecondaryColor="@color/base_black_divider"
wheel:wheelThickness="@dimen/margin_eighth"/>
<ImageView
android:id="@+id/iv__routing_close"
android:layout_width="@dimen/base_block_size"
android:layout_height="@dimen/base_block_size"
android:layout_margin="@dimen/margin_quarter"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/margin_base"
android:scaleType="center"
android:src="@drawable/ic_close_routing"/>
<TextView
android:id="@+id/tv__planning_route"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="1"
android:text="@string/routing_planning"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:text="Planning route..."
tools:visibility="gone"/>
<TextView
android:id="@+id/tv__routing_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_base"
android:layout_marginRight="@dimen/margin_base"
android:layout_weight="0"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:visibility="gone"
tools:text="38 km"
tools:visibility="visible"/>
<TextView
android:id="@+id/tv__routing_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_base"
android:layout_marginRight="@dimen/margin_base"
android:layout_weight="1"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:visibility="gone"
tools:text="16 min"
tools:visibility="visible"/>
<RadioGroup
android:id="@+id/rg__router"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rb__pedestrian"
android:layout_width="@dimen/base_block_size"
android:layout_height="match_parent"
android:button="@drawable/selector_pedestrian"/>
<RadioButton
android:id="@+id/rb__vehicle"
android:layout_width="@dimen/base_block_size"
android:layout_height="match_parent"
android:button="@drawable/selector_vehicle"/>
</RadioGroup>
</LinearLayout>
<Button
android:id="@+id/btn__start_routing"
style="@style/MwmWidget.Button.Blue"
android:layout_width="match_parent"
android:layout_height="@dimen/base_block_size"
android:layout_below="@id/content"
android:gravity="center"
android:text="@string/routing_start"
android:textAllCaps="true"
android:textAppearance="@style/MwmTextAppearance.Body3.Light"/>
</RelativeLayout>

View file

@ -1,512 +0,0 @@
package com.mapswithme.maps.widget;
import android.content.Context;
import android.content.DialogInterface;
import android.location.Location;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.LocationState;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.routing.RoutingInfo;
import com.mapswithme.maps.routing.RoutingResultCodesProcessor;
import com.mapswithme.util.Config;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.statistics.AlohaHelper;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
/**
* Layout for routing setup & turn instruction box.
*/
public class RoutingLayout extends RelativeLayout implements View.OnClickListener
{
private WheelProgressView mWvProgress;
private TextView mTvPlanning;
private View mIvCancelRouteBuild;
private TextView mTvPrepareTime;
private TextView mTvTotalDistance;
private TextView mTvTotalTime;
private ImageView mIvTurn;
private TextView mTvExitNum;
private View mNextTurn;
private ImageView mIvNextTurn;
private TextView mTvTurnDistance;
private TextView mTvPrepareDistance;
private MapObject mEndPoint;
private View mLayoutSetupRouting;
private View mLayoutTurnInstructions;
private View mBtnStart;
private FlatProgressView mFpRouteProgress;
private RadioGroup mRgRouterType;
private TextView mTvNextStreet;
private TextView mTvArrivalTime;
private double mNorth;
private RoutingInfo mCachedRoutingInfo;
public enum State
{
HIDDEN,
PREPARING,
ROUTE_BUILT,
ROUTE_BUILD_ERROR,
TURN_INSTRUCTIONS
}
private State mState = State.HIDDEN;
public interface ActionListener
{
void onCloseRouting();
void onStartRouteFollow();
void onRouteTypeChange(int type);
}
private ActionListener mListener;
public RoutingLayout(Context context)
{
this(context, null, 0);
}
public RoutingLayout(Context context, AttributeSet attrs)
{
this(context, attrs, 0);
}
public RoutingLayout(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, defStyleAttr);
inflate(getContext(), R.layout.layout_routing_full, this);
setClipToPadding(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
setElevation(UiUtils.dimen(R.dimen.appbar_elevation));
if (isInEditMode())
return;
initViews();
UiUtils.hide(this, mLayoutSetupRouting, mBtnStart, mLayoutTurnInstructions);
}
public void setListener(ActionListener listener)
{
mListener = listener;
}
public void refreshAzimuth(double north)
{
mNorth = north;
if (mState == State.TURN_INSTRUCTIONS)
refreshTurnInstructions();
}
private void initViews()
{
mLayoutSetupRouting = findViewById(R.id.layout__routing_setup);
mWvProgress = (WheelProgressView) mLayoutSetupRouting.findViewById(R.id.wp__routing_progress);
mWvProgress.setOnClickListener(this);
mTvPlanning = (TextView) mLayoutSetupRouting.findViewById(R.id.tv__planning_route);
mRgRouterType = (RadioGroup) mLayoutSetupRouting.findViewById(R.id.rg__router);
mRgRouterType.findViewById(R.id.rb__vehicle).setOnClickListener(this);
mRgRouterType.findViewById(R.id.rb__pedestrian).setOnClickListener(this);
mIvCancelRouteBuild = mLayoutSetupRouting.findViewById(R.id.iv__routing_close);
mIvCancelRouteBuild.setOnClickListener(this);
mTvPrepareDistance = (TextView) mLayoutSetupRouting.findViewById(R.id.tv__routing_distance);
mTvPrepareTime = (TextView) mLayoutSetupRouting.findViewById(R.id.tv__routing_time);
mBtnStart = mLayoutSetupRouting.findViewById(R.id.btn__start_routing);
mBtnStart.setOnClickListener(this);
mLayoutTurnInstructions = findViewById(R.id.layout__turn_instructions);
mTvTotalDistance = (TextView) mLayoutTurnInstructions.findViewById(R.id.tv__total_distance);
mTvTotalTime = (TextView) mLayoutTurnInstructions.findViewById(R.id.tv__total_time);
mTvArrivalTime = (TextView) mLayoutTurnInstructions.findViewById(R.id.tv__arrival_time);
mIvTurn = (ImageView) mLayoutTurnInstructions.findViewById(R.id.iv__turn);
mTvExitNum = (TextView) mLayoutTurnInstructions.findViewById(R.id.tv__exit_num);
mNextTurn = findViewById(R.id.next_turn);
mIvNextTurn = (ImageView) mNextTurn.findViewById(R.id.iv__next_turn);
mTvTurnDistance = (TextView) mLayoutTurnInstructions.findViewById(R.id.tv__turn_distance);
mLayoutTurnInstructions.findViewById(R.id.btn__close).setOnClickListener(this);
mFpRouteProgress = (FlatProgressView) mLayoutTurnInstructions.findViewById(R.id.fp__route_progress);
mTvNextStreet = (TextView) mLayoutTurnInstructions.findViewById(R.id.tv__next_street);
}
@Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.btn__close:
AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
setState(State.HIDDEN, true);
mListener.onCloseRouting();
break;
case R.id.iv__routing_close:
AlohaHelper.logClick(AlohaHelper.ROUTING_GO_CLOSE);
setState(State.HIDDEN, true);
mListener.onCloseRouting();
break;
case R.id.wp__routing_progress:
AlohaHelper.logClick(AlohaHelper.ROUTING_PROGRESS_CLOSE);
setState(State.HIDDEN, true);
mListener.onCloseRouting();
break;
case R.id.btn__start_routing:
AlohaHelper.logClick(AlohaHelper.ROUTING_GO);
setState(State.TURN_INSTRUCTIONS, true);
Framework.nativeFollowRoute();
mListener.onStartRouteFollow();
break;
case R.id.rb__pedestrian:
AlohaHelper.logClick(AlohaHelper.ROUTING_PEDESTRIAN_SET);
Framework.setRouter(Framework.ROUTER_TYPE_PEDESTRIAN);
mListener.onRouteTypeChange(Framework.ROUTER_TYPE_PEDESTRIAN);
setState(State.PREPARING, true);
break;
case R.id.rb__vehicle:
AlohaHelper.logClick(AlohaHelper.ROUTING_VEHICLE_SET);
Framework.setRouter(Framework.ROUTER_TYPE_VEHICLE);
mListener.onRouteTypeChange(Framework.ROUTER_TYPE_VEHICLE);
setState(State.PREPARING, true);
break;
}
}
public void setState(State state, boolean animated)
{
mState = state;
switch (mState)
{
case HIDDEN:
if (animated)
UiUtils.disappearSlidingUp(this, null);
else
UiUtils.hide(this);
UiUtils.hide(mBtnStart, mTvExitNum);
Framework.nativeCloseRouting();
mEndPoint = null;
break;
case PREPARING:
if (mEndPoint == null)
throw new IllegalStateException("End point should be not null to prepare routing");
Framework.nativeCloseRouting();
UiUtils.show(mLayoutSetupRouting, mWvProgress, mTvPlanning);
UiUtils.hide(mLayoutTurnInstructions, mTvPrepareDistance, mTvPrepareTime, mIvCancelRouteBuild, mNextTurn);
mTvPlanning.setText(R.string.routing_planning);
mWvProgress.setProgress(0);
if (animated)
{
UiUtils.appearSlidingDown(this, null);
UiUtils.disappearSlidingUp(mBtnStart, null);
}
else
{
UiUtils.show(this);
UiUtils.hide(mBtnStart);
}
buildRoute();
break;
case ROUTE_BUILT:
UiUtils.show(this, mLayoutSetupRouting, mTvPrepareDistance, mTvPrepareTime, mIvCancelRouteBuild);
UiUtils.hide(mLayoutTurnInstructions, mWvProgress, mTvPlanning, mNextTurn);
if (animated)
UiUtils.appearSlidingDown(mBtnStart, null);
else
UiUtils.show(mBtnStart);
refreshRouteSetup();
break;
case ROUTE_BUILD_ERROR:
UiUtils.show(mLayoutSetupRouting, mIvCancelRouteBuild, mTvPlanning);
UiUtils.hide(mLayoutTurnInstructions, mTvPrepareDistance, mTvPrepareTime, mWvProgress, mNextTurn);
mTvPlanning.setText(R.string.routing_planning_error);
break;
case TURN_INSTRUCTIONS:
UiUtils.show(this, mLayoutTurnInstructions);
UiUtils.disappearSlidingUp(mLayoutSetupRouting, null);
refreshTurnInstructions();
break;
}
}
public State getState()
{
return mState;
}
public void setEndPoint(MapObject mapObject)
{
mEndPoint = mapObject;
checkBestRouter();
}
public MapObject getEndPoint()
{
return mEndPoint;
}
public void updateRouteInfo()
{
mCachedRoutingInfo = Framework.nativeGetRouteFollowingInfo();
if (mState == State.TURN_INSTRUCTIONS)
refreshTurnInstructions();
}
public void setRouteBuildingProgress(float progress)
{
mWvProgress.setProgress((int) progress);
}
private void refreshTurnInstructions()
{
if (mCachedRoutingInfo == null)
return;
if (Framework.getRouter() == Framework.ROUTER_TYPE_VEHICLE)
refreshVehicleInfo(mCachedRoutingInfo);
else
refreshPedestrianAzimutAndDistance(mCachedRoutingInfo);
mTvTotalTime.setText(formatRoutingTime(mCachedRoutingInfo.totalTimeInSeconds));
mTvTotalDistance.setText(buildSpannedText(UiUtils.dimen(R.dimen.text_size_routing_number), UiUtils.dimen(R.dimen.text_size_routing_dimension),
mCachedRoutingInfo.distToTarget, mCachedRoutingInfo.targetUnits));
mTvArrivalTime.setText(formatArrivalTime(mCachedRoutingInfo.totalTimeInSeconds));
UiUtils.setTextAndHideIfEmpty(mTvNextStreet, mCachedRoutingInfo.nextStreet);
mFpRouteProgress.setProgress((int) mCachedRoutingInfo.completionPercent);
}
private void refreshVehicleInfo(RoutingInfo routingInfo)
{
mTvTurnDistance.setText(buildSpannedText(UiUtils.dimen(R.dimen.text_size_display_1), UiUtils.dimen(R.dimen.text_size_toolbar),
routingInfo.distToTurn, routingInfo.turnUnits));
routingInfo.vehicleTurnDirection.setTurnDrawable(mIvTurn);
if (RoutingInfo.VehicleTurnDirection.isRoundAbout(routingInfo.vehicleTurnDirection))
UiUtils.setTextAndShow(mTvExitNum, String.valueOf(routingInfo.exitNum));
else
UiUtils.hide(mTvExitNum);
if (routingInfo.vehicleNextTurnDirection.containsNextTurn())
{
if (mNextTurn.getVisibility() != VISIBLE && mNextTurn.getAnimation() == null)
UiUtils.appearSlidingDown(mNextTurn, null);
routingInfo.vehicleNextTurnDirection.setNextTurnDrawable(mIvNextTurn);
}
else if (mNextTurn.getVisibility() == VISIBLE && mNextTurn.getAnimation() == null)
UiUtils.disappearSlidingUp(mNextTurn, null);
}
private void refreshPedestrianAzimutAndDistance(RoutingInfo info)
{
Location location = LocationHelper.INSTANCE.getLastLocation();
DistanceAndAzimut distanceAndAzimut = Framework.nativeGetDistanceAndAzimutFromLatLon(
info.pedestrianNextDirection.getLatitude(), info.pedestrianNextDirection.getLongitude(), location.getLatitude(), location.getLongitude(), mNorth);
String[] splitDistance = distanceAndAzimut.getDistance().split(" ");
mTvTurnDistance.setText(buildSpannedText(UiUtils.dimen(R.dimen.text_size_display_1), UiUtils.dimen(R.dimen.text_size_toolbar),
splitDistance[0], splitDistance[1]));
if (info.pedestrianTurnDirection != null)
info.pedestrianTurnDirection.setTurnDrawable(mIvTurn, distanceAndAzimut);
}
private void refreshRouteSetup()
{
mCachedRoutingInfo = Framework.nativeGetRouteFollowingInfo();
if (mCachedRoutingInfo == null)
return;
mTvPrepareDistance.setText(buildSpannedText(UiUtils.dimen(R.dimen.text_size_routing_number), UiUtils.dimen(R.dimen.text_size_routing_dimension),
mCachedRoutingInfo.distToTarget, mCachedRoutingInfo.targetUnits));
mTvPrepareTime.setText(formatRoutingTime(mCachedRoutingInfo.totalTimeInSeconds));
}
private static SpannableStringBuilder buildSpannedText(int mainTextSize, int unitsTextSize, String main, String units)
{
SpannableStringBuilder builder = new SpannableStringBuilder(main).append(" ").append(units);
builder.setSpan(new AbsoluteSizeSpan(mainTextSize, false), 0, main.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(unitsTextSize, false), main.length(), builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
}
private static CharSequence formatRoutingTime(int seconds)
{
long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
long hours = TimeUnit.SECONDS.toHours(seconds);
if (hours == 0 && minutes == 0)
// one minute is added to estimated time to destination point to prevent displaying zero minutes left
minutes++;
return hours == 0 ?
buildSpannedText(UiUtils.dimen(R.dimen.text_size_routing_number), UiUtils.dimen(R.dimen.text_size_routing_dimension), String.valueOf(minutes), "min") :
TextUtils.concat(buildSpannedText(UiUtils.dimen(R.dimen.text_size_routing_number), UiUtils.dimen(R.dimen.text_size_routing_dimension),
String.valueOf(hours), "h "),
buildSpannedText(UiUtils.dimen(R.dimen.text_size_routing_number), UiUtils.dimen(R.dimen.text_size_routing_dimension),
String.valueOf(minutes), "min"));
}
private static String formatArrivalTime(int seconds)
{
Calendar current = Calendar.getInstance();
current.add(Calendar.SECOND, seconds);
return String.format("%d:%02d", current.get(Calendar.HOUR_OF_DAY), current.get(Calendar.MINUTE));
}
private void buildRoute()
{
if (!Config.isRoutingDisclaimerAccepted())
{
showRoutingDisclaimer();
return;
}
if (!LocationState.isTurnedOn())
{
onMissingLocation();
return;
}
Location location = LocationHelper.INSTANCE.getLastLocation();
if (location == null)
{
// TODO remove that hack after proper route reconstruction logic will be finished
setState(State.HIDDEN, false);
return;
}
Framework.nativeBuildRoute(location.getLatitude(), location.getLongitude(), mEndPoint.getLat(), mEndPoint.getLon());
}
private void checkBestRouter()
{
final Location location = LocationHelper.INSTANCE.getLastLocation();
if (location == null || mEndPoint == null)
return;
final int bestRouter = Framework.nativeGetBestRouter(location.getLatitude(), location.getLongitude(), mEndPoint.getLat(), mEndPoint.getLon());
mRgRouterType.check(bestRouter == Framework.ROUTER_TYPE_PEDESTRIAN ? R.id.rb__pedestrian : R.id.rb__vehicle);
Framework.setRouter(bestRouter);
}
private void showRoutingDisclaimer()
{
StringBuilder builder = new StringBuilder();
for (int resId : new int[]{R.string.dialog_routing_disclaimer_priority, R.string.dialog_routing_disclaimer_precision,
R.string.dialog_routing_disclaimer_recommendations, R.string.dialog_routing_disclaimer_beware})
builder.append(getContext().getString(resId)).append("\n\n");
new AlertDialog.Builder(getContext())
.setTitle(R.string.dialog_routing_disclaimer_title)
.setMessage(builder.toString())
.setCancelable(false)
.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dlg, int which)
{
Config.acceptRoutingDisclaimer();
dlg.dismiss();
buildRoute();
}
})
.setNegativeButton(getContext().getString(R.string.cancel), null)
.show();
}
private void onMissingLocation()
{
Context context = getContext();
if (context instanceof Framework.RoutingListener)
((Framework.RoutingListener) context).onRoutingEvent(RoutingResultCodesProcessor.NO_POSITION, null, null);
}
@Override
protected Parcelable onSaveInstanceState()
{
Parcelable parentState = super.onSaveInstanceState();
SavedState savedState = new SavedState(parentState);
savedState.object = getEndPoint();
savedState.routingStateOrdinal = mState.ordinal();
return savedState;
}
@Override
protected void onRestoreInstanceState(Parcelable state)
{
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
setEndPoint(savedState.object);
// if route was build but it was lost before state was restored - we should rebuild again from scratch
int correctOrdinal;
if (savedState.routingStateOrdinal > State.PREPARING.ordinal() && !Framework.nativeIsRouteBuilt())
correctOrdinal = State.PREPARING.ordinal();
else
correctOrdinal = savedState.routingStateOrdinal;
setState(State.values()[correctOrdinal], false);
}
static class SavedState extends BaseSavedState
{
int routingStateOrdinal;
MapObject object;
public SavedState(Parcel source)
{
super(source);
routingStateOrdinal = source.readInt();
object = source.readParcelable(MapObject.class.getClassLoader());
}
public SavedState(Parcelable superState)
{
super(superState);
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags)
{
super.writeToParcel(dest, flags);
dest.writeInt(routingStateOrdinal);
dest.writeParcelable(object, 0);
}
public static final Creator<SavedState> CREATOR = new Creator<SavedState>()
{
@Override
public SavedState createFromParcel(Parcel source)
{
return new SavedState(source);
}
@Override
public SavedState[] newArray(int size)
{
return new SavedState[0];
}
};
}
}