Simplify channel importance settings screen
Back to bell icons, and removed the flavor text Test: visual Bug: 132971502 Change-Id: I55ce6dd07404aed2ceb5423796b733a70c3bfa13
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
<solid
|
<solid
|
||||||
android:color="@color/notification_importance_selection_bg" />
|
android:color="@color/notification_importance_selection_bg" />
|
||||||
<stroke
|
<stroke
|
||||||
android:width="1dp"
|
android:width="2dp"
|
||||||
android:color="@color/notification_importance_button_selected"/>
|
android:color="@color/notification_importance_button_selected"/>
|
||||||
<corners android:radius="@dimen/rect_button_radius" />
|
<corners android:radius="@dimen/rect_button_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/alert_icon"
|
android:id="@+id/alert_icon"
|
||||||
android:src="@drawable/ic_notification_alert"
|
android:src="@drawable/ic_notifications"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -63,7 +63,8 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:layout_below="@id/alert_icon"
|
android:layout_below="@id/alert_icon"
|
||||||
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
|
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
|
||||||
|
android:visibility="gone" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -76,7 +77,7 @@
|
|||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/silence_icon"
|
android:id="@+id/silence_icon"
|
||||||
android:src="@drawable/ic_notification_silence"
|
android:src="@drawable/ic_notifications_off_24dp"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -106,7 +107,8 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:layout_below="@id/silence_icon"
|
android:layout_below="@id/silence_icon"
|
||||||
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
|
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
|
||||||
|
android:visibility="gone" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@@ -8072,7 +8072,7 @@
|
|||||||
<string name="notification_block_title">Block</string>
|
<string name="notification_block_title">Block</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title -->
|
<!-- [CHAR LIMIT=100] Notification Importance title -->
|
||||||
<string name="notification_silence_title">Gentle</string>
|
<string name="notification_silence_title">Silent</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance title -->
|
<!-- [CHAR LIMIT=100] Notification Importance title -->
|
||||||
<string name="notification_alert_title">Prioritized</string>
|
<string name="notification_alert_title">Prioritized</string>
|
||||||
@@ -8089,19 +8089,10 @@
|
|||||||
<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=150] Notification Importance title: low importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
||||||
<string name="notification_channel_summary_low">Helps you focus with notifications only in the pull-down shade. Always silent.</string>
|
<string name="notification_channel_summary_low">Helps you focus without sound or vibration</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
|
||||||
<string name="notification_channel_summary_low_status">Displays below priority notifications. Always silent.</string>
|
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
|
||||||
<string name="notification_channel_summary_low_lock">Displays below priority notifications. Always silent.</string>
|
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
|
||||||
<string name="notification_channel_summary_low_status_lock">Displays below priority notifications. Always silent.</string>
|
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
|
<!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
|
||||||
<string name="notification_channel_summary_default">Gets your attention with sound & a status bar icon. Shows on lock screen.</string>
|
<string name="notification_channel_summary_default">Gets your attention with sound or vibration</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=150] 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>
|
||||||
|
@@ -24,6 +24,7 @@ import static android.view.View.GONE;
|
|||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.transition.AutoTransition;
|
import android.transition.AutoTransition;
|
||||||
import android.transition.TransitionManager;
|
import android.transition.TransitionManager;
|
||||||
@@ -31,8 +32,10 @@ import android.util.AttributeSet;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -50,6 +53,7 @@ public class ImportancePreference extends Preference {
|
|||||||
Drawable selectedBackground;
|
Drawable selectedBackground;
|
||||||
Drawable unselectedBackground;
|
Drawable unselectedBackground;
|
||||||
private static final int BUTTON_ANIM_TIME_MS = 100;
|
private static final int BUTTON_ANIM_TIME_MS = 100;
|
||||||
|
private static final boolean SHOW_BUTTON_SUMMARY = false;
|
||||||
|
|
||||||
public ImportancePreference(Context context, AttributeSet attrs,
|
public ImportancePreference(Context context, AttributeSet attrs,
|
||||||
int defStyleAttr, int defStyleRes) {
|
int defStyleAttr, int defStyleRes) {
|
||||||
@@ -140,32 +144,45 @@ public class ImportancePreference extends Preference {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ColorStateList getAccentTint() {
|
||||||
|
return Utils.getColorAccent(getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ColorStateList getRegularTint() {
|
||||||
|
return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary);
|
||||||
|
}
|
||||||
|
|
||||||
void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
|
void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
AutoTransition transition = new AutoTransition();
|
AutoTransition transition = new AutoTransition();
|
||||||
transition.setDuration(BUTTON_ANIM_TIME_MS);
|
transition.setDuration(BUTTON_ANIM_TIME_MS);
|
||||||
TransitionManager.beginDelayedTransition(parent, transition);
|
TransitionManager.beginDelayedTransition(parent, transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorStateList colorAccent = getAccentTint();
|
||||||
|
ColorStateList colorNormal = getRegularTint();
|
||||||
|
|
||||||
if (importance >= IMPORTANCE_DEFAULT) {
|
if (importance >= IMPORTANCE_DEFAULT) {
|
||||||
parent.findViewById(R.id.silence_summary).setVisibility(GONE);
|
parent.findViewById(R.id.silence_summary).setVisibility(GONE);
|
||||||
|
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorNormal);
|
||||||
|
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorNormal);
|
||||||
|
|
||||||
|
((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);
|
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);
|
view.setVisibility(VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
parent.findViewById(R.id.alert_summary).setVisibility(GONE);
|
parent.findViewById(R.id.alert_summary).setVisibility(GONE);
|
||||||
|
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorNormal);
|
||||||
|
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorNormal);
|
||||||
|
|
||||||
|
((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);
|
TextView view = parent.findViewById(R.id.silence_summary);
|
||||||
view.setVisibility(VISIBLE);
|
view.setVisibility(VISIBLE);
|
||||||
if (mDisplayInStatusBar) {
|
|
||||||
if (mDisplayOnLockscreen) {
|
|
||||||
view.setText(R.string.notification_channel_summary_low_status_lock);
|
|
||||||
} else {
|
|
||||||
view.setText(R.string.notification_channel_summary_low_status);
|
|
||||||
}
|
|
||||||
} else if (mDisplayOnLockscreen) {
|
|
||||||
view.setText(R.string.notification_channel_summary_low_lock);
|
|
||||||
} else {
|
|
||||||
view.setText(R.string.notification_channel_summary_low);
|
view.setText(R.string.notification_channel_summary_low);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -143,84 +144,44 @@ public class ImportancePreferenceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setImportanceSummary_status() {
|
public void setImportanceSummary() {
|
||||||
ViewGroup parent = new LinearLayout(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));
|
||||||
|
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||||
|
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
|
||||||
|
inflater.inflate(R.layout.notif_importance_preference, null));
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(true);
|
preference.setConfigurable(true);
|
||||||
preference.setDisplayOnLockscreen(false);
|
preference.setImportance(IMPORTANCE_DEFAULT);
|
||||||
|
preference.onBindViewHolder(holder);
|
||||||
|
|
||||||
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
|
TextView tv = holder.itemView.findViewById(R.id.silence_summary);
|
||||||
|
|
||||||
assertThat(tv.getText()).isEqualTo(
|
|
||||||
mContext.getString(R.string.notification_channel_summary_low_status));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setImportanceSummary_lock() {
|
|
||||||
ViewGroup parent = new LinearLayout(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));
|
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(false);
|
|
||||||
preference.setDisplayOnLockscreen(true);
|
|
||||||
|
|
||||||
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
|
|
||||||
|
|
||||||
assertThat(tv.getText()).isEqualTo(
|
|
||||||
mContext.getString(R.string.notification_channel_summary_low_lock));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setImportanceSummary_statusLock() {
|
|
||||||
ViewGroup parent = new LinearLayout(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));
|
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(true);
|
preference.setDisplayInStatusBar(true);
|
||||||
preference.setDisplayOnLockscreen(true);
|
preference.setDisplayOnLockscreen(true);
|
||||||
|
|
||||||
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
|
preference.setImportanceSummary((ViewGroup) holder.itemView, 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setImportanceSummary_statusLock_default() {
|
public void setImportanceSummary_default() {
|
||||||
ViewGroup parent = new LinearLayout(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));
|
||||||
|
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||||
|
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
|
||||||
|
inflater.inflate(R.layout.notif_importance_preference, null));
|
||||||
|
|
||||||
|
preference.setConfigurable(true);
|
||||||
|
preference.setImportance(IMPORTANCE_DEFAULT);
|
||||||
|
preference.onBindViewHolder(holder);
|
||||||
|
|
||||||
|
TextView tv = holder.itemView.findViewById(R.id.alert_summary);
|
||||||
|
|
||||||
preference.setDisplayInStatusBar(true);
|
preference.setDisplayInStatusBar(true);
|
||||||
preference.setDisplayOnLockscreen(true);
|
preference.setDisplayOnLockscreen(true);
|
||||||
|
|
||||||
preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true);
|
preference.setImportanceSummary((ViewGroup) holder.itemView, 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