Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #5814 - Rotated pictures shown as failed to upload, actually uploaded successfully #5899

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
14 changes: 14 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/edit/EditActivity.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -35,6 +41,8 @@ class EditActivity : AppCompatActivity() {
private val sourceExifAttributeList = mutableListOf<Pair<String, String?>>()
private lateinit var binding: ActivityEditBinding

private final var WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 7747;

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityEditBinding.inflate(layoutInflater)
Expand Down Expand Up @@ -239,6 +247,12 @@ class EditActivity : AppCompatActivity() {
* as a result, and finishes the current activity.
*/
fun getRotatedImage() {
//Get Permission to access
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE)
}

val filePath = imageUri.toUri().path
val file = filePath?.let { File(it) }

Expand Down
Loading