From 24fcf4bfa83078073f105f65b764f692cb66678b Mon Sep 17 00:00:00 2001 From: crimean Date: Wed, 20 Feb 2019 21:34:04 +0300 Subject: [PATCH] Added gpx card on route info --- OsmAnd/res/layout/gpx_route_card.xml | 101 ++++++++++++++ OsmAnd/res/layout/gpx_track_item.xml | 1 + OsmAnd/res/layout/prev_route_card.xml | 1 + OsmAnd/res/values/sizes.xml | 1 + OsmAnd/res/values/strings.xml | 1 + .../plus/activities/MapActivityActions.java | 57 +------- .../net/osmand/plus/helpers/GpxUiHelper.java | 25 ++-- .../net/osmand/plus/helpers/ImportHelper.java | 26 ++-- .../MapRouteInfoMenu.java | 37 ++++- .../MapRouteInfoMenuFragment.java | 6 + .../routepreparationmenu/cards/BaseCard.java | 21 +++ .../cards/PreviousRouteCard.java | 1 + .../cards/TracksCard.java | 131 +++++++++++++++++- .../osmand/plus/views/MapControlsLayer.java | 4 - 14 files changed, 326 insertions(+), 87 deletions(-) create mode 100644 OsmAnd/res/layout/gpx_route_card.xml diff --git a/OsmAnd/res/layout/gpx_route_card.xml b/OsmAnd/res/layout/gpx_route_card.xml new file mode 100644 index 0000000000..82e8703ff3 --- /dev/null +++ b/OsmAnd/res/layout/gpx_route_card.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/gpx_track_item.xml b/OsmAnd/res/layout/gpx_track_item.xml index a62f652a8d..3740707fbe 100644 --- a/OsmAnd/res/layout/gpx_track_item.xml +++ b/OsmAnd/res/layout/gpx_track_item.xml @@ -14,6 +14,7 @@ android:visibility="gone"/> 40dp 60dp 56dp + 54dp 52dp diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 85c60ca52e..bad5196f87 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -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 --> + Tracks on the map Please add Destination first Previous route Add home diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 6689780f33..4f4afcfe9e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -458,62 +458,7 @@ public class MapActivityActions implements DialogProvider { } public void enterRoutePlanningMode(final LatLon from, final PointDescription fromName) { - final boolean useIntermediatePointsByDefault = true; - List selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper() - .getSelectedGPXFiles(); - final List 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 adapter = new ArrayAdapter(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, diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 2644a92b74..84b93a5c12 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -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 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; diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index 0b32543b01..88b20d870c 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -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 asFavourites(final List wptPts, String fileName, boolean forceImportFavourites) { + private List asFavourites(final List wptPts, String fileName, boolean forceImportFavourites) { final List favourites = new ArrayList<>(); - for (GPXUtilities.WptPt p : wptPts) { + for (WptPt p : wptPts) { if (p.name != null) { final String fpCat; if (p.category == null) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index f955bd1bff..128d4035b2 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -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 fragmentRef = findMenuFragment(); + if (fragmentRef != null) + fragmentRef.get().updateLayout(); + } + public void updateFromIcon() { WeakReference 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 selectedGPXFiles = + mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles(); + final List 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() { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index 92b488be32..30dffe5e04 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java index a852bd2c9d..98f69ade97 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/BaseCard.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java index c6ee95bd4f..6097424b81 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index ca26831101..7b39384bfd 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -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 gpxFiles; + private boolean showLimited = true; + private List 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 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 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() { + @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); } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 4279043bfb..5719bc7043 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -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(); }