Upgrade to 1.6 and show poi information on long press

This commit is contained in:
Victor Shcherb 2012-01-25 00:57:49 +01:00
parent 428ff147d6
commit ea50c82122
3 changed files with 21 additions and 14 deletions

View file

@ -7,7 +7,7 @@
<!-- comment change build properties for release & set targetSdkVersion="7", build and reverse changes-->
<!-- <uses-sdk android:minSdkVersion="3"/> -->
<!-- uncomment it to allow different screen supports (large/small)-->
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4"/>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true" android:name="net.osmand.plus.activities.OsmandApplication" android:description="@string/app_description"

View file

@ -921,7 +921,8 @@ public class MapActivity extends TrackedActivity implements IMapLocationListener
if (keyCode == KeyEvent.KEYCODE_BACK) {
//some application/hardware needs that back button reacts on key up, so
//that they could do some key combinations with it...
onBackPressed();
// Android 1.6 doesn't have onBack method!
finish();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());

View file

@ -102,23 +102,29 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
if (i > 0) {
res.append("\n\n");
}
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(), view.getSettings().USE_ENGLISH_NAMES.get());
res.append(" " + format);
if (n.getOpeningHours() != null) {
res.append("\n").append(view.getContext().getString(R.string.opening_hours)).append(" : ").append(n.getOpeningHours()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (n.getPhone() != null) {
res.append("\n").append(view.getContext().getString(R.string.phone)).append(" : ").append(n.getPhone()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (n.getSite() != null && n.getType() != AmenityType.OSMWIKI) {
res.append("\n").append(view.getContext().getString(R.string.website)).append(" : ").append(n.getSite()); //$NON-NLS-1$ //$NON-NLS-2$
}
buildPoiInformation(res, n);
}
Toast.makeText(view.getContext(), res.toString(), Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
private StringBuilder buildPoiInformation(StringBuilder res, Amenity n) {
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(), view.getSettings().USE_ENGLISH_NAMES.get());
res.append(" " + format);
if (n.getOpeningHours() != null) {
res.append("\n").append(view.getContext().getString(R.string.opening_hours)).append(" : ").append(n.getOpeningHours()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (n.getPhone() != null) {
res.append("\n").append(view.getContext().getString(R.string.phone)).append(" : ").append(n.getPhone()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (n.getSite() != null && n.getType() != AmenityType.OSMWIKI) {
res.append("\n").append(view.getContext().getString(R.string.website)).append(" : ").append(n.getSite()); //$NON-NLS-1$ //$NON-NLS-2$
}
return res;
}
@Override
@ -359,7 +365,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public String getObjectDescription(Object o) {
if(o instanceof Amenity){
return OsmAndFormatter.getPoiSimpleFormat((Amenity) o, view.getContext(), view.getSettings().USE_ENGLISH_NAMES.get());
return buildPoiInformation(new StringBuilder(), (Amenity) o).toString();
}
return null;
}