mirror of
https://gitlab.shinice.net/pixeldroid/PixelDroid
synced 2024-12-18 19:22:50 +01:00
Merge pull request #226 from H-PixelDroid/gallery_save_hotfix
Make the MediaScanner scan work (previously when saving a photo it would get saved but not scanned properly, so it wouldn't show up in the gallery)
This commit is contained in:
commit
09fc137425
@ -15,15 +15,17 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.webkit.MimeTypeMap
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@ -465,12 +467,16 @@ class PhotoEditActivity : AppCompatActivity(), FilterListFragmentListener, EditI
|
||||
if (!save) {
|
||||
uploadImage(path)
|
||||
} else {
|
||||
val mimeType = MimeTypeMap.getSingleton()
|
||||
.getMimeTypeFromExtension("png")
|
||||
MediaScannerConnection.scanFile(
|
||||
this,
|
||||
arrayOf(path),
|
||||
arrayOf(mimeType), null)
|
||||
arrayOf(path.toUri().toFile().absolutePath),
|
||||
null
|
||||
|
||||
) { path, uri ->
|
||||
if(uri == null) {
|
||||
Log.e("NEW IMAGE SCAN FAILED", "Tried to scan $path, but it failed")
|
||||
}
|
||||
}
|
||||
|
||||
Snackbar.make(
|
||||
coordinator_edit, getString(R.string.save_image_success),
|
||||
|
Loading…
Reference in New Issue
Block a user