mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
properly show third party image, even if its not in mediastore
This commit is contained in:
parent
c04f887229
commit
bc281dd102
5 changed files with 53 additions and 44 deletions
|
@ -116,6 +116,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
config.isThirdPartyIntent = false
|
||||||
if (mStoredAnimateGifs != config.animateGifs) {
|
if (mStoredAnimateGifs != config.animateGifs) {
|
||||||
directories_grid.adapter?.notifyDataSetChanged()
|
directories_grid.adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,11 +105,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.excludedFolders.map { "$it/" }.forEach {
|
config.isThirdPartyIntent = true
|
||||||
if (mPath.startsWith(it)) {
|
|
||||||
config.temporarilyShowExcluded = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showSystemUI()
|
showSystemUI()
|
||||||
|
@ -153,7 +149,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
|
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
|
||||||
config.temporarilyShowHidden = false
|
config.temporarilyShowHidden = false
|
||||||
}
|
}
|
||||||
config.temporarilyShowExcluded = false
|
|
||||||
|
if (config.isThirdPartyIntent) {
|
||||||
|
mMedia.clear()
|
||||||
|
config.isThirdPartyIntent = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrientationEventListener() {
|
private fun setupOrientationEventListener() {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import com.simplemobiletools.gallery.activities.SettingsActivity
|
||||||
import com.simplemobiletools.gallery.helpers.*
|
import com.simplemobiletools.gallery.helpers.*
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||||
val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
|
@ -72,10 +71,10 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
val config = context.config
|
val config = context.config
|
||||||
val filterMedia = config.filterMedia
|
val filterMedia = config.filterMedia
|
||||||
val showHidden = config.shouldShowHidden
|
val showHidden = config.shouldShowHidden
|
||||||
val showExcluded = config.temporarilyShowExcluded
|
|
||||||
val includedFolders = config.includedFolders.map { "$it/" }
|
val includedFolders = config.includedFolders.map { "$it/" }
|
||||||
val excludedFolders = config.excludedFolders.map { "$it/" }
|
val excludedFolders = config.excludedFolders.map { "$it/" }
|
||||||
val noMediaFolders = context.getNoMediaFolders()
|
val noMediaFolders = context.getNoMediaFolders()
|
||||||
|
val isThirdPartyIntent = config.isThirdPartyIntent
|
||||||
|
|
||||||
cur.use {
|
cur.use {
|
||||||
if (cur.moveToFirst()) {
|
if (cur.moveToFirst()) {
|
||||||
|
@ -138,7 +137,7 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
isExcluded = true
|
isExcluded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isExcluded || showExcluded) {
|
if (!isExcluded || isThirdPartyIntent) {
|
||||||
val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN)
|
val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN)
|
||||||
val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L
|
val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L
|
||||||
|
|
||||||
|
@ -152,8 +151,23 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.includedFolders.filter { it.isNotEmpty() && (curPath.isEmpty() || it == curPath) }.mapNotNull { File(it).listFiles() }.forEach {
|
config.includedFolders.filter { it.isNotEmpty() && (curPath.isEmpty() || it == curPath) }.forEach {
|
||||||
for (file in it) {
|
getMediaInFolder(it, curMedia, isPickImage, isPickVideo, filterMedia)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isThirdPartyIntent && curPath.isNotEmpty() && curMedia.isEmpty()) {
|
||||||
|
getMediaInFolder(curPath, curMedia, isPickImage, isPickVideo, filterMedia)
|
||||||
|
}
|
||||||
|
|
||||||
|
Medium.sorting = config.getFileSorting(curPath)
|
||||||
|
curMedia.sort()
|
||||||
|
|
||||||
|
return curMedia
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMediaInFolder(folder: String, curMedia: ArrayList<Medium>, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) {
|
||||||
|
val files = File(folder).listFiles() ?: return
|
||||||
|
for (file in files) {
|
||||||
val size = file.length()
|
val size = file.length()
|
||||||
if (size <= 0L) {
|
if (size <= 0L) {
|
||||||
continue
|
continue
|
||||||
|
@ -186,12 +200,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Medium.sorting = config.getFileSorting(curPath)
|
|
||||||
curMedia.sort()
|
|
||||||
|
|
||||||
return curMedia
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.getSortingForFolder(path: String): String {
|
fun Context.getSortingForFolder(path: String): String {
|
||||||
val sorting = config.getFileSorting(path)
|
val sorting = config.getFileSorting(path)
|
||||||
val sortValue = when {
|
val sortValue = when {
|
||||||
|
|
|
@ -54,9 +54,9 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
get() = prefs.getBoolean(TEMPORARILY_SHOW_HIDDEN, false)
|
get() = prefs.getBoolean(TEMPORARILY_SHOW_HIDDEN, false)
|
||||||
set(temporarilyShowHidden) = prefs.edit().putBoolean(TEMPORARILY_SHOW_HIDDEN, temporarilyShowHidden).apply()
|
set(temporarilyShowHidden) = prefs.edit().putBoolean(TEMPORARILY_SHOW_HIDDEN, temporarilyShowHidden).apply()
|
||||||
|
|
||||||
var temporarilyShowExcluded: Boolean
|
var isThirdPartyIntent: Boolean
|
||||||
get() = prefs.getBoolean(TEMPORARILY_SHOW_EXCLUDED, false)
|
get() = prefs.getBoolean(IS_THIRD_PARTY_INTENT, false)
|
||||||
set(temporarilyShowExcluded) = prefs.edit().putBoolean(TEMPORARILY_SHOW_EXCLUDED, temporarilyShowExcluded).apply()
|
set(isThirdPartyIntent) = prefs.edit().putBoolean(IS_THIRD_PARTY_INTENT, isThirdPartyIntent).apply()
|
||||||
|
|
||||||
var pinnedFolders: Set<String>
|
var pinnedFolders: Set<String>
|
||||||
get() = prefs.getStringSet(PINNED_FOLDERS, HashSet<String>())
|
get() = prefs.getStringSet(PINNED_FOLDERS, HashSet<String>())
|
||||||
|
|
|
@ -6,7 +6,7 @@ val DIRECTORY_SORT_ORDER = "directory_sort_order"
|
||||||
val SORT_FOLDER_PREFIX = "sort_folder_"
|
val SORT_FOLDER_PREFIX = "sort_folder_"
|
||||||
val SHOW_HIDDEN_MEDIA = "show_hidden_media"
|
val SHOW_HIDDEN_MEDIA = "show_hidden_media"
|
||||||
val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
|
val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
|
||||||
val TEMPORARILY_SHOW_EXCLUDED = "temporarily_show_excluded"
|
val IS_THIRD_PARTY_INTENT = "is_third_party_intent"
|
||||||
val AUTOPLAY_VIDEOS = "autoplay_videos"
|
val AUTOPLAY_VIDEOS = "autoplay_videos"
|
||||||
val LOOP_VIDEOS = "loop_videos"
|
val LOOP_VIDEOS = "loop_videos"
|
||||||
val ANIMATE_GIFS = "animate_gifs"
|
val ANIMATE_GIFS = "animate_gifs"
|
||||||
|
|
Loading…
Reference in a new issue