Merge pull request #848 from Bars107/sherpafy
First implementation of dialog
This commit is contained in:
commit
968d36a025
6 changed files with 131 additions and 49 deletions
|
@ -2,7 +2,5 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:width="1dip" android:color="@color/sherpafy_add_text" />
|
||||
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
|
||||
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
|
||||
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||
</shape>
|
|
@ -19,7 +19,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<net.osmand.plus.views.CustomImageView
|
||||
<ImageView
|
||||
android:layout_marginLeft="1dp"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_marginTop="1dp"
|
||||
|
@ -27,7 +27,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop">
|
||||
</net.osmand.plus.views.CustomImageView>
|
||||
</ImageView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TourName"
|
||||
|
|
|
@ -39,6 +39,11 @@ public class WaypointDialogHelper {
|
|||
private long uiModified;
|
||||
private View closePointDialog;
|
||||
|
||||
private static final String GPX_WAYPOINTS = "GPX waypoints";
|
||||
private static final String FAVORITES = "Favorites";
|
||||
private static final String POI = "POI";
|
||||
private static final String TARGETS = "Targets";
|
||||
|
||||
public WaypointDialogHelper(MapActivity mapActivity) {
|
||||
this.app = mapActivity.getMyApplication();
|
||||
waypointHelper = this.app.getWaypointHelper();
|
||||
|
@ -47,7 +52,7 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
|
||||
public void updateDialog() {
|
||||
List<LocationPoint> vlp = waypointHelper.getVisibleLocationPoints();
|
||||
List<LocationPoint> vlp = waypointHelper.getAllVisibleLocationPoints();
|
||||
long locationPointsModified = waypointHelper.getLocationPointsModified();
|
||||
if (locationPointsModified != uiModified) {
|
||||
uiModified = locationPointsModified;
|
||||
|
@ -70,7 +75,7 @@ public class WaypointDialogHelper {
|
|||
all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showAllDialog();
|
||||
showAllDialog(waypointHelper.getAllVisibleLocationPoints());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -185,8 +190,95 @@ public class WaypointDialogHelper {
|
|||
}.execute(reachedView);
|
||||
}
|
||||
|
||||
public void showAllDialog(){
|
||||
final List<LocationPoint> visibleLocationPoints = waypointHelper.getVisibleLocationPoints();
|
||||
public void showWaypointsSettingsDialog(){
|
||||
final List<Object> points = getItemsList(waypointHelper.getAllVisibleLocationPoints());
|
||||
|
||||
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(mapActivity, R.layout.waypoint_reached, R.id.title,
|
||||
points) {
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
if (points.get(position) instanceof LocationPoint){
|
||||
v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
int vl = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, mapActivity.getResources()
|
||||
.getDisplayMetrics());
|
||||
final LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(vl, vl);
|
||||
ll.setMargins(vl / 4, vl / 4, vl / 4, vl / 4);
|
||||
v.findViewById(R.id.waypoint_icon).setLayoutParams(ll);
|
||||
} else if (points.get(position) instanceof String){
|
||||
String header = (String)points.get(position);
|
||||
v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_header, null);
|
||||
TextView headerText = (TextView) v.findViewById(R.id.header_text);
|
||||
headerText.setText(header);
|
||||
ImageButton allpoints = (ImageButton) v.findViewById(R.id.all_points);
|
||||
if (header.equals(FAVORITES)){
|
||||
allpoints.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showAllDialog(waypointHelper.getVisibleFavorites());
|
||||
}
|
||||
});
|
||||
} else if (header.equals(TARGETS)){
|
||||
allpoints.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showAllDialog(waypointHelper.getVisibleTargets());
|
||||
}
|
||||
});
|
||||
} else if (header.equals(GPX_WAYPOINTS)){
|
||||
allpoints.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showAllDialog(waypointHelper.getVisibleGpxPoints());
|
||||
}
|
||||
});
|
||||
} else if (header.equals(POI)){
|
||||
allpoints.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showAllDialog(waypointHelper.getVisiblePOI());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
updatePointInfoView(v, (LocationPoint)getItem(position));
|
||||
TextView text = (TextView) v.findViewById(R.id.waypoint_text);
|
||||
text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showOnMap((LocationPoint)points.get(position));
|
||||
}
|
||||
});
|
||||
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
((ImageButton) remove).setImageDrawable(mapActivity.getResources().getDrawable(
|
||||
app.getSettings().isLightContent()? R.drawable.ic_action_gremove_light:
|
||||
R.drawable.ic_action_gremove_dark));
|
||||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LocationPoint point = waypointHelper.getAllVisibleLocationPoints().get(position);
|
||||
remove(point);
|
||||
waypointHelper.removeVisibleLocationPoint(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private List<Object> getItemsList(List<LocationPoint> visibleLocationPoints) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showAllDialog(final List<LocationPoint> visibleLocationPoints){
|
||||
final ArrayAdapter<LocationPoint> listAdapter = new ArrayAdapter<LocationPoint>(mapActivity, R.layout.waypoint_reached, R.id.title,
|
||||
visibleLocationPoints) {
|
||||
@Override
|
||||
|
@ -217,7 +309,7 @@ public class WaypointDialogHelper {
|
|||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LocationPoint point = waypointHelper.getVisibleLocationPoints().get(position);
|
||||
LocationPoint point = waypointHelper.getAllVisibleLocationPoints().get(position);
|
||||
remove(point);
|
||||
waypointHelper.removeVisibleLocationPoint(point);
|
||||
notifyDataSetChanged();
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.plus.helpers;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -41,10 +43,38 @@ public class WaypointHelper {
|
|||
}
|
||||
|
||||
|
||||
public List<LocationPoint> getVisibleLocationPoints() {
|
||||
public List<LocationPoint> getAllVisibleLocationPoints() {
|
||||
return visibleLocationPoints;
|
||||
}
|
||||
|
||||
public List<LocationPoint> getVisibleFavorites() {
|
||||
List<LocationPoint> points = new ArrayList<LocationPoint>();
|
||||
for (LocationPoint point : visibleLocationPoints){
|
||||
if (point instanceof FavouritePoint){
|
||||
points.add(point);
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
public List<LocationPoint> getVisibleGpxPoints() {
|
||||
List<LocationPoint> points = new ArrayList<LocationPoint>();
|
||||
for (LocationPoint point : visibleLocationPoints){
|
||||
if (point instanceof GPXUtilities.WptPt){
|
||||
points.add(point);
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
public List<LocationPoint> getVisiblePOI() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LocationPoint> getVisibleTargets() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void locationChanged(Location location) {
|
||||
app.getAppCustomization();
|
||||
lastKnownLocation = location;
|
||||
|
|
|
@ -306,7 +306,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
|
||||
@Override
|
||||
public void prepareLocationMenu(final MapActivity mapActivity, ContextMenuAdapter adapter) {
|
||||
filter(adapter, R.string.context_menu_item_directions_to,
|
||||
filter(adapter, R.string.pause_navigation, R.string.continue_navigation, R.string.context_menu_item_directions_to,
|
||||
R.string.context_menu_item_destination_point, R.string.context_menu_item_search,
|
||||
R.string.context_menu_item_share_location/*, R.string.context_menu_item_add_favorite*/);
|
||||
MapActivityLayers layers = mapActivity.getMapLayers();
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* Created by Denis on 13.08.2014.
|
||||
*/
|
||||
public class CustomImageView extends ImageView {
|
||||
|
||||
public static float radius = 13.0f;
|
||||
|
||||
public CustomImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CustomImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public CustomImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
//float radius = 36.0f;
|
||||
Path clipPath = new Path();
|
||||
RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
|
||||
clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
|
||||
canvas.clipPath(clipPath);
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue