Overhaul the message senders screen
* Fix combinations of messages=all with other conversation values. * Correctly display policies with CONVERSATION_SENDERS_ANYONE. An additional checkbox is included, but _only_ if the policy has CONVERSATION_SENDERS_ANYONE when shown. * Changed updateState() to consider the possible cases one by one. Because multiple policies are mapped to the same checkbox states, the strategy of "checking whether the state matches what the checkbox wants to set" doesn't really work. * Fix messages summary and circles to support CONVERSATION_SENDERS_ANYONE. * Added a lot of tests (actually, hopefully ALL OF THEM) covering the user-visible behavior. :) Fixes: 354658240 Test: atest ZenModesSummaryHelperTest ZenModePrioritySendersPreferenceControllerTest Flag: android.app.modes_ui Change-Id: I727496ca3eb820e4baaab942b61d2e57cdb491fc
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -21,8 +21,11 @@ import static android.provider.Settings.Global.ZEN_MODE_OFF;
|
||||
import static android.service.notification.Condition.SOURCE_UNKNOWN;
|
||||
import static android.service.notification.Condition.STATE_TRUE;
|
||||
import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE;
|
||||
import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_IMPORTANT;
|
||||
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_ANYONE;
|
||||
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_CONTACTS;
|
||||
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_NONE;
|
||||
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_STARRED;
|
||||
import static android.service.notification.ZenPolicy.VISUAL_EFFECT_AMBIENT;
|
||||
import static android.service.notification.ZenPolicy.VISUAL_EFFECT_LIGHTS;
|
||||
|
||||
@@ -123,6 +126,59 @@ public class ZenModesSummaryHelperTest {
|
||||
assertThat(mSummaryHelper.getPeopleSummary(policy)).isEqualTo("All people can interrupt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMessagesSettingSummary_allMessages() {
|
||||
ZenPolicy policy1 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_ANYONE)
|
||||
.build();
|
||||
ZenPolicy policy2 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_ANYONE)
|
||||
.allowConversations(CONVERSATION_SENDERS_IMPORTANT)
|
||||
.build();
|
||||
ZenPolicy policy3 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_ANYONE)
|
||||
.allowConversations(CONVERSATION_SENDERS_ANYONE)
|
||||
.build();
|
||||
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy1)).isEqualTo("Anyone");
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy2)).isEqualTo("Anyone");
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy3)).isEqualTo("Anyone");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMessagesSettingSummary_noMessagesButSomeConversations() {
|
||||
ZenPolicy policy1 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_NONE)
|
||||
.allowConversations(CONVERSATION_SENDERS_IMPORTANT)
|
||||
.build();
|
||||
ZenPolicy policy2 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_NONE)
|
||||
.allowConversations(CONVERSATION_SENDERS_ANYONE)
|
||||
.build();
|
||||
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy1)).isEqualTo(
|
||||
"Priority conversations");
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy2)).isEqualTo(
|
||||
"All conversations");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMessagesSettingSummary_contactsAndConversations() {
|
||||
ZenPolicy policy1 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_STARRED)
|
||||
.allowConversations(CONVERSATION_SENDERS_IMPORTANT)
|
||||
.build();
|
||||
ZenPolicy policy2 = new ZenPolicy.Builder()
|
||||
.allowMessages(PEOPLE_TYPE_STARRED)
|
||||
.allowConversations(CONVERSATION_SENDERS_ANYONE)
|
||||
.build();
|
||||
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy1)).isEqualTo(
|
||||
"Starred contacts and priority conversations");
|
||||
assertThat(mSummaryHelper.getMessagesSettingSummary(policy2)).isEqualTo(
|
||||
"Starred contacts and all conversations");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOtherSoundCategoriesSummary_single() {
|
||||
ZenMode zenMode = new TestModeBuilder()
|
||||
|
Reference in New Issue
Block a user