diff --git a/OsmAnd/res/layout-land/empty_state_favourites.xml b/OsmAnd/res/layout-land/empty_state_favourites.xml
index e3a77b04ab..4f28f53214 100644
--- a/OsmAnd/res/layout-land/empty_state_favourites.xml
+++ b/OsmAnd/res/layout-land/empty_state_favourites.xml
@@ -8,23 +8,23 @@
android:orientation="horizontal">
+ tools:src="@drawable/ic_empty_state_favorites_night"/>
@@ -32,11 +32,11 @@
+ android:textSize="@dimen/empty_state_text_desc_size"/>
diff --git a/OsmAnd/res/layout-land/empty_state_markers_active.xml b/OsmAnd/res/layout-land/empty_state_markers_active.xml
new file mode 100644
index 0000000000..6bd6230e40
--- /dev/null
+++ b/OsmAnd/res/layout-land/empty_state_markers_active.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/empty_state_markers_groups.xml b/OsmAnd/res/layout-land/empty_state_markers_groups.xml
new file mode 100644
index 0000000000..d7e773cc43
--- /dev/null
+++ b/OsmAnd/res/layout-land/empty_state_markers_groups.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/empty_state_markers_history.xml b/OsmAnd/res/layout-land/empty_state_markers_history.xml
new file mode 100644
index 0000000000..c423a8ee80
--- /dev/null
+++ b/OsmAnd/res/layout-land/empty_state_markers_history.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/empty_state_my_tracks.xml b/OsmAnd/res/layout-land/empty_state_my_tracks.xml
index 80863986be..15068df0a6 100644
--- a/OsmAnd/res/layout-land/empty_state_my_tracks.xml
+++ b/OsmAnd/res/layout-land/empty_state_my_tracks.xml
@@ -8,23 +8,23 @@
android:orientation="horizontal">
+ tools:src="@drawable/ic_empty_state_trip_night"/>
@@ -32,11 +32,11 @@
+ android:textSize="@dimen/empty_state_text_desc_size"/>
diff --git a/OsmAnd/res/layout/add_favourites_group_header.xml b/OsmAnd/res/layout/add_favourites_group_header.xml
new file mode 100644
index 0000000000..b141dbf862
--- /dev/null
+++ b/OsmAnd/res/layout/add_favourites_group_header.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/empty_state_favourites.xml b/OsmAnd/res/layout/empty_state_favourites.xml
index ca57095bbc..647f454d8e 100644
--- a/OsmAnd/res/layout/empty_state_favourites.xml
+++ b/OsmAnd/res/layout/empty_state_favourites.xml
@@ -12,35 +12,35 @@
android:id="@+id/empty_state_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/my_places_empty_state_image_margin_bottom"
- android:layout_marginTop="@dimen/my_places_empty_state_image_margin_top"
- tools:src="@drawable/ic_empty_state_favorites_night_result"/>
+ android:layout_marginBottom="@dimen/empty_state_image_margin_bottom"
+ android:layout_marginTop="@dimen/empty_state_image_margin_top"
+ tools:src="@drawable/ic_empty_state_favorites_night"/>
+ android:textSize="@dimen/empty_state_text_size"/>
+ android:textSize="@dimen/empty_state_text_desc_size"/>
\ No newline at end of file
diff --git a/OsmAnd/res/layout/empty_state_markers_active.xml b/OsmAnd/res/layout/empty_state_markers_active.xml
new file mode 100644
index 0000000000..7797398219
--- /dev/null
+++ b/OsmAnd/res/layout/empty_state_markers_active.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/empty_state_markers_groups.xml b/OsmAnd/res/layout/empty_state_markers_groups.xml
new file mode 100644
index 0000000000..6d5a817bf8
--- /dev/null
+++ b/OsmAnd/res/layout/empty_state_markers_groups.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/empty_state_markers_history.xml b/OsmAnd/res/layout/empty_state_markers_history.xml
new file mode 100644
index 0000000000..94ab69e18b
--- /dev/null
+++ b/OsmAnd/res/layout/empty_state_markers_history.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/empty_state_my_tracks.xml b/OsmAnd/res/layout/empty_state_my_tracks.xml
index 2e9a969609..c82a21be74 100644
--- a/OsmAnd/res/layout/empty_state_my_tracks.xml
+++ b/OsmAnd/res/layout/empty_state_my_tracks.xml
@@ -12,18 +12,18 @@
android:id="@+id/empty_state_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/my_places_empty_state_image_margin_bottom"
- android:layout_marginTop="@dimen/my_places_empty_state_image_margin_top"
- tools:src="@drawable/ic_empty_state_trip_night_result"/>
+ android:layout_marginBottom="@dimen/empty_state_image_margin_bottom"
+ android:layout_marginTop="@dimen/empty_state_image_margin_top"
+ tools:src="@drawable/ic_empty_state_trip_night"/>
+ android:textSize="@dimen/empty_state_text_desc_size"/>
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_map_markers_active.xml b/OsmAnd/res/layout/fragment_map_markers_active.xml
new file mode 100644
index 0000000000..8059263bec
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_map_markers_active.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_map_markers_groups.xml b/OsmAnd/res/layout/fragment_map_markers_groups.xml
new file mode 100644
index 0000000000..74911b1118
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_map_markers_groups.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_map_markers_history.xml b/OsmAnd/res/layout/fragment_map_markers_history.xml
new file mode 100644
index 0000000000..99438ccd3f
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_map_markers_history.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_marker_add_favourites_group_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_add_favourites_group_bottom_sheet_dialog.xml
new file mode 100644
index 0000000000..3dd4b75cb7
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_marker_add_favourites_group_bottom_sheet_dialog.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000000..baacf61b55
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_marker_add_markers_group_bottom_sheet_dialog.xml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/markers_group_view_holder.xml b/OsmAnd/res/layout/markers_group_view_holder.xml
new file mode 100644
index 0000000000..41f28e4ab8
--- /dev/null
+++ b/OsmAnd/res/layout/markers_group_view_holder.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values-land/sizes.xml b/OsmAnd/res/values-land/sizes.xml
index 9f19fef714..cc32b87429 100644
--- a/OsmAnd/res/values-land/sizes.xml
+++ b/OsmAnd/res/values-land/sizes.xml
@@ -5,8 +5,8 @@
24dp
48dp
- 39dp
- 39dp
+ 39dp
+ 39dp
14dp
\ No newline at end of file
diff --git a/OsmAnd/res/values-large-land/sizes.xml b/OsmAnd/res/values-large-land/sizes.xml
index e44894c275..35bc80ed66 100644
--- a/OsmAnd/res/values-large-land/sizes.xml
+++ b/OsmAnd/res/values-large-land/sizes.xml
@@ -1,7 +1,7 @@
- 59dp
- 59dp
+ 59dp
+ 59dp
21dp
\ No newline at end of file
diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml
index cbc1ce5530..cfc6b49e34 100644
--- a/OsmAnd/res/values-large/sizes.xml
+++ b/OsmAnd/res/values-large/sizes.xml
@@ -81,17 +81,17 @@
15sp
12sp
- 63dp
- 45dp
- 12dp
- 30dp
- 20sp
- 18sp
- 68dp
- 138dp
- 72dp
- 90dp
- 96dp
+ 63dp
+ 45dp
+ 12dp
+ 30dp
+ 20sp
+ 18sp
+ 68dp
+ 138dp
+ 72dp
+ 90dp
+ 96dp
72dp
540dp
diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml
index 18dce59e43..9db6f1d581 100644
--- a/OsmAnd/res/values/sizes.xml
+++ b/OsmAnd/res/values/sizes.xml
@@ -144,17 +144,17 @@
150dp
128dp
- 42dp
- 30dp
- 8dp
- 20dp
- 18sp
- 16sp
- 45dp
- 92dp
- 48dp
- 60dp
- 64dp
+ 42dp
+ 30dp
+ 8dp
+ 20dp
+ 18sp
+ 16sp
+ 45dp
+ 92dp
+ 48dp
+ 60dp
+ 64dp
48dp
360dp
@@ -198,4 +198,6 @@
5dp
28dp
+
+ 88dp
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 97cd87b31a..2d4fa740ac 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,18 @@
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
-->
+ Select track waypoints of which OsmAnd will add to markers
+ Select which favourite group you want to add to markers
+ Track waypoints
+ Favourites group
+ Add group
+ You can add group of favourites or track waypoints.
+ Markers on map!
+ Mark places on map by tap.
+ Import groups
+ You can import favourite groups or track waypoints as markers.
+ @string/shared_string_history
+ Markers marked as passed will appear on this screen.
Two
One
A line connecting your location to locations of the active markers will be shown on the map.
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/AddFavouritesGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/AddFavouritesGroupBottomSheetDialogFragment.java
new file mode 100644
index 0000000000..164571958b
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/AddFavouritesGroupBottomSheetDialogFragment.java
@@ -0,0 +1,84 @@
+package net.osmand.plus.mapmarkers;
+
+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.FavouritesDbHelper.FavoriteGroup;
+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.mapmarkers.adapters.FavouritesGroupsAdapter;
+
+import java.util.List;
+
+public class AddFavouritesGroupBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
+
+ public final static String TAG = "AddFavouritesGroupBottomSheetDialogFragment";
+
+ private AddFavouriteGroupListener listener;
+
+ private List favoriteGroups;
+ private MapMarkersHelper mapMarkersHelper;
+
+ public void setListener(AddFavouriteGroupListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ favoriteGroups = getMyApplication().getFavorites().getFavoriteGroups();
+ mapMarkersHelper = getMyApplication().getMapMarkersHelper();
+ }
+
+ @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_favourites_group_bottom_sheet_dialog, container);
+
+ final RecyclerView recyclerView = mainView.findViewById(R.id.favourites_group_recycler_view);
+ recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ final FavouritesGroupsAdapter adapter = new FavouritesGroupsAdapter(getContext(), favoriteGroups);
+ adapter.setAdapterListener(new FavouritesGroupsAdapter.FavouritesGroupsAdapterListener() {
+ @Override
+ public void onItemClick(View view) {
+ int position = recyclerView.getChildAdapterPosition(view);
+ if (position == RecyclerView.NO_POSITION) {
+ return;
+ }
+ FavoriteGroup group = favoriteGroups.get(position - 1);
+ MarkersSyncGroup markersSyncGroup = new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE, group.color);
+ mapMarkersHelper.addMarkersSyncGroup(markersSyncGroup);
+ mapMarkersHelper.syncGroup(markersSyncGroup);
+ if (listener != null) {
+ listener.onFavouriteGroupAdded();
+ }
+ dismiss();
+ }
+ });
+ recyclerView.setAdapter(adapter);
+
+ mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ dismiss();
+ }
+ });
+
+ setupHeightAndBackground(mainView, R.id.favourites_group_recycler_view);
+
+ return mainView;
+ }
+
+ public interface AddFavouriteGroupListener {
+ void onFavouriteGroupAdded();
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/AddMarkersGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/AddMarkersGroupBottomSheetDialogFragment.java
new file mode 100644
index 0000000000..738ccf1766
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/AddMarkersGroupBottomSheetDialogFragment.java
@@ -0,0 +1,75 @@
+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;
+
+public class AddMarkersGroupBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
+
+ public final static String TAG = "AddMarkersGroupBottomSheetDialogFragment";
+
+ private AddMarkersGroupFragmentListener listener;
+
+ public void setListener(AddMarkersGroupFragmentListener listener) {
+ 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);
+
+ if (nightMode) {
+ ((TextView) mainView.findViewById(R.id.add_group_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
+ }
+
+ ((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));
+
+ 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();
+ }
+ });
+
+ 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;
+ }
+
+ interface AddMarkersGroupFragmentListener {
+
+ void favouritesOnClick();
+
+ void waypointsOnClick();
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
index 2f23726980..a5390a1040 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
@@ -10,6 +10,7 @@ import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import net.osmand.Location;
import net.osmand.data.LatLon;
@@ -25,6 +26,7 @@ import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.mapmarkers.adapters.MapMarkersActiveAdapter;
import net.osmand.plus.mapmarkers.adapters.MapMarkersActiveAdapter.MapMarkersActiveAdapterListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
+import net.osmand.plus.widgets.EmptyStateRecyclerView;
import net.osmand.util.MapUtils;
public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener {
@@ -38,10 +40,9 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- final RecyclerView recyclerView = new RecyclerView(getContext());
final MapActivity mapActivity = (MapActivity) getActivity();
- recyclerView.setPadding(0, 0, 0, (int) mapActivity.getResources().getDimension(R.dimen.map_markers_recycler_view_padding_bottom));
- recyclerView.setClipToPadding(false);
+ final View mainView = inflater.inflate(R.layout.fragment_map_markers_active, container, false);
+ final EmptyStateRecyclerView recyclerView = (EmptyStateRecyclerView) mainView.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
adapter = new MapMarkersActiveAdapter(mapActivity);
@@ -90,6 +91,11 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
compassUpdateAllowed = false;
}
});
+
+ final View emptyView = mainView.findViewById(R.id.empty_view);
+ ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
+ emptyImageView.setImageResource(mapActivity.getMyApplication().getSettings().isLightContent() ? R.drawable.ic_empty_state_marker_list_day : R.drawable.ic_empty_state_marker_list_night);
+ recyclerView.setEmptyView(emptyView);
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
@@ -98,7 +104,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
compassUpdateAllowed = newState == RecyclerView.SCROLL_STATE_IDLE;
}
});
- return recyclerView;
+ return mainView;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
index 7386d29620..196f255e33 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
@@ -148,6 +148,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
});
viewPager = mainView.findViewById(R.id.map_markers_view_pager);
+ viewPager.setOffscreenPageLimit(3);
viewPager.setSwipeLocked(true);
final MapMarkersViewPagerAdapter adapter = new MapMarkersViewPagerAdapter(getChildFragmentManager());
viewPager.setAdapter(adapter);
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
index 88d51a7153..f6d7b732f3 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
@@ -19,6 +19,7 @@ import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.Location;
@@ -34,6 +35,9 @@ import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
+import net.osmand.plus.mapmarkers.AddMarkersGroupBottomSheetDialogFragment.AddMarkersGroupFragmentListener;
+import net.osmand.plus.mapmarkers.AddFavouritesGroupBottomSheetDialogFragment.AddFavouriteGroupListener;
+import net.osmand.plus.widgets.EmptyStateRecyclerView;
import net.osmand.util.MapUtils;
public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener {
@@ -49,15 +53,25 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
private Paint textPaint = new Paint();
private Snackbar snackbar;
private boolean compassUpdateAllowed = true;
+ private View mainView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final MapActivity mapActivity = (MapActivity) getActivity();
final boolean night = !mapActivity.getMyApplication().getSettings().isLightContent();
- final RecyclerView recyclerView = new RecyclerView(getContext());
- recyclerView.setPadding(0, 0, 0, (int) mapActivity.getResources().getDimension(R.dimen.map_markers_recycler_view_padding_bottom));
- recyclerView.setClipToPadding(false);
+ mainView = inflater.inflate(R.layout.fragment_map_markers_groups, container, false);
+
+ Fragment addMarkersGroupFragment = getChildFragmentManager().findFragmentByTag(AddMarkersGroupBottomSheetDialogFragment.TAG);
+ if (addMarkersGroupFragment != null) {
+ ((AddMarkersGroupBottomSheetDialogFragment) addMarkersGroupFragment).setListener(createAddMarkersGroupFragmentListener());
+ }
+ Fragment addFavouritesGroupFragment = getChildFragmentManager().findFragmentByTag(AddFavouritesGroupBottomSheetDialogFragment.TAG);
+ if (addFavouritesGroupFragment != null) {
+ ((AddFavouritesGroupBottomSheetDialogFragment) addFavouritesGroupFragment).setListener(createAddFavouritesGroupListener());
+ }
+
+ final EmptyStateRecyclerView recyclerView = (EmptyStateRecyclerView) mainView.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
@@ -222,8 +236,83 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
}
}
});
+ adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
+ @Override
+ public void onChanged() {
+ changeFabVisibilityIfNeeded();
+ }
+
+ @Override
+ public void onItemRangeInserted(int positionStart, int itemCount) {
+ changeFabVisibilityIfNeeded();
+ }
+
+ @Override
+ public void onItemRangeRemoved(int positionStart, int itemCount) {
+ changeFabVisibilityIfNeeded();
+ }
+ });
+
+ final View emptyView = mainView.findViewById(R.id.empty_view);
+ mainView.findViewById(R.id.import_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ openAddGroupMenu();
+ }
+ });
+ ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
+ emptyImageView.setImageResource(night ? R.drawable.ic_empty_state_marker_group_night : R.drawable.ic_empty_state_marker_group_day);
+ recyclerView.setEmptyView(emptyView);
recyclerView.setAdapter(adapter);
- return recyclerView;
+
+ mainView.findViewById(R.id.add_group_fab).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ openAddGroupMenu();
+ }
+ });
+ return mainView;
+ }
+
+ private void changeFabVisibilityIfNeeded() {
+ mainView.findViewById(R.id.add_group_fab).setVisibility(adapter.getItemCount() > 0 ? View.VISIBLE : View.GONE);
+ }
+
+ private void openAddGroupMenu() {
+ AddMarkersGroupBottomSheetDialogFragment fragment = new AddMarkersGroupBottomSheetDialogFragment();
+ fragment.setListener(createAddMarkersGroupFragmentListener());
+ fragment.setUsedOnMap(false);
+ fragment.show(getChildFragmentManager(), AddMarkersGroupBottomSheetDialogFragment.TAG);
+ }
+
+ private void openAddFavouritesGroupMenu() {
+ AddFavouritesGroupBottomSheetDialogFragment fragment = new AddFavouritesGroupBottomSheetDialogFragment();
+ fragment.setListener(createAddFavouritesGroupListener());
+ fragment.setUsedOnMap(false);
+ fragment.show(getChildFragmentManager(), AddFavouritesGroupBottomSheetDialogFragment.TAG);
+ }
+
+ private AddFavouriteGroupListener createAddFavouritesGroupListener() {
+ return new AddFavouriteGroupListener() {
+ @Override
+ public void onFavouriteGroupAdded() {
+ updateAdapter();
+ }
+ };
+ }
+
+ private AddMarkersGroupFragmentListener createAddMarkersGroupFragmentListener() {
+ return new AddMarkersGroupFragmentListener() {
+ @Override
+ public void favouritesOnClick() {
+ openAddFavouritesGroupMenu();
+ }
+
+ @Override
+ public void waypointsOnClick() {
+
+ }
+ };
}
void updateAdapter() {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
index f2335ba0a6..ec12497499 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java
@@ -18,6 +18,7 @@ import android.support.v7.widget.helper.ItemTouchHelper;
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;
@@ -28,6 +29,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapmarkers.adapters.MapMarkerHeaderViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
+import net.osmand.plus.widgets.EmptyStateRecyclerView;
public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHelper.MapMarkerChangedListener {
@@ -73,9 +75,8 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
((HistoryMarkerMenuBottomSheetDialogFragment) historyMarkerMenuFragment).setListener(createHistoryMarkerMenuListener());
}
- final RecyclerView recyclerView = new RecyclerView(getContext());
- recyclerView.setPadding(0, 0, 0, (int) mapActivity.getResources().getDimension(R.dimen.map_markers_recycler_view_padding_bottom));
- recyclerView.setClipToPadding(false);
+ final View mainView = inflater.inflate(R.layout.fragment_map_markers_history, container, false);
+ final EmptyStateRecyclerView recyclerView = (EmptyStateRecyclerView) mainView.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@@ -203,11 +204,15 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
}
}
});
+ final View emptyView = mainView.findViewById(R.id.empty_view);
+ ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
+ emptyImageView.setImageResource(night ? R.drawable.ic_empty_state_marker_history_night : R.drawable.ic_empty_state_marker_history_day);
+ recyclerView.setEmptyView(emptyView);
recyclerView.setAdapter(adapter);
app.getMapMarkersHelper().addListener(this);
- return recyclerView;
+ return mainView;
}
void hideSnackbar() {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/FavouritesGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/FavouritesGroupsAdapter.java
new file mode 100644
index 0000000000..1ae1f03948
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/FavouritesGroupsAdapter.java
@@ -0,0 +1,89 @@
+package net.osmand.plus.mapmarkers.adapters;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
+import net.osmand.plus.IconsCache;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+
+import java.util.List;
+
+public class FavouritesGroupsAdapter extends RecyclerView.Adapter {
+
+ private static final int TYPE_HEADER = 12;
+ private static final int TYPE_ITEM = 13;
+
+ private FavouritesGroupsAdapterListener listener;
+ private OsmandApplication app;
+ private List favoriteGroups;
+ private IconsCache iconsCache;
+
+ public FavouritesGroupsAdapter(Context context, List favoriteGroups) {
+ this.app = (OsmandApplication) context.getApplicationContext();
+ this.favoriteGroups = favoriteGroups;
+ this.iconsCache = app.getIconsCache();
+ }
+
+ public void setAdapterListener(FavouritesGroupsAdapterListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == TYPE_HEADER) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_favourites_group_header, parent, false);
+ return new MapMarkersGroupHeaderViewHolder(view);
+ } else {
+ View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.markers_group_view_holder, parent, false);
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.onItemClick(view);
+ }
+ }
+ });
+ return new MapMarkersGroupViewHolder(view);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof MapMarkersGroupHeaderViewHolder) {
+ MapMarkersGroupHeaderViewHolder markersGroupHeaderViewHolder = (MapMarkersGroupHeaderViewHolder) holder;
+ markersGroupHeaderViewHolder.title.setText(app.getText(R.string.favourites_group));
+ markersGroupHeaderViewHolder.description.setText(app.getText(R.string.add_favourites_group_to_markers_descr));
+ } else if (holder instanceof MapMarkersGroupViewHolder) {
+ FavoriteGroup favoriteGroup = getItem(position);
+ MapMarkersGroupViewHolder markersGroupViewHolder = (MapMarkersGroupViewHolder) holder;
+ int color = favoriteGroup.color == 0 || favoriteGroup.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : favoriteGroup.color;
+ markersGroupViewHolder.icon.setImageDrawable(iconsCache.getPaintedIcon(R.drawable.ic_action_folder, color | 0xff000000));
+ markersGroupViewHolder.name.setText(favoriteGroup.name.length() == 0 ? app.getString(R.string.shared_string_favorites) : favoriteGroup.name);
+ markersGroupViewHolder.numberCount.setText(String.valueOf(favoriteGroup.points.size()));
+ }
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ return position == 0 ? TYPE_HEADER : TYPE_ITEM;
+ }
+
+ @Override
+ public int getItemCount() {
+ return favoriteGroups.size() + 1;
+ }
+
+ private FavoriteGroup getItem(int position) {
+ return favoriteGroups.get(position - 1);
+ }
+
+ public interface FavouritesGroupsAdapterListener {
+ void onItemClick(View view);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupHeaderViewHolder.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupHeaderViewHolder.java
new file mode 100644
index 0000000000..5f1d6ad17e
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupHeaderViewHolder.java
@@ -0,0 +1,19 @@
+package net.osmand.plus.mapmarkers.adapters;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.TextView;
+
+import net.osmand.plus.R;
+
+public class MapMarkersGroupHeaderViewHolder extends RecyclerView.ViewHolder {
+
+ TextView title;
+ TextView description;
+
+ public MapMarkersGroupHeaderViewHolder(View itemView) {
+ super(itemView);
+ title = itemView.findViewById(R.id.title);
+ description = itemView.findViewById(R.id.description);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupViewHolder.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupViewHolder.java
new file mode 100644
index 0000000000..e2340da0ff
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupViewHolder.java
@@ -0,0 +1,22 @@
+package net.osmand.plus.mapmarkers.adapters;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osmand.plus.R;
+
+public class MapMarkersGroupViewHolder extends RecyclerView.ViewHolder {
+
+ ImageView icon;
+ TextView name;
+ TextView numberCount;
+
+ public MapMarkersGroupViewHolder(View itemView) {
+ super(itemView);
+ icon = itemView.findViewById(R.id.icon);
+ name = itemView.findViewById(R.id.name_text);
+ numberCount = itemView.findViewById(R.id.number_count_text);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/widgets/EmptyStateRecyclerView.java b/OsmAnd/src/net/osmand/plus/widgets/EmptyStateRecyclerView.java
new file mode 100644
index 0000000000..ee2b129c72
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/widgets/EmptyStateRecyclerView.java
@@ -0,0 +1,70 @@
+package net.osmand.plus.widgets;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class EmptyStateRecyclerView extends RecyclerView {
+ private View emptyView;
+
+ public EmptyStateRecyclerView(Context context) {
+ super(context);
+ }
+
+ public EmptyStateRecyclerView(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public EmptyStateRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ private AdapterDataObserver emptyStateObserver = new AdapterDataObserver() {
+ @Override
+ public void onChanged() {
+ checkIfEmpty();
+ }
+
+ @Override
+ public void onItemRangeInserted(int positionStart, int itemCount) {
+ checkIfEmpty();
+ }
+
+ @Override
+ public void onItemRangeRemoved(int positionStart, int itemCount) {
+ checkIfEmpty();
+ }
+ };
+
+ @Override
+ public void setAdapter(Adapter adapter) {
+ final Adapter oldAdapter = getAdapter();
+ if (oldAdapter != null) {
+ oldAdapter.unregisterAdapterDataObserver(emptyStateObserver);
+ }
+ super.setAdapter(adapter);
+ if (adapter != null) {
+ adapter.registerAdapterDataObserver(emptyStateObserver);
+ }
+ checkIfEmpty();
+ }
+
+ public void setEmptyView(View emptyView) {
+ this.emptyView = emptyView;
+ checkIfEmpty();
+ }
+
+ private void checkIfEmpty() {
+ if (emptyView != null && getAdapter() != null) {
+ if (getAdapter().getItemCount() == 0) {
+ setVisibility(View.GONE);
+ emptyView.setVisibility(View.VISIBLE);
+ } else {
+ emptyView.setVisibility(View.GONE);
+ setVisibility(View.VISIBLE);
+ }
+ }
+ }
+}