From e337035aecd19600e188c6ebb460481c1c03eb07 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 11:03:49 +0200 Subject: [PATCH 1/6] Add changelog entry --- changelog.d/6198.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6198.misc diff --git a/changelog.d/6198.misc b/changelog.d/6198.misc new file mode 100644 index 0000000000..71582123f9 --- /dev/null +++ b/changelog.d/6198.misc @@ -0,0 +1 @@ +Remove the background location permission request From 00002105cface3f3ebc451fe3e81e2de913fd8c5 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 11:04:14 +0200 Subject: [PATCH 2/6] Remove permission declaration in Manifests --- vector/src/debug/AndroidManifest.xml | 2 -- vector/src/main/AndroidManifest.xml | 2 -- 2 files changed, 4 deletions(-) diff --git a/vector/src/debug/AndroidManifest.xml b/vector/src/debug/AndroidManifest.xml index 87aade0c8b..0b2b5cf90f 100644 --- a/vector/src/debug/AndroidManifest.xml +++ b/vector/src/debug/AndroidManifest.xml @@ -2,8 +2,6 @@ - - diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 8c2e25bc7e..2e31439e73 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -45,8 +45,6 @@ - - From 90cda6b2beb9fda6974fdf4124fba2ce5606cf4f Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 11:04:29 +0200 Subject: [PATCH 3/6] Adding todo to delete some strings --- vector/src/main/res/values/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 1728d6ef53..58e878e03c 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3017,7 +3017,9 @@ 15 minutes 1 hour 8 hours + Allow access + If you’d like to share your Live location, ${app_name} needs location access all the time when the app is in the background.\nWe will only access your location for the duration that you choose. ${app_name} could not access your location ${app_name} could not access your location. Please try again later. From 233fe21f26b5b39f35b40235aac4ead3debd2304 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 11:04:48 +0200 Subject: [PATCH 4/6] Remove runtime permission request --- .../vector/app/core/utils/PermissionsTools.kt | 6 --- .../DefaultLocationSharingNavigator.kt | 10 ----- .../location/LocationSharingFragment.kt | 37 ++----------------- .../location/LocationSharingNavigator.kt | 2 - 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt b/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt index a41abba7ab..705f683d2e 100644 --- a/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt +++ b/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt @@ -19,7 +19,6 @@ package im.vector.app.core.utils import android.Manifest import android.app.Activity import android.content.pm.PackageManager -import android.os.Build import androidx.activity.ComponentActivity import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts @@ -43,11 +42,6 @@ val PERMISSIONS_FOR_ROOM_AVATAR = listOf(Manifest.permission.CAMERA) val PERMISSIONS_FOR_WRITING_FILES = listOf(Manifest.permission.WRITE_EXTERNAL_STORAGE) val PERMISSIONS_FOR_PICKING_CONTACT = listOf(Manifest.permission.READ_CONTACTS) val PERMISSIONS_FOR_FOREGROUND_LOCATION_SHARING = listOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION) -val PERMISSIONS_FOR_BACKGROUND_LOCATION_SHARING = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - listOf(Manifest.permission.ACCESS_BACKGROUND_LOCATION) -} else { - PERMISSIONS_EMPTY -} // This is not ideal to store the value like that, but it works private var permissionDialogDisplayed = false diff --git a/vector/src/main/java/im/vector/app/features/location/DefaultLocationSharingNavigator.kt b/vector/src/main/java/im/vector/app/features/location/DefaultLocationSharingNavigator.kt index 8f424af9ec..ec8638fdbb 100644 --- a/vector/src/main/java/im/vector/app/features/location/DefaultLocationSharingNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/location/DefaultLocationSharingNavigator.kt @@ -17,20 +17,10 @@ package im.vector.app.features.location import android.app.Activity -import im.vector.app.core.utils.openAppSettingsPage class DefaultLocationSharingNavigator constructor(val activity: Activity?) : LocationSharingNavigator { - override var goingToAppSettings: Boolean = false - override fun quit() { activity?.finish() } - - override fun goToAppSettings() { - activity?.let { - goingToAppSettings = true - openAppSettingsPage(it) - } - } } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index 6de853519b..89aedf3aa9 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -32,9 +32,9 @@ import com.mapbox.mapboxsdk.maps.MapView import im.vector.app.R import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.core.platform.VectorBaseFragment -import im.vector.app.core.utils.PERMISSIONS_FOR_BACKGROUND_LOCATION_SHARING import im.vector.app.core.utils.PERMISSIONS_FOR_FOREGROUND_LOCATION_SHARING import im.vector.app.core.utils.checkPermissions +import im.vector.app.core.utils.onPermissionDeniedDialog import im.vector.app.core.utils.registerForPermissionsResult import im.vector.app.databinding.FragmentLocationSharingBinding import im.vector.app.features.home.AvatarRenderer @@ -100,11 +100,6 @@ class LocationSharingFragment @Inject constructor( override fun onResume() { super.onResume() views.mapView.onResume() - if (locationSharingNavigator.goingToAppSettings) { - locationSharingNavigator.goingToAppSettings = false - // retry to start live location - tryStartLiveLocationSharing() - } } override fun onPause() { @@ -162,18 +157,6 @@ class LocationSharingFragment @Inject constructor( .show() } - private fun handleMissingBackgroundLocationPermission() { - MaterialAlertDialogBuilder(requireActivity()) - .setTitle(R.string.location_in_background_missing_permission_dialog_title) - .setMessage(R.string.location_in_background_missing_permission_dialog_content) - .setPositiveButton(R.string.settings) { _, _ -> - locationSharingNavigator.goToAppSettings() - } - .setNegativeButton(R.string.action_not_now, null) - .setCancelable(false) - .show() - } - private fun initLocateButton() { views.mapView.locateButton.setOnClickListener { viewModel.handle(LocationSharingAction.ZoomToUserLocation) @@ -212,30 +195,16 @@ class LocationSharingFragment @Inject constructor( } private val foregroundLocationResultLauncher = registerForPermissionsResult { allGranted, deniedPermanently -> - if (allGranted && checkPermissions(PERMISSIONS_FOR_BACKGROUND_LOCATION_SHARING, requireActivity(), backgroundLocationResultLauncher)) { - startLiveLocationSharing() - } else if (deniedPermanently) { - handleMissingBackgroundLocationPermission() - } - } - - private val backgroundLocationResultLauncher = registerForPermissionsResult { allGranted, deniedPermanently -> if (allGranted) { startLiveLocationSharing() } else if (deniedPermanently) { - handleMissingBackgroundLocationPermission() + activity?.onPermissionDeniedDialog(R.string.denied_permission_generic) } } private fun tryStartLiveLocationSharing() { // we need to re-check foreground location to be sure it has not changed after landing on this screen - if (checkPermissions(PERMISSIONS_FOR_FOREGROUND_LOCATION_SHARING, requireActivity(), foregroundLocationResultLauncher) && - checkPermissions( - PERMISSIONS_FOR_BACKGROUND_LOCATION_SHARING, - requireActivity(), - backgroundLocationResultLauncher, - R.string.location_in_background_missing_permission_dialog_content - )) { + if (checkPermissions(PERMISSIONS_FOR_FOREGROUND_LOCATION_SHARING, requireActivity(), foregroundLocationResultLauncher)) { startLiveLocationSharing() } } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingNavigator.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingNavigator.kt index 8927da9239..6f4759a1e4 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingNavigator.kt @@ -17,7 +17,5 @@ package im.vector.app.features.location interface LocationSharingNavigator { - var goingToAppSettings: Boolean fun quit() - fun goToAppSettings() } From 4f3b4a71ceb844f5982c3500242d202cb1558f90 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 13:46:14 +0200 Subject: [PATCH 5/6] Ignore unused strings to be deleted --- vector/src/main/res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 58e878e03c..d616abc62e 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3017,10 +3017,10 @@ 15 minutes 1 hour 8 hours - - Allow access - If you’d like to share your Live location, ${app_name} needs location access all the time when the app is in the background.\nWe will only access your location for the duration that you choose. + Allow access + + If you’d like to share your Live location, ${app_name} needs location access all the time when the app is in the background.\nWe will only access your location for the duration that you choose. ${app_name} could not access your location ${app_name} could not access your location. Please try again later. Open with From 2ca96a770db12208a5ad442d5019b3ad5e55f4b8 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 31 May 2022 14:24:09 +0200 Subject: [PATCH 6/6] Declaring tools namespace prefix to fix strange build error --- vector/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index d616abc62e..7035b5a980 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3020,7 +3020,7 @@ Allow access - If you’d like to share your Live location, ${app_name} needs location access all the time when the app is in the background.\nWe will only access your location for the duration that you choose. + If you’d like to share your Live location, ${app_name} needs location access all the time when the app is in the background.\nWe will only access your location for the duration that you choose. ${app_name} could not access your location ${app_name} could not access your location. Please try again later. Open with