Update conversation bubble settings
Test: atest Fixes: 153471239 Change-Id: If53571b17236e5f49a1750acc9816287f5de2b1a
This commit is contained in:
@@ -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>
|
<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] -->
|
<!-- Title for the toggle shown on the app-level bubbles page [CHAR LIMIT=60] -->
|
||||||
<string name="bubbles_app_toggle_title">Bubbles</string>
|
<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 -->
|
<!-- 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] -->
|
<!-- 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>
|
<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] -->
|
<!-- 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] -->
|
||||||
|
@@ -32,13 +32,23 @@
|
|||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
settings:allowDividerBelow="true"/>
|
settings:allowDividerBelow="true"/>
|
||||||
|
|
||||||
<!-- bubbles -->
|
<PreferenceCategory
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
android:key="bubbles"
|
||||||
android:key="bubble_pref"
|
android:title="@string/notification_bubbles_title">
|
||||||
android:title="@string/notification_bubbles_title"
|
|
||||||
android:summary="@string/bubbles_conversation_toggle_summary"
|
<!-- bubbles -->
|
||||||
android:icon="@drawable/ic_create_bubble"
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
|
android:key="bubble_pref"
|
||||||
|
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 -->
|
<!-- demote -->
|
||||||
<Preference
|
<Preference
|
||||||
|
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
@@ -94,6 +94,8 @@ public class ConversationNotificationSettings extends NotificationSettings {
|
|||||||
mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
|
mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
|
||||||
mBackend, false /* isAppPage */));
|
mBackend, false /* isAppPage */));
|
||||||
mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend));
|
mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend));
|
||||||
|
mControllers.add(new BubbleCategoryPreferenceController(context));
|
||||||
|
mControllers.add(new BubbleLinkPreferenceController(context));
|
||||||
return new ArrayList<>(mControllers);
|
return new ArrayList<>(mControllers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user