Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a24c7183 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Migrate alarms and other interruptions to modes_ui" into main

parents 890eecf2 3f2bcf97
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2024 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.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:title="@string/zen_category_exceptions" >

    <!-- Alarms -->
    <SwitchPreferenceCompat
        android:key="modes_category_alarm"
        android:title="@string/zen_mode_alarms"/>

    <!-- Media -->
    <SwitchPreferenceCompat
        android:key="modes_category_media"
        android:title="@string/zen_mode_media"
        android:summary="@string/zen_mode_media_summary"/>

    <!-- System -->
    <SwitchPreferenceCompat
        android:key="modes_category_system"
        android:title="@string/zen_mode_system"
        android:summary="@string/zen_mode_system_summary"/>

    <!-- Reminders -->
    <SwitchPreferenceCompat
        android:key="modes_category_reminders"
        android:title="@string/zen_mode_reminders"/>

    <!-- Events -->
    <SwitchPreferenceCompat
        android:key="modes_category_events"
        android:title="@string/zen_mode_events"/>

</PreferenceScreen>
+4 −0
Original line number Diff line number Diff line
@@ -26,4 +26,8 @@
            android:key="zen_mode_people"
            android:title="@string/zen_category_people"/>

    <Preference
            android:key="zen_other_settings"
            android:title="@string/zen_category_exceptions" />

</PreferenceScreen>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ public class ZenModeFragment extends ZenModeFragmentBase {
        prefControllers.add(new ZenModeHeaderController(context, "header", this, mBackend));
        prefControllers.add(new ZenModePeopleLinkPreferenceController(
                context, "zen_mode_people", mBackend));
        prefControllers.add(new ZenModeOtherLinkPreferenceController(
                context, "zen_other_settings", mBackend));
        return prefControllers;
    }

+64 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.modes;

import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_ALARMS;
import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_EVENTS;
import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_MEDIA;
import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_REMINDERS;
import static android.service.notification.ZenPolicy.PRIORITY_CATEGORY_SYSTEM;

import android.app.settings.SettingsEnums;
import android.content.Context;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;

import java.util.ArrayList;
import java.util.List;

/**
 * Mode >  Alarms & Other Interruptions
 */
public class ZenModeOtherFragment extends ZenModeFragmentBase {

    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        List<AbstractPreferenceController> controllers = new ArrayList<>();
        controllers.add(new ZenModeOtherPreferenceController(
                context, "modes_category_alarm", mBackend));
        controllers.add(new ZenModeOtherPreferenceController(
                context, "modes_category_media", mBackend));
        controllers.add(new ZenModeOtherPreferenceController(
                context, "modes_category_system", mBackend));
        controllers.add(new ZenModeOtherPreferenceController(
                context, "modes_category_reminders", mBackend));
        controllers.add(new ZenModeOtherPreferenceController(
                context, "modes_category_events", mBackend));
        return controllers;
    }

    @Override
    protected int getPreferenceScreenResId() {
        return R.xml.modes_other_settings;
    }

    @Override
    public int getMetricsCategory() {
        // TODO: b/332937635 - make this the correct metrics category
        return SettingsEnums.NOTIFICATION_ZEN_MODE_PRIORITY;
    }
}
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.modes;


import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;

import android.content.Context;
import android.os.Bundle;
import androidx.preference.Preference;
import com.android.settings.core.SubSettingLauncher;

/**
 * Preference with a link and summary about what other sounds can break through the mode
 */
public class ZenModeOtherLinkPreferenceController extends AbstractZenModePreferenceController {

    ZenModeSummaryHelper mSummaryHelper;

    public ZenModeOtherLinkPreferenceController(Context context, String key,
            ZenModesBackend backend) {
        super(context, key, backend);
        mSummaryHelper = new ZenModeSummaryHelper(mContext, mBackend);
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);
        Bundle bundle = new Bundle();
        bundle.putString(MODE_ID, getMode().getId());
        preference.setIntent(new SubSettingLauncher(mContext)
                .setDestination(ZenModeOtherFragment.class.getName())
                .setSourceMetricsCategory(0)
                .setArguments(bundle)
                .toIntent());
        preference.setSummary(mSummaryHelper.getOtherSoundCategoriesSummary(getMode()));
    }
}
Loading