handle new READ_MEDIA_VISUAL_USER_SELECTED permission.
now the app no longer forces media permission to run
This commit is contained in:
parent
c97f3f89e6
commit
3d09de6939
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||||
|
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
|
|
@ -225,30 +225,25 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
private fun tryInitCamera() {
|
private fun tryInitCamera() {
|
||||||
handlePermission(PERMISSION_CAMERA) { grantedCameraPermission ->
|
handlePermission(PERMISSION_CAMERA) { grantedCameraPermission ->
|
||||||
if (grantedCameraPermission) {
|
if (grantedCameraPermission) {
|
||||||
handleStoragePermission { grantedStoragePermission ->
|
handleStoragePermission {
|
||||||
if (grantedStoragePermission) {
|
val isInPhotoMode = isInPhotoMode()
|
||||||
val isInPhotoMode = isInPhotoMode()
|
if (isInPhotoMode) {
|
||||||
if (isInPhotoMode) {
|
initializeCamera(true)
|
||||||
initializeCamera(true)
|
} else {
|
||||||
} else {
|
handlePermission(PERMISSION_RECORD_AUDIO) { grantedRecordAudioPermission ->
|
||||||
handlePermission(PERMISSION_RECORD_AUDIO) { grantedRecordAudioPermission ->
|
if (grantedRecordAudioPermission) {
|
||||||
if (grantedRecordAudioPermission) {
|
initializeCamera(false)
|
||||||
initializeCamera(false)
|
} else {
|
||||||
|
toast(com.simplemobiletools.commons.R.string.no_audio_permissions)
|
||||||
|
if (isThirdPartyIntent()) {
|
||||||
|
finish()
|
||||||
} else {
|
} else {
|
||||||
toast(com.simplemobiletools.commons.R.string.no_audio_permissions)
|
// re-initialize in photo mode
|
||||||
if (isThirdPartyIntent()) {
|
config.initPhotoMode = true
|
||||||
finish()
|
tryInitCamera()
|
||||||
} else {
|
|
||||||
// re-initialize in photo mode
|
|
||||||
config.initPhotoMode = true
|
|
||||||
tryInitCamera()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,13 +265,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
|
|
||||||
private fun handleStoragePermission(callback: (granted: Boolean) -> Unit) {
|
private fun handleStoragePermission(callback: (granted: Boolean) -> Unit) {
|
||||||
if (isTiramisuPlus()) {
|
if (isTiramisuPlus()) {
|
||||||
handlePermission(PERMISSION_READ_MEDIA_IMAGES) { grantedReadImages ->
|
val mediaPermissionIds = mutableListOf(PERMISSION_READ_MEDIA_IMAGES, PERMISSION_READ_MEDIA_VIDEO)
|
||||||
if (grantedReadImages) {
|
if (isUpsideDownCakePlus()) {
|
||||||
handlePermission(PERMISSION_READ_MEDIA_VIDEO, callback)
|
mediaPermissionIds.add(PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED)
|
||||||
} else {
|
|
||||||
callback.invoke(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePartialMediaPermissions(permissionIds = mediaPermissionIds, callback = callback)
|
||||||
} else {
|
} else {
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE, callback)
|
handlePermission(PERMISSION_WRITE_STORAGE, callback)
|
||||||
}
|
}
|
||||||
|
@ -574,7 +568,11 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
|
|
||||||
private fun hasPhotoModePermissions(): Boolean {
|
private fun hasPhotoModePermissions(): Boolean {
|
||||||
return if (isTiramisuPlus()) {
|
return if (isTiramisuPlus()) {
|
||||||
hasPermission(PERMISSION_READ_MEDIA_IMAGES) && hasPermission(PERMISSION_READ_MEDIA_VIDEO) && hasPermission(PERMISSION_CAMERA)
|
var hasMediaPermission = hasPermission(PERMISSION_READ_MEDIA_IMAGES) || hasPermission(PERMISSION_READ_MEDIA_VIDEO)
|
||||||
|
if (isUpsideDownCakePlus()) {
|
||||||
|
hasMediaPermission = hasMediaPermission || hasPermission(PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED)
|
||||||
|
}
|
||||||
|
hasMediaPermission && hasPermission(PERMISSION_CAMERA)
|
||||||
} else {
|
} else {
|
||||||
hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
|
hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
|
||||||
}
|
}
|
||||||
|
@ -582,7 +580,11 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
|
|
||||||
private fun hasVideoModePermissions(): Boolean {
|
private fun hasVideoModePermissions(): Boolean {
|
||||||
return if (isTiramisuPlus()) {
|
return if (isTiramisuPlus()) {
|
||||||
hasPermission(PERMISSION_READ_MEDIA_VIDEO) && hasPermission(PERMISSION_CAMERA) && hasPermission(PERMISSION_RECORD_AUDIO)
|
var hasMediaPermission = hasPermission(PERMISSION_READ_MEDIA_VIDEO)
|
||||||
|
if (isUpsideDownCakePlus()) {
|
||||||
|
hasMediaPermission = hasMediaPermission || hasPermission(PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED)
|
||||||
|
}
|
||||||
|
hasMediaPermission && hasPermission(PERMISSION_CAMERA) && hasPermission(PERMISSION_RECORD_AUDIO)
|
||||||
} else {
|
} else {
|
||||||
hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA) && hasPermission(PERMISSION_RECORD_AUDIO)
|
hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA) && hasPermission(PERMISSION_RECORD_AUDIO)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ androidx-window = "1.2.0-beta01"
|
||||||
androidx-camera = "1.3.0-beta02"
|
androidx-camera = "1.3.0-beta02"
|
||||||
androidx-ktx = "2.6.1"
|
androidx-ktx = "2.6.1"
|
||||||
#Simple tools
|
#Simple tools
|
||||||
simple-commons = "53ad279f5e"
|
simple-commons = "d1629c7f1a"
|
||||||
#Gradle
|
#Gradle
|
||||||
gradlePlugins-agp = "8.1.0"
|
gradlePlugins-agp = "8.1.0"
|
||||||
#build
|
#build
|
||||||
|
|
Loading…
Reference in New Issue