Loading src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java +8 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.notification.NotificationBackend; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.widget.LayoutPreference; Loading @@ -44,8 +45,9 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen private EntityHeaderController mHeaderController; private boolean mStarted = false; public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) { super(context, null); public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment, NotificationBackend backend) { super(context, backend); mFragment = fragment; } Loading Loading @@ -99,20 +101,20 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen @Override public CharSequence getSummary() { if (mChannel != null && !isDefaultChannel()) { CharSequence parentChannelLabel = mBackend.getChannel(mAppRow.pkg, mAppRow.uid, mChannel.getParentChannelId()).getName(); if (mChannelGroup != null && !TextUtils.isEmpty(mChannelGroup.getName())) { final SpannableStringBuilder summary = new SpannableStringBuilder(); BidiFormatter bidi = BidiFormatter.getInstance(); summary.append(bidi.unicodeWrap(mAppRow.label.toString())); summary.append(bidi.unicodeWrap(parentChannelLabel)); summary.append(bidi.unicodeWrap(mContext.getText( R.string.notification_header_divider_symbol_with_spaces))); summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString())); return summary.toString(); } else { return mAppRow.label.toString(); return parentChannelLabel; } } else if (mChannelGroup != null) { return mAppRow.label.toString(); } else { return ""; } Loading src/com/android/settings/notification/app/ConversationNotificationSettings.java +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ public class ConversationNotificationSettings extends NotificationSettings { @Override protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { mControllers = new ArrayList<>(); mControllers.add(new ConversationHeaderPreferenceController(context, this)); mControllers.add(new ConversationHeaderPreferenceController(context, this, mBackend)); mControllers.add(new BlockPreferenceController(context, mDependentFieldListener, mBackend)); mControllers.add(new ConversationPriorityPreferenceController( context, mBackend, mDependentFieldListener)); Loading tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java +12 −4 Original line number Diff line number Diff line Loading @@ -70,6 +70,8 @@ public class ConversationHeaderPreferenceControllerTest { private LayoutPreference mPreference; @Mock private View mView; @Mock private NotificationBackend mBackend; @Before public void setUp() { Loading @@ -83,7 +85,7 @@ public class ConversationHeaderPreferenceControllerTest { FragmentActivity activity = mock(FragmentActivity.class); when(activity.getApplicationContext()).thenReturn(mContext); when(fragment.getActivity()).thenReturn(activity); mController = spy(new ConversationHeaderPreferenceController(mContext, fragment)); mController = spy(new ConversationHeaderPreferenceController(mContext, fragment, mBackend)); when(mPreference.findViewById(anyInt())).thenReturn(mView); } Loading Loading @@ -134,22 +136,28 @@ public class ConversationHeaderPreferenceControllerTest { @Test public void testGetSummary() { NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); appRow.pkg = "pkg"; appRow.uid = 123456; appRow.label = "bananas"; when(mBackend.getChannel(appRow.pkg, appRow.uid, "parent")).thenReturn( new NotificationChannel("parent", "PARENT", 2)); mController.onResume(appRow, null, null, null, null, null, null); assertEquals("", mController.getSummary()); NotificationChannelGroup group = new NotificationChannelGroup("id", "name"); mController.onResume(appRow, null, group, null, null, null, null); assertEquals(appRow.label, mController.getSummary()); assertEquals("", mController.getSummary()); NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE); channel.setConversationId("parent", "convo"); mController.onResume(appRow, channel, group, null, null, null, null); assertTrue(mController.getSummary().toString().contains(group.getName())); assertTrue(mController.getSummary().toString().contains(appRow.label)); assertTrue(mController.getSummary().toString().contains("PARENT")); mController.onResume(appRow, channel, null, null, null, null, null); assertFalse(mController.getSummary().toString().contains(group.getName())); assertTrue(mController.getSummary().toString().contains(appRow.label)); assertTrue(mController.getSummary().toString().contains("PARENT")); NotificationChannel defaultChannel = new NotificationChannel( NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE); Loading Loading
src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java +8 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.notification.NotificationBackend; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.widget.LayoutPreference; Loading @@ -44,8 +45,9 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen private EntityHeaderController mHeaderController; private boolean mStarted = false; public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) { super(context, null); public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment, NotificationBackend backend) { super(context, backend); mFragment = fragment; } Loading Loading @@ -99,20 +101,20 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen @Override public CharSequence getSummary() { if (mChannel != null && !isDefaultChannel()) { CharSequence parentChannelLabel = mBackend.getChannel(mAppRow.pkg, mAppRow.uid, mChannel.getParentChannelId()).getName(); if (mChannelGroup != null && !TextUtils.isEmpty(mChannelGroup.getName())) { final SpannableStringBuilder summary = new SpannableStringBuilder(); BidiFormatter bidi = BidiFormatter.getInstance(); summary.append(bidi.unicodeWrap(mAppRow.label.toString())); summary.append(bidi.unicodeWrap(parentChannelLabel)); summary.append(bidi.unicodeWrap(mContext.getText( R.string.notification_header_divider_symbol_with_spaces))); summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString())); return summary.toString(); } else { return mAppRow.label.toString(); return parentChannelLabel; } } else if (mChannelGroup != null) { return mAppRow.label.toString(); } else { return ""; } Loading
src/com/android/settings/notification/app/ConversationNotificationSettings.java +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ public class ConversationNotificationSettings extends NotificationSettings { @Override protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { mControllers = new ArrayList<>(); mControllers.add(new ConversationHeaderPreferenceController(context, this)); mControllers.add(new ConversationHeaderPreferenceController(context, this, mBackend)); mControllers.add(new BlockPreferenceController(context, mDependentFieldListener, mBackend)); mControllers.add(new ConversationPriorityPreferenceController( context, mBackend, mDependentFieldListener)); Loading
tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java +12 −4 Original line number Diff line number Diff line Loading @@ -70,6 +70,8 @@ public class ConversationHeaderPreferenceControllerTest { private LayoutPreference mPreference; @Mock private View mView; @Mock private NotificationBackend mBackend; @Before public void setUp() { Loading @@ -83,7 +85,7 @@ public class ConversationHeaderPreferenceControllerTest { FragmentActivity activity = mock(FragmentActivity.class); when(activity.getApplicationContext()).thenReturn(mContext); when(fragment.getActivity()).thenReturn(activity); mController = spy(new ConversationHeaderPreferenceController(mContext, fragment)); mController = spy(new ConversationHeaderPreferenceController(mContext, fragment, mBackend)); when(mPreference.findViewById(anyInt())).thenReturn(mView); } Loading Loading @@ -134,22 +136,28 @@ public class ConversationHeaderPreferenceControllerTest { @Test public void testGetSummary() { NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); appRow.pkg = "pkg"; appRow.uid = 123456; appRow.label = "bananas"; when(mBackend.getChannel(appRow.pkg, appRow.uid, "parent")).thenReturn( new NotificationChannel("parent", "PARENT", 2)); mController.onResume(appRow, null, null, null, null, null, null); assertEquals("", mController.getSummary()); NotificationChannelGroup group = new NotificationChannelGroup("id", "name"); mController.onResume(appRow, null, group, null, null, null, null); assertEquals(appRow.label, mController.getSummary()); assertEquals("", mController.getSummary()); NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE); channel.setConversationId("parent", "convo"); mController.onResume(appRow, channel, group, null, null, null, null); assertTrue(mController.getSummary().toString().contains(group.getName())); assertTrue(mController.getSummary().toString().contains(appRow.label)); assertTrue(mController.getSummary().toString().contains("PARENT")); mController.onResume(appRow, channel, null, null, null, null, null); assertFalse(mController.getSummary().toString().contains(group.getName())); assertTrue(mController.getSummary().toString().contains(appRow.label)); assertTrue(mController.getSummary().toString().contains("PARENT")); NotificationChannel defaultChannel = new NotificationChannel( NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE); Loading