Follow track second part
This commit is contained in:
parent
960848ecf5
commit
66e8634bea
9 changed files with 233 additions and 46 deletions
|
@ -1290,6 +1290,17 @@ public class GPXUtilities {
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TrkSegment getTrkSegment() {
|
||||||
|
for (GPXUtilities.Track t : tracks) {
|
||||||
|
for (TrkSegment s : t.segments) {
|
||||||
|
if (s.points.size() > 0) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void addTrkSegment(List<WptPt> points) {
|
public void addTrkSegment(List<WptPt> points) {
|
||||||
removeGeneralTrackIfExists();
|
removeGeneralTrackIfExists();
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
android:id="@+id/bottom_container"
|
android:id="@+id/bottom_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/route_info_bg"
|
||||||
android:foreground="@drawable/bg_contextmenu_shadow"
|
android:foreground="@drawable/bg_contextmenu_shadow"
|
||||||
android:foregroundGravity="top|fill_horizontal">
|
android:foregroundGravity="top|fill_horizontal">
|
||||||
|
|
||||||
|
|
|
@ -165,33 +165,33 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/show_on_map"
|
android:id="@+id/show_on_map"
|
||||||
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="@dimen/list_item_height"
|
android:layout_width="@dimen/list_item_height"
|
||||||
android:layout_height="@dimen/list_item_height"
|
android:layout_height="@dimen/list_item_height"
|
||||||
android:layout_marginLeft="@dimen/favorites_icon_right_margin"
|
|
||||||
android:layout_marginStart="@dimen/favorites_icon_right_margin"
|
android:layout_marginStart="@dimen/favorites_icon_right_margin"
|
||||||
android:background="?attr/dashboard_button"
|
android:layout_marginLeft="@dimen/favorites_icon_right_margin"
|
||||||
osmand:srcCompat="@drawable/ic_action_gsave_dark"
|
android:visibility="gone"
|
||||||
android:visibility="gone" />
|
osmand:srcCompat="@drawable/ic_action_gsave_dark" />
|
||||||
|
|
||||||
<ImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/stop"
|
android:id="@+id/stop"
|
||||||
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="@dimen/list_item_height"
|
android:layout_width="@dimen/list_item_height"
|
||||||
android:layout_height="@dimen/list_item_height"
|
android:layout_height="@dimen/list_item_height"
|
||||||
android:background="?attr/dashboard_button"
|
android:visibility="gone"
|
||||||
osmand:srcCompat="@drawable/ic_action_rec_stop"
|
osmand:srcCompat="@drawable/ic_action_rec_stop" />
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:id="@+id/options"
|
android:id="@+id/options"
|
||||||
android:contentDescription="@string/shared_string_more_actions"
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
android:layout_width="@dimen/list_item_height"
|
android:layout_width="@dimen/list_item_height"
|
||||||
android:layout_height="@dimen/list_item_height"
|
android:layout_height="@dimen/list_item_height"
|
||||||
android:background="?attr/dashboard_button"
|
android:contentDescription="@string/shared_string_more_actions"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
osmand:srcCompat="@drawable/ic_overflow_menu_white"
|
android:visibility="gone"
|
||||||
android:visibility="gone"/>
|
osmand:srcCompat="@drawable/ic_overflow_menu_white" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/check_item"
|
android:id="@+id/check_item"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="select_another_track">Select another track</string>
|
||||||
<string name="import_track_descr">Choose track file to follow or import it from device.</string>
|
<string name="import_track_descr">Choose track file to follow or import it from device.</string>
|
||||||
<string name="follow_track_descr">Choose track file to follow</string>
|
<string name="follow_track_descr">Choose track file to follow</string>
|
||||||
<string name="follow_track">Follow track</string>
|
<string name="follow_track">Follow track</string>
|
||||||
|
|
|
@ -882,11 +882,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
public void addNewGpxData(GPXFile gpxFile) {
|
public void addNewGpxData(GPXFile gpxFile) {
|
||||||
QuadRect rect = gpxFile.getRect();
|
QuadRect rect = gpxFile.getRect();
|
||||||
TrkSegment segment = getTrkSegment(gpxFile);
|
TrkSegment segment = gpxFile.getTrkSegment();
|
||||||
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, segment == null
|
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
|
||||||
? ActionType.ADD_ROUTE_POINTS
|
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
|
||||||
: ActionType.EDIT_SEGMENT,
|
|
||||||
segment);
|
|
||||||
editingCtx.setNewGpxData(newGpxData);
|
editingCtx.setNewGpxData(newGpxData);
|
||||||
initMeasurementMode(newGpxData);
|
initMeasurementMode(newGpxData);
|
||||||
QuadRect qr = newGpxData.getRect();
|
QuadRect qr = newGpxData.getRect();
|
||||||
|
@ -897,17 +896,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TrkSegment getTrkSegment(GPXFile gpxFile) {
|
|
||||||
for (GPXUtilities.Track t : gpxFile.tracks) {
|
|
||||||
for (TrkSegment s : t.segments) {
|
|
||||||
if (s.points.size() > 0) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removePoint(MeasurementToolLayer measurementLayer, int position) {
|
private void removePoint(MeasurementToolLayer measurementLayer, int position) {
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.getCommandManager().execute(new RemovePointCommand(measurementLayer, position));
|
editingCtx.getCommandManager().execute(new RemovePointCommand(measurementLayer, position));
|
||||||
|
|
|
@ -20,9 +20,11 @@ import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -34,9 +36,15 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
import net.osmand.plus.helpers.ImportHelper;
|
import net.osmand.plus.helpers.ImportHelper;
|
||||||
|
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
||||||
|
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||||
|
import net.osmand.plus.measurementtool.NewGpxData;
|
||||||
|
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
||||||
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.routepreparationmenu.cards.ImportTrackCard;
|
import net.osmand.plus.routepreparationmenu.cards.ImportTrackCard;
|
||||||
|
import net.osmand.plus.routepreparationmenu.cards.SelectTrackCard;
|
||||||
|
import net.osmand.plus.routepreparationmenu.cards.TrackEditCard;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard;
|
import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard;
|
||||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||||
|
|
||||||
|
@ -52,11 +60,14 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(FollowTrackFragment.class);
|
private static final Log log = PlatformUtil.getLog(FollowTrackFragment.class);
|
||||||
|
|
||||||
|
private static final String SELECTING_TRACK = "selecting_track";
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private ImportHelper importHelper;
|
private ImportHelper importHelper;
|
||||||
|
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
|
|
||||||
|
private boolean selectingTrack;
|
||||||
private int menuTitleHeight;
|
private int menuTitleHeight;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,11 +116,10 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
gpxFile = routeParamsBuilder.getFile();
|
gpxFile = routeParamsBuilder.getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle arguments = getArguments();
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
selectingTrack = savedInstanceState.getBoolean(SELECTING_TRACK, gpxFile == null);
|
||||||
} else if (arguments != null) {
|
} else {
|
||||||
|
selectingTrack = gpxFile == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,22 +162,35 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupCards() {
|
private void setupCards() {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
ViewGroup cardsContainer = getCardsContainer();
|
ViewGroup cardsContainer = getCardsContainer();
|
||||||
cardsContainer.removeAllViews();
|
cardsContainer.removeAllViews();
|
||||||
|
|
||||||
ImportTrackCard importTrackCard = new ImportTrackCard(mapActivity);
|
if (gpxFile == null || selectingTrack) {
|
||||||
importTrackCard.setListener(this);
|
ImportTrackCard importTrackCard = new ImportTrackCard(mapActivity);
|
||||||
cardsContainer.addView(importTrackCard.build(mapActivity));
|
importTrackCard.setListener(this);
|
||||||
|
cardsContainer.addView(importTrackCard.build(mapActivity));
|
||||||
|
|
||||||
File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||||
List<String> selectedTrackNames = GpxUiHelper.getSelectedTrackNames(app);
|
List<String> selectedTrackNames = GpxUiHelper.getSelectedTrackNames(app);
|
||||||
List<GPXInfo> list = GpxUiHelper.getSortedGPXFilesInfo(dir, selectedTrackNames, false);
|
List<GPXInfo> list = GpxUiHelper.getSortedGPXFilesInfo(dir, selectedTrackNames, false);
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
TracksToFollowCard tracksCard = new TracksToFollowCard(mapActivity, list);
|
String defaultCategory = app.getString(R.string.shared_string_all);
|
||||||
tracksCard.setListener(this);
|
TracksToFollowCard tracksCard = new TracksToFollowCard(mapActivity, list, defaultCategory);
|
||||||
cardsContainer.addView(tracksCard.build(mapActivity));
|
tracksCard.setListener(this);
|
||||||
|
cardsContainer.addView(tracksCard.build(mapActivity));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File file = new File(gpxFile.path);
|
||||||
|
GPXInfo gpxInfo = new GPXInfo(gpxFile.path, file.lastModified(), file.length());
|
||||||
|
TrackEditCard importTrackCard = new TrackEditCard(mapActivity, gpxInfo);
|
||||||
|
importTrackCard.setListener(this);
|
||||||
|
cardsContainer.addView(importTrackCard.build(mapActivity));
|
||||||
|
|
||||||
|
SelectTrackCard selectTrackCard = new SelectTrackCard(mapActivity);
|
||||||
|
selectTrackCard.setListener(this);
|
||||||
|
cardsContainer.addView(selectTrackCard.build(mapActivity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +221,12 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
exitTrackAppearanceMode();
|
exitTrackAppearanceMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(SELECTING_TRACK, selectingTrack);
|
||||||
|
}
|
||||||
|
|
||||||
private void enterTrackAppearanceMode() {
|
private void enterTrackAppearanceMode() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
@ -257,6 +286,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
if (card instanceof ImportTrackCard) {
|
if (card instanceof ImportTrackCard) {
|
||||||
importTrack();
|
importTrack();
|
||||||
|
} else if (card instanceof TrackEditCard) {
|
||||||
|
editTrack();
|
||||||
|
dismiss();
|
||||||
|
} else if (card instanceof SelectTrackCard) {
|
||||||
|
updateSelectionMode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,11 +315,13 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(fileName);
|
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(fileName);
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
selectTrackToFollow(selectedGpxFile.getGpxFile());
|
selectTrackToFollow(selectedGpxFile.getGpxFile());
|
||||||
|
updateSelectionMode(false);
|
||||||
} else {
|
} else {
|
||||||
CallbackWithObject<GPXFile[]> callback = new CallbackWithObject<GPXFile[]>() {
|
CallbackWithObject<GPXFile[]> callback = new CallbackWithObject<GPXFile[]>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXFile[] result) {
|
public boolean processResult(GPXFile[] result) {
|
||||||
selectTrackToFollow(result[0]);
|
selectTrackToFollow(result[0]);
|
||||||
|
updateSelectionMode(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -298,12 +334,18 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
private void selectTrackToFollow(GPXFile gpxFile) {
|
private void selectTrackToFollow(GPXFile gpxFile) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
this.gpxFile = gpxFile;
|
||||||
mapActivity.getMapActions().setGPXRouteParams(gpxFile);
|
mapActivity.getMapActions().setGPXRouteParams(gpxFile);
|
||||||
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||||
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSelectionMode(boolean selecting) {
|
||||||
|
this.selectingTrack = selecting;
|
||||||
|
setupCards();
|
||||||
|
}
|
||||||
|
|
||||||
public void importTrack() {
|
public void importTrack() {
|
||||||
Intent intent = ImportHelper.getImportTrackIntent();
|
Intent intent = ImportHelper.getImportTrackIntent();
|
||||||
try {
|
try {
|
||||||
|
@ -333,6 +375,20 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void editTrack() {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null && gpxFile != null) {
|
||||||
|
QuadRect rect = gpxFile.getRect();
|
||||||
|
GPXUtilities.TrkSegment segment = gpxFile.getTrkSegment();
|
||||||
|
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
|
||||||
|
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
|
||||||
|
|
||||||
|
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
||||||
|
editingContext.setNewGpxData(newGpxData);
|
||||||
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateCardsLayout() {
|
private void updateCardsLayout() {
|
||||||
View mainView = getMainView();
|
View mainView = getMainView();
|
||||||
if (mainView != null) {
|
if (mainView != null) {
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package net.osmand.plus.routepreparationmenu.cards;
|
||||||
|
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.Spanned;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
|
||||||
|
public class SelectTrackCard extends BaseCard {
|
||||||
|
|
||||||
|
public SelectTrackCard(@NonNull MapActivity mapActivity) {
|
||||||
|
super(mapActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCardLayoutId() {
|
||||||
|
return R.layout.bottom_sheet_item_simple;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateContent() {
|
||||||
|
Typeface typeface = FontCache.getRobotoMedium(app);
|
||||||
|
String title = app.getString(R.string.select_another_track);
|
||||||
|
SpannableString spannable = UiUtilities.createCustomFontSpannable(typeface, title, title, title);
|
||||||
|
ForegroundColorSpan colorSpan = new ForegroundColorSpan(getActiveColor());
|
||||||
|
spannable.setSpan(colorSpan, 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
TextView titleTv = view.findViewById(R.id.title);
|
||||||
|
titleTv.setText(spannable);
|
||||||
|
|
||||||
|
ImageView icon = view.findViewById(R.id.icon);
|
||||||
|
icon.setImageDrawable(getActiveIcon(R.drawable.ic_action_folder));
|
||||||
|
|
||||||
|
int minHeight = app.getResources().getDimensionPixelSize(R.dimen.route_info_list_text_padding);
|
||||||
|
view.setMinimumHeight(minHeight);
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
CardListener listener = getListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCardPressed(SelectTrackCard.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package net.osmand.plus.routepreparationmenu.cards;
|
||||||
|
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class TrackEditCard extends BaseCard {
|
||||||
|
|
||||||
|
private GPXInfo gpxInfo;
|
||||||
|
|
||||||
|
public TrackEditCard(MapActivity mapActivity, GPXInfo gpxInfo) {
|
||||||
|
super(mapActivity);
|
||||||
|
this.gpxInfo = gpxInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCardLayoutId() {
|
||||||
|
return R.layout.gpx_track_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GpxDataItem getDataItem(GpxUiHelper.GPXInfo info) {
|
||||||
|
return app.getGpxDbHelper().getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), info.getFileName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateContent() {
|
||||||
|
int minCardHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height);
|
||||||
|
int listContentPadding = app.getResources().getDimensionPixelSize(R.dimen.list_content_padding);
|
||||||
|
|
||||||
|
String fileName = Algorithms.getFileWithoutDirs(gpxInfo.getFileName());
|
||||||
|
String title = GpxUiHelper.getGpxTitle(fileName);
|
||||||
|
GpxDataItem dataItem = getDataItem(gpxInfo);
|
||||||
|
GpxUiHelper.updateGpxInfoView(view, title, gpxInfo, dataItem, false, app);
|
||||||
|
|
||||||
|
ImageView trackIcon = view.findViewById(R.id.icon);
|
||||||
|
trackIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
|
||||||
|
trackIcon.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
ImageButton editButton = view.findViewById(R.id.show_on_map);
|
||||||
|
editButton.setVisibility(View.VISIBLE);
|
||||||
|
editButton.setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
|
||||||
|
editButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
CardListener listener = getListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCardPressed(TrackEditCard.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LinearLayout container = view.findViewById(R.id.container);
|
||||||
|
container.setMinimumHeight(minCardHeight);
|
||||||
|
AndroidUtils.setPadding(container, listContentPadding, 0, 0, 0);
|
||||||
|
|
||||||
|
int activeColor = getActiveColor();
|
||||||
|
int bgColor = UiUtilities.getColorWithAlpha(activeColor, 0.1f);
|
||||||
|
view.setBackgroundDrawable(new ColorDrawable(bgColor));
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,9 +26,10 @@ public class TracksToFollowCard extends BaseCard {
|
||||||
|
|
||||||
private GpxTrackAdapter tracksAdapter;
|
private GpxTrackAdapter tracksAdapter;
|
||||||
|
|
||||||
public TracksToFollowCard(MapActivity mapActivity, List<GPXInfo> gpxInfoList) {
|
public TracksToFollowCard(MapActivity mapActivity, List<GPXInfo> gpxInfoList, String selectedCategory) {
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
this.gpxInfoList = gpxInfoList;
|
this.gpxInfoList = gpxInfoList;
|
||||||
|
this.selectedCategory = selectedCategory;
|
||||||
gpxInfoCategories = getGpxInfoCategories();
|
gpxInfoCategories = getGpxInfoCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue