Merge pull request #5590 from osmandapp/CoordinateInputImprovements
Coordinate input improvements
This commit is contained in:
commit
24adf3b10a
13 changed files with 488 additions and 169 deletions
|
@ -50,6 +50,7 @@ public class IndexConstants {
|
||||||
public static final String MAPS_PATH = "";
|
public static final String MAPS_PATH = "";
|
||||||
public static final String BACKUP_INDEX_DIR= "backup/";
|
public static final String BACKUP_INDEX_DIR= "backup/";
|
||||||
public static final String GPX_INDEX_DIR = "tracks/";
|
public static final String GPX_INDEX_DIR = "tracks/";
|
||||||
|
public static final String MAP_MARKERS_INDEX_DIR = "/map markers";
|
||||||
public static final String GPX_RECORDED_INDEX_DIR = GPX_INDEX_DIR + "rec/";
|
public static final String GPX_RECORDED_INDEX_DIR = GPX_INDEX_DIR + "rec/";
|
||||||
public static final String GPX_IMPORT_DIR = GPX_INDEX_DIR + "import/";
|
public static final String GPX_IMPORT_DIR = GPX_INDEX_DIR + "import/";
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:background="@color/keyboard_divider_dark">
|
tools:background="@color/keyboard_divider_dark">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -98,7 +102,7 @@
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/keyboard_item_next_field"
|
android:id="@+id/keyboard_item_backspace"
|
||||||
layout="@layout/coordinate_input_keyboard_item"
|
layout="@layout/coordinate_input_keyboard_item"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -190,12 +194,29 @@
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<include
|
<LinearLayout
|
||||||
android:id="@+id/keyboard_item_backspace"
|
android:layout_width="0dp"
|
||||||
layout="@layout/coordinate_input_keyboard_item"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="0dp"
|
android:layout_weight="1"
|
||||||
android:layout_height="match_parent"
|
android:orientation="vertical">
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/keyboard_item_next_field"
|
||||||
|
layout="@layout/coordinate_input_keyboard_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/coords_input_keyboard_item_height"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"/>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/keyboard_item_hide"
|
||||||
|
layout="@layout/coordinate_input_keyboard_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/coords_input_keyboard_item_height"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/data_area"
|
android:id="@+id/data_area"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -24,54 +25,59 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/bottom_controls_container"
|
android:id="@+id/bottom_controls_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp">
|
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||||
|
android:background="?attr/wikivoyage_bottom_bar_bg_color">
|
||||||
|
|
||||||
<ImageView
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/show_hide_keyboard_icon_left"
|
android:id="@+id/cancel_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginBottom="@dimen/route_info_button_go_margin"
|
android:layout_weight="0"
|
||||||
android:layout_marginLeft="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_marginStart="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_marginTop="@dimen/route_info_button_go_margin"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingLeft="@dimen/coords_input_show_hide_keyboard_btn_padding"
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:paddingRight="@dimen/coords_input_show_hide_keyboard_btn_padding"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:src="@drawable/ic_action_keyboard_hide"
|
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatTextView
|
|
||||||
android:id="@+id/add_marker_button"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_margin="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center_vertical"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="@string/shared_string_add"
|
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||||
android:textAllCaps="true"
|
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||||
android:textColor="@color/keyboard_item_button_text_color"
|
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||||
android:textStyle="bold"
|
android:text="@string/shared_string_cancel"
|
||||||
tools:background="@drawable/route_info_go_btn_bg_dark"/>
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<ImageView
|
<View
|
||||||
android:id="@+id/show_hide_keyboard_icon_right"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginBottom="@dimen/route_info_button_go_margin"
|
android:layout_weight="1"/>
|
||||||
android:layout_marginEnd="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_marginRight="@dimen/route_info_button_go_margin"
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_marginTop="@dimen/route_info_button_go_margin"
|
android:id="@+id/add_marker_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical|end"
|
||||||
|
android:layout_weight="0"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingLeft="@dimen/coords_input_show_hide_keyboard_btn_padding"
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:paddingRight="@dimen/coords_input_show_hide_keyboard_btn_padding"
|
android:ellipsize="end"
|
||||||
tools:src="@drawable/ic_action_keyboard_hide"/>
|
android:gravity="center_vertical|end"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:drawableRight="@drawable/ic_action_type_add"
|
||||||
|
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||||
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:text="@string/shared_string_add" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,6 @@
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/coordinate_input_keyboard"/>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/keyboard_divider"
|
android:id="@+id/keyboard_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -106,41 +104,65 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/bottom_controls_container"
|
android:id="@+id/bottom_controls_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp">
|
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||||
|
android:background="?attr/wikivoyage_bottom_bar_bg_color">
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatTextView
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/add_marker_button"
|
android:id="@+id/cancel_button"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginBottom="@dimen/route_info_button_go_margin"
|
android:layout_weight="0"
|
||||||
android:layout_marginLeft="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_marginStart="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_marginTop="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_weight="3"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text="@string/shared_string_add"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="@color/keyboard_item_button_text_color"
|
|
||||||
android:textSize="@dimen/default_list_text_size"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:background="@drawable/route_info_go_btn_bg_dark"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/show_hide_keyboard_icon"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_margin="@dimen/route_info_button_go_margin"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:scaleType="center"
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
tools:src="@drawable/ic_action_keyboard_hide"/>
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:text="@string/shared_string_cancel"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/add_marker_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical|end"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical|end"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:drawableRight="@drawable/ic_action_type_add"
|
||||||
|
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||||
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:text="@string/shared_string_add" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/coordinate_input_keyboard"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
osmand:typeface="@string/font_roboto_medium"/>
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/save_as_track_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/bottom_sheet_descr_height"
|
android:layout_height="@dimen/bottom_sheet_descr_height"
|
||||||
android:paddingEnd="@dimen/content_padding"
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="coord_input_edit_point">Edit point</string>
|
||||||
|
<string name="coord_input_add_point">Add point</string>
|
||||||
|
<string name="coord_input_save_as_track">Save as track</string>
|
||||||
|
<string name="coord_input_save_as_track_descr">You added %1$s points. Enter the name of the file and click save.</string>
|
||||||
<string name="error_notification_desc">Please send screenshoot of this notification to support@osmand.net</string>
|
<string name="error_notification_desc">Please send screenshoot of this notification to support@osmand.net</string>
|
||||||
<string name="quick_action_edit_actions">Edit actions</string>
|
<string name="quick_action_edit_actions">Edit actions</string>
|
||||||
<string name="get_osmand_live">Get OsmAnd Live to unlock all features: Daily map updates with unlimited downloads, all paid and free plugins, Wikipedia, Wikivoyage and much more.</string>
|
<string name="get_osmand_live">Get OsmAnd Live to unlock all features: Daily map updates with unlimited downloads, all paid and free plugins, Wikipedia, Wikivoyage and much more.</string>
|
||||||
|
|
|
@ -995,7 +995,30 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateGpx(String fileName) {
|
public String generateGpx(String fileName) {
|
||||||
final File dir = ctx.getAppPath(IndexConstants.GPX_INDEX_DIR + "/map markers");
|
final File dir = ctx.getAppPath(IndexConstants.GPX_INDEX_DIR + IndexConstants.MAP_MARKERS_INDEX_DIR);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
File fout = new File(dir, fileName + ".gpx");
|
||||||
|
int ind = 1;
|
||||||
|
while (fout.exists()) {
|
||||||
|
fout = new File(dir, fileName + "_" + (++ind) + ".gpx");
|
||||||
|
}
|
||||||
|
GPXFile file = new GPXFile();
|
||||||
|
for (MapMarker marker : mapMarkers) {
|
||||||
|
WptPt wpt = new WptPt();
|
||||||
|
wpt.lat = marker.getLatitude();
|
||||||
|
wpt.lon = marker.getLongitude();
|
||||||
|
wpt.setColor(ctx.getResources().getColor(MapMarker.getColorId(marker.colorIndex)));
|
||||||
|
wpt.name = marker.getOnlyName();
|
||||||
|
file.addPoint(wpt);
|
||||||
|
}
|
||||||
|
GPXUtilities.writeGpxFile(fout, file, ctx);
|
||||||
|
return fout.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateGpxFromList(String fileName, List<MapMarker> mapMarkers) {
|
||||||
|
final File dir = ctx.getAppPath(IndexConstants.GPX_INDEX_DIR + IndexConstants.MAP_MARKERS_INDEX_DIR);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
|
import net.osmand.plus.mapmarkers.adapters.CoordinateInputAdapter;
|
||||||
|
|
||||||
|
public class CoordinateInputActionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public final static String TAG = "CoordinateInputActionsBottomSheet";
|
||||||
|
|
||||||
|
private CoordinateInputActionsListener listener;
|
||||||
|
|
||||||
|
public void setListener(CoordinateInputActionsListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
Bundle args = getArguments();
|
||||||
|
if (args == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int position = args.getInt(CoordinateInputAdapter.ADAPTER_POSITION_KEY);
|
||||||
|
|
||||||
|
items.add(new TitleItem(getString(R.string.shared_string_actions)));
|
||||||
|
|
||||||
|
BaseBottomSheetItem editItem = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_type_edit))
|
||||||
|
.setTitle(getString(R.string.shared_string_edit))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
listener.editItem(position);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(editItem);
|
||||||
|
|
||||||
|
BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_type_delete))
|
||||||
|
.setTitle(getString(R.string.shared_string_delete))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
listener.removeItem(position);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(deleteItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDismissButtonTextId() {
|
||||||
|
return R.string.shared_string_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CoordinateInputActionsListener {
|
||||||
|
|
||||||
|
void removeItem(int position);
|
||||||
|
|
||||||
|
void editItem(int position);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,8 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
|
@ -34,6 +36,24 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
final OsmandSettings settings = getMyApplication().getSettings();
|
final OsmandSettings settings = getMyApplication().getSettings();
|
||||||
|
|
||||||
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
||||||
|
BaseBottomSheetItem editItem = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_save_to_file))
|
||||||
|
.setTitle(getString(R.string.coord_input_save_as_track))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.saveAsTrack();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(editItem);
|
||||||
|
|
||||||
|
items.add(new DividerHalfItem(context));
|
||||||
|
|
||||||
boolean useOsmandKeyboard = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.get();
|
boolean useOsmandKeyboard = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.get();
|
||||||
|
|
||||||
BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder()
|
BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||||
|
@ -148,5 +168,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
void onHandChanged();
|
void onHandChanged();
|
||||||
|
|
||||||
void onInputSettingsChanged();
|
void onInputSettingsChanged();
|
||||||
|
|
||||||
|
void saveAsTrack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Dialog;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -16,6 +17,7 @@ import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.IdRes;
|
import android.support.annotation.IdRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
@ -58,7 +60,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapmarkers.CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener;
|
import net.osmand.plus.mapmarkers.CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener;
|
||||||
import net.osmand.plus.mapmarkers.CoordinateInputFormats.DDM;
|
import net.osmand.plus.mapmarkers.CoordinateInputFormats.DDM;
|
||||||
|
@ -82,6 +84,7 @@ import static net.osmand.plus.MapMarkersHelper.MAP_MARKERS_COLORS_COUNT;
|
||||||
public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||||
|
|
||||||
public static final String TAG = "CoordinateInputDialogFragment";
|
public static final String TAG = "CoordinateInputDialogFragment";
|
||||||
|
public static final String ADDED_MARKERS_NUMBER_KEY = "added_markers_number_key";
|
||||||
|
|
||||||
private final List<MapMarker> mapMarkers = new ArrayList<>();
|
private final List<MapMarker> mapMarkers = new ArrayList<>();
|
||||||
private MapMarker selectedMarker;
|
private MapMarker selectedMarker;
|
||||||
|
@ -90,10 +93,11 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
private View mainView;
|
private View mainView;
|
||||||
private final List<EditTextEx> editTexts = new ArrayList<>();
|
private final List<EditTextEx> editTexts = new ArrayList<>();
|
||||||
private CoordinateInputAdapter adapter;
|
private CoordinateInputAdapter adapter;
|
||||||
private ImageView showHideKeyboardIcon;
|
private Snackbar snackbar;
|
||||||
|
|
||||||
private boolean lightTheme;
|
private boolean lightTheme;
|
||||||
private boolean orientationPortrait;
|
private boolean orientationPortrait;
|
||||||
|
private boolean hasUnsavedChanges;
|
||||||
|
|
||||||
private boolean isSoftKeyboardShown;
|
private boolean isSoftKeyboardShown;
|
||||||
private boolean north = true;
|
private boolean north = true;
|
||||||
|
@ -116,6 +120,25 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
setStyle(STYLE_NO_FRAME, lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
setStyle(STYLE_NO_FRAME, lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void quit() {
|
||||||
|
if (!mapMarkers.isEmpty() && hasUnsavedChanges) {
|
||||||
|
showSaveDialog();
|
||||||
|
} else {
|
||||||
|
saveMarkers();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSaveDialog() {
|
||||||
|
hasUnsavedChanges = false;
|
||||||
|
SaveAsTrackBottomSheetDialogFragment fragment = new SaveAsTrackBottomSheetDialogFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(ADDED_MARKERS_NUMBER_KEY, mapMarkers.size());
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setListener(createSaveAsTrackFragmentListener());
|
||||||
|
fragment.show(getChildFragmentManager(), SaveAsTrackBottomSheetDialogFragment.TAG);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
@ -126,8 +149,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
if (isOsmandKeyboardCurrentlyVisible()) {
|
if (isOsmandKeyboardCurrentlyVisible()) {
|
||||||
changeOsmandKeyboardVisibility(false);
|
changeOsmandKeyboardVisibility(false);
|
||||||
} else {
|
} else {
|
||||||
saveMarkers();
|
quit();
|
||||||
super.onBackPressed();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -164,13 +186,15 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
|
|
||||||
if (orientationPortrait) {
|
if (orientationPortrait) {
|
||||||
backBtn.setImageDrawable(getActiveIcon(R.drawable.ic_arrow_back));
|
backBtn.setImageDrawable(getActiveIcon(R.drawable.ic_arrow_back));
|
||||||
((TextView) mainView.findViewById(R.id.toolbar_text))
|
TextView toolbar = (TextView) mainView.findViewById(R.id.toolbar_text);
|
||||||
.setTextColor(getResolvedColor(lightTheme ? R.color.color_black : R.color.color_white));
|
toolbar.setTextColor(getResolvedColor(lightTheme ? R.color.color_black : R.color.color_white));
|
||||||
|
toolbar.setText(R.string.coord_input_add_point);
|
||||||
setBackgroundColor(R.id.app_bar, lightTheme ? R.color.route_info_bg_light : R.color.route_info_bg_dark);
|
setBackgroundColor(R.id.app_bar, lightTheme ? R.color.route_info_bg_light : R.color.route_info_bg_dark);
|
||||||
setBackgroundColor(mainView, lightTheme ? R.color.ctx_menu_info_view_bg_light : R.color.coordinate_input_markers_list_bg_dark);
|
setBackgroundColor(mainView, lightTheme ? R.color.ctx_menu_info_view_bg_light : R.color.coordinate_input_markers_list_bg_dark);
|
||||||
} else {
|
} else {
|
||||||
((TextView) mainView.findViewById(R.id.toolbar_text))
|
TextView toolbar = (TextView) mainView.findViewById(R.id.toolbar_text);
|
||||||
.setTextColor(getResolvedColor(lightTheme ? R.color.color_white : R.color.ctx_menu_title_color_dark));
|
toolbar.setTextColor(getResolvedColor(lightTheme ? R.color.color_white : R.color.ctx_menu_title_color_dark));
|
||||||
|
toolbar.setText(R.string.coord_input_add_point);
|
||||||
setBackgroundColor(R.id.app_bar, lightTheme ? R.color.actionbar_light_color : R.color.route_info_bottom_view_bg_dark);
|
setBackgroundColor(R.id.app_bar, lightTheme ? R.color.actionbar_light_color : R.color.route_info_bottom_view_bg_dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +239,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
lonBackspaceBtn.setImageDrawable(getActiveIcon(R.drawable.ic_action_clear_all_fields));
|
lonBackspaceBtn.setImageDrawable(getActiveIcon(R.drawable.ic_action_clear_all_fields));
|
||||||
lonBackspaceBtn.setOnClickListener(backspaceOnClickListener);
|
lonBackspaceBtn.setOnClickListener(backspaceOnClickListener);
|
||||||
|
|
||||||
showHideKeyboardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon);
|
|
||||||
} else {
|
} else {
|
||||||
boolean rightHand = getMyApplication().getSettings().COORDS_INPUT_USE_RIGHT_SIDE.get();
|
boolean rightHand = getMyApplication().getSettings().COORDS_INPUT_USE_RIGHT_SIDE.get();
|
||||||
LinearLayout handContainer = (LinearLayout) mainView.findViewById(R.id.hand_container);
|
LinearLayout handContainer = (LinearLayout) mainView.findViewById(R.id.hand_container);
|
||||||
|
@ -227,10 +250,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
((FrameLayout) handContainer.findViewById(R.id.left_container)).addView(rightHand ? dataAreaView : keyboardAndListView, 0);
|
((FrameLayout) handContainer.findViewById(R.id.left_container)).addView(rightHand ? dataAreaView : keyboardAndListView, 0);
|
||||||
((FrameLayout) handContainer.findViewById(R.id.right_container)).addView(rightHand ? keyboardAndListView : dataAreaView, 0);
|
((FrameLayout) handContainer.findViewById(R.id.right_container)).addView(rightHand ? keyboardAndListView : dataAreaView, 0);
|
||||||
|
|
||||||
showHideKeyboardIcon = (ImageView) dataAreaView.findViewById(rightHand ? R.id.show_hide_keyboard_icon_right : R.id.show_hide_keyboard_icon_left);
|
|
||||||
showHideKeyboardIcon.setVisibility(View.VISIBLE);
|
|
||||||
dataAreaView.findViewById(rightHand ? R.id.show_hide_keyboard_icon_left : R.id.show_hide_keyboard_icon_right).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
handContainer.findViewById(R.id.input_area_top_padding).setVisibility(View.VISIBLE);
|
handContainer.findViewById(R.id.input_area_top_padding).setVisibility(View.VISIBLE);
|
||||||
handContainer.findViewById(R.id.point_name_top_space).setVisibility(View.VISIBLE);
|
handContainer.findViewById(R.id.point_name_top_space).setVisibility(View.VISIBLE);
|
||||||
handContainer.findViewById(R.id.right_shadow).setVisibility(rightHand ? View.VISIBLE : View.GONE);
|
handContainer.findViewById(R.id.right_shadow).setVisibility(rightHand ? View.VISIBLE : View.GONE);
|
||||||
|
@ -269,7 +288,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
public void run() {
|
public void run() {
|
||||||
isSoftKeyboardShown = true;
|
isSoftKeyboardShown = true;
|
||||||
AndroidUtils.showSoftKeyboard(focusedView);
|
AndroidUtils.showSoftKeyboard(focusedView);
|
||||||
showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide));
|
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
@ -296,21 +314,49 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
enterEditingMode(adapter.getItem(pos));
|
enterEditingMode(adapter.getItem(pos));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
adapter.setOnActionsClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
RecyclerView.ViewHolder viewHolder = recyclerView.findContainingViewHolder(v);
|
||||||
|
if (viewHolder != null) {
|
||||||
|
int pos = viewHolder.getAdapterPosition();
|
||||||
|
if (pos == RecyclerView.NO_POSITION) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(CoordinateInputAdapter.ADAPTER_POSITION_KEY, pos);
|
||||||
|
CoordinateInputActionsBottomSheet fragment = new CoordinateInputActionsBottomSheet();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setListener(createCoordinateInputActionsListener());
|
||||||
|
fragment.show(getChildFragmentManager(), CoordinateInputActionsBottomSheet.TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setBackgroundColor(R.id.bottom_controls_container, lightTheme
|
setBackgroundColor(R.id.bottom_controls_container, lightTheme
|
||||||
? R.color.keyboard_item_control_light_bg : R.color.keyboard_item_control_dark_bg);
|
? R.color.keyboard_item_control_light_bg : R.color.keyboard_item_control_dark_bg);
|
||||||
TextView addButton = (TextView) mainView.findViewById(R.id.add_marker_button);
|
TextView addButton = (TextView) mainView.findViewById(R.id.add_marker_button);
|
||||||
addButton.setBackgroundResource(lightTheme ? R.drawable.route_info_go_btn_bg_light : R.drawable.route_info_go_btn_bg_dark);
|
@ColorRes int colorId = lightTheme ? R.color.wikivoyage_active_light : R.color.wikivoyage_active_dark;
|
||||||
if (selectedMarker != null) {
|
addButton.setCompoundDrawablesWithIntrinsicBounds(null, null, getColoredIcon(R.drawable.ic_action_type_add, colorId), null);
|
||||||
addButton.setText(R.string.shared_string_save);
|
addButton.setText(R.string.shared_string_add);
|
||||||
}
|
|
||||||
addButton.setOnClickListener(new View.OnClickListener() {
|
addButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
addMapMarker();
|
addMapMarker();
|
||||||
|
hasUnsavedChanges = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TextView cancelButton = (TextView) mainView.findViewById(R.id.cancel_button);
|
||||||
|
cancelButton.setText(R.string.shared_string_cancel);
|
||||||
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
dismissEditingMode();
|
||||||
|
clearInputs();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mainView.findViewById(R.id.keyboard_layout).setBackgroundResource(lightTheme
|
mainView.findViewById(R.id.keyboard_layout).setBackgroundResource(lightTheme
|
||||||
? R.drawable.bg_bottom_menu_light : R.drawable.bg_coordinate_input_keyboard_dark);
|
? R.drawable.bg_bottom_menu_light : R.drawable.bg_coordinate_input_keyboard_dark);
|
||||||
|
|
||||||
|
@ -345,6 +391,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
case R.id.keyboard_item_next_field:
|
case R.id.keyboard_item_next_field:
|
||||||
switchEditText(focusedEditText.getId(), true);
|
switchEditText(focusedEditText.getId(), true);
|
||||||
break;
|
break;
|
||||||
|
case R.id.keyboard_item_hide:
|
||||||
|
changeOsmandKeyboardVisibility(false);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
focusedEditText.setText(focusedEditText.getText().toString() + getItemObjectById(id));
|
focusedEditText.setText(focusedEditText.getText().toString() + getItemObjectById(id));
|
||||||
focusedEditText.setSelection(focusedEditText.getText().length());
|
focusedEditText.setSelection(focusedEditText.getText().length());
|
||||||
|
@ -367,42 +416,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
R.id.keyboard_item_9,
|
R.id.keyboard_item_9,
|
||||||
R.id.keyboard_item_clear,
|
R.id.keyboard_item_clear,
|
||||||
R.id.keyboard_item_next_field,
|
R.id.keyboard_item_next_field,
|
||||||
R.id.keyboard_item_backspace);
|
R.id.keyboard_item_backspace,
|
||||||
|
R.id.keyboard_item_hide);
|
||||||
|
|
||||||
if (!isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) {
|
if (!isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) {
|
||||||
changeOsmandKeyboardVisibility(false);
|
changeOsmandKeyboardVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide));
|
|
||||||
showHideKeyboardIcon.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible();
|
|
||||||
if (isOsmandKeyboardOn() && !isSoftKeyboardShown) {
|
|
||||||
changeOsmandKeyboardVisibility(!isCurrentlyVisible);
|
|
||||||
} else {
|
|
||||||
final View focusedView = getDialog().getCurrentFocus();
|
|
||||||
if (focusedView != null) {
|
|
||||||
if (isSoftKeyboardShown) {
|
|
||||||
isSoftKeyboardShown = false;
|
|
||||||
AndroidUtils.hideSoftKeyboard(getActivity(), focusedView);
|
|
||||||
showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_show));
|
|
||||||
} else {
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
isSoftKeyboardShown = true;
|
|
||||||
AndroidUtils.showSoftKeyboard(focusedView);
|
|
||||||
showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide));
|
|
||||||
}
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
changeEditTextSelections();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
|
@ -410,12 +430,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
mainView.getWindowVisibleDisplayFrame(r);
|
mainView.getWindowVisibleDisplayFrame(r);
|
||||||
int screenHeight = mainView.getRootView().getHeight();
|
int screenHeight = mainView.getRootView().getHeight();
|
||||||
int keypadHeight = screenHeight - r.bottom;
|
int keypadHeight = screenHeight - r.bottom;
|
||||||
if (keypadHeight > screenHeight * 0.15) {
|
isSoftKeyboardShown = keypadHeight > screenHeight * 0.15;
|
||||||
isSoftKeyboardShown = true;
|
|
||||||
showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide));
|
|
||||||
} else {
|
|
||||||
isSoftKeyboardShown = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -434,7 +449,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
for (@IdRes int id : itemsIds) {
|
for (@IdRes int id : itemsIds) {
|
||||||
View itemView = keyboardView.findViewById(id);
|
View itemView = keyboardView.findViewById(id);
|
||||||
Object item = getItemObjectById(id);
|
Object item = getItemObjectById(id);
|
||||||
final boolean controlItem = id == R.id.keyboard_item_next_field || id == R.id.keyboard_item_backspace;
|
final boolean controlItem = id == R.id.keyboard_item_next_field
|
||||||
|
|| id == R.id.keyboard_item_backspace
|
||||||
|
|| id == R.id.keyboard_item_hide;
|
||||||
|
|
||||||
itemView.setBackgroundResource(controlItem ? controlItemBg : itemBg);
|
itemView.setBackgroundResource(controlItem ? controlItemBg : itemBg);
|
||||||
itemView.setOnClickListener(listener);
|
itemView.setOnClickListener(listener);
|
||||||
|
@ -507,6 +524,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
return R.drawable.ic_keyboard_next_field;
|
return R.drawable.ic_keyboard_next_field;
|
||||||
case R.id.keyboard_item_backspace:
|
case R.id.keyboard_item_backspace:
|
||||||
return R.drawable.ic_keyboard_backspace;
|
return R.drawable.ic_keyboard_backspace;
|
||||||
|
case R.id.keyboard_item_hide:
|
||||||
|
return R.drawable.ic_action_keyboard_hide;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -674,6 +693,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
if (isOsmandKeyboardOn()) {
|
if (isOsmandKeyboardOn()) {
|
||||||
if (!isOsmandKeyboardCurrentlyVisible()) {
|
if (!isOsmandKeyboardCurrentlyVisible()) {
|
||||||
|
if (isSoftKeyboardShown) {
|
||||||
|
if (view.getId() != R.id.point_name_et) {
|
||||||
|
AndroidUtils.hideSoftKeyboard(getActivity(), view);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
changeOsmandKeyboardVisibility(true);
|
changeOsmandKeyboardVisibility(true);
|
||||||
}
|
}
|
||||||
EditText editText = (EditText) view;
|
EditText editText = (EditText) view;
|
||||||
|
@ -750,6 +776,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
switchEditText(textView.getId(), true);
|
switchEditText(textView.getId(), true);
|
||||||
} else if (i == EditorInfo.IME_ACTION_DONE) {
|
} else if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
addMapMarker();
|
addMapMarker();
|
||||||
|
hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -802,8 +829,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (!hasFocus && isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) {
|
if (!hasFocus && isOsmandKeyboardOn() && (isOsmandKeyboardCurrentlyVisible() || isSoftKeyboardShown)) {
|
||||||
AndroidUtils.hideSoftKeyboard(getActivity(), v);
|
AndroidUtils.hideSoftKeyboard(getActivity(), v);
|
||||||
|
isSoftKeyboardShown = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -851,11 +879,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
if (focusedView != null) {
|
if (focusedView != null) {
|
||||||
if (useOsmandKeyboard) {
|
if (useOsmandKeyboard) {
|
||||||
AndroidUtils.hideSoftKeyboard(getActivity(), focusedView);
|
AndroidUtils.hideSoftKeyboard(getActivity(), focusedView);
|
||||||
|
isSoftKeyboardShown = false;
|
||||||
} else {
|
} else {
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AndroidUtils.showSoftKeyboard(focusedView);
|
AndroidUtils.showSoftKeyboard(focusedView);
|
||||||
|
isSoftKeyboardShown = true;
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
@ -881,6 +911,77 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
dismissEditingMode();
|
dismissEditingMode();
|
||||||
registerInputs();
|
registerInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveAsTrack() {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
if (app != null) {
|
||||||
|
if (mapMarkers.isEmpty()) {
|
||||||
|
Toast.makeText(app, getString(R.string.plan_route_no_markers_toast), Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
showSaveDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener createSaveAsTrackFragmentListener() {
|
||||||
|
return new SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener() {
|
||||||
|
|
||||||
|
final OsmandApplication app = getMyApplication();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveGpx(final String fileName) {
|
||||||
|
final String gpxPath = app.getMapMarkersHelper().generateGpxFromList(fileName, mapMarkers);
|
||||||
|
hasUnsavedChanges = false;
|
||||||
|
snackbar = Snackbar.make(mainView, fileName + " " + getString(R.string.is_saved) + ".", Snackbar.LENGTH_LONG)
|
||||||
|
.setAction(R.string.shared_string_show, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(app, getMyApplication().getAppCustomization().getTrackActivity());
|
||||||
|
intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxPath);
|
||||||
|
intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
|
||||||
|
snackbar.show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private CoordinateInputActionsBottomSheet.CoordinateInputActionsListener createCoordinateInputActionsListener() {
|
||||||
|
return new CoordinateInputActionsBottomSheet.CoordinateInputActionsListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeItem(final int position) {
|
||||||
|
final MapMarker mapMarker = adapter.getItem(position);
|
||||||
|
if (selectedMarker == mapMarker) {
|
||||||
|
dismissEditingMode();
|
||||||
|
clearInputs();
|
||||||
|
}
|
||||||
|
adapter.removeItem(position);
|
||||||
|
hasUnsavedChanges = true;
|
||||||
|
snackbar = Snackbar.make(mainView, R.string.marker_moved_to_history, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
mapMarkers.add(position, mapMarker);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark);
|
||||||
|
snackbar.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void editItem(int position) {
|
||||||
|
enterEditingMode(adapter.getItem(position));
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,9 +1012,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
} else {
|
} else {
|
||||||
mainView.findViewById(R.id.keyboard_layout).setVisibility(visibility);
|
mainView.findViewById(R.id.keyboard_layout).setVisibility(visibility);
|
||||||
}
|
}
|
||||||
showHideKeyboardIcon.setImageDrawable(
|
|
||||||
getActiveIcon(show ? R.drawable.ic_action_keyboard_hide : R.drawable.ic_action_keyboard_show)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchEditText(int currentId, boolean toNext) {
|
private void switchEditText(int currentId, boolean toNext) {
|
||||||
|
@ -949,7 +1047,11 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
|
|
||||||
private void dismissEditingMode() {
|
private void dismissEditingMode() {
|
||||||
selectedMarker = null;
|
selectedMarker = null;
|
||||||
((TextView) mainView.findViewById(R.id.add_marker_button)).setText(R.string.shared_string_add);
|
TextView addButton = (TextView) mainView.findViewById(R.id.add_marker_button);
|
||||||
|
addButton.setText(R.string.shared_string_add);
|
||||||
|
@ColorRes int colorId = lightTheme ? R.color.wikivoyage_active_light : R.color.wikivoyage_active_dark;
|
||||||
|
addButton.setCompoundDrawablesWithIntrinsicBounds(null, null, getColoredIcon(R.drawable.ic_action_type_add, colorId), null);
|
||||||
|
((TextView) mainView.findViewById(R.id.toolbar_text)).setText(R.string.coord_input_add_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterEditingMode(MapMarker marker) {
|
private void enterEditingMode(MapMarker marker) {
|
||||||
|
@ -978,7 +1080,29 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
updateSideOfTheWorldBtn(mainView.findViewById(R.id.lon_side_of_the_world_btn), true);
|
updateSideOfTheWorldBtn(mainView.findViewById(R.id.lon_side_of_the_world_btn), true);
|
||||||
}
|
}
|
||||||
((EditText) mainView.findViewById(R.id.point_name_et)).setText(marker.getName(getContext()));
|
((EditText) mainView.findViewById(R.id.point_name_et)).setText(marker.getName(getContext()));
|
||||||
((TextView) mainView.findViewById(R.id.add_marker_button)).setText(R.string.shared_string_save);
|
((TextView) mainView.findViewById(R.id.toolbar_text)).setText(R.string.coord_input_edit_point);
|
||||||
|
TextView addButton = (TextView) mainView.findViewById(R.id.add_marker_button);
|
||||||
|
addButton.setText(R.string.shared_string_apply);
|
||||||
|
@ColorRes int colorId = lightTheme ? R.color.wikivoyage_active_light : R.color.wikivoyage_active_dark;
|
||||||
|
addButton.setCompoundDrawablesWithIntrinsicBounds(null, null, getColoredIcon(R.drawable.ic_action_type_apply, colorId), null);
|
||||||
|
showKeyboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showKeyboard() {
|
||||||
|
View focusedView = null;
|
||||||
|
for (EditText et : editTexts) {
|
||||||
|
if (et.getId() == R.id.lat_first_input_et) {
|
||||||
|
et.requestFocus();
|
||||||
|
focusedView = getDialog().getCurrentFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isOsmandKeyboardOn()) {
|
||||||
|
if (!isOsmandKeyboardCurrentlyVisible()) {
|
||||||
|
changeOsmandKeyboardVisibility(true);
|
||||||
|
}
|
||||||
|
} else if (!isSoftKeyboardShown && focusedView != null) {
|
||||||
|
AndroidUtils.softKeyboardDelayed(focusedView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInputsDdm(boolean lat, DDM ddm, int accuracy) {
|
private void updateInputsDdm(boolean lat, DDM ddm, int accuracy) {
|
||||||
|
@ -1133,7 +1257,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
et.clearFocus();
|
et.clearFocus();
|
||||||
}
|
}
|
||||||
if (editTexts.size() > 0) {
|
if (editTexts.size() > 0) {
|
||||||
editTexts.get(0).requestFocus();
|
showKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,9 +1302,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
if (!compassUpdateAllowed) {
|
if (!compassUpdateAllowed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final OsmandApplication app = getMyApplication();
|
||||||
if (mapActivity != null && adapter != null) {
|
if (app != null && adapter != null) {
|
||||||
mapActivity.getMyApplication().runInUIThread(new Runnable() {
|
app.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
|
@ -17,12 +17,13 @@ import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import java.io.File;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX;
|
import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX;
|
||||||
|
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.ADDED_MARKERS_NUMBER_KEY;
|
||||||
|
|
||||||
public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@ -45,13 +47,25 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
MapActivity mapActivity = (MapActivity) getActivity();
|
final OsmandApplication app = getMyApplication();
|
||||||
|
boolean isCoordInput = false;
|
||||||
|
int number = 0;
|
||||||
|
Bundle args = getArguments();
|
||||||
|
if (args != null) {
|
||||||
|
number = args.getInt(ADDED_MARKERS_NUMBER_KEY);
|
||||||
|
if (number != 0)
|
||||||
|
isCoordInput = true;
|
||||||
|
}
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||||
final boolean nightMode = !getMyApplication().getSettings().isLightContent();
|
final boolean nightMode = !app.getSettings().isLightContent();
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
|
||||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_save_as_track_bottom_sheet_dialog, container);
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_save_as_track_bottom_sheet_dialog, container);
|
||||||
LinearLayout contentLayout = (LinearLayout) mainView.findViewById(R.id.content_linear_layout);
|
LinearLayout contentLayout = (LinearLayout) mainView.findViewById(R.id.content_linear_layout);
|
||||||
|
TextView titleTv = (TextView) mainView.findViewById(R.id.save_as_track_title);
|
||||||
|
titleTv.setText(isCoordInput ? R.string.coord_input_save_as_track : R.string.marker_save_as_track);
|
||||||
|
TextView descriptionTv = (TextView) mainView.findViewById(R.id.save_as_track_description);
|
||||||
|
descriptionTv.setText(isCoordInput ? getString(R.string.coord_input_save_as_track_descr, number) : getString(R.string.marker_save_as_track_descr));
|
||||||
int layoutRes;
|
int layoutRes;
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
layoutRes = R.layout.markers_track_name_text_field_box;
|
layoutRes = R.layout.markers_track_name_text_field_box;
|
||||||
|
@ -67,16 +81,16 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
|
||||||
if (textBox instanceof TextInputLayout) {
|
if (textBox instanceof TextInputLayout) {
|
||||||
((TextInputLayout) textBox).setHintTextAppearance(R.style.TextAppearance_App_DarkTextInputLayout);
|
((TextInputLayout) textBox).setHintTextAppearance(R.style.TextAppearance_App_DarkTextInputLayout);
|
||||||
} else if (textBox instanceof OsmandTextFieldBoxes) {
|
} else if (textBox instanceof OsmandTextFieldBoxes) {
|
||||||
((OsmandTextFieldBoxes) textBox).setPrimaryColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark));
|
((OsmandTextFieldBoxes) textBox).setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final File dir = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR + "/map markers");
|
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR + "/map markers");
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
}
|
}
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
final String suggestedName = mapActivity.getString(R.string.markers) + "_" + DateFormat.format("yyyy-MM-dd", date).toString();
|
final String suggestedName = app.getString(R.string.markers) + "_" + DateFormat.format("yyyy-MM-dd", date).toString();
|
||||||
String displayedName = suggestedName;
|
String displayedName = suggestedName;
|
||||||
File fout = new File(dir, suggestedName + GPX_SUFFIX);
|
File fout = new File(dir, suggestedName + GPX_SUFFIX);
|
||||||
int ind = 1;
|
int ind = 1;
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
||||||
|
|
||||||
|
public static final String ADAPTER_POSITION_KEY = "adapter_position_key";
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private List<MapMarker> mapMarkers;
|
private List<MapMarker> mapMarkers;
|
||||||
|
|
||||||
|
@ -31,11 +33,16 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
||||||
private boolean nightTheme;
|
private boolean nightTheme;
|
||||||
|
|
||||||
private View.OnClickListener listener;
|
private View.OnClickListener listener;
|
||||||
|
private View.OnClickListener actionsListener;
|
||||||
|
|
||||||
public void setOnClickListener(View.OnClickListener listener) {
|
public void setOnClickListener(View.OnClickListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnActionsClickListener(View.OnClickListener actionsListener) {
|
||||||
|
this.actionsListener = actionsListener;
|
||||||
|
}
|
||||||
|
|
||||||
public CoordinateInputAdapter(OsmandApplication app, List<MapMarker> mapMarkers) {
|
public CoordinateInputAdapter(OsmandApplication app, List<MapMarker> mapMarkers) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.mapMarkers = mapMarkers;
|
this.mapMarkers = mapMarkers;
|
||||||
|
@ -61,23 +68,13 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
||||||
holder.mainLayout.setBackgroundColor(getResolvedColor(nightTheme ? R.color.ctx_menu_bg_dark : R.color.bg_color_light));
|
holder.mainLayout.setBackgroundColor(getResolvedColor(nightTheme ? R.color.ctx_menu_bg_dark : R.color.bg_color_light));
|
||||||
holder.title.setTextColor(getResolvedColor(nightTheme ? R.color.ctx_menu_title_color_dark : R.color.color_black));
|
holder.title.setTextColor(getResolvedColor(nightTheme ? R.color.ctx_menu_title_color_dark : R.color.color_black));
|
||||||
holder.divider.setBackgroundColor(getResolvedColor(nightTheme ? R.color.route_info_divider_dark : R.color.dashboard_divider_light));
|
holder.divider.setBackgroundColor(getResolvedColor(nightTheme ? R.color.route_info_divider_dark : R.color.dashboard_divider_light));
|
||||||
holder.optionsBtn.setBackgroundDrawable(getRemoveBtnBgSelector());
|
holder.optionsBtn.setImageDrawable(getColoredIcon(R.drawable.ic_overflow_menu_white, R.color.icon_color));
|
||||||
holder.optionsBtn.setImageDrawable(getColoredIcon(R.drawable.ic_action_remove_small, R.color.icon_color));
|
holder.optionsBtn.setBackgroundColor(ContextCompat.getColor(app, nightTheme ? R.color.ctx_menu_bg_dark : R.color.bg_color_light));
|
||||||
holder.iconReorder.setVisibility(View.GONE);
|
holder.iconReorder.setVisibility(View.GONE);
|
||||||
holder.numberText.setVisibility(View.VISIBLE);
|
holder.numberText.setVisibility(View.VISIBLE);
|
||||||
holder.numberText.setText(String.valueOf(position + 1));
|
holder.numberText.setText(String.valueOf(position + 1));
|
||||||
holder.description.setVisibility(View.GONE);
|
holder.description.setVisibility(View.GONE);
|
||||||
|
holder.optionsBtn.setOnClickListener(actionsListener);
|
||||||
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
int position = holder.getAdapterPosition();
|
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
mapMarkers.remove(getItem(position));
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
boolean singleItem = getItemCount() == 1;
|
boolean singleItem = getItemCount() == 1;
|
||||||
boolean fistItem = position == 0;
|
boolean fistItem = position == 0;
|
||||||
|
@ -105,14 +102,11 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
||||||
return mapMarkers.get(position);
|
return mapMarkers.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getRemoveBtnBgSelector() {
|
public void removeItem(int position) {
|
||||||
if (nightTheme) {
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
return AndroidUtils.createPressedStateListDrawable(
|
mapMarkers.remove(getItem(position));
|
||||||
getColoredIcon(R.drawable.marker_circle_background_dark_n_with_inset, R.color.keyboard_item_control_dark_bg),
|
notifyDataSetChanged();
|
||||||
ContextCompat.getDrawable(app, R.drawable.marker_circle_background_p_with_inset)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return ContextCompat.getDrawable(app, R.drawable.marker_circle_background_light_with_inset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getColoredIcon(@DrawableRes int resId, @ColorRes int colorResId) {
|
private Drawable getColoredIcon(@DrawableRes int resId, @ColorRes int colorResId) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ import net.osmand.plus.download.ui.LocalIndexesFragment;
|
||||||
import net.osmand.plus.download.ui.LocalIndexesFragment.RenameCallback;
|
import net.osmand.plus.download.ui.LocalIndexesFragment.RenameCallback;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||||
|
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -474,6 +475,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
});
|
});
|
||||||
} else if (itemId == R.string.gpx_add_track) {
|
} else if (itemId == R.string.gpx_add_track) {
|
||||||
addTrack();
|
addTrack();
|
||||||
|
}else if (itemId == R.string.coordinate_input) {
|
||||||
|
openCoordinatesInput();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -481,6 +484,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.gpx_add_track, getActivity())
|
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.gpx_add_track, getActivity())
|
||||||
.setIcon(R.drawable.ic_action_plus)
|
.setIcon(R.drawable.ic_action_plus)
|
||||||
.setListener(listener).createItem());
|
.setListener(listener).createItem());
|
||||||
|
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.coordinate_input, getActivity())
|
||||||
|
.setIcon(R.drawable.ic_action_coordinates_longitude)
|
||||||
|
.setListener(listener).createItem());
|
||||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_show_on_map, getActivity())
|
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_show_on_map, getActivity())
|
||||||
.setIcon(R.drawable.ic_show_on_map)
|
.setIcon(R.drawable.ic_show_on_map)
|
||||||
.setListener(listener).createItem());
|
.setListener(listener).createItem());
|
||||||
|
@ -538,6 +544,12 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
((FavoritesActivity) getActivity()).addTrack();
|
((FavoritesActivity) getActivity()).addTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openCoordinatesInput() {
|
||||||
|
CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
|
||||||
|
fragment.setRetainInstance(true);
|
||||||
|
fragment.show(getChildFragmentManager(), CoordinateInputDialogFragment.TAG);
|
||||||
|
}
|
||||||
|
|
||||||
public void showProgressBar() {
|
public void showProgressBar() {
|
||||||
((FavoritesActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
|
((FavoritesActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue