diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_divider.xml b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_divider.xml
deleted file mode 100644
index 05cc926985..0000000000
--- a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_divider.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_item.xml b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_item.xml
deleted file mode 100644
index b0b4855034..0000000000
--- a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_item.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_title.xml b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_title.xml
deleted file mode 100644
index a70510f0d2..0000000000
--- a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_title.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/bottom_sheet_item_description.xml b/OsmAnd/res/layout/bottom_sheet_item_description.xml
new file mode 100644
index 0000000000..91d1ef1d99
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_description.xml
@@ -0,0 +1,15 @@
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_simple.xml b/OsmAnd/res/layout/bottom_sheet_item_simple.xml
new file mode 100644
index 0000000000..296ba82392
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_simple.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_subtitle.xml b/OsmAnd/res/layout/bottom_sheet_item_subtitle.xml
new file mode 100644
index 0000000000..e0c850a458
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_subtitle.xml
@@ -0,0 +1,16 @@
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_title.xml b/OsmAnd/res/layout/bottom_sheet_item_title.xml
new file mode 100644
index 0000000000..6fa4eb12fe
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_title.xml
@@ -0,0 +1,17 @@
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_56dp.xml
new file mode 100644
index 0000000000..25ee93e4e2
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_56dp.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_switch_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_switch_56dp.xml
new file mode 100644
index 0000000000..b166524d6e
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_switch_56dp.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_radio_btn.xml b/OsmAnd/res/layout/bottom_sheet_item_with_radio_btn.xml
index 5e4a692f66..28aaab9914 100644
--- a/OsmAnd/res/layout/bottom_sheet_item_with_radio_btn.xml
+++ b/OsmAnd/res/layout/bottom_sheet_item_with_radio_btn.xml
@@ -13,7 +13,7 @@
android:paddingStart="@dimen/content_padding">
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_switch.xml b/OsmAnd/res/layout/bottom_sheet_item_with_switch.xml
new file mode 100644
index 0000000000..365bc4a467
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_item_with_switch.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_menu_base.xml b/OsmAnd/res/layout/bottom_sheet_menu_base.xml
new file mode 100644
index 0000000000..8a575be9ee
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_menu_base.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/fragment_add_waypoint_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_add_waypoint_bottom_sheet_dialog.xml
deleted file mode 100644
index f38c3a37f2..0000000000
--- a/OsmAnd/res/layout/fragment_add_waypoint_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,309 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_import_gpx_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_import_gpx_bottom_sheet_dialog.xml
deleted file mode 100644
index 67525105f1..0000000000
--- a/OsmAnd/res/layout/fragment_import_gpx_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml
index 51a0820240..8d5b5f0bef 100644
--- a/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml
+++ b/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml
@@ -11,8 +11,7 @@
android:id="@+id/groups_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:clipToPadding="false"
- android:paddingBottom="@dimen/bottom_sheet_content_padding_small"/>
+ android:clipToPadding="false"/>
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_marker_add_markers_group_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_add_markers_group_bottom_sheet_dialog.xml
deleted file mode 100644
index baacf61b55..0000000000
--- a/OsmAnd/res/layout/fragment_marker_add_markers_group_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_dialog.xml
deleted file mode 100644
index 887d3c7a07..0000000000
--- a/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml
deleted file mode 100644
index a53f553019..0000000000
--- a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_marker_order_by_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_order_by_bottom_sheet_dialog.xml
deleted file mode 100644
index 617d985df1..0000000000
--- a/OsmAnd/res/layout/fragment_marker_order_by_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,224 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_notes_item_menu_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_notes_item_menu_bottom_sheet_dialog.xml
deleted file mode 100644
index c7f722c621..0000000000
--- a/OsmAnd/res/layout/fragment_notes_item_menu_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,220 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml
deleted file mode 100644
index a307700dd6..0000000000
--- a/OsmAnd/res/layout/fragment_notes_sort_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml
deleted file mode 100644
index dabbd5dcea..0000000000
--- a/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,269 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_osm_edit_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_osm_edit_options_bottom_sheet_dialog.xml
deleted file mode 100644
index 61e0860e73..0000000000
--- a/OsmAnd/res/layout/fragment_osm_edit_options_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_osm_export_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_osm_export_options_bottom_sheet_dialog.xml
deleted file mode 100644
index db5d8c5b42..0000000000
--- a/OsmAnd/res/layout/fragment_osm_export_options_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,195 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_osm_file_type_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_osm_file_type_bottom_sheet_dialog.xml
deleted file mode 100644
index 77911fdab2..0000000000
--- a/OsmAnd/res/layout/fragment_osm_file_type_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml
deleted file mode 100644
index 1c9345234f..0000000000
--- a/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,258 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml
deleted file mode 100644
index 5606b9625f..0000000000
--- a/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_save_as_new_track_images_row.xml b/OsmAnd/res/layout/fragment_save_as_new_track_images_row.xml
new file mode 100644
index 0000000000..ebdea2f235
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_save_as_new_track_images_row.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/fragment_selected_menu_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_selected_menu_bottom_sheet_dialog.xml
deleted file mode 100644
index ff13e0cad9..0000000000
--- a/OsmAnd/res/layout/fragment_selected_menu_bottom_sheet_dialog.xml
+++ /dev/null
@@ -1,261 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/share_menu_fragment.xml b/OsmAnd/res/layout/share_menu_fragment.xml
deleted file mode 100644
index c4bcd564c6..0000000000
--- a/OsmAnd/res/layout/share_menu_fragment.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java
index e0184bf6e0..26014c4cb7 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java
@@ -1,20 +1,16 @@
package net.osmand.plus.audionotes;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+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.TitleItem;
public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -32,86 +28,94 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
this.recording = recording;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
-
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.fragment_notes_item_menu_bottom_sheet_dialog, null);
-
+ public void createMenuItems(Bundle savedInstanceState) {
if (recording != null) {
- NumberFormat f = new DecimalFormat("#0.00000");
- ((TextView) mainView.findViewById(R.id.title_text_view))
- .setText(recording.getName(getActivity(), true));
- ((TextView) mainView.findViewById(R.id.play_text_view))
- .setText(recording.isPhoto() ? R.string.watch : R.string.recording_context_menu_play);
- ((TextView) mainView.findViewById(R.id.show_on_map_descr_text_view))
- .setText(f.format(recording.getLatitude()) + ", " + f.format(recording.getLongitude()));
- ((ImageView) mainView.findViewById(R.id.play_icon))
- .setImageDrawable(getContentIcon(recording.isPhoto() ? R.drawable.ic_action_view : R.drawable.ic_play_dark));
+ items.add(new TitleItem(recording.getName(getContext(), true)));
+
+ BaseBottomSheetItem playItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(recording.isPhoto() ? R.drawable.ic_action_view : R.drawable.ic_play_dark))
+ .setTitle(getString(recording.isPhoto() ? R.string.watch : R.string.recording_context_menu_play))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.playOnClick(recording);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(playItem);
+
+ BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_gshare_dark))
+ .setTitle(getString(R.string.shared_string_share))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.shareOnClick(recording);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(shareItem);
+
+ BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.route_descr_lat_lon, recording.getLatitude(), recording.getLongitude()))
+ .setIcon(getContentIcon(R.drawable.ic_show_on_map))
+ .setTitle(getString(R.string.shared_string_show_on_map))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.showOnMapOnClick(recording);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(showOnMapItem);
+
+ items.add(new DividerHalfItem(getContext()));
+
+ BaseBottomSheetItem renameItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
+ .setTitle(getString(R.string.shared_string_rename))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.renameOnClick(recording);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(renameItem);
+
+ BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_delete_dark))
+ .setTitle(getString(R.string.shared_string_delete))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.deleteOnClick(recording);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(deleteItem);
}
-
- ((ImageView) mainView.findViewById(R.id.share_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_gshare_dark));
- ((ImageView) mainView.findViewById(R.id.show_on_map_icon)).setImageDrawable(getContentIcon(R.drawable.ic_show_on_map));
- ((ImageView) mainView.findViewById(R.id.rename_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
- ((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
-
- mainView.findViewById(R.id.play_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null && recording != null) {
- listener.playOnClick(recording);
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.share_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null && recording != null) {
- listener.shareOnClick(recording);
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.show_on_map_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null && recording != null) {
- listener.showOnMapOnClick(recording);
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.rename_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null && recording != null) {
- listener.renameOnClick(recording);
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null && recording != null) {
- listener.deleteOnClick(recording);
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.scroll_view);
-
- return mainView;
}
@Override
@@ -122,6 +126,11 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
super.onDestroyView();
}
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
+ }
+
interface ItemMenuFragmentListener {
void playOnClick(Recording recording);
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java
index 96e7d6b185..9fc75f7f5d 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java
@@ -1,18 +1,15 @@
package net.osmand.plus.audionotes;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.ImageView;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.NotesSortByMode;
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;
public class SortByMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -24,39 +21,35 @@ public class SortByMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFr
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.shared_string_sort)));
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.fragment_notes_sort_bottom_sheet_dialog, null);
+ BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_groped_by_type))
+ .setTitle(getString(R.string.by_type))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ selectSortByMode(NotesSortByMode.BY_TYPE);
+ }
+ })
+ .create();
+ items.add(byTypeItem);
- ((ImageView) mainView.findViewById(R.id.by_type_icon)).setImageDrawable(getContentIcon(R.drawable.ic_groped_by_type));
- ((ImageView) mainView.findViewById(R.id.by_date_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date));
-
- mainView.findViewById(R.id.by_type_row).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- selectSortByMode(NotesSortByMode.BY_TYPE);
- }
- });
- mainView.findViewById(R.id.by_date_row).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- selectSortByMode(NotesSortByMode.BY_DATE);
- }
- });
- mainView.findViewById(R.id.close_row).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.scroll_view);
-
- return mainView;
+ BaseBottomSheetItem byDateItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_sort_by_date))
+ .setTitle(getString(R.string.by_date))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ selectSortByMode(NotesSortByMode.BY_DATE);
+ }
+ })
+ .create();
+ items.add(byDateItem);
}
private void selectSortByMode(NotesSortByMode mode) {
diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java
index 59d3d52d56..f1b2034b3c 100644
--- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java
@@ -4,23 +4,41 @@ import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
+import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.v4.content.ContextCompat;
+import android.view.ContextThemeWrapper;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.widget.TextView;
import net.osmand.AndroidUtils;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.helpers.AndroidUiHelper;
+import java.util.ArrayList;
+import java.util.List;
+
public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
private static final String USED_ON_MAP_KEY = "used_on_map";
+ protected List items = new ArrayList<>();
+
protected boolean usedOnMap = true;
protected boolean nightMode;
+ private LinearLayout itemsContainer;
+
public void setUsedOnMap(boolean usedOnMap) {
this.usedOnMap = usedOnMap;
}
@@ -34,6 +52,40 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
nightMode = isNightMode();
}
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
+ createMenuItems(savedInstanceState);
+
+ OsmandApplication app = getMyApplication();
+ final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+
+ View mainView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_menu_base, null);
+ itemsContainer = (LinearLayout) mainView.findViewById(R.id.items_container);
+
+ for (BaseBottomSheetItem item : items) {
+ item.inflate(app, itemsContainer, nightMode);
+ }
+
+ int closeRowDividerColorId = getCloseRowDividerColorId();
+ if (closeRowDividerColorId != -1) {
+ mainView.findViewById(R.id.close_row_divider)
+ .setBackgroundColor(ContextCompat.getColor(getContext(), closeRowDividerColorId));
+ }
+ mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onCloseRowClickAction();
+ dismiss();
+ }
+ });
+ ((TextView) mainView.findViewById(R.id.close_row_text)).setText(getCloseRowTextId());
+
+ setupHeightAndBackground(mainView, R.id.scroll_view);
+
+ return mainView;
+ }
+
@Override
public void onStart() {
super.onStart();
@@ -51,6 +103,17 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
outState.putBoolean(USED_ON_MAP_KEY, usedOnMap);
}
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ items.clear();
+ if (itemsContainer != null) {
+ itemsContainer.removeAllViews();
+ }
+ }
+
+ public abstract void createMenuItems(Bundle savedInstanceState);
+
@Override
protected Drawable getContentIcon(@DrawableRes int id) {
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
@@ -99,6 +162,20 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
});
}
+ @ColorRes
+ protected int getCloseRowDividerColorId() {
+ return -1;
+ }
+
+ @StringRes
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_cancel;
+ }
+
+ protected void onCloseRowClickAction() {
+
+ }
+
@DrawableRes
protected int getPortraitBgResId() {
return nightMode ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_menu_light;
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java
new file mode 100644
index 0000000000..2eff160b71
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java
@@ -0,0 +1,115 @@
+package net.osmand.plus.base.bottomsheetmenu;
+
+import android.support.annotation.LayoutRes;
+import android.view.ContextThemeWrapper;
+import android.view.View;
+import android.view.ViewGroup;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+
+public class BaseBottomSheetItem {
+
+ public static final int INVALID_POSITION = -1;
+ public static final int INVALID_ID = -1;
+
+ protected View view;
+ @LayoutRes
+ protected int layoutId = INVALID_ID;
+ private Object tag;
+ private boolean disabled;
+ private View.OnClickListener onClickListener;
+ protected int position = INVALID_POSITION;
+
+ public BaseBottomSheetItem(View view,
+ @LayoutRes int layoutId,
+ Object tag,
+ boolean disabled,
+ View.OnClickListener onClickListener,
+ int position) {
+ this.view = view;
+ this.layoutId = layoutId;
+ this.tag = tag;
+ this.disabled = disabled;
+ this.onClickListener = onClickListener;
+ this.position = position;
+ }
+
+ protected BaseBottomSheetItem() {
+
+ }
+
+ public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
+ View view = getView(app, nightMode);
+ if (tag != null) {
+ view.setTag(tag);
+ }
+ if (disabled) {
+ view.setEnabled(false);
+ view.setAlpha(.5f);
+ }
+ view.setOnClickListener(onClickListener);
+ view.setClickable(onClickListener != null);
+ if (position != INVALID_POSITION) {
+ container.addView(view, position);
+ } else {
+ container.addView(view);
+ }
+ }
+
+ private View getView(OsmandApplication app, boolean nightMode) {
+ if (view != null) {
+ return view;
+ }
+ if (layoutId != INVALID_ID) {
+ final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ return view = View.inflate(new ContextThemeWrapper(app, themeRes), layoutId, null);
+ }
+ throw new RuntimeException("BottomSheetItem must have specified view or layoutId.");
+ }
+
+ public static class Builder {
+
+ protected View customView;
+ @LayoutRes
+ protected int layoutId = INVALID_ID;
+ protected Object tag;
+ protected boolean disabled;
+ protected View.OnClickListener onClickListener;
+ protected int position = INVALID_POSITION;
+
+ public Builder setCustomView(View customView) {
+ this.customView = customView;
+ return this;
+ }
+
+ public Builder setLayoutId(@LayoutRes int layoutId) {
+ this.layoutId = layoutId;
+ return this;
+ }
+
+ public Builder setTag(Object tag) {
+ this.tag = tag;
+ return this;
+ }
+
+ public Builder setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ return this;
+ }
+
+ public Builder setOnClickListener(View.OnClickListener onClickListener) {
+ this.onClickListener = onClickListener;
+ return this;
+ }
+
+ public Builder setPosition(int position) {
+ this.position = position;
+ return this;
+ }
+
+ public BaseBottomSheetItem create() {
+ return new BaseBottomSheetItem(customView, layoutId, tag, disabled, onClickListener, position);
+ }
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java
new file mode 100644
index 0000000000..8a967beab4
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java
@@ -0,0 +1,87 @@
+package net.osmand.plus.base.bottomsheetmenu;
+
+import android.content.res.ColorStateList;
+import android.graphics.drawable.Drawable;
+import android.support.annotation.ColorRes;
+import android.support.annotation.LayoutRes;
+import android.support.v4.widget.CompoundButtonCompat;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CompoundButton;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+
+public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescription {
+
+ private boolean checked;
+ private ColorStateList buttonTintList;
+
+ public BottomSheetItemWithCompoundButton(View customView,
+ @LayoutRes int layoutId,
+ Object tag,
+ boolean disabled,
+ View.OnClickListener onClickListener,
+ int position,
+ Drawable icon,
+ String title,
+ @ColorRes int titleColorId,
+ CharSequence description,
+ @ColorRes int descriptionColorId,
+ boolean checked,
+ ColorStateList buttonTintList) {
+ super(customView,
+ layoutId,
+ tag,
+ disabled,
+ onClickListener,
+ position,
+ icon,
+ title,
+ titleColorId,
+ description,
+ descriptionColorId);
+ this.checked = checked;
+ this.buttonTintList = buttonTintList;
+ }
+
+ @Override
+ public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
+ super.inflate(app, container, nightMode);
+ CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
+ compoundButton.setChecked(checked);
+ CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
+ }
+
+ public static class Builder extends BottomSheetItemWithDescription.Builder {
+
+ protected boolean checked;
+ protected ColorStateList buttonTintList;
+
+ public Builder setChecked(boolean checked) {
+ this.checked = checked;
+ return this;
+ }
+
+ public Builder setButtonTintList(ColorStateList buttonTintList) {
+ this.buttonTintList = buttonTintList;
+ return this;
+ }
+
+ public BottomSheetItemWithCompoundButton create() {
+ return new BottomSheetItemWithCompoundButton(customView,
+ layoutId,
+ tag,
+ disabled,
+ onClickListener,
+ position,
+ icon,
+ title,
+ titleColorId,
+ description,
+ descriptionColorId,
+ checked,
+ buttonTintList);
+ }
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java
new file mode 100644
index 0000000000..7b5896c3f7
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java
@@ -0,0 +1,82 @@
+package net.osmand.plus.base.bottomsheetmenu;
+
+import android.graphics.drawable.Drawable;
+import android.support.annotation.ColorRes;
+import android.support.annotation.LayoutRes;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+
+public class BottomSheetItemWithDescription extends SimpleBottomSheetItem {
+
+ protected CharSequence description;
+ @ColorRes
+ private int descriptionColorId = INVALID_ID;
+
+ public BottomSheetItemWithDescription(View customView,
+ @LayoutRes int layoutId,
+ Object tag,
+ boolean disabled,
+ View.OnClickListener onClickListener,
+ int position,
+ Drawable icon,
+ String title,
+ @ColorRes int titleColorId,
+ CharSequence description,
+ @ColorRes int descriptionColorId) {
+ super(customView, layoutId, tag, disabled, onClickListener, position, icon, title, titleColorId);
+ this.description = description;
+ this.descriptionColorId = descriptionColorId;
+ }
+
+ protected BottomSheetItemWithDescription() {
+
+ }
+
+ @Override
+ public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
+ super.inflate(app, container, nightMode);
+ if (description != null) {
+ TextView descriptionTv = (TextView) view.findViewById(R.id.description);
+ descriptionTv.setText(description);
+ if (descriptionColorId != INVALID_ID) {
+ descriptionTv.setTextColor(ContextCompat.getColor(app, descriptionColorId));
+ }
+ }
+ }
+
+ public static class Builder extends SimpleBottomSheetItem.Builder {
+
+ protected CharSequence description;
+ @ColorRes
+ protected int descriptionColorId = INVALID_ID;
+
+ public Builder setDescription(CharSequence description) {
+ this.description = description;
+ return this;
+ }
+
+ public Builder setDescriptionColorId(@ColorRes int descriptionColorId) {
+ this.descriptionColorId = descriptionColorId;
+ return this;
+ }
+
+ public BottomSheetItemWithDescription create() {
+ return new BottomSheetItemWithDescription(customView,
+ layoutId,
+ tag,
+ disabled,
+ onClickListener,
+ position,
+ icon,
+ title,
+ titleColorId,
+ description,
+ descriptionColorId);
+ }
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java
new file mode 100644
index 0000000000..53b861fea6
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java
@@ -0,0 +1,90 @@
+package net.osmand.plus.base.bottomsheetmenu;
+
+import android.graphics.drawable.Drawable;
+import android.support.annotation.ColorRes;
+import android.support.annotation.LayoutRes;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+
+public class SimpleBottomSheetItem extends BaseBottomSheetItem {
+
+ private Drawable icon;
+ protected String title;
+ @ColorRes
+ protected int titleColorId = INVALID_ID;
+
+ public SimpleBottomSheetItem(View customView,
+ @LayoutRes int layoutId,
+ Object tag,
+ boolean disabled,
+ View.OnClickListener onClickListener,
+ int position,
+ Drawable icon,
+ String title,
+ @ColorRes int titleColorId) {
+ super(customView, layoutId, tag, disabled, onClickListener, position);
+ this.icon = icon;
+ this.title = title;
+ this.titleColorId = titleColorId;
+ }
+
+ protected SimpleBottomSheetItem() {
+
+ }
+
+ @Override
+ public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
+ super.inflate(app, container, nightMode);
+ if (icon != null) {
+ ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(icon);
+ }
+ if (title != null) {
+ TextView titleTv = (TextView) view.findViewById(R.id.title);
+ titleTv.setText(title);
+ if (titleColorId != INVALID_ID) {
+ titleTv.setTextColor(ContextCompat.getColor(app, titleColorId));
+ }
+ }
+ }
+
+ public static class Builder extends BaseBottomSheetItem.Builder {
+
+ protected Drawable icon;
+ protected String title;
+ @ColorRes
+ protected int titleColorId = INVALID_ID;
+
+ public Builder setIcon(Drawable icon) {
+ this.icon = icon;
+ return this;
+ }
+
+ public Builder setTitle(String title) {
+ this.title = title;
+ return this;
+ }
+
+ public Builder setTitleColorId(@ColorRes int titleColorId) {
+ this.titleColorId = titleColorId;
+ return this;
+ }
+
+ public SimpleBottomSheetItem create() {
+ return new SimpleBottomSheetItem(customView,
+ layoutId,
+ tag,
+ disabled,
+ onClickListener,
+ position,
+ icon,
+ title,
+ titleColorId);
+ }
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DescriptionItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DescriptionItem.java
new file mode 100644
index 0000000000..759c2273bb
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DescriptionItem.java
@@ -0,0 +1,12 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import net.osmand.plus.R;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
+
+public class DescriptionItem extends BottomSheetItemWithDescription {
+
+ public DescriptionItem(CharSequence description) {
+ this.description = description;
+ this.layoutId = R.layout.bottom_sheet_item_description;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DividerHalfItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DividerHalfItem.java
new file mode 100644
index 0000000000..4d2b965a9e
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DividerHalfItem.java
@@ -0,0 +1,31 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import android.content.Context;
+import android.support.annotation.ColorRes;
+
+import net.osmand.plus.R;
+
+public class DividerHalfItem extends DividerItem {
+
+ public DividerHalfItem(Context context) {
+ super(context);
+ }
+
+ public DividerHalfItem(Context context, @ColorRes int colorId) {
+ super(context, colorId);
+ }
+
+ public DividerHalfItem(Context context, @ColorRes int colorId, int position) {
+ super(context, colorId, position);
+ }
+
+ @Override
+ protected int getTopMargin(Context context) {
+ return context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_divider_margin_top);
+ }
+
+ @Override
+ protected int getLeftMargin(Context context) {
+ return context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_divider_margin_start);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DividerItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DividerItem.java
new file mode 100644
index 0000000000..749235b733
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/DividerItem.java
@@ -0,0 +1,71 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import android.content.Context;
+import android.support.annotation.ColorRes;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import net.osmand.AndroidUtils;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+
+public class DividerItem extends BaseBottomSheetItem {
+
+ @ColorRes
+ private int colorId;
+
+ public DividerItem(Context context) {
+ setupView(context, INVALID_ID, INVALID_POSITION);
+ }
+
+ public DividerItem(Context context, @ColorRes int colorId) {
+ setupView(context, colorId, INVALID_POSITION);
+ }
+
+ public DividerItem(Context context, @ColorRes int colorId, int position) {
+ setupView(context, colorId, position);
+ }
+
+ private void setupView(Context context, @ColorRes int colorId, int position) {
+ view = new View(context);
+ this.colorId = colorId;
+ this.position = position;
+ }
+
+ @Override
+ public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
+ super.inflate(app, container, nightMode);
+
+ int height = AndroidUtils.dpToPx(app, 1);
+
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
+ params.setMargins(getLeftMargin(app), getTopMargin(app), 0, getBottomMargin(app));
+ params.height = height;
+
+ view.setMinimumHeight(height);
+ view.setBackgroundColor(ContextCompat.getColor(app, getBgColorId(nightMode)));
+ }
+
+ protected int getTopMargin(Context context) {
+ return context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_content_padding_small);
+ }
+
+ protected int getLeftMargin(Context context) {
+ return 0;
+ }
+
+ protected int getBottomMargin(Context context) {
+ return context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_content_padding_small);
+ }
+
+ @ColorRes
+ private int getBgColorId(boolean nightMode) {
+ if (colorId != INVALID_ID) {
+ return colorId;
+ }
+ return nightMode ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitleDividerItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitleDividerItem.java
new file mode 100644
index 0000000000..ab94b87737
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitleDividerItem.java
@@ -0,0 +1,24 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import android.content.Context;
+import android.support.annotation.ColorRes;
+
+public class SubtitleDividerItem extends DividerItem {
+
+ public SubtitleDividerItem(Context context) {
+ super(context);
+ }
+
+ public SubtitleDividerItem(Context context, @ColorRes int colorId) {
+ super(context, colorId);
+ }
+
+ public SubtitleDividerItem(Context context, @ColorRes int colorId, int position) {
+ super(context, colorId, position);
+ }
+
+ @Override
+ protected int getBottomMargin(Context context) {
+ return 0;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitleItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitleItem.java
new file mode 100644
index 0000000000..cd87cecf74
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitleItem.java
@@ -0,0 +1,12 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import net.osmand.plus.R;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+
+public class SubtitleItem extends SimpleBottomSheetItem {
+
+ public SubtitleItem(String title) {
+ this.title = title;
+ this.layoutId = R.layout.bottom_sheet_item_subtitle;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/TitleDividerItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/TitleDividerItem.java
new file mode 100644
index 0000000000..d1531d80b5
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/TitleDividerItem.java
@@ -0,0 +1,24 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import android.content.Context;
+import android.support.annotation.ColorRes;
+
+public class TitleDividerItem extends DividerItem {
+
+ public TitleDividerItem(Context context) {
+ super(context);
+ }
+
+ public TitleDividerItem(Context context, @ColorRes int colorId) {
+ super(context, colorId);
+ }
+
+ public TitleDividerItem(Context context, @ColorRes int colorId, int position) {
+ super(context, colorId, position);
+ }
+
+ @Override
+ protected int getTopMargin(Context context) {
+ return 0;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/TitleItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/TitleItem.java
new file mode 100644
index 0000000000..18a25d73b3
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/TitleItem.java
@@ -0,0 +1,21 @@
+package net.osmand.plus.base.bottomsheetmenu.simpleitems;
+
+import android.view.ViewGroup;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+
+public class TitleItem extends SimpleBottomSheetItem {
+
+ public TitleItem(String title) {
+ this.title = title;
+ this.layoutId = R.layout.bottom_sheet_item_title;
+ }
+
+ @Override
+ public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
+ titleColorId = nightMode ? R.color.ctx_menu_info_text_dark : INVALID_ID;
+ super.inflate(app, container, nightMode);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java
index 67f1c11105..17d5b7c289 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java
@@ -8,13 +8,7 @@ import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
@@ -23,6 +17,10 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -31,68 +29,103 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
public static final String LON_KEY = "longitude";
public static final String POINT_DESCRIPTION_KEY = "point_description";
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public void createMenuItems(Bundle savedInstanceState) {
Bundle args = getArguments();
final LatLon latLon = new LatLon(args.getDouble(LAT_KEY), args.getDouble(LON_KEY));
final PointDescription name = PointDescription.deserializeFromString(args.getString(POINT_DESCRIPTION_KEY), latLon);
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.fragment_add_waypoint_bottom_sheet_dialog, container);
+ items.add(new TitleItem(getString(R.string.new_destination_point_dialog)));
- ((TextView) mainView.findViewById(R.id.current_dest_text_view))
- .setText(getCurrentPointName(targetPointsHelper.getPointToNavigate(), false));
- ((TextView) mainView.findViewById(R.id.current_start_text_view))
- .setText(getCurrentPointName(targetPointsHelper.getPointToStart(), true));
-
- ((ImageView) mainView.findViewById(R.id.subsequent_dest_icon)).setImageDrawable(getSubsequentDestIcon());
- ((ImageView) mainView.findViewById(R.id.first_interm_dest_icon)).setImageDrawable(getFirstIntermDestIcon());
- ((ImageView) mainView.findViewById(R.id.last_interm_dest_icon)).setImageDrawable(getLastIntermDistIcon());
-
- View.OnClickListener onClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- int id = v.getId();
- if (id == R.id.replace_dest_row) {
- targetPointsHelper.navigateToPoint(latLon, true, -1, name);
- } else if (id == R.id.replace_start_row) {
- TargetPoint start = targetPointsHelper.getPointToStart();
- if (start != null) {
- targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()),
- false, 0, start.getOriginalPointDescription());
+ BaseBottomSheetItem replaceDestItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getCurrentPointName(targetPointsHelper.getPointToNavigate(), false))
+ .setDescriptionColorId(R.color.searchbar_text_hint_light)
+ .setIcon(getIcon(R.drawable.list_destination, 0))
+ .setTitle(getString(R.string.replace_destination_point))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ targetPointsHelper.navigateToPoint(latLon, true, -1, name);
+ dismiss();
}
- targetPointsHelper.setStartPoint(latLon, true, name);
- } else if (id == R.id.subsequent_dest_row) {
- targetPointsHelper.navigateToPoint(latLon, true,
- targetPointsHelper.getIntermediatePoints().size() + 1, name);
- } else if (id == R.id.first_intermediate_dest_row) {
- targetPointsHelper.navigateToPoint(latLon, true, 0, name);
- } else if (id == R.id.last_intermediate_dest_row) {
- targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), name);
- }
- dismiss();
- }
- };
+ })
+ .create();
+ items.add(replaceDestItem);
- mainView.findViewById(R.id.replace_dest_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.replace_start_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.subsequent_dest_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.first_intermediate_dest_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.last_intermediate_dest_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.cancel_row).setOnClickListener(onClickListener);
+ BaseBottomSheetItem replaceStartItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getCurrentPointName(targetPointsHelper.getPointToStart(), true))
+ .setDescriptionColorId(R.color.searchbar_text_hint_light)
+ .setIcon(getIcon(R.drawable.list_startpoint, 0))
+ .setTitle(getString(R.string.make_as_start_point))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ TargetPoint start = targetPointsHelper.getPointToStart();
+ if (start != null) {
+ targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()),
+ false, 0, start.getOriginalPointDescription());
+ }
+ targetPointsHelper.setStartPoint(latLon, true, name);
+ dismiss();
+ }
+ })
+ .create();
+ items.add(replaceStartItem);
- if (nightMode) {
- int dividerColor = ContextCompat.getColor(getContext(), R.color.route_info_bottom_view_bg_dark);
- mainView.findViewById(R.id.current_dest_divider).setBackgroundColor(dividerColor);
- mainView.findViewById(R.id.cancel_divider).setBackgroundColor(dividerColor);
- }
+ items.add(new DividerHalfItem(getContext(), getCloseRowDividerColorId()));
- setupHeightAndBackground(mainView, R.id.scroll_view);
+ BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.subsequent_dest_description))
+ .setDescriptionColorId(R.color.searchbar_text_hint_light)
+ .setIcon(getSubsequentDestIcon())
+ .setTitle(getString(R.string.keep_and_add_destination_point))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ targetPointsHelper.navigateToPoint(latLon, true,
+ targetPointsHelper.getIntermediatePoints().size() + 1, name);
+ dismiss();
+ }
+ })
+ .create();
+ items.add(subsequentDestItem);
- return mainView;
+ BaseBottomSheetItem firstIntermItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.first_intermediate_dest_description))
+ .setDescriptionColorId(R.color.searchbar_text_hint_light)
+ .setIcon(getFirstIntermDestIcon())
+ .setTitle(getString(R.string.add_as_first_destination_point))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ targetPointsHelper.navigateToPoint(latLon, true, 0, name);
+ dismiss();
+ }
+ })
+ .create();
+ items.add(firstIntermItem);
+
+ BaseBottomSheetItem lastIntermItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.last_intermediate_dest_description))
+ .setDescriptionColorId(R.color.searchbar_text_hint_light)
+ .setIcon(getLastIntermDistIcon())
+ .setTitle(getString(R.string.add_as_last_destination_point))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ targetPointsHelper.navigateToPoint(latLon, true,
+ targetPointsHelper.getIntermediatePoints().size(), name);
+ dismiss();
+ }
+ })
+ .create();
+ items.add(lastIntermItem);
}
@Override
@@ -101,6 +134,11 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
closeContextMenu();
}
+ @Override
+ protected int getCloseRowDividerColorId() {
+ return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
+ }
+
@Override
protected Drawable getActiveIcon(@DrawableRes int id) {
return getIcon(id, nightMode ? R.color.ctx_menu_direction_color_dark : R.color.map_widget_blue);
diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java
index 9fa877cf67..a7c2593f1b 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java
@@ -13,20 +13,18 @@ import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.provider.OpenableColumns;
import android.provider.Settings;
+import android.support.annotation.ColorInt;
+import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
-import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import android.widget.Toast;
import net.osmand.IProgress;
@@ -39,6 +37,11 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
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.DescriptionItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
@@ -742,53 +745,53 @@ public class ImportHelper {
this.useImportDir = useImportDir;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.import_file)));
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_import_gpx_bottom_sheet_dialog, container);
-
- if (nightMode) {
- ((TextView) mainView.findViewById(R.id.import_gpx_title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
- }
-
- ((ImageView) mainView.findViewById(R.id.import_as_favorites_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
- ((ImageView) mainView.findViewById(R.id.import_as_gpx_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
-
- int nameColor = ContextCompat.getColor(getContext(), nightMode ? R.color.osmand_orange : R.color.dashboard_blue);
- int descrColor = ContextCompat.getColor(getContext(), nightMode ? R.color.dashboard_subheader_text_dark : R.color.dashboard_subheader_text_light);
+ int nameColor = getResolvedColor(nightMode ? R.color.osmand_orange : R.color.dashboard_blue);
+ int descrColor = getResolvedColor(nightMode ? R.color.dashboard_subheader_text_dark : R.color.dashboard_subheader_text_light);
String descr = getString(R.string.import_gpx_file_description);
SpannableStringBuilder text = new SpannableStringBuilder(fileName).append(" ").append(descr);
text.setSpan(new ForegroundColorSpan(nameColor), 0, fileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ForegroundColorSpan(descrColor), fileName.length() + 1, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- ((TextView) mainView.findViewById(R.id.import_gpx_description)).setText(text);
- mainView.findViewById(R.id.import_as_favorites_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- importHelper.importFavoritesImpl(gpxFile, fileName, false);
- dismiss();
- }
- });
- mainView.findViewById(R.id.import_as_gpx_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- importHelper.handleResult(gpxFile, fileName, save, useImportDir, false);
- dismiss();
- }
- });
+ items.add(new DescriptionItem(text));
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
+ BaseBottomSheetItem asFavoritesItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_fav_dark))
+ .setTitle(getString(R.string.import_as_favorites))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ importHelper.importFavoritesImpl(gpxFile, fileName, false);
+ dismiss();
+ }
+ })
+ .create();
+ items.add(asFavoritesItem);
- setupHeightAndBackground(mainView, R.id.import_gpx_scroll_view);
+ items.add(new DividerHalfItem(getContext()));
- return mainView;
+ BaseBottomSheetItem asGpxItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
+ .setTitle(getString(R.string.import_as_gpx))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ importHelper.handleResult(gpxFile, fileName, save, useImportDir, false);
+ dismiss();
+ }
+ })
+ .create();
+ items.add(asGpxItem);
+ }
+
+ @ColorInt
+ private int getResolvedColor(@ColorRes int colorId) {
+ return ContextCompat.getColor(getContext(), colorId);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java
index 650cfa12c9..9be893ee1e 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java
@@ -1,33 +1,20 @@
package net.osmand.plus.mapcontextmenu.other;
-import android.annotation.SuppressLint;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
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.mapcontextmenu.other.ShareMenu.ShareItem;
-import net.osmand.plus.widgets.TextViewEx;
-import java.util.List;
+public class ShareMenuFragment extends MenuBottomSheetDialogFragment {
-
-public class ShareMenuFragment extends MenuBottomSheetDialogFragment implements OnItemClickListener {
public static final String TAG = "ShareMenuFragment";
- private ArrayAdapter listAdapter;
private ShareMenu menu;
@Override
@@ -38,36 +25,33 @@ public class ShareMenuFragment extends MenuBottomSheetDialogFragment implements
}
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.share_menu_fragment, container);
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.share_menu_location)));
- if (nightMode) {
- ((TextViewEx) view.findViewById(R.id.title_text_view)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
-
- ListView listView = (ListView) view.findViewById(R.id.list);
- listAdapter = createAdapter();
- listView.setAdapter(listAdapter);
- listView.setOnItemClickListener(this);
-
- view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
+ View.OnClickListener itemOnClickListener = new View.OnClickListener() {
@Override
- public void onClick(View view) {
+ public void onClick(View v) {
dismiss();
+ menu.share((ShareItem) v.getTag());
}
- });
+ };
- setupHeightAndBackground(view, R.id.scroll_view);
-
- return view;
+ for (ShareItem shareItem : menu.getItems()) {
+ BaseBottomSheetItem item = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(shareItem.getIconResourceId()))
+ .setTitle(getString(shareItem.getTitleResourceId()))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(itemOnClickListener)
+ .setTag(shareItem)
+ .create();
+ items.add(item);
+ }
}
@Override
public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
menu.saveMenu(outState);
}
@@ -77,39 +61,4 @@ public class ShareMenuFragment extends MenuBottomSheetDialogFragment implements
fragment.setUsedOnMap(true);
fragment.show(menu.getMapActivity().getSupportFragmentManager(), ShareMenuFragment.TAG);
}
-
- private ArrayAdapter createAdapter() {
- final List items = menu.getItems();
- return new ArrayAdapter(menu.getMapActivity(), R.layout.share_list_item, items) {
-
- @SuppressLint("InflateParams")
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- View v = convertView;
- if (v == null) {
- v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null);
- }
- AndroidUtils.setBackground(v.getContext(), v, nightMode, R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
- final ShareItem item = getItem(position);
- ImageView icon = (ImageView) v.findViewById(R.id.icon);
- icon.setImageDrawable(menu.getMapActivity().getMyApplication()
- .getIconsCache().getIcon(item.getIconResourceId(), !nightMode));
- TextView name = (TextView) v.findViewById(R.id.name);
- AndroidUtils.setTextPrimaryColor(v.getContext(), name, nightMode);
- name.setText(getContext().getText(item.getTitleResourceId()));
- return v;
- }
- };
- }
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- dismiss();
- menu.share(listAdapter.getItem(position));
- }
-
- public void dismissMenu() {
- dismiss();
- menu.getMapActivity().getContextMenu().close();
- }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java
index 9366dab18e..6dc530bef5 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java
@@ -2,18 +2,16 @@ package net.osmand.plus.mapmarkers;
import android.app.Dialog;
import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.mapmarkers.adapters.GroupsAdapter;
public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -35,11 +33,11 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD
mapMarkersHelper = getMyApplication().getMapMarkersHelper();
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public void createMenuItems(Bundle savedInstanceState) {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_add_group_bottom_sheet_dialog, container);
+ mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
+ R.layout.fragment_marker_add_group_bottom_sheet_dialog, null);
final RecyclerView recyclerView = mainView.findViewById(R.id.groups_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
@@ -67,16 +65,7 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD
});
recyclerView.setAdapter(adapter);
- mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.groups_recycler_view);
-
- return mainView;
+ items.add(new BaseBottomSheetItem.Builder().setCustomView(mainView).create());
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
index dea0ec8632..75472c3b3b 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
@@ -4,23 +4,20 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.support.annotation.ColorInt;
+import android.support.annotation.ColorRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
-import android.support.v4.widget.CompoundButtonCompat;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.TextView;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef;
@@ -51,58 +48,62 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
}
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public void createMenuItems(Bundle savedInstanceState) {
final Context context = getContext();
final OsmandSettings settings = getMyApplication().getSettings();
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
- View mainView = View.inflate(new ContextThemeWrapper(context, themeRes),
- R.layout.fragment_marker_coordinate_input_options_bottom_sheet_dialog, container);
+ items.add(new TitleItem(getString(R.string.shared_string_options)));
- if (nightMode) {
- ((TextView) mainView.findViewById(R.id.coordinate_input_title))
- .setTextColor(ContextCompat.getColor(context, R.color.ctx_menu_info_text_dark));
- }
-
- ((ImageView) mainView.findViewById(R.id.use_system_keyboard_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
- ((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
-
- View.OnClickListener itemsOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- int id = v.getId();
- if (id == R.id.use_system_keyboard_row) {
- listener.onKeyboardChanged(!useOsmandKeyboard);
- } else if (id == R.id.hand_row) {
- OsmandSettings.CommonPreference pref = settings.COORDS_INPUT_USE_RIGHT_SIDE;
- pref.set(!pref.get());
- listener.onHandChanged();
+ BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder()
+ .setChecked(!useOsmandKeyboard)
+ .setIcon(getContentIcon(R.drawable.ic_action_keyboard))
+ .setTitle(getString(R.string.use_system_keyboard))
+ .setLayoutId(R.layout.bottom_sheet_item_with_switch)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onKeyboardChanged(!useOsmandKeyboard);
+ }
+ dismiss();
}
- }
- dismiss();
- }
- };
+ })
+ .create();
+ items.add(useSystemKeyboardItem);
- mainView.findViewById(R.id.use_system_keyboard_row).setOnClickListener(itemsOnClickListener);
- mainView.findViewById(R.id.cancel_row).setOnClickListener(itemsOnClickListener);
-
- View handRow = mainView.findViewById(R.id.hand_row);
- if (portrait) {
- handRow.setVisibility(View.GONE);
- } else {
+ if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
boolean rightHand = settings.COORDS_INPUT_USE_RIGHT_SIDE.get();
- ((ImageView) mainView.findViewById(R.id.hand_icon)).setImageDrawable(getContentIcon(rightHand
- ? R.drawable.ic_action_show_keypad_right : R.drawable.ic_action_show_keypad_left));
- ((TextView) mainView.findViewById(R.id.hand_text_view)).setText(getString(rightHand
- ? R.string.shared_string_right : R.string.shared_string_left));
- ((TextView) mainView.findViewById(R.id.hand_text_view)).setTextColor(getResolvedActiveColor());
- handRow.setOnClickListener(itemsOnClickListener);
+
+ BaseBottomSheetItem showNumberPadItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(rightHand ? R.string.shared_string_right : R.string.shared_string_left))
+ .setDescriptionColorId(getActiveColorId())
+ .setIcon(getContentIcon(rightHand
+ ? R.drawable.ic_action_show_keypad_right
+ : R.drawable.ic_action_show_keypad_left))
+ .setTitle(getString(R.string.show_number_pad))
+ .setLayoutId(R.layout.bottom_sheet_item_with_right_descr)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ OsmandSettings.CommonPreference pref = settings.COORDS_INPUT_USE_RIGHT_SIDE;
+ pref.set(!pref.get());
+ listener.onHandChanged();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(showNumberPadItem);
}
+ items.add(new SubtitleDividerItem(context));
+
+ items.add(new SubtitleItem(getString(R.string.coordinates_format)));
+
+ int selectedFormat = settings.COORDS_INPUT_FORMAT.get();
+ Drawable formatIcon = getContentIcon(R.drawable.ic_action_coordinates_latitude);
View.OnClickListener formatsOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -115,34 +116,23 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
}
};
- LinearLayout formatsContainer = (LinearLayout) mainView.findViewById(R.id.formats_container);
- Drawable formatIcon = getContentIcon(R.drawable.ic_action_coordinates_latitude);
- int selectedFormat = settings.COORDS_INPUT_FORMAT.get();
for (@CoordinateInputFormatDef int format : CoordinateInputFormats.VALUES) {
- boolean selectedRow = format == selectedFormat;
+ boolean selectedItem = format == selectedFormat;
- View row = View.inflate(new ContextThemeWrapper(context, themeRes),
- R.layout.bottom_sheet_item_with_radio_btn, null);
- row.setTag(format);
- row.setOnClickListener(formatsOnClickListener);
-
- ((ImageView) row.findViewById(R.id.icon_iv)).setImageDrawable(selectedRow
- ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon);
- TextView nameTv = (TextView) row.findViewById(R.id.name_tv);
- nameTv.setText(CoordinateInputFormats.formatToHumanString(context, format));
- if (selectedRow) {
- nameTv.setTextColor(getResolvedActiveColor());
- RadioButton rb = (RadioButton) row.findViewById(R.id.radio_button);
- rb.setChecked(true);
- CompoundButtonCompat.setButtonTintList(rb, ColorStateList.valueOf(getResolvedActiveColor()));
- }
-
- formatsContainer.addView(row);
+ BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder()
+ .setChecked(selectedItem)
+ .setButtonTintList(selectedItem
+ ? ColorStateList.valueOf(ContextCompat.getColor(context, getActiveColorId()))
+ : null)
+ .setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon)
+ .setTitle(CoordinateInputFormats.formatToHumanString(context, format))
+ .setTitleColorId(selectedItem ? getActiveColorId() : BaseBottomSheetItem.INVALID_ID)
+ .setLayoutId(R.layout.bottom_sheet_item_with_radio_btn)
+ .setOnClickListener(formatsOnClickListener)
+ .setTag(format)
+ .create();
+ items.add(formatItem);
}
-
- setupHeightAndBackground(mainView, R.id.marker_coordinate_input_scroll_view);
-
- return mainView;
}
@Override
@@ -151,9 +141,14 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
super.onSaveInstanceState(outState);
}
- @ColorInt
- private int getResolvedActiveColor() {
- return ContextCompat.getColor(getContext(), nightMode ? R.color.osmand_orange : R.color.color_myloc_distance);
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
+ }
+
+ @ColorRes
+ private int getActiveColorId() {
+ return nightMode ? R.color.osmand_orange : R.color.color_myloc_distance;
}
interface CoordinateInputFormatChangeListener {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java
index 3fe99d59cb..798729d301 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java
@@ -1,17 +1,16 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
+import net.osmand.util.Algorithms;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -32,63 +31,69 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
-
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
-
+ public void createMenuItems(Bundle savedInstanceState) {
Bundle arguments = getArguments();
+
if (arguments != null) {
final int pos = arguments.getInt(MARKER_POSITION);
- String markerName = arguments.getString(MARKER_NAME);
- int markerColorIndex = arguments.getInt(MARKER_COLOR_INDEX);
- long markerVisitedDate = arguments.getLong(MARKER_VISITED_DATE);
- ((TextView) mainView.findViewById(R.id.map_marker_title)).setText(markerName);
- ((ImageView) mainView.findViewById(R.id.map_marker_icon)).setImageDrawable(getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(markerColorIndex)));
+ final String markerName = arguments.getString(MARKER_NAME);
+ final int markerColorIndex = arguments.getInt(MARKER_COLOR_INDEX);
+ final long markerVisitedDate = arguments.getLong(MARKER_VISITED_DATE);
+
Date date = new Date(markerVisitedDate);
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
- if (month.length() > 1) {
- month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
- }
+ month = Algorithms.capitalizeFirstLetter(month);
month = month.replaceAll("\\.", "");
String day = new SimpleDateFormat("d", Locale.getDefault()).format(date);
- ((TextView) mainView.findViewById(R.id.map_marker_passed_info)).setText(getString(R.string.passed, month + " " + day));
- mainView.findViewById(R.id.make_active_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onMakeMarkerActive(pos);
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onDeleteMarker(pos);
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem markerItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.passed, month + " " + day))
+ .setIcon(getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(markerColorIndex)))
+ .setTitle(markerName)
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .create();
+ items.add(markerItem);
+
+ items.add(new DividerItem(getContext()));
+
+ BaseBottomSheetItem makeActiveItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_reset_to_default_dark))
+ .setTitle(getString(R.string.make_active))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onMakeMarkerActive(pos);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(makeActiveItem);
+
+ BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_delete_dark))
+ .setTitle(getString(R.string.shared_string_delete))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onDeleteMarker(pos);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(deleteItem);
}
+ }
- ((ImageView) mainView.findViewById(R.id.make_active_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_reset_to_default_dark));
- ((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
-
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.history_marker_scroll_view);
-
- return mainView;
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
}
interface HistoryMarkerMenuFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java
index b50682748d..7b786261ca 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java
@@ -2,19 +2,16 @@ package net.osmand.plus.mapmarkers;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarkersSortByDef;
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.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -26,69 +23,101 @@ public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
-
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.fragment_marker_order_by_bottom_sheet_dialog, container);
-
- if (nightMode) {
- ((TextView) mainView.findViewById(R.id.order_by_title)).setTextColor(
- ContextCompat.getColor(getContext(), R.color.ctx_menu_info_text_dark)
- );
- }
-
+ public void createMenuItems(Bundle savedInstanceState) {
Drawable distanceIcon = getContentIcon(R.drawable.ic_action_markers_dark);
Drawable dateIcon = getContentIcon(R.drawable.ic_action_sort_by_date);
- ((ImageView) mainView.findViewById(R.id.name_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_name));
- ((ImageView) mainView.findViewById(R.id.distance_nearest_icon)).setImageDrawable(distanceIcon);
- ((ImageView) mainView.findViewById(R.id.distance_farthest_icon)).setImageDrawable(distanceIcon);
- ((ImageView) mainView.findViewById(R.id.date_added_asc_icon)).setImageDrawable(dateIcon);
- ((ImageView) mainView.findViewById(R.id.date_added_desc_icon)).setImageDrawable(dateIcon);
- ((TextView) mainView.findViewById(R.id.date_added_asc_text)).setText(getString(R.string.date_added) + " (" + getString(R.string.ascendingly) + ")");
- ((TextView) mainView.findViewById(R.id.date_added_desc_text)).setText(getString(R.string.date_added) + " (" + getString(R.string.descendingly) + ")");
+ items.add(new TitleItem(getString(R.string.sort_by)));
- View.OnClickListener onClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- int sortByMode = -1;
- switch (v.getId()) {
- case R.id.name_row:
- sortByMode = MapMarkersHelper.BY_NAME;
- break;
- case R.id.distance_nearest_row:
- sortByMode = MapMarkersHelper.BY_DISTANCE_ASC;
- break;
- case R.id.distance_farthest_row:
- sortByMode = MapMarkersHelper.BY_DISTANCE_DESC;
- break;
- case R.id.date_added_asc_row:
- sortByMode = MapMarkersHelper.BY_DATE_ADDED_ASC;
- break;
- case R.id.date_added_desc_row:
- sortByMode = MapMarkersHelper.BY_DATE_ADDED_DESC;
- break;
- }
- if (sortByMode != -1 && listener != null) {
- listener.onMapMarkersOrderByModeChanged(sortByMode);
- }
- dismiss();
- }
- };
+ BaseBottomSheetItem byNameItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_sort_by_name))
+ .setTitle(getString(R.string.shared_string_name))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_NAME);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(byNameItem);
- mainView.findViewById(R.id.name_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.distance_nearest_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.distance_farthest_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.date_added_asc_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.date_added_desc_row).setOnClickListener(onClickListener);
- mainView.findViewById(R.id.close_row).setOnClickListener(onClickListener);
+ items.add(new DividerHalfItem(getContext()));
- setupHeightAndBackground(mainView, R.id.marker_order_by_scroll_view);
+ BaseBottomSheetItem distNearestItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(distanceIcon)
+ .setTitle(getString(R.string.distance_nearest))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DISTANCE_ASC);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(distNearestItem);
- return mainView;
+ BaseBottomSheetItem distFarthestItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(distanceIcon)
+ .setTitle(getString(R.string.distance_farthest))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DISTANCE_DESC);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(distFarthestItem);
+
+ items.add(new DividerHalfItem(getContext()));
+
+ BaseBottomSheetItem dateAscItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(dateIcon)
+ .setTitle(getString(R.string.date_added) + " (" + getString(R.string.ascendingly) + ")")
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DATE_ADDED_ASC);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(dateAscItem);
+
+ BaseBottomSheetItem dateDescItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(dateIcon)
+ .setTitle(getString(R.string.date_added) + " (" + getString(R.string.descendingly) + ")")
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DATE_ADDED_DESC);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(dateDescItem);
+ }
+
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
}
interface OrderByFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
index fab4fcc504..a14e2e306a 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
@@ -150,9 +150,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
}
Fragment optionsFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
if (optionsFragment != null) {
- PlanRouteOptionsBottomSheetDialogFragment fragment = (PlanRouteOptionsBottomSheetDialogFragment) optionsFragment;
- fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
- fragment.setListener(createOptionsFragmentListener());
+ ((PlanRouteOptionsBottomSheetDialogFragment) optionsFragment).setListener(createOptionsFragmentListener());
}
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
@@ -722,9 +720,12 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
private void optionsOnClick() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
+ Bundle args = new Bundle();
+ args.putBoolean(PlanRouteOptionsBottomSheetDialogFragment.SELECT_ALL_KEY,
+ !(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
+ fragment.setArguments(args);
fragment.setUsedOnMap(true);
- fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
fragment.setListener(createOptionsFragmentListener());
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java
index fe04c57e83..2386569c32 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java
@@ -1,118 +1,128 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.helpers.AndroidUiHelper;
public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
- public final static String TAG = "PlanRouteOptionsBottomSheetDialogFragment";
+ public static final String TAG = "PlanRouteOptionsBottomSheetDialogFragment";
+
+ public static final String SELECT_ALL_KEY = "select_all";
private PlanRouteOptionsFragmentListener listener;
- private boolean selectAll;
public void setListener(PlanRouteOptionsFragmentListener listener) {
this.listener = listener;
}
- public void setSelectAll(boolean selectAll) {
- this.selectAll = selectAll;
+ @Override
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.shared_string_options)));
+
+ if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
+ boolean selectAll = getArguments().getBoolean(SELECT_ALL_KEY);
+
+ BaseBottomSheetItem selectItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all))
+ .setTitle(getString(selectAll ? R.string.shared_string_select_all : R.string.shared_string_deselect_all))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.selectOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(selectItem);
+ }
+
+ BaseBottomSheetItem navigateItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark))
+ .setTitle(getString(R.string.get_directions))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.navigateOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(navigateItem);
+
+ BaseBottomSheetItem roundTripItem = new BottomSheetItemWithCompoundButton.Builder()
+ .setChecked(getMyApplication().getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get())
+ .setDescription(getString(R.string.make_round_trip_descr))
+ .setIcon(getContentIcon(R.drawable.ic_action_trip_round))
+ .setTitle(getString(R.string.make_round_trip))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.makeRoundTripOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(roundTripItem);
+
+ items.add(new SubtitleDividerItem(getContext()));
+
+ items.add(new SubtitleItem(getString(R.string.sort_by)));
+
+ BaseBottomSheetItem doorToDoorItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_sort_door_to_door))
+ .setTitle(getString(R.string.intermediate_items_sort_by_distance))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.doorToDoorOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(doorToDoorItem);
+
+ BaseBottomSheetItem reversItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order))
+ .setTitle(getString(R.string.shared_string_reverse_order))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.reverseOrderOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(reversItem);
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
-
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_options_bottom_sheet_dialog, container);
-
- if (nightMode) {
- ((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
- }
-
- ((ImageView) mainView.findViewById(R.id.navigate_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark));
- ((ImageView) mainView.findViewById(R.id.make_round_trip_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_trip_round));
- ((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door));
- ((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
-
- ((CompoundButton) mainView.findViewById(R.id.make_round_trip_switch)).setChecked(getMyApplication().getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get());
-
- if (!portrait) {
- ((ImageView) mainView.findViewById(R.id.select_icon))
- .setImageDrawable(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all));
-
- ((TextView) mainView.findViewById(R.id.select_title))
- .setText(getString(selectAll ? R.string.shared_string_select_all : R.string.shared_string_deselect_all));
-
- View selectRow = mainView.findViewById(R.id.select_row);
- selectRow.setVisibility(View.VISIBLE);
- selectRow.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- listener.selectOnClick();
- dismiss();
- }
- });
- }
- mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.navigateOnClick();
- dismiss();
- }
- }
- });
- mainView.findViewById(R.id.make_round_trip_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.makeRoundTripOnClick();
- dismiss();
- }
- }
- });
- mainView.findViewById(R.id.door_to_door_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.doorToDoorOnClick();
- dismiss();
- }
- }
- });
- mainView.findViewById(R.id.reverse_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.reverseOrderOnClick();
- dismiss();
- }
- }
- });
-
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.sort_by_scroll_view);
-
- return mainView;
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
}
interface PlanRouteOptionsFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java
index 720cb2068e..2d6923d8d3 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java
@@ -1,16 +1,14 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
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.DescriptionItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class SelectionMarkersGroupBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -22,48 +20,48 @@ public class SelectionMarkersGroupBottomSheetDialogFragment extends MenuBottomSh
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_add_markers_group_bottom_sheet_dialog, container);
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.add_group)));
- if (nightMode) {
- ((TextView) mainView.findViewById(R.id.add_group_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
+ items.add(new DescriptionItem(getString(R.string.add_group_descr)));
- ((ImageView) mainView.findViewById(R.id.favourites_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
- ((ImageView) mainView.findViewById(R.id.waypoints_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
+ BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_fav_dark))
+ .setTitle(getString(R.string.favourites_group))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.favouritesOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(favoritesItem);
- mainView.findViewById(R.id.favourites_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.favouritesOnClick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.waypoints_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.waypointsOnClick();
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem waypointsItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
+ .setTitle(getString(R.string.track_waypoints))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.waypointsOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(waypointsItem);
+ }
- mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.add_markers_group_scroll_view);
-
- return mainView;
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
}
interface AddMarkersGroupFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index d44cba2a34..0de6179047 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -272,11 +272,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
+ Bundle args = new Bundle();
+ args.putBoolean(OptionsBottomSheetDialogFragment.SNAP_TO_ROAD_ENABLED_KEY, editingCtx.isInSnapToRoadMode());
+ args.putBoolean(OptionsBottomSheetDialogFragment.ADD_LINE_MODE_KEY, newGpxData != null);
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
+ fragment.setArguments(args);
fragment.setUsedOnMap(true);
- fragment.setSnapToRoadEnabled(editingCtx.isInSnapToRoadMode());
fragment.setListener(createOptionsFragmentListener());
- fragment.setAddLineMode(newGpxData != null);
fragment.show(mapActivity.getSupportFragmentManager(), OptionsBottomSheetDialogFragment.TAG);
}
});
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
index ab83c69048..c171c60f85 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
@@ -1,124 +1,131 @@
package net.osmand.plus.measurementtool;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.SwitchCompat;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
-import net.osmand.plus.widgets.TextViewEx;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
- public final static String TAG = "OptionsBottomSheetDialogFragment";
+ public static final String TAG = "OptionsBottomSheetDialogFragment";
+
+ public static final String SNAP_TO_ROAD_ENABLED_KEY = "snap_to_road_enabled";
+ public static final String ADD_LINE_MODE_KEY = "add_line_mode";
private OptionsFragmentListener listener;
- private boolean addLineMode;
- private boolean snapToRoadEnabled;
public void setListener(OptionsFragmentListener listener) {
this.listener = listener;
}
- public void setAddLineMode(boolean addLineMode) {
- this.addLineMode = addLineMode;
- }
-
- public void setSnapToRoadEnabled(boolean snapToRoadEnabled) {
- this.snapToRoadEnabled = snapToRoadEnabled;
- }
-
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ public void createMenuItems(Bundle savedInstanceState) {
+ Bundle args = getArguments();
+ boolean snapToRoadEnabled = args.getBoolean(SNAP_TO_ROAD_ENABLED_KEY);
+ boolean addLineMode = args.getBoolean(ADD_LINE_MODE_KEY);
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_options_bottom_sheet_dialog, null);
+ items.add(new TitleItem(getString(R.string.shared_string_options)));
- if (nightMode) {
- ((TextViewEx) mainView.findViewById(R.id.options_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
- if (snapToRoadEnabled) {
- mainView.findViewById(R.id.snap_to_road_enabled_text_view).setVisibility(View.VISIBLE);
- ((SwitchCompat) mainView.findViewById(R.id.snap_to_road_switch)).setChecked(true);
- }
- ((ImageView) mainView.findViewById(R.id.snap_to_road_icon)).setImageDrawable(snapToRoadEnabled
- ? getActiveIcon(R.drawable.ic_action_snap_to_road)
- : getContentIcon(R.drawable.ic_action_snap_to_road));
- ((ImageView) mainView.findViewById(R.id.clear_all_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_reset_to_default_dark));
- if (!addLineMode) {
- ((ImageView) mainView.findViewById(R.id.save_as_new_track_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
- ((ImageView) mainView.findViewById(R.id.add_to_the_track_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_split_interval));
+ BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithCompoundButton.Builder()
+ .setChecked(snapToRoadEnabled)
+ .setDescription(getString(snapToRoadEnabled ? R.string.shared_string_enabled : R.string.shared_string_disabled))
+ .setIcon(snapToRoadEnabled
+ ? getActiveIcon(R.drawable.ic_action_snap_to_road)
+ : getContentIcon(R.drawable.ic_action_snap_to_road))
+ .setTitle(getString(R.string.snap_to_road))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.snapToRoadOnCLick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(snapToRoadItem);
+
+ items.add(new DividerHalfItem(getContext()));
+
+ if (addLineMode) {
+ BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
+ .setTitle(getString(R.string.shared_string_save))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.addToGpxOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(saveAsNewSegmentItem);
} else {
- mainView.findViewById(R.id.save_as_new_track_row).setVisibility(View.GONE);
- mainView.findViewById(R.id.add_to_the_track_row).setVisibility(View.GONE);
- mainView.findViewById(R.id.save_as_new_segment_row).setVisibility(View.VISIBLE);
- ((ImageView) mainView.findViewById(R.id.save_as_new_segment_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
+ BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
+ .setTitle(getString(R.string.shared_string_save_as_gpx))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.saveAsNewTrackOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(saveAsNewTrackItem);
+
+ BaseBottomSheetItem addToTrackItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_split_interval))
+ .setTitle(getString(R.string.add_segment_to_the_track))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.addToTheTrackOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(addToTrackItem);
}
- mainView.findViewById(R.id.snap_to_road_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.snapToRoadOnCLick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.clear_all_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.clearAllOnClick();
- }
- dismiss();
- }
- });
- if (!addLineMode) {
- mainView.findViewById(R.id.save_as_new_track_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.saveAsNewTrackOnClick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.add_to_the_track_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.addToTheTrackOnClick();
- }
- dismiss();
- }
- });
- } else {
- mainView.findViewById(R.id.save_as_new_segment_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.addToGpxOnClick();
- }
- dismiss();
- }
- });
- }
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
+ items.add(new DividerHalfItem(getContext()));
- setupHeightAndBackground(mainView, R.id.measure_options_scroll_view);
+ BaseBottomSheetItem clearAllItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_reset_to_default_dark))
+ .setTitle(getString(R.string.shared_string_clear_all))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.clearAllOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(clearAllItem);
+ }
- return mainView;
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
}
interface OptionsFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java
index b277349831..f70bc6d4c3 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java
@@ -1,17 +1,18 @@
package net.osmand.plus.measurementtool;
+import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageView;
-import android.widget.TextView;
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.DescriptionItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -23,63 +24,55 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.shared_string_save_as_gpx)));
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_save_as_new_track_bottom_sheet_dialog, container);
+ items.add(new DescriptionItem(getString(R.string.measurement_tool_save_as_new_track_descr)));
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
- mainView.findViewById(R.id.images_row).setVisibility(View.GONE);
- } else {
- final ImageView routePointImage = (ImageView) mainView.findViewById(R.id.route_point_image);
- ImageView lineImage = (ImageView) mainView.findViewById(R.id.line_image);
- if (nightMode) {
- routePointImage.setImageResource(R.drawable.img_help_trip_route_points_night);
- lineImage.setImageResource(R.drawable.img_help_trip_track_night);
- } else {
- routePointImage.setImageResource(R.drawable.img_help_trip_route_points_day);
- lineImage.setImageResource(R.drawable.img_help_trip_track_day);
- }
+ if (Build.VERSION.SDK_INT >= 17) {
+ final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ View imagesRow = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
+ R.layout.fragment_save_as_new_track_images_row, null);
- mainView.findViewById(R.id.line_text).setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
- return false;
- }
- });
+ final ImageView routePointImage = (ImageView) imagesRow.findViewById(R.id.route_point_image);
+ final ImageView lineImage = (ImageView) imagesRow.findViewById(R.id.line_image);
+ routePointImage.setImageResource(nightMode
+ ? R.drawable.img_help_trip_route_points_night
+ : R.drawable.img_help_trip_route_points_day);
+ lineImage.setImageResource(nightMode
+ ? R.drawable.img_help_trip_track_night
+ : R.drawable.img_help_trip_track_day);
+ routePointImage.setOnClickListener(saveAsRoutePointOnClickListener);
lineImage.setOnClickListener(saveAsLineOnClickListener);
- mainView.findViewById(R.id.route_point_text).setOnTouchListener(new View.OnTouchListener() {
+ View.OnTouchListener textOnTouchListener = new View.OnTouchListener() {
@Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
+ public boolean onTouch(View v, MotionEvent event) {
return false;
}
- });
- routePointImage.setOnClickListener(saveAsRoutePointOnClickListener);
+ };
+ imagesRow.findViewById(R.id.line_text).setOnTouchListener(textOnTouchListener);
+ imagesRow.findViewById(R.id.route_point_text).setOnTouchListener(textOnTouchListener);
+
+ items.add(new BaseBottomSheetItem.Builder().setCustomView(imagesRow).create());
}
- if (nightMode) {
- ((TextView) mainView.findViewById(R.id.save_as_new_track_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
+ BaseBottomSheetItem saveAsRoutePointsItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_route_points))
+ .setTitle(getString(R.string.save_as_route_point))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(saveAsRoutePointOnClickListener)
+ .create();
+ items.add(saveAsRoutePointsItem);
- ((ImageView) mainView.findViewById(R.id.route_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_route_points));
- ((ImageView) mainView.findViewById(R.id.line_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_split_interval));
-
- mainView.findViewById(R.id.save_as_line_row).setOnClickListener(saveAsLineOnClickListener);
- mainView.findViewById(R.id.save_as_route_point_row).setOnClickListener(saveAsRoutePointOnClickListener);
-
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.save_as_new_track_scroll_view);
-
- return mainView;
+ BaseBottomSheetItem saveAsLineItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_split_interval))
+ .setTitle(getString(R.string.save_as_line))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(saveAsLineOnClickListener)
+ .create();
+ items.add(saveAsLineItem);
}
private View.OnClickListener saveAsLineOnClickListener = new View.OnClickListener() {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java
index 58900037e5..893dc62845 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java
@@ -1,21 +1,23 @@
package net.osmand.plus.measurementtool;
+import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+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.TitleDividerItem;
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
import net.osmand.util.MapUtils;
@@ -31,117 +33,83 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final MapActivity mapActivity = (MapActivity) getActivity();
- final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+ public void createMenuItems(Bundle savedInstanceState) {
+ BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getDescription())
+ .setIcon(getActiveIcon(R.drawable.ic_action_measure_point))
+ .setTitle(getTitle())
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .create();
+ items.add(titleItem);
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_selected_menu_bottom_sheet_dialog, null);
+ items.add(new TitleDividerItem(getContext()));
- ((ImageView) mainView.findViewById(R.id.selected_point_icon)).setImageDrawable(getActiveIcon(R.drawable.ic_action_measure_point));
- ((ImageView) mainView.findViewById(R.id.move_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_move_point));
- ((ImageView) mainView.findViewById(R.id.delete_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
- ((ImageView) mainView.findViewById(R.id.add_point_after_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_addpoint_above));
- ((ImageView) mainView.findViewById(R.id.add_point_before_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_addpoint_below));
+ BaseBottomSheetItem moveItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_move_point))
+ .setTitle(getString(R.string.shared_string_move))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.moveOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(moveItem);
- mainView.findViewById(R.id.move_point_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.moveOnClick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.delete_point_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.deleteOnClick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.add_point_after_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.addPointAfterOnClick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.add_point_before_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.addPointBeforeOnClick();
- }
- dismiss();
- }
- });
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onClearSelection();
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_remove_dark))
+ .setTitle(getString(R.string.shared_string_delete))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.deleteOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(deleteItem);
- List points = measurementLayer.getEditingCtx().getPoints();
- int pos = measurementLayer.getEditingCtx().getSelectedPointPosition();
- WptPt pt = points.get(pos);
- String pointTitle = pt.name;
- if (!TextUtils.isEmpty(pointTitle)) {
- ((TextView) mainView.findViewById(R.id.selected_point_title)).setText(pointTitle);
- } else {
- NewGpxData newGpxData = measurementLayer.getEditingCtx().getNewGpxData();
- if (newGpxData != null) {
- ActionType actionType = measurementLayer.getEditingCtx().getNewGpxData().getActionType();
- if (actionType == ActionType.ADD_ROUTE_POINTS) {
- ((TextView) mainView.findViewById(R.id.selected_point_title)).setText(mapActivity.getString(R.string.route_point) + " - " + (pos + 1));
- } else {
- ((TextView) mainView.findViewById(R.id.selected_point_title)).setText(mapActivity.getString(R.string.plugin_distance_point) + " - " + (pos + 1));
- }
- } else {
- ((TextView) mainView.findViewById(R.id.selected_point_title)).setText(mapActivity.getString(R.string.plugin_distance_point) + " - " + (pos + 1));
- }
- }
- String pointDesc = pt.desc;
- if (!TextUtils.isEmpty(pointDesc)) {
- ((TextView) mainView.findViewById(R.id.selected_point_distance)).setText(pointDesc);
- } else {
- if (pos < 1) {
- ((TextView) mainView.findViewById(R.id.selected_point_distance)).setText(mapActivity.getString(R.string.shared_string_control_start));
- } else {
- float dist = 0;
- for (int i = 1; i <= pos; i++) {
- dist += MapUtils.getDistance(points.get(i - 1).lat, points.get(i - 1).lon, points.get(i).lat, points.get(i).lon);
- }
- ((TextView) mainView.findViewById(R.id.selected_point_distance)).setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
- }
- }
- NewGpxData newGpxData = measurementLayer.getEditingCtx().getNewGpxData();
- if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT) {
- double elevation = pt.ele;
- if (!Double.isNaN(elevation)) {
- String eleStr = (mapActivity.getString(R.string.altitude)).substring(0, 1);
- ((TextView) mainView.findViewById(R.id.selected_point_ele)).setText(eleStr + ": " + OsmAndFormatter.getFormattedAlt(elevation, mapActivity.getMyApplication()));
- }
- float speed = (float) pt.speed;
- if (speed != 0) {
- String speedStr = (mapActivity.getString(R.string.map_widget_speed)).substring(0, 1);
- ((TextView) mainView.findViewById(R.id.selected_point_speed)).setText(speedStr + ": " + OsmAndFormatter.getFormattedSpeed(speed, mapActivity.getMyApplication()));
- }
- }
+ items.add(new DividerHalfItem(getContext()));
- setupHeightAndBackground(mainView, R.id.selected_point_options_scroll_view);
+ BaseBottomSheetItem addAfterItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_addpoint_above))
+ .setTitle(getString(R.string.add_point_after))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.addPointAfterOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(addAfterItem);
- return mainView;
+ BaseBottomSheetItem addBeforeItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_addpoint_below))
+ .setTitle(getString(R.string.add_point_before))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.addPointBeforeOnClick();
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(addBeforeItem);
}
@Override
@@ -161,6 +129,96 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
super.onCancel(dialog);
}
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
+ }
+
+ @Override
+ protected void onCloseRowClickAction() {
+ if (listener != null) {
+ listener.onClearSelection();
+ }
+ }
+
+ @Nullable
+ private MapActivity getMapActivity() {
+ Activity activity = getActivity();
+ if (activity instanceof MapActivity) {
+ return (MapActivity) activity;
+ }
+ return null;
+ }
+
+ @NonNull
+ private String getTitle() {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity == null) {
+ return "";
+ }
+
+ MeasurementEditingContext editingCtx = mapActivity.getMapLayers().getMeasurementToolLayer().getEditingCtx();
+ int pos = editingCtx.getSelectedPointPosition();
+
+ String pointName = editingCtx.getPoints().get(pos).name;
+ if (!TextUtils.isEmpty(pointName)) {
+ return pointName;
+ }
+
+ NewGpxData newGpxData = editingCtx.getNewGpxData();
+ if (newGpxData != null && newGpxData.getActionType() == ActionType.ADD_ROUTE_POINTS) {
+ return getString(R.string.route_point) + " - " + (pos + 1);
+ }
+
+ return getString(R.string.plugin_distance_point) + " - " + (pos + 1);
+ }
+
+ @NonNull
+ private String getDescription() {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity == null) {
+ return "";
+ }
+
+ StringBuilder description = new StringBuilder();
+
+ MeasurementEditingContext editingCtx = mapActivity.getMapLayers().getMeasurementToolLayer().getEditingCtx();
+ int pos = editingCtx.getSelectedPointPosition();
+ List points = editingCtx.getPoints();
+ WptPt pt = points.get(pos);
+
+ String pointDesc = pt.desc;
+ if (!TextUtils.isEmpty(pointDesc)) {
+ description.append(pointDesc);
+ } else if (pos < 1) {
+ description.append(getString(R.string.shared_string_control_start));
+ } else {
+ float dist = 0;
+ for (int i = 1; i <= pos; i++) {
+ WptPt first = points.get(i - 1);
+ WptPt second = points.get(i);
+ dist += MapUtils.getDistance(first.lat, first.lon, second.lat, second.lon);
+ }
+ description.append(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
+ }
+
+ NewGpxData newGpxData = editingCtx.getNewGpxData();
+ if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT) {
+ double elevation = pt.ele;
+ if (!Double.isNaN(elevation)) {
+ description.append(" ").append((getString(R.string.altitude)).substring(0, 1)).append(": ");
+ description.append(OsmAndFormatter.getFormattedAlt(elevation, mapActivity.getMyApplication()));
+ }
+ float speed = (float) pt.speed;
+ if (speed != 0) {
+ description.append(" ").append((getString(R.string.map_widget_speed)).substring(0, 1)).append(": ");
+ description.append(OsmAndFormatter.getFormattedSpeed(speed, mapActivity.getMyApplication()));
+ }
+ }
+
+ return description.toString();
+ }
+
interface SelectedPointFragmentListener {
void moveOnClick();
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/ExportOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/ExportOptionsBottomSheetDialogFragment.java
index 2fcc6742ff..fde5b31358 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/ExportOptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/ExportOptionsBottomSheetDialogFragment.java
@@ -1,18 +1,15 @@
package net.osmand.plus.osmedit;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.osmedit.OsmEditsFragment.ExportTypesDef;
-import net.osmand.plus.widgets.TextViewEx;
public class ExportOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -29,91 +26,71 @@ public class ExportOptionsBottomSheetDialogFragment extends MenuBottomSheetDialo
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.fragment_osm_export_options_bottom_sheet_dialog, container);
-
+ public void createMenuItems(Bundle savedInstanceState) {
Bundle args = getArguments();
if (args != null) {
poiCount = args.getInt(POI_COUNT_KEY);
osmNotesCount = args.getInt(NOTES_COUNT_KEY);
}
- if (nightMode) {
- ((TextViewEx) mainView.findViewById(R.id.title_text_view)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
+ items.add(new TitleItem(getString(R.string.shared_string_export)));
- ((ImageView) mainView.findViewById(R.id.poi_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_info_dark));
- ((ImageView) mainView.findViewById(R.id.osm_notes_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_bug_dark));
- ((ImageView) mainView.findViewById(R.id.all_data_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_folder));
+ items.add(new DescriptionItem(getString(R.string.osm_edits_export_desc)));
- ((TextView) mainView.findViewById(R.id.poi_count_text_view)).setText(String.valueOf(poiCount));
- ((TextView) mainView.findViewById(R.id.osm_notes_count_text_view)).setText(String.valueOf(osmNotesCount));
- ((TextView) mainView.findViewById(R.id.all_data_count_text_view)).setText(String.valueOf(poiCount + osmNotesCount));
-
- View poiRow = mainView.findViewById(R.id.poi_row);
- if (poiCount > 0) {
- poiRow.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.onClick(OsmEditsFragment.EXPORT_TYPE_POI);
+ BaseBottomSheetItem poiItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(String.valueOf(poiCount))
+ .setIcon(getContentIcon(R.drawable.ic_action_info_dark))
+ .setTitle(getString(R.string.poi))
+ .setLayoutId(R.layout.bottom_sheet_item_with_right_descr)
+ .setDisabled(!(poiCount > 0))
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(OsmEditsFragment.EXPORT_TYPE_POI);
+ }
+ dismiss();
}
- dismiss();
- }
- });
- } else {
- disable(poiRow);
- }
+ })
+ .create();
+ items.add(poiItem);
- View osmNotesRow = mainView.findViewById(R.id.osm_notes_row);
- if (osmNotesCount > 0) {
- osmNotesRow.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.onClick(OsmEditsFragment.EXPORT_TYPE_NOTES);
+ BaseBottomSheetItem osmNotesItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(String.valueOf(osmNotesCount))
+ .setIcon(getContentIcon(R.drawable.ic_action_bug_dark))
+ .setTitle(getString(R.string.osm_notes))
+ .setLayoutId(R.layout.bottom_sheet_item_with_right_descr)
+ .setDisabled(!(osmNotesCount > 0))
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(OsmEditsFragment.EXPORT_TYPE_NOTES);
+ }
+ dismiss();
}
- dismiss();
- }
- });
- } else {
- disable(osmNotesRow);
- }
+ })
+ .create();
+ items.add(osmNotesItem);
- View allDataRow = mainView.findViewById(R.id.all_data_row);
- if ((poiCount + osmNotesCount) > 0) {
- allDataRow.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.onClick(OsmEditsFragment.EXPORT_TYPE_ALL);
+ BaseBottomSheetItem allDataItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(String.valueOf(poiCount + osmNotesCount))
+ .setIcon(getContentIcon(R.drawable.ic_action_folder))
+ .setTitle(getString(R.string.all_data))
+ .setLayoutId(R.layout.bottom_sheet_item_with_right_descr)
+ .setDisabled(!(poiCount + osmNotesCount > 0))
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(OsmEditsFragment.EXPORT_TYPE_ALL);
+ }
+ dismiss();
}
- dismiss();
- }
- });
- } else {
- disable(allDataRow);
- }
-
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.scroll_view);
-
- return mainView;
- }
-
- private void disable(View view) {
- view.setEnabled(false);
- view.setAlpha(.5f);
+ })
+ .create();
+ items.add(allDataItem);
}
public interface ExportOptionsFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/FileTypeBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/FileTypeBottomSheetDialogFragment.java
index ce23d47238..b09c6c1f28 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/FileTypeBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/FileTypeBottomSheetDialogFragment.java
@@ -2,17 +2,15 @@ package net.osmand.plus.osmedit;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.osmedit.OsmEditsFragment.FileTypesDef;
-import net.osmand.plus.widgets.TextViewEx;
public class FileTypeBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@@ -24,51 +22,47 @@ public class FileTypeBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
- R.layout.fragment_osm_file_type_bottom_sheet_dialog, container);
-
- if (nightMode) {
- ((TextViewEx) mainView.findViewById(R.id.title_text_view)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
+ public void createMenuItems(Bundle savedInstanceState) {
+ items.add(new TitleItem(getString(R.string.choose_file_type)));
Drawable fileIcon = getContentIcon(R.drawable.ic_type_file);
- ((ImageView) mainView.findViewById(R.id.osc_file_icon)).setImageDrawable(fileIcon);
- ((ImageView) mainView.findViewById(R.id.gpx_file_icon)).setImageDrawable(fileIcon);
- mainView.findViewById(R.id.osc_file_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.onClick(OsmEditsFragment.FILE_TYPE_OSC);
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem oscItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.osc_file_desc))
+ .setIcon(fileIcon)
+ .setTitle(getString(R.string.osc_file))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(OsmEditsFragment.FILE_TYPE_OSC);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(oscItem);
- mainView.findViewById(R.id.gpx_file_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (listener != null) {
- listener.onClick(OsmEditsFragment.FILE_TYPE_GPX);
- }
- dismiss();
- }
- });
+ items.add(new DividerHalfItem(getContext()));
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.scroll_view);
-
- return mainView;
+ BaseBottomSheetItem gpxItem = new BottomSheetItemWithDescription.Builder()
+ .setDescription(getString(R.string.gpx_file_desc))
+ .setIcon(fileIcon)
+ .setTitle(getString(R.string.gpx_file))
+ .setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onClick(OsmEditsFragment.FILE_TYPE_GPX);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(gpxItem);
}
public interface FileTypeFragmentListener {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java
index ef45713fb6..d95f9e540f 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java
@@ -1,20 +1,18 @@
package net.osmand.plus.osmedit;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
-import net.osmand.plus.widgets.TextViewEx;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
- public final static String TAG = "OsmEditOptionsBottomSheetDialogFragment";
+ public static final String TAG = "OsmEditOptionsBottomSheetDialogFragment";
public static final String OSM_POINT = "osm_point";
@@ -24,94 +22,105 @@ public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDial
this.listener = listener;
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
- final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_osm_edit_options_bottom_sheet_dialog, container);
-
+ public void createMenuItems(Bundle savedInstanceState) {
Bundle args = getArguments();
if (args != null) {
final OsmPoint osmPoint = (OsmPoint) args.getSerializable(OSM_POINT);
- ((TextViewEx) mainView.findViewById(R.id.osm_edit_name)).setText(OsmEditingPlugin.getName(osmPoint) + ":");
+ items.add(new TitleItem(OsmEditingPlugin.getName(osmPoint) + ":"));
- ((ImageView) mainView.findViewById(R.id.upload_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_export));
- mainView.findViewById(R.id.upload_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onUploadClick(osmPoint);
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem uploadItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_export))
+ .setTitle(getString(R.string.local_openstreetmap_upload))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onUploadClick(osmPoint);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(uploadItem);
- ((ImageView) mainView.findViewById(R.id.show_on_map_icon)).setImageDrawable(getContentIcon(R.drawable.ic_show_on_map));
- mainView.findViewById(R.id.show_on_map_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onShowOnMapClick(osmPoint);
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem showOnMapItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_show_on_map))
+ .setTitle(getString(R.string.shared_string_show_on_map))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onShowOnMapClick(osmPoint);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(showOnMapItem);
+
+ items.add(new DividerHalfItem(getContext()));
if (osmPoint instanceof OpenstreetmapPoint && osmPoint.getAction() != OsmPoint.Action.DELETE) {
- mainView.findViewById(R.id.modify_osm_change_row).setVisibility(View.VISIBLE);
- ((ImageView) mainView.findViewById(R.id.modify_osm_change_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
- mainView.findViewById(R.id.modify_osm_change_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onModifyOsmChangeClick(osmPoint);
- }
- dismiss();
- }
- });
+ BaseBottomSheetItem modifyOsmChangeItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
+ .setTitle(getString(R.string.poi_context_menu_modify_osm_change))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onModifyOsmChangeClick(osmPoint);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(modifyOsmChangeItem);
}
if (osmPoint instanceof OsmNotesPoint) {
- mainView.findViewById(R.id.modify_osm_note_row).setVisibility(View.VISIBLE);
- ((ImageView) mainView.findViewById(R.id.modify_osm_note_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
- mainView.findViewById(R.id.modify_osm_note_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onModifyOsmNoteClick(osmPoint);
+ BaseBottomSheetItem modifyOsmNoteItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
+ .setTitle(getString(R.string.context_menu_item_modify_note))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onModifyOsmNoteClick(osmPoint);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(modifyOsmNoteItem);
+ }
+
+ BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_delete_dark))
+ .setTitle(getString(R.string.shared_string_delete))
+ .setLayoutId(R.layout.bottom_sheet_item_simple)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (listener != null) {
+ listener.onDeleteClick(osmPoint);
+ }
+ dismiss();
}
- dismiss();
- }
- });
- }
-
- ((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
- mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (listener != null) {
- listener.onDeleteClick(osmPoint);
- }
- dismiss();
- }
- });
+ })
+ .create();
+ items.add(deleteItem);
}
+ }
- if (nightMode) {
- ((TextViewEx) mainView.findViewById(R.id.osm_edit_name)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
- }
-
- mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dismiss();
- }
- });
-
- setupHeightAndBackground(mainView, R.id.osm_edit_options_scroll_view);
-
- return mainView;
+ @Override
+ protected int getCloseRowTextId() {
+ return R.string.shared_string_close;
}
public interface OsmEditOptionsFragmentListener {