Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.notification.row; |
| 18 | |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 19 | import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL; |
Mady Mellor | a92268c | 2020-03-09 17:25:08 -0700 | [diff] [blame] | 20 | import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE; |
| 21 | import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 22 | import static android.app.NotificationManager.IMPORTANCE_DEFAULT; |
| 23 | import static android.app.NotificationManager.IMPORTANCE_LOW; |
| 24 | import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 25 | import static android.provider.Settings.Global.NOTIFICATION_BUBBLES; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 26 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 27 | import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN; |
| 28 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 29 | import static java.lang.annotation.RetentionPolicy.SOURCE; |
| 30 | |
| 31 | import android.annotation.IntDef; |
| 32 | import android.annotation.NonNull; |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 33 | import android.annotation.Nullable; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 34 | import android.app.INotificationManager; |
| 35 | import android.app.Notification; |
| 36 | import android.app.NotificationChannel; |
| 37 | import android.app.NotificationChannelGroup; |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 38 | import android.app.NotificationManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 39 | import android.content.Context; |
| 40 | import android.content.Intent; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 41 | import android.content.pm.ApplicationInfo; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 42 | import android.content.pm.PackageManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 43 | import android.content.pm.ShortcutInfo; |
| 44 | import android.content.pm.ShortcutManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 45 | import android.os.Handler; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 46 | import android.os.RemoteException; |
Julia Reynolds | c535650 | 2020-06-08 16:14:58 -0400 | [diff] [blame] | 47 | import android.os.UserHandle; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 48 | import android.provider.Settings; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 49 | import android.service.notification.StatusBarNotification; |
| 50 | import android.text.TextUtils; |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 51 | import android.transition.ChangeBounds; |
| 52 | import android.transition.Fade; |
| 53 | import android.transition.TransitionManager; |
| 54 | import android.transition.TransitionSet; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 55 | import android.util.AttributeSet; |
| 56 | import android.util.Log; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 57 | import android.view.LayoutInflater; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 58 | import android.view.View; |
| 59 | import android.view.accessibility.AccessibilityEvent; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 60 | import android.widget.ImageView; |
| 61 | import android.widget.LinearLayout; |
| 62 | import android.widget.TextView; |
| 63 | |
| 64 | import com.android.internal.annotations.VisibleForTesting; |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 65 | import com.android.settingslib.notification.ConversationIconFactory; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 66 | import com.android.systemui.Prefs; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 67 | import com.android.systemui.R; |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 68 | import com.android.systemui.bubbles.BubbleController; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 69 | import com.android.systemui.dagger.qualifiers.Background; |
| 70 | import com.android.systemui.dagger.qualifiers.Main; |
Mady Mellor | 9adfe6a | 2020-03-30 17:23:26 -0700 | [diff] [blame] | 71 | import com.android.systemui.statusbar.notification.NotificationChannelHelper; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 72 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
| 73 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 74 | import com.android.systemui.statusbar.notification.stack.StackStateAnimator; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 75 | |
| 76 | import java.lang.annotation.Retention; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 77 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 78 | import javax.inject.Provider; |
| 79 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 80 | /** |
| 81 | * The guts of a conversation notification revealed when performing a long press. |
| 82 | */ |
| 83 | public class NotificationConversationInfo extends LinearLayout implements |
| 84 | NotificationGuts.GutsContent { |
| 85 | private static final String TAG = "ConversationGuts"; |
| 86 | |
| 87 | |
| 88 | private INotificationManager mINotificationManager; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 89 | private ShortcutManager mShortcutManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 90 | private PackageManager mPm; |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 91 | private ConversationIconFactory mIconFactory; |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 92 | private VisualStabilityManager mVisualStabilityManager; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 93 | private Handler mMainHandler; |
| 94 | private Handler mBgHandler; |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 95 | private BubbleController mBubbleController; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 96 | private String mPackageName; |
| 97 | private String mAppName; |
| 98 | private int mAppUid; |
| 99 | private String mDelegatePkg; |
| 100 | private NotificationChannel mNotificationChannel; |
| 101 | private ShortcutInfo mShortcutInfo; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 102 | private NotificationEntry mEntry; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 103 | private StatusBarNotification mSbn; |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 104 | @Nullable private Notification.BubbleMetadata mBubbleMetadata; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 105 | private Context mUserContext; |
| 106 | private Provider<PriorityOnboardingDialogController.Builder> mBuilderProvider; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 107 | private boolean mIsDeviceProvisioned; |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 108 | private int mAppBubble; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 109 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 110 | private TextView mPriorityDescriptionView; |
| 111 | private TextView mDefaultDescriptionView; |
| 112 | private TextView mSilentDescriptionView; |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 113 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 114 | private @Action int mSelectedAction = -1; |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 115 | private boolean mPressedApply; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 116 | |
| 117 | private OnSnoozeClickListener mOnSnoozeClickListener; |
| 118 | private OnSettingsClickListener mOnSettingsClickListener; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 119 | private NotificationGuts mGutsContainer; |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 120 | private OnConversationSettingsClickListener mOnConversationSettingsClickListener; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 121 | |
| 122 | @VisibleForTesting |
| 123 | boolean mSkipPost = false; |
Selim Cinek | a5a4ee4 | 2020-05-21 15:38:32 -0700 | [diff] [blame] | 124 | private int mActualHeight; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 125 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 126 | @Retention(SOURCE) |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 127 | @IntDef({ACTION_DEFAULT, ACTION_HOME, ACTION_FAVORITE, ACTION_SNOOZE, ACTION_MUTE, |
| 128 | ACTION_SETTINGS}) |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 129 | private @interface Action {} |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 130 | static final int ACTION_DEFAULT = 0; |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 131 | static final int ACTION_HOME = 1; |
| 132 | static final int ACTION_FAVORITE = 2; |
| 133 | static final int ACTION_SNOOZE = 3; |
| 134 | static final int ACTION_MUTE = 4; |
| 135 | static final int ACTION_SETTINGS = 5; |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 136 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 137 | // TODO: b/152050825 |
| 138 | /* |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 139 | private OnClickListener mOnHomeClick = v -> { |
| 140 | mSelectedAction = ACTION_HOME; |
| 141 | mShortcutManager.requestPinShortcut(mShortcutInfo, null); |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 142 | mShadeController.animateCollapsePanels(); |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 143 | mGutsContainer.closeControls(v, true); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 144 | }; |
| 145 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 146 | private OnClickListener mOnSnoozeClick = v -> { |
| 147 | mSelectedAction = ACTION_SNOOZE; |
| 148 | mOnSnoozeClickListener.onClick(v, 1); |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 149 | mGutsContainer.closeControls(v, true); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 150 | }; |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 151 | */ |
| 152 | |
| 153 | private OnClickListener mOnFavoriteClick = v -> { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 154 | setSelectedAction(ACTION_FAVORITE); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 155 | updateToggleActions(mSelectedAction, true); |
| 156 | }; |
| 157 | |
| 158 | private OnClickListener mOnDefaultClick = v -> { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 159 | setSelectedAction(ACTION_DEFAULT); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 160 | updateToggleActions(mSelectedAction, true); |
| 161 | }; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 162 | |
| 163 | private OnClickListener mOnMuteClick = v -> { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 164 | setSelectedAction(ACTION_MUTE); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 165 | updateToggleActions(mSelectedAction, true); |
| 166 | }; |
| 167 | |
| 168 | private OnClickListener mOnDone = v -> { |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 169 | mPressedApply = true; |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 170 | // If the user selected Priority, maybe show the priority onboarding |
| 171 | if (mSelectedAction == ACTION_FAVORITE && shouldShowPriorityOnboarding()) { |
| 172 | showPriorityOnboarding(); |
| 173 | } |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 174 | mGutsContainer.closeControls(v, true); |
Julia Reynolds | dcd70d6 | 2020-01-15 10:33:43 -0500 | [diff] [blame] | 175 | }; |
| 176 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 177 | public NotificationConversationInfo(Context context, AttributeSet attrs) { |
| 178 | super(context, attrs); |
| 179 | } |
| 180 | |
| 181 | public interface OnSettingsClickListener { |
| 182 | void onClick(View v, NotificationChannel channel, int appUid); |
| 183 | } |
| 184 | |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 185 | public interface OnConversationSettingsClickListener { |
| 186 | void onClick(); |
| 187 | } |
| 188 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 189 | public interface OnAppSettingsClickListener { |
| 190 | void onClick(View v, Intent intent); |
| 191 | } |
| 192 | |
| 193 | public interface OnSnoozeClickListener { |
| 194 | void onClick(View v, int hoursToSnooze); |
| 195 | } |
| 196 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 197 | @VisibleForTesting |
| 198 | void setSelectedAction(int selectedAction) { |
| 199 | if (mSelectedAction == selectedAction) { |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | mSelectedAction = selectedAction; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 204 | } |
| 205 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 206 | public void bindNotification( |
| 207 | ShortcutManager shortcutManager, |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 208 | PackageManager pm, |
| 209 | INotificationManager iNotificationManager, |
| 210 | VisualStabilityManager visualStabilityManager, |
| 211 | String pkg, |
| 212 | NotificationChannel notificationChannel, |
| 213 | NotificationEntry entry, |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 214 | Notification.BubbleMetadata bubbleMetadata, |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 215 | OnSettingsClickListener onSettingsClick, |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 216 | OnSnoozeClickListener onSnoozeClickListener, |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 217 | ConversationIconFactory conversationIconFactory, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 218 | Context userContext, |
| 219 | Provider<PriorityOnboardingDialogController.Builder> builderProvider, |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 220 | boolean isDeviceProvisioned, |
| 221 | @Main Handler mainHandler, |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 222 | @Background Handler bgHandler, |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 223 | OnConversationSettingsClickListener onConversationSettingsClickListener, |
| 224 | BubbleController bubbleController) { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 225 | mSelectedAction = -1; |
| 226 | mINotificationManager = iNotificationManager; |
| 227 | mVisualStabilityManager = visualStabilityManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 228 | mPackageName = pkg; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 229 | mEntry = entry; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 230 | mSbn = entry.getSbn(); |
| 231 | mPm = pm; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 232 | mAppName = mPackageName; |
| 233 | mOnSettingsClickListener = onSettingsClick; |
| 234 | mNotificationChannel = notificationChannel; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 235 | mAppUid = mSbn.getUid(); |
| 236 | mDelegatePkg = mSbn.getOpPkg(); |
| 237 | mIsDeviceProvisioned = isDeviceProvisioned; |
| 238 | mOnSnoozeClickListener = onSnoozeClickListener; |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 239 | mOnConversationSettingsClickListener = onConversationSettingsClickListener; |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 240 | mIconFactory = conversationIconFactory; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 241 | mUserContext = userContext; |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 242 | mBubbleMetadata = bubbleMetadata; |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 243 | mBubbleController = bubbleController; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 244 | mBuilderProvider = builderProvider; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 245 | mMainHandler = mainHandler; |
| 246 | mBgHandler = bgHandler; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 247 | mShortcutManager = shortcutManager; |
Julia Reynolds | 8582df5 | 2020-04-24 18:30:59 -0400 | [diff] [blame] | 248 | mShortcutInfo = entry.getRanking().getShortcutInfo(); |
| 249 | if (mShortcutInfo == null) { |
Julia Reynolds | 7c26752 | 2020-01-16 11:26:41 -0500 | [diff] [blame] | 250 | throw new IllegalArgumentException("Does not have required information"); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 251 | } |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 252 | |
Mady Mellor | 9adfe6a | 2020-03-30 17:23:26 -0700 | [diff] [blame] | 253 | mNotificationChannel = NotificationChannelHelper.createConversationChannelIfNeeded( |
| 254 | getContext(), mINotificationManager, entry, mNotificationChannel); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 255 | |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 256 | try { |
| 257 | mAppBubble = mINotificationManager.getBubblePreferenceForPackage(mPackageName, mAppUid); |
| 258 | } catch (RemoteException e) { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 259 | Log.e(TAG, "can't reach OS", e); |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 260 | mAppBubble = BUBBLE_PREFERENCE_SELECTED; |
| 261 | } |
| 262 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 263 | bindHeader(); |
| 264 | bindActions(); |
| 265 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 266 | View done = findViewById(R.id.done); |
| 267 | done.setOnClickListener(mOnDone); |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 268 | done.setAccessibilityDelegate(mGutsContainer.getAccessibilityDelegate()); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 269 | } |
| 270 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 271 | private void bindActions() { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 272 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 273 | // TODO: b/152050825 |
| 274 | /* |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 275 | Button home = findViewById(R.id.home); |
| 276 | home.setOnClickListener(mOnHomeClick); |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 277 | home.setVisibility(mShortcutInfo != null |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 278 | && mShortcutManager.isRequestPinShortcutSupported() |
| 279 | ? VISIBLE : GONE); |
| 280 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 281 | Button snooze = findViewById(R.id.snooze); |
| 282 | snooze.setOnClickListener(mOnSnoozeClick); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 283 | */ |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 284 | |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 285 | if (mAppBubble == BUBBLE_PREFERENCE_ALL) { |
| 286 | ((TextView) findViewById(R.id.default_summary)).setText(getResources().getString( |
| 287 | R.string.notification_channel_summary_default_with_bubbles, mAppName)); |
| 288 | } |
| 289 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 290 | findViewById(R.id.priority).setOnClickListener(mOnFavoriteClick); |
| 291 | findViewById(R.id.default_behavior).setOnClickListener(mOnDefaultClick); |
| 292 | findViewById(R.id.silence).setOnClickListener(mOnMuteClick); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 293 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 294 | final View settingsButton = findViewById(R.id.info); |
| 295 | settingsButton.setOnClickListener(getSettingsOnClickListener()); |
| 296 | settingsButton.setVisibility(settingsButton.hasOnClickListeners() ? VISIBLE : GONE); |
| 297 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 298 | updateToggleActions(getSelectedAction(), false); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | private void bindHeader() { |
| 302 | bindConversationDetails(); |
| 303 | |
| 304 | // Delegate |
| 305 | bindDelegate(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | private OnClickListener getSettingsOnClickListener() { |
| 309 | if (mAppUid >= 0 && mOnSettingsClickListener != null && mIsDeviceProvisioned) { |
| 310 | final int appUidF = mAppUid; |
| 311 | return ((View view) -> { |
| 312 | mOnSettingsClickListener.onClick(view, mNotificationChannel, appUidF); |
| 313 | }); |
| 314 | } |
| 315 | return null; |
| 316 | } |
| 317 | |
| 318 | private void bindConversationDetails() { |
| 319 | final TextView channelName = findViewById(R.id.parent_channel_name); |
| 320 | channelName.setText(mNotificationChannel.getName()); |
| 321 | |
| 322 | bindGroup(); |
Julia Reynolds | f2acd60 | 2020-01-21 16:01:25 -0500 | [diff] [blame] | 323 | // TODO: bring back when channel name does not include name |
| 324 | // bindName(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 325 | bindPackage(); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 326 | bindIcon(mNotificationChannel.isImportantConversation()); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 327 | } |
| 328 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 329 | private void bindIcon(boolean important) { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 330 | ImageView image = findViewById(R.id.conversation_icon); |
Julia Reynolds | 8582df5 | 2020-04-24 18:30:59 -0400 | [diff] [blame] | 331 | image.setImageDrawable(mIconFactory.getConversationDrawable( |
| 332 | mShortcutInfo, mPackageName, mAppUid, important)); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 333 | } |
| 334 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 335 | private void bindPackage() { |
| 336 | ApplicationInfo info; |
| 337 | try { |
| 338 | info = mPm.getApplicationInfo( |
| 339 | mPackageName, |
| 340 | PackageManager.MATCH_UNINSTALLED_PACKAGES |
| 341 | | PackageManager.MATCH_DISABLED_COMPONENTS |
| 342 | | PackageManager.MATCH_DIRECT_BOOT_UNAWARE |
| 343 | | PackageManager.MATCH_DIRECT_BOOT_AWARE); |
| 344 | if (info != null) { |
| 345 | mAppName = String.valueOf(mPm.getApplicationLabel(info)); |
| 346 | } |
| 347 | } catch (PackageManager.NameNotFoundException e) { |
| 348 | } |
| 349 | ((TextView) findViewById(R.id.pkg_name)).setText(mAppName); |
| 350 | } |
| 351 | |
| 352 | private void bindDelegate() { |
| 353 | TextView delegateView = findViewById(R.id.delegate_name); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 354 | |
| 355 | if (!TextUtils.equals(mPackageName, mDelegatePkg)) { |
| 356 | // this notification was posted by a delegate! |
| 357 | delegateView.setVisibility(View.VISIBLE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 358 | } else { |
| 359 | delegateView.setVisibility(View.GONE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | |
| 363 | private void bindGroup() { |
| 364 | // Set group information if this channel has an associated group. |
| 365 | CharSequence groupName = null; |
| 366 | if (mNotificationChannel != null && mNotificationChannel.getGroup() != null) { |
| 367 | try { |
| 368 | final NotificationChannelGroup notificationChannelGroup = |
| 369 | mINotificationManager.getNotificationChannelGroupForPackage( |
| 370 | mNotificationChannel.getGroup(), mPackageName, mAppUid); |
| 371 | if (notificationChannelGroup != null) { |
| 372 | groupName = notificationChannelGroup.getName(); |
| 373 | } |
| 374 | } catch (RemoteException e) { |
| 375 | } |
| 376 | } |
| 377 | TextView groupNameView = findViewById(R.id.group_name); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 378 | if (groupName != null) { |
| 379 | groupNameView.setText(groupName); |
| 380 | groupNameView.setVisibility(VISIBLE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 381 | } else { |
| 382 | groupNameView.setVisibility(GONE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 383 | } |
| 384 | } |
| 385 | |
| 386 | @Override |
| 387 | public boolean post(Runnable action) { |
| 388 | if (mSkipPost) { |
| 389 | action.run(); |
| 390 | return true; |
| 391 | } else { |
| 392 | return super.post(action); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | @Override |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 397 | protected void onFinishInflate() { |
| 398 | super.onFinishInflate(); |
| 399 | |
| 400 | mPriorityDescriptionView = findViewById(R.id.priority_summary); |
| 401 | mDefaultDescriptionView = findViewById(R.id.default_summary); |
| 402 | mSilentDescriptionView = findViewById(R.id.silence_summary); |
| 403 | } |
| 404 | |
| 405 | @Override |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 406 | public void onFinishedClosing() { |
| 407 | // TODO: do we need to do anything here? |
| 408 | } |
| 409 | |
| 410 | @Override |
Julia Reynolds | be37107 | 2020-05-28 11:32:01 -0400 | [diff] [blame] | 411 | public boolean needsFalsingProtection() { |
| 412 | return true; |
| 413 | } |
| 414 | |
| 415 | @Override |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 416 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { |
| 417 | super.onInitializeAccessibilityEvent(event); |
| 418 | if (mGutsContainer != null && |
| 419 | event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { |
| 420 | if (mGutsContainer.isExposed()) { |
| 421 | event.getText().add(mContext.getString( |
| 422 | R.string.notification_channel_controls_opened_accessibility, mAppName)); |
| 423 | } else { |
| 424 | event.getText().add(mContext.getString( |
| 425 | R.string.notification_channel_controls_closed_accessibility, mAppName)); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 430 | private void updateToggleActions(int selectedAction, boolean userTriggered) { |
| 431 | if (userTriggered) { |
| 432 | TransitionSet transition = new TransitionSet(); |
| 433 | transition.setOrdering(TransitionSet.ORDERING_TOGETHER); |
| 434 | transition.addTransition(new Fade(Fade.OUT)) |
| 435 | .addTransition(new ChangeBounds()) |
| 436 | .addTransition( |
| 437 | new Fade(Fade.IN) |
| 438 | .setStartDelay(150) |
| 439 | .setDuration(200) |
| 440 | .setInterpolator(FAST_OUT_SLOW_IN)); |
| 441 | transition.setDuration(350); |
| 442 | transition.setInterpolator(FAST_OUT_SLOW_IN); |
| 443 | TransitionManager.beginDelayedTransition(this, transition); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 444 | } |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 445 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 446 | View priority = findViewById(R.id.priority); |
| 447 | View defaultBehavior = findViewById(R.id.default_behavior); |
| 448 | View silence = findViewById(R.id.silence); |
| 449 | |
| 450 | switch (selectedAction) { |
| 451 | case ACTION_FAVORITE: |
| 452 | mPriorityDescriptionView.setVisibility(VISIBLE); |
| 453 | mDefaultDescriptionView.setVisibility(GONE); |
| 454 | mSilentDescriptionView.setVisibility(GONE); |
| 455 | post(() -> { |
| 456 | priority.setSelected(true); |
| 457 | defaultBehavior.setSelected(false); |
| 458 | silence.setSelected(false); |
| 459 | }); |
| 460 | break; |
| 461 | |
| 462 | case ACTION_MUTE: |
| 463 | mSilentDescriptionView.setVisibility(VISIBLE); |
| 464 | mDefaultDescriptionView.setVisibility(GONE); |
| 465 | mPriorityDescriptionView.setVisibility(GONE); |
| 466 | post(() -> { |
| 467 | priority.setSelected(false); |
| 468 | defaultBehavior.setSelected(false); |
| 469 | silence.setSelected(true); |
| 470 | }); |
| 471 | break; |
| 472 | |
| 473 | case ACTION_DEFAULT: |
| 474 | mDefaultDescriptionView.setVisibility(VISIBLE); |
| 475 | mSilentDescriptionView.setVisibility(GONE); |
| 476 | mPriorityDescriptionView.setVisibility(GONE); |
| 477 | post(() -> { |
| 478 | priority.setSelected(false); |
| 479 | defaultBehavior.setSelected(true); |
| 480 | silence.setSelected(false); |
| 481 | }); |
| 482 | break; |
| 483 | |
| 484 | default: |
| 485 | throw new IllegalArgumentException("Unrecognized behavior: " + mSelectedAction); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 486 | } |
Dan Sandler | b11f2de | 2020-02-19 13:18:24 -0500 | [diff] [blame] | 487 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 488 | boolean isAChange = getSelectedAction() != selectedAction; |
| 489 | TextView done = findViewById(R.id.done); |
| 490 | done.setText(isAChange |
| 491 | ? R.string.inline_ok_button |
| 492 | : R.string.inline_done_button); |
| 493 | |
Dan Sandler | b11f2de | 2020-02-19 13:18:24 -0500 | [diff] [blame] | 494 | // update icon in case importance has changed |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 495 | bindIcon(selectedAction == ACTION_FAVORITE); |
| 496 | } |
| 497 | |
| 498 | int getSelectedAction() { |
| 499 | if (mNotificationChannel.getImportance() <= IMPORTANCE_LOW |
| 500 | && mNotificationChannel.getImportance() > IMPORTANCE_UNSPECIFIED) { |
| 501 | return ACTION_MUTE; |
| 502 | } else { |
| 503 | if (mNotificationChannel.isImportantConversation()) { |
| 504 | return ACTION_FAVORITE; |
| 505 | } |
| 506 | } |
| 507 | return ACTION_DEFAULT; |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | private void updateChannel() { |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 511 | mBgHandler.post( |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 512 | new UpdateChannelRunnable(mINotificationManager, mPackageName, |
| 513 | mAppUid, mSelectedAction, mNotificationChannel)); |
Steve Elliott | 8b4929d | 2020-06-02 13:38:04 -0400 | [diff] [blame] | 514 | mEntry.markForUserTriggeredMovement(true); |
| 515 | mMainHandler.postDelayed( |
| 516 | mVisualStabilityManager::temporarilyAllowReordering, |
| 517 | StackStateAnimator.ANIMATION_DURATION_STANDARD); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 518 | } |
| 519 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 520 | private boolean shouldShowPriorityOnboarding() { |
| 521 | return !Prefs.getBoolean(mUserContext, Prefs.Key.HAS_SEEN_PRIORITY_ONBOARDING, false); |
| 522 | } |
| 523 | |
| 524 | private void showPriorityOnboarding() { |
| 525 | View onboardingView = LayoutInflater.from(mContext) |
| 526 | .inflate(R.layout.priority_onboarding_half_shell, null); |
| 527 | |
| 528 | boolean ignoreDnd = false; |
| 529 | try { |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 530 | ignoreDnd = mINotificationManager |
| 531 | .getConsolidatedNotificationPolicy().priorityConversationSenders == |
| 532 | NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 533 | } catch (RemoteException e) { |
| 534 | Log.e(TAG, "Could not check conversation senders", e); |
| 535 | } |
| 536 | |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 537 | boolean showAsBubble = mBubbleMetadata != null |
| 538 | && mBubbleMetadata.getAutoExpandBubble() |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 539 | && Settings.Global.getInt(mContext.getContentResolver(), |
| 540 | NOTIFICATION_BUBBLES, 0) == 1; |
| 541 | |
| 542 | PriorityOnboardingDialogController controller = mBuilderProvider.get() |
| 543 | .setContext(mUserContext) |
| 544 | .setView(onboardingView) |
| 545 | .setIgnoresDnd(ignoreDnd) |
| 546 | .setShowsAsBubble(showAsBubble) |
Julia Reynolds | c535650 | 2020-06-08 16:14:58 -0400 | [diff] [blame] | 547 | .setIcon(mIconFactory.getBaseIconDrawable(mShortcutInfo)) |
| 548 | .setBadge(mIconFactory.getAppBadge( |
| 549 | mPackageName, UserHandle.getUserId(mSbn.getUid()))) |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 550 | .setOnSettingsClick(mOnConversationSettingsClickListener) |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 551 | .build(); |
| 552 | |
| 553 | controller.init(); |
| 554 | controller.show(); |
| 555 | } |
| 556 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 557 | @Override |
| 558 | public void setGutsParent(NotificationGuts guts) { |
| 559 | mGutsContainer = guts; |
| 560 | } |
| 561 | |
| 562 | @Override |
| 563 | public boolean willBeRemoved() { |
| 564 | return false; |
| 565 | } |
| 566 | |
| 567 | @Override |
| 568 | public boolean shouldBeSaved() { |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 569 | return mPressedApply; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | @Override |
| 573 | public View getContentView() { |
| 574 | return this; |
| 575 | } |
| 576 | |
| 577 | @Override |
| 578 | public boolean handleCloseControls(boolean save, boolean force) { |
| 579 | if (save && mSelectedAction > -1) { |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 580 | updateChannel(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 581 | } |
| 582 | return false; |
| 583 | } |
| 584 | |
| 585 | @Override |
| 586 | public int getActualHeight() { |
Selim Cinek | a5a4ee4 | 2020-05-21 15:38:32 -0700 | [diff] [blame] | 587 | // Because we're animating the bounds, getHeight will return the small height at the |
| 588 | // beginning of the animation. Instead we'd want it to already return the end value |
| 589 | return mActualHeight; |
| 590 | } |
| 591 | |
| 592 | @Override |
| 593 | protected void onLayout(boolean changed, int l, int t, int r, int b) { |
| 594 | super.onLayout(changed, l, t, r, b); |
| 595 | mActualHeight = getHeight(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | @VisibleForTesting |
| 599 | public boolean isAnimating() { |
| 600 | return false; |
| 601 | } |
| 602 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 603 | class UpdateChannelRunnable implements Runnable { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 604 | |
| 605 | private final INotificationManager mINotificationManager; |
| 606 | private final String mAppPkg; |
| 607 | private final int mAppUid; |
| 608 | private NotificationChannel mChannelToUpdate; |
| 609 | private final @Action int mAction; |
| 610 | |
| 611 | public UpdateChannelRunnable(INotificationManager notificationManager, |
| 612 | String packageName, int appUid, @Action int action, |
| 613 | @NonNull NotificationChannel channelToUpdate) { |
| 614 | mINotificationManager = notificationManager; |
| 615 | mAppPkg = packageName; |
| 616 | mAppUid = appUid; |
| 617 | mChannelToUpdate = channelToUpdate; |
| 618 | mAction = action; |
| 619 | } |
| 620 | |
| 621 | @Override |
| 622 | public void run() { |
| 623 | try { |
| 624 | switch (mAction) { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 625 | case ACTION_FAVORITE: |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 626 | mChannelToUpdate.setImportantConversation(true); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 627 | if (mChannelToUpdate.isImportantConversation()) { |
Julia Reynolds | 908201e | 2020-02-17 21:53:49 -0500 | [diff] [blame] | 628 | mChannelToUpdate.setAllowBubbles(true); |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 629 | if (mAppBubble == BUBBLE_PREFERENCE_NONE) { |
Mady Mellor | a92268c | 2020-03-09 17:25:08 -0700 | [diff] [blame] | 630 | mINotificationManager.setBubblesAllowed(mAppPkg, mAppUid, |
| 631 | BUBBLE_PREFERENCE_SELECTED); |
| 632 | } |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 633 | post(() -> { |
| 634 | mBubbleController.onUserChangedImportance(mEntry); |
| 635 | }); |
Julia Reynolds | 908201e | 2020-02-17 21:53:49 -0500 | [diff] [blame] | 636 | } |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 637 | mChannelToUpdate.setImportance(Math.max( |
| 638 | mChannelToUpdate.getOriginalImportance(), IMPORTANCE_DEFAULT)); |
| 639 | break; |
| 640 | case ACTION_DEFAULT: |
| 641 | mChannelToUpdate.setImportance(Math.max( |
| 642 | mChannelToUpdate.getOriginalImportance(), IMPORTANCE_DEFAULT)); |
| 643 | if (mChannelToUpdate.isImportantConversation()) { |
| 644 | mChannelToUpdate.setImportantConversation(false); |
| 645 | mChannelToUpdate.setAllowBubbles(false); |
| 646 | } |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 647 | break; |
| 648 | case ACTION_MUTE: |
| 649 | if (mChannelToUpdate.getImportance() == IMPORTANCE_UNSPECIFIED |
| 650 | || mChannelToUpdate.getImportance() >= IMPORTANCE_DEFAULT) { |
| 651 | mChannelToUpdate.setImportance(IMPORTANCE_LOW); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 652 | } |
| 653 | if (mChannelToUpdate.isImportantConversation()) { |
| 654 | mChannelToUpdate.setImportantConversation(false); |
| 655 | mChannelToUpdate.setAllowBubbles(false); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 656 | } |
| 657 | break; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 658 | } |
| 659 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 660 | mINotificationManager.updateNotificationChannelForPackage( |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 661 | mAppPkg, mAppUid, mChannelToUpdate); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 662 | } catch (RemoteException e) { |
| 663 | Log.e(TAG, "Unable to update notification channel", e); |
| 664 | } |
| 665 | } |
| 666 | } |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 667 | } |