Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a8d3f9c19d
2 changed files with 36 additions and 7 deletions
|
@ -1,13 +1,17 @@
|
||||||
package net.osmand.core.samples.android.sample1;
|
package net.osmand.core.samples.android.sample1;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.view.ViewPropertyAnimatorListener;
|
import android.support.v4.view.ViewPropertyAnimatorListener;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -137,6 +141,15 @@ public class MainActivity extends Activity {
|
||||||
LANGUAGE = langCode;
|
LANGUAGE = langCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
if(requestCode == SampleApplication.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE &&
|
||||||
|
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
getSampleApplication().initPoiTypes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -149,6 +162,13 @@ public class MainActivity extends Activity {
|
||||||
// Inflate views
|
// Inflate views
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
if(ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
ActivityCompat.requestPermissions(this,
|
||||||
|
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||||
|
SampleApplication.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
||||||
|
}
|
||||||
|
|
||||||
// Get map view
|
// Get map view
|
||||||
mapView = (AtlasMapRendererView) findViewById(R.id.mapRendererView);
|
mapView = (AtlasMapRendererView) findViewById(R.id.mapRendererView);
|
||||||
|
|
||||||
|
@ -643,8 +663,8 @@ public class MainActivity extends Activity {
|
||||||
public void onLongPress(MotionEvent e) {
|
public void onLongPress(MotionEvent e) {
|
||||||
PointI point31 = new PointI();
|
PointI point31 = new PointI();
|
||||||
mapView.getLocationFromScreenPoint(new PointI((int) e.getX(), (int) e.getY()), point31);
|
mapView.getLocationFromScreenPoint(new PointI((int) e.getX(), (int) e.getY()), point31);
|
||||||
geocode(point31);
|
// geocode(point31);
|
||||||
Toast.makeText(MainActivity.this, "Geocoding...", Toast.LENGTH_SHORT).show();
|
//Toast.makeText(MainActivity.this, "Geocoding...", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package net.osmand.core.samples.android.sample1;
|
package net.osmand.core.samples.android.sample1;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.core.android.CoreResourcesFromAndroidAssets;
|
import net.osmand.core.android.CoreResourcesFromAndroidAssets;
|
||||||
import net.osmand.core.android.NativeCore;
|
import net.osmand.core.android.NativeCore;
|
||||||
|
@ -15,8 +19,8 @@ import net.osmand.osm.MapPoiTypes;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class SampleApplication extends Application
|
public class SampleApplication extends Application {
|
||||||
{
|
public static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 5 ;
|
||||||
private CoreResourcesFromAndroidAssets assetsCustom;
|
private CoreResourcesFromAndroidAssets assetsCustom;
|
||||||
private MapPoiTypes poiTypes;
|
private MapPoiTypes poiTypes;
|
||||||
private IconsCache iconsCache;
|
private IconsCache iconsCache;
|
||||||
|
@ -27,8 +31,13 @@ public class SampleApplication extends Application
|
||||||
{
|
{
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
uiHandler = new Handler();
|
uiHandler = new Handler();
|
||||||
|
poiTypes = MapPoiTypes.getDefaultNoInit();
|
||||||
|
if(ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
|
== PackageManager.PERMISSION_GRANTED) {
|
||||||
initPoiTypes();
|
initPoiTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize native core
|
// Initialize native core
|
||||||
if (NativeCore.isAvailable() && !NativeCore.isLoaded()) {
|
if (NativeCore.isAvailable() && !NativeCore.isLoaded()) {
|
||||||
|
@ -48,8 +57,8 @@ public class SampleApplication extends Application
|
||||||
return iconsCache;
|
return iconsCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPoiTypes() {
|
public void initPoiTypes() {
|
||||||
poiTypes = MapPoiTypes.getDefaultNoInit();
|
|
||||||
poiTypes.init(Environment.getExternalStorageDirectory() + "/osmand/poi_types.xml");
|
poiTypes.init(Environment.getExternalStorageDirectory() + "/osmand/poi_types.xml");
|
||||||
poiTypes.setPoiTranslator(new MapPoiTypes.PoiTranslator() {
|
poiTypes.setPoiTranslator(new MapPoiTypes.PoiTranslator() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue