Merge "Always show custom zen vis eff option"
This commit is contained in:
@@ -7931,6 +7931,9 @@
|
|||||||
<!-- [CHAR LIMIT=20] Zen mode settings: Calls option -->
|
<!-- [CHAR LIMIT=20] Zen mode settings: Calls option -->
|
||||||
<string name="zen_mode_calls">Calls</string>
|
<string name="zen_mode_calls">Calls</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=40] Zen mode settings: Allow calls toggle title -->
|
||||||
|
<string name="zen_mode_calls_title">Allow calls</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=20] Zen mode settings: Calls screen footer -->
|
<!-- [CHAR LIMIT=20] Zen mode settings: Calls screen footer -->
|
||||||
<string name="zen_mode_calls_footer">When Do Not Disturb is on, incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
|
<string name="zen_mode_calls_footer">When Do Not Disturb is on, incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
|
||||||
|
|
||||||
@@ -7946,6 +7949,9 @@
|
|||||||
<!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
|
<!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
|
||||||
<string name="zen_mode_messages">Messages</string>
|
<string name="zen_mode_messages">Messages</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=40] Zen mode settings: Allow messages toggle title -->
|
||||||
|
<string name="zen_mode_messages_title">Allow messages</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=50] Zen mode settings: All messages summary -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: All messages summary -->
|
||||||
<string name="zen_mode_all_messages">Messages</string>
|
<string name="zen_mode_all_messages">Messages</string>
|
||||||
|
|
||||||
@@ -7985,9 +7991,15 @@
|
|||||||
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
|
||||||
<string name="zen_mode_reminders">Reminders</string>
|
<string name="zen_mode_reminders">Reminders</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=70] Zen mode settings: Allow reminders toggle title -->
|
||||||
|
<string name="zen_mode_reminders_title">Allow reminders</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
|
||||||
<string name="zen_mode_events">Events</string>
|
<string name="zen_mode_events">Events</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=70] Zen mode settings: Allow events toggle title -->
|
||||||
|
<string name="zen_mode_events_title">Allow events</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
|
||||||
<string name="zen_mode_all_callers">anyone</string>
|
<string name="zen_mode_all_callers">anyone</string>
|
||||||
|
|
||||||
@@ -8000,8 +8012,11 @@
|
|||||||
<!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
|
||||||
<string name="zen_mode_repeat_callers">Repeat callers</string>
|
<string name="zen_mode_repeat_callers">Repeat callers</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=70] Zen mode settings: Allow repeat callers toggle title -->
|
||||||
|
<string name="zen_mode_repeat_callers_title">Allow repeat callers</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
|
||||||
<string name="zen_mode_calls_summary_one">From <xliff:g id="caller type" example="contacts">%1$s</xliff:g> only</string>
|
<string name="zen_mode_calls_summary_one">From <xliff:g id="caller type" example="contacts">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
|
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
|
||||||
<string name="zen_mode_calls_summary_two">From <xliff:g id="caller type" example="starred contacts">%1$s</xliff:g> and <xliff:g id="callert tpye" example="repeat callers">%2$s</xliff:g></string>
|
<string name="zen_mode_calls_summary_two">From <xliff:g id="caller type" example="starred contacts">%1$s</xliff:g> and <xliff:g id="callert tpye" example="repeat callers">%2$s</xliff:g></string>
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
<!-- Calls -->
|
<!-- Calls -->
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="zen_mode_calls"
|
android:key="zen_mode_calls"
|
||||||
android:title="@string/zen_mode_calls"
|
android:title="@string/zen_mode_calls_title"
|
||||||
android:entries="@array/zen_mode_contacts_entries"
|
android:entries="@array/zen_mode_contacts_entries"
|
||||||
android:entryValues="@array/zen_mode_contacts_values"/>
|
android:entryValues="@array/zen_mode_contacts_values"/>
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<!-- Repeat callers -->
|
<!-- Repeat callers -->
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="zen_mode_repeat_callers"
|
android:key="zen_mode_repeat_callers"
|
||||||
android:title="@string/zen_mode_repeat_callers" />
|
android:title="@string/zen_mode_repeat_callers_title" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference/>
|
<com.android.settingslib.widget.FooterPreference/>
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="zen_mode_messages"
|
android:key="zen_mode_messages"
|
||||||
android:title="@string/zen_mode_messages"
|
android:title="@string/zen_mode_messages_title"
|
||||||
android:entries="@array/zen_mode_contacts_entries"
|
android:entries="@array/zen_mode_contacts_entries"
|
||||||
android:entryValues="@array/zen_mode_contacts_values"/>
|
android:entryValues="@array/zen_mode_contacts_values"/>
|
||||||
|
|
||||||
@@ -37,12 +37,12 @@
|
|||||||
<!-- Reminders -->
|
<!-- Reminders -->
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="zen_mode_reminders"
|
android:key="zen_mode_reminders"
|
||||||
android:title="@string/zen_mode_reminders"/>
|
android:title="@string/zen_mode_reminders_title"/>
|
||||||
|
|
||||||
<!-- Events -->
|
<!-- Events -->
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="zen_mode_events"
|
android:key="zen_mode_events"
|
||||||
android:title="@string/zen_mode_events"/>
|
android:title="@string/zen_mode_events_title"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference />
|
<com.android.settingslib.widget.FooterPreference />
|
||||||
|
@@ -16,22 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_ZEN_SHOW_CUSTOM;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
@@ -42,67 +35,21 @@ import java.util.List;
|
|||||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase implements Indexable {
|
public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase implements Indexable {
|
||||||
|
|
||||||
protected static final int APP_MENU_SHOW_CUSTOM = 1;
|
|
||||||
protected boolean mShowMenuSelected;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
menu.add(0, APP_MENU_SHOW_CUSTOM, 0, R.string.zen_mode_restrict_notifications_enable_custom)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
|
||||||
if (menuItem.getItemId() == APP_MENU_SHOW_CUSTOM) {
|
|
||||||
final FeatureFactory featureFactory = FeatureFactory.getFactory(mContext);
|
|
||||||
MetricsFeatureProvider metrics = featureFactory.getMetricsFeatureProvider();
|
|
||||||
|
|
||||||
mShowMenuSelected = !mShowMenuSelected;
|
|
||||||
|
|
||||||
ZenModeVisEffectsCustomPreferenceController custom =
|
|
||||||
use(ZenModeVisEffectsCustomPreferenceController.class);
|
|
||||||
custom.setShownByMenu(mShowMenuSelected);
|
|
||||||
custom.displayPreference(getPreferenceScreen());
|
|
||||||
|
|
||||||
if (mShowMenuSelected) {
|
|
||||||
metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, true);
|
|
||||||
} else {
|
|
||||||
metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
|
||||||
if (mShowMenuSelected) {
|
|
||||||
menu.findItem(APP_MENU_SHOW_CUSTOM)
|
|
||||||
.setTitle(R.string.zen_mode_restrict_notifications_disable_custom);
|
|
||||||
} else {
|
|
||||||
menu.findItem(APP_MENU_SHOW_CUSTOM)
|
|
||||||
.setTitle(R.string.zen_mode_restrict_notifications_enable_custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mShowMenuSelected && use(ZenModeVisEffectsCustomPreferenceController.class)
|
|
||||||
.areCustomOptionsSelected()) {
|
|
||||||
menu.findItem(APP_MENU_SHOW_CUSTOM).setEnabled(false);
|
|
||||||
} else {
|
|
||||||
menu.findItem(APP_MENU_SHOW_CUSTOM).setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
return buildPreferenceControllers(context, getLifecycle());
|
return buildPreferenceControllers(context, getLifecycle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHelpResource() {
|
||||||
|
return R.string.help_uri_interruptions;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
|
@@ -170,7 +170,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
} else if (numCategories == 2) {
|
} else if (numCategories == 2) {
|
||||||
return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
|
return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
|
||||||
enabledCategories.get(1).toLowerCase());
|
enabledCategories.get(1).toLowerCase());
|
||||||
} else if (numCategories == 3) {
|
} else if (numCategories == 3){
|
||||||
final List<String> summaries = new ArrayList<>();
|
final List<String> summaries = new ArrayList<>();
|
||||||
summaries.add(enabledCategories.get(0));
|
summaries.add(enabledCategories.get(0));
|
||||||
summaries.add(enabledCategories.get(1).toLowerCase());
|
summaries.add(enabledCategories.get(1).toLowerCase());
|
||||||
|
@@ -30,7 +30,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
|||||||
public class ZenModeVisEffectsCustomPreferenceController
|
public class ZenModeVisEffectsCustomPreferenceController
|
||||||
extends AbstractZenModePreferenceController {
|
extends AbstractZenModePreferenceController {
|
||||||
|
|
||||||
protected boolean mShowMenuSelected;
|
|
||||||
protected static final int INTERRUPTIVE_EFFECTS = Policy.SUPPRESSED_EFFECT_AMBIENT
|
protected static final int INTERRUPTIVE_EFFECTS = Policy.SUPPRESSED_EFFECT_AMBIENT
|
||||||
| Policy.SUPPRESSED_EFFECT_PEEK
|
| Policy.SUPPRESSED_EFFECT_PEEK
|
||||||
| Policy.SUPPRESSED_EFFECT_LIGHTS
|
| Policy.SUPPRESSED_EFFECT_LIGHTS
|
||||||
@@ -43,13 +42,9 @@ public class ZenModeVisEffectsCustomPreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
if (mShowMenuSelected) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return areCustomOptionsSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
@@ -67,10 +62,6 @@ public class ZenModeVisEffectsCustomPreferenceController
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setShownByMenu(boolean shown) {
|
|
||||||
mShowMenuSelected = shown;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean areCustomOptionsSelected() {
|
protected boolean areCustomOptionsSelected() {
|
||||||
boolean allEffectsSuppressed =
|
boolean allEffectsSuppressed =
|
||||||
Policy.areAllVisualEffectsSuppressed(mBackend.mPolicy.suppressedVisualEffects);
|
Policy.areAllVisualEffectsSuppressed(mBackend.mPolicy.suppressedVisualEffects);
|
||||||
|
@@ -134,13 +134,13 @@ public class ZenModeSettingsTest {
|
|||||||
public void testGetCallsSettingSummary_contacts() {
|
public void testGetCallsSettingSummary_contacts() {
|
||||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_CALLS,
|
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_CALLS,
|
||||||
Policy.PRIORITY_SENDERS_CONTACTS, 0, 0);
|
Policy.PRIORITY_SENDERS_CONTACTS, 0, 0);
|
||||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts only");
|
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetCallsSettingSummary_repeatCallers() {
|
public void testGetCallsSettingSummary_repeatCallers() {
|
||||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, 0, 0, 0);
|
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, 0, 0, 0);
|
||||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers only");
|
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -88,23 +88,14 @@ public class ZenModeVisEffectsCustomPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_menuOff_noVisEffects() {
|
public void isAvailable_noVisEffects() {
|
||||||
mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 0);
|
mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 0);
|
||||||
mController.mShowMenuSelected = false;
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_menuOn_noVisEffects() {
|
|
||||||
mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 0);
|
|
||||||
mController.mShowMenuSelected = true;
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_menuOn_visEffects() {
|
public void isAvailable_visEffects() {
|
||||||
mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 1);
|
mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 1);
|
||||||
mController.mShowMenuSelected = false;
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user