mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix search orientation change
This commit is contained in:
@@ -142,10 +142,7 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
taTextColor.recycle()
|
taTextColor.recycle()
|
||||||
|
|
||||||
// Retrieve group if defined at launch
|
// Retrieve group if defined at launch
|
||||||
if (intent != null) {
|
manageIntent(intent)
|
||||||
mCurrentGroupState = intent.getParcelableExtra(GROUP_STATE_KEY)
|
|
||||||
intent.removeExtra(GROUP_STATE_KEY)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve elements after an orientation change
|
// Retrieve elements after an orientation change
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
@@ -191,72 +188,67 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
mCurrentGroup = currentGroup
|
mCurrentGroup = currentGroup
|
||||||
mRecyclingBinIsCurrentGroup = it.isRecycleBin
|
mRecyclingBinIsCurrentGroup = it.isRecycleBin
|
||||||
|
|
||||||
// Save group id if real group
|
|
||||||
if (!currentGroup.isVirtual) {
|
if (!currentGroup.isVirtual) {
|
||||||
|
// Save group id if real group
|
||||||
mCurrentGroupState = GroupState(currentGroup.nodeId, it.showFromPosition)
|
mCurrentGroupState = GroupState(currentGroup.nodeId, it.showFromPosition)
|
||||||
}
|
|
||||||
|
|
||||||
// Update last access time.
|
// Update last access time.
|
||||||
currentGroup.touch(modified = false, touchParents = false)
|
currentGroup.touch(modified = false, touchParents = false)
|
||||||
|
|
||||||
// To relaunch the activity with ACTION_SEARCH
|
// Add listeners to the add buttons
|
||||||
if (manageSearchInfoIntent(intent)) {
|
addNodeButtonView?.setAddGroupClickListener {
|
||||||
startActivity(intent)
|
GroupEditDialogFragment.create(GroupInfo().apply {
|
||||||
}
|
if (currentGroup.allowAddNoteInGroup) {
|
||||||
|
notes = ""
|
||||||
// Add listeners to the add buttons
|
}
|
||||||
addNodeButtonView?.setAddGroupClickListener {
|
}).show(supportFragmentManager, GroupEditDialogFragment.TAG_CREATE_GROUP)
|
||||||
GroupEditDialogFragment.create(GroupInfo().apply {
|
}
|
||||||
if (currentGroup.allowAddNoteInGroup) {
|
addNodeButtonView?.setAddEntryClickListener {
|
||||||
notes = ""
|
EntrySelectionHelper.doSpecialAction(intent,
|
||||||
}
|
{
|
||||||
}).show(supportFragmentManager, GroupEditDialogFragment.TAG_CREATE_GROUP)
|
EntryEditActivity.launchToCreate(
|
||||||
}
|
this@GroupActivity,
|
||||||
addNodeButtonView?.setAddEntryClickListener {
|
currentGroup.nodeId
|
||||||
EntrySelectionHelper.doSpecialAction(intent,
|
)
|
||||||
{
|
},
|
||||||
EntryEditActivity.launchToCreate(
|
{
|
||||||
this@GroupActivity,
|
// Search not used
|
||||||
currentGroup.nodeId
|
},
|
||||||
)
|
{ searchInfo ->
|
||||||
},
|
EntryEditActivity.launchToCreateForSave(
|
||||||
{
|
this@GroupActivity,
|
||||||
// Search not used
|
currentGroup.nodeId, searchInfo
|
||||||
},
|
)
|
||||||
{ searchInfo ->
|
onLaunchActivitySpecialMode()
|
||||||
EntryEditActivity.launchToCreateForSave(
|
},
|
||||||
this@GroupActivity,
|
{ searchInfo ->
|
||||||
currentGroup.nodeId, searchInfo
|
EntryEditActivity.launchForKeyboardSelectionResult(
|
||||||
)
|
this@GroupActivity,
|
||||||
onLaunchActivitySpecialMode()
|
currentGroup.nodeId, searchInfo
|
||||||
},
|
)
|
||||||
{ searchInfo ->
|
onLaunchActivitySpecialMode()
|
||||||
EntryEditActivity.launchForKeyboardSelectionResult(
|
},
|
||||||
this@GroupActivity,
|
{ searchInfo, autofillComponent ->
|
||||||
currentGroup.nodeId, searchInfo
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
)
|
EntryEditActivity.launchForAutofillResult(
|
||||||
onLaunchActivitySpecialMode()
|
this@GroupActivity,
|
||||||
},
|
autofillComponent,
|
||||||
{ searchInfo, autofillComponent ->
|
currentGroup.nodeId, searchInfo
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
)
|
||||||
EntryEditActivity.launchForAutofillResult(
|
onLaunchActivitySpecialMode()
|
||||||
|
} else {
|
||||||
|
onCancelSpecialMode()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ searchInfo ->
|
||||||
|
EntryEditActivity.launchToCreateForRegistration(
|
||||||
this@GroupActivity,
|
this@GroupActivity,
|
||||||
autofillComponent,
|
|
||||||
currentGroup.nodeId, searchInfo
|
currentGroup.nodeId, searchInfo
|
||||||
)
|
)
|
||||||
onLaunchActivitySpecialMode()
|
onLaunchActivitySpecialMode()
|
||||||
} else {
|
|
||||||
onCancelSpecialMode()
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
{ searchInfo ->
|
}
|
||||||
EntryEditActivity.launchToCreateForRegistration(
|
|
||||||
this@GroupActivity,
|
|
||||||
currentGroup.nodeId, searchInfo
|
|
||||||
)
|
|
||||||
onLaunchActivitySpecialMode()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assignGroupViewElements(currentGroup)
|
assignGroupViewElements(currentGroup)
|
||||||
@@ -419,15 +411,29 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
refreshNumberOfChildren(mCurrentGroup)
|
refreshNumberOfChildren(mCurrentGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
/**
|
||||||
super.onNewIntent(intent)
|
* Transform the AUTO_SEARCH_KEY in ACTION_SEARCH, return true if AUTO_SEARCH_KEY was present
|
||||||
|
*/
|
||||||
|
private fun transformSearchInfoIntent(intent: Intent) {
|
||||||
|
// To relaunch the activity as ACTION_SEARCH
|
||||||
|
val searchInfo: SearchInfo? = EntrySelectionHelper.retrieveSearchInfoFromIntent(intent)
|
||||||
|
val autoSearch = intent.getBooleanExtra(AUTO_SEARCH_KEY, false)
|
||||||
|
intent.removeExtra(AUTO_SEARCH_KEY)
|
||||||
|
if (searchInfo != null && autoSearch) {
|
||||||
|
intent.action = Intent.ACTION_SEARCH
|
||||||
|
intent.putExtra(SearchManager.QUERY, searchInfo.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
intent?.let { intentNotNull ->
|
private fun manageIntent(intent: Intent?) {
|
||||||
|
intent?.let {
|
||||||
|
if (intent.extras?.containsKey(GROUP_STATE_KEY) == true) {
|
||||||
|
mCurrentGroupState = intent.getParcelableExtra(GROUP_STATE_KEY)
|
||||||
|
intent.removeExtra(GROUP_STATE_KEY)
|
||||||
|
}
|
||||||
// To transform KEY_SEARCH_INFO in ACTION_SEARCH
|
// To transform KEY_SEARCH_INFO in ACTION_SEARCH
|
||||||
manageSearchInfoIntent(intentNotNull)
|
transformSearchInfoIntent(intent)
|
||||||
Log.d(TAG, "setNewIntent: $intentNotNull")
|
if (Intent.ACTION_SEARCH == intent.action) {
|
||||||
setIntent(intentNotNull)
|
|
||||||
if (Intent.ACTION_SEARCH == intentNotNull.action) {
|
|
||||||
finishNodeAction()
|
finishNodeAction()
|
||||||
val searchString =
|
val searchString =
|
||||||
intent.getStringExtra(SearchManager.QUERY)?.trim { it <= ' ' } ?: ""
|
intent.getStringExtra(SearchManager.QUERY)?.trim { it <= ' ' } ?: ""
|
||||||
@@ -439,20 +445,11 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
override fun onNewIntent(intent: Intent?) {
|
||||||
* Transform the AUTO_SEARCH_KEY in ACTION_SEARCH, return true if AUTO_SEARCH_KEY was present
|
super.onNewIntent(intent)
|
||||||
*/
|
Log.d(TAG, "setNewIntent: $intent")
|
||||||
private fun manageSearchInfoIntent(intent: Intent): Boolean {
|
setIntent(intent)
|
||||||
// To relaunch the activity as ACTION_SEARCH
|
manageIntent(intent)
|
||||||
val searchInfo: SearchInfo? = EntrySelectionHelper.retrieveSearchInfoFromIntent(intent)
|
|
||||||
val autoSearch = intent.getBooleanExtra(AUTO_SEARCH_KEY, false)
|
|
||||||
intent.removeExtra(AUTO_SEARCH_KEY)
|
|
||||||
if (searchInfo != null && autoSearch) {
|
|
||||||
intent.action = Intent.ACTION_SEARCH
|
|
||||||
intent.putExtra(SearchManager.QUERY, searchInfo.toString())
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
|||||||
Reference in New Issue
Block a user