commit
985327588d
8 changed files with 412 additions and 183 deletions
201
OsmAnd/res/layout/send_gpx_fragment.xml
Normal file
201
OsmAnd/res/layout/send_gpx_fragment.xml
Normal file
|
@ -0,0 +1,201 @@
|
||||||
|
<?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="match_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"
|
||||||
|
android:text="osmand" />
|
||||||
|
|
||||||
|
</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:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="@string/gpx_visibility_txt" />
|
||||||
|
|
||||||
|
</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>
|
|
@ -1,76 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:stretchColumns="1">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/DescriptionTextTop"
|
|
||||||
android:textSize="@dimen/default_list_text_size_large"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:text="@string/send_files_to_osm"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
|
|
||||||
<TableRow android:layout_width="fill_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/TextView"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:text="@string/shared_string_description"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/memory_size"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:minLines="3"
|
|
||||||
android:text=""
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:layout_marginEnd="5dp" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow android:layout_width="fill_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:text="@string/gpx_tags_txt"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/TagsText"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:text="osmand"
|
|
||||||
android:layout_marginEnd="5dp"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow android:layout_width="fill_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:text="@string/gpx_visibility_txt"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/Visibility"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:layout_marginEnd="5dp"
|
|
||||||
android:layout_marginStart="5dp" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
|
|
||||||
</TableLayout>
|
|
|
@ -11,6 +11,12 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="gpx_upload_trackable_visibility_descr">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="gpx_upload_identifiable_visibility_descr">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="gpx_upload_private_visibility_descr">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="gpx_upload_public_visibility_descr">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="markers_history">Markers history</string>
|
<string name="markers_history">Markers history</string>
|
||||||
<string name="subscription_on_hold_title">OsmAnd Live subscription is on hold</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_paused_title">OsmAnd Live subscription has been paused</string>
|
||||||
|
@ -23,11 +29,11 @@
|
||||||
<string name="use_login_password">Use login and password</string>
|
<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="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 don’t show in OsmAnd.</string>
|
<string name="osm_edits_view_descr">You can view all your unloaded edits or OSM bugs in %1$s. Uploaded points don’t 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_org">Login to OpenStreetMap.org</string>
|
||||||
<string name="login_open_street_map">Login to OpenStreetMap</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="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_travel">Travel</string>
|
||||||
<string name="icon_group_emergency">Emergency</string>
|
<string name="icon_group_emergency">Emergency</string>
|
||||||
<string name="icon_group_sport">Sport</string>
|
<string name="icon_group_sport">Sport</string>
|
||||||
|
|
|
@ -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<T extends IEnumWithResource>
|
|
||||||
extends ArrayAdapter<T>
|
|
||||||
{
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -67,7 +67,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getThirdBottomButtonTextId() {
|
protected int getThirdBottomButtonTextId() {
|
||||||
return R.string.sing_in_with_open_street_map;
|
return R.string.sign_in_with_open_street_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,18 +6,14 @@ import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
@ -34,8 +30,6 @@ import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
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.MapActivity;
|
||||||
import net.osmand.plus.activities.TabActivity;
|
import net.osmand.plus.activities.TabActivity;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
|
@ -45,6 +39,7 @@ import net.osmand.plus.myplaces.AvailableGPXFragment;
|
||||||
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.osmedit.OsmPoint.Action;
|
import net.osmand.plus.osmedit.OsmPoint.Action;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.SendGpxBottomSheetFragment;
|
||||||
import net.osmand.plus.quickaction.QuickActionType;
|
import net.osmand.plus.quickaction.QuickActionType;
|
||||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
@ -437,24 +432,34 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UploadVisibility implements IEnumWithResource {
|
public enum UploadVisibility {
|
||||||
Public(R.string.gpxup_public),
|
PUBLIC(R.string.gpxup_public, R.string.gpx_upload_public_visibility_descr),
|
||||||
Identifiable(R.string.gpxup_identifiable),
|
IDENTIFIABLE(R.string.gpxup_identifiable, R.string.gpx_upload_identifiable_visibility_descr),
|
||||||
Trackable(R.string.gpxup_trackable),
|
TRACKABLE(R.string.gpxup_trackable, R.string.gpx_upload_trackable_visibility_descr),
|
||||||
Private(R.string.gpxup_private);
|
PRIVATE(R.string.gpxup_private, R.string.gpx_upload_private_visibility_descr);
|
||||||
private final int resourceId;
|
|
||||||
|
|
||||||
UploadVisibility(int resourceId) {
|
@StringRes
|
||||||
this.resourceId = resourceId;
|
private final int titleId;
|
||||||
|
@StringRes
|
||||||
|
private final int descriptionId;
|
||||||
|
|
||||||
|
UploadVisibility(int titleId, int descriptionId) {
|
||||||
|
this.titleId = titleId;
|
||||||
|
this.descriptionId = descriptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String asURLparam() {
|
public String asURLparam() {
|
||||||
return name().toLowerCase();
|
return name().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@StringRes
|
||||||
public int stringResource() {
|
public int getTitleId() {
|
||||||
return resourceId;
|
return titleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
public int getDescriptionId() {
|
||||||
|
return descriptionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,35 +470,10 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
if ((Algorithms.isEmpty(name) || Algorithms.isEmpty(pwd)) && Algorithms.isEmpty(authToken)) {
|
if ((Algorithms.isEmpty(name) || Algorithms.isEmpty(pwd)) && Algorithms.isEmpty(authToken)) {
|
||||||
LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment());
|
LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment());
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
SendGpxBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), fragment.getTargetFragment(), info);
|
||||||
|
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
|
@Override
|
||||||
|
|
|
@ -1,29 +1,36 @@
|
||||||
package net.osmand.plus.osmedit;
|
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.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin.UploadVisibility;
|
import net.osmand.plus.osmedit.OsmEditingPlugin.UploadVisibility;
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.AsyncTask;
|
import java.io.File;
|
||||||
import android.widget.Toast;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
public class UploadGPXFilesTask extends AsyncTask<GpxInfo, String, String> {
|
public class UploadGPXFilesTask extends AsyncTask<GpxInfo, String, String> {
|
||||||
|
|
||||||
|
private final OsmandApplication app;
|
||||||
|
private final WeakReference<Activity> activityRef;
|
||||||
|
|
||||||
private final String visibility;
|
private final String visibility;
|
||||||
private final String description;
|
private final String description;
|
||||||
private final String tagstring;
|
private final String tagstring;
|
||||||
private Activity la;
|
|
||||||
|
|
||||||
public UploadGPXFilesTask(Activity la,
|
public UploadGPXFilesTask(@NonNull Activity activity, String description, String tagsString,
|
||||||
String description, String tagstring, UploadVisibility visibility) {
|
@Nullable UploadVisibility visibility) {
|
||||||
this.la = la;
|
app = (OsmandApplication) activity.getApplication();
|
||||||
|
this.activityRef = new WeakReference<>(activity);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.tagstring = tagstring;
|
this.tagstring = tagsString;
|
||||||
this.visibility = visibility != null ? visibility.asURLparam() : UploadVisibility.Private.asURLparam();
|
this.visibility = visibility != null ? visibility.asURLparam() : UploadVisibility.PRIVATE.asURLparam();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,10 +39,9 @@ public class UploadGPXFilesTask extends AsyncTask<GpxInfo, String, String> {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (GpxInfo info : params) {
|
for (GpxInfo info : params) {
|
||||||
if (!isCancelled() && info.file != null) {
|
if (!isCancelled() && info.file != null) {
|
||||||
String warning = null;
|
|
||||||
File file = info.file;
|
File file = info.file;
|
||||||
warning = new OpenstreetmapRemoteUtil((OsmandApplication) la.getApplication()).uploadGPXFile(tagstring, description, visibility,
|
OpenstreetmapRemoteUtil remoteUtil = new OpenstreetmapRemoteUtil(app);
|
||||||
file);
|
String warning = remoteUtil.uploadGPXFile(tagstring, description, visibility, file);
|
||||||
total++;
|
total++;
|
||||||
if (warning == null) {
|
if (warning == null) {
|
||||||
count++;
|
count++;
|
||||||
|
@ -44,7 +50,7 @@ public class UploadGPXFilesTask extends AsyncTask<GpxInfo, String, String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return la.getString(R.string.local_index_items_uploaded, count, total);
|
return app.getString(R.string.local_index_items_uploaded, count, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,19 +63,24 @@ public class UploadGPXFilesTask extends AsyncTask<GpxInfo, String, String> {
|
||||||
}
|
}
|
||||||
b.append(values[i]);
|
b.append(values[i]);
|
||||||
}
|
}
|
||||||
Toast.makeText(la, b.toString(), Toast.LENGTH_LONG).show();
|
app.showToastMessage(b.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
la.setProgressBarIndeterminateVisibility(true);
|
Activity activity = activityRef.get();
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
|
activity.setProgressBarIndeterminateVisibility(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String result) {
|
protected void onPostExecute(String result) {
|
||||||
la.setProgressBarIndeterminateVisibility(false);
|
Activity activity = activityRef.get();
|
||||||
Toast.makeText(la, result, Toast.LENGTH_LONG).show();
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
|
activity.setProgressBarIndeterminateVisibility(false);
|
||||||
|
}
|
||||||
|
app.showToastMessage(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
package net.osmand.plus.osmedit.dialogs;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
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.FragmentActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
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.UiUtilities.DialogButtonType;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = SendGpxBottomSheetFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
private GpxInfo[] gpxInfos;
|
||||||
|
private UploadVisibility selectedUploadVisibility = UploadVisibility.PUBLIC;
|
||||||
|
|
||||||
|
private TextInputEditText tagsField;
|
||||||
|
private TextInputEditText messageField;
|
||||||
|
|
||||||
|
public void setGpxInfos(GpxInfo[] gpxInfos) {
|
||||||
|
this.gpxInfos = gpxInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
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());
|
||||||
|
} else {
|
||||||
|
accountName.setText(settings.USER_NAME.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
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.getTitleId());
|
||||||
|
visibilityDescription.setText(selectedUploadVisibility.getDescriptionId());
|
||||||
|
|
||||||
|
List<HorizontalSelectionItem> itemsVisibility = new ArrayList<>();
|
||||||
|
for (UploadVisibility visibilityType : UploadVisibility.values()) {
|
||||||
|
String title = getString(visibilityType.getTitleId());
|
||||||
|
HorizontalSelectionItem item = new HorizontalSelectionAdapter.HorizontalSelectionItem(title, visibilityType);
|
||||||
|
itemsVisibility.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
final HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(app, nightMode);
|
||||||
|
horizontalSelectionAdapter.setItems(itemsVisibility);
|
||||||
|
horizontalSelectionAdapter.setSelectedItemByTitle(getString(selectedUploadVisibility.getTitleId()));
|
||||||
|
horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapterListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) {
|
||||||
|
selectedUploadVisibility = (OsmEditingPlugin.UploadVisibility) item.getObject();
|
||||||
|
visibilityName.setText(selectedUploadVisibility.getTitleId());
|
||||||
|
visibilityDescription.setText(selectedUploadVisibility.getDescriptionId());
|
||||||
|
horizontalSelectionAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
RecyclerView iconCategoriesRecyclerView = sendOsmPoiView.findViewById(R.id.description_view);
|
||||||
|
iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter);
|
||||||
|
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||||
|
horizontalSelectionAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder()
|
||||||
|
.setCustomView(sendOsmPoiView)
|
||||||
|
.create();
|
||||||
|
items.add(titleItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DialogButtonType getRightBottomButtonType() {
|
||||||
|
return DialogButtonType.PRIMARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_upload;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
FragmentActivity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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.setRetainInstance(true);
|
||||||
|
fragment.show(fragmentManager, TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue