Loading res/layout/notif_priority_conversation_preference.xml +15 −15 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ android:clickable="true" android:focusable="true"> <ImageView android:id="@+id/priority_icon" android:id="@+id/icon" android:src="@drawable/ic_important_outline" android:background="@android:color/transparent" android:layout_gravity="center" Loading @@ -41,19 +41,19 @@ android:clickable="false" android:focusable="false"/> <TextView android:id="@+id/priority_label" android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:clickable="false" android:focusable="false" android:layout_toEndOf="@id/priority_icon" android:layout_toEndOf="@id/icon" android:layout_marginStart="@dimen/notification_importance_drawable_padding" android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected" android:text="@string/notification_priority_title"/> <TextView android:id="@+id/priority_summary" android:id="@+id/summary" android:paddingTop="@dimen/notification_importance_button_padding" android:text="@string/notification_channel_summary_priority" android:layout_width="match_parent" Loading @@ -62,7 +62,7 @@ android:focusable="false" android:ellipsize="end" android:maxLines="3" android:layout_below="@id/priority_icon" android:layout_below="@id/icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </com.android.settings.notification.NotificationButtonRelativeLayout> Loading @@ -76,7 +76,7 @@ android:clickable="true" android:focusable="true"> <ImageView android:id="@+id/alert_icon" android:id="@+id/icon" android:src="@drawable/ic_notifications_alert" android:background="@android:color/transparent" android:layout_gravity="center" Loading @@ -85,19 +85,19 @@ android:clickable="false" android:focusable="false"/> <TextView android:id="@+id/alert_label" android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:clickable="false" android:focusable="false" android:layout_toEndOf="@id/alert_icon" android:layout_toEndOf="@id/icon" android:layout_marginStart="@dimen/notification_importance_drawable_padding" android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected" android:text="@string/notification_alert_title"/> <TextView android:id="@+id/alert_summary" android:id="@+id/summary" android:paddingTop="@dimen/notification_importance_button_padding" android:text="@string/notification_channel_summary_default" android:layout_width="match_parent" Loading @@ -106,7 +106,7 @@ android:focusable="false" android:ellipsize="end" android:maxLines="2" android:layout_below="@id/alert_icon" android:layout_below="@id/icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </com.android.settings.notification.NotificationButtonRelativeLayout> Loading @@ -120,7 +120,7 @@ android:clickable="true" android:focusable="true"> <ImageView android:id="@+id/silence_icon" android:id="@+id/icon" android:src="@drawable/ic_notifications_off_24dp" android:background="@android:color/transparent" android:layout_gravity="center" Loading @@ -129,19 +129,19 @@ android:clickable="false" android:focusable="false"/> <TextView android:id="@+id/silence_label" android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:clickable="false" android:focusable="false" android:layout_toEndOf="@id/silence_icon" android:layout_toEndOf="@id/icon" android:layout_marginStart="@dimen/notification_importance_drawable_padding" android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected" android:text="@string/notification_silence_title"/> <TextView android:id="@+id/silence_summary" android:id="@+id/summary" android:paddingTop="@dimen/notification_importance_button_padding" android:text="@string/notification_conversation_summary_low" android:layout_width="match_parent" Loading @@ -150,7 +150,7 @@ android:focusable="false" android:ellipsize="end" android:maxLines="2" android:layout_below="@id/silence_icon" android:layout_below="@id/icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </com.android.settings.notification.NotificationButtonRelativeLayout> Loading src/com/android/settings/notification/app/ConversationPriorityPreference.java +32 −79 Original line number Diff line number Diff line Loading @@ -50,8 +50,6 @@ public class ConversationPriorityPreference extends Preference { private View mAlertButton; private View mPriorityButton; private Context mContext; Drawable selectedBackground; Drawable unselectedBackground; private static final int BUTTON_ANIM_TIME_MS = 100; public ConversationPriorityPreference(Context context, AttributeSet attrs, Loading @@ -77,8 +75,6 @@ public class ConversationPriorityPreference extends Preference { private void init(Context context) { mContext = context; selectedBackground = mContext.getDrawable(R.drawable.button_border_selected); unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected); setLayoutResource(R.layout.notif_priority_conversation_preference); } Loading Loading @@ -148,86 +144,43 @@ public class ConversationPriorityPreference extends Preference { TransitionManager.beginDelayedTransition(parent, transition); } if (importance <= IMPORTANCE_LOW && importance > IMPORTANCE_UNSPECIFIED) { setSelected(mPriorityButton, false); setSelected(mAlertButton, false); setSelected(mSilenceButton, true); } else { if (isPriority) { setSelected(mPriorityButton, true); setSelected(mAlertButton, false); setSelected(mSilenceButton, false); } else { setSelected(mPriorityButton, false); setSelected(mAlertButton, true); setSelected(mSilenceButton, false); } } } void setSelected(View view, boolean selected) { ColorStateList colorAccent = getAccentTint(); ColorStateList colorNormal = getRegularTint(); ImageView silenceIcon = parent.findViewById(R.id.silence_icon); TextView silenceLabel = parent.findViewById(R.id.silence_label); TextView silenceSummary = parent.findViewById(R.id.silence_summary); ImageView alertIcon = parent.findViewById(R.id.alert_icon); TextView alertLabel = parent.findViewById(R.id.alert_label); TextView alertSummary = parent.findViewById(R.id.alert_summary); ImageView priorityIcon = parent.findViewById(R.id.priority_icon); TextView priorityLabel = parent.findViewById(R.id.priority_label); TextView prioritySummary = parent.findViewById(R.id.priority_summary); if (importance <= IMPORTANCE_LOW && importance > IMPORTANCE_UNSPECIFIED) { alertSummary.setVisibility(GONE); alertIcon.setImageTintList(colorNormal); alertLabel.setTextColor(colorNormal); ImageView icon = view.findViewById(R.id.icon); TextView label = view.findViewById(R.id.label); TextView summary = view.findViewById(R.id.summary); prioritySummary.setVisibility(GONE); priorityIcon.setImageTintList(colorNormal); priorityLabel.setTextColor(colorNormal); icon.setImageTintList(selected ? colorAccent : colorNormal); label.setTextColor(selected ? colorAccent : colorNormal); summary.setVisibility(selected ? VISIBLE : GONE); silenceIcon.setImageTintList(colorAccent); silenceLabel.setTextColor(colorAccent); silenceSummary.setVisibility(VISIBLE); mAlertButton.setBackground(unselectedBackground); mPriorityButton.setBackground(unselectedBackground); mSilenceButton.setBackground(selectedBackground); view.setBackground(mContext.getDrawable(selected ? R.drawable.button_border_selected : R.drawable.button_border_unselected)); // 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 parent.post(() -> { mSilenceButton.setSelected(true); mAlertButton.setSelected(false); mPriorityButton.setSelected(false); }); } else { if (isPriority) { alertSummary.setVisibility(GONE); alertIcon.setImageTintList(colorNormal); alertLabel.setTextColor(colorNormal); prioritySummary.setVisibility(VISIBLE); priorityIcon.setImageTintList(colorAccent); priorityLabel.setTextColor(colorAccent); silenceIcon.setImageTintList(colorNormal); silenceLabel.setTextColor(colorNormal); silenceSummary.setVisibility(GONE); mAlertButton.setBackground(unselectedBackground); mPriorityButton.setBackground(selectedBackground); mSilenceButton.setBackground(unselectedBackground); parent.post(() -> { mSilenceButton.setSelected(false); mAlertButton.setSelected(false); mPriorityButton.setSelected(true); view.post(() -> { view.setSelected(selected); }); } else { alertSummary.setVisibility(VISIBLE); alertIcon.setImageTintList(colorAccent); alertLabel.setTextColor(colorAccent); prioritySummary.setVisibility(GONE); priorityIcon.setImageTintList(colorNormal); priorityLabel.setTextColor(colorNormal); silenceIcon.setImageTintList(colorNormal); silenceLabel.setTextColor(colorNormal); silenceSummary.setVisibility(GONE); mAlertButton.setBackground(selectedBackground); mPriorityButton.setBackground(unselectedBackground); mSilenceButton.setBackground(unselectedBackground); parent.post(() -> { mSilenceButton.setSelected(false); mAlertButton.setSelected(true); mPriorityButton.setSelected(false); }); } } } } tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceTest.java +2 −53 Original line number Diff line number Diff line Loading @@ -68,10 +68,6 @@ public class ConversationPriorityPreferenceTest { final LayoutInflater inflater = LayoutInflater.from(mContext); PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); Drawable unselected = mock(Drawable.class); Drawable selected = mock(Drawable.class); preference.selectedBackground = selected; preference.unselectedBackground = unselected; preference.setConfigurable(false); preference.setImportance(IMPORTANCE_DEFAULT); Loading @@ -81,35 +77,6 @@ public class ConversationPriorityPreferenceTest { assertThat(holder.itemView.findViewById(R.id.silence).isEnabled()).isFalse(); assertThat(holder.itemView.findViewById(R.id.priority_group).isEnabled()).isFalse(); assertThat(holder.itemView.findViewById(R.id.alert).isEnabled()).isFalse(); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(selected); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(unselected); // other button preference.setPriorityConversation(false); holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); preference.onBindViewHolder(holder); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); // other other button preference.setImportance(IMPORTANCE_LOW); holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); preference.onBindViewHolder(holder); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected); } @Test Loading @@ -119,10 +86,6 @@ public class ConversationPriorityPreferenceTest { final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); Drawable unselected = mock(Drawable.class); Drawable selected = mock(Drawable.class); preference.selectedBackground = selected; preference.unselectedBackground = unselected; preference.setConfigurable(true); preference.setImportance(IMPORTANCE_LOW); Loading @@ -130,12 +93,8 @@ public class ConversationPriorityPreferenceTest { preference.onBindViewHolder(holder); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(selected); assertThat(holder.itemView.findViewById(R.id.silence_summary).getVisibility()) assertThat(holder.itemView.findViewById(R.id.silence) .findViewById(R.id.summary).getVisibility()) .isEqualTo(View.VISIBLE); } Loading @@ -146,10 +105,6 @@ public class ConversationPriorityPreferenceTest { final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); Drawable unselected = mock(Drawable.class); Drawable selected = mock(Drawable.class); preference.selectedBackground = selected; preference.unselectedBackground = unselected; preference.setConfigurable(true); preference.setImportance(IMPORTANCE_DEFAULT); Loading @@ -161,12 +116,6 @@ public class ConversationPriorityPreferenceTest { silenceButton.callOnClick(); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(selected); verify(preference, times(1)).callChangeListener(new Pair(IMPORTANCE_LOW, false)); } } Loading
res/layout/notif_priority_conversation_preference.xml +15 −15 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ android:clickable="true" android:focusable="true"> <ImageView android:id="@+id/priority_icon" android:id="@+id/icon" android:src="@drawable/ic_important_outline" android:background="@android:color/transparent" android:layout_gravity="center" Loading @@ -41,19 +41,19 @@ android:clickable="false" android:focusable="false"/> <TextView android:id="@+id/priority_label" android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:clickable="false" android:focusable="false" android:layout_toEndOf="@id/priority_icon" android:layout_toEndOf="@id/icon" android:layout_marginStart="@dimen/notification_importance_drawable_padding" android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected" android:text="@string/notification_priority_title"/> <TextView android:id="@+id/priority_summary" android:id="@+id/summary" android:paddingTop="@dimen/notification_importance_button_padding" android:text="@string/notification_channel_summary_priority" android:layout_width="match_parent" Loading @@ -62,7 +62,7 @@ android:focusable="false" android:ellipsize="end" android:maxLines="3" android:layout_below="@id/priority_icon" android:layout_below="@id/icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </com.android.settings.notification.NotificationButtonRelativeLayout> Loading @@ -76,7 +76,7 @@ android:clickable="true" android:focusable="true"> <ImageView android:id="@+id/alert_icon" android:id="@+id/icon" android:src="@drawable/ic_notifications_alert" android:background="@android:color/transparent" android:layout_gravity="center" Loading @@ -85,19 +85,19 @@ android:clickable="false" android:focusable="false"/> <TextView android:id="@+id/alert_label" android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:clickable="false" android:focusable="false" android:layout_toEndOf="@id/alert_icon" android:layout_toEndOf="@id/icon" android:layout_marginStart="@dimen/notification_importance_drawable_padding" android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected" android:text="@string/notification_alert_title"/> <TextView android:id="@+id/alert_summary" android:id="@+id/summary" android:paddingTop="@dimen/notification_importance_button_padding" android:text="@string/notification_channel_summary_default" android:layout_width="match_parent" Loading @@ -106,7 +106,7 @@ android:focusable="false" android:ellipsize="end" android:maxLines="2" android:layout_below="@id/alert_icon" android:layout_below="@id/icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </com.android.settings.notification.NotificationButtonRelativeLayout> Loading @@ -120,7 +120,7 @@ android:clickable="true" android:focusable="true"> <ImageView android:id="@+id/silence_icon" android:id="@+id/icon" android:src="@drawable/ic_notifications_off_24dp" android:background="@android:color/transparent" android:layout_gravity="center" Loading @@ -129,19 +129,19 @@ android:clickable="false" android:focusable="false"/> <TextView android:id="@+id/silence_label" android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:clickable="false" android:focusable="false" android:layout_toEndOf="@id/silence_icon" android:layout_toEndOf="@id/icon" android:layout_marginStart="@dimen/notification_importance_drawable_padding" android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected" android:text="@string/notification_silence_title"/> <TextView android:id="@+id/silence_summary" android:id="@+id/summary" android:paddingTop="@dimen/notification_importance_button_padding" android:text="@string/notification_conversation_summary_low" android:layout_width="match_parent" Loading @@ -150,7 +150,7 @@ android:focusable="false" android:ellipsize="end" android:maxLines="2" android:layout_below="@id/silence_icon" android:layout_below="@id/icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </com.android.settings.notification.NotificationButtonRelativeLayout> Loading
src/com/android/settings/notification/app/ConversationPriorityPreference.java +32 −79 Original line number Diff line number Diff line Loading @@ -50,8 +50,6 @@ public class ConversationPriorityPreference extends Preference { private View mAlertButton; private View mPriorityButton; private Context mContext; Drawable selectedBackground; Drawable unselectedBackground; private static final int BUTTON_ANIM_TIME_MS = 100; public ConversationPriorityPreference(Context context, AttributeSet attrs, Loading @@ -77,8 +75,6 @@ public class ConversationPriorityPreference extends Preference { private void init(Context context) { mContext = context; selectedBackground = mContext.getDrawable(R.drawable.button_border_selected); unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected); setLayoutResource(R.layout.notif_priority_conversation_preference); } Loading Loading @@ -148,86 +144,43 @@ public class ConversationPriorityPreference extends Preference { TransitionManager.beginDelayedTransition(parent, transition); } if (importance <= IMPORTANCE_LOW && importance > IMPORTANCE_UNSPECIFIED) { setSelected(mPriorityButton, false); setSelected(mAlertButton, false); setSelected(mSilenceButton, true); } else { if (isPriority) { setSelected(mPriorityButton, true); setSelected(mAlertButton, false); setSelected(mSilenceButton, false); } else { setSelected(mPriorityButton, false); setSelected(mAlertButton, true); setSelected(mSilenceButton, false); } } } void setSelected(View view, boolean selected) { ColorStateList colorAccent = getAccentTint(); ColorStateList colorNormal = getRegularTint(); ImageView silenceIcon = parent.findViewById(R.id.silence_icon); TextView silenceLabel = parent.findViewById(R.id.silence_label); TextView silenceSummary = parent.findViewById(R.id.silence_summary); ImageView alertIcon = parent.findViewById(R.id.alert_icon); TextView alertLabel = parent.findViewById(R.id.alert_label); TextView alertSummary = parent.findViewById(R.id.alert_summary); ImageView priorityIcon = parent.findViewById(R.id.priority_icon); TextView priorityLabel = parent.findViewById(R.id.priority_label); TextView prioritySummary = parent.findViewById(R.id.priority_summary); if (importance <= IMPORTANCE_LOW && importance > IMPORTANCE_UNSPECIFIED) { alertSummary.setVisibility(GONE); alertIcon.setImageTintList(colorNormal); alertLabel.setTextColor(colorNormal); ImageView icon = view.findViewById(R.id.icon); TextView label = view.findViewById(R.id.label); TextView summary = view.findViewById(R.id.summary); prioritySummary.setVisibility(GONE); priorityIcon.setImageTintList(colorNormal); priorityLabel.setTextColor(colorNormal); icon.setImageTintList(selected ? colorAccent : colorNormal); label.setTextColor(selected ? colorAccent : colorNormal); summary.setVisibility(selected ? VISIBLE : GONE); silenceIcon.setImageTintList(colorAccent); silenceLabel.setTextColor(colorAccent); silenceSummary.setVisibility(VISIBLE); mAlertButton.setBackground(unselectedBackground); mPriorityButton.setBackground(unselectedBackground); mSilenceButton.setBackground(selectedBackground); view.setBackground(mContext.getDrawable(selected ? R.drawable.button_border_selected : R.drawable.button_border_unselected)); // 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 parent.post(() -> { mSilenceButton.setSelected(true); mAlertButton.setSelected(false); mPriorityButton.setSelected(false); }); } else { if (isPriority) { alertSummary.setVisibility(GONE); alertIcon.setImageTintList(colorNormal); alertLabel.setTextColor(colorNormal); prioritySummary.setVisibility(VISIBLE); priorityIcon.setImageTintList(colorAccent); priorityLabel.setTextColor(colorAccent); silenceIcon.setImageTintList(colorNormal); silenceLabel.setTextColor(colorNormal); silenceSummary.setVisibility(GONE); mAlertButton.setBackground(unselectedBackground); mPriorityButton.setBackground(selectedBackground); mSilenceButton.setBackground(unselectedBackground); parent.post(() -> { mSilenceButton.setSelected(false); mAlertButton.setSelected(false); mPriorityButton.setSelected(true); view.post(() -> { view.setSelected(selected); }); } else { alertSummary.setVisibility(VISIBLE); alertIcon.setImageTintList(colorAccent); alertLabel.setTextColor(colorAccent); prioritySummary.setVisibility(GONE); priorityIcon.setImageTintList(colorNormal); priorityLabel.setTextColor(colorNormal); silenceIcon.setImageTintList(colorNormal); silenceLabel.setTextColor(colorNormal); silenceSummary.setVisibility(GONE); mAlertButton.setBackground(selectedBackground); mPriorityButton.setBackground(unselectedBackground); mSilenceButton.setBackground(unselectedBackground); parent.post(() -> { mSilenceButton.setSelected(false); mAlertButton.setSelected(true); mPriorityButton.setSelected(false); }); } } } }
tests/robotests/src/com/android/settings/notification/app/ConversationPriorityPreferenceTest.java +2 −53 Original line number Diff line number Diff line Loading @@ -68,10 +68,6 @@ public class ConversationPriorityPreferenceTest { final LayoutInflater inflater = LayoutInflater.from(mContext); PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); Drawable unselected = mock(Drawable.class); Drawable selected = mock(Drawable.class); preference.selectedBackground = selected; preference.unselectedBackground = unselected; preference.setConfigurable(false); preference.setImportance(IMPORTANCE_DEFAULT); Loading @@ -81,35 +77,6 @@ public class ConversationPriorityPreferenceTest { assertThat(holder.itemView.findViewById(R.id.silence).isEnabled()).isFalse(); assertThat(holder.itemView.findViewById(R.id.priority_group).isEnabled()).isFalse(); assertThat(holder.itemView.findViewById(R.id.alert).isEnabled()).isFalse(); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(selected); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(unselected); // other button preference.setPriorityConversation(false); holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); preference.onBindViewHolder(holder); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); // other other button preference.setImportance(IMPORTANCE_LOW); holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); preference.onBindViewHolder(holder); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected); } @Test Loading @@ -119,10 +86,6 @@ public class ConversationPriorityPreferenceTest { final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); Drawable unselected = mock(Drawable.class); Drawable selected = mock(Drawable.class); preference.selectedBackground = selected; preference.unselectedBackground = unselected; preference.setConfigurable(true); preference.setImportance(IMPORTANCE_LOW); Loading @@ -130,12 +93,8 @@ public class ConversationPriorityPreferenceTest { preference.onBindViewHolder(holder); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(selected); assertThat(holder.itemView.findViewById(R.id.silence_summary).getVisibility()) assertThat(holder.itemView.findViewById(R.id.silence) .findViewById(R.id.summary).getVisibility()) .isEqualTo(View.VISIBLE); } Loading @@ -146,10 +105,6 @@ public class ConversationPriorityPreferenceTest { final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(preference.getLayoutResource(), null)); Drawable unselected = mock(Drawable.class); Drawable selected = mock(Drawable.class); preference.selectedBackground = selected; preference.unselectedBackground = unselected; preference.setConfigurable(true); preference.setImportance(IMPORTANCE_DEFAULT); Loading @@ -161,12 +116,6 @@ public class ConversationPriorityPreferenceTest { silenceButton.callOnClick(); assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.priority_group).getBackground()) .isEqualTo(unselected); assertThat(holder.itemView.findViewById(R.id.silence).getBackground()) .isEqualTo(selected); verify(preference, times(1)).callChangeListener(new Pair(IMPORTANCE_LOW, false)); } }