From e103aa8fd277c94ff9d532de50ad0945dc3d86c7 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Mon, 22 Apr 2019 10:30:41 -0400 Subject: [PATCH] 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 --- res/values/strings.xml | 37 +++++++++++-------- .../AppStateNotificationBridge.java | 8 ++-- .../notification/ImportancePreference.java | 1 + .../notification/NotificationBackend.java | 8 ++-- .../AppStateNotificationBridgeTest.java | 12 ++++++ .../slices/NotificationChannelSliceTest.java | 3 +- 6 files changed, 46 insertions(+), 23 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 525e32cd81d..acd3bdaed22 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7810,19 +7810,19 @@ Automatic Prioritization - Automatically de-prioritize less important notifications to the gentle section + Automatically prioritize important notifications Smart actions and replies - Automatically add suggested actions and replies to notifications + Automatically show suggested actions & replies - Hide silent notification status icons + Hide icons from gentle notifications - Hide icons for silent notifications in the status bar + Icons from gentle notifications aren\'t shown in the status bar Allow notification dots @@ -7979,33 +7979,38 @@ In the pull-down shade, collapse notifications to one line - Gentle notifications will display in pull-down list + Always silent. Displays in pull-down shade. - Gentle notifications will display in pull-down list & status bar + Always silent. Displays in pull-down shade & status bar. - Gentle notifications will display in pull-down list & on lock screen + Always silent. Displays in pull-down shade & on lock screen. - Gentle notifications will display in pull-down list, status bar & on lock screen + Always silent. Displays in pull-down shade, status bar & on lock screen. - Prioritized notifications will alert and display in pull-down list, status bar & on lock screen + Makes sound and displays in pull-down shade, status bar & on lock screen. - When phone is unlocked, show notifications as a banner across top of screen + When device is unlocked, show notifications as a banner across the top of the screen Show notifications - Notification assistant + Smart notifications - ~%1$s per day - - ~%1$s per week + + ~%d notification per day + ~%d notifications per day + + + ~%d notification per week + ~%d notifications per week + Never @@ -8027,10 +8032,10 @@ - Notification Assistant + Smart notifications - No assistant + None No installed apps have requested notification access. diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java index 86f265eed80..d179642a63d 100644 --- a/src/com/android/settings/applications/AppStateNotificationBridge.java +++ b/src/com/android/settings/applications/AppStateNotificationBridge.java @@ -108,10 +108,12 @@ public class AppStateNotificationBridge extends AppStateBaseBridge { return StringUtil.formatRelativeTime( context, System.currentTimeMillis() - state.lastSent, true); } else if (sortOrder == R.id.sort_order_frequent_notification) { - if (state.avgSentWeekly > 0) { - return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly); + if (state.avgSentDaily > 0) { + 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 { return ""; } diff --git a/src/com/android/settings/notification/ImportancePreference.java b/src/com/android/settings/notification/ImportancePreference.java index 5572b125140..687782bdc0d 100644 --- a/src/com/android/settings/notification/ImportancePreference.java +++ b/src/com/android/settings/notification/ImportancePreference.java @@ -91,6 +91,7 @@ public class ImportancePreference extends Preference { @Override public void onBindViewHolder(PreferenceViewHolder holder) { super.onBindViewHolder(holder); + holder.itemView.setClickable(false); TextView textView = (TextView) holder.findViewById(R.id.description); mSilenceButton = (Button) holder.findViewById(R.id.silence); diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java index f27f9792e03..def820c990c 100644 --- a/src/com/android/settings/notification/NotificationBackend.java +++ b/src/com/android/settings/notification/NotificationBackend.java @@ -425,10 +425,12 @@ public class NotificationBackend { return StringUtil.formatRelativeTime( context, System.currentTimeMillis() - state.lastSent, true); } else { - if (state.avgSentWeekly > 0) { - return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly); + if (state.avgSentDaily > 0) { + 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); } } diff --git a/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java b/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java index 10f3706c7d0..24cb10dcc86 100644 --- a/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java +++ b/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java @@ -397,9 +397,21 @@ public class AppStateNotificationBridgeTest { assertThat(AppStateNotificationBridge.getSummary( mContext, sentRarely, R.id.sort_order_frequent_notification).toString()) .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( mContext, sentOften, R.id.sort_order_frequent_notification).toString()) .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 diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java index 81f5797c659..6c020f820b5 100644 --- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java +++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java @@ -151,7 +151,8 @@ public class NotificationChannelSliceTest { for (int i = 0; i < rowItems.size(); i++) { // Assert the summary text is the same as expectation. 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)); } }