mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 20:10:04 +03:00
Merge pull request #6199 from vector-im/feature/mna/6198-remove-background-location-permission
Remove background location permission
This commit is contained in:
commit
de185b94f3
8 changed files with 8 additions and 58 deletions
1
changelog.d/6198.misc
Normal file
1
changelog.d/6198.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Remove the background location permission request
|
|
@ -2,8 +2,6 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="im.vector.app">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
|
||||
<application>
|
||||
<activity android:name=".features.debug.TestLinkifyActivity" />
|
||||
<activity android:name=".features.debug.DebugPermissionActivity" />
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
<!-- Location Sharing -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- Debug only whilst live location sharing is WIP -->
|
||||
<!--<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
|
||||
|
||||
<!-- Jitsi SDK is now API23+ -->
|
||||
<uses-sdk tools:overrideLibrary="org.jitsi.meet.sdk,com.oney.WebRTCModule,com.learnium.RNDeviceInfo,com.reactnativecommunity.asyncstorage,com.ocetnik.timer,com.calendarevents,com.reactnativecommunity.netinfo,com.kevinresol.react_native_default_preference,com.rnimmersive,com.corbt.keepawake,com.BV.LinearGradient,com.horcrux.svg,com.oblador.performance,com.reactnativecommunity.slider,com.brentvatne.react,com.reactnativecommunity.clipboard,com.swmansion.gesturehandler.react,org.linusu,org.reactnative.maskedview,com.reactnativepagerview,com.swmansion.reanimated,com.th3rdwave.safeareacontext,com.swmansion.rnscreens,org.devio.rn.splashscreen,com.reactnativecommunity.webview" />
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,5 @@
|
|||
package im.vector.app.features.location
|
||||
|
||||
interface LocationSharingNavigator {
|
||||
var goingToAppSettings: Boolean
|
||||
fun quit()
|
||||
fun goToAppSettings()
|
||||
}
|
||||
|
|
|
@ -3010,8 +3010,10 @@
|
|||
<string name="location_share_live_select_duration_option_1">15 minutes</string>
|
||||
<string name="location_share_live_select_duration_option_2">1 hour</string>
|
||||
<string name="location_share_live_select_duration_option_3">8 hours</string>
|
||||
<string name="location_in_background_missing_permission_dialog_title">Allow access</string>
|
||||
<string name="location_in_background_missing_permission_dialog_content">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.</string>
|
||||
<!--TODO delete-->
|
||||
<string name="location_in_background_missing_permission_dialog_title" tools:ignore="UnusedResources">Allow access</string>
|
||||
<!--TODO delete-->
|
||||
<string name="location_in_background_missing_permission_dialog_content" xmlns:tools="http://schemas.android.com/tools" tools:ignore="UnusedResources">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.</string>
|
||||
<string name="location_not_available_dialog_title">${app_name} could not access your location</string>
|
||||
<string name="location_not_available_dialog_content">${app_name} could not access your location. Please try again later.</string>
|
||||
<string name="location_share_external">Open with</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue