Added gpx card on route info
This commit is contained in:
parent
aeab7bc30b
commit
24fcf4bfa8
14 changed files with 326 additions and 87 deletions
101
OsmAnd/res/layout/gpx_route_card.xml
Normal file
101
OsmAnd/res/layout/gpx_route_card.xml
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/prev_route_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/card_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_list_top" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/card_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/route_info_button_go_margin">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/route_info_list_item_height"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gpx_card_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
tools:text="Tracks on the map - 10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/show_all_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/route_info_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginStart="@dimen/route_info_list_text_padding"
|
||||
android:layout_marginLeft="@dimen/route_info_list_text_padding"
|
||||
tools:background="?attr/dashboard_divider" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/show_all_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/route_info_list_text_padding"
|
||||
android:layout_marginLeft="@dimen/route_info_list_text_padding"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="SHOW ALL"
|
||||
tools:textColor="?attr/color_dialog_buttons"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bottom_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_list_bottom" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -14,6 +14,7 @@
|
|||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/prev_route_card_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
|
|
|
@ -279,6 +279,7 @@
|
|||
<dimen name="route_info_app_modes_padding">40dp</dimen>
|
||||
<dimen name="route_info_card_row_min_height">60dp</dimen>
|
||||
<dimen name="route_info_card_item_height">56dp</dimen>
|
||||
<dimen name="route_info_list_text_padding">54dp</dimen>
|
||||
|
||||
<dimen name="multi_selection_header_height">52dp</dimen>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||
Thx - Hardy
|
||||
-->
|
||||
<string name="tracks_on_map">Tracks on the map</string>
|
||||
<string name="add_destination_query">Please add Destination first</string>
|
||||
<string name="previous_route">Previous route</string>
|
||||
<string name="add_home">Add home</string>
|
||||
|
|
|
@ -458,62 +458,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public void enterRoutePlanningMode(final LatLon from, final PointDescription fromName) {
|
||||
final boolean useIntermediatePointsByDefault = true;
|
||||
List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper()
|
||||
.getSelectedGPXFiles();
|
||||
final List<GPXFile> gpxFiles = new ArrayList<>();
|
||||
for (SelectedGpxFile gs : selectedGPXFiles) {
|
||||
if (!gs.isShowCurrentTrack() && !gs.notShowNavigationDialog) {
|
||||
if (gs.getGpxFile().hasRtePt() || gs.getGpxFile().hasTrkPt()) {
|
||||
gpxFiles.add(gs.getGpxFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gpxFiles.size() > 0) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
|
||||
if (gpxFiles.size() == 1) {
|
||||
bld.setMessage(R.string.use_displayed_track_for_navigation);
|
||||
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName, useIntermediatePointsByDefault, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bld.setTitle(R.string.navigation_over_track);
|
||||
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity, R.layout.drawer_list_item, gpxFiles) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
|
||||
}
|
||||
String path = getItem(position).path;
|
||||
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
|
||||
((TextView) convertView.findViewById(R.id.title)).setText(name);
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.toggle_item).setVisibility(View.GONE);
|
||||
return convertView;
|
||||
}
|
||||
};
|
||||
bld.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName, useIntermediatePointsByDefault, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
} else {
|
||||
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
|
||||
}
|
||||
enterRoutePlanningModeGivenGpx(null, from, fromName, true, true);
|
||||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||
|
|
|
@ -273,12 +273,8 @@ public class GpxUiHelper {
|
|||
//element position in adapter
|
||||
int i = 0;
|
||||
for (GPXInfo gpxInfo : allGpxList) {
|
||||
String s = gpxInfo.getFileName();
|
||||
String fileName = s;
|
||||
if (s.endsWith(".gpx")) {
|
||||
s = s.substring(0, s.length() - ".gpx".length());
|
||||
}
|
||||
s = s.replace('_', ' ');
|
||||
String fileName = gpxInfo.getFileName();
|
||||
String s = getGpxTitle(fileName);
|
||||
|
||||
adapter.addItem(ContextMenuItem.createBuilder(s).setSelected(false)
|
||||
.setIcon(R.drawable.ic_action_polygom_dark).createItem());
|
||||
|
@ -292,6 +288,15 @@ public class GpxUiHelper {
|
|||
return adapter;
|
||||
}
|
||||
|
||||
public static String getGpxTitle(String fileName) {
|
||||
String s = fileName;
|
||||
if (s.toLowerCase().endsWith(".gpx")) {
|
||||
s = s.substring(0, s.length() - ".gpx".length());
|
||||
}
|
||||
s = s.replace('_', ' ');
|
||||
return s;
|
||||
}
|
||||
|
||||
protected static void updateSelection(List<String> selectedGpxList, boolean showCurrentTrack,
|
||||
final ContextMenuAdapter adapter, int position, String fileName) {
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
|
@ -472,7 +477,7 @@ public class GpxUiHelper {
|
|||
|
||||
final ContextMenuItem item = adapter.getItem(position);
|
||||
GPXInfo info = list.get(position);
|
||||
updateGpxInfoView(v, item, info, getDataItem(info), showCurrentGpx && position == 0, app);
|
||||
updateGpxInfoView(v, item.getTitle(), info, getDataItem(info), showCurrentGpx && position == 0, app);
|
||||
|
||||
if (item.getSelected() == null) {
|
||||
v.findViewById(R.id.check_item).setVisibility(View.GONE);
|
||||
|
@ -710,9 +715,9 @@ public class GpxUiHelper {
|
|||
return dlg;
|
||||
}
|
||||
|
||||
public static void updateGpxInfoView(View v, ContextMenuItem item, GPXInfo info, GpxDataItem dataItem, boolean currentlyRecordingTrack, OsmandApplication app) {
|
||||
public static void updateGpxInfoView(View v, String itemTitle, GPXInfo info, GpxDataItem dataItem, boolean currentlyRecordingTrack, OsmandApplication app) {
|
||||
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
||||
viewName.setText(item.getTitle().replace("/", " • ").trim());
|
||||
viewName.setText(itemTitle.replace("/", " • ").trim());
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setVisibility(View.GONE);
|
||||
//icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
|
@ -1908,7 +1913,7 @@ public class GpxUiHelper {
|
|||
private long fileSize;
|
||||
private boolean selected;
|
||||
|
||||
GPXInfo(String fileName, long lastModified, long fileSize) {
|
||||
public GPXInfo(String fileName, long lastModified, long fileSize) {
|
||||
this.fileName = fileName;
|
||||
this.lastModified = lastModified;
|
||||
this.fileSize = fileSize;
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.text.style.ForegroundColorSpan;
|
|||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -99,16 +100,20 @@ public class ImportHelper {
|
|||
}
|
||||
|
||||
public boolean handleGpxImport(final Uri contentUri, final boolean useImportDir) {
|
||||
final String name = getNameFromContentUri(contentUri);
|
||||
final boolean isOsmandSubdir = isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(contentUri.getPath()));
|
||||
String name = getNameFromContentUri(contentUri);
|
||||
boolean isOsmandSubdir = isSubDirectory(app.getAppPath(IndexConstants.GPX_INDEX_DIR), new File(contentUri.getPath()));
|
||||
if (!isOsmandSubdir && name != null) {
|
||||
if (name.endsWith(GPX_SUFFIX)) {
|
||||
String nameLC = name.toLowerCase();
|
||||
if (nameLC.endsWith(GPX_SUFFIX)) {
|
||||
name = name.substring(0, name.length() - 4) + GPX_SUFFIX;
|
||||
handleGpxImport(contentUri, name, true, useImportDir);
|
||||
return true;
|
||||
} else if (name.endsWith(KML_SUFFIX)) {
|
||||
} else if (nameLC.endsWith(KML_SUFFIX)) {
|
||||
name = name.substring(0, name.length() - 4) + KML_SUFFIX;
|
||||
handleKmlImport(contentUri, name, true, useImportDir);
|
||||
return true;
|
||||
} else if (name.endsWith(KMZ_SUFFIX)) {
|
||||
} else if (nameLC.endsWith(KMZ_SUFFIX)) {
|
||||
name = name.substring(0, name.length() - 4) + KMZ_SUFFIX;
|
||||
handleKmzImport(contentUri, name, true, useImportDir);
|
||||
return true;
|
||||
}
|
||||
|
@ -609,11 +614,12 @@ public class ImportHelper {
|
|||
//noinspection ResultOfMethodCallIgnored
|
||||
importDir.mkdirs();
|
||||
if (importDir.exists() && importDir.isDirectory() && importDir.canWrite()) {
|
||||
final GPXUtilities.WptPt pt = gpxFile.findPointToShow();
|
||||
final WptPt pt = gpxFile.findPointToShow();
|
||||
final File toWrite = getFileToSave(fileName, importDir, pt);
|
||||
Exception e = GPXUtilities.writeGpxFile(toWrite, gpxFile);
|
||||
if(e == null) {
|
||||
gpxFile.path = toWrite.getAbsolutePath();
|
||||
app.getGpxDatabase().remove(new File(gpxFile.path));
|
||||
warning = null;
|
||||
} else {
|
||||
warning = app.getString(R.string.error_reading_gpx);
|
||||
|
@ -626,7 +632,7 @@ public class ImportHelper {
|
|||
return warning;
|
||||
}
|
||||
|
||||
private File getFileToSave(final String fileName, final File importDir, final GPXUtilities.WptPt pt) {
|
||||
private File getFileToSave(final String fileName, final File importDir, final WptPt pt) {
|
||||
final StringBuilder builder = new StringBuilder(fileName);
|
||||
if ("".equals(fileName)) {
|
||||
builder.append("import_").append(new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time))).append(GPX_SUFFIX); //$NON-NLS-1$
|
||||
|
@ -678,7 +684,7 @@ public class ImportHelper {
|
|||
private void showGpxOnMap(final GPXFile result) {
|
||||
if (mapView != null && getMapActivity() != null) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||
final GPXUtilities.WptPt moveTo = result.findPointToShow();
|
||||
final WptPt moveTo = result.findPointToShow();
|
||||
if (moveTo != null) {
|
||||
mapView.getAnimatedDraggingThread().startMoving(moveTo.lat, moveTo.lon, mapView.getZoom(), true);
|
||||
}
|
||||
|
@ -736,9 +742,9 @@ public class ImportHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private List<FavouritePoint> asFavourites(final List<GPXUtilities.WptPt> wptPts, String fileName, boolean forceImportFavourites) {
|
||||
private List<FavouritePoint> asFavourites(final List<WptPt> wptPts, String fileName, boolean forceImportFavourites) {
|
||||
final List<FavouritePoint> favourites = new ArrayList<>();
|
||||
for (GPXUtilities.WptPt p : wptPts) {
|
||||
for (WptPt p : wptPts) {
|
||||
if (p.name != null) {
|
||||
final String fpCat;
|
||||
if (p.category == null) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.ValueHolder;
|
||||
|
@ -31,6 +31,7 @@ import net.osmand.data.RotatedTileBox;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GeocodingLookupService;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -49,10 +50,12 @@ import net.osmand.plus.helpers.WaypointHelper;
|
|||
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||
import net.osmand.plus.routepreparationmenu.cards.HomeWorkCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.PreviousRouteCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.SimpleRouteCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.TracksCard;
|
||||
import net.osmand.plus.routing.IRouteInformationListener;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.TransportRoutingHelper;
|
||||
|
@ -72,7 +75,7 @@ import java.util.Set;
|
|||
|
||||
import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE;
|
||||
|
||||
public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener {
|
||||
|
||||
public static class MenuState {
|
||||
public static final int HEADER_ONLY = 1;
|
||||
|
@ -334,6 +337,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
fragmentRef.get().updateInfo();
|
||||
}
|
||||
|
||||
public void updateLayout() {
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null)
|
||||
fragmentRef.get().updateLayout();
|
||||
}
|
||||
|
||||
public void updateFromIcon() {
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null)
|
||||
|
@ -362,7 +371,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
menuCards.clear();
|
||||
|
||||
if (isBasicRouteCalculated()) {
|
||||
GPXUtilities.GPXFile gpx = GpxUiHelper.makeGpxFromRoute(routingHelper.getRoute(), mapActivity.getMyApplication());
|
||||
GPXFile gpx = GpxUiHelper.makeGpxFromRoute(routingHelper.getRoute(), mapActivity.getMyApplication());
|
||||
if (gpx != null) {
|
||||
menuCards.add(new SimpleRouteCard(mapActivity, gpx));
|
||||
}
|
||||
|
@ -388,6 +397,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
PreviousRouteCard previousRouteCard = new PreviousRouteCard(mapActivity);
|
||||
menuCards.add(previousRouteCard);
|
||||
}
|
||||
|
||||
List<SelectedGpxFile> selectedGPXFiles =
|
||||
mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
final List<GPXFile> gpxFiles = new ArrayList<>();
|
||||
for (SelectedGpxFile gs : selectedGPXFiles) {
|
||||
if (!gs.isShowCurrentTrack()) {
|
||||
if (gs.getGpxFile().hasRtePt() || gs.getGpxFile().hasTrkPt()) {
|
||||
gpxFiles.add(gs.getGpxFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gpxFiles.size() > 0) {
|
||||
TracksCard tracksCard = new TracksCard(mapActivity, gpxFiles);
|
||||
tracksCard.setListener(this);
|
||||
menuCards.add(tracksCard);
|
||||
}
|
||||
}
|
||||
setupCards();
|
||||
}
|
||||
|
@ -397,6 +422,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
build(cardsContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCardLayoutNeeded() {
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
public boolean isRouteCalculated() {
|
||||
return isBasicRouteCalculated() || isTransportRouteCalculated();
|
||||
}
|
||||
|
@ -1391,6 +1421,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
visible = false;
|
||||
}
|
||||
routingHelper.removeListener(this);
|
||||
removeTargetPointListener();
|
||||
}
|
||||
|
||||
public void setShowMenu() {
|
||||
|
|
|
@ -786,6 +786,12 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateLayout() {
|
||||
if (menu != null) {
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFromIcon() {
|
||||
if (menu != null) {
|
||||
menu.updateFromIcon(mainView);
|
||||
|
|
|
@ -24,6 +24,12 @@ public abstract class BaseCard {
|
|||
boolean showBottomShadow;
|
||||
protected boolean nightMode;
|
||||
|
||||
private CardListener listener;
|
||||
|
||||
public interface CardListener {
|
||||
void onCardLayoutNeeded();
|
||||
}
|
||||
|
||||
public BaseCard(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
|
@ -39,6 +45,21 @@ public abstract class BaseCard {
|
|||
}
|
||||
}
|
||||
|
||||
public CardListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
public void setListener(CardListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setLayoutNeeded() {
|
||||
CardListener listener = this.listener;
|
||||
if (listener != null) {
|
||||
listener.onCardLayoutNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void updateContent();
|
||||
|
||||
public View build(Context ctx) {
|
||||
|
|
|
@ -71,6 +71,7 @@ public class PreviousRouteCard extends BaseCard {
|
|||
|
||||
@Override
|
||||
protected void applyDayNightMode() {
|
||||
AndroidUtils.setTextSecondaryColor(app, (TextView) view.findViewById(R.id.prev_route_card_title), nightMode);
|
||||
AndroidUtils.setTextSecondaryColor(app, (TextView) view.findViewById(R.id.start_title), nightMode);
|
||||
AndroidUtils.setTextPrimaryColor(app, (TextView) view.findViewById(R.id.destination_title), nightMode);
|
||||
Drawable img = app.getUIUtilities().getIcon(R.drawable.ic_action_previous_route, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||
|
|
|
@ -1,25 +1,148 @@
|
|||
package net.osmand.plus.routepreparationmenu.cards;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class TracksCard extends BaseCard {
|
||||
|
||||
public TracksCard(MapActivity mapActivity) {
|
||||
private List<GPXFile> gpxFiles;
|
||||
private boolean showLimited = true;
|
||||
private List<GpxDataItem> dataItems;
|
||||
|
||||
private static class GpxItem {
|
||||
String title;
|
||||
GPXFile file;
|
||||
GPXInfo info;
|
||||
|
||||
GpxItem(String title, GPXFile file, GPXInfo info) {
|
||||
this.title = title;
|
||||
this.file = file;
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
|
||||
public TracksCard(MapActivity mapActivity, List<GPXFile> gpxFiles) {
|
||||
super(mapActivity);
|
||||
this.gpxFiles = gpxFiles;
|
||||
this.dataItems = app.getGpxDatabase().getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardLayoutId() {
|
||||
return 0;
|
||||
return R.layout.gpx_route_card;
|
||||
}
|
||||
|
||||
|
||||
private GpxDataItem getDataItem(GPXInfo info) {
|
||||
for (GpxDataItem item : dataItems) {
|
||||
if (item.getFile().getAbsolutePath().endsWith(info.getFileName())) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
protected void updateContent() {
|
||||
final List<GpxItem> list = new ArrayList<>();
|
||||
for (GPXFile gpx : gpxFiles) {
|
||||
File f = new File(gpx.path);
|
||||
list.add(new GpxItem(GpxUiHelper.getGpxTitle(f.getName()), gpx, new GPXInfo(f.getName(), f.lastModified(), f.length())));
|
||||
}
|
||||
Collections.sort(list, new Comparator<GpxItem>() {
|
||||
@Override
|
||||
public int compare(GpxItem i1, GpxItem i2) {
|
||||
return i1.title.toLowerCase().compareTo(i2.title.toLowerCase());
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout tracks = (LinearLayout) view.findViewById(R.id.items);
|
||||
tracks.removeAllViews();
|
||||
|
||||
int minCardHeight = app.getResources().getDimensionPixelSize(R.dimen.route_info_card_item_height);
|
||||
int listContentPadding = app.getResources().getDimensionPixelSize(R.dimen.list_content_padding);
|
||||
int listTextPadding = app.getResources().getDimensionPixelSize(R.dimen.route_info_list_text_padding);
|
||||
|
||||
int i = 0;
|
||||
boolean showLimitExceeds = list.size() > 4;
|
||||
LayoutInflater inflater = mapActivity.getLayoutInflater();
|
||||
for (final GpxItem item : list) {
|
||||
if (showLimitExceeds && i >= 3 && showLimited) {
|
||||
break;
|
||||
}
|
||||
View v = inflater.inflate(R.layout.gpx_track_item, tracks, false);
|
||||
GpxUiHelper.updateGpxInfoView(v, item.title, item.info, getDataItem(item.info), false, app);
|
||||
|
||||
View div = v.findViewById(R.id.divider);
|
||||
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(div.getLayoutParams().width, div.getLayoutParams().height);
|
||||
p.setMargins(listTextPadding, 0, 0, 0);
|
||||
div.setLayoutParams(p);
|
||||
div.setVisibility(i == 0 ? View.GONE : View.VISIBLE);
|
||||
|
||||
ImageView img = (ImageView) v.findViewById(R.id.icon);
|
||||
img.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_polygom_dark, R.color.color_distance));
|
||||
img.setVisibility(View.VISIBLE);
|
||||
LinearLayout container = (LinearLayout) v.findViewById(R.id.container);
|
||||
container.setMinimumHeight(minCardHeight);
|
||||
container.setPadding(listContentPadding, 0, 0, 0);
|
||||
v.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMapActions().setGPXRouteParams(item.file);
|
||||
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
});
|
||||
tracks.addView(v);
|
||||
i++;
|
||||
}
|
||||
|
||||
View showAllButton = view.findViewById(R.id.show_all_button);
|
||||
if (showLimited && showLimitExceeds) {
|
||||
((TextView) view.findViewById(R.id.show_all_title)).setText(
|
||||
String.format("%s — %d", app.getString(R.string.shared_string_show_all).toUpperCase(), list.size()));
|
||||
showAllButton.setVisibility(View.VISIBLE);
|
||||
showAllButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showLimited = false;
|
||||
updateContent();
|
||||
setLayoutNeeded();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showAllButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
((TextView) view.findViewById(R.id.gpx_card_title)).setText(
|
||||
String.format("%s — %d", app.getString(R.string.tracks_on_map), list.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyDayNightMode() {
|
||||
|
||||
AndroidUtils.setTextSecondaryColor(app, (TextView) view.findViewById(R.id.gpx_card_title), nightMode);
|
||||
((TextView) view.findViewById(R.id.show_all_title)).setTextColor(mapActivity.getResources().getColor(
|
||||
nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light));
|
||||
AndroidUtils.setBackground(app, view.findViewById(R.id.card_content), nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
|
||||
AndroidUtils.setBackground(app, view.findViewById(R.id.divider), nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
|
||||
AndroidUtils.setBackground(app, view.findViewById(R.id.divider_list), nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,7 @@ import android.support.v4.view.ViewPropertyAnimatorListener;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
@ -56,7 +54,6 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
|||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
|
||||
|
@ -416,7 +413,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||
if (!hasTargets) {
|
||||
//getTargets().restoreTargetPoints(false);
|
||||
if (getTargets().getPointToNavigate() == null) {
|
||||
mapActivity.getMapActions().setFirstMapMarkerAsTarget();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue