Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permission prompt #378

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
apply plugin: 'realm-android'
apply plugin: 'maven-publish'

version '0.10.6-SNAPSHOT'
version '0.10.7-SNAPSHOT'

project.version = this.version

Expand Down
14 changes: 12 additions & 2 deletions library/src/main/java/io/ona/kujaku/helpers/PermissionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,33 @@
import com.karumi.dexter.Dexter;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;

import java.util.ArrayList;
import java.util.List;

import io.ona.kujaku.utils.KujakuMultiplePermissionListener;
import timber.log.Timber;

public class PermissionsHelper {

public static void checkPermissions(String TAG, Context context) {
if (context instanceof Activity) {
List<String> permissions = new ArrayList<>();
permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);

if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
Comment on lines +22 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lentumunai-Mark Do we have tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dubdabasoduba no existing tests for the class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create one

final Activity activity = (Activity) context;

MultiplePermissionsListener dialogMultiplePermissionListener = new KujakuMultiplePermissionListener(activity);

Dexter.withActivity(activity)
.withPermissions(Manifest.permission.ACCESS_FINE_LOCATION, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) ? Manifest.permission.MANAGE_EXTERNAL_STORAGE : Manifest.permission.WRITE_EXTERNAL_STORAGE)
.withPermissions(permissions)
.withListener(dialogMultiplePermissionListener)
.check();

} else {
Log.wtf(TAG, "KujakuMapView was not started in an activity!! This is very bad or it is being used in tests. We are going to ignore the permissions check! Good luck");
Timber.tag(TAG).wtf("KujakuMapView was not started in an activity!! This is very bad or it is being used in tests. We are going to ignore the permissions check! Good luck");
}
}
}
2 changes: 1 addition & 1 deletion utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'

version '0.10.6-SNAPSHOT'
version '0.10.7-SNAPSHOT'
project.version = this.version


Expand Down