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

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

Merge "Update conversation bubble settings" into rvc-dev

parents 12a838d1 cecc6951
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -8137,8 +8137,12 @@
    <string name="bubbles_feature_education">Some notifications and other content can appear as bubbles on the screen. To open a bubble, tap it. To dismiss it, drag it down the screen.</string>
    <!-- Title for the toggle shown on the app-level bubbles page  [CHAR LIMIT=60] -->
    <string name="bubbles_app_toggle_title">Bubbles</string>
    <!-- Title on the conversation level screen; links back to the app level setting -->
    <string name="bubbles_conversation_app_link">All Bubble settings</string>
    <!-- Title for bubbles option on the conversation level screen -->
    <string name="bubbles_conversation_toggle_title">Bubble this conversation</string>
    <!-- Summary for bubbles option on the conversation level screen -->
    <string name="bubbles_conversation_toggle_summary">New messages will appear on screen</string>
    <string name="bubbles_conversation_toggle_summary">Show floating icon on top of apps</string>
    <!-- Description for the toggle shown on the app-level bubbles page  [CHAR LIMIT=NONE] -->
    <string name="bubbles_app_toggle_summary">Allow <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> to show some notifications as bubbles</string>
    <!-- Title of the dialog shown when the user has disabled bubbles at the feature level but tries to enable it for an app. [CHAR LIMIT=NONE] -->
+17 −7
Original line number Diff line number Diff line
@@ -32,14 +32,24 @@
        settings:allowDividerAbove="true"
        settings:allowDividerBelow="true"/>

    <PreferenceCategory
        android:key="bubbles"
        android:title="@string/notification_bubbles_title">

        <!-- bubbles -->
        <com.android.settingslib.RestrictedSwitchPreference
            android:key="bubble_pref"
        android:title="@string/notification_bubbles_title"
            android:title="@string/bubbles_conversation_toggle_title"
            android:summary="@string/bubbles_conversation_toggle_summary"
            android:icon="@drawable/ic_create_bubble"
            settings:restrictedSwitchSummary="@string/enabled_by_admin" />

        <Preference
            android:key="notification_bubbles"
            android:title="@string/bubbles_conversation_app_link"
        />
    </PreferenceCategory>

    <!-- demote -->
    <Preference
        android:key="demote"
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.app;

import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;

import android.content.Context;
import android.content.Intent;
import android.provider.Settings;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

public class BubbleCategoryPreferenceController extends NotificationPreferenceController {

    private static final String KEY = "bubbles";
    @VisibleForTesting
    static final int ON = 1;

    public BubbleCategoryPreferenceController(Context context) {
        super(context, null);
    }

    @Override
    public boolean isAvailable() {
        if (!super.isAvailable()) {
            return false;
        }
        return areBubblesEnabled();
    }

    @Override
    public String getPreferenceKey() {
        return KEY;
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);

        if (mAppRow != null) {
            final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
            intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
            preference.setIntent(intent);
        }
    }


    private boolean areBubblesEnabled() {
        return Settings.Global.getInt(mContext.getContentResolver(),
                NOTIFICATION_BUBBLES, ON) == ON;
    }
}
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.app;

import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;

import android.content.Context;
import android.content.Intent;
import android.provider.Settings;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

public class BubbleLinkPreferenceController extends NotificationPreferenceController {

    private static final String KEY = "notification_bubbles";
    @VisibleForTesting
    static final int ON = 1;

    public BubbleLinkPreferenceController(Context context) {
        super(context, null);
    }

    @Override
    public boolean isAvailable() {
        if (!super.isAvailable()) {
            return false;
        }
        return areBubblesEnabled();
    }

    @Override
    public String getPreferenceKey() {
        return KEY;
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);

        if (mAppRow != null) {
            final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
            intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
            preference.setIntent(intent);
        }
    }


    private boolean areBubblesEnabled() {
        return Settings.Global.getInt(mContext.getContentResolver(),
                NOTIFICATION_BUBBLES, ON) == ON;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ public class ConversationNotificationSettings extends NotificationSettings {
        mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
                mBackend, false /* isAppPage */));
        mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend));
        mControllers.add(new BubbleCategoryPreferenceController(context));
        mControllers.add(new BubbleLinkPreferenceController(context));
        return new ArrayList<>(mControllers);
    }
}