mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
do not ask for authentication on every screen, at locked folders
This commit is contained in:
parent
a1e0d07798
commit
638dab9d97
4 changed files with 25 additions and 12 deletions
|
@ -835,6 +835,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
handleLockedFolderOpening(path) { success ->
|
handleLockedFolderOpening(path) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
Intent(this, MediaActivity::class.java).apply {
|
Intent(this, MediaActivity::class.java).apply {
|
||||||
|
putExtra(SKIP_AUTHENTICATION, true)
|
||||||
putExtra(DIRECTORY, path)
|
putExtra(DIRECTORY, path)
|
||||||
handleMediaIntent(this)
|
handleMediaIntent(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
media_empty_text_placeholder_2.setTextColor(getAdjustedPrimaryColor())
|
media_empty_text_placeholder_2.setTextColor(getAdjustedPrimaryColor())
|
||||||
|
|
||||||
if (mMedia.isEmpty() || config.getFolderSorting(mPath) and SORT_BY_RANDOM == 0) {
|
if (mMedia.isEmpty() || config.getFolderSorting(mPath) and SORT_BY_RANDOM == 0) {
|
||||||
|
if (shouldSkipAuthentication()) {
|
||||||
|
tryLoadGallery()
|
||||||
|
} else {
|
||||||
handleLockedFolderOpening(mPath) { success ->
|
handleLockedFolderOpening(mPath) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
tryLoadGallery()
|
tryLoadGallery()
|
||||||
|
@ -169,6 +172,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
@ -274,8 +278,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun startSlideshow() {
|
private fun startSlideshow() {
|
||||||
if (mMedia.isNotEmpty()) {
|
if (mMedia.isNotEmpty()) {
|
||||||
Intent(this, ViewPagerActivity::class.java).apply {
|
Intent(this, ViewPagerActivity::class.java).apply {
|
||||||
val item = mMedia.firstOrNull { it is Medium } as? Medium
|
val item = mMedia.firstOrNull { it is Medium } as? Medium ?: return
|
||||||
?: return
|
putExtra(SKIP_AUTHENTICATION, shouldSkipAuthentication())
|
||||||
putExtra(PATH, item.path)
|
putExtra(PATH, item.path)
|
||||||
putExtra(SHOW_ALL, mShowAll)
|
putExtra(SHOW_ALL, mShowAll)
|
||||||
putExtra(SLIDESHOW_START_ON_ENTER, true)
|
putExtra(SLIDESHOW_START_ON_ENTER, true)
|
||||||
|
@ -865,6 +869,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
openPath(path, false, extras)
|
openPath(path, false, extras)
|
||||||
} else {
|
} else {
|
||||||
Intent(this, ViewPagerActivity::class.java).apply {
|
Intent(this, ViewPagerActivity::class.java).apply {
|
||||||
|
putExtra(SKIP_AUTHENTICATION, shouldSkipAuthentication())
|
||||||
putExtra(PATH, path)
|
putExtra(PATH, path)
|
||||||
putExtra(SHOW_ALL, mShowAll)
|
putExtra(SHOW_ALL, mShowAll)
|
||||||
putExtra(SHOW_FAVORITES, mPath == FAVORITES)
|
putExtra(SHOW_FAVORITES, mPath == FAVORITES)
|
||||||
|
@ -932,6 +937,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun shouldSkipAuthentication() = intent.getBooleanExtra(SKIP_AUTHENTICATION, false)
|
||||||
|
|
||||||
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
|
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
|
||||||
deleteFiles(filtered) {
|
deleteFiles(filtered) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
|
|
|
@ -308,6 +308,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
showSystemUI(true)
|
showSystemUI(true)
|
||||||
|
|
||||||
|
if (intent.getBooleanExtra(SKIP_AUTHENTICATION, false)) {
|
||||||
|
initContinue()
|
||||||
|
} else {
|
||||||
handleLockedFolderOpening(mPath.getParentPath()) { success ->
|
handleLockedFolderOpening(mPath.getParentPath()) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
initContinue()
|
initContinue()
|
||||||
|
@ -316,6 +319,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initContinue() {
|
private fun initContinue() {
|
||||||
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
|
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
|
||||||
|
|
|
@ -132,6 +132,7 @@ const val IS_VIEW_INTENT = "is_view_intent"
|
||||||
const val PICKED_PATHS = "picked_paths"
|
const val PICKED_PATHS = "picked_paths"
|
||||||
const val SHOULD_INIT_FRAGMENT = "should_init_fragment"
|
const val SHOULD_INIT_FRAGMENT = "should_init_fragment"
|
||||||
const val PORTRAIT_PATH = "portrait_path"
|
const val PORTRAIT_PATH = "portrait_path"
|
||||||
|
const val SKIP_AUTHENTICATION = "skip_authentication"
|
||||||
|
|
||||||
// rotations
|
// rotations
|
||||||
const val ROTATE_BY_SYSTEM_SETTING = 0
|
const val ROTATE_BY_SYSTEM_SETTING = 0
|
||||||
|
|
Loading…
Reference in a new issue