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

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

Merge "Add skeleton page for bundling" into main

parents 33c580ec 976850db
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -9041,6 +9041,13 @@
    <string name="notification_polite_work">Apply to work profiles</string>
    <string name="notification_polite_work_summary">Apply to work profile apps</string>
    <!-- Title for Bundled Notifications setting  [CHAR LIMIT=45]-->
    <string name="notification_bundle_title">Bundled notifications</string>
    <string name="notification_bundle_on">On</string>
    <string name="notification_bundle_off">Off</string>
    <string name="notification_bundle_main_control_title">Use notification bundling</string>
    <string name="notification_bundle_description">Notifications with similar themes will be silenced and grouped together for a quieter experience. Bundling will override an app\'s own notification settings.</string>
    <!-- Title for managing VR (virtual reality) helper services. [CHAR LIMIT=50] -->
    <string name="vr_listeners_title">VR helper services</string>
+59 −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"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:title="@string/notification_bundle_title">

    <com.android.settingslib.widget.IllustrationPreference
        android:key="illustration"
        settings:searchable="false"
        android:selectable="false"
        app:lottie_cacheComposition="false"
        settings:dynamicColor="true"/>

    <com.android.settingslib.widget.TopIntroPreference
        android:key="feature_description"
        settings:searchable="false"
        android:title="@string/notification_bundle_description"/>

    <com.android.settingslib.widget.MainSwitchPreference
        android:key="global_pref"
        android:title="@string/notification_bundle_main_control_title"
        settings:controller="com.android.settings.notification.BundleGlobalPreferenceController" />

    <CheckBoxPreference
        android:key="promotions"
        android:title="@*android:string/promotional_notification_channel_label"
        settings:controller="com.android.settings.notification.BundleTypePreferenceController"/>

    <CheckBoxPreference
        android:key="news"
        android:title="@*android:string/news_notification_channel_label"
        settings:controller="com.android.settings.notification.BundleTypePreferenceController"/>

    <CheckBoxPreference
        android:key="social"
        android:title="@*android:string/social_notification_channel_label"
        settings:controller="com.android.settings.notification.BundleTypePreferenceController"/>

    <CheckBoxPreference
        android:key="recs"
        android:title="@*android:string/recs_notification_channel_label"
        settings:controller="com.android.settings.notification.BundleTypePreferenceController"/>
</PreferenceScreen>
+8 −0
Original line number Diff line number Diff line
@@ -43,6 +43,14 @@
                android:targetPackage="com.android.settings"
                android:targetClass="com.android.settings.notification.history.NotificationHistoryActivity" />
        </Preference>

        <Preference
            android:fragment="com.android.settings.notification.BundlePreferenceFragment"
            android:key="bundle_notifications_preference"
            android:persistent="false"
            android:order="12"
            android:title="@string/notification_bundle_title"
            settings:controller="com.android.settings.notification.BundlePreferenceController" />
    </PreferenceCategory>

    <PreferenceCategory
+61 −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;

import android.app.Flags;
import android.content.Context;

import androidx.annotation.NonNull;

import com.android.settings.widget.SettingsMainSwitchPreferenceController;

public class BundleGlobalPreferenceController extends
        SettingsMainSwitchPreferenceController {

    NotificationBackend mBackend;

    public BundleGlobalPreferenceController(@NonNull Context context,
            @NonNull String preferenceKey) {
        super(context, preferenceKey);
        mBackend = new NotificationBackend();
    }

    @Override
    public int getAvailabilityStatus() {
        if (Flags.notificationClassificationUi() && mBackend.isNotificationBundlingSupported()) {
            return AVAILABLE;
        }
        return CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public boolean isChecked() {
        return mBackend.isNotificationBundlingEnabled(mContext);
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        mBackend.setNotificationBundlingEnabled(isChecked);
        return true;
    }

    @Override
    public int getSliceHighlightMenuRes() {
        // not needed since it's not sliceable
        return NO_RES;
    }
}
+49 −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;

import android.app.Flags;
import android.content.Context;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

/**
 * Controller for the bundled notifications settings page.
 */
public class BundlePreferenceController extends BasePreferenceController {

    NotificationBackend mBackend;

    public BundlePreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        mBackend = new NotificationBackend();
    }

    @Override
    public int getAvailabilityStatus() {
        return Flags.notificationClassificationUi() && mBackend.isNotificationBundlingSupported()
                ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public CharSequence getSummary() {
        return mBackend.isNotificationBundlingEnabled(mContext)
                ? mContext.getString(R.string.notification_bundle_on)
                : mContext.getString(R.string.notification_bundle_off);
    }
}
Loading