fix loading of fullscreen OTG media
This commit is contained in:
parent
a1a23217b9
commit
b70292652b
9 changed files with 23 additions and 20 deletions
|
@ -46,7 +46,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.12.12'
|
||||
implementation 'com.simplemobiletools:commons:3.12.13'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
||||
implementation 'com.android.support:multidex:1.0.2'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.provider.MediaStore
|
|||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
|
@ -65,7 +66,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
saveUri = when {
|
||||
intent.extras?.containsKey(REAL_FILE_PATH) == true -> {
|
||||
val realPath = intent.extras.get(REAL_FILE_PATH) as String
|
||||
if (isPathOnOTG(realPath)) {
|
||||
if (realPath.startsWith(OTG_PATH)) {
|
||||
Uri.parse(realPath)
|
||||
} else {
|
||||
Uri.fromFile(File(realPath))
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.view.View
|
|||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_FROM_GALLERY
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||
import com.simplemobiletools.gallery.R
|
||||
|
@ -60,13 +61,12 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
mUri = intent.data ?: return
|
||||
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
||||
val realPath = intent.extras.get(REAL_FILE_PATH) as String
|
||||
if (!isPathOnOTG(realPath)) {
|
||||
if (!realPath.startsWith(OTG_PATH)) {
|
||||
mUri = Uri.fromFile(File(realPath))
|
||||
}
|
||||
}
|
||||
|
||||
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
|
||||
|
||||
if (mUri!!.scheme == "file") {
|
||||
scanPath(mUri!!.path)
|
||||
sendViewPagerIntent(mUri!!.path)
|
||||
|
|
|
@ -29,10 +29,7 @@ import com.bumptech.glide.Glide
|
|||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_FROM_GALLERY
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
||||
import com.simplemobiletools.commons.helpers.REQUEST_SET_AS
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.adapters.MyPagerAdapter
|
||||
|
@ -202,6 +199,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
showSystemUI()
|
||||
|
||||
mDirectory = mPath.getParentPath().trimEnd('/')
|
||||
if (mDirectory.startsWith(OTG_PATH.trimEnd('/'))) {
|
||||
mDirectory += "/"
|
||||
}
|
||||
supportActionBar?.title = mPath.getFilenameFromPath()
|
||||
|
||||
view_pager.onGlobalLayout {
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -288,7 +289,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
photo_name.tag = medium.path
|
||||
|
||||
var thumbnailPath = medium.path
|
||||
if (hasOTGConnected && activity.isPathOnOTG(thumbnailPath)) {
|
||||
if (hasOTGConnected && thumbnailPath.startsWith(OTG_PATH)) {
|
||||
thumbnailPath = thumbnailPath.getOTGPublicPath(context)
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
|||
|
||||
val firstItem = curMedia.first()
|
||||
val lastItem = curMedia.last()
|
||||
val parentDir = if (hasOTG && context.isPathOnOTG(firstItem.path)) firstItem.path.getParentPath() else File(firstItem.path).parent
|
||||
val parentDir = if (hasOTG && firstItem.path.startsWith(OTG_PATH)) firstItem.path.getParentPath() else File(firstItem.path).parent
|
||||
var thumbnail = firstItem.path
|
||||
if (thumbnail.startsWith(OTG_PATH)) {
|
||||
thumbnail = thumbnail.getOTGPublicPath(context)
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.simplemobiletools.gallery.extensions
|
||||
|
||||
import android.os.Environment
|
||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||
import java.io.File
|
||||
|
||||
fun File.containsNoMedia() = isDirectory && File(this, NOMEDIA).exists()
|
||||
|
||||
fun File.isDownloadsFolder() = absolutePath == Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.bumptech.glide.request.target.Target
|
|||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.PhotoActivity
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
|
@ -204,10 +205,11 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
private fun loadGif() {
|
||||
try {
|
||||
gifDrawable = if (medium.path.startsWith("content://") || medium.path.startsWith("file://")) {
|
||||
GifDrawable(context!!.contentResolver, Uri.parse(medium.path))
|
||||
val pathToLoad = getPathToLoad()
|
||||
gifDrawable = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
||||
GifDrawable(context!!.contentResolver, Uri.parse(pathToLoad))
|
||||
} else {
|
||||
GifDrawable(medium.path)
|
||||
GifDrawable(pathToLoad)
|
||||
}
|
||||
|
||||
if (!isFragmentVisible) {
|
||||
|
@ -241,7 +243,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(medium.path)
|
||||
.load(getPathToLoad())
|
||||
.apply(options)
|
||||
.listener(object : RequestListener<Bitmap> {
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>?, isFirstResource: Boolean) = false
|
||||
|
@ -259,7 +261,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(medium.path)
|
||||
.load(getPathToLoad())
|
||||
.thumbnail(0.2f)
|
||||
.apply(options)
|
||||
.into(view.gif_view)
|
||||
|
@ -273,7 +275,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
maxScale = 10f
|
||||
beVisible()
|
||||
isQuickScaleEnabled = context.config.oneFingerZoom
|
||||
setImage(ImageSource.uri(medium.path))
|
||||
setImage(ImageSource.uri(getPathToLoad()))
|
||||
orientation = if (imageOrientation == -1) SubsamplingScaleImageView.ORIENTATION_USE_EXIF else degreesForRotation(imageOrientation)
|
||||
setEagerLoadingEnabled(false)
|
||||
setExecutor(AsyncTask.SERIAL_EXECUTOR)
|
||||
|
@ -308,6 +310,8 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getPathToLoad() = if (medium.path.startsWith(OTG_PATH)) medium.path.getOTGPublicPath(context!!) else medium.path
|
||||
|
||||
private fun getImageOrientation(): Int {
|
||||
val defaultOrientation = -1
|
||||
var orient = defaultOrientation
|
||||
|
|
|
@ -199,7 +199,7 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
|
||||
config.includedFolders.filter { it.isNotEmpty() && (curPath.isEmpty() || it == curPath) }.forEach {
|
||||
if (context.isPathOnOTG(it)) {
|
||||
if (it.startsWith(OTG_PATH)) {
|
||||
getMediaOnOTG(it, curMedia, isPickImage, isPickVideo, filterMedia)
|
||||
} else {
|
||||
getMediaInFolder(it, curMedia, isPickImage, isPickVideo, filterMedia)
|
||||
|
|
Loading…
Reference in a new issue