Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeae8877 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Enable Talkback for long clicking contacts

Bug: 24098561
Change-Id: I3630b739a6b618b8e4fd9f10c6a3c77896d02fff
parent 2da5d2ff
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.TextUtils;
import android.view.accessibility.AccessibilityEvent;

import java.util.TreeSet;

@@ -125,6 +126,16 @@ public class MultiSelectContactsListFragment extends DefaultContactBrowseListFra
                    mCheckBoxListListener.onStartDisplayingCheckBoxes();
                }
                getAdapter().toggleSelectionOfContactId(Long.valueOf(contactId));
                // Sending an accessibility event of TYPE_VIEW_CLICKED and forcing Talkback to be
                // performed on the checkbox.
                // We need to:
                // 1. consider the difference between position and adjPosition;
                // 2. make sure the list item is not null before sending the event.
                final int adjPosition = position + getListView().getHeaderViewsCount();
                if (getListView() != null && adjPosition < getListView().getChildCount()) {
                    getListView().getChildAt(adjPosition).sendAccessibilityEvent(AccessibilityEvent
                            .TYPE_VIEW_CLICKED);
                }
            }
        }
        final int nowSelectedCount = getAdapter().getSelectedContactIds().size();