mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix add button listeners
This commit is contained in:
@@ -294,13 +294,64 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
|
||||
// Update last access time.
|
||||
currentGroup.touch(modified = false, touchParents = false)
|
||||
} else {
|
||||
mSearchGroup = currentGroup
|
||||
}
|
||||
|
||||
loadingView?.hideByFading()
|
||||
}
|
||||
|
||||
mGroupViewModel.firstPositionVisible.observe(this) { firstPositionVisible ->
|
||||
mCurrentGroupState?.firstVisibleItem = firstPositionVisible
|
||||
}
|
||||
|
||||
mGroupEditViewModel.requestIconSelection.observe(this) { iconImage ->
|
||||
IconPickerActivity.launch(this@GroupActivity, iconImage, mIconSelectionActivityResultLauncher)
|
||||
}
|
||||
|
||||
mGroupEditViewModel.requestDateTimeSelection.observe(this) { dateInstant ->
|
||||
if (dateInstant.type == DateInstant.Type.TIME) {
|
||||
// Launch the time picker
|
||||
val dateTime = DateTime(dateInstant.date)
|
||||
TimePickerFragment.getInstance(dateTime.hourOfDay, dateTime.minuteOfHour)
|
||||
.show(supportFragmentManager, "TimePickerFragment")
|
||||
} else {
|
||||
// Launch the date picker
|
||||
val dateTime = DateTime(dateInstant.date)
|
||||
DatePickerFragment.getInstance(
|
||||
dateTime.year,
|
||||
dateTime.monthOfYear - 1,
|
||||
dateTime.dayOfMonth
|
||||
)
|
||||
.show(supportFragmentManager, "DatePickerFragment")
|
||||
}
|
||||
}
|
||||
|
||||
mGroupEditViewModel.onGroupCreated.observe(this) { groupInfo ->
|
||||
if (groupInfo.title.isNotEmpty()) {
|
||||
mCurrentGroup?.let { currentGroup ->
|
||||
createGroup(currentGroup, groupInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mGroupEditViewModel.onGroupUpdated.observe(this) { groupInfo ->
|
||||
if (groupInfo.title.isNotEmpty()) {
|
||||
mOldGroupToUpdate?.let { oldGroupToUpdate ->
|
||||
updateGroup(oldGroupToUpdate, groupInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add listeners to the add buttons
|
||||
addNodeButtonView?.setAddGroupClickListener {
|
||||
mCurrentGroup?.let { currentGroup ->
|
||||
launchDialogForGroupCreation(currentGroup)
|
||||
}
|
||||
}
|
||||
addNodeButtonView?.setAddEntryClickListener {
|
||||
mDatabase?.let { database ->
|
||||
mCurrentGroup?.let { currentGroup ->
|
||||
EntrySelectionHelper.doSpecialAction(intent,
|
||||
{
|
||||
mCurrentGroup?.nodeId?.let { currentParentGroupId ->
|
||||
@@ -362,53 +413,6 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mSearchGroup = currentGroup
|
||||
}
|
||||
|
||||
loadingView?.hideByFading()
|
||||
}
|
||||
|
||||
mGroupViewModel.firstPositionVisible.observe(this) { firstPositionVisible ->
|
||||
mCurrentGroupState?.firstVisibleItem = firstPositionVisible
|
||||
}
|
||||
|
||||
mGroupEditViewModel.requestIconSelection.observe(this) { iconImage ->
|
||||
IconPickerActivity.launch(this@GroupActivity, iconImage, mIconSelectionActivityResultLauncher)
|
||||
}
|
||||
|
||||
mGroupEditViewModel.requestDateTimeSelection.observe(this) { dateInstant ->
|
||||
if (dateInstant.type == DateInstant.Type.TIME) {
|
||||
// Launch the time picker
|
||||
val dateTime = DateTime(dateInstant.date)
|
||||
TimePickerFragment.getInstance(dateTime.hourOfDay, dateTime.minuteOfHour)
|
||||
.show(supportFragmentManager, "TimePickerFragment")
|
||||
} else {
|
||||
// Launch the date picker
|
||||
val dateTime = DateTime(dateInstant.date)
|
||||
DatePickerFragment.getInstance(
|
||||
dateTime.year,
|
||||
dateTime.monthOfYear - 1,
|
||||
dateTime.dayOfMonth
|
||||
)
|
||||
.show(supportFragmentManager, "DatePickerFragment")
|
||||
}
|
||||
}
|
||||
|
||||
mGroupEditViewModel.onGroupCreated.observe(this) { groupInfo ->
|
||||
if (groupInfo.title.isNotEmpty()) {
|
||||
mCurrentGroup?.let { currentGroup ->
|
||||
createGroup(currentGroup, groupInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mGroupEditViewModel.onGroupUpdated.observe(this) { groupInfo ->
|
||||
if (groupInfo.title.isNotEmpty()) {
|
||||
mOldGroupToUpdate?.let { oldGroupToUpdate ->
|
||||
updateGroup(oldGroupToUpdate, groupInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +421,6 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
|
||||
private fun loadGroup(database: Database?) {
|
||||
loadingView?.showByFading()
|
||||
when {
|
||||
Intent.ACTION_SEARCH == intent.action -> {
|
||||
finishNodeAction()
|
||||
|
||||
Reference in New Issue
Block a user