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

Commit 56973247 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Read the subtext of notif importance field on selection

When using a11y services

Test: manual with Talkback
Bug: 133649570
Change-Id: Ic68a948ab5d55e68994e6b14456d25d438637886
parent 13cbb2ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@
        <TextView
            android:id="@+id/silence_summary"
            android:paddingTop="@dimen/notification_importance_button_padding"
            android:text="@string/notification_channel_summary_default"
            android:text="@string/notification_channel_summary_low"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="false"
+15 −11
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.transition.AutoTransition;
import android.transition.Transition;
import android.transition.TransitionManager;
import android.util.AttributeSet;
import android.view.View;
@@ -112,6 +113,7 @@ public class ImportancePreference extends Preference {
            mAlertButton.setEnabled(false);
        }

        setImportanceSummary((ViewGroup) holder.itemView, mImportance, false);
        switch (mImportance) {
            case IMPORTANCE_MIN:
            case IMPORTANCE_LOW:
@@ -126,23 +128,29 @@ public class ImportancePreference extends Preference {
                mAlertButton.setSelected(true);
                break;
        }
        setImportanceSummary((ViewGroup) holder.itemView, mImportance, false);

        mSilenceButton.setOnClickListener(v -> {
            callChangeListener(IMPORTANCE_LOW);
            mAlertButton.setBackground(unselectedBackground);
            mAlertButton.setSelected(false);
            mSilenceButton.setBackground(selectedBackground);
            mSilenceButton.setSelected(true);
            setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
            // a11y service won't always read the newly appearing text in the right order if the
            // selection happens too soon (readback happens on a different thread as layout). post
            // the selection to make that conflict less likely
            holder.itemView.post(() -> {
                mAlertButton.setSelected(false);
                mSilenceButton.setSelected(true);
            });
        });
        mAlertButton.setOnClickListener(v -> {
            callChangeListener(IMPORTANCE_DEFAULT);
            mSilenceButton.setBackground(unselectedBackground);
            mSilenceButton.setSelected(false);
            mAlertButton.setBackground(selectedBackground);
            mAlertButton.setSelected(true);
            setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true);
            holder.itemView.post(() -> {
                mSilenceButton.setSelected(false);
                mAlertButton.setSelected(true);
            });
        });
    }

@@ -172,9 +180,7 @@ public class ImportancePreference extends Preference {
            ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorAccent);
            ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorAccent);

            TextView view = parent.findViewById(R.id.alert_summary);
            view.setText(R.string.notification_channel_summary_default);
            view.setVisibility(VISIBLE);
            parent.findViewById(R.id.alert_summary).setVisibility(VISIBLE);
        } else {
            parent.findViewById(R.id.alert_summary).setVisibility(GONE);
            ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorNormal);
@@ -182,9 +188,7 @@ public class ImportancePreference extends Preference {

            ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorAccent);
            ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorAccent);
            TextView view = parent.findViewById(R.id.silence_summary);
            view.setVisibility(VISIBLE);
            view.setText(R.string.notification_channel_summary_low);
            parent.findViewById(R.id.silence_summary).setVisibility(VISIBLE);
        }
    }
}