[Sample] added my location button

This commit is contained in:
Alexey Kulish 2016-11-22 18:48:36 +03:00
parent 5324bc399a
commit bb1a230262
23 changed files with 370 additions and 64 deletions

View file

@ -2,7 +2,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.osmand.core.samples.android.sample1" >
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap android:src="@drawable/map_bt_round_2_shadow" android:gravity="fill" />
</item>
<item>
<inset
android:insetBottom="@dimen/map_button_inset"
android:insetLeft="@dimen/map_button_inset"
android:insetRight="@dimen/map_button_inset"
android:insetTop="@dimen/map_button_inset" >
<shape android:shape="oval" >
<solid android:color="@color/map_widget_dark_pressed" />
</shape>
</inset>
</item>
</layer-list>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_inset_circle_p" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_inset_circle_trans_n"></item>
</selector>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap android:src="@drawable/map_bt_round_2_shadow" android:gravity="fill" />
</item>
<item>
<inset
android:insetBottom="@dimen/map_button_inset"
android:insetLeft="@dimen/map_button_inset"
android:insetRight="@dimen/map_button_inset"
android:insetTop="@dimen/map_button_inset" >
<shape android:shape="oval" >
<solid android:color="@color/map_widget_light_trans" />
</shape>
</inset>
</item>
</layer-list>

View file

@ -22,16 +22,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp">
android:layout_marginRight="@dimen/map_button_margin"
android:layout_marginTop="@dimen/map_button_margin">
<ImageButton
android:id="@+id/map_azimuth_north_button"
android:layout_width="52dp"
android:layout_height="52dp"
android:background="@drawable/btn_circle"
android:contentDescription="@string/azimuthNorth"
android:src="@drawable/map_compass_niu"/>
android:id="@+id/map_compass_button"
android:layout_width="@dimen/map_small_button_size"
android:layout_height="@dimen/map_small_button_size"
android:background="@drawable/btn_inset_circle_trans"
android:src="@drawable/map_compass"
android:visibility="gone"/>
</FrameLayout>
@ -39,14 +39,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp">
android:layout_marginLeft="@dimen/map_button_margin"
android:layout_marginTop="@dimen/map_button_margin">
<ImageButton
android:id="@+id/search_button"
android:layout_width="52dp"
android:layout_height="52dp"
android:background="@drawable/btn_circle"
android:layout_width="@dimen/map_small_button_size"
android:layout_height="@dimen/map_small_button_size"
android:background="@drawable/btn_inset_circle_trans"
android:contentDescription="@string/shared_string_search"
android:src="@drawable/map_search_dark"/>
@ -56,13 +56,24 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp">
android:layout_marginBottom="@dimen/map_button_margin"
android:layout_marginRight="@dimen/map_button_margin">
<ImageButton
android:id="@+id/map_my_location_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:layout_gravity="bottom"
android:layout_marginRight="@dimen/map_button_size_plus_spacing"
android:background="@drawable/btn_circle"
android:contentDescription="@string/shared_string_my_location"
android:src="@drawable/map_my_location"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:layout_gravity="bottom|right">
<TextView
android:id="@+id/text_zoom"
@ -76,18 +87,18 @@
<ImageButton
android:id="@+id/map_zoom_in_button"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginTop="10dp"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:layout_marginTop="@dimen/map_button_spacing"
android:background="@drawable/btn_circle"
android:contentDescription="@string/zoomIn"
android:src="@drawable/map_zoom_in"/>
<ImageButton
android:id="@+id/map_zoom_out_button"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginTop="10dp"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:layout_marginTop="@dimen/map_button_spacing"
android:background="@drawable/btn_circle"
android:contentDescription="@string/zoomOut"
android:src="@drawable/map_zoom_out"/>

View file

@ -63,6 +63,7 @@
<dimen name="map_address_height">40dp</dimen>
<dimen name="map_button_size">52dp</dimen>
<dimen name="map_button_size_plus_spacing">63dp</dimen>
<dimen name="map_small_button_size">44dp</dimen>
<dimen name="map_small_button_margin">5dp</dimen>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="compass">Compass</string>
<string name="shared_string_my_location">My location</string>
<string name="shared_string_search">Search</string>
<string name="yard">yd</string>
<string name="foot">ft</string>
@ -38,7 +40,6 @@
<string name="title_activity_main">OsmAnd Core Sample 1</string>
<string name="zoomIn">Zoom in</string>
<string name="zoomOut">Zoom out</string>
<string name="azimuthNorth">Azimuth to North</string>
<string name="search_hint">Type and Search</string>
<string name="shared_string_close">Close</string>
</resources>

