Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 1 | /* |
| 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 Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 17 | package com.android.systemui.statusbar; |
| 18 | |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.app.INotificationManager; |
| 22 | import android.app.NotificationChannel; |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 23 | import android.app.NotificationChannelGroup; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 24 | import android.app.NotificationManager; |
| 25 | import android.content.Context; |
| 26 | import android.content.pm.ApplicationInfo; |
| 27 | import android.content.pm.PackageInfo; |
| 28 | import android.content.pm.PackageManager; |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 29 | import android.content.pm.ParceledListSlice; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 30 | import android.content.res.ColorStateList; |
| 31 | import android.content.res.TypedArray; |
| 32 | import android.graphics.Canvas; |
| 33 | import android.graphics.drawable.Drawable; |
| 34 | import android.os.Handler; |
| 35 | import android.os.RemoteException; |
| 36 | import android.os.ServiceManager; |
| 37 | import android.service.notification.NotificationListenerService; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 38 | import android.util.AttributeSet; |
| 39 | import android.util.Log; |
| 40 | import android.view.View; |
| 41 | import android.view.ViewAnimationUtils; |
| 42 | import android.view.ViewGroup; |
| 43 | import android.view.View.OnClickListener; |
| 44 | import android.widget.CompoundButton; |
| 45 | import android.widget.ImageView; |
| 46 | import android.widget.LinearLayout; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 47 | import android.widget.SeekBar; |
| 48 | import android.widget.Switch; |
| 49 | import android.widget.TextView; |
| 50 | |
| 51 | import com.android.internal.logging.MetricsLogger; |
| 52 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
| 53 | import com.android.settingslib.Utils; |
| 54 | import com.android.systemui.Interpolators; |
| 55 | import com.android.systemui.R; |
| 56 | import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.GutsContent; |
| 57 | import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.GutsInteractionListener; |
| 58 | import com.android.systemui.statusbar.NotificationGuts.OnSettingsClickListener; |
| 59 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
| 60 | |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 61 | import java.lang.IllegalArgumentException; |
| 62 | import java.util.List; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 63 | import java.util.Set; |
| 64 | |
| 65 | /** |
| 66 | * The guts of a notification revealed when performing a long press. |
| 67 | */ |
| 68 | public class NotificationInfo extends LinearLayout implements GutsContent { |
| 69 | private static final String TAG = "InfoGuts"; |
| 70 | |
| 71 | private INotificationManager mINotificationManager; |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 72 | private String mPkg; |
| 73 | private int mAppUid; |
| 74 | private List<NotificationChannel> mNotificationChannels; |
| 75 | private NotificationChannel mSingleNotificationChannel; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 76 | private int mStartingUserImportance; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 77 | |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 78 | private TextView mNumChannelsView; |
| 79 | private View mChannelDisabledView; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 80 | private Switch mChannelEnabledSwitch; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 81 | |
| 82 | private GutsInteractionListener mGutsInteractionListener; |
| 83 | |
| 84 | public NotificationInfo(Context context, AttributeSet attrs) { |
| 85 | super(context, attrs); |
| 86 | } |
| 87 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 88 | public interface OnSettingsClickListener { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 89 | void onClick(View v, NotificationChannel channel, int appUid); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 90 | } |
| 91 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 92 | public void bindNotification(final PackageManager pm, |
| 93 | final INotificationManager iNotificationManager, |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 94 | final String pkg, |
| 95 | final List<NotificationChannel> notificationChannels, |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 96 | OnSettingsClickListener onSettingsClick, |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 97 | OnClickListener onDoneClick, final Set<String> nonBlockablePkgs) |
| 98 | throws RemoteException { |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 99 | mINotificationManager = iNotificationManager; |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 100 | mPkg = pkg; |
| 101 | mNotificationChannels = notificationChannels; |
Geoffrey Pitsch | ee8c81e | 2017-03-23 11:38:56 -0400 | [diff] [blame^] | 102 | boolean isSingleDefaultChannel = false; |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 103 | if (mNotificationChannels.isEmpty()) { |
| 104 | throw new IllegalArgumentException("bindNotification requires at least one channel"); |
| 105 | } else if (mNotificationChannels.size() == 1) { |
| 106 | mSingleNotificationChannel = mNotificationChannels.get(0); |
| 107 | mStartingUserImportance = mSingleNotificationChannel.getImportance(); |
Geoffrey Pitsch | ee8c81e | 2017-03-23 11:38:56 -0400 | [diff] [blame^] | 108 | isSingleDefaultChannel = mSingleNotificationChannel.getId() |
| 109 | .equals(NotificationChannel.DEFAULT_CHANNEL_ID); |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 110 | } else { |
| 111 | mSingleNotificationChannel = null; |
| 112 | } |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 113 | |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 114 | String appName = mPkg; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 115 | Drawable pkgicon = null; |
Julia Reynolds | 5a31193 | 2017-03-01 16:33:44 -0500 | [diff] [blame] | 116 | CharSequence channelNameText = ""; |
| 117 | ApplicationInfo info = null; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 118 | try { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 119 | info = pm.getApplicationInfo(mPkg, |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 120 | PackageManager.MATCH_UNINSTALLED_PACKAGES |
| 121 | | PackageManager.MATCH_DISABLED_COMPONENTS |
| 122 | | PackageManager.MATCH_DIRECT_BOOT_UNAWARE |
| 123 | | PackageManager.MATCH_DIRECT_BOOT_AWARE); |
| 124 | if (info != null) { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 125 | mAppUid = info.uid; |
Geoffrey Pitsch | 1f7fb1a | 2017-02-13 16:57:40 -0500 | [diff] [blame] | 126 | appName = String.valueOf(pm.getApplicationLabel(info)); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 127 | pkgicon = pm.getApplicationIcon(info); |
| 128 | } |
| 129 | } catch (PackageManager.NameNotFoundException e) { |
| 130 | // app is gone, just show package name and generic icon |
| 131 | pkgicon = pm.getDefaultActivityIcon(); |
| 132 | } |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 133 | ((ImageView) findViewById(R.id.pkgicon)).setImageDrawable(pkgicon); |
| 134 | |
| 135 | int numChannels = 1; |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 136 | numChannels = iNotificationManager.getNumNotificationChannelsForPackage( |
| 137 | pkg, mAppUid, false /* includeDeleted */); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 138 | |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 139 | String channelsDescText; |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 140 | mNumChannelsView = (TextView) (findViewById(R.id.num_channels_desc)); |
Geoffrey Pitsch | ee8c81e | 2017-03-23 11:38:56 -0400 | [diff] [blame^] | 141 | if (isSingleDefaultChannel) { |
| 142 | channelsDescText = mContext.getString(R.string.notification_default_channel_desc); |
| 143 | } else { |
| 144 | switch (mNotificationChannels.size()) { |
| 145 | case 1: |
| 146 | channelsDescText = String.format(mContext.getResources().getQuantityString( |
| 147 | R.plurals.notification_num_channels_desc, numChannels), numChannels); |
| 148 | break; |
| 149 | case 2: |
| 150 | channelsDescText = mContext.getString( |
| 151 | R.string.notification_channels_list_desc_2, |
| 152 | mNotificationChannels.get(0).getName(), |
| 153 | mNotificationChannels.get(1).getName()); |
| 154 | break; |
| 155 | default: |
| 156 | final int numOthers = mNotificationChannels.size() - 2; |
| 157 | channelsDescText = String.format( |
| 158 | mContext.getResources().getQuantityString( |
| 159 | R.plurals.notification_channels_list_desc_2_and_others, |
| 160 | numOthers), |
| 161 | mNotificationChannels.get(0).getName(), |
| 162 | mNotificationChannels.get(1).getName(), |
| 163 | numOthers); |
| 164 | } |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 165 | } |
| 166 | mNumChannelsView.setText(channelsDescText); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 167 | |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 168 | if (mSingleNotificationChannel == null) { |
| 169 | // Multiple channels don't use a channel name for the title. |
| 170 | channelNameText = mContext.getString(R.string.notification_num_channels, |
| 171 | mNotificationChannels.size()); |
Geoffrey Pitsch | ee8c81e | 2017-03-23 11:38:56 -0400 | [diff] [blame^] | 172 | } else if (isSingleDefaultChannel) { |
| 173 | // If this is the default channel, don't use our channel-specific text. |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 174 | channelNameText = mContext.getString(R.string.notification_header_default_channel); |
| 175 | } else { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 176 | channelNameText = mSingleNotificationChannel.getName(); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 177 | } |
Geoffrey Pitsch | 1f7fb1a | 2017-02-13 16:57:40 -0500 | [diff] [blame] | 178 | ((TextView) findViewById(R.id.pkgname)).setText(appName); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 179 | ((TextView) findViewById(R.id.channel_name)).setText(channelNameText); |
| 180 | |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 181 | // Set group information if this channel has an associated group. |
| 182 | CharSequence groupName = null; |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 183 | if (mSingleNotificationChannel != null && mSingleNotificationChannel.getGroup() != null) { |
| 184 | final NotificationChannelGroup notificationChannelGroup = |
| 185 | iNotificationManager.getNotificationChannelGroupForPackage( |
| 186 | mSingleNotificationChannel.getGroup(), pkg, mAppUid); |
| 187 | if (notificationChannelGroup != null) { |
| 188 | groupName = notificationChannelGroup.getName(); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 189 | } |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 190 | } |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 191 | TextView groupNameView = ((TextView) findViewById(R.id.group_name)); |
| 192 | TextView groupDividerView = ((TextView) findViewById(R.id.pkg_group_divider)); |
| 193 | if (groupName != null) { |
| 194 | groupNameView.setText(groupName); |
| 195 | groupNameView.setVisibility(View.VISIBLE); |
| 196 | groupDividerView.setVisibility(View.VISIBLE); |
| 197 | } else { |
| 198 | groupNameView.setVisibility(View.GONE); |
| 199 | groupDividerView.setVisibility(View.GONE); |
| 200 | } |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 201 | |
| 202 | boolean nonBlockable = false; |
| 203 | try { |
Julia Reynolds | 5a31193 | 2017-03-01 16:33:44 -0500 | [diff] [blame] | 204 | final PackageInfo pkgInfo = pm.getPackageInfo(pkg, PackageManager.GET_SIGNATURES); |
| 205 | nonBlockable = Utils.isSystemPackage(getResources(), pm, pkgInfo); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 206 | } catch (PackageManager.NameNotFoundException e) { |
| 207 | // unlikely. |
| 208 | } |
| 209 | if (nonBlockablePkgs != null) { |
| 210 | nonBlockable |= nonBlockablePkgs.contains(pkg); |
| 211 | } |
| 212 | |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 213 | bindButtons(nonBlockable); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 214 | |
| 215 | // Top-level importance group |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 216 | mChannelDisabledView = findViewById(R.id.channel_disabled); |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 217 | updateSecondaryText(); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 218 | |
| 219 | // Settings button. |
| 220 | final TextView settingsButton = (TextView) findViewById(R.id.more_settings); |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 221 | if (mAppUid >= 0 && onSettingsClick != null) { |
| 222 | final int appUidF = mAppUid; |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 223 | settingsButton.setOnClickListener( |
| 224 | (View view) -> { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 225 | onSettingsClick.onClick(view, mSingleNotificationChannel, appUidF); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 226 | }); |
| 227 | if (numChannels > 1) { |
| 228 | settingsButton.setText(R.string.notification_all_categories); |
| 229 | } else { |
| 230 | settingsButton.setText(R.string.notification_more_settings); |
| 231 | } |
| 232 | |
| 233 | } else { |
| 234 | settingsButton.setVisibility(View.GONE); |
| 235 | } |
| 236 | |
| 237 | // Done button. |
| 238 | final TextView doneButton = (TextView) findViewById(R.id.done); |
| 239 | doneButton.setText(R.string.notification_done); |
| 240 | doneButton.setOnClickListener(onDoneClick); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | public boolean hasImportanceChanged() { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 244 | return mSingleNotificationChannel != null && |
| 245 | mStartingUserImportance != getSelectedImportance(); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 246 | } |
| 247 | |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 248 | private void saveImportance() { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 249 | if (mSingleNotificationChannel == null) { |
| 250 | return; |
| 251 | } |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 252 | int selectedImportance = getSelectedImportance(); |
| 253 | if (selectedImportance == mStartingUserImportance) { |
| 254 | return; |
| 255 | } |
| 256 | MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE, |
| 257 | selectedImportance - mStartingUserImportance); |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 258 | mSingleNotificationChannel.setImportance(selectedImportance); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 259 | try { |
| 260 | mINotificationManager.updateNotificationChannelForPackage( |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 261 | mPkg, mAppUid, mSingleNotificationChannel); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 262 | } catch (RemoteException e) { |
| 263 | // :( |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | private int getSelectedImportance() { |
| 268 | if (!mChannelEnabledSwitch.isChecked()) { |
| 269 | return NotificationManager.IMPORTANCE_NONE; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 270 | } else { |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 271 | return mStartingUserImportance; |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 275 | private void bindButtons(final boolean nonBlockable) { |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 276 | // Enabled Switch |
| 277 | mChannelEnabledSwitch = (Switch) findViewById(R.id.channel_enabled_switch); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 278 | mChannelEnabledSwitch.setChecked( |
| 279 | mStartingUserImportance != NotificationManager.IMPORTANCE_NONE); |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 280 | final boolean visible = !nonBlockable && mSingleNotificationChannel != null; |
| 281 | mChannelEnabledSwitch.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 282 | |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 283 | // Callback when checked. |
| 284 | mChannelEnabledSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> { |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 285 | if (mGutsInteractionListener != null) { |
| 286 | mGutsInteractionListener.onInteraction(NotificationInfo.this); |
| 287 | } |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 288 | updateSecondaryText(); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 289 | }); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 292 | private void updateSecondaryText() { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 293 | final boolean disabled = mSingleNotificationChannel != null && |
| 294 | getSelectedImportance() == NotificationManager.IMPORTANCE_NONE; |
Geoffrey Pitsch | ee8c81e | 2017-03-23 11:38:56 -0400 | [diff] [blame^] | 295 | if (disabled) { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 296 | mChannelDisabledView.setVisibility(View.VISIBLE); |
| 297 | mNumChannelsView.setVisibility(View.GONE); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 298 | } else { |
Geoffrey Pitsch | d0856f0 | 2017-02-16 10:51:18 -0500 | [diff] [blame] | 299 | mChannelDisabledView.setVisibility(View.GONE); |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 300 | mNumChannelsView.setVisibility(View.VISIBLE); |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 301 | } |
| 302 | } |
| 303 | |
| 304 | @Override |
| 305 | public void setInteractionListener(GutsInteractionListener listener) { |
| 306 | mGutsInteractionListener = listener; |
| 307 | } |
| 308 | |
| 309 | @Override |
Mady Mellor | 434180c | 2017-02-13 11:29:42 -0800 | [diff] [blame] | 310 | public boolean willBeRemoved() { |
| 311 | return !mChannelEnabledSwitch.isChecked(); |
| 312 | } |
| 313 | |
| 314 | @Override |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 315 | public View getContentView() { |
| 316 | return this; |
| 317 | } |
| 318 | |
| 319 | @Override |
Geoffrey Pitsch | df44b60 | 2017-02-03 13:31:50 -0500 | [diff] [blame] | 320 | public boolean handleCloseControls(boolean save) { |
| 321 | if (save) { |
| 322 | saveImportance(); |
| 323 | } |
Mady Mellor | 87d7945 | 2017-01-10 11:52:52 -0800 | [diff] [blame] | 324 | return false; |
| 325 | } |
| 326 | } |