**Fix 2:** I believe the issue described is actually caused by a failure to obtain storage read and write permissions. On my phone, this bug manifests as a crash when attempting to store the rotated image (I tested this on both my emulator and my real phone; Fix 1 addresses the emulator, and Fix 2 is for the real phone). The issue described in the report could not be reproduced, and I suspect this is due to the storage permission problem manifesting differently on different emulators/phones. In any case, the two situations mentioned in the issue no longer occur. I added code to request permissions in the getRotatedImage function of EditActivity.kt to resolve this problem.

This commit is contained in:
Quiet 2024-10-27 00:56:30 +11:00
parent 3c80d205fa
commit 21e9a304c5

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons.edit
import android.Manifest
import android.animation.Animator
import android.animation.Animator.AnimatorListener
import android.animation.ValueAnimator
@ -20,6 +21,11 @@ import androidx.lifecycle.ViewModelProvider
import fr.free.nrw.commons.databinding.ActivityEditBinding
import timber.log.Timber
import java.io.File
import androidx.core.content.ContextCompat
import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
/**
* An activity class for editing and rotating images using LLJTran with EXIF attribute preservation.
@ -239,6 +245,12 @@ class EditActivity : AppCompatActivity() {
* as a result, and finishes the current activity.
*/
fun getRotatedImage() {
//Get Permission to saccess
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 7747)
}
val filePath = imageUri.toUri().path
val file = filePath?.let { File(it) }