mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-01 22:32:47 -08:00
Fix special modes and add search/save modes
This commit is contained in:
1 parent
f7e8662bdf
commit
c5e9d14199
11 files changed
+292
-91
No files matched your search
@@ -50,11 +50,6 @@ class AutofillLauncherActivity : AppCompatActivity() {
|
||||
// Retrieve selection mode
|
||||
EntrySelectionHelper.retrieveSpecialModeFromIntent(intent).let { specialMode ->
|
||||
when (specialMode) {
|
||||
SpecialMode.DEFAULT -> {
|
||||
// Not an autofill call
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
SpecialMode.SELECTION -> {
|
||||
// Build search param
|
||||
val searchInfo = SearchInfo().apply {
|
||||
@@ -83,6 +78,11 @@ class AutofillLauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
launchRegistration(searchInfo, registerInfo)
|
||||
}
|
||||
else -> {
|
||||
// Not an autofill call
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,6 +308,12 @@ class EntryEditActivity : LockingActivity(),
|
||||
// Finish naturally
|
||||
finish()
|
||||
},
|
||||
{
|
||||
// Nothing when search retrieved
|
||||
},
|
||||
{
|
||||
onValidateSpecialMode()
|
||||
},
|
||||
{
|
||||
entryValidatedForKeyboardSelection(entry)
|
||||
},
|
||||
@@ -822,6 +828,30 @@ class EntryEditActivity : LockingActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
fun launchForSave(context: Context,
|
||||
entry: Entry,
|
||||
searchInfo: SearchInfo) {
|
||||
if (TimeoutHelper.checkTimeAndLockIfTimeout(context)) {
|
||||
val intent = Intent(context, EntryEditActivity::class.java)
|
||||
intent.putExtra(KEY_ENTRY, entry.nodeId)
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(context,
|
||||
intent,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
|
||||
fun launchForSave(context: Context,
|
||||
group: Group,
|
||||
searchInfo: SearchInfo) {
|
||||
if (TimeoutHelper.checkTimeAndLockIfTimeout(context)) {
|
||||
val intent = Intent(context, EntryEditActivity::class.java)
|
||||
intent.putExtra(KEY_PARENT, group.nodeId)
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(context,
|
||||
intent,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch EntryEditActivity to add a new entry in keyboard selection
|
||||
*/
|
||||
|
||||
+3
-4
@@ -95,7 +95,7 @@ class EntrySelectionLauncherActivity : AppCompatActivity() {
|
||||
searchInfo)
|
||||
}
|
||||
} else {
|
||||
GroupActivity.launch(this,
|
||||
GroupActivity.launchForSearchResult(this,
|
||||
true,
|
||||
searchInfo)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class EntrySelectionLauncherActivity : AppCompatActivity() {
|
||||
false,
|
||||
searchInfo)
|
||||
} else {
|
||||
GroupActivity.launch(this,
|
||||
GroupActivity.launchForSaveResult(this,
|
||||
false,
|
||||
searchInfo)
|
||||
}
|
||||
@@ -118,12 +118,11 @@ class EntrySelectionLauncherActivity : AppCompatActivity() {
|
||||
FileDatabaseSelectActivity.launchForKeyboardSelectionResult(this,
|
||||
searchInfo)
|
||||
} else {
|
||||
FileDatabaseSelectActivity.launch(this,
|
||||
FileDatabaseSelectActivity.launchForSearchResult(this,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,8 +292,7 @@ class FileDatabaseSelectActivity : SpecialModeActivity(),
|
||||
createDatabaseButtonView?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
SpecialMode.SELECTION,
|
||||
SpecialMode.REGISTRATION -> {
|
||||
else -> {
|
||||
// Disable create button if in selection mode or request for autofill
|
||||
createDatabaseButtonView?.visibility = View.GONE
|
||||
}
|
||||
@@ -447,15 +446,25 @@ class FileDatabaseSelectActivity : SpecialModeActivity(),
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Launch only to standard search, else pass by PasswordActivity
|
||||
* Standard Launch
|
||||
* -------------------------
|
||||
*/
|
||||
|
||||
fun launch(context: Context,
|
||||
searchInfo: SearchInfo? = null) {
|
||||
val intent = Intent(context, FileDatabaseSelectActivity::class.java)
|
||||
EntrySelectionHelper.addSearchInfoInIntent(intent, searchInfo)
|
||||
context.startActivity(intent)
|
||||
fun launch(context: Context) {
|
||||
context.startActivity(Intent(context, FileDatabaseSelectActivity::class.java))
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Search Launch
|
||||
* -------------------------
|
||||
*/
|
||||
|
||||
fun launchForSearchResult(context: Context,
|
||||
searchInfo: SearchInfo) {
|
||||
EntrySelectionHelper.startActivityForSearchModeResult(context,
|
||||
Intent(context, FileDatabaseSelectActivity::class.java),
|
||||
searchInfo)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.appcompat.widget.SearchView
|
||||
@@ -214,6 +213,14 @@ class GroupActivity : LockingActivity(),
|
||||
{
|
||||
EntryEditActivity.launch(this@GroupActivity, currentGroup)
|
||||
},
|
||||
{
|
||||
// Search not used
|
||||
},
|
||||
{ searchInfo ->
|
||||
EntryEditActivity.launchForSave(this@GroupActivity,
|
||||
currentGroup, searchInfo)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
{ searchInfo ->
|
||||
EntryEditActivity.launchForKeyboardSelectionResult(this@GroupActivity,
|
||||
currentGroup, searchInfo)
|
||||
@@ -262,7 +269,13 @@ class GroupActivity : LockingActivity(),
|
||||
mListNodesFragment?.updateNodes(oldNodes, newNodes)
|
||||
EntrySelectionHelper.doSpecialAction(intent,
|
||||
{
|
||||
// Not use
|
||||
// Standard not used after task
|
||||
},
|
||||
{
|
||||
// Search not used
|
||||
},
|
||||
{
|
||||
// Save not used
|
||||
},
|
||||
{
|
||||
try {
|
||||
@@ -567,6 +580,15 @@ class GroupActivity : LockingActivity(),
|
||||
{
|
||||
EntryActivity.launch(this@GroupActivity, entryVersioned, mReadOnly)
|
||||
},
|
||||
{
|
||||
// Nothing here, a search is simply performed
|
||||
},
|
||||
{ searchInfo ->
|
||||
if (!mReadOnly)
|
||||
entrySelectedForSave(entryVersioned, searchInfo)
|
||||
else
|
||||
finish()
|
||||
},
|
||||
{ searchInfo ->
|
||||
if (!mReadOnly
|
||||
&& searchInfo != null
|
||||
@@ -586,7 +608,10 @@ class GroupActivity : LockingActivity(),
|
||||
}
|
||||
},
|
||||
{ registerInfo ->
|
||||
entrySelectedForRegistration(entryVersioned, registerInfo)
|
||||
if (!mReadOnly)
|
||||
entrySelectedForRegistration(entryVersioned, registerInfo)
|
||||
else
|
||||
finish()
|
||||
})
|
||||
} catch (e: ClassCastException) {
|
||||
Log.e(TAG, "Node can't be cast in Entry")
|
||||
@@ -594,6 +619,14 @@ class GroupActivity : LockingActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun entrySelectedForSave(entry: Entry, searchInfo: SearchInfo) {
|
||||
rebuildListNodes()
|
||||
// Save to update the entry
|
||||
EntryEditActivity.launchForSave(this@GroupActivity,
|
||||
entry, searchInfo)
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
|
||||
private fun entrySelectedForKeyboardSelection(entry: Entry) {
|
||||
rebuildListNodes()
|
||||
// Populate Magikeyboard with entry
|
||||
@@ -619,10 +652,9 @@ class GroupActivity : LockingActivity(),
|
||||
private fun entrySelectedForRegistration(entry: Entry, registerInfo: RegisterInfo?) {
|
||||
rebuildListNodes()
|
||||
// Registration to update the entry
|
||||
// TODO box update confirmation
|
||||
EntryEditActivity.launchForRegistration(this@GroupActivity,
|
||||
entry, registerInfo)
|
||||
onValidateSpecialMode()
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
|
||||
private fun updateEntryWithSearchInfo(entry: Entry, searchInfo: SearchInfo) {
|
||||
@@ -793,14 +825,6 @@ class GroupActivity : LockingActivity(),
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
// If in registration mode, don't allow read only
|
||||
if (mSpecialMode == SpecialMode.REGISTRATION
|
||||
&& mReadOnly) {
|
||||
Toast.makeText(this, R.string.error_registration_read_only , Toast.LENGTH_LONG).show()
|
||||
EntrySelectionHelper.removeModesFromIntent(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
// Show the lock button
|
||||
lockView?.visibility = if (PreferencesUtil.showLockDatabaseButton(this)) {
|
||||
View.VISIBLE
|
||||
@@ -1188,15 +1212,47 @@ class GroupActivity : LockingActivity(),
|
||||
*/
|
||||
fun launch(context: Context,
|
||||
autoSearch: Boolean = false,
|
||||
searchInfo: SearchInfo? = null,
|
||||
readOnly: Boolean = PreferencesUtil.enableReadOnlyDatabase(context)) {
|
||||
checkTimeAndBuildIntent(context, null, readOnly) { intent ->
|
||||
EntrySelectionHelper.addSearchInfoInIntent(intent, searchInfo)
|
||||
intent.putExtra(AUTO_SEARCH_KEY, autoSearch)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Search Launch
|
||||
* -------------------------
|
||||
*/
|
||||
fun launchForSearchResult(context: Context,
|
||||
autoSearch: Boolean = false,
|
||||
searchInfo: SearchInfo,
|
||||
readOnly: Boolean = PreferencesUtil.enableReadOnlyDatabase(context)) {
|
||||
checkTimeAndBuildIntent(context, null, readOnly) { intent ->
|
||||
intent.putExtra(AUTO_SEARCH_KEY, autoSearch)
|
||||
EntrySelectionHelper.addSearchInfoInIntent(
|
||||
intent,
|
||||
searchInfo)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Search save Launch
|
||||
* -------------------------
|
||||
*/
|
||||
fun launchForSaveResult(context: Context,
|
||||
autoSearch: Boolean = false,
|
||||
searchInfo: SearchInfo) {
|
||||
checkTimeAndBuildIntent(context, null, false) { intent ->
|
||||
intent.putExtra(AUTO_SEARCH_KEY, autoSearch)
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(context,
|
||||
intent,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Keyboard Launch
|
||||
@@ -1260,15 +1316,44 @@ class GroupActivity : LockingActivity(),
|
||||
onCancelSpecialMode: () -> Unit,
|
||||
onLaunchActivitySpecialMode: () -> Unit) {
|
||||
EntrySelectionHelper.doSpecialAction(activity.intent,
|
||||
{ searchInfo ->
|
||||
{
|
||||
GroupActivity.launch(activity,
|
||||
true,
|
||||
searchInfo,
|
||||
readOnly)
|
||||
// Finish activity if no search info
|
||||
if (searchInfo != null) {
|
||||
activity.finish()
|
||||
}
|
||||
},
|
||||
{ searchInfo ->
|
||||
SearchHelper.checkAutoSearchInfo(activity,
|
||||
Database.getInstance(),
|
||||
searchInfo,
|
||||
{ _ ->
|
||||
// Response is build
|
||||
GroupActivity.launchForSearchResult(activity,
|
||||
true,
|
||||
searchInfo)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
{
|
||||
// Here no search info found
|
||||
if (readOnly) {
|
||||
GroupActivity.launchForSearchResult(activity,
|
||||
false,
|
||||
searchInfo,
|
||||
readOnly)
|
||||
} else {
|
||||
GroupActivity.launchForSaveResult(activity,
|
||||
false,
|
||||
searchInfo)
|
||||
}
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
{
|
||||
// Simply close if database not opened, normally not happened
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
)
|
||||
},
|
||||
{
|
||||
// Nothing with Save Info, only pass by search first
|
||||
},
|
||||
{ searchInfo ->
|
||||
SearchHelper.checkAutoSearchInfo(activity,
|
||||
|
||||
@@ -760,14 +760,31 @@ open class PasswordActivity : SpecialModeActivity() {
|
||||
@Throws(FileNotFoundException::class)
|
||||
fun launch(activity: Activity,
|
||||
databaseFile: Uri,
|
||||
keyFile: Uri?,
|
||||
searchInfo: SearchInfo?) {
|
||||
keyFile: Uri?) {
|
||||
buildAndLaunchIntent(activity, databaseFile, keyFile) { intent ->
|
||||
EntrySelectionHelper.addSearchInfoInIntent(intent, searchInfo)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Share Launch
|
||||
* -------------------------
|
||||
*/
|
||||
|
||||
@Throws(FileNotFoundException::class)
|
||||
fun launchForSearchResult(activity: Activity,
|
||||
databaseFile: Uri,
|
||||
keyFile: Uri?,
|
||||
searchInfo: SearchInfo) {
|
||||
buildAndLaunchIntent(activity, databaseFile, keyFile) { intent ->
|
||||
EntrySelectionHelper.startActivityForSearchModeResult(
|
||||
activity,
|
||||
intent,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Keyboard Launch
|
||||
@@ -798,18 +815,14 @@ open class PasswordActivity : SpecialModeActivity() {
|
||||
fun launchForAutofillResult(activity: Activity,
|
||||
databaseFile: Uri,
|
||||
keyFile: Uri?,
|
||||
assistStructure: AssistStructure?,
|
||||
assistStructure: AssistStructure,
|
||||
searchInfo: SearchInfo?) {
|
||||
if (assistStructure != null) {
|
||||
buildAndLaunchIntent(activity, databaseFile, keyFile) { intent ->
|
||||
AutofillHelper.startActivityForAutofillResult(
|
||||
activity,
|
||||
intent,
|
||||
assistStructure,
|
||||
searchInfo)
|
||||
}
|
||||
} else {
|
||||
launch(activity, databaseFile, keyFile, searchInfo)
|
||||
buildAndLaunchIntent(activity, databaseFile, keyFile) { intent ->
|
||||
AutofillHelper.startActivityForAutofillResult(
|
||||
activity,
|
||||
intent,
|
||||
assistStructure,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,55 +854,49 @@ open class PasswordActivity : SpecialModeActivity() {
|
||||
fileNoFoundAction: (exception: FileNotFoundException) -> Unit,
|
||||
onCancelSpecialMode: () -> Unit,
|
||||
onLaunchActivitySpecialMode: () -> Unit) {
|
||||
EntrySelectionHelper.doSpecialAction(activity.intent,
|
||||
{ searchInfo -> // Default Action
|
||||
try {
|
||||
|
||||
try {
|
||||
EntrySelectionHelper.doSpecialAction(activity.intent,
|
||||
{
|
||||
PasswordActivity.launch(activity,
|
||||
databaseUri, keyFile)
|
||||
},
|
||||
{ searchInfo -> // Search Action
|
||||
PasswordActivity.launchForSearchResult(activity,
|
||||
databaseUri, keyFile,
|
||||
searchInfo)
|
||||
// Remove the search info from intent
|
||||
if (searchInfo != null) {
|
||||
activity.finish()
|
||||
}
|
||||
} catch (e: FileNotFoundException) {
|
||||
fileNoFoundAction(e)
|
||||
}
|
||||
},
|
||||
{ searchInfo -> // Keyboard Selection Action
|
||||
try {
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
{ // Save Action
|
||||
// Not directly used, a search is performed before
|
||||
},
|
||||
{ searchInfo -> // Keyboard Selection Action
|
||||
PasswordActivity.launchForKeyboardResult(activity,
|
||||
databaseUri, keyFile,
|
||||
searchInfo)
|
||||
onLaunchActivitySpecialMode()
|
||||
} catch (e: FileNotFoundException) {
|
||||
fileNoFoundAction(e)
|
||||
}
|
||||
},
|
||||
{ searchInfo, assistStructure -> // Autofill Selection Action
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
try {
|
||||
},
|
||||
{ searchInfo, assistStructure -> // Autofill Selection Action
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
PasswordActivity.launchForAutofillResult(activity,
|
||||
databaseUri, keyFile,
|
||||
assistStructure,
|
||||
searchInfo)
|
||||
onLaunchActivitySpecialMode()
|
||||
} catch (e: FileNotFoundException) {
|
||||
fileNoFoundAction(e)
|
||||
} else {
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
} else {
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
},
|
||||
{ searchInfo -> // Registration Action
|
||||
try {
|
||||
},
|
||||
{ registerInfo -> // Registration Action
|
||||
PasswordActivity.launchForRegistration(activity,
|
||||
databaseUri, keyFile,
|
||||
searchInfo)
|
||||
registerInfo)
|
||||
onLaunchActivitySpecialMode()
|
||||
} catch (e: FileNotFoundException) {
|
||||
fileNoFoundAction(e)
|
||||
}
|
||||
})
|
||||
)
|
||||
} catch (e: FileNotFoundException) {
|
||||
fileNoFoundAction(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,25 @@ object EntrySelectionHelper {
|
||||
private const val KEY_SEARCH_INFO = "com.kunzisoft.keepass.extra.SEARCH_INFO"
|
||||
private const val KEY_REGISTER_INFO = "com.kunzisoft.keepass.extra.REGISTER_INFO"
|
||||
|
||||
fun startActivityForSearchModeResult(context: Context,
|
||||
intent: Intent,
|
||||
searchInfo: SearchInfo) {
|
||||
addSpecialModeInIntent(intent, SpecialMode.SEARCH)
|
||||
addSearchInfoInIntent(intent, searchInfo)
|
||||
intent.flags = intent.flags or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
fun startActivityForSaveModeResult(context: Context,
|
||||
intent: Intent,
|
||||
searchInfo: SearchInfo) {
|
||||
addSpecialModeInIntent(intent, SpecialMode.SAVE)
|
||||
addTypeModeInIntent(intent, TypeMode.DEFAULT)
|
||||
addSearchInfoInIntent(intent, searchInfo)
|
||||
intent.flags = intent.flags or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
fun startActivityForKeyboardSelectionModeResult(context: Context,
|
||||
intent: Intent,
|
||||
searchInfo: SearchInfo?) {
|
||||
@@ -112,16 +131,39 @@ object EntrySelectionHelper {
|
||||
}
|
||||
|
||||
fun doSpecialAction(intent: Intent,
|
||||
defaultAction: (searchInfo: SearchInfo?) -> Unit,
|
||||
defaultAction: () -> Unit,
|
||||
searchAction: (searchInfo: SearchInfo) -> Unit,
|
||||
saveAction: (searchInfo: SearchInfo) -> Unit,
|
||||
keyboardSelectionAction: (searchInfo: SearchInfo?) -> Unit,
|
||||
autofillSelectionAction: (searchInfo: SearchInfo?,
|
||||
assistStructure: AssistStructure) -> Unit,
|
||||
registrationAction: (registerInfo: RegisterInfo?) -> Unit) {
|
||||
autofillRegistrationAction: (registerInfo: RegisterInfo?) -> Unit) {
|
||||
|
||||
when (retrieveSpecialModeFromIntent(intent)) {
|
||||
SpecialMode.DEFAULT -> {
|
||||
removeModesFromIntent(intent)
|
||||
defaultAction.invoke(retrieveSearchInfoFromIntent(intent))
|
||||
removeInfoFromIntent(intent)
|
||||
defaultAction.invoke()
|
||||
}
|
||||
SpecialMode.SEARCH -> {
|
||||
val searchInfo = retrieveSearchInfoFromIntent(intent)
|
||||
removeModesFromIntent(intent)
|
||||
removeInfoFromIntent(intent)
|
||||
if (searchInfo != null)
|
||||
searchAction.invoke(searchInfo)
|
||||
else {
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
SpecialMode.SAVE -> {
|
||||
val searchInfo = retrieveSearchInfoFromIntent(intent)
|
||||
removeModesFromIntent(intent)
|
||||
removeInfoFromIntent(intent)
|
||||
if (searchInfo != null)
|
||||
saveAction.invoke(searchInfo)
|
||||
else {
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
SpecialMode.SELECTION -> {
|
||||
val searchInfo: SearchInfo? = retrieveSearchInfoFromIntent(intent)
|
||||
@@ -137,7 +179,10 @@ object EntrySelectionHelper {
|
||||
when (retrieveTypeModeFromIntent(intent)) {
|
||||
TypeMode.DEFAULT -> {
|
||||
removeModesFromIntent(intent)
|
||||
defaultAction.invoke(searchInfo)
|
||||
if (searchInfo != null)
|
||||
searchAction.invoke(searchInfo)
|
||||
else
|
||||
defaultAction.invoke()
|
||||
}
|
||||
TypeMode.MAGIKEYBOARD -> keyboardSelectionAction.invoke(searchInfo)
|
||||
else -> {
|
||||
@@ -147,7 +192,10 @@ object EntrySelectionHelper {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
defaultAction.invoke(searchInfo)
|
||||
if (searchInfo != null)
|
||||
searchAction.invoke(searchInfo)
|
||||
else
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +203,7 @@ object EntrySelectionHelper {
|
||||
val registerInfo: RegisterInfo? = retrieveRegisterInfoFromIntent(intent)
|
||||
removeModesFromIntent(intent)
|
||||
removeInfoFromIntent(intent)
|
||||
registrationAction.invoke(registerInfo)
|
||||
autofillRegistrationAction.invoke(registerInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.kunzisoft.keepass.activities.helpers
|
||||
|
||||
enum class SpecialMode {
|
||||
DEFAULT,
|
||||
SEARCH,
|
||||
SAVE,
|
||||
SELECTION,
|
||||
REGISTRATION;
|
||||
}
|
||||
@@ -25,7 +25,11 @@ import android.os.Bundle
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.helpers.EntrySelectionHelper
|
||||
import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
|
||||
import com.kunzisoft.keepass.activities.helpers.SpecialMode
|
||||
import com.kunzisoft.keepass.activities.selection.SpecialModeActivity
|
||||
import com.kunzisoft.keepass.database.action.ProgressDatabaseTaskProvider
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
@@ -96,6 +100,15 @@ abstract class LockingActivity : SpecialModeActivity() {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
// If in ave or registration mode, don't allow read only
|
||||
if ((mSpecialMode == SpecialMode.SAVE
|
||||
|| mSpecialMode == SpecialMode.REGISTRATION)
|
||||
&& mReadOnly) {
|
||||
Toast.makeText(this, R.string.error_registration_read_only , Toast.LENGTH_LONG).show()
|
||||
EntrySelectionHelper.removeModesFromIntent(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
mProgressDatabaseTaskProvider?.registerProgressTask()
|
||||
|
||||
// To refresh when back to normal workflow from selection workflow
|
||||
|
||||
@@ -121,6 +121,8 @@ abstract class SpecialModeActivity : StylishActivity() {
|
||||
// Populate title
|
||||
val selectionModeStringId = when (mSpecialMode) {
|
||||
SpecialMode.DEFAULT, // Not important because hidden
|
||||
SpecialMode.SEARCH -> R.string.search_mode
|
||||
SpecialMode.SAVE -> R.string.save_mode
|
||||
SpecialMode.SELECTION -> R.string.selection_mode
|
||||
SpecialMode.REGISTRATION -> R.string.registration_mode
|
||||
}
|
||||
@@ -129,13 +131,17 @@ abstract class SpecialModeActivity : StylishActivity() {
|
||||
TypeMode.MAGIKEYBOARD -> R.string.magic_keyboard_title
|
||||
TypeMode.AUTOFILL -> R.string.autofill
|
||||
}
|
||||
title = "${getString(selectionModeStringId)} (${getString(typeModeStringId)})"
|
||||
title = getString(selectionModeStringId)
|
||||
if (mTypeMode != TypeMode.DEFAULT)
|
||||
title = "$title (${getString(typeModeStringId)})"
|
||||
// Populate subtitle
|
||||
subtitle = searchInfo?.getName(resources)
|
||||
|
||||
// Show the toolbar or not
|
||||
visible = when (mSpecialMode) {
|
||||
SpecialMode.DEFAULT -> false
|
||||
SpecialMode.SEARCH -> true
|
||||
SpecialMode.SAVE -> true
|
||||
SpecialMode.SELECTION -> true
|
||||
SpecialMode.REGISTRATION -> true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user