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

Commit a51c9988 authored by Tsung-Mao Fang's avatar Tsung-Mao Fang
Browse files

Fix talkback doesn't speak subtext info

In the original design, we only set title description for
view holder, this is wrong. It causes talkback can't
speak subtext info.

Currently, we set the title content description in the title
view directly, so talkback can say the title and subtext now
when talkback focus on an app view.

Test: Talkback speaks full information for an app entry
Fix: 177873163
Change-Id: I94996d596a85cc2813ed1b10cdd4ed2bee62f4a9
parent bac284a6
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.applications.manageapplications;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -37,9 +38,8 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;

public class ApplicationViewHolder extends RecyclerView.ViewHolder {

    private final TextView mAppName;
    private final ImageView mAppIcon;

    @VisibleForTesting
    final TextView mAppName;
    @VisibleForTesting
    final TextView mSummary;
    @VisibleForTesting
@@ -49,6 +49,8 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
    @VisibleForTesting
    final Switch mSwitch;

    private final ImageView mAppIcon;

    ApplicationViewHolder(View itemView) {
        super(itemView);
        mAppName = itemView.findViewById(android.R.id.title);
@@ -95,11 +97,16 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
        itemView.setEnabled(isEnabled);
    }

    void setTitle(CharSequence title) {
    void setTitle(CharSequence title, CharSequence contentDescription) {
        if (title == null) {
            return;
        }
        mAppName.setText(title);

        if (TextUtils.isEmpty(contentDescription)) {
            return;
        }
        mAppName.setContentDescription(contentDescription);
    }

    void setIcon(int drawableRes) {
+1 −2
Original line number Diff line number Diff line
@@ -1422,9 +1422,8 @@ public class ManageApplications extends InstrumentedFragment
            // Bind the data efficiently with the holder
            final ApplicationsState.AppEntry entry = mEntries.get(position);
            synchronized (entry) {
                holder.setTitle(entry.label);
                mState.ensureLabelDescription(entry);
                holder.itemView.setContentDescription(entry.labelDescription);
                holder.setTitle(entry.label, entry.labelDescription);
                mState.ensureIcon(entry);
                holder.setIcon(entry.icon);
                updateSummary(holder, entry);
+16 −0
Original line number Diff line number Diff line
@@ -69,6 +69,22 @@ public class ApplicationViewHolderTest {
        assertThat(mHolder.mSummary.getText()).isEqualTo(mContext.getText(R.string.disabled));
    }

    @Test
    public void setTitle_titleIsNotEmptyAndContentIsNotEmpty_shouldSetTitleAndContentDescription() {
        mHolder.setTitle("title", "content");

        assertThat(mHolder.mAppName).isEqualTo("title");
        assertThat(mHolder.mAppName.getContentDescription()).isEqualTo("content");
    }

    @Test
    public void setTitle_titleIsNotEmptyButContentIsEmpty_shouldSetTitle() {
        mHolder.setTitle("title", "");

        assertThat(mHolder.mAppName).isEqualTo("title");
        assertThat(mHolder.mAppName.getContentDescription()).isEqualTo("title");
    }

    @Test
    public void updateSize() {
        final String invalidStr = "invalid";