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

Commit 5678dcb0 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Update left nav label menu item content description

Bug: 32975864

Test: manually verified it announces "{label name} label", annoucement
      of accounts are also correct, and left nav works well when
      Talkback is off.

Change-Id: Ieb76be43b475565e0090ad1062eee3cc1f5805e8
parent aa5cac38
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2016 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<!-- A dummy action view to attach extra hidden content description to menuItem for Talkback. -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="gone">
    <View
        android:layout_width="1dp"
        android:layout_height= "1dp" />
</LinearLayout>
 No newline at end of file
+15 −9
Original line number Diff line number Diff line
@@ -437,6 +437,8 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
                        return true;
                    }
                });

                updateMenuContentDescription(menuItem, getString(R.string.group_name_dialog_hint));
            }
        }

@@ -528,7 +530,6 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
            return;
        }


        for (int i = 0; i < accountFilterItems.size(); i++) {
            final ContactListFilter filter = accountFilterItems.get(i);
            final AccountDisplayInfo displayableAccount =
@@ -556,14 +557,8 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
                // Get rid of the default menu item overlay and show original account icons.
                menuItem.getIcon().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
            }
            // Create a dummy action view to attach extra hidden content description to the menuItem
            // for Talkback. We want Talkback to read out the account type but not have it be part
            // of the menuItem title.
            LinearLayout view = (LinearLayout) LayoutInflater.from(this)
                    .inflate(R.layout.account_type_info, null);
            view.setContentDescription(displayableAccount.getTypeLabel());
            view.setVisibility(View.VISIBLE);
            menuItem.setActionView(view);

            updateMenuContentDescription(menuItem, displayableAccount.getTypeLabel());
        }

        if (isAccountView()) {
@@ -571,6 +566,17 @@ public abstract class ContactsDrawerActivity extends AppCompatContactsActivity i
        }
    }

    private void updateMenuContentDescription(MenuItem menuItem, CharSequence contentDescription) {
        // Create a dummy action view to attach extra hidden content description to the menuItem
        // for Talkback. We want Talkback to read out the account type but not have it be part
        // of the menuItem title.
        final LinearLayout view = (LinearLayout) LayoutInflater.from(this)
                .inflate(R.layout.menu_item_action_view, null);
        view.setContentDescription(contentDescription);
        view.setVisibility(View.VISIBLE);
        menuItem.setActionView(view);
    }

    public void updateFilterMenu(ContactListFilter filter) {
        clearCheckedMenus();
        if (filter != null && filter.isContactsFilterType()) {