BIN
OsmAnd/res/drawable-hdpi/ic_flat_list_dark.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_flat_list_white.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_tree_list_dark.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_tree_list_white.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_flat_list_dark.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_flat_list_white.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_tree_list_dark.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_tree_list_white.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_flat_list_dark.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_flat_list_white.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_tree_list_dark.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_tree_list_white.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
|
@ -1,24 +0,0 @@
|
|||
<?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="match_parent">
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView android:id="@+id/descr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView android:id="@+id/title"
|
||||
android:textSize="18sp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
<ImageButton android:id="@+id/remove"
|
||||
android:focusable="false"
|
||||
android:layout_marginLeft="11dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
|
@ -4,32 +4,51 @@
|
|||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="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"/>
|
||||
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/waypoints"
|
||||
android:ellipsize="end"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<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:focusable="false"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/all"
|
||||
android:contentDescription="@string/flat_list_waypoints"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginRight="8dp"/>
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:choiceMode="singleChoice"
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.widget.*;
|
|||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
@ -12,6 +14,7 @@ import android.os.Build;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
|
||||
public class ContextMenuAdapter {
|
||||
|
||||
|
@ -267,6 +270,18 @@ public class ContextMenuAdapter {
|
|||
// User super class to create the View
|
||||
View v = convertView;
|
||||
Integer lid = getLayoutId(position);
|
||||
if (lid == R.layout.mode_toggles){
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
return AppModeDialog.prepareAppModeView(activity, selected, true, null, true, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(selected.size() > 0) {
|
||||
((OsmandApplication)activity.getApplication()).getSettings().APPLICATION_MODE.set(selected.iterator().next());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (v == null || (v.getTag() != lid)) {
|
||||
v = activity.getLayoutInflater().inflate(lid, null);
|
||||
v.setTag(lid);
|
||||
|
@ -331,6 +346,4 @@ public class ContextMenuAdapter {
|
|||
return listAdapter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -40,12 +40,6 @@ import android.widget.TextView;
|
|||
|
||||
public class IntermediatePointsDialog {
|
||||
|
||||
|
||||
public static void openIntermediatePointsDialog(MapActivity mapActivity){
|
||||
// openIntermediatePointsDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), false);
|
||||
WaypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
||||
}
|
||||
|
||||
public static void openIntermediatePointsDialog(final Activity activity,
|
||||
final OsmandApplication app, final boolean changeOrder){
|
||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
|
|
|
@ -1,38 +1,28 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.londatiga.android.ActionItem;
|
||||
import net.londatiga.android.QuickAction;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.Item;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -44,7 +34,6 @@ import net.osmand.plus.activities.actions.OsmAndDialogs;
|
|||
import net.osmand.plus.activities.actions.ShareLocation;
|
||||
import net.osmand.plus.activities.actions.StartGPSStatus;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||
|
@ -55,36 +44,26 @@ import net.osmand.plus.routing.RoutingHelper;
|
|||
import net.osmand.plus.views.BaseMapLayer;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MapActivityActions implements DialogProvider {
|
||||
|
@ -363,7 +342,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
targets.navigateToPoint(new LatLon(latitude, longitude), true,
|
||||
dest ? -1 : targets.getIntermediatePoints().size(), selected);
|
||||
if(targets.getIntermediatePoints().size() > 0) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(mapActivity);
|
||||
openIntermediatePointsDialog();
|
||||
}
|
||||
} else if (standardId == R.string.context_menu_item_share_location) {
|
||||
enhance(dialogBundle,latitude,longitude,mapActivity.getMapView().getZoom());
|
||||
|
@ -737,7 +716,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
// ContextMenuAdapter cm = waypointDialogHelper.setListAdapter(app.getMapActivity(),
|
||||
// mDrawerList, deletedPoints);
|
||||
// prepareOptionsMenu(cm);
|
||||
WaypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
||||
boolean drawer = true;
|
||||
if (drawer) {
|
||||
showWaypointsInDrawer(false);
|
||||
} else {
|
||||
waypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
@ -794,7 +778,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().openViewConfigureDrawer();
|
||||
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
||||
prepareOptionsMenu(cm);
|
||||
return false;
|
||||
}
|
||||
|
@ -877,9 +861,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
return optionsMenuHelper;
|
||||
}
|
||||
|
||||
|
||||
public void showWaypointsInDrawer(boolean b) {
|
||||
final int[] running = new int[]{-1};
|
||||
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(b, mapActivity,
|
||||
running);
|
||||
mDrawerList.setAdapter(listAdapter);
|
||||
mDrawerList.setDivider(mapActivity.getResources().getDrawable(R.drawable.drawer_divider));
|
||||
mDrawerList.setBackgroundColor( getMyApplication().getSettings().isLightContentMenu()?
|
||||
mapActivity.getResources().getColor(R.color.color_white) :
|
||||
mapActivity.getResources().getColor(R.color.dark_drawer_bg_color));
|
||||
mDrawerList.setOnItemClickListener(waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, listAdapter, null));
|
||||
}
|
||||
|
||||
public void openIntermediatePointsDialog(){
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(mapActivity);
|
||||
waypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
||||
}
|
||||
|
||||
private TargetPointsHelper getTargets() {
|
||||
|
|
|
@ -41,7 +41,8 @@ public class ConfigureMapMenu {
|
|||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
adapter.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||
|
||||
createLayersItems(adapter, ma);
|
||||
createRenderingAttributeItems(adapter, ma);
|
||||
return adapter;
|
||||
|
|
|
@ -52,9 +52,10 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
private LinearLayout mainLayout;
|
||||
private WaypointHelper waypointHelper;
|
||||
|
||||
|
||||
|
||||
private static class RadiusItem {
|
||||
int type;
|
||||
|
||||
public RadiusItem(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -128,7 +129,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
mainLayout.addView(closePointDialog, getDialogLayoutParams());
|
||||
waitBeforeLayoutIsResized(dlg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +218,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}.execute(reachedView);
|
||||
}
|
||||
|
||||
public static void showWaypointsDialogFlat(FragmentActivity fragmentActivity, boolean edit) {
|
||||
public void showWaypointsDialogFlat(FragmentActivity fragmentActivity, boolean edit) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(WaypointDialogFragment.FLAT_ARG, true);
|
||||
args.putBoolean(WaypointDialogFragment.EDIT_ARG, edit);
|
||||
|
@ -226,7 +227,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
||||
}
|
||||
|
||||
public static void showWaypointsDialog(FragmentActivity fragmentActivity, boolean edit) {
|
||||
public void showWaypointsDialog(FragmentActivity fragmentActivity, boolean edit) {
|
||||
Bundle args = new Bundle();
|
||||
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
||||
args.putBoolean(WaypointDialogFragment.EDIT_ARG, edit);
|
||||
|
@ -234,7 +235,491 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
||||
}
|
||||
|
||||
public static class WaypointDialogFragment extends DialogFragment {
|
||||
|
||||
public ArrayAdapter<Object> getWaypointsDrawerAdapter(final boolean edit,
|
||||
final FragmentActivity ctx, final int[] running) {
|
||||
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
final List<Object> points = getPoints();
|
||||
return new ArrayAdapter<Object>(ctx,
|
||||
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;
|
||||
final ArrayAdapter<Object> thisAdapter = this;
|
||||
boolean labelView = (getItem(position) instanceof Integer);
|
||||
if (position == 0) {
|
||||
v = createDrawerHeader(ctx, edit);
|
||||
} else if (getItem(position) instanceof RadiusItem) {
|
||||
final int type = ((RadiusItem) getItem(position)).type;
|
||||
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter);
|
||||
} else if (labelView) {
|
||||
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
||||
} else {
|
||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
}
|
||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), null);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
if (!edit) {
|
||||
remove.setVisibility(View.GONE);
|
||||
} else {
|
||||
remove.setVisibility(View.VISIBLE);
|
||||
((ImageButton) remove).setImageDrawable(ctx.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) {
|
||||
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
||||
remove(point);
|
||||
deletedPoints.add(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public ArrayAdapter<Object> getWaypointsAdapter(final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
||||
final FragmentActivity ctx, final int[] running,
|
||||
final AlertDialog[] srcDialog, final DialogFragment dialogFragment) {
|
||||
final List<Object> points = getPoints();
|
||||
return new ArrayAdapter<Object>(ctx,
|
||||
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;
|
||||
final ArrayAdapter<Object> thisAdapter = this;
|
||||
boolean labelView = (getItem(position) instanceof Integer);
|
||||
if (position == 0) {
|
||||
v = createDialogHeader(ctx, edit, false, srcDialog[0]);
|
||||
} else if (getItem(position) instanceof RadiusItem) {
|
||||
final int type = ((RadiusItem) getItem(position)).type;
|
||||
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter);
|
||||
} else if (labelView) {
|
||||
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
||||
} else {
|
||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
}
|
||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), dialogFragment);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
if (!edit) {
|
||||
remove.setVisibility(View.GONE);
|
||||
} else {
|
||||
remove.setVisibility(View.VISIBLE);
|
||||
((ImageButton) remove).setImageDrawable(ctx.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) {
|
||||
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
||||
remove(point);
|
||||
deletedPoints.add(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
protected View createDrawerHeader(final FragmentActivity ctx, final boolean editF) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_waypoint_header, null);
|
||||
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
if (mapActivity.getMyApplication().getSettings().isLightContent()){
|
||||
icon.setImageResource(R.drawable.ic_back_drawer_white);
|
||||
} else {
|
||||
icon.setImageResource(R.drawable.ic_back_drawer_dark);
|
||||
}
|
||||
|
||||
ImageView edit = (ImageView) v.findViewById(R.id.edit);
|
||||
ImageView sort = (ImageView) v.findViewById(R.id.sort);
|
||||
ImageView all = (ImageView) v.findViewById(R.id.all);
|
||||
edit.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_edit_light
|
||||
: R.drawable.ic_action_edit_dark);
|
||||
edit.setVisibility(editF ? View.GONE : View.VISIBLE);
|
||||
edit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMapActions().showWaypointsInDrawer(!editF);
|
||||
}
|
||||
});
|
||||
|
||||
if (app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
||||
sort.setVisibility(View.VISIBLE);
|
||||
sort.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_sort_waypoint_white
|
||||
: R.drawable.ic_sort_waypoint_dark);
|
||||
sort.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(app.getMapActivity(), app, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sort.setVisibility(View.GONE);
|
||||
}
|
||||
if (waypointHelper.isRouteCalculated()) {
|
||||
all.setVisibility(View.GONE);
|
||||
} else {
|
||||
all.setVisibility(View.VISIBLE);
|
||||
all.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_gup_light
|
||||
: R.drawable.ic_action_gup_dark);
|
||||
all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMapActions().showWaypointsInDrawer(editF);
|
||||
}
|
||||
});
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
protected View createDialogHeader(final FragmentActivity ctx, final boolean editF, final boolean flat, final AlertDialog dlg) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_title, null);
|
||||
ImageButton edit = (ImageButton) v.findViewById(R.id.edit);
|
||||
ImageButton sort = (ImageButton) v.findViewById(R.id.sort);
|
||||
ImageButton all = (ImageButton) v.findViewById(R.id.all);
|
||||
edit.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_edit_light
|
||||
: R.drawable.ic_action_edit_dark);
|
||||
edit.setVisibility(editF ? View.GONE : View.VISIBLE);
|
||||
edit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (flat) {
|
||||
showWaypointsDialogFlat(ctx, true);
|
||||
} else {
|
||||
showWaypointsDialog(ctx, true);
|
||||
}
|
||||
if (dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
||||
sort.setVisibility(View.VISIBLE);
|
||||
sort.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_sort_waypoint_white
|
||||
: R.drawable.ic_sort_waypoint_dark);
|
||||
sort.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(app.getMapActivity(), app, true);
|
||||
if (dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sort.setVisibility(View.GONE);
|
||||
}
|
||||
if (waypointHelper.isRouteCalculated()) {
|
||||
all.setVisibility(View.GONE);
|
||||
} else {
|
||||
all.setVisibility(View.VISIBLE);
|
||||
if (flat) {
|
||||
all.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_gdown_light
|
||||
: R.drawable.ic_action_gdown_dark);
|
||||
} else {
|
||||
all.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_gup_light
|
||||
: R.drawable.ic_action_gup_dark);
|
||||
}
|
||||
all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (flat) {
|
||||
showWaypointsDialog(ctx, editF);
|
||||
} else {
|
||||
showWaypointsDialogFlat(ctx, editF);
|
||||
}
|
||||
if (dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
|
||||
final int position, final ArrayAdapter<Object> thisAdapter) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null);
|
||||
final TextView radius = (TextView) v.findViewById(R.id.descr);
|
||||
((ImageView) v.findViewById(R.id.waypoint_icon)).setImageResource(
|
||||
app.getSettings().isLightContent() ? R.drawable.ic_poi_radius_white
|
||||
: R.drawable.ic_poi_radius_dark);
|
||||
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app));
|
||||
radius.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
selectDifferentRadius(type, running, position, thisAdapter, mapActivity);
|
||||
}
|
||||
|
||||
});
|
||||
return v;
|
||||
}
|
||||
|
||||
protected View createItemForCategory(final FragmentActivity ctx, final int type, final int[] running,
|
||||
final int position, final ArrayAdapter<Object> thisAdapter) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
|
||||
ImageView sort = (ImageView) v.findViewById(R.id.sort);
|
||||
//sort button in Destination header
|
||||
if (type == 0 && sort != null && app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sort.setVisibility(View.GONE);
|
||||
}
|
||||
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
||||
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(null);
|
||||
final boolean checked = waypointHelper.isTypeEnabled(type);
|
||||
btn.setChecked(checked);
|
||||
btn.setEnabled(running[0] == -1);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
running[0] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
if (type == WaypointHelper.POI && isChecked) {
|
||||
selectPoi(running, thisAdapter, type, isChecked, ctx);
|
||||
} else {
|
||||
enableType(running, thisAdapter, type, isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||
tv.setText(getHeader(type, checked, ctx));
|
||||
return v;
|
||||
}
|
||||
|
||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable, Activity ctx) {
|
||||
if (ctx instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
||||
MapActivity map = (MapActivity) ctx;
|
||||
final PoiFilter[] selected = new PoiFilter[1];
|
||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||
dlg.setOnDismissListener(new OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (selected != null) {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
|
||||
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
app.getWaypointHelper().enableWaypointType(type, enable);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
running[0] = -1;
|
||||
listAdapter.clear();
|
||||
for (Object point : getPoints()) {
|
||||
listAdapter.add(point);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}.execute((Void) null);
|
||||
}
|
||||
|
||||
public AdapterView.OnItemClickListener getDrawerItemClickListener(final FragmentActivity ctx,
|
||||
final int[] running,
|
||||
final ArrayAdapter<Object> listAdapter, final DialogFragment dialog) {
|
||||
return new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if (item == 0){
|
||||
mapActivity.getMapActions().prepareStartOptionsMenu();
|
||||
} else if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||
showOnMap(app, ctx, ps.getPoint(), dialog);
|
||||
} else if (new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
|
||||
} else if (listAdapter.getItem(item) instanceof RadiusItem) {
|
||||
selectDifferentRadius(((RadiusItem) listAdapter.getItem(item)).type, running, item, listAdapter, ctx);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void selectDifferentRadius(final int type, final int[] running, final int position,
|
||||
final ArrayAdapter<Object> thisAdapter, Activity ctx) {
|
||||
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(type)) {
|
||||
selected = i;
|
||||
}
|
||||
}
|
||||
new AlertDialog.Builder(ctx)
|
||||
.setSingleChoiceItems(names, selected, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i];
|
||||
if (waypointHelper.getSearchDeviationRadius(type) != value) {
|
||||
running[0] = position;
|
||||
waypointHelper.setSearchDeviationRadius(type, value);
|
||||
recalculatePoints(running, thisAdapter, type);
|
||||
dialogInterface.dismiss();
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
}).setTitle(app.getString(R.string.search_radius_proximity))
|
||||
.setNegativeButton(R.string.default_buttons_cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected String getHeader(int type, boolean checked, Activity ctx) {
|
||||
String str = ctx.getString(R.string.waypoints);
|
||||
switch (type) {
|
||||
case WaypointHelper.TARGETS:
|
||||
str = ctx.getString(R.string.targets);
|
||||
break;
|
||||
case WaypointHelper.ALARMS:
|
||||
str = ctx.getString(R.string.way_alarms);
|
||||
break;
|
||||
case WaypointHelper.FAVORITES:
|
||||
str = ctx.getString(R.string.my_favorites);
|
||||
break;
|
||||
case WaypointHelper.WAYPOINTS:
|
||||
str = ctx.getString(R.string.waypoints);
|
||||
break;
|
||||
case WaypointHelper.POI:
|
||||
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
||||
.getPoiFilter().getName();
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
protected List<Object> getPoints() {
|
||||
final List<Object> points = new ArrayList<Object>();
|
||||
boolean rc = waypointHelper.isRouteCalculated();
|
||||
points.add("");
|
||||
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
||||
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||
if (!rc && i != WaypointHelper.WAYPOINTS && i != WaypointHelper.TARGETS) {
|
||||
// skip
|
||||
} else if (waypointHelper.isTypeVisible(i)) {
|
||||
if (i != WaypointHelper.TARGETS) {
|
||||
points.add(new Integer(i));
|
||||
}
|
||||
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES || i == WaypointHelper.WAYPOINTS)
|
||||
&& rc) {
|
||||
if (waypointHelper.isTypeEnabled(i)) {
|
||||
points.add(new RadiusItem(i));
|
||||
}
|
||||
}
|
||||
if (tp != null && tp.size() > 0) {
|
||||
points.addAll(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
public static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
|
||||
if (!(a instanceof MapActivity)) {
|
||||
return;
|
||||
}
|
||||
MapActivity ctx = (MapActivity) a;
|
||||
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
||||
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
|
||||
boolean di = dialog != null;
|
||||
if (thread.isAnimating()) {
|
||||
ctx.getMapView().setIntZoom(fZoom);
|
||||
ctx.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
double t = 10;
|
||||
if (dist < t) {
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||
}
|
||||
if (di) {
|
||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||
ctx.getMapLayers()
|
||||
.getContextMenuLayer()
|
||||
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
|
||||
locationPoint.getName(ctx));
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WaypointDialogFragment extends DialogFragment {
|
||||
|
||||
WaypointHelper waypointHelper;
|
||||
private OsmandApplication app;
|
||||
|
@ -257,91 +742,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
return createWaypointsDialog(getArguments().getBoolean(EDIT_ARG));
|
||||
}
|
||||
|
||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable) {
|
||||
if (getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
||||
MapActivity map = (MapActivity) getActivity();
|
||||
final PoiFilter[] selected = new PoiFilter[1];
|
||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||
dlg.setOnDismissListener(new OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (selected != null) {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
final boolean enable) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
app.getWaypointHelper().enableWaypointType(type, enable);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
running[0] = -1;
|
||||
listAdapter.clear();
|
||||
for (Object point : getPoints()) {
|
||||
listAdapter.add(point);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}.execute((Void) null);
|
||||
}
|
||||
|
||||
protected String getHeader(int type, boolean checked) {
|
||||
FragmentActivity ctx = getActivity();
|
||||
String str = ctx.getString(R.string.waypoints);
|
||||
switch (type) {
|
||||
case WaypointHelper.TARGETS:
|
||||
str = ctx.getString(R.string.targets);
|
||||
break;
|
||||
case WaypointHelper.ALARMS:
|
||||
str = ctx.getString(R.string.way_alarms);
|
||||
break;
|
||||
case WaypointHelper.FAVORITES:
|
||||
str = ctx.getString(R.string.my_favorites);
|
||||
break;
|
||||
case WaypointHelper.WAYPOINTS:
|
||||
str = ctx.getString(R.string.waypoints);
|
||||
break;
|
||||
case WaypointHelper.POI:
|
||||
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
||||
.getPoiFilter().getName();
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points, final boolean edit) {
|
||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
final FragmentActivity ctx = getActivity();
|
||||
|
@ -353,7 +753,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
if(position == 0) {
|
||||
if (position == 0) {
|
||||
return createDialogHeader(ctx, edit, true, srcDialog[0]);
|
||||
}
|
||||
if (v == null || v.findViewById(R.id.waypoint_icon) == null) {
|
||||
|
@ -361,7 +761,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}
|
||||
updatePointInfoView(app, ctx, v, getItem(position), WaypointDialogFragment.this);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
if(!edit) {
|
||||
if (!edit) {
|
||||
remove.setVisibility(View.GONE);
|
||||
} else {
|
||||
remove.setVisibility(View.VISIBLE);
|
||||
|
@ -401,7 +801,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
||||
}
|
||||
});
|
||||
if(edit) {
|
||||
if (edit) {
|
||||
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||
}
|
||||
AlertDialog dlg = builder.create();
|
||||
|
@ -410,72 +810,28 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}
|
||||
|
||||
public AlertDialog createWaypointsDialog(final boolean edit) {
|
||||
final List<Object> points = getPoints();
|
||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
final FragmentActivity ctx = getActivity();
|
||||
final ListView listView = new ListView(ctx);
|
||||
final int[] running = new int[]{-1};
|
||||
final AlertDialog[] srcDialog = new AlertDialog[1];
|
||||
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(ctx,
|
||||
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;
|
||||
final ArrayAdapter<Object> thisAdapter = this;
|
||||
boolean labelView = (getItem(position) instanceof Integer);
|
||||
if(position == 0) {
|
||||
v = createDialogHeader(ctx, edit, false, srcDialog[0]);
|
||||
} else if (getItem(position) instanceof RadiusItem){
|
||||
final int type = ((RadiusItem) getItem(position)).type;
|
||||
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter);
|
||||
} else if (labelView) {
|
||||
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
||||
} else {
|
||||
if(v == null || v.findViewById(R.id.info_close) == null) {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
}
|
||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), WaypointDialogFragment.this);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
if (!edit) {
|
||||
remove.setVisibility(View.GONE);
|
||||
} else {
|
||||
remove.setVisibility(View.VISIBLE);
|
||||
((ImageButton) remove).setImageDrawable(ctx.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) {
|
||||
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
||||
remove(point);
|
||||
deletedPoints.add(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
final ArrayAdapter<Object> listAdapter = getWaypointsAdapter(edit, deletedPoints, ctx,
|
||||
running, srcDialog, WaypointDialogFragment.this);
|
||||
|
||||
listView.setAdapter(listAdapter);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
listView.setOnItemClickListener( new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
||||
} else if(new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(getActivity(), app, true);
|
||||
if(srcDialog[0] != null) {
|
||||
} else if (new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
|
||||
if (srcDialog[0] != null) {
|
||||
srcDialog[0].dismiss();
|
||||
}
|
||||
} else if(listAdapter.getItem(item) instanceof RadiusItem) {
|
||||
selectDifferentRadius(((RadiusItem) listAdapter.getItem(item)).type, running, item, listAdapter);
|
||||
} else if (listAdapter.getItem(item) instanceof RadiusItem) {
|
||||
selectDifferentRadius(((RadiusItem) listAdapter.getItem(item)).type, running, item, listAdapter, ctx);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -488,7 +844,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
||||
}
|
||||
});
|
||||
if(edit) {
|
||||
if (edit) {
|
||||
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||
}
|
||||
AlertDialog dlg = builder.create();
|
||||
|
@ -496,227 +852,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
return dlg;
|
||||
}
|
||||
|
||||
protected List<Object> getPoints() {
|
||||
final List<Object> points = new ArrayList<Object>();
|
||||
boolean rc = waypointHelper.isRouteCalculated();
|
||||
points.add("");
|
||||
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
||||
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||
if(!rc && i != WaypointHelper.WAYPOINTS && i != WaypointHelper.TARGETS) {
|
||||
// skip
|
||||
} else if (waypointHelper.isTypeVisible(i)) {
|
||||
if(i != WaypointHelper.TARGETS) {
|
||||
points.add(new Integer(i));
|
||||
}
|
||||
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES || i == WaypointHelper.WAYPOINTS)
|
||||
&& rc) {
|
||||
if (waypointHelper.isTypeEnabled(i)) {
|
||||
points.add(new RadiusItem(i));
|
||||
}
|
||||
}
|
||||
if (tp != null && tp.size() > 0) {
|
||||
points.addAll(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
protected View createDialogHeader(final FragmentActivity ctx, final boolean editF, final boolean flat, final AlertDialog dlg) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_title, null);
|
||||
ImageButton edit = (ImageButton) v.findViewById(R.id.edit);
|
||||
ImageButton sort = (ImageButton) v.findViewById(R.id.sort);
|
||||
ImageButton all = (ImageButton) v.findViewById(R.id.all);
|
||||
edit.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_edit_light
|
||||
: R.drawable.ic_action_edit_dark);
|
||||
edit.setVisibility(editF ? View.GONE : View.VISIBLE);
|
||||
edit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(flat) {
|
||||
showWaypointsDialogFlat(ctx, true);
|
||||
} else {
|
||||
showWaypointsDialog(ctx, true);
|
||||
}
|
||||
if(dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
||||
sort.setVisibility(View.VISIBLE);
|
||||
sort.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_sort_waypoint_white
|
||||
: R.drawable.ic_sort_waypoint_dark);
|
||||
sort.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(getActivity(), app, true);
|
||||
if(dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sort.setVisibility(View.GONE);
|
||||
}
|
||||
if(waypointHelper.isRouteCalculated()) {
|
||||
all.setVisibility(View.GONE);
|
||||
} else {
|
||||
all.setVisibility(View.VISIBLE);
|
||||
if(flat) {
|
||||
all.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_gdown_light
|
||||
: R.drawable.ic_action_gdown_dark);
|
||||
} else {
|
||||
all.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_action_gup_light
|
||||
: R.drawable.ic_action_gup_dark);
|
||||
}
|
||||
all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(flat) {
|
||||
showWaypointsDialog(ctx, editF);
|
||||
} else {
|
||||
showWaypointsDialogFlat(ctx, editF);
|
||||
}
|
||||
if(dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
protected void selectDifferentRadius(final int type, final int[] running, final int position,
|
||||
final ArrayAdapter<Object> thisAdapter) {
|
||||
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(type)){
|
||||
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(type) != value){
|
||||
running[0] = position;
|
||||
waypointHelper.setSearchDeviationRadius(type, value);
|
||||
recalculatePoints(running, thisAdapter, WaypointHelper.POI);
|
||||
dialogInterface.dismiss();
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
}).setTitle(app.getString(R.string.search_radius_proximity))
|
||||
.setNegativeButton(R.string.default_buttons_cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
|
||||
final int position, final ArrayAdapter<Object> thisAdapter) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null);
|
||||
final TextView radius = (TextView) v.findViewById(R.id.descr);
|
||||
((ImageView)v.findViewById(R.id.waypoint_icon)).setImageResource(
|
||||
app.getSettings().isLightContent() ? R.drawable.ic_poi_radius_white
|
||||
: R.drawable.ic_poi_radius_dark);
|
||||
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app));
|
||||
radius.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
selectDifferentRadius(type, running, position, thisAdapter);
|
||||
}
|
||||
|
||||
});
|
||||
return v;
|
||||
}
|
||||
|
||||
protected View createItemForCategory(final FragmentActivity ctx, final int type, final int[] running,
|
||||
final int position, final ArrayAdapter<Object> thisAdapter) {
|
||||
View v;
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
|
||||
ImageView sort = (ImageView) v.findViewById(R.id.sort);
|
||||
//sort button in Destination header
|
||||
if (type == 0 && sort != null && app.getTargetPointsHelper().getIntermediatePoints().size() > 0){
|
||||
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);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sort.setVisibility(View.GONE);
|
||||
}
|
||||
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
||||
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(null);
|
||||
final boolean checked = waypointHelper.isTypeEnabled(type);
|
||||
btn.setChecked(checked);
|
||||
btn.setEnabled(running[0] == -1);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
running[0] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
if (type == WaypointHelper.POI && isChecked) {
|
||||
selectPoi(running, thisAdapter, type, isChecked);
|
||||
} else {
|
||||
enableType(running, thisAdapter, type, isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||
tv.setText(getHeader(type, checked));
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
|
||||
if (!(a instanceof MapActivity)) {
|
||||
return;
|
||||
}
|
||||
MapActivity ctx = (MapActivity) a;
|
||||
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
||||
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
|
||||
boolean di = dialog != null;
|
||||
if (thread.isAnimating()) {
|
||||
ctx.getMapView().setIntZoom(fZoom);
|
||||
ctx.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
double t = 10;
|
||||
if (dist < t) {
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||
}
|
||||
if (di) {
|
||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||
ctx.getMapLayers()
|
||||
.getContextMenuLayer()
|
||||
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
|
||||
locationPoint.getName(ctx));
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -289,7 +289,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
recreateControls();
|
||||
}
|
||||
|
||||
public ContextMenuAdapter openViewConfigureDrawer() {
|
||||
public ContextMenuAdapter getViewConfigureMenuAdapter() {
|
||||
final OsmandSettings settings = view.getSettings();
|
||||
ContextMenuAdapter cm = new ContextMenuAdapter(view.getContext());
|
||||
cm.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||
|
@ -302,7 +302,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||
cm.item(R.string.map_widget_reset)
|
||||
.icons(R.drawable.widget_reset_to_default_dark, R.drawable.widget_reset_to_default_light).listen(new OnContextMenuClick() {
|
||||
|
||||
|
@ -324,8 +324,9 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
addControls(cm, mapInfoControls.getAppearanceWidgets(), mode);
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO add profiles
|
||||
// View confirmDialog = View.inflate(view.getContext(), R.layout.configuration_dialog, null);
|
||||
// AppModeDialog.prepareAppModeView(map, selected, true,
|
||||
|
|
|
@ -148,8 +148,8 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if(getTargets().checkPointToNavigateShort()) {
|
||||
hideDialog();
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(mapActivity);
|
||||
hideDialog();
|
||||
mapActivity.getMapActions().openIntermediatePointsDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
|