Skip to content

Commit df898b8

Browse files
authored
Merge pull request #149 from Esri/release/100.6.1
Merge 100.6.1 into master
2 parents adb520a + ff3eb09 commit df898b8

File tree

5 files changed

+75
-15
lines changed

5 files changed

+75
-15
lines changed

arcgis-android-toolkit/src/main/java/com/esri/arcgisruntime/toolkit/ar/ArcGISArView.kt

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,15 @@ class ArcGISArView : FrameLayout, DefaultLifecycleObserver, Scene.OnUpdateListen
425425
cameraController.translationFactor = value
426426
}
427427

428+
/**
429+
* List of permissions requested during this session.
430+
*
431+
* @since 100.6.1
432+
*/
433+
private val requestedPermissions: MutableList<String> by lazy {
434+
ArrayList<String>()
435+
}
436+
428437
/**
429438
* Exposes an [Exception] should it occur when using this view.
430439
*
@@ -559,9 +568,18 @@ class ArcGISArView : FrameLayout, DefaultLifecycleObserver, Scene.OnUpdateListen
559568
// permission on Android M and above, now is a good time to ask the user for it.
560569
// when the permission is requested and the user responds to the request from the OS this is executed again
561570
// during onResume()
562-
if (isUsingARCore == ARCoreUsage.YES && renderVideoFeed && !hasPermission(CAMERA_PERMISSION)) {
563-
requestPermission(context as Activity, CAMERA_PERMISSION, CAMERA_PERMISSION_CODE)
564-
return
571+
if (isUsingARCore == ARCoreUsage.YES && !hasPermission(CAMERA_PERMISSION)) {
572+
if (permissionHasBeenPermanentlyDenied(context as Activity, CAMERA_PERMISSION)) {
573+
error = Exception(
574+
resources.getString(
575+
R.string.arcgis_ar_view_exception_permission_permanently_denied,
576+
CAMERA_PERMISSION
577+
)
578+
)
579+
} else {
580+
requestPermission(context as Activity, CAMERA_PERMISSION, CAMERA_PERMISSION_CODE)
581+
return
582+
}
565583
}
566584

567585
if (isUsingARCore == ARCoreUsage.YES) {
@@ -607,11 +625,20 @@ class ArcGISArView : FrameLayout, DefaultLifecycleObserver, Scene.OnUpdateListen
607625
// Request location permission if user has provided a LocationDataSource
608626
locationDataSource?.let {
609627
if (!hasPermission(LOCATION_PERMISSION)) {
610-
requestPermission(
611-
context as Activity,
612-
LOCATION_PERMISSION,
613-
LOCATION_PERMISSION_CODE
614-
)
628+
if (permissionHasBeenPermanentlyDenied(context as Activity, LOCATION_PERMISSION)) {
629+
error = Exception(
630+
resources.getString(
631+
R.string.arcgis_ar_view_exception_permission_permanently_denied,
632+
LOCATION_PERMISSION
633+
)
634+
)
635+
} else {
636+
requestPermission(
637+
context as Activity,
638+
LOCATION_PERMISSION,
639+
LOCATION_PERMISSION_CODE
640+
)
641+
}
615642
return
616643
}
617644
}
@@ -838,13 +865,36 @@ class ArcGISArView : FrameLayout, DefaultLifecycleObserver, Scene.OnUpdateListen
838865
) == PackageManager.PERMISSION_GRANTED
839866
}
840867

868+
/**
869+
* We use [ActivityCompat.shouldShowRequestPermissionRationale] as a workaround to detect whether
870+
* the user has denied the permission permanently, i.e. has selected `Don't Ask Again`. There is
871+
* no official API to detect that, so we use a variation of a workaround described here:
872+
* https://blog.usejournal.com/method-to-detect-if-user-has-selected-dont-ask-again-while-requesting-for-permission-921b95ded536
873+
*
874+
* Checks [requestedPermissions] property for permission to determine if it has already been
875+
* requested this session. Returns false if permission has never been requested and therefore the
876+
* user has not selected `Don't Ask Again`. Returns true otherwise.
877+
*
878+
* @since 100.6.1
879+
*/
880+
private fun permissionHasBeenPermanentlyDenied(
881+
activity: Activity,
882+
permission: String
883+
): Boolean {
884+
return requestedPermissions.contains(permission) && ActivityCompat.shouldShowRequestPermissionRationale(
885+
activity,
886+
permission
887+
).not()
888+
}
889+
841890
/**
842891
* Request a [permission] using the provided [activity] and [permissionCode].
843892
*
844893
* @since 100.6.0
845894
*/
846895
private fun requestPermission(activity: Activity, permission: String, permissionCode: Int) {
847896
ActivityCompat.requestPermissions(activity, arrayOf(permission), permissionCode)
897+
requestedPermissions.add(permission)
848898
}
849899

850900
/**

arcgis-android-toolkit/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
-->
1717

1818
<resources>
19+
20+
<!-- ArcGISArView -->
1921
<string name="arcgis_ar_view_ar_core_unsupported_error">ARCore is unsupported: %s</string>
22+
<string name="arcgis_ar_view_exception_permission_permanently_denied">%s permission has been permanently denied</string>
2023

2124
<!-- ArCalibrationView -->
2225
<string name="ar_calibration_view_elevation_label">Elevation</string>

gradle/script/aar-publishing.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@
1616

1717
apply from: "$rootProject.projectDir/gradle/script/artifact.gradle"
1818

19+
// https://docs.gradle.org/current/userguide/publishing_maven.html
1920
publishing {
2021
publications {
21-
mavenAar(MavenPublication) {
22+
aar(MavenPublication) {
2223
from components.android
2324
groupId _groupId
2425
artifactId _artifactId
2526
version _versionName
2627
}
2728
}
2829
}
30+
31+
// Rewrites default filename for pom to match that of the artifact
32+
// https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.tasks.GenerateMavenPom.html
33+
generatePomFileForAarPublication {
34+
destination = "$buildDir/outputs/aar/${_artifactId}-${_versionName}.xml"
35+
}

gradle/script/artifact.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
ext {
18-
_versionCode = 106
19-
_versionName = "100.6.0"
18+
_versionCode = 108
19+
_versionName = "100.6.1"
2020
_groupId = "com.esri.arcgisruntime"
2121
_artifactId = 'arcgis-android-toolkit'
2222
}

gradle/script/versions.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
ext {
1818
droid = ext {
1919
minSdk = 19
20-
targetSdk = 28
21-
buildTools = "28.0.3"
22-
androidGradlePlugin = "3.5.0"
20+
targetSdk = 29
21+
buildTools = "29.0.2"
22+
androidGradlePlugin = "3.5.1"
2323
androidMavenGradlePlugin = "2.1"
2424
dokka = "0.9.18"
2525
constraintLayout = "1.1.3"
2626
multiDex = "1.0.3"
2727
support = "28.0.0"
2828
testRunner = "1.0.2"
29-
arCore = "1.8.0"
29+
arCore = "1.12.0"
3030
lifecycle = "1.1.1"
3131
}
3232
test = ext {

0 commit comments

Comments
 (0)