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:
Evan Laird
2019-05-17 17:05:27 -04:00
parent f061ccf14d
commit 472e19eae4
5 changed files with 60 additions and 89 deletions

View File

@@ -19,7 +19,7 @@
<solid
android:color="@color/notification_importance_selection_bg" />
<stroke
android:width="1dp"
android:width="2dp"
android:color="@color/notification_importance_button_selected"/>
<corners android:radius="@dimen/rect_button_radius" />
</shape>

View File

@@ -33,7 +33,7 @@
android:focusable="true">
<ImageView
android:id="@+id/alert_icon"
android:src="@drawable/ic_notification_alert"
android:src="@drawable/ic_notifications"
android:background="@android:color/transparent"
android:layout_gravity="center"
android:layout_width="wrap_content"
@@ -63,7 +63,8 @@
android:ellipsize="end"
android:maxLines="2"
android:layout_below="@id/alert_icon"
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
@@ -76,7 +77,7 @@
android:focusable="true">
<ImageView
android:id="@+id/silence_icon"
android:src="@drawable/ic_notification_silence"
android:src="@drawable/ic_notifications_off_24dp"
android:background="@android:color/transparent"
android:layout_gravity="center"
android:layout_width="wrap_content"
@@ -106,7 +107,8 @@
android:ellipsize="end"
android:maxLines="2"
android:layout_below="@id/silence_icon"
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>

View File

@@ -8072,7 +8072,7 @@
<string name="notification_block_title">Block</string>
<!-- [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 -->
<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>
<!-- [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>
<!-- [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>
<string name="notification_channel_summary_low">Helps you focus without sound or vibration</string>
<!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
<string name="notification_channel_summary_default">Gets your attention with sound &amp; 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 -->
<string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>

View File

@@ -24,6 +24,7 @@ import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.transition.AutoTransition;
import android.transition.TransitionManager;
@@ -31,8 +32,10 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.settings.Utils;
import com.android.settingslib.R;
import androidx.preference.Preference;
@@ -50,6 +53,7 @@ public class ImportancePreference extends Preference {
Drawable selectedBackground;
Drawable unselectedBackground;
private static final int BUTTON_ANIM_TIME_MS = 100;
private static final boolean SHOW_BUTTON_SUMMARY = false;
public ImportancePreference(Context context, AttributeSet attrs,
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) {
if (fromUser) {
AutoTransition transition = new AutoTransition();
transition.setDuration(BUTTON_ANIM_TIME_MS);
TransitionManager.beginDelayedTransition(parent, transition);
}
ColorStateList colorAccent = getAccentTint();
ColorStateList colorNormal = getRegularTint();
if (importance >= IMPORTANCE_DEFAULT) {
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);
view.setText(R.string.notification_channel_summary_default);
view.setVisibility(VISIBLE);
} else {
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);
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 File

@@ -32,6 +32,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -143,84 +144,44 @@ public class ImportancePreferenceTest {
}
@Test
public void setImportanceSummary_status() {
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);
public void setImportanceSummary() {
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.setDisplayOnLockscreen(false);
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
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));
TextView tv = holder.itemView.findViewById(R.id.silence_summary);
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(true);
preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_status_lock));
mContext.getString(R.string.notification_channel_summary_low));
}
@Test
public void setImportanceSummary_statusLock_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);
public void setImportanceSummary_default() {
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.setDisplayOnLockscreen(true);
preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true);
preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_default));