add visible gpx track to search history
This commit is contained in:
parent
0d29c84a6e
commit
a4e7edc6bd
13 changed files with 341 additions and 16 deletions
|
@ -8,7 +8,7 @@ public enum ObjectType {
|
|||
// LOCATION
|
||||
LOCATION(true), PARTIAL_LOCATION(false),
|
||||
// UI OBJECTS
|
||||
FAVORITE(true), FAVORITE_GROUP(false), WPT(true), RECENT_OBJ(true),
|
||||
FAVORITE(true), FAVORITE_GROUP(false), WPT(true), RECENT_OBJ(true), GPX_TRACK(false),
|
||||
|
||||
// ONLINE SEARCH
|
||||
ONLINE_SEARCH(true),
|
||||
|
|
166
OsmAnd/res/layout/search_gpx_list_item.xml
Normal file
166
OsmAnd/res/layout/search_gpx_list_item.xml
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/searchListItemLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/dialog_button_ex_height"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="@dimen/content_padding_half"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckBox
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/title_padding"
|
||||
android:focusable="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:layout_marginEnd="@dimen/title_padding" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
osmand:srcCompat="@drawable/ic_action_polygom_dark"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:visibility="visible"
|
||||
android:layout_marginEnd="@dimen/list_content_padding" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/name_and_read_section_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/gpx_text_top_margin"
|
||||
android:paddingBottom="@dimen/gpx_text_top_margin"
|
||||
android:layout_marginRight="@dimen/showAllButtonMarginRight"
|
||||
android:layout_marginEnd="@dimen/showAllButtonMarginRight"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="@string/current_track"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/read_section"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/distance_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/gpx_small_icon_margin"
|
||||
android:layout_marginEnd="@dimen/gpx_small_icon_margin"
|
||||
osmand:srcCompat="@drawable/ic_action_distance_16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/gpx_small_text_margin"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:layout_marginEnd="@dimen/gpx_small_text_margin" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/points_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/gpx_small_icon_margin"
|
||||
android:layout_marginEnd="@dimen/gpx_small_icon_margin"
|
||||
osmand:srcCompat="@drawable/ic_action_waypoint_16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/points_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/gpx_small_text_margin"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:layout_marginEnd="@dimen/gpx_small_text_margin" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/time_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/gpx_small_icon_margin"
|
||||
android:layout_marginEnd="@dimen/gpx_small_icon_margin"
|
||||
osmand:srcCompat="@drawable/ic_action_time_16" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/gpx_small_text_margin"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:includeFontPadding="false"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:layout_marginEnd="@dimen/gpx_small_text_margin" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/unknown_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date_and_size_details"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/default_sub_text_size" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -47,6 +47,7 @@ public class PointDescription {
|
|||
public static final String POINT_TYPE_OSM_BUG = "bug";
|
||||
public static final String POINT_TYPE_WORLD_REGION = "world_region";
|
||||
public static final String POINT_TYPE_GPX_ITEM = "gpx_item";
|
||||
public static final String POINT_TYPE_GPX_FILE = "gpx_file";
|
||||
public static final String POINT_TYPE_WORLD_REGION_SHOW_ON_MAP = "world_region_show_on_map";
|
||||
public static final String POINT_TYPE_BLOCKED_ROAD = "blocked_road";
|
||||
public static final String POINT_TYPE_TRANSPORT_ROUTE = "transport_route";
|
||||
|
@ -297,6 +298,10 @@ public class PointDescription {
|
|||
return POINT_TYPE_GPX.equals(type);
|
||||
}
|
||||
|
||||
public boolean isGpxFile() {
|
||||
return POINT_TYPE_GPX_FILE.equals(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.osmand.plus.activities.SavingTrackHelper;
|
|||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersHelper;
|
||||
|
@ -581,7 +582,7 @@ public class GpxSelectionHelper {
|
|||
} else if (obj.has(BACKUP)) {
|
||||
selectedGpxFilesBackUp.put(gpx, gpx.modifiedTime);
|
||||
} else {
|
||||
SelectedGpxFile file = selectGpxFile(gpx, true, false, true, selectedByUser, false);
|
||||
SelectedGpxFile file = selectGpxFile(gpx, true, false, true, selectedByUser, false, false);
|
||||
if (obj.has(HIDDEN_GROUPS)) {
|
||||
readHiddenGroups(file, obj.getString(HIDDEN_GROUPS));
|
||||
}
|
||||
|
@ -684,7 +685,13 @@ public class GpxSelectionHelper {
|
|||
app.getSettings().SELECTED_GPX.set(ar.toString());
|
||||
}
|
||||
|
||||
private SelectedGpxFile selectGpxFileImpl(GPXFile gpx, GpxDataItem dataItem, boolean show, boolean notShowNavigationDialog, boolean syncGroup, boolean selectedByUser) {
|
||||
private SelectedGpxFile selectGpxFileImpl(GPXFile gpx,
|
||||
GpxDataItem dataItem,
|
||||
boolean show,
|
||||
boolean notShowNavigationDialog,
|
||||
boolean syncGroup,
|
||||
boolean selectedByUser,
|
||||
boolean addToHistory) {
|
||||
boolean displayed;
|
||||
SelectedGpxFile sf;
|
||||
if (gpx != null && gpx.showCurrentTrack) {
|
||||
|
@ -724,6 +731,12 @@ public class GpxSelectionHelper {
|
|||
if (sf != null) {
|
||||
sf.splitProcessed = false;
|
||||
}
|
||||
if (show && selectedByUser && addToHistory) {
|
||||
String path = gpx.path;
|
||||
String rootGpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath() + '/';
|
||||
String fileName = path.replace(rootGpxDir, "");
|
||||
SearchHistoryHelper.getInstance(app).addGpxFileToHistory(fileName);
|
||||
}
|
||||
return sf;
|
||||
}
|
||||
|
||||
|
@ -749,18 +762,39 @@ public class GpxSelectionHelper {
|
|||
return selectGpxFile(gpx, show, notShowNavigationDialog, true, true, true);
|
||||
}
|
||||
|
||||
public SelectedGpxFile selectGpxFile(GPXFile gpx, GpxDataItem dataItem, boolean show, boolean notShowNavigationDialog, boolean syncGroup, boolean selectedByUser) {
|
||||
SelectedGpxFile sf = selectGpxFileImpl(gpx, dataItem, show, notShowNavigationDialog, syncGroup, selectedByUser);
|
||||
public SelectedGpxFile selectGpxFile(GPXFile gpx,
|
||||
GpxDataItem dataItem,
|
||||
boolean show,
|
||||
boolean notShowNavigationDialog,
|
||||
boolean syncGroup,
|
||||
boolean selectedByUser,
|
||||
boolean addToHistory) {
|
||||
SelectedGpxFile sf = selectGpxFileImpl(gpx, dataItem, show, notShowNavigationDialog, syncGroup, selectedByUser, addToHistory);
|
||||
saveCurrentSelections();
|
||||
return sf;
|
||||
}
|
||||
|
||||
public SelectedGpxFile selectGpxFile(GPXFile gpx, boolean show, boolean notShowNavigationDialog, boolean syncGroup, boolean selectedByUser, boolean canAddToMarkers) {
|
||||
public SelectedGpxFile selectGpxFile(GPXFile gpx,
|
||||
boolean show,
|
||||
boolean notShowNavigationDialog,
|
||||
boolean syncGroup,
|
||||
boolean selectedByUser,
|
||||
boolean canAddToMarkers) {
|
||||
return selectGpxFile(gpx, show, notShowNavigationDialog, syncGroup, selectedByUser, canAddToMarkers, true);
|
||||
}
|
||||
|
||||
public SelectedGpxFile selectGpxFile(GPXFile gpx,
|
||||
boolean show,
|
||||
boolean notShowNavigationDialog,
|
||||
boolean syncGroup,
|
||||
boolean selectedByUser,
|
||||
boolean canAddToMarkers,
|
||||
boolean addToHistory) {
|
||||
GpxDataItem dataItem = app.getGpxDbHelper().getItem(new File(gpx.path));
|
||||
if (canAddToMarkers && show && dataItem != null && dataItem.isShowAsMarkers()) {
|
||||
app.getMapMarkersHelper().addOrEnableGroup(gpx);
|
||||
}
|
||||
return selectGpxFile(gpx, dataItem, show, notShowNavigationDialog, syncGroup, selectedByUser);
|
||||
return selectGpxFile(gpx, dataItem, show, notShowNavigationDialog, syncGroup, selectedByUser, addToHistory);
|
||||
}
|
||||
|
||||
public void clearPoints(GPXFile gpxFile) {
|
||||
|
|
|
@ -93,7 +93,6 @@ import net.osmand.plus.activities.ActivityResultListener;
|
|||
import net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.PluginsFragment;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||
|
@ -751,13 +750,32 @@ public class GpxUiHelper {
|
|||
gpxDbHelper.updateShowStartFinish(item, showStartFinish);
|
||||
}
|
||||
|
||||
public static void updateGpxInfoView(View v, String itemTitle, GPXInfo info, GpxDataItem dataItem, boolean currentlyRecordingTrack, OsmandApplication app) {
|
||||
public static void updateGpxInfoView(OsmandApplication app,
|
||||
View v,
|
||||
String itemTitle,
|
||||
Drawable iconDrawable,
|
||||
GPXInfo info) {
|
||||
GpxDataItem dataItem = getDataItem(app, info);
|
||||
updateGpxInfoView(v, itemTitle, info, dataItem, false, app);
|
||||
if (iconDrawable != null) {
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setImageDrawable(iconDrawable);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
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(itemTitle.replace("/", " • ").trim());
|
||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setVisibility(View.GONE);
|
||||
//icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||
|
||||
GPXTrackAnalysis analysis = null;
|
||||
if (currentlyRecordingTrack) {
|
||||
|
@ -809,9 +827,19 @@ public class GpxUiHelper {
|
|||
}
|
||||
|
||||
TextView descr = ((TextView) v.findViewById(R.id.description));
|
||||
descr.setVisibility(View.GONE);
|
||||
if (descr != null) {
|
||||
descr.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
v.findViewById(R.id.check_item).setVisibility(View.GONE);
|
||||
View checkbox = v.findViewById(R.id.check_item);
|
||||
if (checkbox != null) {
|
||||
checkbox.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private static GpxDataItem getDataItem(OsmandApplication app, GPXInfo info) {
|
||||
return app.getGpxDbHelper().getItem(
|
||||
new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), info.getFileName()));
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
|
@ -884,6 +912,17 @@ public class GpxUiHelper {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GPXInfo getGpxInfoByFileName(@NonNull OsmandApplication app, @NonNull String fileName) {
|
||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
List<GPXInfo> infoList = getSortedGPXFilesInfo(dir, null, false);
|
||||
for (GPXInfo info : infoList) {
|
||||
if (Algorithms.objectEquals(info.fileName, fileName)) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<GPXInfo> getSortedGPXFilesInfo(File dir, final List<String> selectedGpxList, boolean absolutePath) {
|
||||
final List<GPXInfo> list = new ArrayList<>();
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.data.PointDescription.POINT_TYPE_GPX_FILE;
|
||||
|
||||
public class SearchHistoryHelper {
|
||||
|
||||
private static final int HISTORY_LIMIT = 1500;
|
||||
|
@ -40,6 +42,10 @@ public class SearchHistoryHelper {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public void addGpxFileToHistory(String fileName) {
|
||||
addNewItemToHistory(0, 0, new PointDescription(POINT_TYPE_GPX_FILE, fileName));
|
||||
}
|
||||
|
||||
public void addNewItemToHistory(double latitude, double longitude, PointDescription pointDescription) {
|
||||
addNewItemToHistory(new HistoryEntry(latitude, longitude, pointDescription));
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ import net.osmand.plus.poi.RearrangePoiFiltersFragment;
|
|||
import net.osmand.plus.resources.RegionAddressRepository;
|
||||
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
|
||||
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchGpxTrackListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||
|
@ -117,6 +118,7 @@ import java.util.List;
|
|||
|
||||
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_LOCATION_KEY;
|
||||
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_QUERY_KEY;
|
||||
import static net.osmand.search.core.ObjectType.GPX_TRACK;
|
||||
import static net.osmand.search.core.ObjectType.POI_TYPE;
|
||||
import static net.osmand.search.core.ObjectType.SEARCH_STARTED;
|
||||
import static net.osmand.search.core.SearchCoreFactory.SEARCH_AMENITY_TYPE_PRIORITY;
|
||||
|
@ -1232,7 +1234,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (res != null) {
|
||||
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
addListItem(rows, sr);
|
||||
}
|
||||
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_world_globe_dark,
|
||||
app.getString(R.string.search_online_address), new OnClickListener() {
|
||||
|
@ -1499,7 +1501,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
int limit = 15;
|
||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||
if (limit > 0) {
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
addListItem(rows, sr);
|
||||
}
|
||||
limit--;
|
||||
}
|
||||
|
@ -1539,7 +1541,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||
if (res != null) {
|
||||
for (SearchResult sr : res.getCurrentSearchResults()) {
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
addListItem(rows, sr);
|
||||
}
|
||||
}
|
||||
historySearchFragment.updateListAdapter(rows, false);
|
||||
|
@ -1550,6 +1552,14 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
private void addListItem(List<QuickSearchListItem> rows, SearchResult sr) {
|
||||
if (sr.objectType == GPX_TRACK) {
|
||||
rows.add(new QuickSearchGpxTrackListItem(app, sr));
|
||||
} else {
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreSearch() {
|
||||
if (addressSearch) {
|
||||
startAddressSearch();
|
||||
|
@ -2051,7 +2061,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||
if (res != null && res.getCurrentSearchResults().size() > 0) {
|
||||
for (final SearchResult sr : res.getCurrentSearchResults()) {
|
||||
rows.add(new QuickSearchListItem(app, sr));
|
||||
addListItem(rows, sr);
|
||||
}
|
||||
updateSendEmptySearchBottomBar(false);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
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 net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.poi.NominatimPoiFilter;
|
||||
|
@ -457,6 +459,14 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
sr.objectType = ObjectType.POI_TYPE;
|
||||
publish = true;
|
||||
}
|
||||
} else if (pd.isGpxFile()) {
|
||||
GPXInfo gpxInfo = GpxUiHelper.getGpxInfoByFileName(app, pd.getName());
|
||||
if (gpxInfo != null) {
|
||||
sr.localeName = gpxInfo.getFileName();
|
||||
sr.object = gpxInfo;
|
||||
sr.objectType = ObjectType.GPX_TRACK;
|
||||
publish = true;
|
||||
}
|
||||
} else {
|
||||
sr.localeName = pd.getName();
|
||||
sr.object = point;
|
||||
|
|
|
@ -30,6 +30,8 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||
import net.osmand.plus.search.listitems.QuickSearchBannerListItem;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||
|
@ -225,6 +227,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
return bindTopShadowItem(convertView);
|
||||
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
|
||||
return bindBottomShadowItem(convertView);
|
||||
} else if (type == QuickSearchListItemType.GPX_TRACK) {
|
||||
view = bindGpxTrackItem(position, convertView, listItem);
|
||||
} else {
|
||||
view = bindSearchResultItem(position, convertView, listItem);
|
||||
}
|
||||
|
@ -395,6 +399,17 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
return getLinearLayout(convertView, R.layout.list_shadow_footer);
|
||||
}
|
||||
|
||||
private LinearLayout bindGpxTrackItem(int position,
|
||||
@Nullable View convertView,
|
||||
@NonNull QuickSearchListItem listItem) {
|
||||
LinearLayout view = getLinearLayout(convertView, R.layout.search_gpx_list_item);
|
||||
SearchResult sr = listItem.getSearchResult();
|
||||
GPXInfo gpxInfo = (GPXInfo) sr.object;
|
||||
setupCheckBox(position, view, listItem);
|
||||
GpxUiHelper.updateGpxInfoView(app, view, sr.localeName, listItem.getIcon(), gpxInfo);
|
||||
return view;
|
||||
}
|
||||
|
||||
private LinearLayout bindSearchResultItem(int position,
|
||||
@Nullable View convertView,
|
||||
@NonNull QuickSearchListItem listItem) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.ListView;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -23,6 +24,8 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.OsmAndListFragment;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||
import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem;
|
||||
|
@ -30,10 +33,12 @@ import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
|||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||
import net.osmand.plus.search.listitems.QuickSearchTopShadowListItem;
|
||||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.search.core.ObjectType;
|
||||
import net.osmand.search.core.SearchResult;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -104,6 +109,11 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
}
|
||||
dialogFragment.completeQueryWithObject(sr);
|
||||
}
|
||||
} else if (item.getType() == QuickSearchListItemType.GPX_TRACK) {
|
||||
SearchResult sr = item.getSearchResult();
|
||||
if (sr.objectType == ObjectType.GPX_TRACK) {
|
||||
showTrackMenuFragment((GPXInfo) sr.object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,6 +302,17 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void showTrackMenuFragment(GPXInfo gpxInfo) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
String fileName = gpxInfo.getFileName();
|
||||
SearchHistoryHelper.getInstance(app).addGpxFileToHistory(fileName);
|
||||
File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), fileName);
|
||||
String path = file.getAbsolutePath();
|
||||
TrackMenuFragment.showInstance(mapActivity, path, false, null, null);
|
||||
dialogFragment.dismiss();
|
||||
}
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package net.osmand.plus.search.listitems;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.search.core.SearchResult;
|
||||
|
||||
public class QuickSearchGpxTrackListItem extends QuickSearchListItem {
|
||||
|
||||
public QuickSearchGpxTrackListItem(OsmandApplication app, SearchResult searchResult) {
|
||||
super(app, searchResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuickSearchListItemType getType() {
|
||||
return QuickSearchListItemType.GPX_TRACK;
|
||||
}
|
||||
}
|
|
@ -382,6 +382,8 @@ public class QuickSearchListItem {
|
|||
case WPT:
|
||||
WptPt wpt = (WptPt) searchResult.object;
|
||||
return PointImageDrawable.getFromWpt(app, wpt.getColor(), false, wpt);
|
||||
case GPX_TRACK:
|
||||
return getIcon(app, R.drawable.ic_action_polygom_dark);
|
||||
case UNKNOWN_NAME_FILTER:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.search.listitems;
|
|||
|
||||
public enum QuickSearchListItemType {
|
||||
SEARCH_RESULT,
|
||||
GPX_TRACK,
|
||||
HEADER,
|
||||
BUTTON,
|
||||
SEARCH_MORE,
|
||||
|
|
Loading…
Reference in a new issue