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

Commit a585881d authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Fix talkback issue with drop down menu

The drop down views need to be created in `getDropDownView` in order for
Talkback to announce correctly that they are clickable.

Fixes: 253557350
Test: manual with talkback on - video in bug
Change-Id: I9dcbc7935332a20d5890e589f2c441eaff5425f8
parent 0d750d1f
Loading
Loading
Loading
Loading
+13 −25
Original line number Diff line number Diff line
@@ -16,10 +16,6 @@

package com.android.systemui.screenrecord;

import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.INTERNAL;
import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.MIC;
import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.MIC_AND_INTERNAL;

import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
@@ -40,9 +36,6 @@ public class ScreenRecordingAdapter extends ArrayAdapter<ScreenRecordingAudioSou
    private LinearLayout mSelectedMic;
    private LinearLayout mSelectedInternal;
    private LinearLayout mSelectedMicAndInternal;
    private LinearLayout mMicOption;
    private LinearLayout mMicAndInternalOption;
    private LinearLayout mInternalOption;

    public ScreenRecordingAdapter(Context context, int resource,
            List<ScreenRecordingAudioSource> objects) {
@@ -54,28 +47,21 @@ public class ScreenRecordingAdapter extends ArrayAdapter<ScreenRecordingAudioSou
        mSelectedInternal = getSelected(R.string.screenrecord_device_audio_label);
        mSelectedMic = getSelected(R.string.screenrecord_mic_label);
        mSelectedMicAndInternal = getSelected(R.string.screenrecord_device_audio_and_mic_label);

        mMicOption = getOption(R.string.screenrecord_mic_label, Resources.ID_NULL);
        mMicOption.removeViewAt(1);

        mMicAndInternalOption = getOption(
                R.string.screenrecord_device_audio_and_mic_label, Resources.ID_NULL);
        mMicAndInternalOption.removeViewAt(1);

        mInternalOption = getOption(R.string.screenrecord_device_audio_label,
                R.string.screenrecord_device_audio_description);
    }

    private LinearLayout getOption(int label, int description) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LayoutInflater inflater = LayoutInflater.from(getContext());
        LinearLayout layout = (LinearLayout) inflater
                .inflate(R.layout.screen_record_dialog_audio_source, null, false);
        ((TextView) layout.findViewById(R.id.screen_recording_dialog_source_text))
                .setText(label);
        if (description != Resources.ID_NULL)
            ((TextView) layout.findViewById(R.id.screen_recording_dialog_source_description))
                    .setText(description);
        TextView descriptionView = layout.findViewById(
                R.id.screen_recording_dialog_source_description);
        if (description != Resources.ID_NULL) {
            descriptionView.setText(description);
        } else {
            descriptionView.setVisibility(View.GONE);
        }
        return layout;
    }

@@ -92,11 +78,13 @@ public class ScreenRecordingAdapter extends ArrayAdapter<ScreenRecordingAudioSou
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        switch (getItem(position)) {
            case INTERNAL:
                return mInternalOption;
                return getOption(R.string.screenrecord_device_audio_label,
                        R.string.screenrecord_device_audio_description);
            case MIC_AND_INTERNAL:
                return mMicAndInternalOption;
                return getOption(
                        R.string.screenrecord_device_audio_and_mic_label, Resources.ID_NULL);
            case MIC:
                return mMicOption;
                return getOption(R.string.screenrecord_mic_label, Resources.ID_NULL);
            default:
                return super.getDropDownView(position, convertView, parent);
        }