diff --git a/build.gradle b/build.gradle
index 3c9c0f3f..1cd61cf7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,7 +33,7 @@ static def androidCompileSdk() { return 29 }
// 14 for Support Library, 16 for sqlite-android
static def androidMinSdk() { return 16 }
-static def androidTargetSdk() { return 22 }
+static def androidTargetSdk() { return 29 }
static def versionCode() { return 1 }
diff --git a/gradle.properties b/gradle.properties
index 743d692c..9592636c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -11,3 +11,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml
index bbc07a7e..03c0762c 100644
--- a/vtm-android-example/AndroidManifest.xml
+++ b/vtm-android-example/AndroidManifest.xml
@@ -7,7 +7,6 @@
-
0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
+ enableAvailableProviders();
+ }
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
enableAvailableProviders();
}
@Override
- protected void onPause() {
- super.onPause();
-
+ public void onStop() {
locationManager.removeUpdates(this);
+
+ super.onStop();
}
@Override
@@ -78,6 +88,13 @@ public class LocationActivity extends BitmapTileActivity implements LocationList
}
private void enableAvailableProviders() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
+ return;
+ }
+ }
+
locationManager.removeUpdates(this);
for (String provider : locationManager.getProviders(true)) {
diff --git a/vtm-android-example/src/org/oscim/android/test/LocationTextureActivity.java b/vtm-android-example/src/org/oscim/android/test/LocationTextureActivity.java
index 596b17d4..2377bad0 100644
--- a/vtm-android-example/src/org/oscim/android/test/LocationTextureActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/LocationTextureActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2018 devemux86
+ * Copyright 2016-2019 devemux86
* Copyright 2018 Longri
*
* This program is free software: you can redistribute it and/or modify it under the
@@ -15,12 +15,14 @@
*/
package org.oscim.android.test;
+import android.Manifest;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
+import android.os.Build;
import android.os.Bundle;
-
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Color;
@@ -78,17 +80,25 @@ public class LocationTextureActivity extends BitmapTileActivity implements Locat
}
@Override
- protected void onResume() {
- super.onResume();
+ public void onRequestPermissionsResult(final int requestCode, final String[] permissions, final int[] grantResults) {
+ if (requestCode == 0) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
+ enableAvailableProviders();
+ }
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
enableAvailableProviders();
}
@Override
- protected void onPause() {
- super.onPause();
-
+ public void onStop() {
locationManager.removeUpdates(this);
+
+ super.onStop();
}
@Override
@@ -115,6 +125,13 @@ public class LocationTextureActivity extends BitmapTileActivity implements Locat
}
private void enableAvailableProviders() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
+ return;
+ }
+ }
+
locationManager.removeUpdates(this);
for (String provider : locationManager.getProviders(true)) {
diff --git a/vtm-app/AndroidManifest.xml b/vtm-app/AndroidManifest.xml
index 3881a03f..26186026 100644
--- a/vtm-app/AndroidManifest.xml
+++ b/vtm-app/AndroidManifest.xml
@@ -9,7 +9,6 @@
-
= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
+ requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
+ }
+
setContentView(R.layout.activity_tilemap);
App.view = (MapView) findViewById(R.id.mapView);
registerMapView(App.view);
diff --git a/vtm-app/src/org/oscim/app/filepicker/FilePicker.java b/vtm-app/src/org/oscim/app/filepicker/FilePicker.java
index 77c31a3a..57799b90 100755
--- a/vtm-app/src/org/oscim/app/filepicker/FilePicker.java
+++ b/vtm-app/src/org/oscim/app/filepicker/FilePicker.java
@@ -1,6 +1,6 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
- * Copyright 2016 devemux86
+ * Copyright 2016-2019 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -24,11 +24,9 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.os.Bundle;
-import android.os.Environment;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
-
import org.oscim.app.R;
import org.oscim.app.filefilter.ValidFileFilter;
@@ -62,7 +60,6 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
public static final String SELECTED_FILE = "selectedFile";
private static final String CURRENT_DIRECTORY = "currentDirectory";
- private static final String DEFAULT_DIRECTORY = Environment.getExternalStorageDirectory().getAbsolutePath();
private static final int DIALOG_FILE_INVALID = 0;
// private static final int DIALOG_FILE_SELECT = 1;
private static Comparator fileComparator = getDefaultFileComparator();
@@ -125,6 +122,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
}
private File currentDirectory;
+ private String defaultDirectory;
private FilePickerIconAdapter filePickerIconAdapter;
private File[] files;
private File[] filesWithParentFolder;
@@ -166,7 +164,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
}
// if a parent directory exists, add it at the first position
- if (this.currentDirectory.getParentFile() != null) {
+ if (this.currentDirectory.getParentFile() != null && this.currentDirectory.getParentFile().canRead()) {
this.filesWithParentFolder = new File[this.files.length + 1];
this.filesWithParentFolder[0] = this.currentDirectory.getParentFile();
System.arraycopy(this.files, 0, this.filesWithParentFolder, 1,
@@ -184,6 +182,7 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_picker);
+ defaultDirectory = getExternalFilesDir(null) != null ? getExternalFilesDir(null).getAbsolutePath() : "/sdcard/";
this.filePickerIconAdapter = new FilePickerIconAdapter(this);
GridView gridView = (GridView) findViewById(R.id.filePickerView);
gridView.setOnItemClickListener(this);
@@ -254,10 +253,9 @@ public class FilePicker extends Activity implements AdapterView.OnItemClickListe
// restore the current directory
SharedPreferences preferences = getSharedPreferences(PREFERENCES_FILE,
MODE_PRIVATE);
- this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY,
- DEFAULT_DIRECTORY));
+ this.currentDirectory = new File(preferences.getString(CURRENT_DIRECTORY, defaultDirectory));
if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) {
- this.currentDirectory = new File(DEFAULT_DIRECTORY);
+ this.currentDirectory = new File(defaultDirectory);
}
browseToCurrentDirectory();
}