swipe length/speed thresholds for list view swipe-to-delete action (like KitKat stock email app)

StackOverflow https://stackoverflow.com/questions/23070773

  •  03-07-2023
  •  | 
  •  

Question

What are the parameters (swipe distance and/or speed) that the latest (4.4 KitKat) Android stock email client uses to determine whether a horizontal swipe is far enough to cause an email to be deleted when viewing the inbox list?

I'm unfamiliar with both Android programming and the android source code, although some Googling yielded this code snippet in EmailProvider.java:

    if (projectionColumns.contains(UIProvider.AccountColumns.SettingsColumns.SWIPE)) {
        values.put(UIProvider.AccountColumns.SettingsColumns.SWIPE,
                mailPrefs.getConversationListSwipeActionInteger(false));
    }

and that led me to the SwipeableListView class which seems to be implementing this behavior, but I couldn't find where the Email app's thresholds are defined.

Anyone know where swipe thresholds are defined for this app, or for all SwipeListView instances if the email app uses the default behavior?

I'm asking these questions because our team just implemented swipe-to-delete in an iOS app's list view, and the initial swipe threshold we chose (50% of the width of the list item, with no adjustment for swipe speed) doesn't feel sensitive enough, meaning it's too difficult to trigger the swipe-to-delete action. (Yes I know that iOS has a default swipe-to-delete behavior, but we're building ours custom because iOS's default swipe-to-delete action requires a confirm button but this view can't require 2 taps for every delete)

The android stock email app's swipe-to-delete behavior matches how we want our app to work. It seems to be both distance and speed-dependent. So we'd like to port similar behavior to iOS. Does anyone know the exact thresholds (or algorithm) used to differentiate "swipe" from "not swipe" in the KitKat email app?

Was it helpful?

Solution

The constants are defined in /res/values/animation_constants and applied using SwipeHelper.

By default SwipeHelper is disabled in SwipeableListView, but enabled in ConversationListFragment using SwipeableListView.enableSwipe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top