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