mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
store the new folder path in shared prefs, so its more accessible
This commit is contained in:
parent
551fc3a1c6
commit
189f9b7410
3 changed files with 13 additions and 6 deletions
|
@ -57,7 +57,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private var mLoadedInitialPhotos = false
|
private var mLoadedInitialPhotos = false
|
||||||
private var mLastMediaModified = 0
|
private var mLastMediaModified = 0
|
||||||
private var mLastMediaHandler = Handler()
|
private var mLastMediaHandler = Handler()
|
||||||
private var mNewFolderPath = ""
|
|
||||||
|
|
||||||
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
||||||
|
|
||||||
|
@ -74,6 +73,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent ||
|
mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent ||
|
||||||
mIsGetAnyContentIntent || mIsSetWallpaperIntent
|
mIsGetAnyContentIntent || mIsSetWallpaperIntent
|
||||||
|
|
||||||
|
config.tempFolderPath = ""
|
||||||
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
|
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
|
||||||
mDirs = ArrayList()
|
mDirs = ArrayList()
|
||||||
mStoredAnimateGifs = config.animateGifs
|
mStoredAnimateGifs = config.animateGifs
|
||||||
|
@ -160,12 +160,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
config.temporarilyShowHidden = false
|
config.temporarilyShowHidden = false
|
||||||
|
|
||||||
val newFolder = File(mNewFolderPath)
|
val newFolder = File(config.tempFolderPath)
|
||||||
if (newFolder.exists() && newFolder.isDirectory) {
|
if (newFolder.exists() && newFolder.isDirectory) {
|
||||||
if (newFolder.list()?.isEmpty() == true) {
|
if (newFolder.list()?.isEmpty() == true) {
|
||||||
deleteFileBg(newFolder, true) { }
|
deleteFileBg(newFolder, true) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config.tempFolderPath = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryloadGallery() {
|
private fun tryloadGallery() {
|
||||||
|
@ -314,7 +315,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun createNewFolder() {
|
private fun createNewFolder() {
|
||||||
FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) {
|
FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) {
|
||||||
CreateNewFolderDialog(this, it) {
|
CreateNewFolderDialog(this, it) {
|
||||||
mNewFolderPath = it
|
config.tempFolderPath = it
|
||||||
addTempFolderIfNeeded(mDirs, true)
|
addTempFolderIfNeeded(mDirs, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,8 +323,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
|
|
||||||
private fun addTempFolderIfNeeded(dirs: ArrayList<Directory>, isFromCache: Boolean) {
|
private fun addTempFolderIfNeeded(dirs: ArrayList<Directory>, isFromCache: Boolean) {
|
||||||
val directories = ArrayList<Directory>()
|
val directories = ArrayList<Directory>()
|
||||||
if (mNewFolderPath.isNotEmpty()) {
|
val tempFolderPath = config.tempFolderPath
|
||||||
val newFolder = Directory(mNewFolderPath, "", mNewFolderPath.getFilenameFromPath(), 0, 0, 0, 0L)
|
if (tempFolderPath.isNotEmpty()) {
|
||||||
|
val newFolder = Directory(tempFolderPath, "", tempFolderPath.getFilenameFromPath(), 0, 0, 0, 0L)
|
||||||
directories.add(newFolder)
|
directories.add(newFolder)
|
||||||
}
|
}
|
||||||
directories.addAll(dirs)
|
directories.addAll(dirs)
|
||||||
|
@ -449,7 +451,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeDirectories() {
|
private fun storeDirectories() {
|
||||||
if (!config.temporarilyShowHidden && mNewFolderPath.isEmpty()) {
|
if (!config.temporarilyShowHidden && config.tempFolderPath.isEmpty()) {
|
||||||
val directories = Gson().toJson(mDirs)
|
val directories = Gson().toJson(mDirs)
|
||||||
config.directories = directories
|
config.directories = directories
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,4 +276,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
var loopSlideshow: Boolean
|
var loopSlideshow: Boolean
|
||||||
get() = prefs.getBoolean(SLIDESHOW_LOOP, false)
|
get() = prefs.getBoolean(SLIDESHOW_LOOP, false)
|
||||||
set(loopSlideshow) = prefs.edit().putBoolean(SLIDESHOW_LOOP, loopSlideshow).apply()
|
set(loopSlideshow) = prefs.edit().putBoolean(SLIDESHOW_LOOP, loopSlideshow).apply()
|
||||||
|
|
||||||
|
var tempFolderPath: String
|
||||||
|
get() = prefs.getString(TEMP_FOLDER_PATH, "")
|
||||||
|
set(tempFolderPath) = prefs.edit().putString(TEMP_FOLDER_PATH, tempFolderPath).apply()
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ val HIDE_SYSTEM_UI = "hide_system_ui"
|
||||||
val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate"
|
val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate"
|
||||||
val DELETE_EMPTY_FOLDERS = "delete_empty_folders"
|
val DELETE_EMPTY_FOLDERS = "delete_empty_folders"
|
||||||
val ALLOW_VIDEO_GESTURES = "allow_video_gestures"
|
val ALLOW_VIDEO_GESTURES = "allow_video_gestures"
|
||||||
|
val TEMP_FOLDER_PATH = "temp_folder_path"
|
||||||
|
|
||||||
// slideshow
|
// slideshow
|
||||||
val SLIDESHOW_INTERVAL = "slideshow_interval"
|
val SLIDESHOW_INTERVAL = "slideshow_interval"
|
||||||
|
|
Loading…
Reference in a new issue