Krobys / document-scanner-fast

16 stars 11 forks source link

Problems saving the image (New read/write permissions required) #3

Open lquintero07 opened 11 months ago

lquintero07 commented 11 months ago

Hi,

Thanks for the library it is nice.

There is a problem at the moment to save the image, the original library added this:

`

private fun getReadStoragePermission(): String {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        Manifest.permission.READ_MEDIA_IMAGES
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            Manifest.permission.ACCESS_MEDIA_LOCATION
        } else {
            Manifest.permission.READ_EXTERNAL_STORAGE
        }
    }
}

private fun getWriteStoragePermission(): String {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        Manifest.permission.ACCESS_MEDIA_LOCATION
    } else {
        Manifest.permission.WRITE_EXTERNAL_STORAGE
    }
}

`

That works great with the new devices permissions and resolve the problem when i added to your code.

Tested with the original library there is another problem regarding with this: Environment.getExternalStorageDirectory()

Krobys commented 11 months ago

Hi,

Thanks for the library it is nice.

There is a problem at the moment to save the image, the original library added this:

`

private fun getReadStoragePermission(): String {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        Manifest.permission.READ_MEDIA_IMAGES
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            Manifest.permission.ACCESS_MEDIA_LOCATION
        } else {
            Manifest.permission.READ_EXTERNAL_STORAGE
        }
    }
}

private fun getWriteStoragePermission(): String {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        Manifest.permission.ACCESS_MEDIA_LOCATION
    } else {
        Manifest.permission.WRITE_EXTERNAL_STORAGE
    }
}

`

That works great with the new devices permissions and resolve the problem when i added to your code.

Tested with the original library there is another problem regarding with this: Environment.getExternalStorageDirectory()

Thanks for information, could you please create PR with this fix for new versions of android? Dont really have time to fix it.