Loading res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -8409,6 +8409,15 @@ <!-- [CHAR LIMIT=100] link to page listing all conversations --> <string name="manage_conversations">Manage conversations</string> <!-- [CHAR LIMIT=100] summary text on link to 'all conversations' page, no conversations are priority --> <string name="priority_conversation_count_zero">No priority conversations</string> <!-- [CHAR LIMIT=100] summary text on link to 'all conversations' page, some conversations are priority --> <plurals name="priority_conversation_count"> <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> priority conversation</item> <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> priority conversations</item> </plurals> <!-- [CHAR LIMIT=100] preference category title --> <string name="important_conversations">Priority conversations</string> res/xml/app_and_notification.xml +8 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,14 @@ android:layout="@layout/preference_category_no_label" android:order="-997"/> <Preference android:key="conversations" android:title="@string/conversations_category_title" android:order="-550" settings:controller="com.android.settings.notification.ConversationListSummaryPreferenceController" android:fragment="com.android.settings.notification.app.ConversationListSettings" /> <Preference android:key="configure_notification_settings" android:title="@string/configure_notification_settings" Loading res/xml/configure_notification_settings.xml +0 −8 Original line number Diff line number Diff line Loading @@ -38,14 +38,6 @@ android:targetClass="com.android.settings.notification.history.NotificationHistoryActivity" /> </Preference> <Preference android:key="conversations" android:title="@string/conversations_category_title" android:summary="@string/manage_conversations" android:order="3" android:fragment="com.android.settings.notification.app.ConversationListSettings" /> <Preference android:key="notification_bubbles" android:title="@string/notification_bubbles_title" Loading src/com/android/settings/notification/ConversationListSummaryPreferenceController.java 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.notification; import android.content.Context; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; public class ConversationListSummaryPreferenceController extends BasePreferenceController { private NotificationBackend mBackend; public ConversationListSummaryPreferenceController(Context context, String key) { super(context, key); mBackend = new NotificationBackend(); } @Override public int getAvailabilityStatus() { return AVAILABLE; } @Override public CharSequence getSummary() { final int count = mBackend.getConversations(true).getList().size(); if (count == 0) { return mContext.getText(R.string.priority_conversation_count_zero); } return mContext.getResources().getQuantityString( R.plurals.priority_conversation_count, count, count); } void setBackend(NotificationBackend backend) { mBackend = backend; } } tests/robotests/src/com/android/settings/notification/ConversationListSummaryPreferenceControllerTest.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.notification; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.ParceledListSlice; import android.service.notification.ConversationChannelWrapper; import com.android.settings.testutils.shadow.ShadowNotificationBackend; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.util.ArrayList; import java.util.List; @RunWith(RobolectricTestRunner.class) @Config(shadows = ShadowNotificationBackend.class) public class ConversationListSummaryPreferenceControllerTest { private ConversationListSummaryPreferenceController mController; private Context mContext; @Mock NotificationBackend mBackend; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mController = new ConversationListSummaryPreferenceController(mContext, "key"); mController.setBackend(mBackend); } @Test public void getSummary_noPriorityConversations() { List<ConversationChannelWrapper> convos = new ArrayList<>(); when(mBackend.getConversations(true)).thenReturn( new ParceledListSlice<>(convos)); assertThat(mController.getSummary().toString()).contains("No"); } @Test public void getSummary_somePriorityConversations() { List<ConversationChannelWrapper> convos = new ArrayList<>(); convos.add(mock(ConversationChannelWrapper.class)); convos.add(mock(ConversationChannelWrapper.class)); when(mBackend.getConversations(true)).thenReturn( new ParceledListSlice<>(convos)); assertThat(mController.getSummary().toString()).contains("2"); assertThat(mController.getSummary().toString()).contains("conversations"); } } Loading
res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -8409,6 +8409,15 @@ <!-- [CHAR LIMIT=100] link to page listing all conversations --> <string name="manage_conversations">Manage conversations</string> <!-- [CHAR LIMIT=100] summary text on link to 'all conversations' page, no conversations are priority --> <string name="priority_conversation_count_zero">No priority conversations</string> <!-- [CHAR LIMIT=100] summary text on link to 'all conversations' page, some conversations are priority --> <plurals name="priority_conversation_count"> <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> priority conversation</item> <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> priority conversations</item> </plurals> <!-- [CHAR LIMIT=100] preference category title --> <string name="important_conversations">Priority conversations</string>
res/xml/app_and_notification.xml +8 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,14 @@ android:layout="@layout/preference_category_no_label" android:order="-997"/> <Preference android:key="conversations" android:title="@string/conversations_category_title" android:order="-550" settings:controller="com.android.settings.notification.ConversationListSummaryPreferenceController" android:fragment="com.android.settings.notification.app.ConversationListSettings" /> <Preference android:key="configure_notification_settings" android:title="@string/configure_notification_settings" Loading
res/xml/configure_notification_settings.xml +0 −8 Original line number Diff line number Diff line Loading @@ -38,14 +38,6 @@ android:targetClass="com.android.settings.notification.history.NotificationHistoryActivity" /> </Preference> <Preference android:key="conversations" android:title="@string/conversations_category_title" android:summary="@string/manage_conversations" android:order="3" android:fragment="com.android.settings.notification.app.ConversationListSettings" /> <Preference android:key="notification_bubbles" android:title="@string/notification_bubbles_title" Loading
src/com/android/settings/notification/ConversationListSummaryPreferenceController.java 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.notification; import android.content.Context; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; public class ConversationListSummaryPreferenceController extends BasePreferenceController { private NotificationBackend mBackend; public ConversationListSummaryPreferenceController(Context context, String key) { super(context, key); mBackend = new NotificationBackend(); } @Override public int getAvailabilityStatus() { return AVAILABLE; } @Override public CharSequence getSummary() { final int count = mBackend.getConversations(true).getList().size(); if (count == 0) { return mContext.getText(R.string.priority_conversation_count_zero); } return mContext.getResources().getQuantityString( R.plurals.priority_conversation_count, count, count); } void setBackend(NotificationBackend backend) { mBackend = backend; } }
tests/robotests/src/com/android/settings/notification/ConversationListSummaryPreferenceControllerTest.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.notification; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.ParceledListSlice; import android.service.notification.ConversationChannelWrapper; import com.android.settings.testutils.shadow.ShadowNotificationBackend; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import java.util.ArrayList; import java.util.List; @RunWith(RobolectricTestRunner.class) @Config(shadows = ShadowNotificationBackend.class) public class ConversationListSummaryPreferenceControllerTest { private ConversationListSummaryPreferenceController mController; private Context mContext; @Mock NotificationBackend mBackend; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mController = new ConversationListSummaryPreferenceController(mContext, "key"); mController.setBackend(mBackend); } @Test public void getSummary_noPriorityConversations() { List<ConversationChannelWrapper> convos = new ArrayList<>(); when(mBackend.getConversations(true)).thenReturn( new ParceledListSlice<>(convos)); assertThat(mController.getSummary().toString()).contains("No"); } @Test public void getSummary_somePriorityConversations() { List<ConversationChannelWrapper> convos = new ArrayList<>(); convos.add(mock(ConversationChannelWrapper.class)); convos.add(mock(ConversationChannelWrapper.class)); when(mBackend.getConversations(true)).thenReturn( new ParceledListSlice<>(convos)); assertThat(mController.getSummary().toString()).contains("2"); assertThat(mController.getSummary().toString()).contains("conversations"); } }