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

Commit 88e72785 authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Enable proper Talkback for "Contacts to display"" into ub-contactsdialer-a-dev

parents 977dbb6d 30b92834
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -165,13 +165,21 @@ public class AccountFilterActivity extends Activity implements AdapterView.OnIte

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        final ContactListFilterView listFilterView = (ContactListFilterView) view;
        final ContactListFilter filter = (ContactListFilter) view.getTag();
        if (filter == null) return; // Just in case
        if (filter.filterType == ContactListFilter.FILTER_TYPE_CUSTOM) {
            final Intent intent = new Intent(this,
                    CustomContactListFilterActivity.class);
            listFilterView.setActivated(true);
            // Switching activity has the highest priority. So when we open another activity, the
            // announcement that indicates an account is checked will be interrupted. This is the
            // way to overcome -- View.announceForAccessibility(CharSequence text);
            listFilterView.announceForAccessibility(listFilterView.generateContentDescription());
            startActivityForResult(intent, SUBACTIVITY_CUSTOMIZE_FILTER);
        } else {
            listFilterView.setActivated(true);
            listFilterView.announceForAccessibility(listFilterView.generateContentDescription());
            final Intent intent = new Intent();
            intent.putExtra(KEY_EXTRA_CONTACT_LIST_FILTER, filter);
            setResult(Activity.RESULT_OK, intent);
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.contacts.common.list;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -74,6 +75,7 @@ public class ContactListFilterView extends LinearLayout {
            // properly if the button hasn't been initialized.
            Log.wtf(TAG, "radio-button cannot be activated because it is null");
        }
        setContentDescription(generateContentDescription());
    }

    public void bindView(AccountTypeManager accountTypes) {
@@ -127,6 +129,7 @@ public class ContactListFilterView extends LinearLayout {
                break;
            }
        }
        setContentDescription(generateContentDescription());
    }

    private void bindView(int iconResource, int textResource) {
@@ -139,4 +142,19 @@ public class ContactListFilterView extends LinearLayout {

        mAccountType.setText(textResource);
    }

    String generateContentDescription() {
        final StringBuilder sb = new StringBuilder();
        if (!TextUtils.isEmpty(mAccountType.getText())) {
            sb.append(mAccountType.getText());
        }
        if (!TextUtils.isEmpty(mAccountUserName.getText())) {
            if (sb.length() > 0) {
                sb.append(" ");
            }
            sb.append(mAccountUserName.getText());
        }
        return getContext().getString(isActivated() ? R.string.account_filter_view_checked :
                R.string.account_filter_view_not_checked, sb.toString());
    }
}