adding some OTG related changes
This commit is contained in:
parent
277b54ce32
commit
3624091994
14 changed files with 33 additions and 51 deletions
|
@ -61,7 +61,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.7.13'
|
implementation 'com.simplemobiletools:commons:5.7.17'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -26,7 +26,6 @@ import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||||
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.helpers.isNougatPlus
|
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||||
|
@ -148,7 +147,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
||||||
val realPath = intent.extras.getString(REAL_FILE_PATH)
|
val realPath = intent.extras.getString(REAL_FILE_PATH)
|
||||||
uri = when {
|
uri = when {
|
||||||
realPath.startsWith(OTG_PATH) -> uri
|
isPathOnOTG(realPath) -> uri
|
||||||
realPath.startsWith("file:/") -> Uri.parse(realPath)
|
realPath.startsWith("file:/") -> Uri.parse(realPath)
|
||||||
else -> Uri.fromFile(File(realPath))
|
else -> Uri.fromFile(File(realPath))
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,7 +377,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
ConfirmationDialog(this, getString(R.string.usb_detected), positive = R.string.ok, negative = 0) {
|
ConfirmationDialog(this, getString(R.string.usb_detected), positive = R.string.ok, negative = 0) {
|
||||||
handleOTGPermission {
|
handleOTGPermission {
|
||||||
config.addIncludedFolder(OTG_PATH)
|
if (config.OTGPartition.isNotEmpty()) {
|
||||||
|
config.addIncludedFolder(config.OTGPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -943,13 +945,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
private fun createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
|
private fun createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
|
||||||
includedFolders: MutableSet<String>, isSortingAscending: Boolean): Directory {
|
includedFolders: MutableSet<String>, isSortingAscending: Boolean): Directory {
|
||||||
var thumbnail = curMedia.firstOrNull { getDoesFilePathExist(it.path) }?.path ?: ""
|
var thumbnail = curMedia.firstOrNull { File(it.path).exists() }?.path ?: ""
|
||||||
if (thumbnail.startsWith(OTG_PATH)) {
|
|
||||||
thumbnail = thumbnail.getOTGPublicPath(applicationContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
albumCovers.forEach {
|
albumCovers.forEach {
|
||||||
if (it.path == path && getDoesFilePathExist(it.tmb)) {
|
if (it.path == path && File(it.tmb).exists()) {
|
||||||
thumbnail = it.tmb
|
thumbnail = it.tmb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,10 +1031,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private fun checkInvalidDirectories(dirs: ArrayList<Directory>) {
|
private fun checkInvalidDirectories(dirs: ArrayList<Directory>) {
|
||||||
val invalidDirs = ArrayList<Directory>()
|
val invalidDirs = ArrayList<Directory>()
|
||||||
dirs.filter { !it.areFavorites() && !it.isRecycleBin() }.forEach {
|
dirs.filter { !it.areFavorites() && !it.isRecycleBin() }.forEach {
|
||||||
if (!getDoesFilePathExist(it.path)) {
|
if (!File(it.path).exists()) {
|
||||||
invalidDirs.add(it)
|
invalidDirs.add(it)
|
||||||
} else if (it.path != config.tempFolderPath) {
|
} else if (it.path != config.tempFolderPath) {
|
||||||
val children = if (it.path.startsWith(OTG_PATH)) getOTGFolderChildrenNames(it.path) else File(it.path).list()?.asList()
|
val children = if (isPathOnOTG(it.path)) getOTGFolderChildrenNames(it.path) else File(it.path).list()?.asList()
|
||||||
val hasMediaFile = children?.any { it?.isMediaFile() == true } ?: false
|
val hasMediaFile = children?.any { it?.isMediaFile() == true } ?: false
|
||||||
if (!hasMediaFile) {
|
if (!hasMediaFile) {
|
||||||
invalidDirs.add(it)
|
invalidDirs.add(it)
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.bumptech.glide.request.target.SimpleTarget
|
||||||
import com.bumptech.glide.request.transition.Transition
|
import com.bumptech.glide.request.transition.Transition
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
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.REQUEST_EDIT_IMAGE
|
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
@ -339,8 +338,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
val dirName = when {
|
val dirName = when {
|
||||||
mPath == FAVORITES -> getString(R.string.favorites)
|
mPath == FAVORITES -> getString(R.string.favorites)
|
||||||
mPath == RECYCLE_BIN -> getString(R.string.recycle_bin)
|
mPath == RECYCLE_BIN -> getString(R.string.recycle_bin)
|
||||||
mPath == OTG_PATH -> getString(R.string.usb)
|
mPath == config.OTGPath -> getString(R.string.usb)
|
||||||
mPath.startsWith(OTG_PATH) -> mPath.trimEnd('/').substringAfterLast('/')
|
|
||||||
else -> getHumanizedFilename(mPath)
|
else -> getHumanizedFilename(mPath)
|
||||||
}
|
}
|
||||||
updateActionBarTitle(if (mShowAll) resources.getString(R.string.all_folders) else dirName)
|
updateActionBarTitle(if (mShowAll) resources.getString(R.string.all_folders) else dirName)
|
||||||
|
|
|
@ -243,7 +243,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getDoesFilePathExist(mPath)) {
|
if (!File(mPath).exists()) {
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -267,9 +267,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
isShowingRecycleBin -> RECYCLE_BIN
|
isShowingRecycleBin -> RECYCLE_BIN
|
||||||
else -> mPath.getParentPath()
|
else -> mPath.getParentPath()
|
||||||
}
|
}
|
||||||
if (mDirectory.startsWith(OTG_PATH.trimEnd('/'))) {
|
|
||||||
mDirectory += "/"
|
|
||||||
}
|
|
||||||
supportActionBar?.title = mPath.getFilenameFromPath()
|
supportActionBar?.title = mPath.getFilenameFromPath()
|
||||||
|
|
||||||
view_pager.onGlobalLayout {
|
view_pager.onGlobalLayout {
|
||||||
|
@ -867,7 +864,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun deleteConfirmed() {
|
private fun deleteConfirmed() {
|
||||||
val path = getCurrentMedia().getOrNull(mPos)?.path ?: return
|
val path = getCurrentMedia().getOrNull(mPos)?.path ?: return
|
||||||
if (getIsPathDirectory(path) || !path.isMediaFile()) {
|
if (File(path).isDirectory || !path.isMediaFile()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +956,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteDirectoryIfEmpty() {
|
private fun deleteDirectoryIfEmpty() {
|
||||||
val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), getIsPathDirectory(mDirectory))
|
val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory)
|
||||||
if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory && fileDirItem.getProperFileCount(applicationContext, true) == 0) {
|
if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory && fileDirItem.getProperFileCount(applicationContext, true) == 0) {
|
||||||
tryDeleteFileDirItem(fileDirItem, true, true)
|
tryDeleteFileDirItem(fileDirItem, true, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemsDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemsDialog
|
||||||
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
|
||||||
|
@ -321,12 +320,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
val paths = ArrayList<String>()
|
val paths = ArrayList<String>()
|
||||||
val showHidden = activity.config.shouldShowHidden
|
val showHidden = activity.config.shouldShowHidden
|
||||||
getSelectedPaths().forEach {
|
getSelectedPaths().forEach {
|
||||||
if (it.startsWith(OTG_PATH)) {
|
if (activity.isPathOnOTG(it)) {
|
||||||
paths.addAll(getOTGFilePaths(it, showHidden))
|
paths.addAll(getOTGFilePaths(it, showHidden))
|
||||||
} else if (it != FAVORITES) {
|
} else if (it != FAVORITES) {
|
||||||
val filter = config.filterMedia
|
val filter = config.filterMedia
|
||||||
File(it).listFiles()?.filter {
|
File(it).listFiles()?.filter {
|
||||||
!activity.getIsPathDirectory(it.absolutePath) &&
|
!File(it.absolutePath).isDirectory &&
|
||||||
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
|
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
|
||||||
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
|
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
|
||||||
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
|
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
|
||||||
|
@ -358,7 +357,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
(it.name!!.isSvg() && filter and TYPE_SVGS != 0))
|
(it.name!!.isSvg() && filter and TYPE_SVGS != 0))
|
||||||
) {
|
) {
|
||||||
val relativePath = it.uri.path.substringAfterLast("${activity.config.OTGPartition}:")
|
val relativePath = it.uri.path.substringAfterLast("${activity.config.OTGPartition}:")
|
||||||
paths.add("$OTG_PATH$relativePath")
|
paths.add("${config.OTGPath}/$relativePath")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return paths
|
return paths
|
||||||
|
|
|
@ -13,7 +13,6 @@ import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemsDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemsDialog
|
||||||
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
|
||||||
|
@ -457,7 +456,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = medium.path
|
var path = medium.path
|
||||||
if (hasOTGConnected && path.startsWith(OTG_PATH)) {
|
if (hasOTGConnected && context.isPathOnOTG(path)) {
|
||||||
path = path.getOTGPublicPath(context)
|
path = path.getOTGPublicPath(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
|
class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getDoesFilePathExist(newPath)) {
|
if (File(newPath).exists()) {
|
||||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
||||||
ConfirmationDialog(activity, title) {
|
ConfirmationDialog(activity, title) {
|
||||||
callback(newPath)
|
callback(newPath)
|
||||||
|
|
|
@ -406,7 +406,7 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String,
|
||||||
saveFile(tmpPath, bitmap, it as FileOutputStream, newDegrees)
|
saveFile(tmpPath, bitmap, it as FileOutputStream, newDegrees)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDoesFilePathExist(newPath)) {
|
if (File(newPath).exists()) {
|
||||||
tryDeleteFileDirItem(FileDirItem(newPath, newPath.getFilenameFromPath()), false, true)
|
tryDeleteFileDirItem(FileDirItem(newPath, newPath.getFilenameFromPath()), false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,16 +374,10 @@ fun Context.getFolderNameFromPath(path: String): String {
|
||||||
return when (path) {
|
return when (path) {
|
||||||
internalStoragePath -> getString(R.string.internal)
|
internalStoragePath -> getString(R.string.internal)
|
||||||
sdCardPath -> getString(R.string.sd_card)
|
sdCardPath -> getString(R.string.sd_card)
|
||||||
OTG_PATH -> getString(R.string.usb)
|
otgPath -> getString(R.string.usb)
|
||||||
FAVORITES -> getString(R.string.favorites)
|
FAVORITES -> getString(R.string.favorites)
|
||||||
RECYCLE_BIN -> getString(R.string.recycle_bin)
|
RECYCLE_BIN -> getString(R.string.recycle_bin)
|
||||||
else -> {
|
else -> path.getFilenameFromPath()
|
||||||
if (path.startsWith(OTG_PATH)) {
|
|
||||||
path.trimEnd('/').substringAfterLast('/')
|
|
||||||
} else {
|
|
||||||
path.getFilenameFromPath()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +425,7 @@ fun Context.addTempFolderIfNeeded(dirs: ArrayList<Directory>): ArrayList<Directo
|
||||||
fun Context.getPathLocation(path: String): Int {
|
fun Context.getPathLocation(path: String): Int {
|
||||||
return when {
|
return when {
|
||||||
isPathOnSD(path) -> LOCATION_SD
|
isPathOnSD(path) -> LOCATION_SD
|
||||||
path.startsWith(OTG_PATH) -> LOCATION_OTG
|
isPathOnOTG(path) -> LOCATION_OTG
|
||||||
else -> LOCAITON_INTERNAL
|
else -> LOCAITON_INTERNAL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +565,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
||||||
callback(grouped.clone() as ArrayList<ThumbnailItem>)
|
callback(grouped.clone() as ArrayList<ThumbnailItem>)
|
||||||
|
|
||||||
val mediaToDelete = ArrayList<Medium>()
|
val mediaToDelete = ArrayList<Medium>()
|
||||||
media.filter { !getDoesFilePathExist(it.path) }.forEach {
|
media.filter { !File(it.path).exists() }.forEach {
|
||||||
if (it.path.startsWith(recycleBinPath)) {
|
if (it.path.startsWith(recycleBinPath)) {
|
||||||
deleteDBPath(mediumDao, it.path)
|
deleteDBPath(mediumDao, it.path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -585,7 +579,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
||||||
|
|
||||||
fun Context.removeInvalidDBDirectories(dirs: ArrayList<Directory>? = null, directoryDao: DirectoryDao = galleryDB.DirectoryDao()) {
|
fun Context.removeInvalidDBDirectories(dirs: ArrayList<Directory>? = null, directoryDao: DirectoryDao = galleryDB.DirectoryDao()) {
|
||||||
val dirsToCheck = dirs ?: directoryDao.getAll()
|
val dirsToCheck = dirs ?: directoryDao.getAll()
|
||||||
dirsToCheck.filter { !it.areFavorites() && !it.isRecycleBin() && !getDoesFilePathExist(it.path) && it.path != config.tempFolderPath }.forEach {
|
dirsToCheck.filter { !it.areFavorites() && !it.isRecycleBin() && !File(it.path).exists() && it.path != config.tempFolderPath }.forEach {
|
||||||
directoryDao.deleteDirPath(it.path)
|
directoryDao.deleteDirPath(it.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPath
|
||||||
// recognize /sdcard/DCIM as the same folder as /storage/emulated/0/DCIM
|
// recognize /sdcard/DCIM as the same folder as /storage/emulated/0/DCIM
|
||||||
fun String.getDistinctPath(): String {
|
fun String.getDistinctPath(): String {
|
||||||
return try {
|
return try {
|
||||||
if (startsWith(OTG_PATH)) toLowerCase() else File(this).canonicalPath.toLowerCase()
|
File(this).canonicalPath.toLowerCase()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
toLowerCase()
|
toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import com.davemorrissey.labs.subscaleview.ImageRegionDecoder
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity
|
import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity
|
||||||
import com.simplemobiletools.gallery.pro.activities.PhotoActivity
|
import com.simplemobiletools.gallery.pro.activities.PhotoActivity
|
||||||
|
@ -529,7 +528,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val exif = android.media.ExifInterface(pathToLoad)
|
val exif = android.media.ExifInterface(pathToLoad)
|
||||||
orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
||||||
|
|
||||||
if (orient == defaultOrientation || mMedium.path.startsWith(OTG_PATH)) {
|
if (orient == defaultOrientation || context!!.isPathOnOTG(mMedium.path)) {
|
||||||
val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad))
|
val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad))
|
||||||
val inputStream = context!!.contentResolver.openInputStream(uri)
|
val inputStream = context!!.contentResolver.openInputStream(uri)
|
||||||
val exif2 = ExifInterface()
|
val exif2 = ExifInterface()
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.provider.MediaStore
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
|
@ -77,7 +76,7 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
return details.toString().trim()
|
return details.toString().trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPathToLoad(medium: Medium) = if (medium.path.startsWith(OTG_PATH)) medium.path.getOTGPublicPath(context!!) else medium.path
|
fun getPathToLoad(medium: Medium) = medium.path //if (context!!.isPathOnOTG(medium.path)) medium.path.getOTGPublicPath(context!!) else medium.path
|
||||||
|
|
||||||
private fun getFileLastModified(file: File): String {
|
private fun getFileLastModified(file: File): String {
|
||||||
val projection = arrayOf(MediaStore.Images.Media.DATE_MODIFIED)
|
val projection = arrayOf(MediaStore.Images.Media.DATE_MODIFIED)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MediaFetcher(val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
val curMedia = ArrayList<Medium>()
|
val curMedia = ArrayList<Medium>()
|
||||||
if (curPath.startsWith(OTG_PATH, true)) {
|
if (context.isPathOnOTG(curPath)) {
|
||||||
if (context.hasOTGConnected()) {
|
if (context.hasOTGConnected()) {
|
||||||
val newMedia = getMediaOnOTG(curPath, isPickImage, isPickVideo, filterMedia, favoritePaths, getVideoDurations)
|
val newMedia = getMediaOnOTG(curPath, isPickImage, isPickVideo, filterMedia, favoritePaths, getVideoDurations)
|
||||||
curMedia.addAll(newMedia)
|
curMedia.addAll(newMedia)
|
||||||
|
@ -128,7 +128,7 @@ class MediaFetcher(val context: Context) {
|
||||||
val foldersToIgnore = arrayListOf("/storage/emulated/legacy")
|
val foldersToIgnore = arrayListOf("/storage/emulated/legacy")
|
||||||
val config = context.config
|
val config = context.config
|
||||||
val includedFolders = config.includedFolders
|
val includedFolders = config.includedFolders
|
||||||
var foldersToScan = config.everShownFolders.filter { it == FAVORITES || it == RECYCLE_BIN || context.getDoesFilePathExist(it) }.toMutableList() as ArrayList
|
var foldersToScan = config.everShownFolders.filter { it == FAVORITES || it == RECYCLE_BIN || File(it).exists() }.toMutableList() as ArrayList
|
||||||
|
|
||||||
cursor.use {
|
cursor.use {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
|
@ -154,12 +154,12 @@ class MediaFetcher(val context: Context) {
|
||||||
|
|
||||||
private fun addFolder(curFolders: ArrayList<String>, folder: String) {
|
private fun addFolder(curFolders: ArrayList<String>, folder: String) {
|
||||||
curFolders.add(folder)
|
curFolders.add(folder)
|
||||||
if (folder.startsWith(OTG_PATH)) {
|
if (context.isPathOnOTG(folder)) {
|
||||||
val files = context.getOTGFolderChildren(folder) ?: return
|
val files = context.getOTGFolderChildren(folder) ?: return
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
if (file.isDirectory) {
|
if (file.isDirectory) {
|
||||||
val relativePath = file.uri.path.substringAfterLast("${context.config.OTGPartition}:")
|
val relativePath = file.uri.path.substringAfterLast("${context.config.OTGPartition}:")
|
||||||
addFolder(curFolders, "$OTG_PATH$relativePath")
|
addFolder(curFolders, "${context.config.OTGPath}/$relativePath")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -314,7 +314,7 @@ class MediaFetcher(val context: Context) {
|
||||||
else -> TYPE_IMAGES
|
else -> TYPE_IMAGES
|
||||||
}
|
}
|
||||||
|
|
||||||
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", OTG_PATH))
|
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", context.config.OTGPath))
|
||||||
val videoDuration = if (getVideoDurations) path.getVideoDuration() else 0
|
val videoDuration = if (getVideoDurations) path.getVideoDuration() else 0
|
||||||
val isFavorite = favoritePaths.contains(path)
|
val isFavorite = favoritePaths.contains(path)
|
||||||
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, videoDuration, isFavorite, 0L)
|
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, videoDuration, isFavorite, 0L)
|
||||||
|
|
Loading…
Reference in a new issue