Search in sources :

Example 1 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testRemoveConversation.

@Test
public void testRemoveConversation() throws Exception {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getId()).thenReturn("person");
    when(si.getPackage()).thenReturn("pkg");
    ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "channel", 4), new NotificationChannelGroup("hi", "group"), 7, false);
    RecentConversationPreference pref = (RecentConversationPreference) mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    final View view = View.inflate(mContext, pref.getLayoutResource(), null);
    PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
    View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
    when(holder.findViewById(pref.getClearId())).thenReturn(delete);
    pref.onBindViewHolder(holder);
    pref.getClearView().performClick();
    verify(mPs).removeRecentConversation(si.getPackage(), UserHandle.getUserId(ccw.getUid()), si.getId());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) PreferenceCategory(androidx.preference.PreferenceCategory) View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 2 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testPopulateList_validConversations.

@Test
public void testPopulateList_validConversations() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
    PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
    ps.addPreference(outerContainer);
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, false);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    // one for the preference, one for the button ro clear all
    verify(outerContainer, times(2)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) PreferenceScreen(androidx.preference.PreferenceScreen) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 3 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method getSummary_noGroup.

@Test
public void getSummary_noGroup() {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getLabel()).thenReturn("person");
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "channel", 4), null, 7, true);
    assertThat(mController.getSummary(ccw).toString()).isEqualTo(ccw.getNotificationChannel().getName());
}
Also used : NotificationChannel(android.app.NotificationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) Test(org.junit.Test)

Example 4 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testNullSpans.

@Test
public void testNullSpans() {
    ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), null, 7, true);
    ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true);
    // no crash
    mController.mConversationComparator.compare(ccw, ccw2);
}
Also used : NotificationChannel(android.app.NotificationChannel) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) Test(org.junit.Test)

Example 5 with ConversationChannel

use of android.app.people.ConversationChannel in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceController method populateConversations.

protected boolean populateConversations(List<ConversationChannel> conversations, PreferenceGroup containerGroup) {
    int order = 100;
    boolean hasClearable = false;
    for (ConversationChannel conversation : conversations) {
        if (conversation.getNotificationChannel().getImportance() == IMPORTANCE_NONE || (conversation.getNotificationChannelGroup() != null && conversation.getNotificationChannelGroup().isBlocked())) {
            continue;
        }
        RecentConversationPreference pref = createConversationPref(containerGroup, conversation, order++);
        containerGroup.addPreference(pref);
        if (pref.hasClearListener()) {
            hasClearable = true;
        }
    }
    return hasClearable;
}
Also used : ConversationChannel(android.app.people.ConversationChannel)

Aggregations

ConversationChannel (android.app.people.ConversationChannel)14 NotificationChannel (android.app.NotificationChannel)13 ShortcutInfo (android.content.pm.ShortcutInfo)13 Test (org.junit.Test)13 NotificationChannelGroup (android.app.NotificationChannelGroup)10 PreferenceCategory (androidx.preference.PreferenceCategory)7 PreferenceManager (androidx.preference.PreferenceManager)3 PreferenceScreen (androidx.preference.PreferenceScreen)3 ArrayList (java.util.ArrayList)3 View (android.view.View)2 Preference (androidx.preference.Preference)2 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)2 LayoutPreference (com.android.settingslib.widget.LayoutPreference)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 SpannedString (android.text.SpannedString)1