Skip to content

Commit

Permalink
android/permission: Add prominent disclosure for location permission
Browse files Browse the repository at this point in the history
Google Play Store have a requirement for permission android.permission.ACCESS_BACKGROUND_LOCATION which needs to in-app disclosure to explain why we need it
https://support.google.com/googleplay/android-developer/answer/9799150
  • Loading branch information
zinuzoid committed Nov 22, 2021
1 parent e8d9ca0 commit 29b0923
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Version 7.21 - not yet released
- Support for AF/AR frequency fields in OpenAir
* devices
- fix inverted cruise/circling mode in borgelt and xcvario driver
* Android
- re-enable background location and comply with Google Play Store policy

Version 7.20 - 2021/10/22
* map
Expand Down
21 changes: 16 additions & 5 deletions android/src/XCSoar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ of the License, or (at your option) any later version.

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.KeyEvent;
Expand Down Expand Up @@ -270,11 +272,20 @@ private void requestAllPermissions() {
is not enough */

if (!hasAllPermissions()) {
try {
this.requestPermissions(NEEDED_PERMISSIONS, 0);
} catch (IllegalArgumentException e) {
Log.e(TAG, "could not request permissions: " + String.join(", ", NEEDED_PERMISSIONS), e);
}
new AlertDialog.Builder(this)
.setTitle("Location Permission")
.setMessage("XCSoar needs to collect location data to enable live navigation calculation and IGC logger, even when the app is in the background")
.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
XCSoar.this.requestPermissions(NEEDED_PERMISSIONS, 0);
} catch (IllegalArgumentException e) {
Log.e(TAG, "could not request permissions: " + String.join(", ", NEEDED_PERMISSIONS), e);
}
}
})
.show();
}
}

Expand Down

0 comments on commit 29b0923

Please sign in to comment.