Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 1 | /* |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 2 | * Copyright (C) 2017 The Android Open Source Project |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 3 | * |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 13 | */ |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 14 | package com.android.systemui.qs.tileimpl; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 15 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 16 | import static com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH; |
| 17 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 18 | import android.animation.ValueAnimator; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 19 | import android.content.Context; |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 20 | import android.content.res.ColorStateList; |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 21 | import android.content.res.TypedArray; |
| 22 | import android.graphics.drawable.Drawable; |
| 23 | import android.graphics.drawable.RippleDrawable; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 24 | import android.os.Handler; |
| 25 | import android.os.Looper; |
| 26 | import android.os.Message; |
Jason Monk | e2f05d2 | 2017-03-23 10:45:37 -0400 | [diff] [blame] | 27 | import android.service.quicksettings.Tile; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 28 | import android.text.TextUtils; |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 29 | import android.util.Log; |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 30 | import android.view.Gravity; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 31 | import android.view.View; |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 32 | import android.view.ViewGroup; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 33 | import android.view.accessibility.AccessibilityEvent; |
| 34 | import android.view.accessibility.AccessibilityNodeInfo; |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 35 | import android.widget.FrameLayout; |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 36 | import android.widget.ImageView; |
| 37 | import android.widget.ImageView.ScaleType; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 38 | import android.widget.Switch; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 39 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 40 | import com.android.settingslib.Utils; |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 41 | import com.android.systemui.R; |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 42 | import com.android.systemui.plugins.qs.QSIconView; |
| 43 | import com.android.systemui.plugins.qs.QSTile; |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 44 | import com.android.systemui.plugins.qs.QSTile.BooleanState; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 45 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 46 | public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 47 | |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 48 | private static final String TAG = "QSTileBaseView"; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 49 | private final H mHandler = new H(); |
Jason Monk | f13413e | 2017-02-15 15:49:32 -0500 | [diff] [blame] | 50 | private final FrameLayout mIconFrame; |
Jiaquan He | 074ae46 | 2016-05-13 08:56:19 -0700 | [diff] [blame] | 51 | protected QSIconView mIcon; |
| 52 | protected RippleDrawable mRipple; |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 53 | private Drawable mTileBackground; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 54 | private String mAccessibilityClass; |
| 55 | private boolean mTileState; |
| 56 | private boolean mCollapsedView; |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 57 | private boolean mClicked; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 58 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 59 | private final ImageView mBg; |
| 60 | private final int mColorActive; |
| 61 | private final int mColorInactive; |
| 62 | private final int mColorDisabled; |
| 63 | private int mCircleColor; |
| 64 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 65 | public QSTileBaseView(Context context, QSIconView icon) { |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 66 | this(context, icon, false); |
| 67 | } |
| 68 | |
| 69 | public QSTileBaseView(Context context, QSIconView icon, boolean collapsedView) { |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 70 | super(context); |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 71 | // Default to Quick Tile padding, and QSTileView will specify its own padding. |
| 72 | int padding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding); |
| 73 | |
Jason Monk | f13413e | 2017-02-15 15:49:32 -0500 | [diff] [blame] | 74 | mIconFrame = new FrameLayout(context); |
| 75 | mIconFrame.setForegroundGravity(Gravity.CENTER); |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 76 | int size = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size); |
Jason Monk | f13413e | 2017-02-15 15:49:32 -0500 | [diff] [blame] | 77 | addView(mIconFrame, new LayoutParams(size, size)); |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 78 | mBg = new ImageView(getContext()); |
| 79 | mBg.setScaleType(ScaleType.FIT_CENTER); |
| 80 | mBg.setImageResource(R.drawable.ic_qs_circle); |
| 81 | mIconFrame.addView(mBg); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 82 | mIcon = icon; |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 83 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( |
| 84 | ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| 85 | params.setMargins(0, padding, 0, padding); |
Jason Monk | f13413e | 2017-02-15 15:49:32 -0500 | [diff] [blame] | 86 | mIconFrame.addView(mIcon, params); |
Rohan Shah | 28191fc | 2018-01-16 14:28:55 -0800 | [diff] [blame] | 87 | mIconFrame.setClipChildren(false); |
| 88 | mIconFrame.setClipToPadding(false); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 89 | |
| 90 | mTileBackground = newTileBackground(); |
| 91 | if (mTileBackground instanceof RippleDrawable) { |
| 92 | setRipple((RippleDrawable) mTileBackground); |
| 93 | } |
| 94 | setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); |
| 95 | setBackground(mTileBackground); |
| 96 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 97 | mColorActive = Utils.getColorAttr(context, android.R.attr.colorAccent); |
| 98 | mColorDisabled = Utils.getDisabled(context, |
| 99 | Utils.getColorAttr(context, android.R.attr.textColorTertiary)); |
| 100 | mColorInactive = Utils.getColorAttr(context, android.R.attr.textColorSecondary); |
| 101 | |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 102 | setPadding(0, 0, 0, 0); |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 103 | setClipChildren(false); |
| 104 | setClipToPadding(false); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 105 | mCollapsedView = collapsedView; |
Min Yun | f07f170 | 2016-06-27 13:55:15 -0700 | [diff] [blame] | 106 | setFocusable(true); |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 107 | } |
| 108 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 109 | public View getBgCicle() { |
| 110 | return mBg; |
| 111 | } |
| 112 | |
Jiaquan He | 074ae46 | 2016-05-13 08:56:19 -0700 | [diff] [blame] | 113 | protected Drawable newTileBackground() { |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 114 | final int[] attrs = new int[]{android.R.attr.selectableItemBackgroundBorderless}; |
| 115 | final TypedArray ta = getContext().obtainStyledAttributes(attrs); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 116 | final Drawable d = ta.getDrawable(0); |
| 117 | ta.recycle(); |
| 118 | return d; |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 119 | } |
| 120 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 121 | private void setRipple(RippleDrawable tileBackground) { |
| 122 | mRipple = tileBackground; |
| 123 | if (getWidth() != 0) { |
Amin Shaikh | 3033099 | 2018-03-26 17:50:42 -0400 | [diff] [blame] | 124 | updateRippleSize(); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
Amin Shaikh | 3033099 | 2018-03-26 17:50:42 -0400 | [diff] [blame] | 128 | private void updateRippleSize() { |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 129 | // center the touch feedback on the center of the icon, and dial it down a bit |
Amin Shaikh | 3033099 | 2018-03-26 17:50:42 -0400 | [diff] [blame] | 130 | final int cx = mIconFrame.getMeasuredWidth() / 2 + mIconFrame.getLeft(); |
| 131 | final int cy = mIconFrame.getMeasuredHeight() / 2 + mIconFrame.getTop(); |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 132 | final int rad = (int) (mIcon.getHeight() * .85f); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 133 | mRipple.setHotspotBounds(cx - rad, cy - rad, cx + rad, cy + rad); |
| 134 | } |
| 135 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 136 | @Override |
| 137 | public void init(QSTile tile) { |
| 138 | init(v -> tile.click(), v -> tile.secondaryClick(), view -> { |
| 139 | tile.longClick(); |
| 140 | return true; |
| 141 | }); |
| 142 | } |
| 143 | |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 144 | public void init(OnClickListener click, OnClickListener secondaryClick, |
| 145 | OnLongClickListener longClick) { |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 146 | setOnClickListener(click); |
Jason Monk | 76c67aa | 2016-02-19 14:49:42 -0500 | [diff] [blame] | 147 | setOnLongClickListener(longClick); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | @Override |
| 151 | protected void onLayout(boolean changed, int l, int t, int r, int b) { |
| 152 | super.onLayout(changed, l, t, r, b); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 153 | if (mRipple != null) { |
Amin Shaikh | 3033099 | 2018-03-26 17:50:42 -0400 | [diff] [blame] | 154 | updateRippleSize(); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | |
Jorim Jaggi | c308117 | 2016-04-08 23:56:37 -0700 | [diff] [blame] | 158 | @Override |
| 159 | public boolean hasOverlappingRendering() { |
| 160 | // Avoid layers for this layout - we don't need them. |
| 161 | return false; |
| 162 | } |
| 163 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 164 | /** |
| 165 | * Update the accessibility order for this view. |
| 166 | * |
| 167 | * @param previousView the view which should be before this one |
| 168 | * @return the last view in this view which is accessible |
| 169 | */ |
| 170 | public View updateAccessibilityOrder(View previousView) { |
| 171 | setAccessibilityTraversalAfter(previousView.getId()); |
| 172 | return this; |
| 173 | } |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 174 | |
| 175 | public void onStateChanged(QSTile.State state) { |
| 176 | mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget(); |
| 177 | } |
| 178 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 179 | protected void handleStateChanged(QSTile.State state) { |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 180 | int circleColor = getCircleColor(state.state); |
| 181 | if (circleColor != mCircleColor) { |
Amin Shaikh | 5df1a75 | 2018-04-03 13:39:53 -0400 | [diff] [blame] | 182 | if (mBg.isShown() && animationsEnabled()) { |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 183 | ValueAnimator animator = ValueAnimator.ofArgb(mCircleColor, circleColor) |
| 184 | .setDuration(QS_ANIM_LENGTH); |
| 185 | animator.addUpdateListener(animation -> mBg.setImageTintList(ColorStateList.valueOf( |
| 186 | (Integer) animation.getAnimatedValue()))); |
| 187 | animator.start(); |
| 188 | } else { |
| 189 | QSIconViewImpl.setTint(mBg, circleColor); |
| 190 | } |
| 191 | mCircleColor = circleColor; |
| 192 | } |
| 193 | |
Jason Monk | e2f05d2 | 2017-03-23 10:45:37 -0400 | [diff] [blame] | 194 | setClickable(state.state != Tile.STATE_UNAVAILABLE); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 195 | mIcon.setIcon(state); |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 196 | setContentDescription(state.contentDescription); |
Rohan Shah | 185f661 | 2018-03-29 17:35:00 -0700 | [diff] [blame] | 197 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 198 | mAccessibilityClass = state.expandedAccessibilityClassName; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 199 | if (state instanceof QSTile.BooleanState) { |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 200 | boolean newState = ((BooleanState) state).value; |
| 201 | if (mTileState != newState) { |
| 202 | mClicked = false; |
| 203 | mTileState = newState; |
| 204 | } |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 205 | } |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 206 | } |
| 207 | |
Amin Shaikh | 5df1a75 | 2018-04-03 13:39:53 -0400 | [diff] [blame] | 208 | protected boolean animationsEnabled() { |
| 209 | return true; |
| 210 | } |
| 211 | |
Jason Monk | cb2307c | 2018-01-15 14:19:45 -0500 | [diff] [blame] | 212 | private int getCircleColor(int state) { |
| 213 | switch (state) { |
| 214 | case Tile.STATE_ACTIVE: |
| 215 | return mColorActive; |
| 216 | case Tile.STATE_INACTIVE: |
| 217 | case Tile.STATE_UNAVAILABLE: |
| 218 | return mColorDisabled; |
| 219 | default: |
| 220 | Log.e(TAG, "Invalid state " + state); |
| 221 | return 0; |
| 222 | } |
| 223 | } |
| 224 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 225 | @Override |
Jason Monk | e2f05d2 | 2017-03-23 10:45:37 -0400 | [diff] [blame] | 226 | public void setClickable(boolean clickable) { |
| 227 | super.setClickable(clickable); |
| 228 | setBackground(clickable ? mRipple : null); |
| 229 | } |
| 230 | |
| 231 | @Override |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 232 | public int getDetailY() { |
| 233 | return getTop() + getHeight() / 2; |
| 234 | } |
| 235 | |
Jason Monk | 1aec93f | 2016-03-01 09:39:30 -0500 | [diff] [blame] | 236 | public QSIconView getIcon() { |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 237 | return mIcon; |
| 238 | } |
| 239 | |
Rohan Shah | a840199 | 2018-01-25 18:22:44 -0800 | [diff] [blame] | 240 | public View getIconWithBackground() { |
| 241 | return mIconFrame; |
| 242 | } |
| 243 | |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 244 | @Override |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 245 | public boolean performClick() { |
| 246 | mClicked = true; |
| 247 | return super.performClick(); |
| 248 | } |
| 249 | |
| 250 | @Override |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 251 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { |
| 252 | super.onInitializeAccessibilityEvent(event); |
| 253 | if (!TextUtils.isEmpty(mAccessibilityClass)) { |
| 254 | event.setClassName(mAccessibilityClass); |
| 255 | if (Switch.class.getName().equals(mAccessibilityClass)) { |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 256 | boolean b = mClicked ? !mTileState : mTileState; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 257 | String label = getResources() |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 258 | .getString(b ? R.string.switch_bar_on : R.string.switch_bar_off); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 259 | event.setContentDescription(label); |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 260 | event.setChecked(b); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | @Override |
| 266 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { |
| 267 | super.onInitializeAccessibilityNodeInfo(info); |
Amin Shaikh | 34044ac | 2018-06-12 18:25:43 -0400 | [diff] [blame] | 268 | // Clear selected state so it is not announce by talkback. |
| 269 | info.setSelected(false); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 270 | if (!TextUtils.isEmpty(mAccessibilityClass)) { |
| 271 | info.setClassName(mAccessibilityClass); |
| 272 | if (Switch.class.getName().equals(mAccessibilityClass)) { |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 273 | boolean b = mClicked ? !mTileState : mTileState; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 274 | String label = getResources() |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 275 | .getString(b ? R.string.switch_bar_on : R.string.switch_bar_off); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 276 | info.setText(label); |
Jason Monk | 90950d9 | 2017-06-20 13:16:05 -0400 | [diff] [blame] | 277 | info.setChecked(b); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 278 | info.setCheckable(true); |
Rohan Shah | 185f661 | 2018-03-29 17:35:00 -0700 | [diff] [blame] | 279 | info.addAction( |
| 280 | new AccessibilityNodeInfo.AccessibilityAction( |
| 281 | AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK.getId(), |
| 282 | getResources().getString(R.string.accessibility_long_click_tile))); |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
Jason Monk | c133d26 | 2015-10-27 12:32:45 -0400 | [diff] [blame] | 287 | private class H extends Handler { |
| 288 | private static final int STATE_CHANGED = 1; |
| 289 | public H() { |
| 290 | super(Looper.getMainLooper()); |
| 291 | } |
| 292 | |
| 293 | @Override |
| 294 | public void handleMessage(Message msg) { |
| 295 | if (msg.what == STATE_CHANGED) { |
| 296 | handleStateChanged((QSTile.State) msg.obj); |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | } |