Merge "Fix exception sorting conversations" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
44e53efb52
@@ -163,8 +163,16 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
|
|||||||
return o1.getNotificationChannel().getId().compareTo(
|
return o1.getNotificationChannel().getId().compareTo(
|
||||||
o2.getNotificationChannel().getId());
|
o2.getNotificationChannel().getId());
|
||||||
}
|
}
|
||||||
return sCollator.compare(o1.getShortcutInfo().getLabel(),
|
if (o1.getShortcutInfo().getLabel() == null
|
||||||
o2.getShortcutInfo().getLabel());
|
&& o2.getShortcutInfo().getLabel() != null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (o1.getShortcutInfo().getLabel() != null
|
||||||
|
&& o2.getShortcutInfo().getLabel() == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return sCollator.compare(o1.getShortcutInfo().getLabel().toString(),
|
||||||
|
o2.getShortcutInfo().getLabel().toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,12 @@ import android.content.pm.ShortcutInfo;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.ConversationChannelWrapper;
|
import android.service.notification.ConversationChannelWrapper;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.Spanned;
|
||||||
|
import android.text.style.BulletSpan;
|
||||||
|
import android.text.style.QuoteSpan;
|
||||||
|
import android.text.style.SubscriptSpan;
|
||||||
|
import android.text.style.UnderlineSpan;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
@@ -211,6 +217,29 @@ public class ConversationListPreferenceControllerTest {
|
|||||||
ccw.getNotificationChannel().getConversationId());
|
ccw.getNotificationChannel().getConversationId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCompareSpans() {
|
||||||
|
ConversationChannelWrapper one = new ConversationChannelWrapper();
|
||||||
|
String text1 = "one one";
|
||||||
|
SpannableStringBuilder builder1 = new SpannableStringBuilder(text1);
|
||||||
|
Object first1 = new SubscriptSpan();
|
||||||
|
builder1.setSpan(first1, 2, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
ShortcutInfo s1 = new ShortcutInfo.Builder(mContext, "one").setShortLabel(
|
||||||
|
builder1).build();
|
||||||
|
one.setShortcutInfo(s1);
|
||||||
|
|
||||||
|
ConversationChannelWrapper two = new ConversationChannelWrapper();
|
||||||
|
String text2 = "two two";
|
||||||
|
SpannableStringBuilder builder2 = new SpannableStringBuilder(text2);
|
||||||
|
Object first2 = new SubscriptSpan();
|
||||||
|
builder2.setSpan(first2, 2, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
ShortcutInfo s2 = new ShortcutInfo.Builder(mContext, "two").setShortLabel(
|
||||||
|
builder2).build();
|
||||||
|
two.setShortcutInfo(s2);
|
||||||
|
|
||||||
|
assertThat(mController.mConversationComparator.compare(one, two)).isLessThan(0);
|
||||||
|
}
|
||||||
|
|
||||||
private final class TestPreferenceController extends ConversationListPreferenceController {
|
private final class TestPreferenceController extends ConversationListPreferenceController {
|
||||||
|
|
||||||
private TestPreferenceController(Context context, NotificationBackend backend) {
|
private TestPreferenceController(Context context, NotificationBackend backend) {
|
||||||
|
Reference in New Issue
Block a user