diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt index 2bd847f955..a932e65685 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt @@ -77,8 +77,7 @@ class QuickWizardListActivity : DaggerAppCompatActivityWithResult(), OnStartDrag } ) } - - fun click() { + holder.binding.root.setOnClickListener { if (actionHelper.isNoAction) { val manager = fragmentManager val editQuickWizardDialog = EditQuickWizardDialog() @@ -91,23 +90,18 @@ class QuickWizardListActivity : DaggerAppCompatActivityWithResult(), OnStartDrag actionHelper.updateSelection(position, entry, holder.binding.cbRemove.isChecked) } } - // For accessibility add click lister too, unfortunately sort can not made accessible - holder.binding.root.setOnClickListener { - click() - } - holder.binding.root.setOnTouchListener { _, event -> - if (event.actionMasked == MotionEvent.ACTION_UP) { - click() - } else if (event.actionMasked == MotionEvent.ACTION_DOWN && actionHelper.isSorting) { + holder.binding.sortHandle.setOnTouchListener { _, event -> + if (event.actionMasked == MotionEvent.ACTION_DOWN) { onStartDrag(holder) + return@setOnTouchListener true } - return@setOnTouchListener true + return@setOnTouchListener false } holder.binding.cbRemove.isChecked = actionHelper.isSelected(position) holder.binding.cbRemove.setOnCheckedChangeListener { _, value -> actionHelper.updateSelection(position, entry, value) } - holder.binding.handleView.visibility = actionHelper.isSorting.toVisibility() + holder.binding.sortHandle.visibility = actionHelper.isSorting.toVisibility() holder.binding.cbRemove.visibility = actionHelper.isRemoving.toVisibility() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 0f1386afbb..f3e06897c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -147,10 +147,12 @@ class BGSourceFragment : DaggerFragment() { } holder.binding.root.setOnLongClickListener { - actionHelper.startRemove() - holder.binding.cbRemove.toggle() - actionHelper.updateSelection(position, glucoseValue, holder.binding.cbRemove.isChecked) - true + if (actionHelper.startRemove()) { + holder.binding.cbRemove.toggle() + actionHelper.updateSelection(position, glucoseValue, holder.binding.cbRemove.isChecked) + return@setOnLongClickListener true + } + false } holder.binding.root.setOnClickListener { if (actionHelper.isRemoving) { diff --git a/app/src/main/res/layout/overview_quickwizardlist_item.xml b/app/src/main/res/layout/overview_quickwizardlist_item.xml index c45ed72a08..2496e6e0bc 100644 --- a/app/src/main/res/layout/overview_quickwizardlist_item.xml +++ b/app/src/main/res/layout/overview_quickwizardlist_item.xml @@ -81,7 +81,7 @@ tools:ignore="RtlSymmetry" /> - when (touchEvent.actionMasked) { - MotionEvent.ACTION_UP -> { - handler.removeCallbacks(mLongPressed) - click() - longPress = false - } - - MotionEvent.ACTION_DOWN -> { - if (actionHelper.isSorting) { - onStartDrag(holder) - } - if (actionHelper.isNoAction && !actionHelper.inMenu) { - handler.postDelayed(mLongPressed, ViewConfiguration.getLongPressTimeout().toLong()) - } - } - + holder.binding.sortHandle.setOnTouchListener { _, touchEvent -> + if (touchEvent.actionMasked == MotionEvent.ACTION_DOWN) { + onStartDrag(holder) + return@setOnTouchListener true } - return@setOnTouchListener true + return@setOnTouchListener false } - - holder.binding.cbRemove.isChecked = actionHelper.isSelected(position) holder.binding.cbRemove.setOnCheckedChangeListener { _, value -> actionHelper.updateSelection(position, automation, value) } - holder.binding.iconSort.visibility = actionHelper.isSorting.toVisibility() + holder.binding.cbRemove.isChecked = actionHelper.isSelected(position) + holder.binding.sortHandle.visibility = actionHelper.isSorting.toVisibility() holder.binding.cbRemove.visibility = actionHelper.isRemoving.toVisibility() holder.binding.cbRemove.isEnabled = automation.readOnly.not() holder.binding.enabled.visibility = if (actionHelper.isRemoving) View.INVISIBLE else View.VISIBLE diff --git a/automation/src/main/res/layout/automation_event_item.xml b/automation/src/main/res/layout/automation_event_item.xml index e3ba50b3a1..7d0d9e2400 100644 --- a/automation/src/main/res/layout/automation_event_item.xml +++ b/automation/src/main/res/layout/automation_event_item.xml @@ -55,12 +55,12 @@ android:contentDescription="@string/remove_label" android:orientation="horizontal" app:layout_constraintBottom_toTopOf="@+id/iconLayout" - app:layout_constraintEnd_toStartOf="@+id/iconSort" + app:layout_constraintEnd_toStartOf="@+id/sortHandle" app:layout_constraintStart_toEndOf="@+id/eventTitle" app:layout_constraintTop_toTopOf="parent" /> (val rh: ResourceHelper, val activity: FragmentActivity?) { menu.findItem(R.id.nav_sort_items)?.isVisible = enableSort } - fun startAction() { - if (actionMode == null) { + fun startAction(): Boolean { + if (isNoAction) { actionMode = activity?.startActionMode(ActionModeCallback()) + return true } + return false } - fun startRemove() { + fun startRemove(): Boolean { if (removeActionMode == null) { removeActionMode = activity?.startActionMode(RemoveActionModeCallback()) + return true } + return false } - fun startSort() { + fun startSort(): Boolean { if (sortActionMode == null) { sortActionMode = activity?.startActionMode(SortActionModeCallback()) + return true } + return false } fun isSelected(position: Int) =