blob: 89251897e25f993e0451bcb0cc94c53bc5ca94ad [file] [log] [blame]
Mady Mellor87d79452017-01-10 11:52:52 -08001/*
2 * Copyright (C) 2017 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
Geoffrey Pitschdf44b602017-02-03 13:31:50 -050017package com.android.systemui.statusbar;
18
Julia Reynolds3aedded2017-03-31 14:42:09 -040019import static android.app.NotificationManager.IMPORTANCE_NONE;
20
Mady Mellor87d79452017-01-10 11:52:52 -080021import android.app.INotificationManager;
Julia Reynolds3aedded2017-03-31 14:42:09 -040022import android.app.Notification;
Mady Mellor87d79452017-01-10 11:52:52 -080023import android.app.NotificationChannel;
Geoffrey Pitschdf44b602017-02-03 13:31:50 -050024import android.app.NotificationChannelGroup;
Mady Mellor87d79452017-01-10 11:52:52 -080025import android.content.Context;
Julia Reynolds3aedded2017-03-31 14:42:09 -040026import android.content.Intent;
27import android.content.pm.ActivityInfo;
Mady Mellor87d79452017-01-10 11:52:52 -080028import android.content.pm.ApplicationInfo;
29import android.content.pm.PackageInfo;
30import android.content.pm.PackageManager;
Julia Reynolds3aedded2017-03-31 14:42:09 -040031import android.content.pm.ResolveInfo;
Mady Mellor87d79452017-01-10 11:52:52 -080032import android.graphics.drawable.Drawable;
Mady Mellor87d79452017-01-10 11:52:52 -080033import android.os.RemoteException;
Julia Reynolds3aedded2017-03-31 14:42:09 -040034import android.service.notification.StatusBarNotification;
35import android.text.TextUtils;
Mady Mellor87d79452017-01-10 11:52:52 -080036import android.util.AttributeSet;
Mady Mellor87d79452017-01-10 11:52:52 -080037import android.view.View;
Geoffrey Pitschd94e7882017-04-06 09:52:11 -040038import android.view.accessibility.AccessibilityEvent;
Mady Mellor87d79452017-01-10 11:52:52 -080039import android.widget.ImageView;
40import android.widget.LinearLayout;
Mady Mellor87d79452017-01-10 11:52:52 -080041import android.widget.Switch;
42import android.widget.TextView;
43
44import com.android.internal.logging.MetricsLogger;
45import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
46import com.android.settingslib.Utils;
Mady Mellor87d79452017-01-10 11:52:52 -080047import com.android.systemui.R;
Mady Mellor87d79452017-01-10 11:52:52 -080048
Geoffrey Pitschd0856f02017-02-16 10:51:18 -050049import java.lang.IllegalArgumentException;
50import java.util.List;
Mady Mellor87d79452017-01-10 11:52:52 -080051import java.util.Set;
52
53/**
54 * The guts of a notification revealed when performing a long press.
55 */
Mady Mellor95d743c2017-01-10 12:05:27 -080056public class NotificationInfo extends LinearLayout implements NotificationGuts.GutsContent {
Mady Mellor87d79452017-01-10 11:52:52 -080057 private static final String TAG = "InfoGuts";
58
59 private INotificationManager mINotificationManager;
Geoffrey Pitschd0856f02017-02-16 10:51:18 -050060 private String mPkg;
Geoffrey Pitschd94e7882017-04-06 09:52:11 -040061 private String mAppName;
Geoffrey Pitschd0856f02017-02-16 10:51:18 -050062 private int mAppUid;
63 private List<NotificationChannel> mNotificationChannels;
64 private NotificationChannel mSingleNotificationChannel;
Julia Reynolds3aedded2017-03-31 14:42:09 -040065 private StatusBarNotification mSbn;
Mady Mellor87d79452017-01-10 11:52:52 -080066 private int mStartingUserImportance;
Mady Mellor87d79452017-01-10 11:52:52 -080067
Geoffrey Pitschdf44b602017-02-03 13:31:50 -050068 private TextView mNumChannelsView;
69 private View mChannelDisabledView;
Julia Reynolds3aedded2017-03-31 14:42:09 -040070 private TextView mSettingsLinkView;
Mady Mellor87d79452017-01-10 11:52:52 -080071 private Switch mChannelEnabledSwitch;
Geoffrey Pitsch5278d3d2017-03-29 13:39:10 -040072 private CheckSaveListener mCheckSaveListener;
Julia Reynolds3aedded2017-03-31 14:42:09 -040073 private OnAppSettingsClickListener mAppSettingsClickListener;
74 private PackageManager mPm;
Mady Mellor87d79452017-01-10 11:52:52 -080075
Mady Mellor95d743c2017-01-10 12:05:27 -080076 private NotificationGuts mGutsContainer;
Mady Mellor87d79452017-01-10 11:52:52 -080077
78 public NotificationInfo(Context context, AttributeSet attrs) {
79 super(context, attrs);
80 }
81
Geoffrey Pitsch5278d3d2017-03-29 13:39:10 -040082 // Specify a CheckSaveListener to override when/if the user's changes are committed.
83 public interface CheckSaveListener {
84 // Invoked when importance has changed and the NotificationInfo wants to try to save it.
85 // Listener should run saveImportance unless the change should be canceled.
86 void checkSave(Runnable saveImportance);
87 }
88
Jason Monk2a6ea9c2017-01-26 11:14:51 -050089 public interface OnSettingsClickListener {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -050090 void onClick(View v, NotificationChannel channel, int appUid);
Mady Mellor87d79452017-01-10 11:52:52 -080091 }
92
Julia Reynolds3aedded2017-03-31 14:42:09 -040093 public interface OnAppSettingsClickListener {
94 void onClick(View v, Intent intent);
95 }
96
Jason Monk2a6ea9c2017-01-26 11:14:51 -050097 public void bindNotification(final PackageManager pm,
98 final INotificationManager iNotificationManager,
Geoffrey Pitschd0856f02017-02-16 10:51:18 -050099 final String pkg,
100 final List<NotificationChannel> notificationChannels,
Julia Reynolds3aedded2017-03-31 14:42:09 -0400101 int startingUserImportance,
102 final StatusBarNotification sbn,
Mady Mellor87d79452017-01-10 11:52:52 -0800103 OnSettingsClickListener onSettingsClick,
Julia Reynolds3aedded2017-03-31 14:42:09 -0400104 OnAppSettingsClickListener onAppSettingsClick,
Geoffrey Pitsch5278d3d2017-03-29 13:39:10 -0400105 OnClickListener onDoneClick,
106 CheckSaveListener checkSaveListener,
107 final Set<String> nonBlockablePkgs)
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500108 throws RemoteException {
Mady Mellor87d79452017-01-10 11:52:52 -0800109 mINotificationManager = iNotificationManager;
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500110 mPkg = pkg;
111 mNotificationChannels = notificationChannels;
Geoffrey Pitsch5278d3d2017-03-29 13:39:10 -0400112 mCheckSaveListener = checkSaveListener;
Julia Reynolds3aedded2017-03-31 14:42:09 -0400113 mSbn = sbn;
114 mPm = pm;
115 mAppSettingsClickListener = onAppSettingsClick;
Geoffrey Pitschee8c81e2017-03-23 11:38:56 -0400116 boolean isSingleDefaultChannel = false;
Julia Reynolds3aedded2017-03-31 14:42:09 -0400117 mStartingUserImportance = startingUserImportance;
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500118 if (mNotificationChannels.isEmpty()) {
119 throw new IllegalArgumentException("bindNotification requires at least one channel");
Julia Reynolds3aedded2017-03-31 14:42:09 -0400120 } else {
121 if (mNotificationChannels.size() == 1) {
122 mSingleNotificationChannel = mNotificationChannels.get(0);
123 isSingleDefaultChannel = mSingleNotificationChannel.getId()
124 .equals(NotificationChannel.DEFAULT_CHANNEL_ID);
125 } else {
126 mSingleNotificationChannel = null;
127 }
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500128 }
Mady Mellor87d79452017-01-10 11:52:52 -0800129
Geoffrey Pitschd94e7882017-04-06 09:52:11 -0400130 mAppName = mPkg;
Mady Mellor87d79452017-01-10 11:52:52 -0800131 Drawable pkgicon = null;
Julia Reynolds5a311932017-03-01 16:33:44 -0500132 CharSequence channelNameText = "";
133 ApplicationInfo info = null;
Mady Mellor87d79452017-01-10 11:52:52 -0800134 try {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500135 info = pm.getApplicationInfo(mPkg,
Mady Mellor87d79452017-01-10 11:52:52 -0800136 PackageManager.MATCH_UNINSTALLED_PACKAGES
137 | PackageManager.MATCH_DISABLED_COMPONENTS
138 | PackageManager.MATCH_DIRECT_BOOT_UNAWARE
139 | PackageManager.MATCH_DIRECT_BOOT_AWARE);
140 if (info != null) {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500141 mAppUid = info.uid;
Geoffrey Pitschd94e7882017-04-06 09:52:11 -0400142 mAppName = String.valueOf(pm.getApplicationLabel(info));
Mady Mellor87d79452017-01-10 11:52:52 -0800143 pkgicon = pm.getApplicationIcon(info);
144 }
145 } catch (PackageManager.NameNotFoundException e) {
146 // app is gone, just show package name and generic icon
147 pkgicon = pm.getDefaultActivityIcon();
148 }
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500149 ((ImageView) findViewById(R.id.pkgicon)).setImageDrawable(pkgicon);
150
151 int numChannels = 1;
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500152 numChannels = iNotificationManager.getNumNotificationChannelsForPackage(
153 pkg, mAppUid, false /* includeDeleted */);
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500154
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500155 String channelsDescText;
Alan Viverette51efddb2017-04-05 10:00:01 -0400156 mNumChannelsView = findViewById(R.id.num_channels_desc);
Geoffrey Pitschee8c81e2017-03-23 11:38:56 -0400157 if (isSingleDefaultChannel) {
158 channelsDescText = mContext.getString(R.string.notification_default_channel_desc);
159 } else {
160 switch (mNotificationChannels.size()) {
161 case 1:
162 channelsDescText = String.format(mContext.getResources().getQuantityString(
163 R.plurals.notification_num_channels_desc, numChannels), numChannels);
164 break;
165 case 2:
166 channelsDescText = mContext.getString(
167 R.string.notification_channels_list_desc_2,
168 mNotificationChannels.get(0).getName(),
169 mNotificationChannels.get(1).getName());
170 break;
171 default:
172 final int numOthers = mNotificationChannels.size() - 2;
173 channelsDescText = String.format(
174 mContext.getResources().getQuantityString(
175 R.plurals.notification_channels_list_desc_2_and_others,
176 numOthers),
177 mNotificationChannels.get(0).getName(),
178 mNotificationChannels.get(1).getName(),
179 numOthers);
180 }
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500181 }
182 mNumChannelsView.setText(channelsDescText);
Mady Mellor87d79452017-01-10 11:52:52 -0800183
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500184 if (mSingleNotificationChannel == null) {
185 // Multiple channels don't use a channel name for the title.
186 channelNameText = mContext.getString(R.string.notification_num_channels,
187 mNotificationChannels.size());
Geoffrey Pitschee8c81e2017-03-23 11:38:56 -0400188 } else if (isSingleDefaultChannel) {
189 // If this is the default channel, don't use our channel-specific text.
Mady Mellor87d79452017-01-10 11:52:52 -0800190 channelNameText = mContext.getString(R.string.notification_header_default_channel);
191 } else {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500192 channelNameText = mSingleNotificationChannel.getName();
Mady Mellor87d79452017-01-10 11:52:52 -0800193 }
Geoffrey Pitschd94e7882017-04-06 09:52:11 -0400194 ((TextView) findViewById(R.id.pkgname)).setText(mAppName);
Mady Mellor87d79452017-01-10 11:52:52 -0800195 ((TextView) findViewById(R.id.channel_name)).setText(channelNameText);
196
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500197 // Set group information if this channel has an associated group.
198 CharSequence groupName = null;
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500199 if (mSingleNotificationChannel != null && mSingleNotificationChannel.getGroup() != null) {
200 final NotificationChannelGroup notificationChannelGroup =
201 iNotificationManager.getNotificationChannelGroupForPackage(
202 mSingleNotificationChannel.getGroup(), pkg, mAppUid);
203 if (notificationChannelGroup != null) {
204 groupName = notificationChannelGroup.getName();
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500205 }
Mady Mellor87d79452017-01-10 11:52:52 -0800206 }
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500207 TextView groupNameView = ((TextView) findViewById(R.id.group_name));
208 TextView groupDividerView = ((TextView) findViewById(R.id.pkg_group_divider));
209 if (groupName != null) {
210 groupNameView.setText(groupName);
211 groupNameView.setVisibility(View.VISIBLE);
212 groupDividerView.setVisibility(View.VISIBLE);
213 } else {
214 groupNameView.setVisibility(View.GONE);
215 groupDividerView.setVisibility(View.GONE);
216 }
Mady Mellor87d79452017-01-10 11:52:52 -0800217
218 boolean nonBlockable = false;
219 try {
Julia Reynolds5a311932017-03-01 16:33:44 -0500220 final PackageInfo pkgInfo = pm.getPackageInfo(pkg, PackageManager.GET_SIGNATURES);
221 nonBlockable = Utils.isSystemPackage(getResources(), pm, pkgInfo);
Mady Mellor87d79452017-01-10 11:52:52 -0800222 } catch (PackageManager.NameNotFoundException e) {
223 // unlikely.
224 }
225 if (nonBlockablePkgs != null) {
226 nonBlockable |= nonBlockablePkgs.contains(pkg);
227 }
228
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500229 bindButtons(nonBlockable);
Mady Mellor87d79452017-01-10 11:52:52 -0800230
231 // Top-level importance group
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500232 mChannelDisabledView = findViewById(R.id.channel_disabled);
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500233 updateSecondaryText();
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500234
235 // Settings button.
236 final TextView settingsButton = (TextView) findViewById(R.id.more_settings);
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500237 if (mAppUid >= 0 && onSettingsClick != null) {
Geoffrey Pitsch029a3fa2017-03-30 13:01:57 -0400238 settingsButton.setVisibility(View.VISIBLE);
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500239 final int appUidF = mAppUid;
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500240 settingsButton.setOnClickListener(
241 (View view) -> {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500242 onSettingsClick.onClick(view, mSingleNotificationChannel, appUidF);
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500243 });
244 if (numChannels > 1) {
245 settingsButton.setText(R.string.notification_all_categories);
246 } else {
247 settingsButton.setText(R.string.notification_more_settings);
248 }
249
250 } else {
251 settingsButton.setVisibility(View.GONE);
252 }
253
254 // Done button.
255 final TextView doneButton = (TextView) findViewById(R.id.done);
256 doneButton.setText(R.string.notification_done);
257 doneButton.setOnClickListener(onDoneClick);
Julia Reynolds3aedded2017-03-31 14:42:09 -0400258
259 // Optional settings link
260 updateAppSettingsLink();
Mady Mellor87d79452017-01-10 11:52:52 -0800261 }
262
Geoffrey Pitsch5278d3d2017-03-29 13:39:10 -0400263 private boolean hasImportanceChanged() {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500264 return mSingleNotificationChannel != null &&
265 mStartingUserImportance != getSelectedImportance();
Mady Mellor87d79452017-01-10 11:52:52 -0800266 }
267
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500268 private void saveImportance() {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500269 if (mSingleNotificationChannel == null) {
270 return;
271 }
Mady Mellor87d79452017-01-10 11:52:52 -0800272 int selectedImportance = getSelectedImportance();
273 if (selectedImportance == mStartingUserImportance) {
274 return;
275 }
276 MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE,
277 selectedImportance - mStartingUserImportance);
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500278 mSingleNotificationChannel.setImportance(selectedImportance);
Julia Reynolds8ceb5792017-04-11 11:32:44 -0400279 mSingleNotificationChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
Mady Mellor87d79452017-01-10 11:52:52 -0800280 try {
281 mINotificationManager.updateNotificationChannelForPackage(
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500282 mPkg, mAppUid, mSingleNotificationChannel);
Mady Mellor87d79452017-01-10 11:52:52 -0800283 } catch (RemoteException e) {
284 // :(
285 }
286 }
287
288 private int getSelectedImportance() {
289 if (!mChannelEnabledSwitch.isChecked()) {
Julia Reynolds3aedded2017-03-31 14:42:09 -0400290 return IMPORTANCE_NONE;
Mady Mellor87d79452017-01-10 11:52:52 -0800291 } else {
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500292 return mStartingUserImportance;
Mady Mellor87d79452017-01-10 11:52:52 -0800293 }
294 }
295
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500296 private void bindButtons(final boolean nonBlockable) {
Mady Mellor87d79452017-01-10 11:52:52 -0800297 // Enabled Switch
298 mChannelEnabledSwitch = (Switch) findViewById(R.id.channel_enabled_switch);
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500299 mChannelEnabledSwitch.setChecked(
Julia Reynolds3aedded2017-03-31 14:42:09 -0400300 mStartingUserImportance != IMPORTANCE_NONE);
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500301 final boolean visible = !nonBlockable && mSingleNotificationChannel != null;
302 mChannelEnabledSwitch.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
Mady Mellor87d79452017-01-10 11:52:52 -0800303
Mady Mellor87d79452017-01-10 11:52:52 -0800304 // Callback when checked.
305 mChannelEnabledSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
Mady Mellor95d743c2017-01-10 12:05:27 -0800306 if (mGutsContainer != null) {
307 mGutsContainer.resetFalsingCheck();
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500308 }
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500309 updateSecondaryText();
Julia Reynolds3aedded2017-03-31 14:42:09 -0400310 updateAppSettingsLink();
Mady Mellor87d79452017-01-10 11:52:52 -0800311 });
Mady Mellor87d79452017-01-10 11:52:52 -0800312 }
313
Geoffrey Pitschd94e7882017-04-06 09:52:11 -0400314 @Override
315 public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
316 super.onInitializeAccessibilityEvent(event);
317 if (mGutsContainer != null &&
318 event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
319 if (mGutsContainer.isExposed()) {
320 event.getText().add(mContext.getString(
321 R.string.notification_channel_controls_opened_accessibility, mAppName));
322 } else {
323 event.getText().add(mContext.getString(
324 R.string.notification_channel_controls_closed_accessibility, mAppName));
325 }
326 }
327 }
328
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500329 private void updateSecondaryText() {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500330 final boolean disabled = mSingleNotificationChannel != null &&
Julia Reynolds3aedded2017-03-31 14:42:09 -0400331 getSelectedImportance() == IMPORTANCE_NONE;
Geoffrey Pitschee8c81e2017-03-23 11:38:56 -0400332 if (disabled) {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500333 mChannelDisabledView.setVisibility(View.VISIBLE);
334 mNumChannelsView.setVisibility(View.GONE);
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500335 } else {
Geoffrey Pitschd0856f02017-02-16 10:51:18 -0500336 mChannelDisabledView.setVisibility(View.GONE);
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500337 mNumChannelsView.setVisibility(View.VISIBLE);
Mady Mellor87d79452017-01-10 11:52:52 -0800338 }
339 }
340
Julia Reynolds3aedded2017-03-31 14:42:09 -0400341 private void updateAppSettingsLink() {
342 mSettingsLinkView = findViewById(R.id.app_settings);
343 Intent settingsIntent = getAppSettingsIntent(mPm, mPkg, mSingleNotificationChannel,
344 mSbn.getId(), mSbn.getTag());
345 if (settingsIntent != null && getSelectedImportance() != IMPORTANCE_NONE
346 && !TextUtils.isEmpty(mSbn.getNotification().getSettingsText())) {
347 mSettingsLinkView.setVisibility(View.VISIBLE);
348 mSettingsLinkView.setText(mContext.getString(R.string.notification_app_settings,
349 mSbn.getNotification().getSettingsText()));
350 mSettingsLinkView.setOnClickListener((View view) -> {
351 mAppSettingsClickListener.onClick(view, settingsIntent);
352 });
353 } else {
354 mSettingsLinkView.setVisibility(View.GONE);
355 }
356 }
357
358 private Intent getAppSettingsIntent(PackageManager pm, String packageName,
359 NotificationChannel channel, int id, String tag) {
360 Intent intent = new Intent(Intent.ACTION_MAIN)
361 .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES)
362 .setPackage(packageName);
363 final List<ResolveInfo> resolveInfos = pm.queryIntentActivities(
364 intent,
365 PackageManager.MATCH_DEFAULT_ONLY
366 );
367 if (resolveInfos == null || resolveInfos.size() == 0 || resolveInfos.get(0) == null) {
368 return null;
369 }
370 final ActivityInfo activityInfo = resolveInfos.get(0).activityInfo;
371 intent.setClassName(activityInfo.packageName, activityInfo.name);
372 if (channel != null) {
373 intent.putExtra(Notification.EXTRA_CHANNEL_ID, channel.getId());
374 }
375 intent.putExtra(Notification.EXTRA_NOTIFICATION_ID, id);
376 intent.putExtra(Notification.EXTRA_NOTIFICATION_TAG, tag);
377 return intent;
378 }
379
Mady Mellor87d79452017-01-10 11:52:52 -0800380 @Override
Mady Mellor95d743c2017-01-10 12:05:27 -0800381 public void setGutsParent(NotificationGuts guts) {
382 mGutsContainer = guts;
Mady Mellor87d79452017-01-10 11:52:52 -0800383 }
384
385 @Override
Mady Mellor434180c2017-02-13 11:29:42 -0800386 public boolean willBeRemoved() {
387 return !mChannelEnabledSwitch.isChecked();
388 }
389
390 @Override
Mady Mellor87d79452017-01-10 11:52:52 -0800391 public View getContentView() {
392 return this;
393 }
394
395 @Override
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500396 public boolean handleCloseControls(boolean save) {
Geoffrey Pitsch5278d3d2017-03-29 13:39:10 -0400397 if (save && hasImportanceChanged()) {
398 if (mCheckSaveListener != null) {
399 mCheckSaveListener.checkSave(() -> { saveImportance(); });
400 } else {
401 saveImportance();
402 }
Geoffrey Pitschdf44b602017-02-03 13:31:50 -0500403 }
Mady Mellor87d79452017-01-10 11:52:52 -0800404 return false;
405 }
406}