store Show All in shared prefs making it permanent
This commit is contained in:
parent
73cd9a5638
commit
6f11b05e25
|
@ -114,7 +114,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
|
|
||||||
private fun tryloadGallery() {
|
private fun tryloadGallery() {
|
||||||
if (hasStoragePermission()) {
|
if (hasStoragePermission()) {
|
||||||
getDirectories()
|
if (mConfig.showAll)
|
||||||
|
showAllMedia()
|
||||||
|
else
|
||||||
|
getDirectories()
|
||||||
} else {
|
} else {
|
||||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION)
|
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION)
|
||||||
}
|
}
|
||||||
|
@ -150,11 +153,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showAllMedia() {
|
private fun showAllMedia() {
|
||||||
|
mConfig.showAll = true
|
||||||
Intent(this, MediaActivity::class.java).apply {
|
Intent(this, MediaActivity::class.java).apply {
|
||||||
putExtra(DIRECTORY, "/")
|
putExtra(DIRECTORY, "/")
|
||||||
putExtra(SHOW_ALL, true)
|
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun prepareForDeleting(paths: ArrayList<String>) {
|
override fun prepareForDeleting(paths: ArrayList<String>) {
|
||||||
|
|
|
@ -57,7 +57,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
media_holder.setOnRefreshListener({ getMedia() })
|
media_holder.setOnRefreshListener({ getMedia() })
|
||||||
mPath = intent.getStringExtra(DIRECTORY)
|
mPath = intent.getStringExtra(DIRECTORY)
|
||||||
mMedia = ArrayList<Medium>()
|
mMedia = ArrayList<Medium>()
|
||||||
mShowAll = intent.getBooleanExtra(SHOW_ALL, false)
|
mShowAll = mConfig.showAll
|
||||||
|
if (mShowAll)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -103,6 +105,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
val isFolderHidden = mConfig.getIsFolderHidden(mPath)
|
val isFolderHidden = mConfig.getIsFolderHidden(mPath)
|
||||||
menu.findItem(R.id.hide_folder).isVisible = !isFolderHidden && !mShowAll
|
menu.findItem(R.id.hide_folder).isVisible = !isFolderHidden && !mShowAll
|
||||||
menu.findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll
|
menu.findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll
|
||||||
|
|
||||||
|
menu.findItem(R.id.folder_view).isVisible = mShowAll
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +121,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
toggleFilenameVisibility()
|
toggleFilenameVisibility()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.folder_view -> {
|
||||||
|
switchToFolderView()
|
||||||
|
true
|
||||||
|
}
|
||||||
R.id.hide_folder -> {
|
R.id.hide_folder -> {
|
||||||
hideFolder()
|
hideFolder()
|
||||||
true
|
true
|
||||||
|
@ -140,6 +149,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun switchToFolderView() {
|
||||||
|
mConfig.showAll = false
|
||||||
|
startActivity(Intent(this, MainActivity::class.java))
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
private fun hideFolder() {
|
private fun hideFolder() {
|
||||||
mConfig.addHiddenFolder(mPath)
|
mConfig.addHiddenFolder(mPath)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import com.simplemobiletools.gallery.fragments.ViewPagerFragment
|
||||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
||||||
import com.simplemobiletools.gallery.helpers.SHOW_ALL
|
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.activity_medium.*
|
import kotlinx.android.synthetic.main.activity_medium.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -67,7 +66,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mPath = intent.getStringExtra(MEDIUM)
|
mPath = intent.getStringExtra(MEDIUM)
|
||||||
mShowAll = intent.getBooleanExtra(SHOW_ALL, false)
|
mShowAll = mConfig.showAll
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPath.isEmpty()) {
|
if (mPath.isEmpty()) {
|
||||||
|
|
|
@ -43,6 +43,10 @@ class Config private constructor(context: Context) {
|
||||||
get() = mPrefs.getStringSet(PINNED_FOLDERS, HashSet<String>())
|
get() = mPrefs.getStringSet(PINNED_FOLDERS, HashSet<String>())
|
||||||
set(pinnedFolders) = mPrefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply()
|
set(pinnedFolders) = mPrefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply()
|
||||||
|
|
||||||
|
var showAll: Boolean
|
||||||
|
get() = mPrefs.getBoolean(SHOW_ALL, false)
|
||||||
|
set(showAll) = mPrefs.edit().putBoolean(SHOW_ALL, showAll).apply()
|
||||||
|
|
||||||
fun addPinnedFolders(paths: Set<String>) {
|
fun addPinnedFolders(paths: Set<String>) {
|
||||||
val currPinnedFolders = HashSet<String>(pinnedFolders)
|
val currPinnedFolders = HashSet<String>(pinnedFolders)
|
||||||
currPinnedFolders.addAll(paths)
|
currPinnedFolders.addAll(paths)
|
||||||
|
|
|
@ -13,6 +13,7 @@ val AUTOPLAY_VIDEOS = "autoplay_videos"
|
||||||
val TREE_URI = "tree_uri"
|
val TREE_URI = "tree_uri"
|
||||||
val DISPLAY_FILE_NAMES = "display_file_names"
|
val DISPLAY_FILE_NAMES = "display_file_names"
|
||||||
val PINNED_FOLDERS = "pinned_folders"
|
val PINNED_FOLDERS = "pinned_folders"
|
||||||
|
val SHOW_ALL = "show_all"
|
||||||
|
|
||||||
// sorting
|
// sorting
|
||||||
val SORT_BY_NAME = 1
|
val SORT_BY_NAME = 1
|
||||||
|
@ -26,7 +27,6 @@ val SORT_DESCENDING = 1024
|
||||||
val OPEN_DOCUMENT_TREE = 1000
|
val OPEN_DOCUMENT_TREE = 1000
|
||||||
|
|
||||||
val DIRECTORY = "directory"
|
val DIRECTORY = "directory"
|
||||||
val SHOW_ALL = "show_all"
|
|
||||||
val MEDIUM = "medium"
|
val MEDIUM = "medium"
|
||||||
val GET_IMAGE_INTENT = "get_image_intent"
|
val GET_IMAGE_INTENT = "get_image_intent"
|
||||||
val GET_VIDEO_INTENT = "get_video_intent"
|
val GET_VIDEO_INTENT = "get_video_intent"
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
android:icon="@mipmap/toggle_filename"
|
android:icon="@mipmap/toggle_filename"
|
||||||
android:title="@string/toggle_filename"
|
android:title="@string/toggle_filename"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/folder_view"
|
||||||
|
android:title="@string/folder_view"
|
||||||
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/hide_folder"
|
android:id="@+id/hide_folder"
|
||||||
android:title="@string/hide_folder"
|
android:title="@string/hide_folder"
|
||||||
|
|
Loading…
Reference in New Issue