Menu button for favourites items. For better use experience: issue #1340
This commit is contained in:
parent
5a495b1913
commit
e95aa8ab32
5 changed files with 185 additions and 144 deletions
|
@ -1,42 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/expandable_list_item_background"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:id="@+id/divider"
|
||||
android:visibility="gone"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/list_content_padding" >
|
||||
android:paddingLeft="@dimen/list_content_padding">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/check_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||
android:focusable="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favourite_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin" />
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -44,7 +45,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingRight="@dimen/list_content_padding" >
|
||||
android:paddingRight="@dimen/list_content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/favourite_label"
|
||||
|
@ -52,19 +53,19 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="@string/lorem_ipsum" />
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/direction"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_destination_arrow_white"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_destination_arrow_white"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
|
@ -73,7 +74,7 @@
|
|||
android:layout_marginLeft="2dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="100500 km" />
|
||||
tools:text="100500 km"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/group_image"
|
||||
|
@ -81,7 +82,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:src="@drawable/ic_small_group" />
|
||||
android:src="@drawable/ic_small_group"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/group_name"
|
||||
|
@ -90,7 +91,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size" />
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -99,18 +100,19 @@
|
|||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="invisible"
|
||||
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:src="@drawable/ic_action_test_light" />
|
||||
android:src="@drawable/ic_action_test_light"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/options"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:src="@drawable/ic_overflow_menu_white"/>
|
||||
android:src="@drawable/ic_overflow_menu_white"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -3,8 +3,20 @@
|
|||
*/
|
||||
package net.osmand.plus.activities;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -18,24 +30,10 @@ import net.osmand.plus.base.FavoriteImageDrawable;
|
|||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoritesListFragment extends OsmAndListFragment implements SearchActivityChild, OsmAndCompassListener {
|
||||
|
||||
public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY";
|
||||
|
@ -46,15 +44,27 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
private boolean selectFavoriteMode;
|
||||
private OsmandSettings settings;
|
||||
private boolean compassRegistered;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
Intent intent = activity.getIntent();
|
||||
if (intent != null) {
|
||||
selectFavoriteMode = intent.hasExtra(SELECT_FAVORITE_POINT_INTENT_KEY);
|
||||
if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) {
|
||||
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
|
||||
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
|
||||
if (lat != 0 || lon != 0) {
|
||||
favouritesAdapter.location = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
}
|
||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||
OsmandApplication app = (OsmandApplication) getApplication();
|
||||
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints());
|
||||
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints(),
|
||||
!selectFavoriteMode);
|
||||
setListAdapter(favouritesAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
@ -66,17 +76,6 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Intent intent = getActivity().getIntent();
|
||||
if (intent != null) {
|
||||
selectFavoriteMode = intent.hasExtra(SELECT_FAVORITE_POINT_INTENT_KEY);
|
||||
if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) {
|
||||
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
|
||||
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
|
||||
if (lat != 0 || lon != 0) {
|
||||
favouritesAdapter.location = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (favouritesAdapter.location == null && getActivity() instanceof SearchActivity) {
|
||||
favouritesAdapter.location = ((SearchActivity) getActivity()).getSearchPoint();
|
||||
|
@ -104,9 +103,9 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
if (favouritesAdapter != null) {
|
||||
favouritesAdapter.updateLocation(l);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
@ -133,11 +132,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
|
||||
if (!isSelectFavoriteMode()) {
|
||||
FavouritePoint point = favouritesAdapter.getItem(position);
|
||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location, point, point.getPointDescription(), settings.getLastKnownMapZoom(),
|
||||
getActivity(), true, false);
|
||||
optionsMenu.show();
|
||||
showItemPopupOptionsMenu(point, getActivity(), v);
|
||||
} else {
|
||||
Intent intent = getActivity().getIntent();
|
||||
intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position));
|
||||
|
@ -153,6 +148,15 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
private boolean searchAroundLocation;
|
||||
private int screenOrientation;
|
||||
private Float heading;
|
||||
private boolean shoudShowMenuButton;
|
||||
|
||||
public FavouritesAdapter(Activity activity, List<FavouritePoint> list,
|
||||
boolean shoudShowMenuButton) {
|
||||
super(activity, R.layout.favorites_list_item, list);
|
||||
this.activity = activity;
|
||||
this.app = ((OsmandApplication) activity.getApplication());
|
||||
this.shoudShowMenuButton = shoudShowMenuButton;
|
||||
}
|
||||
|
||||
public LatLon getLocation() {
|
||||
return location;
|
||||
|
@ -179,12 +183,6 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
});
|
||||
}
|
||||
|
||||
public FavouritesAdapter(Activity activity, List<FavouritePoint> list) {
|
||||
super(activity, R.layout.favorites_list_item, list);
|
||||
this.activity = activity;
|
||||
this.app = ((OsmandApplication) activity.getApplication());
|
||||
}
|
||||
|
||||
public String getName(FavouritePoint model) {
|
||||
return model.getName();
|
||||
}
|
||||
|
@ -193,7 +191,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
LayoutInflater inflater = activity.getLayoutInflater(); // favourite dank
|
||||
row = inflater.inflate(R.layout.favorites_list_item, parent, false);
|
||||
}
|
||||
|
||||
|
@ -204,6 +202,19 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
ImageView giImage= (ImageView)row.findViewById(R.id.group_image);
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
final FavouritePoint favorite = getItem(position);
|
||||
if (shoudShowMenuButton) {
|
||||
ImageButton options = (ImageButton) row.findViewById(R.id.options);
|
||||
options.setFocusable(false);
|
||||
options.setImageDrawable(((OsmandApplication) activity.getApplication())
|
||||
.getIconsCache().getContentIcon(R.drawable.ic_overflow_menu_white));
|
||||
options.setVisibility(View.VISIBLE);
|
||||
options.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showItemPopupOptionsMenu(favorite, activity, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!favorite.getCategory().isEmpty()) {
|
||||
giImage.setVisibility(View.VISIBLE);
|
||||
giImage.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_small_group));
|
||||
|
@ -213,9 +224,9 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
|
||||
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), 0));
|
||||
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
|
||||
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
|
||||
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity);
|
||||
|
||||
|
||||
name.setText(getName(favorite));
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
|
@ -231,14 +242,24 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
|
||||
@Override
|
||||
public void updateCompassValue(float value) {
|
||||
// 99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass
|
||||
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) on non-compass
|
||||
// devices
|
||||
float lastHeading = favouritesAdapter.heading != null ? favouritesAdapter.heading : 99;
|
||||
favouritesAdapter.heading = value;
|
||||
if (favouritesAdapter.heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, favouritesAdapter.heading)) > 5) {
|
||||
if (Math.abs(MapUtils.degreesDiff(lastHeading, favouritesAdapter.heading)) > 5) {
|
||||
favouritesAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
favouritesAdapter.heading = lastHeading;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showItemPopupOptionsMenu(FavouritePoint point, Activity activity, View view) {
|
||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
final PopupMenu optionsMenu = new PopupMenu(activity, view);
|
||||
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location,
|
||||
point, point.getPointDescription(),
|
||||
((OsmandApplication) activity.getApplication()).getSettings().getLastKnownMapZoom(),
|
||||
activity, true, false);
|
||||
optionsMenu.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ import android.widget.ImageView;
|
|||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
|
@ -53,8 +53,8 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -183,39 +183,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
updateSelectionMode(actionMode);
|
||||
} else {
|
||||
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition);
|
||||
final OsmandSettings settings = getMyApplication().getSettings();
|
||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location, point,
|
||||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), settings.getLastKnownMapZoom(),
|
||||
getActivity(), true, false);
|
||||
|
||||
MenuItem item = optionsMenu.getMenu().add(R.string.favourites_context_menu_edit)
|
||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
editPoint(getActivity(), point, new Runnable() {
|
||||
public void run() {
|
||||
favouritesAdapter.synchronizeGroups();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.favourites_context_menu_delete)
|
||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
deletePoint(point);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
optionsMenu.show();
|
||||
showItemPopupOptionsMenu(point, v);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -792,8 +760,19 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
TextView name = (TextView) row.findViewById(R.id.favourite_label);
|
||||
TextView distanceText = (TextView) row.findViewById(R.id.distance);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
||||
ImageView options = (ImageView) row.findViewById(R.id.options);
|
||||
options.setFocusable(false);
|
||||
options.setImageDrawable(getMyApplication().getIconsCache()
|
||||
.getContentIcon(R.drawable.ic_overflow_menu_white));
|
||||
options.setVisibility(View.VISIBLE);
|
||||
final FavouritePoint model = (FavouritePoint) getChild(groupPosition, childPosition);
|
||||
row.setTag(model);
|
||||
options.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showItemPopupOptionsMenu(model, v);
|
||||
}
|
||||
});
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), model.getColor(), 0));
|
||||
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
|
||||
|
@ -895,4 +874,41 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showItemPopupOptionsMenu(final FavouritePoint point, final View view) {
|
||||
final OsmandSettings settings = getMyApplication().getSettings();
|
||||
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), view);
|
||||
DirectionsDialogs.createDirectionActionsPopUpMenu(optionsMenu, location, point,
|
||||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()),
|
||||
settings.getLastKnownMapZoom(),
|
||||
getActivity(), true, false);
|
||||
|
||||
MenuItem item = optionsMenu.getMenu().add(R.string.favourites_context_menu_edit)
|
||||
.setIcon(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
editPoint(getActivity(), point, new Runnable() {
|
||||
public void run() {
|
||||
favouritesAdapter.synchronizeGroups();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.favourites_context_menu_delete)
|
||||
.setIcon(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
deletePoint(point);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
optionsMenu.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,5 @@
|
|||
package net.osmand.plus.dialogs;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
|
@ -36,6 +19,24 @@ import android.widget.EditText;
|
|||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoriteDialogs {
|
||||
public static final String KEY_FAVORITE = "favorite";
|
||||
|
||||
|
@ -43,7 +44,8 @@ public class FavoriteDialogs {
|
|||
final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites();
|
||||
final List<FavouritePoint> points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
|
||||
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(activity,
|
||||
((OsmandApplication) activity.getApplication()).getFavorites().getFavouritePoints());
|
||||
((OsmandApplication) activity.getApplication()).getFavorites().getFavouritePoints(),
|
||||
false);
|
||||
final Dialog[] dlgHolder = new Dialog[1];
|
||||
OnItemClickListener click = new AdapterView.OnItemClickListener() {
|
||||
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PointF;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -24,7 +34,6 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
import net.osmand.plus.activities.search.SearchAddressActivity;
|
||||
import net.osmand.plus.activities.search.SearchAddressFragment;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||
|
@ -34,20 +43,11 @@ import net.osmand.plus.views.ContextMenuLayer;
|
|||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.controls.MapRoutePreferencesControl.RoutePrepareDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PointF;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MapRouteInfoControl implements IRouteInformationListener {
|
||||
public static int directionInfo = -1;
|
||||
|
@ -268,7 +268,7 @@ public class MapRouteInfoControl implements IRouteInformationListener {
|
|||
|
||||
protected void selectFavorite(final View parentView, final boolean target) {
|
||||
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(mapActivity, mapActivity.getMyApplication()
|
||||
.getFavorites().getFavouritePoints());
|
||||
.getFavorites().getFavouritePoints(), false);
|
||||
Dialog[] dlgHolder = new Dialog[1];
|
||||
OnItemClickListener click = getOnClickListener(target, favouritesAdapter, dlgHolder);
|
||||
OnDismissListener dismissListener = new DialogInterface.OnDismissListener() {
|
||||
|
|
Loading…
Reference in a new issue