Skip to content

Commit

Permalink
Merge pull request #29 from Qase/FIX/write_external_storage_permission
Browse files Browse the repository at this point in the history
Fix/write external storage permission
  • Loading branch information
zelenmi6 committed May 24, 2022
2 parents e7e1117 + 4a8b621 commit 43688a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions kotlinlog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 4
versionName "2.2.9"
versionCode 5
versionName "2.2.10"
buildConfigField 'int', 'VERSION_CODE', "$versionCode"
buildConfigField 'String', 'VERSION_NAME', "\"$versionName\""
consumerProguardFile('proguard-rules.pro')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package quanti.com.kotlinlog.utils

import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import androidx.core.content.ContextCompat

/**
Expand All @@ -20,7 +21,11 @@ fun Context.checkPermission(permission: String) = ContextCompat.checkSelfPermiss
*/
fun Context.hasPermission(permission: String) = checkPermission(permission) == PackageManager.PERMISSION_GRANTED

fun Context.hasFileWritePermission() = hasPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
/**
* Returns true if Write external storage permission is provided
* or if the Android is >= Android 10 since this permission is irrelevant for those versions
*/
fun Context.hasFileWritePermission() = hasPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) || (Build.VERSION.SDK_INT >= 29)



Expand Down

0 comments on commit 43688a3

Please sign in to comment.