View file

@ -6,6 +6,8 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -25,10 +27,12 @@ import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import net.osmand.Location;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.core.android.AtlasMapRendererView;
import net.osmand.core.jni.AmenitySymbolsProvider.AmenitySymbolsGroup;
import net.osmand.core.jni.AreaI;
import net.osmand.core.jni.FColorRGB;
import net.osmand.core.jni.IBillboardMapSymbol;
import net.osmand.core.jni.IMapLayerProvider;
import net.osmand.core.jni.IMapRenderer.MapSymbolInformation;
@ -57,6 +61,8 @@ import net.osmand.core.jni.ResolvedMapStyle;
import net.osmand.core.jni.SwigUtilities;
import net.osmand.core.jni.Utilities;
import net.osmand.core.samples.android.sample1.MultiTouchSupport.MultiTouchZoomListener;
import net.osmand.core.samples.android.sample1.SampleLocationProvider.SampleCompassListener;
import net.osmand.core.samples.android.sample1.SampleLocationProvider.SampleLocationListener;
import net.osmand.core.samples.android.sample1.data.PointDescription;
import net.osmand.core.samples.android.sample1.mapcontextmenu.MapContextMenu;
import net.osmand.core.samples.android.sample1.mapcontextmenu.MenuController;
@ -73,7 +79,11 @@ import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
import static net.osmand.core.samples.android.sample1.SampleApplication.PERMISSION_REQUEST_LOCATION_ON_BUTTON;
import static net.osmand.core.samples.android.sample1.SampleApplication.PERMISSION_REQUEST_LOCATION_ON_RESUME;
import static net.osmand.core.samples.android.sample1.SampleApplication.PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE;
public class MainActivity extends AppCompatActivity implements SampleLocationListener, SampleCompassListener {
private static final String TAG = "OsmAndCoreSample";
private float displayDensityFactor;
@ -93,12 +103,13 @@ public class MainActivity extends AppCompatActivity {
private AtlasMapRendererView mapView;
private TextView textZoom;
private ImageButton searchButton;
private ImageButton azimuthNorthButton;
private ImageButton compassButton;
private CompassDrawable compassDrawable;
private GestureDetector gestureDetector;
private PointI target31;
private float zoom;
private float azimuth;
private float azimuth = 0;
private float elevationAngle;
private MultiTouchSupport multiTouchSupport;
@ -107,11 +118,12 @@ public class MainActivity extends AppCompatActivity {
// Context pin marker
private MapMarkersCollection contextPinMarkersCollection;
private MapMarker contextPinMarker;
private static final int CONTEXT_MARKER_ID = 1;
private static final int MARKER_ID_CONTEXT_PIN = 1;
// "My location" marker, "My course" marker and collection
private MapMarkersCollection myMarkersCollection;
private MapMarker myLocationMarker;
private static final int MARKER_ID_MY_LOCATION = 2;
// Germany
private final static float INIT_LAT = 49.353953f;
@ -136,14 +148,22 @@ public class MainActivity extends AppCompatActivity {
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == SampleApplication.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (!InstallOsmandAppDialog.wasShown()) {
checkMapsInstalled();
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
switch (requestCode) {
case PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE:
if (!InstallOsmandAppDialog.wasShown()) {
checkMapsInstalled();
}
getMyApplication().initPoiTypes();
break;
case PERMISSION_REQUEST_LOCATION_ON_BUTTON:
goToLocation();
case PERMISSION_REQUEST_LOCATION_ON_RESUME:
getMyApplication().getLocationProvider().resumeAllUpdates();
break;
}
getSampleApplication().initPoiTypes();
}
}
@ -151,7 +171,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SampleApplication app = getSampleApplication();
SampleApplication app = getMyApplication();
gestureDetector = new GestureDetector(this, new MapViewOnGestureListener());
multiTouchSupport = new MultiTouchSupport(this, new MapViewMultiTouchZoomListener());
@ -164,7 +184,7 @@ public class MainActivity extends AppCompatActivity {
if (!externalStoragePermissionGranted) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
SampleApplication.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
}
// Get map view
@ -180,14 +200,32 @@ public class MainActivity extends AppCompatActivity {
}
});
azimuthNorthButton = (ImageButton) findViewById(R.id.map_azimuth_north_button);
azimuthNorthButton.setOnClickListener(new View.OnClickListener() {
compassButton = (ImageButton) findViewById(R.id.map_compass_button);
compassButton.setContentDescription(app.getString("rotate_map_compass_opt"));
compassDrawable = new CompassDrawable(app.getIconsCache().getIcon(R.drawable.map_compass));
compassButton.setImageDrawable(compassDrawable);
compassButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setAzimuth(0f);
}
});
ImageButton myLocationButton = (ImageButton) findViewById(R.id.map_my_location_button);
myLocationButton.setImageDrawable(app.getIconsCache().getIcon("map_my_location", R.color.color_myloc_distance));
myLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SampleLocationProvider.isLocationPermissionAvailable(MainActivity.this)) {
goToLocation();
} else {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSION_REQUEST_LOCATION_ON_BUTTON);
}
}
});
findViewById(R.id.map_zoom_in_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -271,7 +309,7 @@ public class MainActivity extends AppCompatActivity {
}
private void checkMapsInstalled() {
File mapsDir = new File(getSampleApplication().getAbsoluteAppPath());
File mapsDir = new File(getMyApplication().getAbsoluteAppPath());
boolean noMapsFound;
if (mapsDir.exists()) {
File[] maps = mapsDir.listFiles(new FilenameFilter() {
@ -301,11 +339,31 @@ public class MainActivity extends AppCompatActivity {
}
public void initMapMarkers() {
// Create my location marker
Drawable myLocationDrawable = OsmandResources.getDrawable("map_pedestrian_location");
myMarkersCollection = new MapMarkersCollection();
myLocationMarker = new MapMarkerBuilder()
.setMarkerId(MARKER_ID_MY_LOCATION)
.setIsAccuracyCircleSupported(true)
.setAccuracyCircleBaseColor(new FColorRGB(32/255f, 173/255f, 229/255f))
.setBaseOrder(-206000)
.setIsHidden(true)
//.addOnMapSurfaceIcon(SwigUtilities.getOnSurfaceIconKey(0), SwigUtilities.createSkBitmapARGB888With(
// myLocationDrawable.getIntrinsicWidth(), myLocationDrawable.getIntrinsicHeight(),
// SampleUtils.getDrawableAsByteArray(myLocationDrawable)))
.setPinIcon(SwigUtilities.createSkBitmapARGB888With(
myLocationDrawable.getIntrinsicWidth(), myLocationDrawable.getIntrinsicHeight(),
SampleUtils.getDrawableAsByteArray(myLocationDrawable)))
.buildAndAddToCollection(myMarkersCollection);
mapView.addSymbolsProvider(myMarkersCollection);
// Create context pin marker
Drawable pinDrawable = OsmandResources.getDrawable("map_pin_context_menu");
contextPinMarkersCollection = new MapMarkersCollection();
contextPinMarker = new MapMarkerBuilder()
.setMarkerId(CONTEXT_MARKER_ID)
.setMarkerId(MARKER_ID_CONTEXT_PIN)
.setIsAccuracyCircleSupported(false)
.setBaseOrder(-210000)
.setIsHidden(true)
@ -314,7 +372,7 @@ public class MainActivity extends AppCompatActivity {
SampleUtils.getDrawableAsByteArray(pinDrawable)))
.setPinIconVerticalAlignment(MapMarker.PinIconVerticalAlignment.Top)
.setPinIconHorisontalAlignment(MapMarker.PinIconHorisontalAlignment.CenterHorizontal)
.buildAndAddToCollection(contextPinMarkersCollection);
.buildAndAddToCollection(contextPinMarkersCollection);
mapView.addSymbolsProvider(contextPinMarkersCollection);
}
@ -333,14 +391,89 @@ public class MainActivity extends AppCompatActivity {
mapView.resumeSymbolsUpdate();
}
public void goToLocation() {
if (mapView != null) {
SampleLocationProvider locationProvider = getMyApplication().getLocationProvider();
if (locationProvider.getLastKnownLocation() != null) {
net.osmand.Location lastKnownLocation = locationProvider.getLastKnownLocation();
int fZoom = zoom < 15 ? 15 : (int)zoom;
showOnMap(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom);
//todo animation
//AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
//thread.startMoving(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom, false);
}
if (locationProvider.getLastKnownLocation() == null) {
getMyApplication().showToastMessage(getMyApplication().getString("unknown_location"));
}
}
}
@Override
public void updateLocation(Location location) {
final SampleApplication app = getMyApplication();
final Location lastKnownLocation = app.getLocationProvider().getLastKnownLocation();
if (lastKnownLocation == null || mapView == null){
app.runInUIThread(new Runnable() {
@Override
public void run() {
if (!myLocationMarker.isHidden()) {
mapView.suspendSymbolsUpdate();
myLocationMarker.setIsHidden(true);
mapView.resumeSymbolsUpdate();
}
}
});
return;
}
final PointI target31 = Utilities.convertLatLonTo31(
new net.osmand.core.jni.LatLon(location.getLatitude(), location.getLongitude()));
app.runInUIThread(new Runnable() {
@Override
public void run() {
mapView.suspendSymbolsUpdate();
myLocationMarker.setIsHidden(false);
myLocationMarker.setPosition(target31);
myLocationMarker.setIsAccuracyCircleVisible(true);
myLocationMarker.setAccuracyCircleRadius(lastKnownLocation.getAccuracy());
mapView.resumeSymbolsUpdate();
}
});
if (menu != null) {
menu.updateMyLocation(location);
}
}
@Override
public void updateCompassValue(float value) {
if (menu != null) {
menu.updateCompassValue(value);
}
}
@Override
protected void onResume() {
super.onResume();
SampleApplication app = getMyApplication();
app.getLocationProvider().checkIfLastKnownLocationIsValid();
app.getLocationProvider().addLocationListener(this);
if (SampleLocationProvider.isLocationPermissionAvailable(this)) {
app.getLocationProvider().resumeAllUpdates();
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSION_REQUEST_LOCATION_ON_RESUME);
}
mapView.handleOnResume();
}
@Override
protected void onPause() {
SampleApplication app = getMyApplication();
app.getLocationProvider().pauseAllUpdates();
app.getLocationProvider().removeLocationListener(this);
saveMapState();
mapView.handleOnPause();
super.onPause();
@ -352,25 +485,24 @@ public class MainActivity extends AppCompatActivity {
super.onDestroy();
}
public SampleApplication getSampleApplication() {
return (SampleApplication) getApplication();
}
public AtlasMapRendererView getMapView() {
return mapView;
}
public void showOnMap(LatLon latLon, int zoom) {
if (latLon != null) {
PointI target = Utilities.convertLatLonTo31(
new net.osmand.core.jni.LatLon(latLon.getLatitude(), latLon.getLongitude()));
setTarget(target);
setZoom(zoom);
showOnMap(latLon.getLatitude(), latLon.getLongitude(), zoom);
}
}
public void showOnMap(double latitude, double longitude, int zoom) {
PointI target = Utilities.convertLatLonTo31(
new net.osmand.core.jni.LatLon(latitude, longitude));
setTarget(target);
setZoom(zoom);
}
public void refreshMap() {
//todo
}
public MapContextMenu getContextMenu() {
@ -473,13 +605,16 @@ public class MainActivity extends AppCompatActivity {
public void setAzimuth(float angle) {
angle = MapUtils.unifyRotationTo360(angle);
this.azimuth = angle;
azimuth = angle;
mapView.setAzimuth(angle);
if (angle == 0f && azimuthNorthButton.getVisibility() == View.VISIBLE) {
azimuthNorthButton.setVisibility(View.INVISIBLE);
} else if (angle != 0f && azimuthNorthButton.getVisibility() == View.INVISIBLE) {
azimuthNorthButton.setVisibility(View.VISIBLE);
if (angle == 0f && compassButton.getVisibility() == View.VISIBLE) {
compassButton.setVisibility(View.INVISIBLE);
} else if (angle != 0f) {
if (compassButton.getVisibility() != View.VISIBLE) {
compassButton.setVisibility(View.VISIBLE);
}
compassButton.invalidate();
}
}
@ -552,9 +687,17 @@ public class MainActivity extends AppCompatActivity {
} catch (Exception eMapMarker) {
mapMarker = null;
}
if (mapMarker != null && mapMarker.getMarkerId() == CONTEXT_MARKER_ID) {
hideMultiContextMenu();
menu.show();
if (mapMarker != null) {
if (mapMarker.getMarkerId() == MARKER_ID_CONTEXT_PIN) {
hideMultiContextMenu();
menu.show();
} else if (mapMarker.getMarkerId() == MARKER_ID_MY_LOCATION) {
hideMultiContextMenu();
LatLon latLon = new LatLon(lat, lon);
showContextMenu(latLon, new PointDescription(
PointDescription.POINT_TYPE_MY_LOCATION,
getMyApplication().getString("shared_string_my_location"), ""), latLon);
}
return true;
} else {
net.osmand.core.jni.Amenity amenity;
@ -850,4 +993,68 @@ public class MainActivity extends AppCompatActivity {
NEW_IF_EXPIRED,
CURRENT,
}
private class CompassDrawable extends Drawable {
private Drawable original;
public CompassDrawable(Drawable original) {
this.original = original;
}
@Override
public void draw(@NonNull Canvas canvas) {
canvas.save();
canvas.rotate(azimuth, getIntrinsicWidth() / 2, getIntrinsicHeight() / 2);
original.draw(canvas);
canvas.restore();
}
@Override
public int getMinimumHeight() {
return original.getMinimumHeight();
}
@Override
public int getMinimumWidth() {
return original.getMinimumWidth();
}
@Override
public int getIntrinsicHeight() {
return original.getIntrinsicHeight();
}
@Override
public int getIntrinsicWidth() {
return original.getIntrinsicWidth();
}
@Override
public void setChangingConfigurations(int configs) {
super.setChangingConfigurations(configs);
original.setChangingConfigurations(configs);
}
@Override
public void setBounds(int left, int top, int right, int bottom) {
super.setBounds(left, top, right, bottom);
original.setBounds(left, top, right, bottom);
}
@Override
public void setAlpha(int alpha) {
original.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter cf) {
original.setColorFilter(cf);
}
@Override
public int getOpacity() {
return original.getOpacity();
}
}
}

View file

@ -10,6 +10,7 @@ import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
import net.osmand.core.android.CoreResourcesFromAndroidAssets;
import net.osmand.core.android.NativeCore;
@ -33,7 +34,9 @@ import java.util.Locale;
import static net.osmand.core.samples.android.sample1.data.PointDescription.FORMAT_DEGREES;
public class SampleApplication extends Application {
public static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 5 ;
public static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 5 ;
public static final int PERMISSION_REQUEST_LOCATION_ON_RESUME = 6 ;
public static final int PERMISSION_REQUEST_LOCATION_ON_BUTTON = 7 ;
private CoreResourcesFromAndroidAssets assetsCustom;
private MapPoiTypes poiTypes;
private IconsCache iconsCache;
@ -297,4 +300,40 @@ public class SampleApplication extends Application {
}
return getFilesDir();
}
public void showShortToastMessage(final int msgId, final Object... args) {
uiHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(SampleApplication.this, getString(msgId, args), Toast.LENGTH_SHORT).show();
}
});
}
public void showShortToastMessage(final String msg) {
uiHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(SampleApplication.this, msg, Toast.LENGTH_SHORT).show();
}
});
}
public void showToastMessage(final int msgId, final Object... args) {
uiHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(SampleApplication.this, getString(msgId, args), Toast.LENGTH_LONG).show();
}
});
}
public void showToastMessage(final String msg) {
uiHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(SampleApplication.this, msg, Toast.LENGTH_LONG).show();
}
});
}
}

View file

@ -393,7 +393,7 @@ public class MapContextMenuFragment extends Fragment {
}
}
int newMenuState = menu.getCurrentMenuState();
boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
boolean needMapAdjust = false;//oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
if (newMenuState != oldMenuState) {
doBeforeMenuStateChange(oldMenuState, newMenuState);

View file

@ -25,11 +25,6 @@ public class MyLocationMenuController extends MenuController {
return getLatLon();
}
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
}
@Override
public String getTypeStr() {
return getPointDescription().getTypeName();