Merge branch 'sasha_pasha_branch' of ssh://github.com/osmandapp/Osmand into sasha_pasha_branch
This commit is contained in:
commit
b0da4038d2
6 changed files with 218 additions and 99 deletions
|
@ -7,11 +7,21 @@
|
||||||
android:descendantFocusability="blocksDescendants"
|
android:descendantFocusability="blocksDescendants"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<LinearLayout
|
||||||
android:id="@+id/top_divider"
|
android:id="@+id/top_divider"
|
||||||
layout="@layout/list_item_divider"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="4dp"/>
|
||||||
|
|
||||||
|
<include layout="@layout/card_top_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/main_layout"
|
android:id="@+id/main_layout"
|
||||||
|
|
|
@ -3,10 +3,21 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/list_item_divider"/>
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="4dp"/>
|
||||||
|
|
||||||
|
<include layout="@layout/card_top_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/background_view"
|
android:id="@+id/background_view"
|
||||||
|
@ -58,8 +69,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginLeft="56dp"
|
android:layout_marginLeft="44dp"
|
||||||
android:layout_marginStart="56dp">
|
android:layout_marginStart="44dp">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/use_location_button"
|
android:id="@+id/use_location_button"
|
||||||
|
@ -69,8 +80,8 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingLeft="12dp"
|
||||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingRight="12dp"
|
||||||
android:text="@string/use_location"
|
android:text="@string/use_location"
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
osmand:textAllCapsCompat="true"
|
osmand:textAllCapsCompat="true"
|
||||||
|
@ -84,8 +95,8 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingLeft="12dp"
|
||||||
android:paddingStart="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingRight="12dp"
|
||||||
android:text="@string/shared_string_do_not_use"
|
android:text="@string/shared_string_do_not_use"
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
osmand:textAllCapsCompat="true"
|
osmand:textAllCapsCompat="true"
|
||||||
|
@ -94,4 +105,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/card_bottom_divider"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.mapmarkers;
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -14,6 +15,7 @@ import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -27,6 +29,7 @@ import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.MapMarkersHelper;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
|
@ -161,7 +164,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
||||||
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
quit(false);
|
if (quit(false)) {
|
||||||
|
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mapActivity.showTopToolbar(toolbarController);
|
mapActivity.showTopToolbar(toolbarController);
|
||||||
|
@ -201,9 +206,26 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
||||||
toPosition = holder.getAdapterPosition();
|
toPosition = holder.getAdapterPosition();
|
||||||
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
||||||
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
|
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
|
||||||
adapter.notifyDataSetChanged();
|
mapActivity.getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
try {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// to avoid crash because of:
|
||||||
|
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUseLocationClick() {
|
||||||
|
Toast.makeText(mapActivity, "use location", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDoNotUseLocationClick() {
|
||||||
|
Toast.makeText(mapActivity, "do not use location", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600;
|
boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600;
|
||||||
markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108));
|
markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108));
|
||||||
|
@ -211,6 +233,24 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
||||||
markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
markersRv.setAdapter(adapter);
|
markersRv.setAdapter(adapter);
|
||||||
|
|
||||||
|
if (portrait) {
|
||||||
|
showMarkersList();
|
||||||
|
} else {
|
||||||
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
showMarkersList();
|
||||||
|
|
||||||
|
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
obs.removeOnGlobalLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,10 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
|
||||||
@Override
|
@Override
|
||||||
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||||
super.clearView(recyclerView, viewHolder);
|
super.clearView(recyclerView, viewHolder);
|
||||||
((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.VISIBLE);
|
if (iconHidden) {
|
||||||
iconHidden = false;
|
((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.VISIBLE);
|
||||||
|
iconHidden = false;
|
||||||
|
}
|
||||||
adapter.onItemDismiss(viewHolder);
|
adapter.onItemDismiss(viewHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,15 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder>
|
public class MapMarkersListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter {
|
implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter {
|
||||||
|
|
||||||
|
private static final int USE_LOCATION_CARD_TYPE = 1;
|
||||||
|
private static final int MARKER_ITEM_TYPE = 2;
|
||||||
|
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
private List<MapMarker> markers;
|
private List<MapMarker> markers;
|
||||||
|
private boolean locationCardDisplayed = true;
|
||||||
private MapMarkersListAdapterListener listener;
|
private MapMarkersListAdapterListener listener;
|
||||||
|
|
||||||
private LatLon location;
|
private LatLon location;
|
||||||
|
@ -50,107 +54,135 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
if (viewType == USE_LOCATION_CARD_TYPE) {
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.use_location_card, viewGroup, false);
|
||||||
@Override
|
return new UseLocationCardViewHolder(view);
|
||||||
public void onClick(View view) {
|
} else if (viewType == MARKER_ITEM_TYPE) {
|
||||||
listener.onItemClick(view);
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||||
}
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
});
|
@Override
|
||||||
return new MapMarkerItemViewHolder(view);
|
public void onClick(View view) {
|
||||||
|
listener.onItemClick(view);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new MapMarkerItemViewHolder(view);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unsupported view type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) {
|
public int getItemViewType(int position) {
|
||||||
|
if (locationCardDisplayed && position == 0) {
|
||||||
|
return USE_LOCATION_CARD_TYPE;
|
||||||
|
}
|
||||||
|
return MARKER_ITEM_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int pos) {
|
||||||
boolean night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
boolean night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
||||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||||
MapMarker marker = markers.get(pos);
|
|
||||||
|
|
||||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
|
if (holder instanceof UseLocationCardViewHolder) {
|
||||||
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
|
final UseLocationCardViewHolder locationCardHolder = (UseLocationCardViewHolder) holder;
|
||||||
holder.iconDirection.setVisibility(View.GONE);
|
|
||||||
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light));
|
|
||||||
holder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
|
|
||||||
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
|
|
||||||
holder.optionsBtn.setVisibility(View.GONE);
|
|
||||||
holder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
|
|
||||||
holder.checkBox.setVisibility(View.VISIBLE);
|
|
||||||
holder.checkBox.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
listener.onItemClick(holder.itemView);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
holder.checkBox.setChecked(marker.selected);
|
|
||||||
|
|
||||||
if (pos == 0 || pos == getItemCount() - 1) {
|
locationCardHolder.useLocationBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
holder.firstDescription.setVisibility(View.VISIBLE);
|
@Override
|
||||||
if (pos == 0) {
|
public void onClick(View view) {
|
||||||
holder.topDivider.setVisibility(View.VISIBLE);
|
listener.onUseLocationClick();
|
||||||
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + " • ");
|
|
||||||
} else {
|
|
||||||
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_finish) + " • ");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
holder.firstDescription.setVisibility(View.GONE);
|
|
||||||
holder.topDivider.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos == getItemCount() - 1) {
|
|
||||||
holder.bottomShadow.setVisibility(View.VISIBLE);
|
|
||||||
holder.divider.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
holder.bottomShadow.setVisibility(View.GONE);
|
|
||||||
holder.divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.point.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View view, MotionEvent event) {
|
|
||||||
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
|
|
||||||
listener.onDragStarted(holder);
|
|
||||||
}
|
}
|
||||||
return false;
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
holder.title.setText(marker.getName(mapActivity));
|
locationCardHolder.doNotUseLocationBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
listener.onDoNotUseLocationClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (holder instanceof MapMarkerItemViewHolder) {
|
||||||
|
MapMarker marker = getItem(pos);
|
||||||
|
final MapMarkerItemViewHolder itemHolder = (MapMarkerItemViewHolder) holder;
|
||||||
|
|
||||||
String descr;
|
itemHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
|
||||||
if ((descr = marker.groupName) != null) {
|
itemHolder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
|
||||||
if (descr.equals("")) {
|
itemHolder.iconDirection.setVisibility(View.GONE);
|
||||||
descr = mapActivity.getString(R.string.shared_string_favorites);
|
itemHolder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light));
|
||||||
}
|
itemHolder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
|
||||||
} else {
|
itemHolder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
|
||||||
Date date = new Date(marker.creationDate);
|
itemHolder.optionsBtn.setVisibility(View.GONE);
|
||||||
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
|
itemHolder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
|
||||||
if (month.length() > 1) {
|
itemHolder.checkBox.setVisibility(View.VISIBLE);
|
||||||
month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
|
itemHolder.checkBox.setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
String day = new SimpleDateFormat("dd", Locale.getDefault()).format(date);
|
public void onClick(View view) {
|
||||||
descr = month + " " + day;
|
listener.onItemClick(itemHolder.itemView);
|
||||||
}
|
}
|
||||||
holder.description.setText(descr);
|
});
|
||||||
|
itemHolder.checkBox.setChecked(marker.selected);
|
||||||
|
|
||||||
if (location != null) {
|
int firstMarkerPos = locationCardDisplayed ? 1 : 0;
|
||||||
holder.distance.setTextColor(ContextCompat.getColor(mapActivity, useCenter
|
int lastMarkerPos = getItemCount() - 1;
|
||||||
? R.color.color_distance : R.color.color_myloc_distance));
|
|
||||||
float dist = (float) MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
itemHolder.topDivider.setVisibility(pos == firstMarkerPos ? View.VISIBLE : View.GONE);
|
||||||
marker.getLatitude(), marker.getLongitude());
|
itemHolder.firstDescription.setVisibility((pos == firstMarkerPos || pos == lastMarkerPos) ? View.VISIBLE : View.GONE);
|
||||||
holder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
|
itemHolder.bottomShadow.setVisibility(pos == lastMarkerPos ? View.VISIBLE : View.GONE);
|
||||||
|
itemHolder.divider.setVisibility(pos == lastMarkerPos ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
|
if (pos == firstMarkerPos) {
|
||||||
|
itemHolder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + " • ");
|
||||||
|
} else if (pos == lastMarkerPos) {
|
||||||
|
itemHolder.firstDescription.setText(mapActivity.getString(R.string.shared_string_finish) + " • ");
|
||||||
|
}
|
||||||
|
|
||||||
|
itemHolder.point.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
itemHolder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View view, MotionEvent event) {
|
||||||
|
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
|
||||||
|
listener.onDragStarted(itemHolder);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
itemHolder.title.setText(marker.getName(mapActivity));
|
||||||
|
|
||||||
|
String descr;
|
||||||
|
if ((descr = marker.groupName) != null) {
|
||||||
|
if (descr.equals("")) {
|
||||||
|
descr = mapActivity.getString(R.string.shared_string_favorites);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Date date = new Date(marker.creationDate);
|
||||||
|
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
|
||||||
|
if (month.length() > 1) {
|
||||||
|
month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
|
||||||
|
}
|
||||||
|
String day = new SimpleDateFormat("dd", Locale.getDefault()).format(date);
|
||||||
|
descr = month + " " + day;
|
||||||
|
}
|
||||||
|
itemHolder.description.setText(descr);
|
||||||
|
|
||||||
|
if (location != null) {
|
||||||
|
itemHolder.distance.setTextColor(ContextCompat.getColor(mapActivity, useCenter
|
||||||
|
? R.color.color_distance : R.color.color_myloc_distance));
|
||||||
|
float dist = (float) MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
||||||
|
marker.getLatitude(), marker.getLongitude());
|
||||||
|
itemHolder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return markers.size();
|
return locationCardDisplayed ? markers.size() + 1 : markers.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapMarker getItem(int position) {
|
public MapMarker getItem(int position) {
|
||||||
return markers.get(position);
|
return markers.get(locationCardDisplayed ? position - 1 : position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -160,7 +192,10 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemMove(int from, int to) {
|
public boolean onItemMove(int from, int to) {
|
||||||
Collections.swap(markers, from, to);
|
if (locationCardDisplayed && to == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Collections.swap(markers, locationCardDisplayed ? from - 1 : from, locationCardDisplayed ? to - 1 : to);
|
||||||
notifyItemMoved(from, to);
|
notifyItemMoved(from, to);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -182,5 +217,21 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
||||||
void onDragStarted(RecyclerView.ViewHolder holder);
|
void onDragStarted(RecyclerView.ViewHolder holder);
|
||||||
|
|
||||||
void onDragEnded(RecyclerView.ViewHolder holder);
|
void onDragEnded(RecyclerView.ViewHolder holder);
|
||||||
|
|
||||||
|
void onUseLocationClick();
|
||||||
|
|
||||||
|
void onDoNotUseLocationClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UseLocationCardViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final View useLocationBtn;
|
||||||
|
final View doNotUseLocationBtn;
|
||||||
|
|
||||||
|
UseLocationCardViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
useLocationBtn = view.findViewById(R.id.use_location_button);
|
||||||
|
doNotUseLocationBtn = view.findViewById(R.id.do_not_use_location_button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
|
|
||||||
private final ContextMenuLayer contextMenuLayer;
|
private final ContextMenuLayer contextMenuLayer;
|
||||||
private final MeasurementToolLayer measurementToolLayer;
|
private final MeasurementToolLayer measurementToolLayer;
|
||||||
|
private final MapMarkersLayer mapMarkersLayer;
|
||||||
private ImageView contextMarker;
|
private ImageView contextMarker;
|
||||||
private final MapActivity mapActivity;
|
private final MapActivity mapActivity;
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
|
@ -66,6 +67,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
settings = activity.getMyApplication().getSettings();
|
settings = activity.getMyApplication().getSettings();
|
||||||
quickActionRegistry = activity.getMapLayers().getQuickActionRegistry();
|
quickActionRegistry = activity.getMapLayers().getQuickActionRegistry();
|
||||||
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||||
|
mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,6 +325,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||||
contextMenuLayer.isInGpxDetailsMode() ||
|
contextMenuLayer.isInGpxDetailsMode() ||
|
||||||
measurementToolLayer.isInMeasurementMode() ||
|
measurementToolLayer.isInMeasurementMode() ||
|
||||||
|
mapMarkersLayer.isInPlanRouteMode() ||
|
||||||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
|
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
|
||||||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
|
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
|
||||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
|
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
|
||||||
|
|
Loading…
Reference in a new issue