settings:useAdminDisabledSummary="true"
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
settings:allowDividerAbove="true"
- settings:controller="com.android.settings.notification.ZenModeSoundSettingsPreferenceController"/>
+ settings:controller="com.android.settings.notification.ZenModePreferenceController"/>
<Preference
android:key="gesture_prevent_ringing_sound"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="zen_mode_settings"
android:title="@string/zen_mode_settings_title"
- settings:keywords="@string/keywords_zen_mode_settings">
+ settings:searchable="false">
<PreferenceCategory
android:key="zen_mode_settings_category_behavior"
<!-- Turn on DND button -->
<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:layout="@layout/zen_mode_settings_button"
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 -->
<com.android.settingslib.widget.FooterPreference/>
public class ZenModeButtonPreferenceController extends AbstractZenModePreferenceController
implements PreferenceControllerMixin {
+ public static final String KEY = "zen_mode_toggle";
+
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 mZenButtonOff;
- private FragmentManager mFragment;
public ZenModeButtonPreferenceController(Context context, Lifecycle lifecycle, FragmentManager
fragment) {
super.updateState(preference);
if (null == mZenButtonOn) {
- mZenButtonOn = (Button) ((LayoutPreference) preference)
+ mZenButtonOn = ((LayoutPreference) preference)
.findViewById(R.id.zen_mode_settings_turn_on_button);
updateZenButtonOnClickListener();
}
if (null == mZenButtonOff) {
- mZenButtonOff = (Button) ((LayoutPreference) preference)
+ mZenButtonOff = ((LayoutPreference) preference)
.findViewById(R.id.zen_mode_settings_turn_off_button);
mZenButtonOff.setOnClickListener(v -> {
mMetricsFeatureProvider.action(mContext,
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
keys.add(ZenModeDurationPreferenceController.KEY);
- keys.add(ZenModeButtonPreferenceController.KEY);
return keys;
}
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.app.NotificationManager;
import android.app.PendingIntent;
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.
*/
final PendingIntent primaryAction = getPrimaryAction(context);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction,
(IconCompat) null /* icon */, ListBuilder.ICON_IMAGE, title);
- final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null /* actionTitle */,
+ final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
+ null /* actionTitle */,
isZenModeEnabled);
return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI,
}
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();
return SliceBuilderUtils.buildSearchResultPageIntent(context,
- ZenModeSettings.class.getName(), ZEN_MODE_KEY, screenTitle,
+ ZenModeSettings.class.getName(), ZEN_MODE_SLICE_KEY, screenTitle,
SettingsEnums.NOTIFICATION_ZEN_MODE)
.setClassName(context.getPackageName(), SubSettings.class.getName())
.setData(contentUri);
+++ /dev/null
-/*
- * 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;
- }
-}
import static android.provider.SettingsSlicesContract.KEY_LOCATION;
import static android.provider.SettingsSlicesContract.KEY_WIFI;
-import static com.android.settings.notification.ZenModeSoundSettingsPreferenceController.ZEN_MODE_KEY;
-
import android.content.ContentResolver;
import android.net.Uri;
import android.provider.SettingsSlicesContract;
import com.android.settings.media.MediaOutputIndicatorSlice;
import com.android.settings.media.MediaOutputSlice;
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.slice.ContextualWifiSlice;
import com.android.settings.wifi.slice.WifiSlice;
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(ZEN_MODE_KEY)
+ .appendPath(ZenModeButtonPreferenceController.KEY)
.build();
/**
+++ /dev/null
-/*
- * 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);
- }
-}