Skip to content

Commit

Permalink
fix missing consent migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrya committed Mar 23, 2021
1 parent b3055ba commit 4aaf5a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {
minSdkVersion(14)
targetSdkVersion(30)
versionCode = 39
versionName = "2.2.8"
versionName = "2.2.9-alpha"
}
signingConfigs {
register("release") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ protected EnsureLocationPermission(MainActivity activity, Queue<HandlerFactory>
@Override
protected void doInitialize() {
if (activity.isLocationServiceNeeded()
&& ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
HyperLog.i(TAG, "Location permission not yet granted, asking user ...");
&& (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED
// for migration of pre-2.2.2 app versions, the consent needs to be confirmed once
|| !PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(LOCATION_CONSENT, false))) {
HyperLog.i(TAG, "Location permission / consent not yet granted, asking user ...");
FragmentManager fm = activity.getSupportFragmentManager();

ConfirmationDialogFragment fragment = ConfirmationDialogFragment.getInstance(
Expand All @@ -51,7 +53,10 @@ private void onResult(Activity parent, boolean ok) {
PreferenceManager.getDefaultSharedPreferences(parent).edit()
.putBoolean(LOCATION_CONSENT, true)
.apply();
getLauncher().launch(Manifest.permission.ACCESS_FINE_LOCATION);
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
getLauncher().launch(Manifest.permission.ACCESS_FINE_LOCATION);
}
} else {
HyperLog.i(getName(), "User did not give consent. Stopping any further actions.");
PreferenceManager.getDefaultSharedPreferences(parent).edit()
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/play/release-notes/en-US/default.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
v2.2.8
• Fix activity resume error.
v2.2.9
• automatically ask the user for consent to process location data if not set
• Important: if you have updated from version 2.2.1 and the app no longer publishes, you need to give your consent once by opening the app.

0 comments on commit 4aaf5a9

Please sign in to comment.