Fix getSelected and some UI issue

This commit is contained in:
Dima-1 2020-07-27 14:04:19 +03:00
parent 166ecf6dcd
commit a433aad8f1
5 changed files with 32 additions and 25 deletions

View file

@ -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"

View file

@ -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>

View file

@ -78,7 +78,6 @@ import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback; import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
@ -788,8 +787,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
} }
@Override @Override
public void openLastEditTrackOnClick(GPXFile gpxFile) { public void openLastEditTrackOnClick(String gpxFileName) {
addNewGpxData(gpxFile); getGpxFile(gpxFileName);
} }
@Override @Override
@ -802,8 +801,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
@ -817,6 +816,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);
}
}
public void addNewGpxData(GPXFile gpxFile) { public void addNewGpxData(GPXFile gpxFile) {
QuadRect rect = gpxFile.getRect(); QuadRect rect = gpxFile.getRect();
TrkSegment segment = getTrkSegment(gpxFile); TrkSegment segment = getTrkSegment(gpxFile);

View file

@ -10,8 +10,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;
@ -22,7 +20,6 @@ import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener;
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
import net.osmand.util.Algorithms;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -85,9 +82,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();
@ -163,7 +159,7 @@ public class SelectFileBottomSheet extends MenuBottomSheetDialogFragment {
interface SelectFileListener { interface SelectFileListener {
void selectFileOnCLick(GPXFile gpxFile); void selectFileOnCLick(String fileName);
void dismissButtonOnClick(); void dismissButtonOnClick();

View file

@ -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();