mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 05:55:39 +03:00
Merge pull request #2880 from nextcloud/feature/2299/MigrateToAndroid13
Bump target and compile SDK to 33
This commit is contained in:
commit
cefdd5203e
9 changed files with 134 additions and 44 deletions
|
@ -36,14 +36,14 @@ apply plugin: "org.jlleitschuh.gradle.ktlint"
|
||||||
apply plugin: 'kotlinx-serialization'
|
apply plugin: 'kotlinx-serialization'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 32
|
compileSdkVersion 33
|
||||||
buildToolsVersion '33.0.2'
|
buildToolsVersion '33.0.2'
|
||||||
|
|
||||||
namespace 'com.nextcloud.talk'
|
namespace 'com.nextcloud.talk'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 31
|
targetSdkVersion 33
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
// mayor.minor.hotfix.increment (for increment: 01-50=Alpha / 51-89=RC / 90-99=stable)
|
// mayor.minor.hotfix.increment (for increment: 01-50=Alpha / 51-89=RC / 90-99=stable)
|
||||||
|
|
|
@ -71,7 +71,12 @@
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="29"
|
android:maxSdkVersion="29"
|
||||||
tools:ignore="ScopedStorage" />
|
tools:ignore="ScopedStorage" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||||
|
android:maxSdkVersion="32" />
|
||||||
|
<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_AUDIO" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||||
|
|
|
@ -801,7 +801,7 @@ class ChatController(args: Bundle) :
|
||||||
requestRecordAudioPermissions()
|
requestRecordAudioPermissions()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (!UploadAndShareFilesWorker.isStoragePermissionGranted(context)) {
|
if (!permissionUtil.isFilesPermissionGranted()) {
|
||||||
UploadAndShareFilesWorker.requestStoragePermission(this@ChatController)
|
UploadAndShareFilesWorker.requestStoragePermission(this@ChatController)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -1312,6 +1312,26 @@ class ChatController(args: Bundle) :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requestReadFilesPermissions() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
requestPermissions(
|
||||||
|
arrayOf(
|
||||||
|
Manifest.permission.READ_MEDIA_IMAGES,
|
||||||
|
Manifest.permission.READ_MEDIA_VIDEO,
|
||||||
|
Manifest.permission.READ_MEDIA_AUDIO
|
||||||
|
),
|
||||||
|
REQUEST_SHARE_FILE_PERMISSION
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
requestPermissions(
|
||||||
|
arrayOf(
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
),
|
||||||
|
REQUEST_SHARE_FILE_PERMISSION
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkShowCallButtons() {
|
private fun checkShowCallButtons() {
|
||||||
if (isAlive()) {
|
if (isAlive()) {
|
||||||
if (isReadOnlyConversation() || shouldShowLobby()) {
|
if (isReadOnlyConversation() || shouldShowLobby()) {
|
||||||
|
@ -1490,7 +1510,7 @@ class ChatController(args: Bundle) :
|
||||||
.setTitle(confirmationQuestion)
|
.setTitle(confirmationQuestion)
|
||||||
.setMessage(filenamesWithLineBreaks.toString())
|
.setMessage(filenamesWithLineBreaks.toString())
|
||||||
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
||||||
if (UploadAndShareFilesWorker.isStoragePermissionGranted(context)) {
|
if (permissionUtil.isFilesPermissionGranted()) {
|
||||||
uploadFiles(filesToUpload)
|
uploadFiles(filesToUpload)
|
||||||
} else {
|
} else {
|
||||||
UploadAndShareFilesWorker.requestStoragePermission(this)
|
UploadAndShareFilesWorker.requestStoragePermission(this)
|
||||||
|
@ -1557,7 +1577,7 @@ class ChatController(args: Bundle) :
|
||||||
throw IllegalStateException("Failed to get data from intent and uri")
|
throw IllegalStateException("Failed to get data from intent and uri")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UploadAndShareFilesWorker.isStoragePermissionGranted(context)) {
|
if (permissionUtil.isFilesPermissionGranted()) {
|
||||||
uploadFiles(filesToUpload)
|
uploadFiles(filesToUpload)
|
||||||
} else {
|
} else {
|
||||||
UploadAndShareFilesWorker.requestStoragePermission(this)
|
UploadAndShareFilesWorker.requestStoragePermission(this)
|
||||||
|
@ -1618,6 +1638,10 @@ class ChatController(args: Bundle) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hasGrantedPermissions(grantResults: IntArray): Boolean {
|
||||||
|
return permissionUtil.isFilesPermissionGranted()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||||
if (requestCode == UploadAndShareFilesWorker.REQUEST_PERMISSION) {
|
if (requestCode == UploadAndShareFilesWorker.REQUEST_PERMISSION) {
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
@ -1630,6 +1654,16 @@ class ChatController(args: Bundle) :
|
||||||
.makeText(context, context.getString(R.string.read_storage_no_permission), Toast.LENGTH_LONG)
|
.makeText(context, context.getString(R.string.read_storage_no_permission), Toast.LENGTH_LONG)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
} else if (requestCode == REQUEST_SHARE_FILE_PERMISSION) {
|
||||||
|
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
showLocalFilePicker()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
context.getString(R.string.nc_file_storage_permission),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
}
|
||||||
} else if (requestCode == REQUEST_RECORD_AUDIO_PERMISSION) {
|
} else if (requestCode == REQUEST_RECORD_AUDIO_PERMISSION) {
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
// do nothing. user will tap on the microphone again if he wants to record audio..
|
// do nothing. user will tap on the microphone again if he wants to record audio..
|
||||||
|
@ -1696,7 +1730,7 @@ class ChatController(args: Bundle) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendSelectLocalFileIntent() {
|
private fun showLocalFilePicker() {
|
||||||
val action = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
|
val action = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
|
||||||
type = "*/*"
|
type = "*/*"
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
@ -1713,6 +1747,14 @@ class ChatController(args: Bundle) :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun sendSelectLocalFileIntent() {
|
||||||
|
if (!permissionUtil.isFilesPermissionGranted()) {
|
||||||
|
requestReadFilesPermissions()
|
||||||
|
} else {
|
||||||
|
showLocalFilePicker()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun sendChooseContactIntent() {
|
fun sendChooseContactIntent() {
|
||||||
requestReadContacts()
|
requestReadContacts()
|
||||||
}
|
}
|
||||||
|
@ -3490,6 +3532,7 @@ class ChatController(args: Bundle) :
|
||||||
private const val REQUEST_CODE_CHOOSE_FILE: Int = 555
|
private const val REQUEST_CODE_CHOOSE_FILE: Int = 555
|
||||||
private const val REQUEST_CODE_SELECT_CONTACT: Int = 666
|
private const val REQUEST_CODE_SELECT_CONTACT: Int = 666
|
||||||
private const val REQUEST_CODE_MESSAGE_SEARCH: Int = 777
|
private const val REQUEST_CODE_MESSAGE_SEARCH: Int = 777
|
||||||
|
private const val REQUEST_SHARE_FILE_PERMISSION: Int = 221
|
||||||
private const val REQUEST_RECORD_AUDIO_PERMISSION = 222
|
private const val REQUEST_RECORD_AUDIO_PERMISSION = 222
|
||||||
private const val REQUEST_READ_CONTACT_PERMISSION = 234
|
private const val REQUEST_READ_CONTACT_PERMISSION = 234
|
||||||
private const val REQUEST_CAMERA_PERMISSION = 223
|
private const val REQUEST_CAMERA_PERMISSION = 223
|
||||||
|
|
|
@ -87,7 +87,6 @@ import com.nextcloud.talk.jobs.AccountRemovalWorker
|
||||||
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.run
|
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.run
|
||||||
import com.nextcloud.talk.jobs.DeleteConversationWorker
|
import com.nextcloud.talk.jobs.DeleteConversationWorker
|
||||||
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker
|
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker
|
||||||
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker.Companion.isStoragePermissionGranted
|
|
||||||
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker.Companion.requestStoragePermission
|
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker.Companion.requestStoragePermission
|
||||||
import com.nextcloud.talk.messagesearch.MessageSearchHelper
|
import com.nextcloud.talk.messagesearch.MessageSearchHelper
|
||||||
import com.nextcloud.talk.messagesearch.MessageSearchHelper.MessageSearchResults
|
import com.nextcloud.talk.messagesearch.MessageSearchHelper.MessageSearchResults
|
||||||
|
@ -119,6 +118,7 @@ import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.hasSpreedFeatu
|
||||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isServerEOL
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isServerEOL
|
||||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUnifiedSearchAvailable
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUnifiedSearchAvailable
|
||||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUserStatusAvailable
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUserStatusAvailable
|
||||||
|
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping.remapChatController
|
import com.nextcloud.talk.utils.remapchat.ConductorRemapping.remapChatController
|
||||||
import com.nextcloud.talk.utils.rx.SearchViewObservable.Companion.observeSearchView
|
import com.nextcloud.talk.utils.rx.SearchViewObservable.Companion.observeSearchView
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
||||||
|
@ -159,6 +159,9 @@ class ConversationsListController(bundle: Bundle) :
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var unifiedSearchRepository: UnifiedSearchRepository
|
lateinit var unifiedSearchRepository: UnifiedSearchRepository
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var platformPermissionUtil: PlatformPermissionUtil
|
||||||
|
|
||||||
private val binding: ControllerConversationsRvBinding? by viewBinding(ControllerConversationsRvBinding::bind)
|
private val binding: ControllerConversationsRvBinding? by viewBinding(ControllerConversationsRvBinding::bind)
|
||||||
|
|
||||||
override val title: String
|
override val title: String
|
||||||
|
@ -960,7 +963,7 @@ class ConversationsListController(bundle: Bundle) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSendFilesConfirmDialog() {
|
private fun showSendFilesConfirmDialog() {
|
||||||
if (isStoragePermissionGranted(context)) {
|
if (platformPermissionUtil.isFilesPermissionGranted()) {
|
||||||
val fileNamesWithLineBreaks = StringBuilder("\n")
|
val fileNamesWithLineBreaks = StringBuilder("\n")
|
||||||
for (file in filesToShare!!) {
|
for (file in filesToShare!!) {
|
||||||
val filename = FileUtils.getFileName(Uri.parse(file), context)
|
val filename = FileUtils.getFileName(Uri.parse(file), context)
|
||||||
|
|
|
@ -32,7 +32,6 @@ import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.content.PermissionChecker
|
|
||||||
import androidx.work.Data
|
import androidx.work.Data
|
||||||
import androidx.work.ExistingWorkPolicy
|
import androidx.work.ExistingWorkPolicy
|
||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
|
@ -57,6 +56,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FROM_NOTIFICATION_START_CA
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
|
||||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
||||||
|
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
@ -78,6 +78,9 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var okHttpClient: OkHttpClient
|
lateinit var okHttpClient: OkHttpClient
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var platformPermissionUtil: PlatformPermissionUtil
|
||||||
|
|
||||||
lateinit var fileName: String
|
lateinit var fileName: String
|
||||||
|
|
||||||
private var mNotifyManager: NotificationManager? = null
|
private var mNotifyManager: NotificationManager? = null
|
||||||
|
@ -93,7 +96,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||||
|
|
||||||
if (!isStoragePermissionGranted(context)) {
|
if (!platformPermissionUtil.isFilesPermissionGranted()) {
|
||||||
Log.w(
|
Log.w(
|
||||||
TAG,
|
TAG,
|
||||||
"Storage permission is not granted. As a developer please make sure you check for" +
|
"Storage permission is not granted. As a developer please make sure you check for" +
|
||||||
|
@ -285,39 +288,19 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||||
private const val ZERO_PERCENT = 0
|
private const val ZERO_PERCENT = 0
|
||||||
const val REQUEST_PERMISSION = 3123
|
const val REQUEST_PERMISSION = 3123
|
||||||
|
|
||||||
fun isStoragePermissionGranted(context: Context): Boolean {
|
|
||||||
return when {
|
|
||||||
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
|
||||||
if (PermissionChecker.checkSelfPermission(
|
|
||||||
context,
|
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
|
||||||
) == PermissionChecker.PERMISSION_GRANTED
|
|
||||||
) {
|
|
||||||
Log.d(TAG, "Permission is granted (SDK 30 or greater)")
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Permission is revoked (SDK 30 or greater)")
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
if (PermissionChecker.checkSelfPermission(
|
|
||||||
context,
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
||||||
) == PermissionChecker.PERMISSION_GRANTED
|
|
||||||
) {
|
|
||||||
Log.d(TAG, "Permission is granted")
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Permission is revoked")
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun requestStoragePermission(controller: Controller) {
|
fun requestStoragePermission(controller: Controller) {
|
||||||
when {
|
when {
|
||||||
|
Build.VERSION
|
||||||
|
.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> {
|
||||||
|
controller.requestPermissions(
|
||||||
|
arrayOf(
|
||||||
|
Manifest.permission.READ_MEDIA_IMAGES,
|
||||||
|
Manifest.permission.READ_MEDIA_VIDEO,
|
||||||
|
Manifest.permission.READ_MEDIA_AUDIO
|
||||||
|
),
|
||||||
|
REQUEST_PERMISSION
|
||||||
|
)
|
||||||
|
}
|
||||||
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
||||||
controller.requestPermissions(
|
controller.requestPermissions(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
|
|
|
@ -220,12 +220,12 @@ class MessageSearchActivity : BaseActivity() {
|
||||||
searchView = menuItem.actionView as SearchView
|
searchView = menuItem.actionView as SearchView
|
||||||
setupSearchView()
|
setupSearchView()
|
||||||
menuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
menuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||||
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
|
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||||
searchView.requestFocus()
|
searchView.requestFocus()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,6 @@ package com.nextcloud.talk.utils.permissions
|
||||||
interface PlatformPermissionUtil {
|
interface PlatformPermissionUtil {
|
||||||
val privateBroadcastPermission: String
|
val privateBroadcastPermission: String
|
||||||
fun isCameraPermissionGranted(): Boolean
|
fun isCameraPermissionGranted(): Boolean
|
||||||
|
|
||||||
|
fun isFilesPermissionGranted(): Boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ package com.nextcloud.talk.utils.permissions
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
import androidx.core.content.PermissionChecker
|
import androidx.core.content.PermissionChecker
|
||||||
import com.nextcloud.talk.BuildConfig
|
import com.nextcloud.talk.BuildConfig
|
||||||
|
|
||||||
|
@ -36,4 +38,55 @@ class PlatformPermissionUtilImpl(private val context: Context) : PlatformPermiss
|
||||||
Manifest.permission.CAMERA
|
Manifest.permission.CAMERA
|
||||||
) == PermissionChecker.PERMISSION_GRANTED
|
) == PermissionChecker.PERMISSION_GRANTED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isFilesPermissionGranted(): Boolean {
|
||||||
|
return when {
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> {
|
||||||
|
if (
|
||||||
|
PermissionChecker.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES)
|
||||||
|
== PermissionChecker.PERMISSION_GRANTED ||
|
||||||
|
PermissionChecker.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VIDEO)
|
||||||
|
== PermissionChecker.PERMISSION_GRANTED ||
|
||||||
|
PermissionChecker.checkSelfPermission(context, Manifest.permission.READ_MEDIA_AUDIO)
|
||||||
|
== PermissionChecker.PERMISSION_GRANTED
|
||||||
|
) {
|
||||||
|
Log.d(TAG, "Permission is granted (SDK 33 or greater)")
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Permission is revoked (SDK 33 or greater)")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
||||||
|
if (PermissionChecker.checkSelfPermission(
|
||||||
|
context,
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
) == PermissionChecker.PERMISSION_GRANTED
|
||||||
|
) {
|
||||||
|
Log.d(TAG, "Permission is granted (SDK 30 or greater)")
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Permission is revoked (SDK 30 or greater)")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
if (PermissionChecker.checkSelfPermission(
|
||||||
|
context,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
) == PermissionChecker.PERMISSION_GRANTED
|
||||||
|
) {
|
||||||
|
Log.d(TAG, "Permission is granted")
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Permission is revoked")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val TAG = PlatformPermissionUtilImpl::class.simpleName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,6 +464,7 @@ How to translate with transifex:
|
||||||
<string name="nc_upload_notification_text">%1$s to %2$s - %3$s\%%</string>
|
<string name="nc_upload_notification_text">%1$s to %2$s - %3$s\%%</string>
|
||||||
<string name="nc_upload_failed_notification_title">Failure</string>
|
<string name="nc_upload_failed_notification_title">Failure</string>
|
||||||
<string name="nc_upload_failed_notification_text">Failed to upload %1$s</string>
|
<string name="nc_upload_failed_notification_text">Failed to upload %1$s</string>
|
||||||
|
<string name="nc_file_storage_permission">Permission for file access is required</string>
|
||||||
|
|
||||||
<!-- Video -->
|
<!-- Video -->
|
||||||
<string name="nc_video_filename">Video recording from %1$s</string>
|
<string name="nc_video_filename">Video recording from %1$s</string>
|
||||||
|
|
Loading…
Reference in a new issue