forked from organicmaps/organicmaps
Routing buttons.
This commit is contained in:
parent
34ebb59424
commit
88f5a8081f
3 changed files with 101 additions and 39 deletions
|
@ -26,33 +26,60 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/rl__routing_box"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_height="@dimen/routing_pp_height"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/bg_top_panels">
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn__routing_go"
|
||||
<LinearLayout
|
||||
android:id="@+id/ll__routing_go"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/routing_button_height"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/margin_medium"
|
||||
android:text="go, routing, go!"/>
|
||||
android:layout_marginRight="@dimen/margin_medium"
|
||||
android:layout_toLeftOf="@+id/iv__routing_close"
|
||||
android:background="@drawable/ic_route_bg"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingRight="@dimen/margin_small"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__routing_go"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/margin_medium"
|
||||
android:text="@string/routing_go"
|
||||
android:textColor="@color/downloader_green"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_route_go"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv__routing_close"
|
||||
android:layout_width="@dimen/routing_button_height"
|
||||
android:layout_height="@dimen/routing_button_height"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="@dimen/margin_small"
|
||||
android:background="@drawable/ic_route_bg"
|
||||
android:padding="@dimen/margin_medium"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_close_routing"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__routing_distance"
|
||||
style="@style/Holo.TextAppearance.Large.Light"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv__routing_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_height="@dimen/routing_button_height"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="@dimen/margin_small"
|
||||
android:src="@drawable/ic_close_green"/>
|
||||
android:layout_marginLeft="@dimen/margin_small"
|
||||
android:background="@drawable/ic_route_bg"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/margin_small"
|
||||
android:paddingRight="@dimen/margin_small"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<include
|
||||
|
|
|
@ -51,5 +51,7 @@
|
|||
<dimen name="progress_wheel_width_neg">-48dp</dimen>
|
||||
<dimen name="bg_downloader_radius">6dp</dimen>
|
||||
<dimen name="bg_downloader_size">16dp</dimen>
|
||||
<dimen name="routing_pp_height">80dp</dimen>
|
||||
<dimen name="routing_button_height">48dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.view.animation.AlphaAnimation;
|
|||
import android.view.animation.Animation;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -66,6 +67,9 @@ import com.mapswithme.util.UiUtils;
|
|||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.Yota;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
import com.nineoldandroids.animation.ObjectAnimator;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
import com.nvidia.devtech.NvEventQueueActivity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -99,6 +103,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
private ImageView mIvStartRouting;
|
||||
private TextView mTvRoutingDistance;
|
||||
private RelativeLayout mRlRoutingBox;
|
||||
private LinearLayout mLayoutRoutingGo;
|
||||
|
||||
private SearchController mSearchController;
|
||||
private boolean mNeedCheckUpdate = true;
|
||||
|
@ -828,7 +833,8 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
mRlRoutingBox = (RelativeLayout) findViewById(R.id.rl__routing_box);
|
||||
mRlRoutingBox.setVisibility(View.GONE);
|
||||
mRlRoutingBox.findViewById(R.id.iv__routing_close).setOnClickListener(this);
|
||||
mRlRoutingBox.findViewById(R.id.btn__routing_go).setOnClickListener(this);
|
||||
mLayoutRoutingGo = (LinearLayout) mRlRoutingBox.findViewById(R.id.ll__routing_go);
|
||||
mLayoutRoutingGo.setOnClickListener(this);
|
||||
mTvRoutingDistance = (TextView) mRlRoutingBox.findViewById(R.id.tv__routing_distance);
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1401,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
case R.id.iv__routing_close:
|
||||
closeRouting();
|
||||
break;
|
||||
case R.id.btn__routing_go:
|
||||
case R.id.ll__routing_go:
|
||||
followRoute();
|
||||
break;
|
||||
default:
|
||||
|
@ -1406,6 +1412,9 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
private void followRoute()
|
||||
{
|
||||
Framework.nativeFollowRoute();
|
||||
|
||||
Animator animator = ObjectAnimator.ofFloat(mLayoutRoutingGo, "alpha", 1, 0);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
private void buildRoute()
|
||||
|
@ -1498,7 +1507,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRoutingError(final boolean isSuccess, final String message, boolean openDownloader)
|
||||
public void onRoutingError(final boolean isSuccess, final String message, final boolean openDownloader)
|
||||
{
|
||||
runOnUiThread(new Runnable()
|
||||
{
|
||||
|
@ -1508,6 +1517,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
deactivatePopup();
|
||||
if (isSuccess)
|
||||
{
|
||||
ViewHelper.setAlpha(mLayoutRoutingGo, 1);
|
||||
Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
|
||||
alphaAnimation.setFillBefore(true);
|
||||
alphaAnimation.setFillAfter(true);
|
||||
|
@ -1518,30 +1528,53 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
mInfoView.setState(State.HIDDEN);
|
||||
|
||||
if (mIsLocationLocked)
|
||||
{
|
||||
final LocationState.RoutingInfo info = Framework.nativeGetRouteFollowingInfo();
|
||||
if (info != null)
|
||||
mTvRoutingDistance.setText(info.mDistToTarget + info.mUnits);
|
||||
}
|
||||
final LocationState.RoutingInfo info = Framework.nativeGetRouteFollowingInfo();
|
||||
if (info != null)
|
||||
mTvRoutingDistance.setText(info.mDistToTarget + info.mUnits);
|
||||
}
|
||||
else
|
||||
{
|
||||
/// if openDownloader == true than we need show dialog with 2 button. On positive button - open downloader
|
||||
new AlertDialog.Builder(MWMActivity.this)
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(MWMActivity.this)
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
.setCancelable(true);
|
||||
if (openDownloader)
|
||||
{
|
||||
builder
|
||||
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
|
||||
{
|
||||
closeRouting();
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
runDownloadActivity();
|
||||
closeRouting();
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
closeRouting();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
builder
|
||||
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
closeRouting();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue