Importance preference updates
- Use show on lockscreen setting - Match design to notification shade guts Test: robotests Bug: 131290247 Bug: 128445911 Change-Id: I645b35191c8f22e751c264fd8ca13560f50b7582
This commit is contained in:
@@ -18,6 +18,6 @@
|
|||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="2dp"
|
android:width="2dp"
|
||||||
android:color="?android:attr/colorAccent"/>
|
android:color="?android:attr/textColorSecondary"/>
|
||||||
<corners android:radius="@dimen/rect_button_radius" />
|
<corners android:radius="@dimen/rect_button_radius" />
|
||||||
</shape>
|
</shape>
|
@@ -18,7 +18,7 @@
|
|||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="2dp"
|
android:width="2dp"
|
||||||
android:color="@color/notification_importance_button_unselected"/>
|
android:color="?android:attr/textColorSecondary"/>
|
||||||
|
|
||||||
<corners android:radius="@dimen/rect_button_radius" />
|
<corners android:radius="@dimen/rect_button_radius" />
|
||||||
</shape>
|
</shape>
|
@@ -21,53 +21,92 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:padding="@dimen/notification_importance_toggle_marginTop"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<RelativeLayout
|
||||||
android:id="@+id/buttons"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/alert"
|
android:id="@+id/alert"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/notification_importance_toggle_size"
|
|
||||||
android:minWidth="@dimen/notification_importance_button_width"
|
|
||||||
android:paddingStart="@dimen/notification_importance_button_horiz_padding"
|
|
||||||
android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
|
|
||||||
android:drawablePadding="@dimen/notification_importance_drawable_padding"
|
|
||||||
android:foreground="@drawable/button_ripple_radius"
|
|
||||||
android:drawableLeft="@drawable/ic_notification_alert"
|
|
||||||
android:text="@string/notification_alert_title" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/silence"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/notification_importance_toggle_size"
|
|
||||||
android:minWidth="@dimen/notification_importance_button_width"
|
|
||||||
android:paddingStart="@dimen/notification_importance_button_horiz_padding"
|
|
||||||
android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
|
|
||||||
android:drawablePadding="@dimen/notification_importance_drawable_padding"
|
|
||||||
android:foreground="@drawable/button_ripple_radius"
|
|
||||||
android:layout_marginStart="@dimen/notification_importance_button_separation"
|
|
||||||
android:drawableLeft="@drawable/ic_notification_silence"
|
|
||||||
android:text="@string/notification_silence_title" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/description"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/notification_alert_title"
|
android:padding="@dimen/notification_importance_button_padding"
|
||||||
android:gravity="center"
|
android:clickable="true"
|
||||||
android:layout_marginTop="@dimen/notification_importance_text_marginTop"
|
android:focusable="true">
|
||||||
android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
|
<ImageView
|
||||||
android:paddingStart="@dimen/notification_importance_description_padding"
|
android:id="@+id/alert_icon"
|
||||||
android:paddingEnd="@dimen/notification_importance_description_padding"
|
android:src="@drawable/ic_notification_alert"
|
||||||
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" />
|
android:background="@android:color/transparent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/alert_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_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:paddingTop="@dimen/notification_importance_button_padding"
|
||||||
|
android:text="@string/notification_channel_summary_default"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:layout_below="@id/alert_icon"
|
||||||
|
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/silence"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="@dimen/notification_importance_button_padding"
|
||||||
|
android:layout_marginTop="@dimen/notification_importance_button_separation"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/silence_icon"
|
||||||
|
android:src="@drawable/ic_notification_silence"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/silence_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_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:paddingTop="@dimen/notification_importance_button_padding"
|
||||||
|
android:text="@string/notification_channel_summary_default"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:layout_below="@id/silence_icon"
|
||||||
|
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@@ -79,6 +79,7 @@
|
|||||||
<dimen name="notification_importance_description_padding">20dp</dimen>
|
<dimen name="notification_importance_description_padding">20dp</dimen>
|
||||||
<dimen name="notification_importance_description_text">14sp</dimen>
|
<dimen name="notification_importance_description_text">14sp</dimen>
|
||||||
<dimen name="notification_importance_button_text">16sp</dimen>
|
<dimen name="notification_importance_button_text">16sp</dimen>
|
||||||
|
<dimen name="notification_importance_button_padding">14dp</dimen>
|
||||||
|
|
||||||
<dimen name="zen_schedule_rule_checkbox_padding">7dp</dimen>
|
<dimen name="zen_schedule_rule_checkbox_padding">7dp</dimen>
|
||||||
<dimen name="zen_schedule_day_margin">17dp</dimen>
|
<dimen name="zen_schedule_day_margin">17dp</dimen>
|
||||||
|
@@ -7805,7 +7805,7 @@
|
|||||||
<string name="profile_section_header">Work notifications</string>
|
<string name="profile_section_header">Work notifications</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: section header for prioritizer settings [CHAR LIMIT=80] -->
|
<!-- Configure Notifications: section header for prioritizer settings [CHAR LIMIT=80] -->
|
||||||
<string name="smart_notifications_title">Smart notifications</string>
|
<string name="smart_notifications_title">Adaptive notifications</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
|
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
|
||||||
<string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
|
<string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
|
||||||
@@ -7976,25 +7976,25 @@
|
|||||||
|
|
||||||
<!-- Channel summaries for the app notification page -->
|
<!-- Channel summaries for the app notification page -->
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: min importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: min importance level summary -->
|
||||||
<string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
|
<string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
||||||
<string name="notification_channel_summary_low">Always silent. Displays in pull-down shade.</string>
|
<string name="notification_channel_summary_low">Helps you focus with notifications only in the pull-down shade. Always silent.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
||||||
<string name="notification_channel_summary_low_status">Always silent. Displays in pull-down shade & status bar.</string>
|
<string name="notification_channel_summary_low_status">Displays below priority notifications. Always silent.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
||||||
<string name="notification_channel_summary_low_lock">Always silent. Displays in pull-down shade & on lock screen.</string>
|
<string name="notification_channel_summary_low_lock">Displays below priority notifications. Always silent.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
||||||
<string name="notification_channel_summary_low_status_lock">Always silent. Displays in pull-down shade, status bar & on lock screen.</string>
|
<string name="notification_channel_summary_low_status_lock">Displays below priority notifications. Always silent.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
|
||||||
<string name="notification_channel_summary_default">Makes sound and displays in pull-down shade, status bar & on lock screen.</string>
|
<string name="notification_channel_summary_default">Gets your attention with sound & a status bar icon. Shows on lock screen.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: high importance level summary -->
|
||||||
<string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
|
<string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
|
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
|
||||||
|
@@ -20,10 +20,16 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
|||||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||||
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||||
|
import static android.view.View.GONE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.transition.AutoTransition;
|
||||||
|
import android.transition.TransitionManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -38,11 +44,12 @@ public class ImportancePreference extends Preference {
|
|||||||
private int mImportance;
|
private int mImportance;
|
||||||
private boolean mDisplayInStatusBar;
|
private boolean mDisplayInStatusBar;
|
||||||
private boolean mDisplayOnLockscreen;
|
private boolean mDisplayOnLockscreen;
|
||||||
private Button mSilenceButton;
|
private View mSilenceButton;
|
||||||
private Button mAlertButton;
|
private View mAlertButton;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
Drawable selectedBackground;
|
Drawable selectedBackground;
|
||||||
Drawable unselectedBackground;
|
Drawable unselectedBackground;
|
||||||
|
private static final int BUTTON_ANIM_TIME_MS = 100;
|
||||||
|
|
||||||
public ImportancePreference(Context context, AttributeSet attrs,
|
public ImportancePreference(Context context, AttributeSet attrs,
|
||||||
int defStyleAttr, int defStyleRes) {
|
int defStyleAttr, int defStyleRes) {
|
||||||
@@ -89,13 +96,12 @@ public class ImportancePreference extends Preference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
public void onBindViewHolder(final PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
holder.itemView.setClickable(false);
|
holder.itemView.setClickable(false);
|
||||||
|
|
||||||
TextView textView = (TextView) holder.findViewById(R.id.description);
|
mSilenceButton = holder.findViewById(R.id.silence);
|
||||||
mSilenceButton = (Button) holder.findViewById(R.id.silence);
|
mAlertButton = holder.findViewById(R.id.alert);
|
||||||
mAlertButton = (Button) holder.findViewById(R.id.alert);
|
|
||||||
|
|
||||||
if (!mIsConfigurable) {
|
if (!mIsConfigurable) {
|
||||||
mSilenceButton.setEnabled(false);
|
mSilenceButton.setEnabled(false);
|
||||||
@@ -114,34 +120,41 @@ public class ImportancePreference extends Preference {
|
|||||||
mAlertButton.setBackground(selectedBackground);
|
mAlertButton.setBackground(selectedBackground);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setImportanceSummary(textView, mImportance);
|
setImportanceSummary((ViewGroup) holder.itemView, mImportance, false);
|
||||||
|
|
||||||
mSilenceButton.setOnClickListener(v -> {
|
mSilenceButton.setOnClickListener(v -> {
|
||||||
callChangeListener(IMPORTANCE_LOW);
|
callChangeListener(IMPORTANCE_LOW);
|
||||||
mAlertButton.setBackground(unselectedBackground);
|
mAlertButton.setBackground(unselectedBackground);
|
||||||
|
mAlertButton.setSelected(false);
|
||||||
mSilenceButton.setBackground(selectedBackground);
|
mSilenceButton.setBackground(selectedBackground);
|
||||||
mSilenceButton.setTextAppearance(
|
mSilenceButton.setSelected(true);
|
||||||
R.style.TextAppearance_NotificationImportanceButton_Selected);
|
setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
|
||||||
mAlertButton.setTextAppearance(
|
|
||||||
R.style.TextAppearance_NotificationImportanceButton_Unselected);
|
|
||||||
setImportanceSummary(textView, IMPORTANCE_LOW);
|
|
||||||
});
|
});
|
||||||
mAlertButton.setOnClickListener(v -> {
|
mAlertButton.setOnClickListener(v -> {
|
||||||
callChangeListener(IMPORTANCE_DEFAULT);
|
callChangeListener(IMPORTANCE_DEFAULT);
|
||||||
mSilenceButton.setBackground(unselectedBackground);
|
mSilenceButton.setBackground(unselectedBackground);
|
||||||
|
mSilenceButton.setSelected(false);
|
||||||
mAlertButton.setBackground(selectedBackground);
|
mAlertButton.setBackground(selectedBackground);
|
||||||
mAlertButton.setTextAppearance(
|
mAlertButton.setSelected(true);
|
||||||
R.style.TextAppearance_NotificationImportanceButton_Selected);
|
setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true);
|
||||||
mSilenceButton.setTextAppearance(
|
|
||||||
R.style.TextAppearance_NotificationImportanceButton_Unselected);
|
|
||||||
setImportanceSummary(textView, IMPORTANCE_DEFAULT);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void setImportanceSummary(TextView view, int importance) {
|
void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
|
||||||
|
if (fromUser) {
|
||||||
|
AutoTransition transition = new AutoTransition();
|
||||||
|
transition.setDuration(BUTTON_ANIM_TIME_MS);
|
||||||
|
TransitionManager.beginDelayedTransition(parent, transition);
|
||||||
|
}
|
||||||
if (importance >= IMPORTANCE_DEFAULT) {
|
if (importance >= IMPORTANCE_DEFAULT) {
|
||||||
|
parent.findViewById(R.id.silence_summary).setVisibility(GONE);
|
||||||
|
TextView view = parent.findViewById(R.id.alert_summary);
|
||||||
view.setText(R.string.notification_channel_summary_default);
|
view.setText(R.string.notification_channel_summary_default);
|
||||||
|
view.setVisibility(VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
parent.findViewById(R.id.alert_summary).setVisibility(GONE);
|
||||||
|
TextView view = parent.findViewById(R.id.silence_summary);
|
||||||
|
view.setVisibility(VISIBLE);
|
||||||
if (mDisplayInStatusBar) {
|
if (mDisplayInStatusBar) {
|
||||||
if (mDisplayOnLockscreen) {
|
if (mDisplayOnLockscreen) {
|
||||||
view.setText(R.string.notification_channel_summary_low_status_lock);
|
view.setText(R.string.notification_channel_summary_low_status_lock);
|
||||||
|
@@ -22,6 +22,7 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
|||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
|
||||||
@@ -64,7 +65,8 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
|||||||
pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
|
pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
|
||||||
pref.setImportance(mChannel.getImportance());
|
pref.setImportance(mChannel.getImportance());
|
||||||
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
|
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
|
||||||
// TODO: b/128445911 pass along lock screen setting
|
pref.setDisplayOnLockscreen(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,10 @@ import static org.mockito.Mockito.verify;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -110,8 +113,8 @@ public class ImportancePreferenceTest {
|
|||||||
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
|
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
|
||||||
assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
|
assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
|
||||||
.isEqualTo(unselected);
|
.isEqualTo(unselected);
|
||||||
assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
|
assertThat(((TextView) holder.itemView.findViewById(R.id.alert_summary)).getText())
|
||||||
mContext.getString(R.string.notification_channel_summary_default));
|
.isEqualTo(mContext.getString(R.string.notification_channel_summary_default));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -129,28 +132,32 @@ public class ImportancePreferenceTest {
|
|||||||
preference.setImportance(IMPORTANCE_DEFAULT);
|
preference.setImportance(IMPORTANCE_DEFAULT);
|
||||||
preference.onBindViewHolder(holder);
|
preference.onBindViewHolder(holder);
|
||||||
|
|
||||||
Button silenceButton = holder.itemView.findViewById(R.id.silence);
|
View silenceButton = holder.itemView.findViewById(R.id.silence);
|
||||||
|
|
||||||
silenceButton.callOnClick();
|
silenceButton.callOnClick();
|
||||||
|
|
||||||
assertThat(holder.itemView.findViewById(R.id.alert).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).getBackground()).isEqualTo(selected);
|
||||||
assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
|
|
||||||
mContext.getString(R.string.notification_channel_summary_low));
|
|
||||||
|
|
||||||
verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
|
verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setImportanceSummary_status() {
|
public void setImportanceSummary_status() {
|
||||||
|
ViewGroup parent = new LinearLayout(mContext);
|
||||||
TextView tv = new TextView(mContext);
|
TextView tv = new TextView(mContext);
|
||||||
|
tv.setId(R.id.silence_summary);
|
||||||
|
parent.addView(tv);
|
||||||
|
TextView other = new TextView(mContext);
|
||||||
|
other.setId(R.id.alert_summary);
|
||||||
|
parent.addView(other);
|
||||||
|
|
||||||
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(true);
|
preference.setDisplayInStatusBar(true);
|
||||||
preference.setDisplayOnLockscreen(false);
|
preference.setDisplayOnLockscreen(false);
|
||||||
|
|
||||||
preference.setImportanceSummary(tv, IMPORTANCE_LOW);
|
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
|
||||||
|
|
||||||
assertThat(tv.getText()).isEqualTo(
|
assertThat(tv.getText()).isEqualTo(
|
||||||
mContext.getString(R.string.notification_channel_summary_low_status));
|
mContext.getString(R.string.notification_channel_summary_low_status));
|
||||||
@@ -158,14 +165,20 @@ public class ImportancePreferenceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setImportanceSummary_lock() {
|
public void setImportanceSummary_lock() {
|
||||||
|
ViewGroup parent = new LinearLayout(mContext);
|
||||||
TextView tv = new TextView(mContext);
|
TextView tv = new TextView(mContext);
|
||||||
|
tv.setId(R.id.silence_summary);
|
||||||
|
parent.addView(tv);
|
||||||
|
TextView other = new TextView(mContext);
|
||||||
|
other.setId(R.id.alert_summary);
|
||||||
|
parent.addView(other);
|
||||||
|
|
||||||
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(false);
|
preference.setDisplayInStatusBar(false);
|
||||||
preference.setDisplayOnLockscreen(true);
|
preference.setDisplayOnLockscreen(true);
|
||||||
|
|
||||||
preference.setImportanceSummary(tv, IMPORTANCE_LOW);
|
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
|
||||||
|
|
||||||
assertThat(tv.getText()).isEqualTo(
|
assertThat(tv.getText()).isEqualTo(
|
||||||
mContext.getString(R.string.notification_channel_summary_low_lock));
|
mContext.getString(R.string.notification_channel_summary_low_lock));
|
||||||
@@ -173,14 +186,20 @@ public class ImportancePreferenceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setImportanceSummary_statusLock() {
|
public void setImportanceSummary_statusLock() {
|
||||||
|
ViewGroup parent = new LinearLayout(mContext);
|
||||||
TextView tv = new TextView(mContext);
|
TextView tv = new TextView(mContext);
|
||||||
|
tv.setId(R.id.silence_summary);
|
||||||
|
parent.addView(tv);
|
||||||
|
TextView other = new TextView(mContext);
|
||||||
|
other.setId(R.id.alert_summary);
|
||||||
|
parent.addView(other);
|
||||||
|
|
||||||
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(true);
|
preference.setDisplayInStatusBar(true);
|
||||||
preference.setDisplayOnLockscreen(true);
|
preference.setDisplayOnLockscreen(true);
|
||||||
|
|
||||||
preference.setImportanceSummary(tv, IMPORTANCE_LOW);
|
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
|
||||||
|
|
||||||
assertThat(tv.getText()).isEqualTo(
|
assertThat(tv.getText()).isEqualTo(
|
||||||
mContext.getString(R.string.notification_channel_summary_low_status_lock));
|
mContext.getString(R.string.notification_channel_summary_low_status_lock));
|
||||||
@@ -188,14 +207,20 @@ public class ImportancePreferenceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setImportanceSummary_statusLock_default() {
|
public void setImportanceSummary_statusLock_default() {
|
||||||
|
ViewGroup parent = new LinearLayout(mContext);
|
||||||
TextView tv = new TextView(mContext);
|
TextView tv = new TextView(mContext);
|
||||||
|
tv.setId(R.id.alert_summary);
|
||||||
|
parent.addView(tv);
|
||||||
|
TextView other = new TextView(mContext);
|
||||||
|
other.setId(R.id.silence_summary);
|
||||||
|
parent.addView(other);
|
||||||
|
|
||||||
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
final ImportancePreference preference = spy(new ImportancePreference(mContext));
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(true);
|
preference.setDisplayInStatusBar(true);
|
||||||
preference.setDisplayOnLockscreen(true);
|
preference.setDisplayOnLockscreen(true);
|
||||||
|
|
||||||
preference.setImportanceSummary(tv, IMPORTANCE_DEFAULT);
|
preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true);
|
||||||
|
|
||||||
assertThat(tv.getText()).isEqualTo(
|
assertThat(tv.getText()).isEqualTo(
|
||||||
mContext.getString(R.string.notification_channel_summary_default));
|
mContext.getString(R.string.notification_channel_summary_default));
|
||||||
|
Reference in New Issue
Block a user