Implemented search radius for POI in waypoints dialog
This commit is contained in:
parent
f540b3e6fd
commit
4604ec38dc
11 changed files with 142 additions and 13 deletions
BIN
OsmAnd/res/drawable-hdpi/ic_sort_waypoint_dark.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_sort_waypoint_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_sort_waypoint_white.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_sort_waypoint_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_sort_waypoint_dark.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_sort_waypoint_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_sort_waypoint_white.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_sort_waypoint_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_sort_waypoint_dark.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_sort_waypoint_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_sort_waypoint_white.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_sort_waypoint_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
34
OsmAnd/res/layout/radius_search_list_element.xml
Normal file
34
OsmAnd/res/layout/radius_search_list_element.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:layout_marginBottom="3dp">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/ProgressBar"
|
||||||
|
android:layout_marginLeft="4dp"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/header"
|
||||||
|
android:text="@string/search_radius"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:textSize="20sp"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/radius"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="@color/sherpafy_selection"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="8dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -7,12 +7,12 @@
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
android:layout_marginBottom="3dp"
|
android:layout_marginBottom="3dp"
|
||||||
android:layout_marginRight="3dp">
|
android:layout_marginRight="3dp">
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:id="@+id/ProgressBar"
|
android:id="@+id/ProgressBar"
|
||||||
android:layout_marginLeft="4dp"/>
|
android:layout_marginLeft="4dp"/>
|
||||||
|
|
||||||
<TextView android:id="@+id/header_text"
|
<TextView android:id="@+id/header_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -25,4 +25,12 @@
|
||||||
android:textSize="20sp"/>
|
android:textSize="20sp"/>
|
||||||
|
|
||||||
<include layout="@layout/check_item_rel"/>
|
<include layout="@layout/check_item_rel"/>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sort"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginRight="8dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="search_radius">Search radius</string>
|
||||||
<string name="osmo_device_not_found">Device not found</string>
|
<string name="osmo_device_not_found">Device not found</string>
|
||||||
<string name="osmo_no_connection_msg">OsMo service is not available:\n- check the connection;\n- check the settings;\n- check out our Twitter: https://twitter.com/OsMomobi</string>
|
<string name="osmo_no_connection_msg">OsMo service is not available:\n- check the connection;\n- check the settings;\n- check out our Twitter: https://twitter.com/OsMomobi</string>
|
||||||
<string name="anonymous_user_hint">An anonymous user can not:\n- create groups;\n- synchronize groups and devices with the server;\n- manage groups and devices in a private office.</string>
|
<string name="anonymous_user_hint">An anonymous user can not:\n- create groups;\n- synchronize groups and devices with the server;\n- manage groups and devices in a private office.</string>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.PoiFilter;
|
import net.osmand.plus.PoiFilter;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
|
@ -44,6 +45,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
private LinearLayout mainLayout;
|
private LinearLayout mainLayout;
|
||||||
private WaypointHelper waypointHelper;
|
private WaypointHelper waypointHelper;
|
||||||
|
|
||||||
|
private final static String POI_RADIUS = "poi_radius";
|
||||||
|
|
||||||
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
||||||
private View closePointDialog;
|
private View closePointDialog;
|
||||||
private List<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
private List<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
|
@ -245,15 +248,30 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void recalculatePoints(final int[] running, final ArrayAdapter<Object> listAdapter, final int type){
|
||||||
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
app.getWaypointHelper().recalculatePoints(type);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
running[0] = -1;
|
||||||
|
listAdapter.clear();
|
||||||
|
for (Object point : getPoints()) {
|
||||||
|
listAdapter.add(point);
|
||||||
|
}
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}.execute((Void) null);
|
||||||
|
}
|
||||||
|
|
||||||
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable) {
|
final boolean enable) {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
|
||||||
protected void onPreExecute() {
|
|
||||||
}
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
app.getWaypointHelper().enableWaypointType(type, enable);
|
app.getWaypointHelper().enableWaypointType(type, enable);
|
||||||
|
@ -356,6 +374,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
final int[] running = new int[]{-1};
|
final int[] running = new int[]{-1};
|
||||||
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(ctx,
|
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(ctx,
|
||||||
R.layout.waypoint_reached, R.id.title, points) {
|
R.layout.waypoint_reached, R.id.title, points) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
// User super class to create the View
|
// User super class to create the View
|
||||||
|
@ -366,8 +385,60 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
if (v == null || viewText != labelView) {
|
if (v == null || viewText != labelView) {
|
||||||
v = ctx.getLayoutInflater().inflate(labelView ? R.layout.waypoint_header : R.layout.waypoint_reached, null);
|
v = ctx.getLayoutInflater().inflate(labelView ? R.layout.waypoint_header : R.layout.waypoint_reached, null);
|
||||||
}
|
}
|
||||||
if (labelView) {
|
if (getItem(position) instanceof String && getItem(position).equals(POI_RADIUS)){
|
||||||
|
v = ctx.getLayoutInflater().inflate(R.layout.radius_search_list_element, null);
|
||||||
|
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||||
|
final TextView radius = (TextView) v.findViewById(R.id.radius);
|
||||||
|
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(), app));
|
||||||
|
radius.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
|
||||||
|
String[] names = new String[length];
|
||||||
|
int selected = 0;
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
names[i] = OsmAndFormatter.getFormattedDistance(WaypointHelper.SEARCH_RADIUS_VALUES[i], app);
|
||||||
|
if (WaypointHelper.SEARCH_RADIUS_VALUES[i] == waypointHelper.getSearchDeviationRadius()){
|
||||||
|
selected = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setSingleChoiceItems(names, selected, new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i];
|
||||||
|
if (waypointHelper.getSearchDeviationRadius() != value){
|
||||||
|
running[0] = position;
|
||||||
|
waypointHelper.setSearchDeviationRadius(value);
|
||||||
|
radius.setText(OsmAndFormatter.getFormattedDistance(value, app));
|
||||||
|
recalculatePoints(running, thisAdapter, WaypointHelper.POI);
|
||||||
|
dialogInterface.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).setTitle(app.getString(R.string.search_radius)+ " " + app.getString(R.string.poi))
|
||||||
|
.setNegativeButton(R.string.default_buttons_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (labelView) {
|
||||||
|
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
|
||||||
final int type = (Integer) getItem(position);
|
final int type = (Integer) getItem(position);
|
||||||
|
ImageView sort = (ImageView) v.findViewById(R.id.sort);
|
||||||
|
//sort button in Destination header
|
||||||
|
if (type == 0 && sort != null){
|
||||||
|
sort.setVisibility(View.VISIBLE);
|
||||||
|
if (app.getSettings().isLightContent()){
|
||||||
|
sort.setImageResource(R.drawable.ic_sort_waypoint_white);
|
||||||
|
} else {
|
||||||
|
sort.setImageResource(R.drawable.ic_sort_waypoint_dark);
|
||||||
|
}
|
||||||
|
sort.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
||||||
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
|
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
|
||||||
btn.setOnCheckedChangeListener(null);
|
btn.setOnCheckedChangeListener(null);
|
||||||
|
@ -392,6 +463,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||||
tv.setText(getHeader(type, checked));
|
tv.setText(getHeader(type, checked));
|
||||||
} else {
|
} else {
|
||||||
|
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), WaypointDialogFragment.this);
|
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), WaypointDialogFragment.this);
|
||||||
View remove = v.findViewById(R.id.info_close);
|
View remove = v.findViewById(R.id.info_close);
|
||||||
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
||||||
|
@ -448,6 +520,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||||
if (waypointHelper.isTypeVisible(i)) {
|
if (waypointHelper.isTypeVisible(i)) {
|
||||||
points.add(new Integer(i));
|
points.add(new Integer(i));
|
||||||
|
if (i == WaypointHelper.POI && waypointHelper.isTypeEnabled(WaypointHelper.POI)){
|
||||||
|
points.add(POI_RADIUS);
|
||||||
|
}
|
||||||
if (tp != null && tp.size() > 0) {
|
if (tp != null && tp.size() > 0) {
|
||||||
points.addAll(tp);
|
points.addAll(tp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class WaypointHelper {
|
||||||
public static final int FAVORITES = 3;
|
public static final int FAVORITES = 3;
|
||||||
public static final int ALARMS = 4;
|
public static final int ALARMS = 4;
|
||||||
public static final int MAX = 5;
|
public static final int MAX = 5;
|
||||||
|
public static final int[] SEARCH_RADIUS_VALUES = {50, 100, 250, 500, 1000, 1500};
|
||||||
|
|
||||||
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
||||||
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
||||||
|
@ -210,7 +211,9 @@ public class WaypointHelper {
|
||||||
recalculatePoints(route, type, locationPoints);
|
recalculatePoints(route, type, locationPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void recalculatePoints(int type){
|
||||||
|
recalculatePoints(route, type, locationPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isTypeConfigurable(int waypointType) {
|
public boolean isTypeConfigurable(int waypointType) {
|
||||||
|
@ -705,6 +708,14 @@ public class WaypointHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSearchDeviationRadius(){
|
||||||
|
return searchDeviationRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchDeviationRadius(int radius){
|
||||||
|
this.searchDeviationRadius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
private class AmenityLocationPoint implements LocationPoint {
|
private class AmenityLocationPoint implements LocationPoint {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue