fix menu, fix context menu
git-svn-id: https://osmand.googlecode.com/svn/trunk@146 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
88b46f6489
commit
344c0b9b8e
9 changed files with 134 additions and 48 deletions
|
@ -46,24 +46,25 @@ public class ToDoConstants {
|
||||||
// 34. Investigate routing (bicycle, car)
|
// 34. Investigate routing (bicycle, car)
|
||||||
// 36. Postcode search
|
// 36. Postcode search
|
||||||
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
|
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
|
||||||
// 38. Add Button in search navigate to.
|
// 38. Add button in search "navigate to".
|
||||||
|
|
||||||
|
|
||||||
// BUGS Android
|
// BUGS Android
|
||||||
// 1. Fix bug with navigation layout (less zoom controls) (fixed).
|
// 1. Fix bug with navigation layout (less zoom controls) [fixed].
|
||||||
// 4. Fix layout problems with add comment (fixed)
|
// 4. Fix layout problems with add comment [fixed]
|
||||||
// 3. Implement clear existing area with tiles (update map)
|
// 7. Fix set location (clear sync with gps) [fixed]
|
||||||
|
// 3. Implement clear existing area with tiles (update map) [fixed]
|
||||||
|
// 6. Implement context menu for long press & trackball press [fixed - trackball todo]
|
||||||
// 2. Include to amenity index : historic, sport, ....
|
// 2. Include to amenity index : historic, sport, ....
|
||||||
// 5. Implement caching files existing on FS, implement specific method in RM
|
// 5. Implement caching files existing on FS, implement specific method in RM
|
||||||
// 7. Fix set location (clear sync with gps)
|
|
||||||
// Improvements
|
|
||||||
// 6. Implement context menu for long press & trackball press
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO swing
|
// TODO swing
|
||||||
// 2. Internal (Simplify MapPanel - introduce layers for it)ю
|
// 2. Internal (Simplify MapPanel - introduce layers for it)ю
|
||||||
// 3. Implement clear progress.
|
// 3. Implement clear progress.
|
||||||
|
// 4. Fix issues with big files (such as netherlands)
|
||||||
// 1. Download tiles without using dir tiles
|
// 1. Download tiles without using dir tiles
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package com.osmand.osm.util;
|
package com.osmand.osm.util;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Container;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -21,11 +17,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JMenuBar;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.xml.stream.XMLStreamException;
|
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.osmand.data.DataTileManager;
|
import com.osmand.data.DataTileManager;
|
||||||
|
@ -40,8 +31,6 @@ import com.osmand.osm.Way;
|
||||||
import com.osmand.osm.OSMSettings.OSMTagKey;
|
import com.osmand.osm.OSMSettings.OSMTagKey;
|
||||||
import com.osmand.osm.io.IOsmStorageFilter;
|
import com.osmand.osm.io.IOsmStorageFilter;
|
||||||
import com.osmand.osm.io.OsmBaseStorage;
|
import com.osmand.osm.io.OsmBaseStorage;
|
||||||
import com.osmand.osm.io.OsmStorageWriter;
|
|
||||||
import com.osmand.swing.DataExtractionSettings;
|
|
||||||
import com.osmand.swing.MapPanel;
|
import com.osmand.swing.MapPanel;
|
||||||
|
|
||||||
public class MinskTransReader {
|
public class MinskTransReader {
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu
|
<menu
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<group android:id="@+id/map_context_menu" android:menuCategory="container"><item android:id="@+id/map_show_settings" android:title="@string/settings_Button"></item>
|
<group android:id="@+id/map_context_menu" android:menuCategory="container">
|
||||||
<item android:title="@string/mark_point" android:id="@+id/map_mark_point"></item>
|
<item android:title="@string/mark_point" android:id="@+id/map_mark_point" android:icon="@android:drawable/ic_menu_mylocation"></item>
|
||||||
<item android:title="@string/navigate_to_point" android:id="@+id/map_navigate_to_point"></item>
|
<item android:id="@+id/map_navigate_to_point" android:title="@string/stop_navigation" android:visible="false" android:icon="@android:drawable/ic_menu_close_clear_cancel"></item>
|
||||||
<item android:title="@string/map_specify_point" android:id="@+id/map_specify_point"></item>
|
<item android:id="@+id/map_reload_tile" android:title="@string/update_tile" android:icon="@android:drawable/ic_menu_view"></item>
|
||||||
|
<item android:title="@string/map_specify_point" android:id="@+id/map_specify_point" android:icon="@android:drawable/ic_menu_search"></item>
|
||||||
|
<item android:id="@+id/map_show_settings" android:title="@string/settings_Button" android:icon="@android:drawable/ic_menu_preferences"></item>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="update_tile">Update map</string>
|
||||||
|
<string name="reload_tile">Reload tile</string>
|
||||||
<string name="user_name_descr">Input user name to communicate osm</string>
|
<string name="user_name_descr">Input user name to communicate osm</string>
|
||||||
<string name="user_name">User name</string>
|
<string name="user_name">User name</string>
|
||||||
<string name="mark_point">Mark point</string>
|
<string name="mark_point">Target</string>
|
||||||
<string name="show_osm_bugs_descr">Show open street bugs on map</string>
|
<string name="show_osm_bugs_descr">Show open street bugs on map</string>
|
||||||
<string name="show_osm_bugs">Show open street bugs</string>
|
<string name="show_osm_bugs">Show open street bugs</string>
|
||||||
<string name="favourites_activity">List of favourite points</string>
|
<string name="favourites_activity">List of favourite points</string>
|
||||||
|
|
|
@ -81,11 +81,11 @@ public class ResourceManager {
|
||||||
|
|
||||||
////////////////////////////////////////////// Working with tiles ////////////////////////////////////////////////
|
////////////////////////////////////////////// Working with tiles ////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
public Bitmap getTileImageForMapAsync(ITileSource map, int x, int y, int zoom, boolean loadFromInternetIfNeeded) {
|
public Bitmap getTileImageForMapAsync(ITileSource map, int x, int y, int zoom, boolean loadFromInternetIfNeeded) {
|
||||||
return getTileImageForMap(map, x, y, zoom, loadFromInternetIfNeeded, false, true);
|
return getTileImageForMap(map, x, y, zoom, loadFromInternetIfNeeded, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Bitmap getTileImageFromCache(ITileSource map, int x, int y, int zoom){
|
public Bitmap getTileImageFromCache(ITileSource map, int x, int y, int zoom){
|
||||||
return getTileImageForMap(map, x, y, zoom, false, false, false);
|
return getTileImageForMap(map, x, y, zoom, false, false, false);
|
||||||
}
|
}
|
||||||
|
@ -99,10 +99,18 @@ public class ResourceManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearTileImageForMap(ITileSource map, int x, int y, int zoom){
|
||||||
|
getTileImageForMap(map, x, y, zoom, true, false, false, true);
|
||||||
|
}
|
||||||
|
protected Bitmap getTileImageForMap(ITileSource map, int x, int y, int zoom,
|
||||||
|
boolean loadFromInternetIfNeeded, boolean sync, boolean loadFromFs) {
|
||||||
|
return getTileImageForMap(map, x, y, zoom, loadFromInternetIfNeeded, sync, loadFromFs, false);
|
||||||
|
}
|
||||||
|
|
||||||
// introduce cache in order save memory
|
// introduce cache in order save memory
|
||||||
protected StringBuilder builder = new StringBuilder(40);
|
protected StringBuilder builder = new StringBuilder(40);
|
||||||
protected synchronized Bitmap getTileImageForMap(ITileSource map, int x, int y, int zoom,
|
protected synchronized Bitmap getTileImageForMap(ITileSource map, int x, int y, int zoom,
|
||||||
boolean loadFromInternetIfNeeded, boolean sync, boolean loadFromFs) {
|
boolean loadFromInternetIfNeeded, boolean sync, boolean loadFromFs, boolean deleteBefore) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +118,14 @@ public class ResourceManager {
|
||||||
builder.append(map.getName()).append('/').append(zoom). append('/').append(x).
|
builder.append(map.getName()).append('/').append(zoom). append('/').append(x).
|
||||||
append('/').append(y).append(map.getTileFormat()).append(".tile");
|
append('/').append(y).append(map.getTileFormat()).append(".tile");
|
||||||
String file = builder.toString();
|
String file = builder.toString();
|
||||||
|
if(deleteBefore){
|
||||||
|
cacheOfImages.remove(file);
|
||||||
|
File f = new File(dirWithTiles, file);
|
||||||
|
if(f.exists()){
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (loadFromFs && cacheOfImages.get(file) == null) {
|
if (loadFromFs && cacheOfImages.get(file) == null) {
|
||||||
String url = loadFromInternetIfNeeded ? map.getUrlToLoad(x, y, zoom) : null;
|
String url = loadFromInternetIfNeeded ? map.getUrlToLoad(x, y, zoom) : null;
|
||||||
TileLoadDownloadRequest req = new TileLoadDownloadRequest(dirWithTiles, file, url, new File(dirWithTiles, file),
|
TileLoadDownloadRequest req = new TileLoadDownloadRequest(dirWithTiles, file, url, new File(dirWithTiles, file),
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.app.AlertDialog.Builder;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.PointF;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
import android.hardware.SensorEventListener;
|
import android.hardware.SensorEventListener;
|
||||||
|
@ -67,6 +68,8 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
private WakeLock wakeLock;
|
private WakeLock wakeLock;
|
||||||
private boolean sensorRegistered = false;
|
private boolean sensorRegistered = false;
|
||||||
|
|
||||||
|
private MenuItem navigateToPointMenu;
|
||||||
|
|
||||||
private boolean isMapLinkedToLocation(){
|
private boolean isMapLinkedToLocation(){
|
||||||
return OsmandSettings.isMapSyncToGpsLocation(this);
|
return OsmandSettings.isMapSyncToGpsLocation(this);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +152,22 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mapView.setOnLongClickListener(new OsmandMapTileView.OnLongClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLongPressEvent(PointF point) {
|
||||||
|
float dx = point.x - mapView.getCenterPointX();
|
||||||
|
float dy = point.y - mapView.getCenterPointY();
|
||||||
|
float fy = mapView.calcDiffTileY(dx, dy);
|
||||||
|
float fx = mapView.calcDiffTileX(dx, dy);
|
||||||
|
double latitude = MapUtils.getLatitudeFromTile(mapView.getZoom(), mapView.getYTile() + fy);
|
||||||
|
double longitude = MapUtils.getLongitudeFromTile(mapView.getZoom(), mapView.getXTile() + fx);
|
||||||
|
contextMenuPoint(latitude, longitude);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,6 +191,10 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
double lon = MapUtils.getLongitudeFromTile(mapView.getZoom(), x);
|
double lon = MapUtils.getLongitudeFromTile(mapView.getZoom(), x);
|
||||||
setMapLocation(lat, lon);
|
setMapLocation(lat, lon);
|
||||||
return true;
|
return true;
|
||||||
|
// that doesn't work for now
|
||||||
|
// } else if(event.getAction() == MotionEvent.ACTION_UP){
|
||||||
|
// contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||||
|
// return true;
|
||||||
}
|
}
|
||||||
return super.onTrackballEvent(event);
|
return super.onTrackballEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -225,13 +248,13 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateToPoint(LatLon point){
|
public void navigateToPoint(LatLon point){
|
||||||
|
|
||||||
if(point != null){
|
if(point != null){
|
||||||
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
|
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
|
||||||
} else {
|
} else {
|
||||||
OsmandSettings.clearPointToNavigate(this);
|
OsmandSettings.clearPointToNavigate(this);
|
||||||
}
|
}
|
||||||
navigationLayer.setPointToNavigate(point);
|
navigationLayer.setPointToNavigate(point);
|
||||||
|
updateNavigateToPointMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLastKnownLocation(){
|
public Location getLastKnownLocation(){
|
||||||
|
@ -373,18 +396,21 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
locationLayer.setHeading(event.values[0]);
|
locationLayer.setHeading(event.values[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateNavigateToPointMenu(){
|
||||||
|
if (navigateToPointMenu != null) {
|
||||||
|
if (OsmandSettings.getPointToNavigate(this) != null) {
|
||||||
|
navigateToPointMenu.setVisible(true);
|
||||||
|
} else {
|
||||||
|
navigateToPointMenu.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.map_menu, menu);
|
inflater.inflate(R.menu.map_menu, menu);
|
||||||
MenuItem item = menu.findItem(R.id.map_navigate_to_point);
|
navigateToPointMenu = menu.findItem(R.id.map_navigate_to_point);
|
||||||
if (item != null) {
|
updateNavigateToPointMenu();
|
||||||
if (OsmandSettings.getPointToNavigate(this) != null) {
|
|
||||||
item.setTitle(R.string.stop_navigation);
|
|
||||||
} else {
|
|
||||||
item.setTitle(R.string.navigate_to_point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +421,10 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
startActivity(settings);
|
startActivity(settings);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.map_mark_point) {
|
} else if (item.getItemId() == R.id.map_mark_point) {
|
||||||
markPoint();
|
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.map_reload_tile) {
|
||||||
|
reloadTile(mapView.getZoom(), mapView.getLatitude(), mapView.getLongitude());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.map_specify_point) {
|
} else if (item.getItemId() == R.id.map_specify_point) {
|
||||||
openChangeLocationDialog();
|
openChangeLocationDialog();
|
||||||
|
@ -410,18 +439,36 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void markPoint(){
|
protected void reloadTile(final int zoom, final double latitude, final double longitude){
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setItems(new String[]{"Navigate to point", "Add to favourites", "Open osm bug"}, new DialogInterface.OnClickListener(){
|
builder.setMessage("Tile image will be removed from file system. Do you want to reload tile from internet?");
|
||||||
|
builder.setNegativeButton("Cancel", null);
|
||||||
|
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
int x = (int) MapUtils.getTileNumberX(zoom, longitude);
|
||||||
|
int y = (int) MapUtils.getTileNumberY(zoom, latitude);
|
||||||
|
ResourceManager.getResourceManager().clearTileImageForMap(mapView.getMap(), x, y, zoom);
|
||||||
|
mapView.refreshMap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void contextMenuPoint(final double latitude, final double longitude){
|
||||||
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setItems(new String[]{"Navigate to point", "Add to favourites", "Update map", "Open osm bug"}, new DialogInterface.OnClickListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if(which == 0){
|
if(which == 0){
|
||||||
navigateToPoint(new LatLon(mapView.getLatitude(), mapView.getLongitude()));
|
navigateToPoint(new LatLon(latitude, longitude));
|
||||||
} else if(which == 1){
|
} else if(which == 1){
|
||||||
addFavouritePoint();
|
addFavouritePoint(latitude, longitude);
|
||||||
} else if(which == 2){
|
} else if(which == 2){
|
||||||
osmBugsLayer.openBug(MapActivity.this, getLayoutInflater(), mapView);
|
reloadTile(mapView.getZoom(), latitude, longitude);
|
||||||
|
} else if(which == 3){
|
||||||
|
osmBugsLayer.openBug(MapActivity.this, getLayoutInflater(), mapView, latitude, longitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -429,10 +476,10 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void addFavouritePoint(){
|
protected void addFavouritePoint(double latitude, double longitude){
|
||||||
final FavouritePoint p = new FavouritesActivity.FavouritePoint();
|
final FavouritePoint p = new FavouritesActivity.FavouritePoint();
|
||||||
p.setLatitude(mapView.getLatitude());
|
p.setLatitude(latitude);
|
||||||
p.setLongitude(mapView.getLongitude());
|
p.setLongitude(longitude);
|
||||||
p.setName("Favourite");
|
p.setName("Favourite");
|
||||||
|
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
|
|
|
@ -113,6 +113,9 @@ public class MapInfoLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cachedMeters = 0;
|
||||||
|
cachedDistString = null;
|
||||||
}
|
}
|
||||||
if(view.getZoom() != cachedZoom){
|
if(view.getZoom() != cachedZoom){
|
||||||
cachedZoom = view.getZoom();
|
cachedZoom = view.getZoom();
|
||||||
|
|
|
@ -338,7 +338,7 @@ public class OsmBugsLayer implements OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void openBug(final Context ctx, LayoutInflater layoutInflater, final OsmandMapTileView mapView){
|
public void openBug(final Context ctx, LayoutInflater layoutInflater, final OsmandMapTileView mapView, final double latitude, final double longitude){
|
||||||
Builder builder = new AlertDialog.Builder(ctx);
|
Builder builder = new AlertDialog.Builder(ctx);
|
||||||
builder.setTitle("Input text of bug");
|
builder.setTitle("Input text of bug");
|
||||||
final View view = layoutInflater.inflate(R.layout.open_bug, null);
|
final View view = layoutInflater.inflate(R.layout.open_bug, null);
|
||||||
|
@ -351,7 +351,7 @@ public class OsmBugsLayer implements OsmandMapLayer {
|
||||||
String text = ((EditText)view.findViewById(R.id.BugMessage)).getText().toString();
|
String text = ((EditText)view.findViewById(R.id.BugMessage)).getText().toString();
|
||||||
String author = ((EditText)view.findViewById(R.id.AuthorName)).getText().toString();
|
String author = ((EditText)view.findViewById(R.id.AuthorName)).getText().toString();
|
||||||
OsmandSettings.setUserName(ctx, author);
|
OsmandSettings.setUserName(ctx, author);
|
||||||
boolean bug = createNewBug(mapView.getLatitude(), mapView.getLongitude(),
|
boolean bug = createNewBug(latitude, longitude,
|
||||||
text, author);
|
text, author);
|
||||||
if (bug) {
|
if (bug) {
|
||||||
Toast.makeText(ctx, "Bug was successfully created", Toast.LENGTH_LONG).show();
|
Toast.makeText(ctx, "Bug was successfully created", Toast.LENGTH_LONG).show();
|
||||||
|
|
|
@ -45,6 +45,13 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
protected final int timeForDraggingAnimation = 300;
|
protected final int timeForDraggingAnimation = 300;
|
||||||
protected final int minimumDistanceForDraggingAnimation = 40;
|
protected final int minimumDistanceForDraggingAnimation = 40;
|
||||||
|
|
||||||
|
public interface OnLongClickListener {
|
||||||
|
public boolean onLongPressEvent(PointF point);
|
||||||
|
}
|
||||||
|
public interface OnClickListener {
|
||||||
|
public boolean onPressEvent(PointF point);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static final Log log = LogUtil.getLog(OsmandMapTileView.class);
|
protected static final Log log = LogUtil.getLog(OsmandMapTileView.class);
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +72,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
private IMapLocationListener locationListener;
|
private IMapLocationListener locationListener;
|
||||||
|
|
||||||
|
private OnLongClickListener onLongClickListener;
|
||||||
|
|
||||||
|
private OnClickListener onClickListener;
|
||||||
|
|
||||||
private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>();
|
private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>();
|
||||||
|
|
||||||
// UI Part
|
// UI Part
|
||||||
|
@ -120,8 +131,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
setClickable(true);
|
setClickable(true);
|
||||||
setLongClickable(true);
|
setLongClickable(true);
|
||||||
setOnLongClickListener(this);
|
super.setOnLongClickListener(this);
|
||||||
setOnClickListener(this);
|
super.setOnClickListener(this);
|
||||||
|
|
||||||
getHolder().addCallback(this);
|
getHolder().addCallback(this);
|
||||||
|
|
||||||
|
@ -620,10 +631,22 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(onLongClickListener != null && onLongClickListener.onLongPressEvent(point)){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnLongClickListener(OnLongClickListener l) {
|
||||||
|
this.onLongClickListener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnClickListener(OnClickListener l) {
|
||||||
|
this.onClickListener = l;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PointF point = startDragging;
|
PointF point = startDragging;
|
||||||
|
@ -637,8 +660,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(onClickListener != null && onClickListener.onPressEvent(point)){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue