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