store media parent paths too
This commit is contained in:
parent
ce4ee915bb
commit
73000aa611
|
@ -47,7 +47,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.19.4'
|
||||
implementation 'com.simplemobiletools:commons:3.19.5'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
|
|
|
@ -90,7 +90,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
else -> TYPE_GIF
|
||||
}
|
||||
|
||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), 0, 0, file.length(), type)
|
||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type)
|
||||
supportActionBar?.title = mMedium!!.name
|
||||
bundle.putSerializable(MEDIUM, mMedium)
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
showSystemUI()
|
||||
|
||||
mDirectory = mPath.getParentPath().trimEnd('/')
|
||||
mDirectory = mPath.getParentPath()
|
||||
if (mDirectory.startsWith(OTG_PATH.trimEnd('/'))) {
|
||||
mDirectory += "/"
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
private fun updateStoredFolderItems() {
|
||||
Thread {
|
||||
if (media.isNotEmpty()) {
|
||||
activity.applicationContext.storeFolderItems(media.first().path.getParentPath().trimEnd('/'), media as ArrayList<Medium>)
|
||||
activity.applicationContext.storeFolderItems(media.first().parentPath, media as ArrayList<Medium>)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
|||
val firstItem = curMedia.first()
|
||||
val lastItem = curMedia.last()
|
||||
val parentDir = if (hasOTG && firstItem.path.startsWith(OTG_PATH)) {
|
||||
firstItem.path.getParentPath()
|
||||
firstItem.parentPath
|
||||
} else {
|
||||
File(firstItem.path).parent
|
||||
} ?: continue
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.io.File
|
|||
class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
|
||||
|
||||
init {
|
||||
var realPath = path.getParentPath().trimEnd('/')
|
||||
var realPath = path.getParentPath()
|
||||
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
||||
save_as_path.text = activity.humanizePath(realPath)
|
||||
|
|
|
@ -172,8 +172,7 @@ class MediaFetcher(val context: Context) {
|
|||
break
|
||||
}
|
||||
|
||||
val parentDir = (if (hasOTG && medium.path.startsWith(OTG_PATH)) medium.path.getParentPath().toLowerCase() else File(medium.path).parent?.toLowerCase())
|
||||
?: continue
|
||||
val parentDir = medium.parentPath.toLowerCase()
|
||||
if (directories.containsKey(parentDir)) {
|
||||
directories[parentDir]!!.add(medium)
|
||||
} else {
|
||||
|
@ -247,7 +246,8 @@ class MediaFetcher(val context: Context) {
|
|||
else -> TYPE_GIF
|
||||
}
|
||||
|
||||
val medium = Medium(null, filename, file.absolutePath, dateModified, dateTaken, size, type)
|
||||
val parentPath = file.absolutePath.removeSuffix("/")
|
||||
val medium = Medium(null, filename, file.absolutePath, folder, dateModified, dateTaken, size, type)
|
||||
curMedia.add(medium)
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
|
||||
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGBasePath}%3A", OTG_PATH))
|
||||
val medium = Medium(null, filename, path, dateModified, dateTaken, size, type)
|
||||
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type)
|
||||
curMedia.add(medium)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.simplemobiletools.gallery.models.Directory
|
|||
|
||||
@Dao
|
||||
interface DirectoryDao {
|
||||
@Query("SELECT * from directories")
|
||||
@Query("SELECT * FROM directories")
|
||||
fun getAll(): List<Directory>
|
||||
|
||||
@Insert(onConflict = REPLACE)
|
||||
|
|
|
@ -8,9 +8,12 @@ import com.simplemobiletools.gallery.models.Medium
|
|||
|
||||
@Dao
|
||||
interface MediumDao {
|
||||
@Query("SELECT * from media")
|
||||
@Query("SELECT * FROM media")
|
||||
fun getAll(): List<Medium>
|
||||
|
||||
@Query("SELECT * FROM media WHERE parent_path = :path")
|
||||
fun getMediaFromPath(path: String): List<Medium>
|
||||
|
||||
@Insert(onConflict = REPLACE)
|
||||
fun insert(medium: Medium)
|
||||
|
||||
|
|
|
@ -13,11 +13,12 @@ import com.simplemobiletools.gallery.helpers.TYPE_IMAGE
|
|||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEO
|
||||
import java.io.Serializable
|
||||
|
||||
@Entity(tableName = "media", indices = [(Index(value = "path", unique = true))])
|
||||
@Entity(tableName = "media", indices = [(Index(value = "full_path", unique = true))])
|
||||
data class Medium(
|
||||
@PrimaryKey(autoGenerate = true) var id: Long?,
|
||||
@ColumnInfo(name = "filename") var name: String,
|
||||
@ColumnInfo(name = "path") var path: String,
|
||||
@ColumnInfo(name = "full_path") var path: String,
|
||||
@ColumnInfo(name = "parent_path") var parentPath: String,
|
||||
@ColumnInfo(name = "last_modified") val modified: Long,
|
||||
@ColumnInfo(name = "date_taken") val taken: Long,
|
||||
@ColumnInfo(name = "size") val size: Long,
|
||||
|
|
Loading…
Reference in New Issue