diff --git a/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml
new file mode 100644
index 0000000000..e77703ddfc
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml
@@ -0,0 +1,236 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 49b412d859..f37e4d2c66 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,11 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Move all to history
+ Build route
+ Show direction
+ Sort by
+ Marker options
Do not use animations
Disables animations in the app
Keep showing on map
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
index 4b689e261b..0bdc11b5fb 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
@@ -19,6 +19,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.mapmarkers.MarkerOptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
import java.util.Arrays;
import java.util.List;
@@ -39,6 +40,12 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
+ FragmentManager fragmentManager = getChildFragmentManager();
+ Fragment markerOptionsFragment = fragmentManager.findFragmentByTag(MarkerOptionsBottomSheetDialogFragment.TAG);
+ if (markerOptionsFragment != null) {
+ ((MarkerOptionsBottomSheetDialogFragment) markerOptionsFragment).setListener(createMarkerOptionsFragmentListener());
+ }
+
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
@@ -49,10 +56,13 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
dismiss();
}
});
- mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
+ final View optionsButton = mainView.findViewById(R.id.options_button);
+ optionsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- Toast.makeText(getContext(), "Options", Toast.LENGTH_SHORT).show();
+ MarkerOptionsBottomSheetDialogFragment fragment = new MarkerOptionsBottomSheetDialogFragment();
+ fragment.setListener(createMarkerOptionsFragmentListener());
+ fragment.show(getChildFragmentManager(), MarkerOptionsBottomSheetDialogFragment.TAG);
}
});
@@ -69,10 +79,12 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
case R.id.action_active:
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
viewPager.setCurrentItem(0);
+ optionsButton.setVisibility(View.VISIBLE);
return true;
case R.id.action_history:
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
viewPager.setCurrentItem(1);
+ optionsButton.setVisibility(View.GONE);
return true;
}
return false;
@@ -86,6 +98,36 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
return (OsmandApplication) getActivity().getApplication();
}
+ private MarkerOptionsFragmentListener createMarkerOptionsFragmentListener() {
+ return new MarkerOptionsFragmentListener() {
+ @Override
+ public void sortByOnClick() {
+ Toast.makeText(getContext(), "Sort by", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void showDirectionOnClick() {
+ Toast.makeText(getContext(), "Show direction", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void buildRouteOnClick() {
+ Toast.makeText(getContext(), "Build route", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void saveAsNewTrackOnClick() {
+ Toast.makeText(getContext(), "Save as new track", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void moveAllToHistoryOnClick() {
+ Toast.makeText(getContext(), "Move all to history", Toast.LENGTH_SHORT).show();
+ }
+ };
+ }
+
+
public static boolean showInstance(@NonNull MapActivity mapActivity) {
try {
if (mapActivity.isActivityDestroyed()) {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
index 1667047172..b84d42ba86 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
@@ -3,18 +3,26 @@ package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
+
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
public class MapMarkersHistoryFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- TextView textView = new TextView(getContext());
- textView.setText("history fragment");
- return textView;
+ final RecyclerView recyclerView = new RecyclerView(getContext());
+ recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ final MapActivity mapActivity = (MapActivity) getActivity();
+
+ recyclerView.setAdapter(new MapMarkersHistoryAdapter(mapActivity.getMyApplication()));
+
+ return recyclerView;
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java
new file mode 100644
index 0000000000..2bcf3d1325
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java
@@ -0,0 +1,169 @@
+package net.osmand.plus.mapmarkers;
+
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+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.ImageView;
+import android.widget.TextView;
+
+import net.osmand.AndroidUtils;
+import net.osmand.plus.R;
+import net.osmand.plus.base.BottomSheetDialogFragment;
+import net.osmand.plus.helpers.AndroidUiHelper;
+
+public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
+
+ public final static String TAG = "MarkerOptionsBottomSheetDialogFragment";
+
+ private MarkerOptionsFragmentListener listener;
+ private boolean portrait;
+
+ public void setListener(MarkerOptionsFragmentListener listener) {
+ this.listener = listener;
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
+
+ final View mainView = inflater.inflate(R.layout.fragment_marker_options_bottom_sheet_dialog, container);
+ if (portrait) {
+ AndroidUtils.setBackground(getActivity(), mainView, false, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
+ }
+
+ ((ImageView) mainView.findViewById(R.id.sort_by_icon))
+ .setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color));
+ ((ImageView) mainView.findViewById(R.id.show_direction_icon))
+ .setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color));
+ ((ImageView) mainView.findViewById(R.id.build_route_icon))
+ .setImageDrawable(getIcon(R.drawable.map_directions, R.color.on_map_icon_color));
+ ((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
+ .setImageDrawable(getIcon(R.drawable.ic_action_polygom_dark, R.color.on_map_icon_color));
+ ((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
+ .setImageDrawable(getIcon(R.drawable.ic_action_history2, R.color.on_map_icon_color));
+
+ ((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText("Top bar");
+
+ mainView.findViewById(R.id.sort_by_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.sortByOnClick();
+ }
+ dismiss();
+ }
+ });
+ mainView.findViewById(R.id.show_direction_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.showDirectionOnClick();
+ }
+ dismiss();
+ }
+ });
+ mainView.findViewById(R.id.build_route_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.buildRouteOnClick();
+ }
+ dismiss();
+ }
+ });
+ 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.move_all_to_history_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.moveAllToHistoryOnClick();
+ }
+ dismiss();
+ }
+ });
+ mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ dismiss();
+ }
+ });
+
+ final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
+ final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
+ final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
+
+ mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ final View scrollView = mainView.findViewById(R.id.marker_options_scroll_view);
+ int scrollViewHeight = scrollView.getHeight();
+ int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
+ int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height);
+ int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
+ if (scrollViewHeight > spaceForScrollView) {
+ scrollView.getLayoutParams().height = spaceForScrollView;
+ scrollView.requestLayout();
+ }
+
+ if (!portrait) {
+ if (screenHeight - statusBarHeight - mainView.getHeight()
+ >= AndroidUtils.dpToPx(getActivity(), 8)) {
+ AndroidUtils.setBackground(getActivity(), mainView, false,
+ R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
+ } else {
+ AndroidUtils.setBackground(getActivity(), mainView, false,
+ R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
+ }
+ }
+
+ ViewTreeObserver obs = mainView.getViewTreeObserver();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ obs.removeOnGlobalLayoutListener(this);
+ } else {
+ obs.removeGlobalOnLayoutListener(this);
+ }
+ }
+ });
+
+ return mainView;
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (!portrait) {
+ final Window window = getDialog().getWindow();
+ WindowManager.LayoutParams params = window.getAttributes();
+ params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
+ window.setAttributes(params);
+ }
+ }
+
+ interface MarkerOptionsFragmentListener {
+
+ void sortByOnClick();
+
+ void showDirectionOnClick();
+
+ void buildRouteOnClick();
+
+ void saveAsNewTrackOnClick();
+
+ void moveAllToHistoryOnClick();
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java
new file mode 100644
index 0000000000..ee9b3bdd86
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java
@@ -0,0 +1,48 @@
+package net.osmand.plus.mapmarkers.adapters;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import net.osmand.plus.IconsCache;
+import net.osmand.plus.MapMarkersHelper.MapMarker;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+
+import java.util.List;
+
+public class MapMarkersHistoryAdapter extends RecyclerView.Adapter {
+
+ private OsmandApplication app;
+ private List markers;
+
+ public MapMarkersHistoryAdapter(OsmandApplication app) {
+ this.app = app;
+ markers = app.getMapMarkersHelper().getMapMarkersHistory();
+ }
+
+ @Override
+ public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
+ View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
+ return new MapMarkerItemViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(MapMarkerItemViewHolder holder, int pos) {
+ IconsCache iconsCache = app.getIconsCache();
+ MapMarker marker = markers.get(pos);
+
+ holder.iconReorder.setVisibility(View.GONE);
+
+ int color = MapMarker.getColorId(marker.colorIndex);
+ holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
+
+ holder.title.setText(marker.getName(app));
+ }
+
+ @Override
+ public int getItemCount() {
+ return markers.size();
+ }
+}