From adf02739fe18719997ae779d31b3b284d79cc4cf Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 10:19:10 +0100 Subject: [PATCH] implement Back navigation at direct subfolder grouping --- .../gallery/pro/activities/MainActivity.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 778c07f3e..5fd3f08be 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -67,7 +67,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private var mIsSearchOpen = false private var mLatestMediaId = 0L private var mLatestMediaDateId = 0L - private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation + private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation + private var mOpenedSubfolders = arrayListOf("") // used at "Group direct subfolders" for navigating Up with the back button private var mLastMediaHandler = Handler() private var mTempShowHiddenHandler = Handler() private var mZoomListener: MyRecyclerView.MyZoomListener? = null @@ -243,6 +244,20 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } + override fun onBackPressed() { + if (config.groupDirectSubfolders) { + if (mCurrentPathPrefix.isEmpty()) { + super.onBackPressed() + } else { + mOpenedSubfolders.removeAt(mOpenedSubfolders.size - 1) + mCurrentPathPrefix = mOpenedSubfolders.last() + setupAdapter(mDirs) + } + } else { + super.onBackPressed() + } + } + override fun onCreateOptionsMenu(menu: Menu): Boolean { if (mIsThirdPartyIntent) { menuInflater.inflate(R.menu.menu_main_intent, menu) @@ -1064,6 +1079,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } else { mCurrentPathPrefix = path + mOpenedSubfolders.add(path) setupAdapter(mDirs, "") } }.apply {