Restored replace existing favorite feature

This commit is contained in:
Alexey Kulish 2015-10-21 21:21:55 +03:00
parent d6acfc67f5
commit a13498f794
2 changed files with 29 additions and 3 deletions

View file

@ -22,6 +22,7 @@ import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
@ -57,8 +58,10 @@ public class FavoriteDialogs {
} }
FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE); FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
if (helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) { if (helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) {
AccessibleToast.makeText(activity, activity.getString(R.string.fav_points_edited), if (activity instanceof MapActivity) {
Toast.LENGTH_SHORT).show(); ((MapActivity) activity).getContextMenu()
.show(new LatLon(point.getLatitude(), point.getLongitude()), fp.getPointDescription(), fp);
}
} }
if (activity instanceof MapActivity) { if (activity instanceof MapActivity) {
((MapActivity) activity).getMapView().refreshMap(); ((MapActivity) activity).getMapView().refreshMap();

View file

@ -7,6 +7,10 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -17,6 +21,7 @@ import net.osmand.plus.OsmandApplication;
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.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -38,7 +43,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
boolean light = getMyApplication().getSettings().isLightContent(); boolean light = getMyApplication().getSettings().isLightContent();
@ -48,6 +53,24 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
group = helper.getGroup(favorite); group = helper.getGroup(favorite);
} }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null && editor.isNew()) {
Button btnReplace = (Button) view.findViewById(R.id.button_replace);
btnReplace.setVisibility(View.VISIBLE);
btnReplace.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putSerializable(FavoriteDialogs.KEY_FAVORITE, favorite);
FavoriteDialogs.createReplaceFavouriteDialog(getActivity(), args);
}
});
}
return view;
}
@Override @Override
public PointEditor getEditor() { public PointEditor getEditor() {
return editor; return editor;