From 262b8d0084554f42f27d64ef8e1bdce6785f9790 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 31 Mar 2021 10:53:46 +0300 Subject: [PATCH] Fix #10072 --- .../osmedit/dialogs/SendGpxBottomSheetFragment.java | 10 +++++++--- .../osmand/plus/settings/backend/OsmandSettings.java | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index 2e66d01970..ae3871547e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -47,7 +47,7 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { public static final String TAG = SendGpxBottomSheetFragment.class.getSimpleName(); private GpxInfo[] gpxInfos; - private UploadVisibility selectedUploadVisibility = UploadVisibility.PUBLIC; + private UploadVisibility selectedUploadVisibility; private TextInputEditText tagsField; private TextInputEditText messageField; @@ -59,12 +59,15 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override public void createMenuItems(Bundle savedInstanceState) { OsmandApplication app = requiredMyApplication(); - OsmandSettings settings = app.getSettings(); + final OsmandSettings settings = app.getSettings(); LayoutInflater themedInflater = UiUtilities.getInflater(app, nightMode); View sendGpxView = themedInflater.inflate(R.layout.send_gpx_fragment, null); sendGpxView.getViewTreeObserver().addOnGlobalLayoutListener(getShadowLayoutListener()); + if (selectedUploadVisibility == null) { + selectedUploadVisibility = settings.OSM_UPLOAD_VISIBILITY.get(); + } tagsField = sendGpxView.findViewById(R.id.tags_field); messageField = sendGpxView.findViewById(R.id.message_field); @@ -96,8 +99,9 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { horizontalSelectionAdapter.setSelectedItemByTitle(getString(selectedUploadVisibility.getTitleId())); horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapterListener() { @Override - public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { + public void onItemSelected(HorizontalSelectionItem item) { selectedUploadVisibility = (OsmEditingPlugin.UploadVisibility) item.getObject(); + settings.OSM_UPLOAD_VISIBILITY.set(selectedUploadVisibility); visibilityName.setText(selectedUploadVisibility.getTitleId()); visibilityDescription.setText(selectedUploadVisibility.getDescriptionId()); horizontalSelectionAdapter.notifyDataSetChanged(); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index d1cd8fd622..39f3cf3d92 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -47,6 +47,7 @@ import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format; import net.osmand.plus.mapmarkers.MapMarkersMode; +import net.osmand.plus.osmedit.OsmEditingPlugin.UploadVisibility; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; @@ -1135,6 +1136,7 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference OSM_USER_NAME = new StringPreference(this, "user_name", "").makeGlobal().makeShared(); public final OsmandPreference OSM_USER_DISPLAY_NAME = new StringPreference(this, "user_display_name", "").makeGlobal().makeShared(); + public final CommonPreference OSM_UPLOAD_VISIBILITY = new EnumStringPreference<>(this, "upload_visibility", UploadVisibility.PUBLIC, UploadVisibility.values()).makeGlobal().makeShared(); public static final String BILLING_USER_DONATION_WORLD_PARAMETER = ""; public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none";