Skip to content

Commit

Permalink
Fixed issue with selecting map file on Android 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
biylda committed Mar 22, 2017
1 parent c923468 commit 748a37f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export ANDROID_HOME=/path/to/android-sdk
<ul>
<li>Input can now be scanned from QR code</li>
<li>Map can be centered to target.</li>
<li>Fixed issue with selecting map file on Android 7.</li>
<li>Improved French translation.</li>
</ul>
</p>
Expand Down
1 change: 1 addition & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
Expand Down
1 change: 1 addition & 0 deletions src/main/assets/news.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<update name="0.9.2" id="43" time="22.3.2017">
<li>Input can now be scanned from QR code.</li>
<li>Map can be centered to target.</li>
<li>Fixed issue with selecting map file on Android 7.</li>
<li>Improved French translation.</li>
</update>
<update name="0.9.1" id="42" time="20.3.2017">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
package menion.android.whereyougo.gui.activity;

import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
Expand Down Expand Up @@ -335,10 +337,12 @@ private boolean isAnyCartridgeAvailable() {
}
}

@TargetApi(Build.VERSION_CODES.M)
private void checkPermissions() {
final String[] permissions = new String[] {
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
};

Expand All @@ -362,7 +366,9 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

checkPermissions();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkPermissions();
}

if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
Intent intent = new Intent(getIntent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.WindowManager;
Expand Down Expand Up @@ -237,6 +238,9 @@ protected void onResume() {
if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) {
this.currentDirectory = new File(DEFAULT_DIRECTORY);
}
if (!this.currentDirectory.exists() || !this.currentDirectory.canRead()) {
this.currentDirectory = Environment.getExternalStorageDirectory();
}
browseToCurrentDirectory();
}
}

0 comments on commit 748a37f

Please sign in to comment.