This commit is contained in:
androiddevkkotlin 2020-11-10 18:25:05 +02:00
parent 17b7386514
commit 1a2eb66263
5 changed files with 345 additions and 42 deletions

View file

@ -0,0 +1,198 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_content_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/send_files_to_openstreetmap"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/message_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/bottom_sheet_content_margin"
android:hint="@string/shared_string_description"
app:boxStrokeColor="@color/osmand_orange"
app:hintTextColor="@color/text_color_secondary_light">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/message_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tags_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/bottom_sheet_content_margin"
android:hint="@string/gpx_tags_txt"
app:boxStrokeColor="@color/osmand_orange"
app:helperText="@string/enter_text_separated"
app:helperTextEnabled="true"
app:hintTextColor="@color/text_color_secondary_light">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tags_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
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:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/visibility_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
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"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/description_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:itemCount="4"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/point_editor_icon_category_item"
tools:orientation="horizontal" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/visibility_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/context_menu_first_line_top_margin"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/context_menu_first_line_top_margin"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout
android:id="@+id/account_block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/context_menu_buttons_bottom_height"
tools:background="?android:attr/selectableItemBackground">
<androidx.appcompat.widget.AppCompatImageView
android:id="@android:id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin_large"
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin"
android:tint="@color/active_buttons_and_links_text_disabled_light"
osmand:srcCompat="@drawable/ic_action_user_account" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/account_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:singleLine="true"
android:text="@string/login_account"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -11,6 +11,12 @@
Thx - Hardy
-->
<string name="trackable_visibility">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.</string>
<string name="identifiable_visibility">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.</string>
<string name="private_visibility">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.</string>
<string name="public_visibility">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.</string>
<string name="enter_text_separated">Enter tags separated by comma.</string>
<string name="send_files_to_openstreetmap">Send GPX file to OpenStreetMap</string>
<string name="subscription_on_hold_title">OsmAnd Live subscription is on hold</string>
<string name="subscription_paused_title">OsmAnd Live subscription has been paused</string>
<string name="subscription_expired_title">OsmAnd Live subscription has been expired</string>
@ -22,11 +28,11 @@
<string name="use_login_password">Use login and password</string>
<string name="open_street_map_login_mode">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.</string>
<string name="osm_edits_view_descr">You can view all your unloaded edits or OSM bugs in %1$s. Uploaded points dont show in OsmAnd.</string>
<string name="sing_in_with_open_street_map">Sing in with OpenStreetMap</string>
<string name="sign_in_with_open_street_map">Sign in with OpenStreetMap</string>
<string name="login_open_street_map_org">Login to OpenStreetMap.org</string>
<string name="login_open_street_map">Login to OpenStreetMap</string>
<string name="plugin_global_prefs_info">These plugin setting are global, and apply to all profiles</string>
<string name="message_you_need_add_two_points_to_show_graphs">You must add at least two points.</string>
<string name="message_you_need_add_two_points_to_show_graphs">You need to add at least two points</string>
<string name="icon_group_travel">Travel</string>
<string name="icon_group_emergency">Emergency</string>
<string name="icon_group_sport">Sport</string>

View file

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

View file

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

View file

@ -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<AvailableGPXFragment.GpxInfo> 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<HorizontalSelectionAdapter.HorizontalSelectionItem> 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;
}
}