Merge pull request #11035 from osmandapp/AddVisibleGpxToHistory
Add visible GPX to history
This commit is contained in:
commit
42e4b17054
13 changed files with 670 additions and 283 deletions
|
@ -8,7 +8,7 @@ public enum ObjectType {
|
||||||
// LOCATION
|
// LOCATION
|
||||||
LOCATION(true), PARTIAL_LOCATION(false),
|
LOCATION(true), PARTIAL_LOCATION(false),
|
||||||
// UI OBJECTS
|
// 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
|
||||||
ONLINE_SEARCH(true),
|
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_OSM_BUG = "bug";
|
||||||
public static final String POINT_TYPE_WORLD_REGION = "world_region";
|
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_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_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_BLOCKED_ROAD = "blocked_road";
|
||||||
public static final String POINT_TYPE_TRANSPORT_ROUTE = "transport_route";
|
public static final String POINT_TYPE_TRANSPORT_ROUTE = "transport_route";
|
||||||
|
@ -297,6 +298,10 @@ public class PointDescription {
|
||||||
return POINT_TYPE_GPX.equals(type);
|
return POINT_TYPE_GPX.equals(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGpxFile() {
|
||||||
|
return POINT_TYPE_GPX_FILE.equals(type);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|
|
@ -27,6 +27,8 @@ import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||||
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
|
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersHelper;
|
import net.osmand.plus.mapmarkers.MapMarkersHelper;
|
||||||
|
@ -581,7 +583,7 @@ public class GpxSelectionHelper {
|
||||||
} else if (obj.has(BACKUP)) {
|
} else if (obj.has(BACKUP)) {
|
||||||
selectedGpxFilesBackUp.put(gpx, gpx.modifiedTime);
|
selectedGpxFilesBackUp.put(gpx, gpx.modifiedTime);
|
||||||
} else {
|
} 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)) {
|
if (obj.has(HIDDEN_GROUPS)) {
|
||||||
readHiddenGroups(file, obj.getString(HIDDEN_GROUPS));
|
readHiddenGroups(file, obj.getString(HIDDEN_GROUPS));
|
||||||
}
|
}
|
||||||
|
@ -684,7 +686,13 @@ public class GpxSelectionHelper {
|
||||||
app.getSettings().SELECTED_GPX.set(ar.toString());
|
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;
|
boolean displayed;
|
||||||
SelectedGpxFile sf;
|
SelectedGpxFile sf;
|
||||||
if (gpx != null && gpx.showCurrentTrack) {
|
if (gpx != null && gpx.showCurrentTrack) {
|
||||||
|
@ -724,6 +732,13 @@ public class GpxSelectionHelper {
|
||||||
if (sf != null) {
|
if (sf != null) {
|
||||||
sf.splitProcessed = false;
|
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, "");
|
||||||
|
GPXInfo gpxInfo = GpxUiHelper.getGpxInfoByFileName(app, fileName);
|
||||||
|
SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo);
|
||||||
|
}
|
||||||
return sf;
|
return sf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,18 +764,39 @@ public class GpxSelectionHelper {
|
||||||
return selectGpxFile(gpx, show, notShowNavigationDialog, true, true, true);
|
return selectGpxFile(gpx, show, notShowNavigationDialog, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedGpxFile selectGpxFile(GPXFile gpx, GpxDataItem dataItem, boolean show, boolean notShowNavigationDialog, boolean syncGroup, boolean selectedByUser) {
|
public SelectedGpxFile selectGpxFile(GPXFile gpx,
|
||||||
SelectedGpxFile sf = selectGpxFileImpl(gpx, dataItem, show, notShowNavigationDialog, syncGroup, selectedByUser);
|
GpxDataItem dataItem,
|
||||||
|
boolean show,
|
||||||
|
boolean notShowNavigationDialog,
|
||||||
|
boolean syncGroup,
|
||||||
|
boolean selectedByUser,
|
||||||
|
boolean addToHistory) {
|
||||||
|
SelectedGpxFile sf = selectGpxFileImpl(gpx, dataItem, show, notShowNavigationDialog, syncGroup, selectedByUser, addToHistory);
|
||||||
saveCurrentSelections();
|
saveCurrentSelections();
|
||||||
return sf;
|
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));
|
GpxDataItem dataItem = app.getGpxDbHelper().getItem(new File(gpx.path));
|
||||||
if (canAddToMarkers && show && dataItem != null && dataItem.isShowAsMarkers()) {
|
if (canAddToMarkers && show && dataItem != null && dataItem.isShowAsMarkers()) {
|
||||||
app.getMapMarkersHelper().addOrEnableGroup(gpx);
|
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) {
|
public void clearPoints(GPXFile gpxFile) {
|
||||||
|
|
|
@ -303,7 +303,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
|
||||||
iconId = R.drawable.ic_type_audio;
|
iconId = R.drawable.ic_type_audio;
|
||||||
} else if (pd.isVideoNote()) {
|
} else if (pd.isVideoNote()) {
|
||||||
iconId = R.drawable.ic_type_video;
|
iconId = R.drawable.ic_type_video;
|
||||||
}else if (pd.isPhotoNote()) {
|
} else if (pd.isPhotoNote()) {
|
||||||
iconId = R.drawable.ic_type_img;
|
iconId = R.drawable.ic_type_img;
|
||||||
} else {
|
} else {
|
||||||
iconId = R.drawable.ic_action_street_name;
|
iconId = R.drawable.ic_action_street_name;
|
||||||
|
|
|
@ -93,7 +93,6 @@ import net.osmand.plus.activities.ActivityResultListener;
|
||||||
import net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener;
|
import net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.PluginsFragment;
|
import net.osmand.plus.activities.PluginsFragment;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
|
||||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||||
import net.osmand.plus.helpers.enums.MetricsConstants;
|
import net.osmand.plus.helpers.enums.MetricsConstants;
|
||||||
|
@ -751,13 +750,53 @@ public class GpxUiHelper {
|
||||||
gpxDbHelper.updateShowStartFinish(item, showStartFinish);
|
gpxDbHelper.updateShowStartFinish(item, showStartFinish);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateGpxInfoView(View v, String itemTitle, GPXInfo info, GpxDataItem dataItem, boolean currentlyRecordingTrack, OsmandApplication app) {
|
public static void updateGpxInfoView(final @NonNull OsmandApplication app,
|
||||||
|
final @NonNull View v,
|
||||||
|
final @NonNull String itemTitle,
|
||||||
|
final @Nullable Drawable iconDrawable,
|
||||||
|
final @NonNull GPXInfo info) {
|
||||||
|
GpxDataItem item = getDataItem(app, info, new GpxDataItemCallback() {
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGpxDataItemReady(GpxDataItem item) {
|
||||||
|
updateGpxInfoView(app, v, itemTitle, iconDrawable, info, item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (item != null) {
|
||||||
|
updateGpxInfoView(app, v, itemTitle, iconDrawable, info, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void updateGpxInfoView(@NonNull OsmandApplication app,
|
||||||
|
@NonNull View v,
|
||||||
|
@NonNull String itemTitle,
|
||||||
|
@Nullable Drawable iconDrawable,
|
||||||
|
@NonNull GPXInfo info,
|
||||||
|
@NonNull GpxDataItem dataItem) {
|
||||||
|
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));
|
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
||||||
viewName.setText(itemTitle.replace("/", " • ").trim());
|
viewName.setText(itemTitle.replace("/", " • ").trim());
|
||||||
|
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||||
icon.setVisibility(View.GONE);
|
icon.setVisibility(View.GONE);
|
||||||
//icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark));
|
//icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
|
|
||||||
GPXTrackAnalysis analysis = null;
|
GPXTrackAnalysis analysis = null;
|
||||||
if (currentlyRecordingTrack) {
|
if (currentlyRecordingTrack) {
|
||||||
|
@ -809,9 +848,23 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView descr = ((TextView) v.findViewById(R.id.description));
|
TextView descr = ((TextView) v.findViewById(R.id.description));
|
||||||
|
if (descr != null) {
|
||||||
descr.setVisibility(View.GONE);
|
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(@NonNull OsmandApplication app,
|
||||||
|
@NonNull GPXInfo info,
|
||||||
|
@Nullable GpxDataItemCallback callback) {
|
||||||
|
File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||||
|
String fileName = info.getFileName();
|
||||||
|
File file = new File(dir, fileName);
|
||||||
|
return app.getGpxDbHelper().getItem(file, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||||
|
@ -884,6 +937,17 @@ public class GpxUiHelper {
|
||||||
return list;
|
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.getFileName(), fileName)) {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<GPXInfo> getSortedGPXFilesInfo(File dir, final List<String> selectedGpxList, boolean absolutePath) {
|
public static List<GPXInfo> getSortedGPXFilesInfo(File dir, final List<String> selectedGpxList, boolean absolutePath) {
|
||||||
final List<GPXInfo> list = new ArrayList<>();
|
final List<GPXInfo> list = new ArrayList<>();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.osmand.osm.AbstractPoiType;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||||
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.osmand.data.PointDescription.POINT_TYPE_GPX_FILE;
|
||||||
|
|
||||||
public class SearchHistoryHelper {
|
public class SearchHistoryHelper {
|
||||||
|
|
||||||
private static final int HISTORY_LIMIT = 1500;
|
private static final int HISTORY_LIMIT = 1500;
|
||||||
|
@ -53,6 +56,10 @@ public class SearchHistoryHelper {
|
||||||
context.getPoiFilters().markHistory(filter.getFilterId(), true);
|
context.getPoiFilters().markHistory(filter.getFilterId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addNewItemToHistory(GPXInfo gpxInfo) {
|
||||||
|
addNewItemToHistory(new HistoryEntry(0, 0, createPointDescription(gpxInfo)));
|
||||||
|
}
|
||||||
|
|
||||||
public List<HistoryEntry> getHistoryEntries(boolean onlyPoints) {
|
public List<HistoryEntry> getHistoryEntries(boolean onlyPoints) {
|
||||||
if (loadedEntries == null) {
|
if (loadedEntries == null) {
|
||||||
checkLoadedEntries();
|
checkLoadedEntries();
|
||||||
|
@ -75,6 +82,10 @@ public class SearchHistoryHelper {
|
||||||
return new PointDescription(PointDescription.POINT_TYPE_CUSTOM_POI_FILTER, filter.getFilterId());
|
return new PointDescription(PointDescription.POINT_TYPE_CUSTOM_POI_FILTER, filter.getFilterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PointDescription createPointDescription(GPXInfo gpxInfo) {
|
||||||
|
return new PointDescription(PointDescription.POINT_TYPE_GPX_FILE, gpxInfo.getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
public void remove(Object item) {
|
public void remove(Object item) {
|
||||||
PointDescription pd = null;
|
PointDescription pd = null;
|
||||||
if (item instanceof HistoryEntry) {
|
if (item instanceof HistoryEntry) {
|
||||||
|
@ -83,6 +94,8 @@ public class SearchHistoryHelper {
|
||||||
pd = createPointDescription((AbstractPoiType) item);
|
pd = createPointDescription((AbstractPoiType) item);
|
||||||
} else if (item instanceof PoiUIFilter) {
|
} else if (item instanceof PoiUIFilter) {
|
||||||
pd = createPointDescription((PoiUIFilter) item);
|
pd = createPointDescription((PoiUIFilter) item);
|
||||||
|
} else if (item instanceof GPXInfo) {
|
||||||
|
pd = createPointDescription((GPXInfo) item);
|
||||||
}
|
}
|
||||||
if (pd != null) {
|
if (pd != null) {
|
||||||
remove(pd);
|
remove(pd);
|
||||||
|
|
|
@ -513,7 +513,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>();
|
List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>();
|
||||||
List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems();
|
List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems();
|
||||||
for (QuickSearchListItem searchListItem : selectedItems) {
|
for (QuickSearchListItem searchListItem : selectedItems) {
|
||||||
Object object = searchListItem.getSearchResult().object;
|
Object object = searchListItem.getSearchResult().object;;
|
||||||
if (object instanceof HistoryEntry) {
|
if (object instanceof HistoryEntry) {
|
||||||
historyEntries.add((HistoryEntry) object);
|
historyEntries.add((HistoryEntry) object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
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;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.poi.NominatimPoiFilter;
|
import net.osmand.plus.poi.NominatimPoiFilter;
|
||||||
|
@ -457,6 +459,15 @@ public class QuickSearchHelper implements ResourceListener {
|
||||||
sr.objectType = ObjectType.POI_TYPE;
|
sr.objectType = ObjectType.POI_TYPE;
|
||||||
publish = true;
|
publish = true;
|
||||||
}
|
}
|
||||||
|
} else if (pd.isGpxFile()) {
|
||||||
|
GPXInfo gpxInfo = GpxUiHelper.getGpxInfoByFileName(app, pd.getName());
|
||||||
|
if (gpxInfo != null) {
|
||||||
|
sr.localeName = gpxInfo.getFileName();
|
||||||
|
sr.object = point;
|
||||||
|
sr.objectType = ObjectType.GPX_TRACK;
|
||||||
|
sr.relatedObject = gpxInfo;
|
||||||
|
publish = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sr.localeName = pd.getName();
|
sr.localeName = pd.getName();
|
||||||
sr.object = point;
|
sr.object = point;
|
||||||
|
|
|
@ -10,12 +10,10 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper;
|
import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
|
@ -32,8 +30,9 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
|
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
|
||||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
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.search.listitems.QuickSearchBannerListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchFreeBannerListItem;
|
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||||
|
@ -41,7 +40,9 @@ import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem;
|
import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem;
|
||||||
import net.osmand.search.SearchUICore;
|
import net.osmand.search.SearchUICore;
|
||||||
|
import net.osmand.search.core.ObjectType;
|
||||||
import net.osmand.search.core.SearchPhrase;
|
import net.osmand.search.core.SearchPhrase;
|
||||||
|
import net.osmand.search.core.SearchResult;
|
||||||
import net.osmand.search.core.SearchWord;
|
import net.osmand.search.core.SearchWord;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
|
@ -209,15 +210,38 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
|
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
|
||||||
final QuickSearchListItem listItem = getItem(position);
|
final QuickSearchListItem listItem = getItem(position);
|
||||||
QuickSearchListItemType type = listItem.getType();
|
QuickSearchListItemType type = listItem.getType();
|
||||||
|
|
||||||
LinearLayout view;
|
LinearLayout view;
|
||||||
if (type == QuickSearchListItemType.BANNER) {
|
if (type == QuickSearchListItemType.BANNER) {
|
||||||
final QuickSearchBannerListItem banner = (QuickSearchBannerListItem) listItem;
|
view = bindBannerItem(convertView, listItem);
|
||||||
if (convertView == null) {
|
} else if (type == QuickSearchListItemType.FREE_VERSION_BANNER) {
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.search_banner_list_item, null);
|
view = bindFreeVersionBannerItem(convertView);
|
||||||
|
} else if (type == QuickSearchListItemType.SEARCH_MORE) {
|
||||||
|
view = bindSearchMoreItem(convertView, listItem);
|
||||||
|
} else if (type == QuickSearchListItemType.BUTTON) {
|
||||||
|
view = bindButtonItem(convertView, listItem);
|
||||||
|
} else if (type == QuickSearchListItemType.SELECT_ALL) {
|
||||||
|
view = bindSelectAllItem(position, convertView);
|
||||||
|
} else if (type == QuickSearchListItemType.HEADER) {
|
||||||
|
view = bindHeaderItem(convertView, listItem);
|
||||||
|
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
|
||||||
|
return bindTopShadowItem(convertView);
|
||||||
|
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
|
||||||
|
return bindBottomShadowItem(convertView);
|
||||||
} else {
|
} else {
|
||||||
view = (LinearLayout) convertView;
|
view = bindSearchResultItem(position, convertView, listItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupBackground(view);
|
||||||
|
setupDivider(position, view, listItem);
|
||||||
|
ViewCompat.setAccessibilityDelegate(view, accessibilityAssistant);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindBannerItem(@Nullable View convertView,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
|
QuickSearchBannerListItem banner = (QuickSearchBannerListItem) listItem;
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.search_banner_list_item);
|
||||||
((TextView) view.findViewById(R.id.empty_search_description)).setText(R.string.nothing_found_descr);
|
((TextView) view.findViewById(R.id.empty_search_description)).setText(R.string.nothing_found_descr);
|
||||||
|
|
||||||
SearchUICore searchUICore = app.getSearchUICore().getCore();
|
SearchUICore searchUICore = app.getSearchUICore().getCore();
|
||||||
|
@ -252,14 +276,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
buttonContainer.addView(v);
|
buttonContainer.addView(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == QuickSearchListItemType.FREE_VERSION_BANNER) {
|
return view;
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(
|
|
||||||
R.layout.read_wikipedia_ofline_banner, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindFreeVersionBannerItem(@Nullable View convertView) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.read_wikipedia_ofline_banner);
|
||||||
View btnGet = view.findViewById(R.id.btn_get);
|
View btnGet = view.findViewById(R.id.btn_get);
|
||||||
if (btnGet != null) {
|
if (btnGet != null) {
|
||||||
btnGet.setOnClickListener(new View.OnClickListener() {
|
btnGet.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -270,13 +291,13 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (type == QuickSearchListItemType.SEARCH_MORE) {
|
return view;
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.search_more_list_item, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindSearchMoreItem(@Nullable View convertView,
|
||||||
|
@NonNull final QuickSearchListItem listItem) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.search_more_list_item);
|
||||||
|
|
||||||
if (listItem.getSpannableName() != null) {
|
if (listItem.getSpannableName() != null) {
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -325,24 +346,24 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
searchMoreItem.onSecondaryButtonClick();
|
searchMoreItem.onSecondaryButtonClick();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (type == QuickSearchListItemType.BUTTON) {
|
return view;
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.search_custom_list_item, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindButtonItem(@Nullable View convertView,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.search_custom_list_item);
|
||||||
((ImageView) view.findViewById(R.id.imageView)).setImageDrawable(listItem.getIcon());
|
((ImageView) view.findViewById(R.id.imageView)).setImageDrawable(listItem.getIcon());
|
||||||
if (listItem.getSpannableName() != null) {
|
if (listItem.getSpannableName() != null) {
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
||||||
} else {
|
} else {
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||||
}
|
}
|
||||||
} else if (type == QuickSearchListItemType.SELECT_ALL) {
|
return view;
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.select_all_list_item, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindSelectAllItem(final int position,
|
||||||
|
@Nullable View convertView) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.select_all_list_item);
|
||||||
final CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
|
final CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
|
||||||
ch.setVisibility(View.VISIBLE);
|
ch.setVisibility(View.VISIBLE);
|
||||||
ch.setChecked(selectAll);
|
ch.setChecked(selectAll);
|
||||||
|
@ -353,12 +374,12 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
toggleCheckbox(position, ch);
|
toggleCheckbox(position, ch);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (type == QuickSearchListItemType.HEADER) {
|
return view;
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.search_header_list_item, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindHeaderItem(@Nullable View convertView,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.search_header_list_item);
|
||||||
view.findViewById(R.id.top_divider)
|
view.findViewById(R.id.top_divider)
|
||||||
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
|
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
|
||||||
if (listItem.getSpannableName() != null) {
|
if (listItem.getSpannableName() != null) {
|
||||||
|
@ -366,41 +387,44 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
} else {
|
} else {
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||||
}
|
}
|
||||||
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
|
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.list_shadow_header, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
|
||||||
return view;
|
return view;
|
||||||
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
|
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.list_shadow_footer, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
} else {
|
|
||||||
if (convertView == null) {
|
|
||||||
view = (LinearLayout) inflater.inflate(R.layout.search_list_item, null);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
|
private LinearLayout bindTopShadowItem(@Nullable View convertView) {
|
||||||
if (selectionMode) {
|
return getLinearLayout(convertView, R.layout.list_shadow_header);
|
||||||
ch.setVisibility(View.VISIBLE);
|
}
|
||||||
ch.setChecked(selectedItems.contains(listItem));
|
|
||||||
ch.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
private LinearLayout bindBottomShadowItem(@Nullable View convertView) {
|
||||||
public void onClick(View v) {
|
return getLinearLayout(convertView, R.layout.list_shadow_footer);
|
||||||
toggleCheckbox(position, ch);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
private LinearLayout bindSearchResultItem(int position,
|
||||||
|
@Nullable View convertView,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
|
SearchResult sr = listItem.getSearchResult();
|
||||||
|
if (sr != null && sr.objectType == ObjectType.GPX_TRACK) {
|
||||||
|
return bindGpxTrack(position, convertView, listItem, (GPXInfo) sr.relatedObject);
|
||||||
} else {
|
} else {
|
||||||
ch.setVisibility(View.GONE);
|
return bindSearchResult(position, convertView, listItem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindGpxTrack(int position,
|
||||||
|
@Nullable View convertView,
|
||||||
|
@NonNull QuickSearchListItem listItem,
|
||||||
|
@NonNull GPXInfo gpxInfo) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.search_gpx_list_item);
|
||||||
|
SearchResult sr = listItem.getSearchResult();
|
||||||
|
setupCheckBox(position, view, listItem);
|
||||||
|
GpxUiHelper.updateGpxInfoView(app, view, sr.localeName, listItem.getIcon(), gpxInfo);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinearLayout bindSearchResult(int position,
|
||||||
|
@Nullable View convertView,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
|
LinearLayout view = getLinearLayout(convertView, R.layout.search_list_item);
|
||||||
|
setupCheckBox(position, view, listItem);
|
||||||
|
|
||||||
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
|
||||||
TextView title = (TextView) view.findViewById(R.id.title);
|
TextView title = (TextView) view.findViewById(R.id.title);
|
||||||
|
@ -483,9 +507,51 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCompassVisibility(view, listItem);
|
updateCompassVisibility(view, listItem);
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
view.setBackgroundColor(app.getResources().getColor(
|
|
||||||
app.getSettings().isLightContent() ? R.color.list_background_color_light : R.color.list_background_color_dark));
|
private LinearLayout getLinearLayout(@Nullable View convertView, int layoutId) {
|
||||||
|
if (convertView == null || isLayoutIdChanged(convertView, layoutId)) {
|
||||||
|
convertView = inflater.inflate(layoutId, null);
|
||||||
|
convertView.setTag(layoutId);
|
||||||
|
}
|
||||||
|
return (LinearLayout) convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLayoutIdChanged(@NonNull View view, int layoutId) {
|
||||||
|
return !Algorithms.objectEquals(view.getTag(), layoutId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupCheckBox(final int position,
|
||||||
|
@NonNull View rootView,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
|
final CheckBox ch = (CheckBox) rootView.findViewById(R.id.toggle_item);
|
||||||
|
if (selectionMode) {
|
||||||
|
ch.setVisibility(View.VISIBLE);
|
||||||
|
ch.setChecked(selectedItems.contains(listItem));
|
||||||
|
ch.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
toggleCheckbox(position, ch);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ch.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupBackground(View view) {
|
||||||
|
int bgColorResId = isNightMode() ?
|
||||||
|
R.color.list_background_color_dark :
|
||||||
|
R.color.list_background_color_light;
|
||||||
|
view.setBackgroundColor(app.getResources().getColor(bgColorResId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDivider(final int position,
|
||||||
|
@NonNull View view,
|
||||||
|
@NonNull QuickSearchListItem listItem) {
|
||||||
View divider = view.findViewById(R.id.divider);
|
View divider = view.findViewById(R.id.divider);
|
||||||
if (divider != null) {
|
if (divider != null) {
|
||||||
if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER
|
if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER
|
||||||
|
@ -494,7 +560,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
} else {
|
} else {
|
||||||
divider.setVisibility(View.VISIBLE);
|
divider.setVisibility(View.VISIBLE);
|
||||||
if (getItem(position + 1).getType() == QuickSearchListItemType.SEARCH_MORE
|
if (getItem(position + 1).getType() == QuickSearchListItemType.SEARCH_MORE
|
||||||
|| type == QuickSearchListItemType.SELECT_ALL) {
|
|| listItem.getType() == QuickSearchListItemType.SELECT_ALL) {
|
||||||
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp1);
|
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp1);
|
||||||
p.setMargins(0, 0, 0 ,0);
|
p.setMargins(0, 0, 0 ,0);
|
||||||
divider.setLayoutParams(p);
|
divider.setLayoutParams(p);
|
||||||
|
@ -505,8 +571,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ViewCompat.setAccessibilityDelegate(view, accessibilityAssistant);
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getIncreaseSearchButtonTitle(OsmandApplication app, SearchPhrase searchPhrase) {
|
public static String getIncreaseSearchButtonTitle(OsmandApplication app, SearchPhrase searchPhrase) {
|
||||||
|
@ -576,4 +640,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
LatLon toloc = listItem.getSearchResult().location;
|
LatLon toloc = listItem.getSearchResult().location;
|
||||||
app.getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, toloc);
|
app.getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, toloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isNightMode() {
|
||||||
|
return !app.getSettings().isLightContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.City;
|
import net.osmand.data.City;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
@ -23,6 +24,8 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.OsmAndListFragment;
|
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.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem;
|
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.QuickSearchListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchTopShadowListItem;
|
import net.osmand.plus.search.listitems.QuickSearchTopShadowListItem;
|
||||||
|
import net.osmand.plus.track.TrackMenuFragment;
|
||||||
import net.osmand.search.core.ObjectType;
|
import net.osmand.search.core.ObjectType;
|
||||||
import net.osmand.search.core.SearchResult;
|
import net.osmand.search.core.SearchResult;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -95,7 +100,8 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|| sr.objectType == ObjectType.FAVORITE
|
|| sr.objectType == ObjectType.FAVORITE
|
||||||
|| sr.objectType == ObjectType.RECENT_OBJ
|
|| sr.objectType == ObjectType.RECENT_OBJ
|
||||||
|| sr.objectType == ObjectType.WPT
|
|| sr.objectType == ObjectType.WPT
|
||||||
|| sr.objectType == ObjectType.STREET_INTERSECTION) {
|
|| sr.objectType == ObjectType.STREET_INTERSECTION
|
||||||
|
|| sr.objectType == ObjectType.GPX_TRACK) {
|
||||||
|
|
||||||
showResult(sr);
|
showResult(sr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,7 +171,9 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
public void showResult(SearchResult searchResult) {
|
public void showResult(SearchResult searchResult) {
|
||||||
showResult = false;
|
showResult = false;
|
||||||
if (searchResult.location != null) {
|
if (searchResult.objectType == ObjectType.GPX_TRACK) {
|
||||||
|
showTrackMenuFragment((GPXInfo) searchResult.relatedObject);
|
||||||
|
} else if (searchResult.location != null) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
|
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
|
||||||
boolean transliterate = searchResult.requiredSearchPhrase.getSettings().isTransliterate();
|
boolean transliterate = searchResult.requiredSearchPhrase.getSettings().isTransliterate();
|
||||||
|
@ -292,6 +300,16 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showTrackMenuFragment(GPXInfo gpxInfo) {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo);
|
||||||
|
File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxInfo.getFileName());
|
||||||
|
String path = file.getAbsolutePath();
|
||||||
|
TrackMenuFragment.showInstance(mapActivity, path, false, null, QuickSearchDialogFragment.TAG);
|
||||||
|
dialogFragment.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
public MapActivity getMapActivity() {
|
public MapActivity getMapActivity() {
|
||||||
return (MapActivity) getActivity();
|
return (MapActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,6 +359,8 @@ public class QuickSearchListItem {
|
||||||
} else {
|
} else {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
case GPX_TRACK:
|
||||||
|
return getIcon(app, R.drawable.ic_action_polygom_dark);
|
||||||
case LOCATION:
|
case LOCATION:
|
||||||
return getIcon(app, R.drawable.ic_action_world_globe);
|
return getIcon(app, R.drawable.ic_action_world_globe);
|
||||||
case FAVORITE:
|
case FAVORITE:
|
||||||
|
|
|
@ -59,6 +59,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
|
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
|
||||||
import net.osmand.plus.activities.MapActivityActions;
|
import net.osmand.plus.activities.MapActivityActions;
|
||||||
import net.osmand.plus.base.ContextMenuFragment;
|
import net.osmand.plus.base.ContextMenuFragment;
|
||||||
import net.osmand.plus.base.ContextMenuScrollFragment;
|
import net.osmand.plus.base.ContextMenuScrollFragment;
|
||||||
|
@ -81,6 +82,7 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||||
|
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||||
import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder;
|
import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder;
|
||||||
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||||
import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener;
|
import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener;
|
||||||
|
@ -270,6 +272,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
if (contextMenu.isActive() && contextMenu.getPointDescription() != null
|
if (contextMenu.isActive() && contextMenu.getPointDescription() != null
|
||||||
&& contextMenu.getPointDescription().isGpxPoint()) {
|
&& contextMenu.getPointDescription().isGpxPoint()) {
|
||||||
contextMenu.show();
|
contextMenu.show();
|
||||||
|
} else if (Algorithms.objectEquals(returnScreenName, QuickSearchDialogFragment.TAG)) {
|
||||||
|
mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false);
|
||||||
} else {
|
} else {
|
||||||
mapActivity.launchPrevActivityIntent();
|
mapActivity.launchPrevActivityIntent();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue