Fix notification preferences

- ImportancePreference should not be separately clickable
- new strings

Bug: 127796543
Fixes: 131060409
Test: make sure talkback doesn't read 'double tap to activate' when
the preference is focused

Change-Id: I6b6eef0915873b4e0b44c59758e5f4b5a265364b
This commit is contained in:
Julia Reynolds
2019-04-22 10:30:41 -04:00
parent 4d03377901
commit e103aa8fd2
6 changed files with 46 additions and 23 deletions

View File

@@ -7810,19 +7810,19 @@
<string name="asst_capability_prioritizer_title">Automatic Prioritization</string> <string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=200] --> <!-- Configure Notifications: setting summary [CHAR LIMIT=200] -->
<string name="asst_capability_prioritizer_summary">Automatically de-prioritize less important notifications to the gentle section</string> <string name="asst_capability_prioritizer_summary">Automatically prioritize important notifications</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] --> <!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="asst_capabilities_actions_replies_title">Smart actions and replies</string> <string name="asst_capabilities_actions_replies_title">Smart actions and replies</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=200] --> <!-- Configure Notifications: setting summary [CHAR LIMIT=200] -->
<string name="asst_capabilities_actions_replies_summary">Automatically add suggested actions and replies to notifications</string> <string name="asst_capabilities_actions_replies_summary">Automatically show suggested actions &amp; replies</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] --> <!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="hide_silent_icons_title">Hide silent notification status icons</string> <string name="hide_silent_icons_title">Hide icons from gentle notifications</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=NONE] --> <!-- Configure Notifications: setting summary [CHAR LIMIT=NONE] -->
<string name="hide_silent_icons_summary">Hide icons for silent notifications in the status bar</string> <string name="hide_silent_icons_summary">Icons from gentle notifications aren\'t shown in the status bar</string>
<!-- Configure Notifications: Title for the notification badging option. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=5125022693565388760] --> <!-- Configure Notifications: Title for the notification badging option. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=5125022693565388760] -->
<string name="notification_badging_title">Allow notification dots</string> <string name="notification_badging_title">Allow notification dots</string>
@@ -7979,33 +7979,38 @@
<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=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low">Gentle notifications will display in pull-down list</string> <string name="notification_channel_summary_low">Always silent. Displays in pull-down shade.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary --> <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low_status">Gentle notifications will display in pull-down list &amp; status bar</string> <string name="notification_channel_summary_low_status">Always silent. Displays in pull-down shade &amp; status bar.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary --> <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low_lock">Gentle notifications will display in pull-down list &amp; on lock screen</string> <string name="notification_channel_summary_low_lock">Always silent. Displays in pull-down shade &amp; on lock screen.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary --> <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low_status_lock">Gentle notifications will display in pull-down list, status bar &amp; on lock screen</string> <string name="notification_channel_summary_low_status_lock">Always silent. Displays in pull-down shade, status bar &amp; on lock screen.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary --> <!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary -->
<string name="notification_channel_summary_default">Prioritized notifications will alert and display in pull-down list, status bar &amp; on lock screen</string> <string name="notification_channel_summary_default">Makes sound and displays in pull-down shade, status bar &amp; on lock screen.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary --> <!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary -->
<string name="notification_channel_summary_high">When phone is unlocked, show notifications as a banner across top of 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 -->
<string name="notification_switch_label">Show notifications</string> <string name="notification_switch_label">Show notifications</string>
<!-- Default Apps > Default notification assistant --> <!-- Default Apps > Default notification assistant -->
<string name="default_notification_assistant">Notification assistant</string> <string name="default_notification_assistant">Smart notifications</string>
<!-- app summary of notification app list screen [CHAR LIMIT=100] --> <!-- app summary of notification app list screen [CHAR LIMIT=100] -->
<string name="notifications_sent_daily">~<xliff:g id="number">%1$s</xliff:g> per day</string> <plurals name="notifications_sent_daily">
<!-- app summary of notification app list screen [CHAR LIMIT=100] --> <item quantity="one">~<xliff:g id="number">%d</xliff:g> notification per day</item>
<string name="notifications_sent_weekly">~<xliff:g id="number">%1$s</xliff:g> per week</string> <item quantity="other">~<xliff:g id="number">%d</xliff:g> notifications per day</item>
</plurals>
<plurals name="notifications_sent_weekly">
<item quantity="one">~<xliff:g id="number">%d</xliff:g> notification per week</item>
<item quantity="other">~<xliff:g id="number">%d</xliff:g> notifications per week</item>
</plurals>
<!-- app summary of notification app list screen [CHAR LIMIT=100] --> <!-- app summary of notification app list screen [CHAR LIMIT=100] -->
<string name="notifications_sent_never">Never</string> <string name="notifications_sent_never">Never</string>
@@ -8027,10 +8032,10 @@
</plurals> </plurals>
<!-- Title for Notification Assistant Picker screen [CHAR LIMIT=30]--> <!-- Title for Notification Assistant Picker screen [CHAR LIMIT=30]-->
<string name="notification_assistant_title">Notification Assistant</string> <string name="notification_assistant_title">Smart notifications</string>
<!-- Label for no NotificationAssistantService [CHAR_LIMIT=NONE] --> <!-- Label for no NotificationAssistantService [CHAR_LIMIT=NONE] -->
<string name="no_notification_assistant">No assistant</string> <string name="no_notification_assistant">None</string>
<!-- String to show in the list of notification listeners, when none is installed --> <!-- String to show in the list of notification listeners, when none is installed -->
<string name="no_notification_listeners">No installed apps have requested notification access.</string> <string name="no_notification_listeners">No installed apps have requested notification access.</string>

View File

@@ -108,10 +108,12 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
return StringUtil.formatRelativeTime( return StringUtil.formatRelativeTime(
context, System.currentTimeMillis() - state.lastSent, true); context, System.currentTimeMillis() - state.lastSent, true);
} else if (sortOrder == R.id.sort_order_frequent_notification) { } else if (sortOrder == R.id.sort_order_frequent_notification) {
if (state.avgSentWeekly > 0) { if (state.avgSentDaily > 0) {
return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly); return context.getResources().getQuantityString(
R.plurals.notifications_sent_daily, state.avgSentDaily, state.avgSentDaily);
} }
return context.getString(R.string.notifications_sent_daily, state.avgSentDaily); return context.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
state.avgSentWeekly, state.avgSentWeekly);
} else { } else {
return ""; return "";
} }

View File

@@ -91,6 +91,7 @@ public class ImportancePreference extends Preference {
@Override @Override
public void onBindViewHolder(PreferenceViewHolder holder) { public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder); super.onBindViewHolder(holder);
holder.itemView.setClickable(false);
TextView textView = (TextView) holder.findViewById(R.id.description); TextView textView = (TextView) holder.findViewById(R.id.description);
mSilenceButton = (Button) holder.findViewById(R.id.silence); mSilenceButton = (Button) holder.findViewById(R.id.silence);

View File

@@ -425,10 +425,12 @@ public class NotificationBackend {
return StringUtil.formatRelativeTime( return StringUtil.formatRelativeTime(
context, System.currentTimeMillis() - state.lastSent, true); context, System.currentTimeMillis() - state.lastSent, true);
} else { } else {
if (state.avgSentWeekly > 0) { if (state.avgSentDaily > 0) {
return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly); return context.getResources().getQuantityString(R.plurals.notifications_sent_daily,
state.avgSentDaily, state.avgSentDaily);
} }
return context.getString(R.string.notifications_sent_daily, state.avgSentDaily); return context.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
state.avgSentWeekly, state.avgSentWeekly);
} }
} }

View File

@@ -397,9 +397,21 @@ public class AppStateNotificationBridgeTest {
assertThat(AppStateNotificationBridge.getSummary( assertThat(AppStateNotificationBridge.getSummary(
mContext, sentRarely, R.id.sort_order_frequent_notification).toString()) mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
.contains("1"); .contains("1");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
.contains("notification ");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
.contains("week");
assertThat(AppStateNotificationBridge.getSummary( assertThat(AppStateNotificationBridge.getSummary(
mContext, sentOften, R.id.sort_order_frequent_notification).toString()) mContext, sentOften, R.id.sort_order_frequent_notification).toString())
.contains("8"); .contains("8");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentOften, R.id.sort_order_frequent_notification).toString())
.contains("notifications");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentOften, R.id.sort_order_frequent_notification).toString())
.contains("day");
} }
@Test @Test

View File

@@ -151,7 +151,8 @@ public class NotificationChannelSliceTest {
for (int i = 0; i < rowItems.size(); i++) { for (int i = 0; i < rowItems.size(); i++) {
// Assert the summary text is the same as expectation. // Assert the summary text is the same as expectation.
assertThat(getSummaryFromSliceItem(rowItems.get(i))).isEqualTo( assertThat(getSummaryFromSliceItem(rowItems.get(i))).isEqualTo(
mContext.getString(R.string.notifications_sent_weekly, CHANNEL_COUNT - i)); mContext.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
CHANNEL_COUNT - i, CHANNEL_COUNT - i));
} }
} }