Merge branch 'plan_route_start' into plan_route_options
# Conflicts: # OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
This commit is contained in:
commit
6a41ecdc05
5 changed files with 32 additions and 23 deletions
|
@ -14,10 +14,11 @@
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:paddingEnd="@dimen/content_padding"
|
android:paddingEnd="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:paddingTop="@dimen/bottom_sheet_title_padding_top"
|
android:paddingTop="@dimen/multi_selection_menu_padding_top"
|
||||||
android:paddingBottom="@dimen/bottom_sheet_title_padding_bottom"
|
android:paddingBottom="@dimen/bottom_sheet_title_padding_bottom"
|
||||||
android:text="@string/plan_route_open_existing_track"
|
android:text="@string/plan_route_open_existing_track"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle" />
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
|
@ -27,8 +28,7 @@
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:paddingEnd="@dimen/content_padding"
|
android:paddingEnd="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:paddingTop="@dimen/bottom_sheet_title_padding_top"
|
android:paddingBottom="@dimen/content_padding"
|
||||||
android:paddingBottom="@dimen/bottom_sheet_title_padding_bottom"
|
|
||||||
android:text="@string/plan_route_select_track_file_for_open"
|
android:text="@string/plan_route_select_track_file_for_open"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/plan_route_last_edited"
|
android:text="@string/plan_route_last_edited"
|
||||||
|
android:letterSpacing="@dimen/description_letter_spacing"
|
||||||
android:textColor="?attr/active_color_basic"
|
android:textColor="?attr/active_color_basic"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_regular" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -798,8 +798,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openLastEditTrackOnClick(GPXFile gpxFile) {
|
public void openLastEditTrackOnClick(String gpxFileName) {
|
||||||
addNewGpxData(gpxFile);
|
getGpxFile(gpxFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -812,8 +812,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
||||||
private SelectFileListener createSelectFileListener() {
|
private SelectFileListener createSelectFileListener() {
|
||||||
return new SelectFileListener() {
|
return new SelectFileListener() {
|
||||||
@Override
|
@Override
|
||||||
public void selectFileOnCLick(GPXFile gpxFile) {
|
public void selectFileOnCLick(String gpxFileName) {
|
||||||
addNewGpxData(gpxFile);
|
getGpxFile(gpxFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -827,6 +827,21 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getGpxFile(String gpxFileName) {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
GPXFile gpxFile;
|
||||||
|
if (app != null) {
|
||||||
|
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(gpxFileName);
|
||||||
|
if (selectedGpxFile != null) {
|
||||||
|
gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
} else {
|
||||||
|
gpxFile = GPXUtilities.loadGPXFile(new File(
|
||||||
|
getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR), gpxFileName));
|
||||||
|
}
|
||||||
|
addNewGpxData(gpxFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SelectFileListener createAddToTrackFileListener() {
|
private SelectFileListener createAddToTrackFileListener() {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
return new SelectFileListener() {
|
return new SelectFileListener() {
|
||||||
|
|
|
@ -12,8 +12,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -116,9 +114,8 @@ public class SelectFileBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
public void onItemClick(int position) {
|
public void onItemClick(int position) {
|
||||||
if (position != RecyclerView.NO_POSITION && position < allGpxList.size()) {
|
if (position != RecyclerView.NO_POSITION && position < allGpxList.size()) {
|
||||||
String fileName = allGpxList.get(position).getFileName();
|
String fileName = allGpxList.get(position).getFileName();
|
||||||
GPXFile gpxFile = GPXUtilities.loadGPXFile(new File(gpxDir, fileName));
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.selectFileOnCLick(gpxFile);
|
listener.selectFileOnCLick(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -195,7 +192,7 @@ public class SelectFileBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
interface SelectFileListener {
|
interface SelectFileListener {
|
||||||
|
|
||||||
void selectFileOnCLick(GPXFile gpxFile);
|
void selectFileOnCLick(String fileName);
|
||||||
|
|
||||||
void dismissButtonOnClick();
|
void dismissButtonOnClick();
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -24,7 +22,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.helpers.GpxTrackAdapter;
|
import net.osmand.plus.helpers.GpxTrackAdapter;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
|
@ -106,7 +104,7 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
.create();
|
.create();
|
||||||
items.add(importTrackItem);
|
items.add(importTrackItem);
|
||||||
|
|
||||||
items.add(new DividerHalfItem(getContext()));
|
items.add(new DividerItem(getContext()));
|
||||||
|
|
||||||
final RecyclerView recyclerView = mainView.findViewById(R.id.gpx_track_list);
|
final RecyclerView recyclerView = mainView.findViewById(R.id.gpx_track_list);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
@ -125,7 +123,7 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final List<GPXInfo> gpxTopList = gpxList.subList(0, Math.min(5, gpxList.size()));
|
final List<GPXInfo> gpxTopList = gpxList.subList(0, Math.min(5, gpxList.size()));
|
||||||
adapter = new GpxTrackAdapter(requireContext(), gpxList, false);
|
adapter = new GpxTrackAdapter(requireContext(), gpxTopList, false);
|
||||||
adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() {
|
adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(int position) {
|
public void onItemClick(int position) {
|
||||||
|
@ -143,11 +141,9 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
private void onItemClick(int position, List<GPXInfo> gpxInfoList) {
|
private void onItemClick(int position, List<GPXInfo> gpxInfoList) {
|
||||||
if (position != RecyclerView.NO_POSITION && position < gpxInfoList.size()) {
|
if (position != RecyclerView.NO_POSITION && position < gpxInfoList.size()) {
|
||||||
OsmandApplication app = requiredMyApplication();
|
|
||||||
String fileName = gpxInfoList.get(position).getFileName();
|
String fileName = gpxInfoList.get(position).getFileName();
|
||||||
GPXFile gpxFile = GPXUtilities.loadGPXFile(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), fileName));
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.openLastEditTrackOnClick(gpxFile);
|
listener.openLastEditTrackOnClick(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -221,7 +217,7 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
void openExistingTrackOnClick();
|
void openExistingTrackOnClick();
|
||||||
|
|
||||||
void openLastEditTrackOnClick(GPXFile gpxFile);
|
void openLastEditTrackOnClick(String fileName);
|
||||||
|
|
||||||
void dismissButtonOnClick();
|
void dismissButtonOnClick();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue