Add a default behavior setting for VICs
Test: atest Bug: 149696991 Change-Id: Ica06f80a02d65294a7b503fd3556add644c61bd7
This commit is contained in:
@@ -35,13 +35,13 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
|
||||
|
||||
private static final String TAG = "AllowSoundPrefContr";
|
||||
private static final String KEY_IMPORTANCE = "allow_sound";
|
||||
private NotificationSettings.ImportanceListener mImportanceListener;
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public AllowSoundPreferenceController(Context context,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mImportanceListener = importanceListener;
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +77,7 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
|
||||
mChannel.setImportance(importance);
|
||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
saveChannel();
|
||||
mImportanceListener.onImportanceChanged();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -100,18 +100,18 @@ public class AppNotificationSettings extends NotificationSettings {
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
mControllers = new ArrayList<>();
|
||||
mControllers.add(new HeaderPreferenceController(context, this));
|
||||
mControllers.add(new BlockPreferenceController(context, mImportanceListener, mBackend));
|
||||
mControllers.add(new BlockPreferenceController(context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new BadgePreferenceController(context, mBackend));
|
||||
mControllers.add(new AllowSoundPreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new ImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new MinImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new HighImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new SoundPreferenceController(context, this,
|
||||
mImportanceListener, mBackend));
|
||||
mDependentFieldListener, mBackend));
|
||||
mControllers.add(new LightsPreferenceController(context, mBackend));
|
||||
mControllers.add(new VibrationPreferenceController(context, mBackend));
|
||||
mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
|
||||
|
@@ -36,13 +36,13 @@ public class BlockPreferenceController extends NotificationPreferenceController
|
||||
implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
|
||||
|
||||
private static final String KEY_BLOCK = "block";
|
||||
private NotificationSettings.ImportanceListener mImportanceListener;
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public BlockPreferenceController(Context context,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mImportanceListener = importanceListener;
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
|
||||
mAppRow.banned = blocked;
|
||||
mBackend.setNotificationsEnabledForPackage(mAppRow.pkg, mAppRow.uid, !blocked);
|
||||
}
|
||||
mImportanceListener.onImportanceChanged();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
|
||||
String getSwitchBarText() {
|
||||
|
@@ -109,17 +109,17 @@ public class ChannelNotificationSettings extends NotificationSettings {
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
mControllers = new ArrayList<>();
|
||||
mControllers.add(new HeaderPreferenceController(context, this));
|
||||
mControllers.add(new BlockPreferenceController(context, mImportanceListener, mBackend));
|
||||
mControllers.add(new BlockPreferenceController(context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new ImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new MinImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new HighImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new AllowSoundPreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new SoundPreferenceController(context, this,
|
||||
mImportanceListener, mBackend));
|
||||
mDependentFieldListener, mBackend));
|
||||
mControllers.add(new VibrationPreferenceController(context, mBackend));
|
||||
mControllers.add(new AppLinkPreferenceController(context));
|
||||
mControllers.add(new DescriptionPreferenceController(context));
|
||||
|
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.provider.Settings.Secure.BUBBLE_IMPORTANT_CONVERSATIONS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -29,10 +32,12 @@ public class ConversationImportantPreferenceController extends NotificationPrefe
|
||||
|
||||
private static final String TAG = "ConvoImpPC";
|
||||
private static final String KEY = "important";
|
||||
private final NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public ConversationImportantPreferenceController(Context context,
|
||||
NotificationBackend backend) {
|
||||
NotificationBackend backend, NotificationSettings.DependentFieldListener listener) {
|
||||
super(context, backend);
|
||||
mDependentFieldListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,8 +72,17 @@ public class ConversationImportantPreferenceController extends NotificationPrefe
|
||||
}
|
||||
final boolean value = (Boolean) newValue;
|
||||
mChannel.setImportantConversation(value);
|
||||
if (value && bubbleImportantConversations()) {
|
||||
mChannel.setAllowBubbles(true);
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
saveChannel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean bubbleImportantConversations() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
BUBBLE_IMPORTANT_CONVERSATIONS, 1) == 1;
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class ConversationListSettings extends DashboardFragment {
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
NotificationBackend mBackend = new NotificationBackend();
|
||||
protected List<ConversationListPreferenceController> mControllers = new ArrayList<>();
|
||||
protected List<AbstractPreferenceController> mControllers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
|
@@ -79,14 +79,15 @@ public class ConversationNotificationSettings extends NotificationSettings {
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
mControllers = new ArrayList<>();
|
||||
mControllers.add(new ConversationHeaderPreferenceController(context, this));
|
||||
mControllers.add(new ConversationImportantPreferenceController(context, mBackend));
|
||||
mControllers.add(new ConversationImportantPreferenceController(
|
||||
context, mBackend, mDependentFieldListener));
|
||||
mControllers.add(new DefaultImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new AddToHomeScreenPreferenceController(context, mBackend));
|
||||
mControllers.add(new HighImportancePreferenceController(
|
||||
context, mImportanceListener, mBackend));
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new SoundPreferenceController(context, this,
|
||||
mImportanceListener, mBackend));
|
||||
mDependentFieldListener, mBackend));
|
||||
mControllers.add(new VibrationPreferenceController(context, mBackend));
|
||||
mControllers.add(new AppLinkPreferenceController(context));
|
||||
mControllers.add(new DescriptionPreferenceController(context));
|
||||
|
@@ -32,13 +32,13 @@ public class DefaultImportancePreferenceController extends NotificationPreferenc
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY = "alerting";
|
||||
private NotificationSettings.ImportanceListener mImportanceListener;
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public DefaultImportancePreferenceController(Context context,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mImportanceListener = importanceListener;
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class DefaultImportancePreferenceController extends NotificationPreferenc
|
||||
mChannel.setImportance(checked ? IMPORTANCE_DEFAULT : IMPORTANCE_LOW);
|
||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
saveChannel();
|
||||
mImportanceListener.onImportanceChanged();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -32,13 +32,13 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_IMPORTANCE = "high_importance";
|
||||
private NotificationSettings.ImportanceListener mImportanceListener;
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public HighImportancePreferenceController(Context context,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mImportanceListener = importanceListener;
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
|
||||
mChannel.setImportance(checked ? IMPORTANCE_HIGH : IMPORTANCE_DEFAULT);
|
||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
saveChannel();
|
||||
mImportanceListener.onImportanceChanged();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -33,13 +33,13 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_IMPORTANCE = "importance";
|
||||
private NotificationSettings.ImportanceListener mImportanceListener;
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public ImportancePreferenceController(Context context,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mImportanceListener = importanceListener;
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +91,7 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
mChannel.setImportance(importance);
|
||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
saveChannel();
|
||||
mImportanceListener.onImportanceChanged();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 static android.provider.Settings.Secure.BUBBLE_IMPORTANT_CONVERSATIONS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class ImportantConversationBubblePreferenceController extends TogglePreferenceController
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "ImpConvBubPrefContr";
|
||||
@VisibleForTesting
|
||||
static final int ON = 1;
|
||||
@VisibleForTesting
|
||||
static final int OFF = 0;
|
||||
|
||||
|
||||
public ImportantConversationBubblePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
private boolean isGloballyEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, OFF) == ON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isGloballyEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
BUBBLE_IMPORTANT_CONVERSATIONS, ON) == ON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
BUBBLE_IMPORTANT_CONVERSATIONS, isChecked ? ON : OFF);
|
||||
}
|
||||
}
|
@@ -32,13 +32,13 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_IMPORTANCE = "min_importance";
|
||||
private NotificationSettings.ImportanceListener mImportanceListener;
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public MinImportancePreferenceController(Context context,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mImportanceListener = importanceListener;
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
|
||||
mChannel.setImportance(checked ? IMPORTANCE_MIN : IMPORTANCE_LOW);
|
||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
saveChannel();
|
||||
mImportanceListener.onImportanceChanged();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -33,7 +33,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
@@ -79,7 +78,7 @@ abstract public class NotificationSettings extends DashboardFragment {
|
||||
protected boolean mListeningToPackageRemove;
|
||||
|
||||
protected List<NotificationPreferenceController> mControllers = new ArrayList<>();
|
||||
protected ImportanceListener mImportanceListener = new ImportanceListener();
|
||||
protected DependentFieldListener mDependentFieldListener = new DependentFieldListener();
|
||||
|
||||
protected Intent mIntent;
|
||||
protected Bundle mArgs;
|
||||
@@ -328,8 +327,8 @@ abstract public class NotificationSettings extends DashboardFragment {
|
||||
}
|
||||
};
|
||||
|
||||
protected class ImportanceListener {
|
||||
protected void onImportanceChanged() {
|
||||
protected class DependentFieldListener {
|
||||
protected void onFieldValueChanged() {
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
for (NotificationPreferenceController controller : mControllers) {
|
||||
controller.displayPreference(screen);
|
||||
|
@@ -40,16 +40,16 @@ public class SoundPreferenceController extends NotificationPreferenceController
|
||||
|
||||
private static final String KEY_SOUND = "ringtone";
|
||||
private final SettingsPreferenceFragment mFragment;
|
||||
private final NotificationSettings.ImportanceListener mListener;
|
||||
private final NotificationSettings.DependentFieldListener mListener;
|
||||
private NotificationSoundPreference mPreference;
|
||||
protected static final int CODE = 200;
|
||||
|
||||
public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment,
|
||||
NotificationSettings.ImportanceListener importanceListener,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mFragment = hostFragment;
|
||||
mListener = importanceListener;
|
||||
mListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +121,7 @@ public class SoundPreferenceController extends NotificationPreferenceController
|
||||
}
|
||||
// the importance hasn't changed, but the importance description might as a result of
|
||||
// user's selection.
|
||||
mListener.onImportanceChanged();
|
||||
mListener.onFieldValueChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user