diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt
index 5abe06cab..6cdc8cd61 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/FileDatabaseSelectActivity.kt
@@ -157,7 +157,7 @@ class FileDatabaseSelectActivity : StylishActivity(),
UriUtil.parse(databasePath)?.let { databaseFileUri ->
launchPasswordActivityWithPath(databaseFileUri)
} ?: run {
- Log.i(TAG, "Unable to launch Password Activity")
+ Log.i(TAG, "No default database to prepare")
}
}
@@ -269,37 +269,37 @@ class FileDatabaseSelectActivity : StylishActivity(),
}
override fun onResume() {
+ super.onResume()
+
val database = Database.getInstance()
if (database.loaded) {
launchGroupActivity(database.isReadOnly)
- }
-
- super.onResume()
-
- // Construct adapter with listeners
- if (PreferencesUtil.showRecentFiles(this)) {
- mFileDatabaseHistoryAction?.getAllFileDatabaseHistories { databaseFileHistoryList ->
- databaseFileHistoryList?.let { historyList ->
- val hideBrokenLocations = PreferencesUtil.hideBrokenLocations(this@FileDatabaseSelectActivity)
- mAdapterDatabaseHistory?.addDatabaseFileHistoryList(
- // Show only uri accessible
- historyList.filter {
- if (hideBrokenLocations) {
- FileDatabaseInfo(this@FileDatabaseSelectActivity,
- it.databaseUri).exists
- } else
- true
- })
- mAdapterDatabaseHistory?.notifyDataSetChanged()
- }
- }
} else {
- mAdapterDatabaseHistory?.clearDatabaseFileHistoryList()
- mAdapterDatabaseHistory?.notifyDataSetChanged()
- }
+ // Construct adapter with listeners
+ if (PreferencesUtil.showRecentFiles(this)) {
+ mFileDatabaseHistoryAction?.getAllFileDatabaseHistories { databaseFileHistoryList ->
+ databaseFileHistoryList?.let { historyList ->
+ val hideBrokenLocations = PreferencesUtil.hideBrokenLocations(this@FileDatabaseSelectActivity)
+ mAdapterDatabaseHistory?.addDatabaseFileHistoryList(
+ // Show only uri accessible
+ historyList.filter {
+ if (hideBrokenLocations) {
+ FileDatabaseInfo(this@FileDatabaseSelectActivity,
+ it.databaseUri).exists
+ } else
+ true
+ })
+ mAdapterDatabaseHistory?.notifyDataSetChanged()
+ }
+ }
+ } else {
+ mAdapterDatabaseHistory?.clearDatabaseFileHistoryList()
+ mAdapterDatabaseHistory?.notifyDataSetChanged()
+ }
- // Register progress task
- mProgressDialogThread?.registerProgressTask()
+ // Register progress task
+ mProgressDialogThread?.registerProgressTask()
+ }
}
override fun onPause() {
diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt
index 7952b8474..bd88a4622 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/GroupActivity.kt
@@ -32,6 +32,7 @@ import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View
+import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi
@@ -97,7 +98,8 @@ class GroupActivity : LockingActivity(),
private var toolbarAction: ToolbarAction? = null
private var iconView: ImageView? = null
private var numberChildrenView: TextView? = null
- private var modeTitleView: TextView? = null
+ private var modeContainerView: View? = null
+ private var modeCancelButton: Button? = null
private var addNodeButtonView: AddNodeButtonView? = null
private var groupNameView: TextView? = null
@@ -107,6 +109,9 @@ class GroupActivity : LockingActivity(),
private var mCurrentGroupIsASearch: Boolean = false
private var mRequestStartupSearch = true
+ // To manage history in selection mode
+ private var mSelectionModeCountBackStack = 0
+
// Nodes
private var mRootGroup: Group? = null
private var mCurrentGroup: Group? = null
@@ -136,7 +141,8 @@ class GroupActivity : LockingActivity(),
searchTitleView = findViewById(R.id.search_title)
groupNameView = findViewById(R.id.group_name)
toolbarAction = findViewById(R.id.toolbar_action)
- modeTitleView = findViewById(R.id.mode_title_view)
+ modeContainerView = findViewById(R.id.mode_container)
+ modeCancelButton = findViewById(R.id.mode_cancel_button)
lockView = findViewById(R.id.lock_button)
lockView?.setOnClickListener {
@@ -354,6 +360,9 @@ class GroupActivity : LockingActivity(),
fragmentTransaction.addToBackStack(fragmentTag)
fragmentTransaction.commit()
+ if (mSelectionMode)
+ mSelectionModeCountBackStack++
+
// Update last access time.
group?.touch(modified = false, touchParents = false)
@@ -462,9 +471,24 @@ class GroupActivity : LockingActivity(),
// Show selection mode message if needed
if (mSelectionMode) {
- modeTitleView?.visibility = View.VISIBLE
+ modeCancelButton?.setOnClickListener {
+ // To remove the navigation history and
+ EntrySelectionHelper.removeEntrySelectionModeFromIntent(intent)
+ val fragmentManager = supportFragmentManager
+ if (mSelectionModeCountBackStack > 0) {
+ for (selectionMode in 0 .. mSelectionModeCountBackStack) {
+ fragmentManager.popBackStack()
+ }
+ }
+ // Reinit the counter for navigation history
+ mSelectionModeCountBackStack = 0
+ // Back to the app caller
+ super.onBackPressed()
+ }
+ modeContainerView?.visibility = View.VISIBLE
} else {
- modeTitleView?.visibility = View.GONE
+ modeCancelButton?.setOnClickListener(null)
+ modeContainerView?.visibility = View.GONE
}
// Show button if allowed
@@ -976,9 +1000,11 @@ class GroupActivity : LockingActivity(),
finishNodeAction()
} else {
// Normal way when we are not in root
- if (mRootGroup != null && mRootGroup != mCurrentGroup)
+ if (mRootGroup != null && mRootGroup != mCurrentGroup) {
super.onBackPressed()
- // Else lock if needed
+ rebuildListNodes()
+ }
+ // Else in root, lock if needed
else {
if (PreferencesUtil.isLockDatabaseWhenBackButtonOnRootClicked(this)) {
lockAndExit()
@@ -986,11 +1012,15 @@ class GroupActivity : LockingActivity(),
} else {
// To restore standard mode
EntrySelectionHelper.removeEntrySelectionModeFromIntent(intent)
- moveTaskToBack(true)
+ if (mSelectionMode) {
+ // To get the app caller
+ super.onBackPressed()
+ } else {
+ // To move the app in background
+ moveTaskToBack(true)
+ }
}
}
-
- rebuildListNodes()
}
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt
index c8cd60fbe..56f7e3c22 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt
@@ -780,10 +780,13 @@ open class PasswordActivity : StylishActivity() {
if (!keyFileResult) {
// this block if not a key file response
when (resultCode) {
- LockingActivity.RESULT_EXIT_LOCK, Activity.RESULT_CANCELED -> {
+ LockingActivity.RESULT_EXIT_LOCK -> {
clearCredentialsViews()
Database.getInstance().closeAndClear(applicationContext.filesDir)
}
+ Activity.RESULT_CANCELED -> {
+ clearCredentialsViews()
+ }
}
}
}
diff --git a/app/src/main/res/drawable-v21/background_button.xml b/app/src/main/res/drawable-v21/background_button.xml
index 7971f309f..efe76dbbc 100644
--- a/app/src/main/res/drawable-v21/background_button.xml
+++ b/app/src/main/res/drawable-v21/background_button.xml
@@ -8,8 +8,8 @@
diff --git a/app/src/main/res/drawable/background_button.xml b/app/src/main/res/drawable/background_button.xml
index 84c503d39..addbbc56d 100644
--- a/app/src/main/res/drawable/background_button.xml
+++ b/app/src/main/res/drawable/background_button.xml
@@ -5,8 +5,8 @@
@@ -17,8 +17,8 @@
diff --git a/app/src/main/res/layout/activity_group.xml b/app/src/main/res/layout/activity_group.xml
index 5cfdf3803..1a3f2e717 100644
--- a/app/src/main/res/layout/activity_group.xml
+++ b/app/src/main/res/layout/activity_group.xml
@@ -124,15 +124,31 @@
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_below="@+id/toolbar">
-
+ android:background="?attr/colorAccent">
+
+
+