From 1a2eb6626373ea86e566932b9a2c6bc5ed32d60e Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Tue, 10 Nov 2020 18:25:05 +0200 Subject: [PATCH 1/4] test --- OsmAnd/res/layout/send_gpx_fragment.xml | 198 ++++++++++++++++++ OsmAnd/res/values/strings.xml | 10 +- .../LoginBottomSheetFragment.java | 2 +- .../osmand/plus/osmedit/OsmEditingPlugin.java | 56 ++--- .../dialogs/SendGpxBottomSheetFragment.java | 121 +++++++++++ 5 files changed, 345 insertions(+), 42 deletions(-) create mode 100644 OsmAnd/res/layout/send_gpx_fragment.xml create mode 100644 OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java diff --git a/OsmAnd/res/layout/send_gpx_fragment.xml b/OsmAnd/res/layout/send_gpx_fragment.xml new file mode 100644 index 0000000000..234ccfb9dc --- /dev/null +++ b/OsmAnd/res/layout/send_gpx_fragment.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index dc262a8b1b..8519838557 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,12 @@ Thx - Hardy --> + Trackable means that the trace will not show up in any public listings but trackpoints from it will still be available through the public GPS API with timestamps. Other users will only be able to download processed trackpoints from your trace which can\'t be associated with you directly. + Identifiable means that the trace will be shown publicly in Your GPS traces and in public GPS trace listings, i.e. other users will be able to download the raw trace and associate it with your username. Data served via the trackpoints API will reference your original trace page. Timestamps of the trace points are available through the public GPS API. + Private means that the trace will not show up in any public listings, but trackpoints from it will still be available through the public GPS API without timestamps but will not be chronologically ordered. + Public means that the trace will be shown publicly in Your GPS traces and in public GPS trace listings. Data served via the API does not reference your trace page. Timestamps of the trace points are not available through the public GPS API, and the points are not chronologically ordered. However, other users are still able to download the raw trace from the public trace list and any timestamps contained within. + Enter tags separated by comma. + Send GPX file to OpenStreetMap OsmAnd Live subscription is on hold OsmAnd Live subscription has been paused OsmAnd Live subscription has been expired @@ -22,11 +28,11 @@ Use login and password You need to login to upload new or modified changes. \n\nYou can log in using the safe OAuth method or use your login and password. You can view all your unloaded edits or OSM bugs in %1$s. Uploaded points don’t show in OsmAnd. - Sing in with OpenStreetMap + Sign in with OpenStreetMap Login to OpenStreetMap.org Login to OpenStreetMap These plugin setting are global, and apply to all profiles - You must add at least two points. + You need to add at least two points Travel Emergency Sport diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java index 44547815ce..5eed849b92 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java @@ -67,7 +67,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override protected int getThirdBottomButtonTextId() { - return R.string.sing_in_with_open_street_map; + return R.string.sign_in_with_open_street_map; } @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 71da65bf20..39ebaa4052 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -6,18 +6,14 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.graphics.Typeface; import android.graphics.drawable.Drawable; -import android.os.AsyncTask; import android.text.SpannableString; import android.text.TextUtils; import android.text.style.StyleSpan; -import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; -import android.widget.EditText; -import android.widget.Spinner; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; +import androidx.annotation.StringRes; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; @@ -34,7 +30,6 @@ import net.osmand.plus.ContextMenuItem; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; -import net.osmand.plus.activities.EnumAdapter; import net.osmand.plus.activities.EnumAdapter.IEnumWithResource; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TabActivity; @@ -45,6 +40,7 @@ import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.osmedit.OsmPoint.Action; +import net.osmand.plus.osmedit.dialogs.SendGpxBottomSheetFragment; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; @@ -438,14 +434,16 @@ public class OsmEditingPlugin extends OsmandPlugin { } public enum UploadVisibility implements IEnumWithResource { - Public(R.string.gpxup_public), - Identifiable(R.string.gpxup_identifiable), - Trackable(R.string.gpxup_trackable), - Private(R.string.gpxup_private); + Public(R.string.gpxup_public, R.string.public_visibility), + Identifiable(R.string.gpxup_identifiable, R.string.identifiable_visibility), + Trackable(R.string.gpxup_trackable, R.string.trackable_visibility), + Private(R.string.gpxup_private, R.string.private_visibility); private final int resourceId; + private final int descriptionId; - UploadVisibility(int resourceId) { + UploadVisibility(int resourceId,int descriptionId ) { this.resourceId = resourceId; + this.descriptionId = descriptionId; } public String asURLparam() { @@ -456,6 +454,11 @@ public class OsmEditingPlugin extends OsmandPlugin { public int stringResource() { return resourceId; } + + @StringRes + public int getDescriptionId() { + return descriptionId; + } } public boolean sendGPXFiles(final FragmentActivity activity, AvailableGPXFragment fragment, final GpxInfo... info) { @@ -465,35 +468,10 @@ public class OsmEditingPlugin extends OsmandPlugin { if ((Algorithms.isEmpty(name) || Algorithms.isEmpty(pwd)) && Algorithms.isEmpty(authToken)) { LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment()); return false; + } else { + SendGpxBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment()); + return true; } - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - final View view = inflater.inflate(R.layout.send_gpx_osm, null); - final EditText descr = (EditText) view.findViewById(R.id.memory_size); - if (info.length > 0 && info[0].getFileName() != null) { - int dt = info[0].getFileName().indexOf('.'); - descr.setText(info[0].getFileName().substring(0, dt)); - } - final EditText tags = (EditText) view.findViewById(R.id.TagsText); - final Spinner visibility = ((Spinner) view.findViewById(R.id.Visibility)); - EnumAdapter adapter = new EnumAdapter<>(activity, android.R.layout.simple_spinner_item, UploadVisibility.values()); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - visibility.setAdapter(adapter); - visibility.setSelection(0); - - builder.setView(view); - builder.setNegativeButton(R.string.shared_string_no, null); - builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - new UploadGPXFilesTask(activity, descr.getText().toString(), tags.getText().toString(), - (UploadVisibility) visibility.getItemAtPosition(visibility.getSelectedItemPosition()) - ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info); - } - }); - builder.show(); - return true; } @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java new file mode 100644 index 0000000000..0ad89d1504 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -0,0 +1,121 @@ +package net.osmand.plus.osmedit.dialogs; + +import android.os.AsyncTask; +import android.os.Bundle; +import android.view.ContextThemeWrapper; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.textfield.TextInputLayout; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; +import net.osmand.plus.myplaces.AvailableGPXFragment; +import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.plus.osmedit.UploadGPXFilesTask; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.util.Algorithms; + +import java.util.ArrayList; +import java.util.List; + +public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { + + public static final String TAG = "SendGpxBottomSheetFragment"; + + protected OsmandSettings settings; + + private OsmEditingPlugin.UploadVisibility uploadVisibility; + private List info; + private String selectedVisibilityType; + + protected OsmandApplication getMyApplication() { + return (OsmandApplication) getActivity().getApplication(); + } + + private boolean isLoginOAuth() { + return !Algorithms.isEmpty(getMyApplication().getSettings().USER_DISPLAY_NAME.get()); + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + final View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_gpx_fragment, null); + final TextView accountName = sendOsmPoiView.findViewById(R.id.user_name); + settings = getMyApplication().getSettings(); + String userNameOAuth = settings.USER_DISPLAY_NAME.get(); + String userNameOpenID = settings.USER_NAME.get(); + String userName = isLoginOAuth() ? userNameOAuth : userNameOpenID; + accountName.setText(userName); + final TextView visibilityName = sendOsmPoiView.findViewById(R.id.visibility_name); + final TextView visibilityDescription = sendOsmPoiView.findViewById(R.id.visibility_description); + HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(getMyApplication(), nightMode); + List itemsVisibility = new ArrayList<>(); + for (OsmEditingPlugin.UploadVisibility visibilityType : OsmEditingPlugin.UploadVisibility.values()) { + String title = getMyApplication().getString(visibilityType.stringResource()); + HorizontalSelectionAdapter.HorizontalSelectionItem item = new HorizontalSelectionAdapter.HorizontalSelectionItem(title, visibilityType); + itemsVisibility.add(item); + } + horizontalSelectionAdapter.setItems(itemsVisibility); +// horizontalSelectionAdapter.setSelectedItemByTitle(selectedVisibilityType); + horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapter.HorizontalSelectionAdapterListener() { + @Override + public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { + uploadVisibility = (OsmEditingPlugin.UploadVisibility) item.getObject(); + visibilityName.setText(uploadVisibility.stringResource()); + visibilityDescription.setText(uploadVisibility.getDescriptionId()); + } + + }); + RecyclerView iconCategoriesRecyclerView = sendOsmPoiView.findViewById(R.id.description_view); + iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); + iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(getMyApplication(), RecyclerView.HORIZONTAL, false)); + horizontalSelectionAdapter.notifyDataSetChanged(); + + final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(sendOsmPoiView) + .create(); + items.add(titleItem); + } + + public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment, final AvailableGPXFragment.GpxInfo... info) { + if (!fragmentManager.isStateSaved()) { + SendGpxBottomSheetFragment fragment = new SendGpxBottomSheetFragment(); + fragment.setTargetFragment(targetFragment, 0); + fragment.show(fragmentManager, TAG); + } + } + + @Override + protected UiUtilities.DialogButtonType getRightBottomButtonType() { + return (UiUtilities.DialogButtonType.PRIMARY); + } + + @Override + protected void onRightBottomButtonClick() { + final View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_gpx_fragment, null); + final TextInputLayout descr = sendOsmPoiView.findViewById(R.id.message_field); + final TextInputLayout tags = sendOsmPoiView.findViewById(R.id.tags_field); + +// new UploadGPXFilesTask(getActivity(), descr.getEditText().toString(), tags.getEditText().toString(), +// uploadVisibility +// ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info); + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_upload; + } + +} + From c80a358b45320edcf4f1204d798069f7bda5e243 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Wed, 11 Nov 2020 00:12:17 +0200 Subject: [PATCH 2/4] OSM Renovation - Send GPX Final --- .../osmand/plus/osmedit/OsmEditingPlugin.java | 2 +- .../dialogs/SendGpxBottomSheetFragment.java | 123 +++++++++++------- 2 files changed, 74 insertions(+), 51 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 39ebaa4052..d8f1ac1423 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -469,7 +469,7 @@ public class OsmEditingPlugin extends OsmandPlugin { LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment()); return false; } else { - SendGpxBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment()); + SendGpxBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment(), info); return true; } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index 0ad89d1504..6b3476670c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -9,20 +9,23 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.textfield.TextInputLayout; +import com.google.android.material.textfield.TextInputEditText; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; -import net.osmand.plus.myplaces.AvailableGPXFragment; +import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; +import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem; +import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.plus.osmedit.OsmEditingPlugin.UploadVisibility; import net.osmand.plus.osmedit.UploadGPXFilesTask; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.util.Algorithms; @@ -32,68 +35,79 @@ import java.util.List; public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { - public static final String TAG = "SendGpxBottomSheetFragment"; + public static final String TAG = SendGpxBottomSheetFragment.class.getSimpleName(); - protected OsmandSettings settings; + private GpxInfo[] gpxInfos; + private UploadVisibility selectedUploadVisibility = UploadVisibility.Public; - private OsmEditingPlugin.UploadVisibility uploadVisibility; - private List info; - private String selectedVisibilityType; + private TextInputEditText tagsField; + private TextInputEditText messageField; - protected OsmandApplication getMyApplication() { - return (OsmandApplication) getActivity().getApplication(); - } - - private boolean isLoginOAuth() { - return !Algorithms.isEmpty(getMyApplication().getSettings().USER_DISPLAY_NAME.get()); + public void setGpxInfos(GpxInfo[] gpxInfos) { + this.gpxInfos = gpxInfos; } @Override public void createMenuItems(Bundle savedInstanceState) { - final View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_gpx_fragment, null); - final TextView accountName = sendOsmPoiView.findViewById(R.id.user_name); - settings = getMyApplication().getSettings(); - String userNameOAuth = settings.USER_DISPLAY_NAME.get(); - String userNameOpenID = settings.USER_NAME.get(); - String userName = isLoginOAuth() ? userNameOAuth : userNameOpenID; - accountName.setText(userName); + View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_gpx_fragment, null); + + messageField = sendOsmPoiView.findViewById(R.id.message_field); + tagsField = sendOsmPoiView.findViewById(R.id.tags_field); + + OsmandSettings settings = requiredMyApplication().getSettings(); + + TextView accountName = sendOsmPoiView.findViewById(R.id.user_name); + if (!Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get())) { + accountName.setText(settings.USER_DISPLAY_NAME.get()); + } else { + accountName.setText(settings.USER_NAME.get()); + } + + if (gpxInfos.length > 0 && gpxInfos[0].getFileName() != null) { + int dt = gpxInfos[0].getFileName().indexOf('.'); + messageField.setText(gpxInfos[0].getFileName().substring(0, dt)); + } + tagsField.setText(R.string.app_name_osmand); + final TextView visibilityName = sendOsmPoiView.findViewById(R.id.visibility_name); final TextView visibilityDescription = sendOsmPoiView.findViewById(R.id.visibility_description); - HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(getMyApplication(), nightMode); - List itemsVisibility = new ArrayList<>(); - for (OsmEditingPlugin.UploadVisibility visibilityType : OsmEditingPlugin.UploadVisibility.values()) { - String title = getMyApplication().getString(visibilityType.stringResource()); - HorizontalSelectionAdapter.HorizontalSelectionItem item = new HorizontalSelectionAdapter.HorizontalSelectionItem(title, visibilityType); + visibilityName.setText(selectedUploadVisibility.stringResource()); + visibilityDescription.setText(selectedUploadVisibility.getDescriptionId()); + + List itemsVisibility = new ArrayList<>(); + for (UploadVisibility visibilityType : UploadVisibility.values()) { + String title = getString(visibilityType.stringResource()); + HorizontalSelectionItem item = new HorizontalSelectionAdapter.HorizontalSelectionItem(title, visibilityType); itemsVisibility.add(item); } + + final HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(getMyApplication(), nightMode); horizontalSelectionAdapter.setItems(itemsVisibility); -// horizontalSelectionAdapter.setSelectedItemByTitle(selectedVisibilityType); - horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapter.HorizontalSelectionAdapterListener() { + horizontalSelectionAdapter.setSelectedItemByTitle(getString(selectedUploadVisibility.stringResource())); + horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapterListener() { @Override public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { - uploadVisibility = (OsmEditingPlugin.UploadVisibility) item.getObject(); - visibilityName.setText(uploadVisibility.stringResource()); - visibilityDescription.setText(uploadVisibility.getDescriptionId()); + selectedUploadVisibility = (OsmEditingPlugin.UploadVisibility) item.getObject(); + visibilityName.setText(selectedUploadVisibility.stringResource()); + visibilityDescription.setText(selectedUploadVisibility.getDescriptionId()); + horizontalSelectionAdapter.notifyDataSetChanged(); } }); + RecyclerView iconCategoriesRecyclerView = sendOsmPoiView.findViewById(R.id.description_view); iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(getMyApplication(), RecyclerView.HORIZONTAL, false)); horizontalSelectionAdapter.notifyDataSetChanged(); - final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() .setCustomView(sendOsmPoiView) .create(); items.add(titleItem); } - public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment, final AvailableGPXFragment.GpxInfo... info) { - if (!fragmentManager.isStateSaved()) { - SendGpxBottomSheetFragment fragment = new SendGpxBottomSheetFragment(); - fragment.setTargetFragment(targetFragment, 0); - fragment.show(fragmentManager, TAG); - } + private boolean isLoginOAuth() { + return !Algorithms.isEmpty(getMyApplication().getSettings().USER_DISPLAY_NAME.get()); } @Override @@ -101,21 +115,30 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { return (UiUtilities.DialogButtonType.PRIMARY); } - @Override - protected void onRightBottomButtonClick() { - final View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_gpx_fragment, null); - final TextInputLayout descr = sendOsmPoiView.findViewById(R.id.message_field); - final TextInputLayout tags = sendOsmPoiView.findViewById(R.id.tags_field); - -// new UploadGPXFilesTask(getActivity(), descr.getEditText().toString(), tags.getEditText().toString(), -// uploadVisibility -// ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info); - } - @Override protected int getRightBottomButtonTextId() { return R.string.shared_string_upload; } -} + @Override + protected void onRightBottomButtonClick() { + FragmentActivity activity = getActivity(); + if (activity != null) { + String tags = tagsField.getText().toString(); + String descr = messageField.getText().toString(); + UploadGPXFilesTask uploadGPXFilesTask = new UploadGPXFilesTask(activity, descr, tags, selectedUploadVisibility); + uploadGPXFilesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, gpxInfos); + } + dismiss(); + } + + public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment, GpxInfo[] info) { + if (!fragmentManager.isStateSaved()) { + SendGpxBottomSheetFragment fragment = new SendGpxBottomSheetFragment(); + fragment.setTargetFragment(targetFragment, 0); + fragment.setGpxInfos(info); + fragment.show(fragmentManager, TAG); + } + } +} \ No newline at end of file From a6f65b066fd25f71a8647282157790561b606c0a Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Wed, 11 Nov 2020 12:20:22 +0200 Subject: [PATCH 3/4] Refactor: enum, unnecessary method, delete unnecessary files, screen rotate support, null fix, strinf name fix --- OsmAnd/res/layout/send_gpx_fragment.xml | 5 +- OsmAnd/res/layout/send_gpx_osm.xml | 76 ------------------- OsmAnd/res/values/strings.xml | 8 +- .../osmand/plus/activities/EnumAdapter.java | 38 ---------- .../osmand/plus/osmedit/OsmEditingPlugin.java | 26 ++++--- .../plus/osmedit/UploadGPXFilesTask.java | 2 +- .../dialogs/SendGpxBottomSheetFragment.java | 42 +++++----- 7 files changed, 44 insertions(+), 153 deletions(-) delete mode 100644 OsmAnd/res/layout/send_gpx_osm.xml delete mode 100644 OsmAnd/src/net/osmand/plus/activities/EnumAdapter.java diff --git a/OsmAnd/res/layout/send_gpx_fragment.xml b/OsmAnd/res/layout/send_gpx_fragment.xml index 234ccfb9dc..333030a190 100644 --- a/OsmAnd/res/layout/send_gpx_fragment.xml +++ b/OsmAnd/res/layout/send_gpx_fragment.xml @@ -59,7 +59,8 @@ android:id="@+id/tags_field" android:layout_width="match_parent" android:layout_height="wrap_content" - android:imeOptions="actionDone" /> + android:imeOptions="actionDone" + android:text="osmand"/> @@ -98,9 +99,9 @@ android:paddingTop="@dimen/context_menu_first_line_top_margin" android:paddingRight="@dimen/content_padding" android:paddingBottom="@dimen/context_menu_first_line_top_margin" - android:text="@string/gpx_visibility_txt" android:textColor="?android:textColorSecondary" android:textSize="@dimen/default_desc_text_size" + tools:text="@string/gpx_visibility_txt" osmand:typeface="@string/font_roboto_medium" /> diff --git a/OsmAnd/res/layout/send_gpx_osm.xml b/OsmAnd/res/layout/send_gpx_osm.xml deleted file mode 100644 index 2fd9794b7f..0000000000 --- a/OsmAnd/res/layout/send_gpx_osm.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 8519838557..ffb7b686d8 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,10 +11,10 @@ Thx - Hardy --> - Trackable means that the trace will not show up in any public listings but trackpoints from it will still be available through the public GPS API with timestamps. Other users will only be able to download processed trackpoints from your trace which can\'t be associated with you directly. - Identifiable means that the trace will be shown publicly in Your GPS traces and in public GPS trace listings, i.e. other users will be able to download the raw trace and associate it with your username. Data served via the trackpoints API will reference your original trace page. Timestamps of the trace points are available through the public GPS API. - Private means that the trace will not show up in any public listings, but trackpoints from it will still be available through the public GPS API without timestamps but will not be chronologically ordered. - Public means that the trace will be shown publicly in Your GPS traces and in public GPS trace listings. Data served via the API does not reference your trace page. Timestamps of the trace points are not available through the public GPS API, and the points are not chronologically ordered. However, other users are still able to download the raw trace from the public trace list and any timestamps contained within. + Trackable means that the trace will not show up in any public listings but trackpoints from it will still be available through the public GPS API with timestamps. Other users will only be able to download processed trackpoints from your trace which can\'t be associated with you directly. + Identifiable means that the trace will be shown publicly in Your GPS traces and in public GPS trace listings, i.e. other users will be able to download the raw trace and associate it with your username. Data served via the trackpoints API will reference your original trace page. Timestamps of the trace points are available through the public GPS API. + Private means that the trace will not show up in any public listings, but trackpoints from it will still be available through the public GPS API without timestamps but will not be chronologically ordered. + Public means that the trace will be shown publicly in Your GPS traces and in public GPS trace listings. Data served via the API does not reference your trace page. Timestamps of the trace points are not available through the public GPS API, and the points are not chronologically ordered. However, other users are still able to download the raw trace from the public trace list and any timestamps contained within. Enter tags separated by comma. Send GPX file to OpenStreetMap OsmAnd Live subscription is on hold diff --git a/OsmAnd/src/net/osmand/plus/activities/EnumAdapter.java b/OsmAnd/src/net/osmand/plus/activities/EnumAdapter.java deleted file mode 100644 index 519952b8e3..0000000000 --- a/OsmAnd/src/net/osmand/plus/activities/EnumAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.osmand.plus.activities; - -import net.osmand.plus.activities.EnumAdapter.IEnumWithResource; -import android.content.Context; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.TextView; - -public class EnumAdapter - extends ArrayAdapter -{ - - public EnumAdapter(Context context, int textViewResourceId, T[] enums) - { - super(context, textViewResourceId, enums); - } - - @Override - public View getDropDownView(int position, View convertView, ViewGroup parent) { - TextView textView = (TextView) super.getDropDownView(position, convertView, parent); - T item = getItem(position); - textView.setText(item.stringResource()); - return textView; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - TextView textView = (TextView) super.getView(position, convertView, parent); - T item = getItem(position); - textView.setText(item.stringResource()); - return textView; - } - - public static interface IEnumWithResource { - int stringResource(); - } -} diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index d8f1ac1423..3b11e7a309 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -30,7 +30,6 @@ import net.osmand.plus.ContextMenuItem; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; -import net.osmand.plus.activities.EnumAdapter.IEnumWithResource; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TabActivity; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; @@ -433,16 +432,19 @@ public class OsmEditingPlugin extends OsmandPlugin { } } - public enum UploadVisibility implements IEnumWithResource { - Public(R.string.gpxup_public, R.string.public_visibility), - Identifiable(R.string.gpxup_identifiable, R.string.identifiable_visibility), - Trackable(R.string.gpxup_trackable, R.string.trackable_visibility), - Private(R.string.gpxup_private, R.string.private_visibility); - private final int resourceId; + public enum UploadVisibility { + PUBLIC(R.string.gpxup_public, R.string.gpx_upload_public_visibility_descr), + IDENTIFIABLE(R.string.gpxup_identifiable, R.string.gpx_upload_identifiable_visibility_descr), + TRACKABLE(R.string.gpxup_trackable, R.string.gpx_upload_trackable_visibility_descr), + PRIVATE(R.string.gpxup_private, R.string.gpx_upload_private_visibility_descr); + + @StringRes + private final int titleId; + @StringRes private final int descriptionId; - UploadVisibility(int resourceId,int descriptionId ) { - this.resourceId = resourceId; + UploadVisibility(int titleId, int descriptionId) { + this.titleId = titleId; this.descriptionId = descriptionId; } @@ -450,9 +452,9 @@ public class OsmEditingPlugin extends OsmandPlugin { return name().toLowerCase(); } - @Override - public int stringResource() { - return resourceId; + @StringRes + public int getTitleId() { + return titleId; } @StringRes diff --git a/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java b/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java index c49b49aad0..6f3807609a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java @@ -22,7 +22,7 @@ public class UploadGPXFilesTask extends AsyncTask { this.la = la; this.description = description; this.tagstring = tagstring; - this.visibility = visibility != null ? visibility.asURLparam() : UploadVisibility.Private.asURLparam(); + this.visibility = visibility != null ? visibility.asURLparam() : UploadVisibility.PRIVATE.asURLparam(); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index 6b3476670c..c47f757a92 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -2,7 +2,9 @@ package net.osmand.plus.osmedit.dialogs; import android.os.AsyncTask; import android.os.Bundle; +import android.text.Editable; import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; @@ -16,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.textfield.TextInputEditText; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.MenuBottomSheetDialogFragment; @@ -32,13 +35,14 @@ import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.List; +import java.util.Optional; public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { public static final String TAG = SendGpxBottomSheetFragment.class.getSimpleName(); private GpxInfo[] gpxInfos; - private UploadVisibility selectedUploadVisibility = UploadVisibility.Public; + private UploadVisibility selectedUploadVisibility = UploadVisibility.PUBLIC; private TextInputEditText tagsField; private TextInputEditText messageField; @@ -49,12 +53,14 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override public void createMenuItems(Bundle savedInstanceState) { - View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_gpx_fragment, null); + LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode); + View sendOsmPoiView = themedInflater.inflate(R.layout.send_gpx_fragment, null); messageField = sendOsmPoiView.findViewById(R.id.message_field); tagsField = sendOsmPoiView.findViewById(R.id.tags_field); - OsmandSettings settings = requiredMyApplication().getSettings(); + OsmandApplication app = requiredMyApplication(); + OsmandSettings settings = app.getSettings(); TextView accountName = sendOsmPoiView.findViewById(R.id.user_name); if (!Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get())) { @@ -63,32 +69,29 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { accountName.setText(settings.USER_NAME.get()); } - if (gpxInfos.length > 0 && gpxInfos[0].getFileName() != null) { - int dt = gpxInfos[0].getFileName().indexOf('.'); - messageField.setText(gpxInfos[0].getFileName().substring(0, dt)); - } - tagsField.setText(R.string.app_name_osmand); + String fileName = gpxInfos[0].getFileName(); + messageField.setText(Algorithms.getFileNameWithoutExtension(fileName)); final TextView visibilityName = sendOsmPoiView.findViewById(R.id.visibility_name); final TextView visibilityDescription = sendOsmPoiView.findViewById(R.id.visibility_description); - visibilityName.setText(selectedUploadVisibility.stringResource()); + visibilityName.setText(selectedUploadVisibility.getTitleId()); visibilityDescription.setText(selectedUploadVisibility.getDescriptionId()); List itemsVisibility = new ArrayList<>(); for (UploadVisibility visibilityType : UploadVisibility.values()) { - String title = getString(visibilityType.stringResource()); + String title = getString(visibilityType.getTitleId()); HorizontalSelectionItem item = new HorizontalSelectionAdapter.HorizontalSelectionItem(title, visibilityType); itemsVisibility.add(item); } - final HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(getMyApplication(), nightMode); + final HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(app, nightMode); horizontalSelectionAdapter.setItems(itemsVisibility); - horizontalSelectionAdapter.setSelectedItemByTitle(getString(selectedUploadVisibility.stringResource())); + horizontalSelectionAdapter.setSelectedItemByTitle(getString(selectedUploadVisibility.getTitleId())); horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapterListener() { @Override public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { selectedUploadVisibility = (OsmEditingPlugin.UploadVisibility) item.getObject(); - visibilityName.setText(selectedUploadVisibility.stringResource()); + visibilityName.setText(selectedUploadVisibility.getTitleId()); visibilityDescription.setText(selectedUploadVisibility.getDescriptionId()); horizontalSelectionAdapter.notifyDataSetChanged(); } @@ -97,17 +100,14 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { RecyclerView iconCategoriesRecyclerView = sendOsmPoiView.findViewById(R.id.description_view); iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); - iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(getMyApplication(), RecyclerView.HORIZONTAL, false)); + iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); horizontalSelectionAdapter.notifyDataSetChanged(); SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() .setCustomView(sendOsmPoiView) .create(); items.add(titleItem); - } - - private boolean isLoginOAuth() { - return !Algorithms.isEmpty(getMyApplication().getSettings().USER_DISPLAY_NAME.get()); + setRetainInstance(true); } @Override @@ -124,8 +124,10 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { protected void onRightBottomButtonClick() { FragmentActivity activity = getActivity(); if (activity != null) { - String tags = tagsField.getText().toString(); - String descr = messageField.getText().toString(); + Editable tagsText = tagsField.getText(); + Editable descrText = messageField.getText(); + String tags = tagsText != null ? tagsText.toString() : ""; + String descr = descrText != null ? descrText.toString() : ""; UploadGPXFilesTask uploadGPXFilesTask = new UploadGPXFilesTask(activity, descr, tags, selectedUploadVisibility); uploadGPXFilesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, gpxInfos); From ec8e778b6a6387ea1c0b322a63a5da9e6c7c0d8c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 11 Nov 2020 16:48:43 +0200 Subject: [PATCH 4/4] Small fixes in send gpx task --- OsmAnd/res/layout/send_gpx_fragment.xml | 14 +++--- .../plus/osmedit/UploadGPXFilesTask.java | 49 ++++++++++++------- .../dialogs/SendGpxBottomSheetFragment.java | 21 ++++---- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/OsmAnd/res/layout/send_gpx_fragment.xml b/OsmAnd/res/layout/send_gpx_fragment.xml index 333030a190..5e7edddd7b 100644 --- a/OsmAnd/res/layout/send_gpx_fragment.xml +++ b/OsmAnd/res/layout/send_gpx_fragment.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> @@ -27,7 +27,6 @@ android:textSize="@dimen/default_list_text_size" osmand:typeface="@string/font_roboto_medium" /> - + + android:text="osmand" /> + @@ -101,8 +102,9 @@ android:paddingBottom="@dimen/context_menu_first_line_top_margin" android:textColor="?android:textColorSecondary" android:textSize="@dimen/default_desc_text_size" - tools:text="@string/gpx_visibility_txt" - osmand:typeface="@string/font_roboto_medium" /> + osmand:typeface="@string/font_roboto_medium" + tools:text="@string/gpx_visibility_txt" /> + - + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java b/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java index 6f3807609a..7ef392acf9 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/UploadGPXFilesTask.java @@ -1,29 +1,36 @@ package net.osmand.plus.osmedit; -import java.io.File; +import android.app.Activity; +import android.os.AsyncTask; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.osmedit.OsmEditingPlugin.UploadVisibility; -import android.app.Activity; -import android.os.AsyncTask; -import android.widget.Toast; + +import java.io.File; +import java.lang.ref.WeakReference; public class UploadGPXFilesTask extends AsyncTask { + private final OsmandApplication app; + private final WeakReference activityRef; + private final String visibility; private final String description; private final String tagstring; - private Activity la; - public UploadGPXFilesTask(Activity la, - String description, String tagstring, UploadVisibility visibility) { - this.la = la; + public UploadGPXFilesTask(@NonNull Activity activity, String description, String tagsString, + @Nullable UploadVisibility visibility) { + app = (OsmandApplication) activity.getApplication(); + this.activityRef = new WeakReference<>(activity); this.description = description; - this.tagstring = tagstring; + this.tagstring = tagsString; this.visibility = visibility != null ? visibility.asURLparam() : UploadVisibility.PRIVATE.asURLparam(); - } @Override @@ -32,10 +39,9 @@ public class UploadGPXFilesTask extends AsyncTask { int total = 0; for (GpxInfo info : params) { if (!isCancelled() && info.file != null) { - String warning = null; File file = info.file; - warning = new OpenstreetmapRemoteUtil((OsmandApplication) la.getApplication()).uploadGPXFile(tagstring, description, visibility, - file); + OpenstreetmapRemoteUtil remoteUtil = new OpenstreetmapRemoteUtil(app); + String warning = remoteUtil.uploadGPXFile(tagstring, description, visibility, file); total++; if (warning == null) { count++; @@ -44,7 +50,7 @@ public class UploadGPXFilesTask extends AsyncTask { } } } - return la.getString(R.string.local_index_items_uploaded, count, total); + return app.getString(R.string.local_index_items_uploaded, count, total); } @Override @@ -57,19 +63,24 @@ public class UploadGPXFilesTask extends AsyncTask { } b.append(values[i]); } - Toast.makeText(la, b.toString(), Toast.LENGTH_LONG).show(); + app.showToastMessage(b.toString()); } } @Override protected void onPreExecute() { - la.setProgressBarIndeterminateVisibility(true); + Activity activity = activityRef.get(); + if (AndroidUtils.isActivityNotDestroyed(activity)) { + activity.setProgressBarIndeterminateVisibility(true); + } } @Override protected void onPostExecute(String result) { - la.setProgressBarIndeterminateVisibility(false); - Toast.makeText(la, result, Toast.LENGTH_LONG).show(); + Activity activity = activityRef.get(); + if (AndroidUtils.isActivityNotDestroyed(activity)) { + activity.setProgressBarIndeterminateVisibility(false); + } + app.showToastMessage(result); } - } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index c47f757a92..f9e8e6d00a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -3,7 +3,6 @@ package net.osmand.plus.osmedit.dialogs; import android.os.AsyncTask; import android.os.Bundle; import android.text.Editable; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; @@ -21,6 +20,7 @@ import com.google.android.material.textfield.TextInputEditText; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; @@ -35,7 +35,6 @@ import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.List; -import java.util.Optional; public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { @@ -53,15 +52,15 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override public void createMenuItems(Bundle savedInstanceState) { - LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode); - View sendOsmPoiView = themedInflater.inflate(R.layout.send_gpx_fragment, null); - - messageField = sendOsmPoiView.findViewById(R.id.message_field); - tagsField = sendOsmPoiView.findViewById(R.id.tags_field); - OsmandApplication app = requiredMyApplication(); OsmandSettings settings = app.getSettings(); + LayoutInflater themedInflater = UiUtilities.getInflater(app, nightMode); + View sendOsmPoiView = themedInflater.inflate(R.layout.send_gpx_fragment, null); + + tagsField = sendOsmPoiView.findViewById(R.id.tags_field); + messageField = sendOsmPoiView.findViewById(R.id.message_field); + TextView accountName = sendOsmPoiView.findViewById(R.id.user_name); if (!Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get())) { accountName.setText(settings.USER_DISPLAY_NAME.get()); @@ -107,12 +106,11 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { .setCustomView(sendOsmPoiView) .create(); items.add(titleItem); - setRetainInstance(true); } @Override - protected UiUtilities.DialogButtonType getRightBottomButtonType() { - return (UiUtilities.DialogButtonType.PRIMARY); + protected DialogButtonType getRightBottomButtonType() { + return DialogButtonType.PRIMARY; } @Override @@ -140,6 +138,7 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { SendGpxBottomSheetFragment fragment = new SendGpxBottomSheetFragment(); fragment.setTargetFragment(targetFragment, 0); fragment.setGpxInfos(info); + fragment.setRetainInstance(true); fragment.show(fragmentManager, TAG); } }