diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_switch_outlined.xml b/OsmAnd/res/layout/bottom_sheet_item_with_switch_outlined.xml
index 513fd09d59..b42be04eb9 100644
--- a/OsmAnd/res/layout/bottom_sheet_item_with_switch_outlined.xml
+++ b/OsmAnd/res/layout/bottom_sheet_item_with_switch_outlined.xml
@@ -41,6 +41,7 @@
android:layout_marginRight="@dimen/content_padding_small"
android:layout_gravity="end"
android:background="@null"
+ android:saveEnabled="false"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
diff --git a/OsmAnd/res/layout/markers_track_name_text_field_box.xml b/OsmAnd/res/layout/markers_track_name_text_field_box.xml
deleted file mode 100644
index 17cd56c10a..0000000000
--- a/OsmAnd/res/layout/markers_track_name_text_field_box.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/markers_track_name_edit_text.xml b/OsmAnd/res/layout/track_name_edit_text.xml
similarity index 80%
rename from OsmAnd/res/layout/markers_track_name_edit_text.xml
rename to OsmAnd/res/layout/track_name_edit_text.xml
index b2b4f6da29..545b7c42a0 100644
--- a/OsmAnd/res/layout/markers_track_name_edit_text.xml
+++ b/OsmAnd/res/layout/track_name_edit_text.xml
@@ -1,14 +1,14 @@
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ android:focusableInTouchMode="true" />
+ android:layout_height="wrap_content" />
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java
index 5cdb3571c2..f176437ebd 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java
@@ -1,6 +1,5 @@
package net.osmand.plus.mapmarkers;
-import android.os.Build;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.ContextThemeWrapper;
@@ -70,14 +69,10 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
titleTv.setText(openFromCoordinateInput ? R.string.coord_input_save_as_track : R.string.marker_save_as_track);
titleTv.setTextColor(ContextCompat.getColor(getContext(), textPrimaryColor));
TextView descriptionTv = (TextView) mainView.findViewById(R.id.save_as_track_description);
- descriptionTv.setText(openFromCoordinateInput ? getString(R.string.coord_input_save_as_track_descr, number) : getString(R.string.marker_save_as_track_descr));
- int layoutRes;
- if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- layoutRes = R.layout.markers_track_name_text_field_box;
- } else {
- layoutRes = R.layout.markers_track_name_edit_text;
- }
- contentLayout.addView(getLayoutInflater().inflate(layoutRes, contentLayout, false), 2);
+ descriptionTv.setText(openFromCoordinateInput
+ ? getString(R.string.coord_input_save_as_track_descr, String.valueOf(number))
+ : getString(R.string.marker_save_as_track_descr));
+ contentLayout.addView(getLayoutInflater().inflate(R.layout.track_name_edit_text, contentLayout, false), 2);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/FolderListAdapter.java b/OsmAnd/src/net/osmand/plus/measurementtool/FolderListAdapter.java
index e4ce603b8a..781dcbbe96 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/FolderListAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/FolderListAdapter.java
@@ -29,17 +29,15 @@ public class FolderListAdapter extends RecyclerView.Adapter items = new ArrayList<>();
- void setSelectedItemName(String selectedItemName) {
- this.selectedItemName = selectedItemName;
- }
-
String selectedItemName;
OsmandApplication app;
boolean nightMode;
+ FolderListAdapterListener listener;
- FolderListAdapter(OsmandApplication app, boolean nightMode) {
+ FolderListAdapter(OsmandApplication app, boolean nightMode, String folderName) {
this.app = app;
this.nightMode = nightMode;
+ selectedItemName = folderName;
fillGroups();
}
@@ -85,6 +83,9 @@ public class FolderListAdapter extends RecyclerView.Adapter 0) {
- SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), this);
+ SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
+ this, getSuggestedFileName());
} else {
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
}
@@ -1329,7 +1330,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
});
showOnMapToggle.setChecked(true);
- String displayedName = getSuggestedFileName(dir);
+ String displayedName = getSuggestedFileName();
nameEt.setText(displayedName);
nameEt.setSelection(displayedName.length());
final boolean[] textChanged = new boolean[1];
@@ -1388,17 +1389,21 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
}
- private String getSuggestedFileName(File dir) {
+ private String getSuggestedFileName() {
GpxData gpxData = editingCtx.getGpxData();
String displayedName;
if (gpxData == null) {
final String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
displayedName = suggestedName;
- File fout = new File(dir, suggestedName + GPX_FILE_EXT);
- int ind = 0;
- while (fout.exists()) {
- displayedName = suggestedName + "_" + (++ind);
- fout = new File(dir, displayedName + GPX_FILE_EXT);
+ OsmandApplication app = getMyApplication();
+ if (app != null) {
+ File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
+ File fout = new File(dir, suggestedName + GPX_FILE_EXT);
+ int ind = 0;
+ while (fout.exists()) {
+ displayedName = suggestedName + "_" + (++ind);
+ fout = new File(dir, displayedName + GPX_FILE_EXT);
+ }
}
} else {
displayedName = AndroidUtils.trimExtension(new File(gpxData.getGpxFile().path).getName());
@@ -1639,7 +1644,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return;
}
final GpxData gpxData = editingCtx.getGpxData();
- String fileName = getSuggestedFileName(mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR));
+ String fileName = getSuggestedFileName();
String actionStr = getString(R.string.plan_route);
boolean editMode = isInEditMode();
if (editMode) {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java
index ba69f3ed02..c0b574566a 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java
@@ -13,6 +13,7 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
+import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import net.osmand.AndroidUtils;
@@ -33,10 +34,14 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
public static final String TAG = SaveAsNewTrackBottomSheetDialogFragment.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(SaveAsNewTrackBottomSheetDialogFragment.class);
+ public static final String SHOW_ON_MAP_KEY = "show_on_map_key";
+ public static final String SIMPLIFIED_TRACK_KEY = "simplified_track_key";
+ public static final String FOLDER_NAME_KEY = "folder_name_key";
boolean showOnMap;
boolean simplifiedTrack;
String fileName;
+ String folderName;
@Override
public void createMenuItems(Bundle savedInstanceState) {
@@ -44,11 +49,16 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
if (app == null) {
return;
}
+ if (savedInstanceState != null) {
+ showOnMap = savedInstanceState.getBoolean(SHOW_ON_MAP_KEY);
+ simplifiedTrack = savedInstanceState.getBoolean(SIMPLIFIED_TRACK_KEY);
+ folderName = savedInstanceState.getString(FOLDER_NAME_KEY);
+ }
int activeColorRes = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
items.add(new TitleItem(getString(R.string.shared_string_save_as_gpx)));
- View editNameView = UiUtilities.getInflater(app, nightMode).inflate(R.layout.markers_track_name_edit_text,
+ View editNameView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.track_name_edit_text,
null, false);
TextInputLayout nameTextBox = editNameView.findViewById(R.id.name_text_box);
nameTextBox.setBoxBackgroundColorResource(R.color.material_text_input_layout_bg);
@@ -56,9 +66,8 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat
.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light));
nameTextBox.setDefaultHintTextColor(colorStateList);
- if (nameTextBox.getEditText() != null) {
- AndroidUtils.setHintTextSecondaryColor(app, nameTextBox.getEditText(), nightMode);
- }
+ TextInputEditText nameText = editNameView.findViewById(R.id.name_edit_text);
+ nameText.setText(fileName);
BaseBottomSheetItem editFileName = new BaseBottomSheetItem.Builder()
.setCustomView(editNameView)
.create();
@@ -70,7 +79,8 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
items.add(new DividerSpaceItem(app, contentPaddingSmall));
- FolderListAdapter adapter = new FolderListAdapter(app, nightMode);
+ FolderListAdapter adapter = new FolderListAdapter(app, nightMode, folderName);
+ adapter.setListener(createFolderSelectListener());
View view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.bottom_sheet_item_recyclerview,
null, false);
View recyclerView = view.findViewById(R.id.recycler_view);
@@ -131,11 +141,29 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
items.add(new DividerSpaceItem(app, contentPaddingSmall));
}
- public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment) {
+ private FolderListAdapter.FolderListAdapterListener createFolderSelectListener() {
+ return new FolderListAdapter.FolderListAdapterListener() {
+ @Override
+ public void onItemSelected(String item) {
+ folderName = item;
+ }
+ };
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putBoolean(SHOW_ON_MAP_KEY, showOnMap);
+ outState.putBoolean(SIMPLIFIED_TRACK_KEY, simplifiedTrack);
+ outState.putString(FOLDER_NAME_KEY, folderName);
+ super.onSaveInstanceState(outState);
+ }
+
+ public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment, String fileName) {
try {
if (!fm.isStateSaved()) {
SaveAsNewTrackBottomSheetDialogFragment fragment = new SaveAsNewTrackBottomSheetDialogFragment();
fragment.setTargetFragment(targetFragment, 0);
+ fragment.fileName = fileName;
fragment.show(fm, TAG);
}
} catch (RuntimeException e) {