Added wptpt parametr for waypoint reached dialog

This commit is contained in:
Denis 2014-07-29 19:38:00 +03:00
parent 840b46f576
commit d5d654ff25
4 changed files with 60 additions and 75 deletions

View file

@ -1,54 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/package_delivered_layout"
android:background="@color/color_black">
android:background="@color/color_black"
android:weightSum="1">
<TextView android:id="@+id/point_name"
<ImageView android:layout_marginLeft="8dp"
android:src="@drawable/list_favorite"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/waypoint_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:textSize="16sp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:textStyle="bold"
android:visibility="gone"/>
<TextView android:id="@+id/point_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:singleLine="false"
android:layout_gravity="center_horizontal"
android:text="@string/waypoint_reached_msg"/>
<LinearLayout android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/info_yes"
<Button android:id="@+id/info_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="@string/default_buttons_yes"/>
<Button android:id="@+id/info_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="@string/default_buttons_no"/>
</LinearLayout>
</LinearLayout>
android:layout_marginLeft="8dp"
android:layout_marginRight="4dp"
android:text="@string/close"/>
</LinearLayout>

View file

@ -41,5 +41,5 @@
<string name="start_tour">Start tour</string>
<string name="download_tour">Download tour</string>
<string name="sherpafy_app_name">Sherpafy</string>
<string name="waypoint_reached_msg">Do you want to see waypoint information?</string>
<string name="waypoint_reached_msg">See waypoint information</string>
</resources>

View file

@ -78,6 +78,8 @@ public class RoutingHelper {
private RouteCalculationProgressCallback progressRoute;
WaypointDialogHelper dialogHelper;
// private ProgressBar progress;
// private Handler progressHandler;
@ -89,6 +91,7 @@ public class RoutingHelper {
this.app = context;
settings = context.getSettings();
voiceRouter = new VoiceRouter(this, settings, player);
dialogHelper = new WaypointDialogHelper(context);
}
public boolean isFollowingMode() {
@ -329,8 +332,7 @@ public class RoutingHelper {
}
if(!Algorithms.isEmpty(s)) {
voiceRouter.announceWaypoint(s);
WaypointDialogHelper dialogHelper = new WaypointDialogHelper(app);
dialogHelper.addDialogWithShift();
dialogHelper.addDialogWithShift(wpt.get(0));
}
}
}

View file

@ -1,24 +1,18 @@
package net.osmand.plus.sherpafy;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.SystemClock;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.*;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.api.render.Paint;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.*;
/**
* Created by Denis on 25.07.2014.
@ -38,7 +32,7 @@ public class WaypointDialogHelper {
}
}
public void addDialogWithShift() {
public void addDialogWithShift(GPXUtilities.WptPt point) {
//if map activity is null - try to get it from app again
if (mapActivity == null){
mapActivity = app.mapActivity;
@ -55,23 +49,38 @@ public class WaypointDialogHelper {
final LayoutInflater vi = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View reachedView = vi.inflate(R.layout.waypoint_reached, null);
Button btnY = (Button) reachedView.findViewById(R.id.info_yes);
btnY.setOnClickListener(new View.OnClickListener() {
TextView text = (TextView) reachedView.findViewById(R.id.waypoint_text);
text.setText(point != null ? point.name : "Point");
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//call your activity here
final Intent favorites = new Intent(mapActivity, app.getAppCustomization().getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(favorites);
removeDialog(view);
}
});
Button btnN = (Button) reachedView.findViewById(R.id.info_no);
Button btnN = (Button) reachedView.findViewById(R.id.info_close);
btnN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View child) {
public void onClick(View view) {
removeDialog(view);
}
});
if (reachedView != null && mainLayout != null) {
mainLayout.addView(reachedView, params);
waitBeforeLayoutIsResized(reachedView);
}
}
public void removeDialog(View child){
if (child == null || child.getParent() == null) {
return;
}
View parent = (View) child.getParent().getParent().getParent();
View parent = (View) child.getParent();
if (parent == null) {
return;
}
@ -83,13 +92,6 @@ public class WaypointDialogHelper {
}
}
}
});
if (reachedView != null && mainLayout != null) {
mainLayout.addView(reachedView, params);
waitBeforeLayoutIsResized(reachedView);
}
}
private boolean checkIfDialogExists() {
if (mainLayout == null){