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