Merge "Clean up DND slice in search." into qt-dev
This commit is contained in:
@@ -103,7 +103,7 @@
|
|||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
|
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
|
||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
settings:controller="com.android.settings.notification.ZenModeSoundSettingsPreferenceController"/>
|
settings:controller="com.android.settings.notification.ZenModePreferenceController"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_prevent_ringing_sound"
|
android:key="gesture_prevent_ringing_sound"
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="zen_mode_settings"
|
android:key="zen_mode_settings"
|
||||||
android:title="@string/zen_mode_settings_title"
|
android:title="@string/zen_mode_settings_title"
|
||||||
settings:keywords="@string/keywords_zen_mode_settings">
|
settings:searchable="false">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="zen_mode_settings_category_behavior"
|
android:key="zen_mode_settings_category_behavior"
|
||||||
@@ -66,11 +66,13 @@
|
|||||||
|
|
||||||
<!-- Turn on DND button -->
|
<!-- Turn on DND button -->
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
<com.android.settingslib.widget.LayoutPreference
|
||||||
android:key="zen_mode_settings_button_container"
|
android:key="zen_mode_toggle"
|
||||||
|
android:title="@string/zen_mode_settings_title"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
android:layout="@layout/zen_mode_settings_button"
|
android:layout="@layout/zen_mode_settings_button"
|
||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
settings:allowDividerBelow="true"/>
|
settings:allowDividerBelow="true"
|
||||||
|
settings:keywords="@string/keywords_zen_mode_settings"/>
|
||||||
|
|
||||||
<!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
|
<!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
|
||||||
<com.android.settingslib.widget.FooterPreference/>
|
<com.android.settingslib.widget.FooterPreference/>
|
||||||
|
@@ -33,11 +33,12 @@ import com.android.settingslib.widget.LayoutPreference;
|
|||||||
public class ZenModeButtonPreferenceController extends AbstractZenModePreferenceController
|
public class ZenModeButtonPreferenceController extends AbstractZenModePreferenceController
|
||||||
implements PreferenceControllerMixin {
|
implements PreferenceControllerMixin {
|
||||||
|
|
||||||
|
public static final String KEY = "zen_mode_toggle";
|
||||||
|
|
||||||
private static final String TAG = "EnableZenModeButton";
|
private static final String TAG = "EnableZenModeButton";
|
||||||
protected static final String KEY = "zen_mode_settings_button_container";
|
private final FragmentManager mFragment;
|
||||||
private Button mZenButtonOn;
|
private Button mZenButtonOn;
|
||||||
private Button mZenButtonOff;
|
private Button mZenButtonOff;
|
||||||
private FragmentManager mFragment;
|
|
||||||
|
|
||||||
public ZenModeButtonPreferenceController(Context context, Lifecycle lifecycle, FragmentManager
|
public ZenModeButtonPreferenceController(Context context, Lifecycle lifecycle, FragmentManager
|
||||||
fragment) {
|
fragment) {
|
||||||
@@ -60,13 +61,13 @@ public class ZenModeButtonPreferenceController extends AbstractZenModePreference
|
|||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
|
|
||||||
if (null == mZenButtonOn) {
|
if (null == mZenButtonOn) {
|
||||||
mZenButtonOn = (Button) ((LayoutPreference) preference)
|
mZenButtonOn = ((LayoutPreference) preference)
|
||||||
.findViewById(R.id.zen_mode_settings_turn_on_button);
|
.findViewById(R.id.zen_mode_settings_turn_on_button);
|
||||||
updateZenButtonOnClickListener();
|
updateZenButtonOnClickListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null == mZenButtonOff) {
|
if (null == mZenButtonOff) {
|
||||||
mZenButtonOff = (Button) ((LayoutPreference) preference)
|
mZenButtonOff = ((LayoutPreference) preference)
|
||||||
.findViewById(R.id.zen_mode_settings_turn_off_button);
|
.findViewById(R.id.zen_mode_settings_turn_off_button);
|
||||||
mZenButtonOff.setOnClickListener(v -> {
|
mZenButtonOff.setOnClickListener(v -> {
|
||||||
mMetricsFeatureProvider.action(mContext,
|
mMetricsFeatureProvider.action(mContext,
|
||||||
|
@@ -328,7 +328,6 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
public List<String> getNonIndexableKeys(Context context) {
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
List<String> keys = super.getNonIndexableKeys(context);
|
List<String> keys = super.getNonIndexableKeys(context);
|
||||||
keys.add(ZenModeDurationPreferenceController.KEY);
|
keys.add(ZenModeDurationPreferenceController.KEY);
|
||||||
keys.add(ZenModeButtonPreferenceController.KEY);
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,8 +18,6 @@ package com.android.settings.notification;
|
|||||||
|
|
||||||
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||||
|
|
||||||
import static com.android.settings.notification.ZenModeSoundSettingsPreferenceController.ZEN_MODE_KEY;
|
|
||||||
|
|
||||||
import android.annotation.ColorInt;
|
import android.annotation.ColorInt;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -47,6 +45,8 @@ public class ZenModeSliceBuilder {
|
|||||||
|
|
||||||
private static final String TAG = "ZenModeSliceBuilder";
|
private static final String TAG = "ZenModeSliceBuilder";
|
||||||
|
|
||||||
|
private static final String ZEN_MODE_SLICE_KEY = ZenModeButtonPreferenceController.KEY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action notifying a change on the Zen Mode Slice.
|
* Action notifying a change on the Zen Mode Slice.
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +78,8 @@ public class ZenModeSliceBuilder {
|
|||||||
final PendingIntent primaryAction = getPrimaryAction(context);
|
final PendingIntent primaryAction = getPrimaryAction(context);
|
||||||
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction,
|
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction,
|
||||||
(IconCompat) null /* icon */, ListBuilder.ICON_IMAGE, title);
|
(IconCompat) null /* icon */, ListBuilder.ICON_IMAGE, title);
|
||||||
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null /* actionTitle */,
|
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
|
||||||
|
null /* actionTitle */,
|
||||||
isZenModeEnabled);
|
isZenModeEnabled);
|
||||||
|
|
||||||
return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI,
|
return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI,
|
||||||
@@ -110,10 +111,10 @@ public class ZenModeSliceBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Intent getIntent(Context context) {
|
public static Intent getIntent(Context context) {
|
||||||
final Uri contentUri = new Uri.Builder().appendPath(ZEN_MODE_KEY).build();
|
final Uri contentUri = new Uri.Builder().appendPath(ZEN_MODE_SLICE_KEY).build();
|
||||||
final String screenTitle = context.getText(R.string.zen_mode_settings_title).toString();
|
final String screenTitle = context.getText(R.string.zen_mode_settings_title).toString();
|
||||||
return SliceBuilderUtils.buildSearchResultPageIntent(context,
|
return SliceBuilderUtils.buildSearchResultPageIntent(context,
|
||||||
ZenModeSettings.class.getName(), ZEN_MODE_KEY, screenTitle,
|
ZenModeSettings.class.getName(), ZEN_MODE_SLICE_KEY, screenTitle,
|
||||||
SettingsEnums.NOTIFICATION_ZEN_MODE)
|
SettingsEnums.NOTIFICATION_ZEN_MODE)
|
||||||
.setClassName(context.getPackageName(), SubSettings.class.getName())
|
.setClassName(context.getPackageName(), SubSettings.class.getName())
|
||||||
.setData(contentUri);
|
.setData(contentUri);
|
||||||
|
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.notification;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
public class ZenModeSoundSettingsPreferenceController extends ZenModePreferenceController {
|
|
||||||
|
|
||||||
public static final String ZEN_MODE_KEY = "zen_mode";
|
|
||||||
|
|
||||||
public ZenModeSoundSettingsPreferenceController(Context context, String key) {
|
|
||||||
super(context, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,8 +19,6 @@ package com.android.settings.slices;
|
|||||||
import static android.provider.SettingsSlicesContract.KEY_LOCATION;
|
import static android.provider.SettingsSlicesContract.KEY_LOCATION;
|
||||||
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||||
|
|
||||||
import static com.android.settings.notification.ZenModeSoundSettingsPreferenceController.ZEN_MODE_KEY;
|
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.SettingsSlicesContract;
|
import android.provider.SettingsSlicesContract;
|
||||||
@@ -43,6 +41,7 @@ import com.android.settings.location.LocationSlice;
|
|||||||
import com.android.settings.media.MediaOutputIndicatorSlice;
|
import com.android.settings.media.MediaOutputIndicatorSlice;
|
||||||
import com.android.settings.media.MediaOutputSlice;
|
import com.android.settings.media.MediaOutputSlice;
|
||||||
import com.android.settings.network.telephony.MobileDataSlice;
|
import com.android.settings.network.telephony.MobileDataSlice;
|
||||||
|
import com.android.settings.notification.ZenModeButtonPreferenceController;
|
||||||
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
|
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
|
||||||
import com.android.settings.wifi.slice.ContextualWifiSlice;
|
import com.android.settings.wifi.slice.ContextualWifiSlice;
|
||||||
import com.android.settings.wifi.slice.WifiSlice;
|
import com.android.settings.wifi.slice.WifiSlice;
|
||||||
@@ -298,7 +297,7 @@ public class CustomSliceRegistry {
|
|||||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||||
.appendPath(ZEN_MODE_KEY)
|
.appendPath(ZenModeButtonPreferenceController.KEY)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.notification;
|
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class ZenModeSoundSettingsPreferenceControllerTest {
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private ZenModeSoundSettingsPreferenceController mController;
|
|
||||||
private static final String KEY_ZEN_MODE = "zen_mode";
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
mController = new ZenModeSoundSettingsPreferenceController(mContext, KEY_ZEN_MODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_available() {
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user