Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 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 |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.statusbar.phone; |
| 16 | |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 17 | import android.annotation.Nullable; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 18 | import android.content.Context; |
| 19 | import android.content.res.Configuration; |
| 20 | import android.content.res.Resources; |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 21 | import android.graphics.drawable.Icon; |
| 22 | import android.net.Uri; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 23 | import android.util.AttributeSet; |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 24 | import android.util.Log; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 25 | import android.util.SparseArray; |
| 26 | import android.view.LayoutInflater; |
| 27 | import android.view.View; |
| 28 | import android.view.ViewGroup; |
| 29 | import android.widget.FrameLayout; |
| 30 | import android.widget.ImageView; |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 31 | import android.widget.LinearLayout; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 32 | import android.widget.Space; |
| 33 | import com.android.systemui.R; |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 34 | import com.android.systemui.statusbar.policy.KeyButtonView; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 35 | import com.android.systemui.tuner.TunerService; |
| 36 | |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 37 | import java.io.File; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 38 | import java.util.Objects; |
| 39 | |
| 40 | public class NavigationBarInflaterView extends FrameLayout implements TunerService.Tunable { |
| 41 | |
| 42 | private static final String TAG = "NavBarInflater"; |
| 43 | |
| 44 | public static final String NAV_BAR_VIEWS = "sysui_nav_bar"; |
| 45 | |
Jason Monk | 3ebd239 | 2016-01-22 10:01:44 -0500 | [diff] [blame] | 46 | public static final String MENU_IME = "menu_ime"; |
| 47 | public static final String BACK = "back"; |
| 48 | public static final String HOME = "home"; |
| 49 | public static final String RECENT = "recent"; |
| 50 | public static final String NAVSPACE = "space"; |
Jason Monk | 3b58714 | 2016-01-23 16:47:59 -0500 | [diff] [blame] | 51 | public static final String CLIPBOARD = "clipboard"; |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 52 | public static final String KEY = "key"; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 53 | |
| 54 | public static final String GRAVITY_SEPARATOR = ";"; |
| 55 | public static final String BUTTON_SEPARATOR = ","; |
| 56 | |
Jason Monk | 46a196e | 2016-01-23 15:28:10 -0500 | [diff] [blame] | 57 | public static final String SIZE_MOD_START = "["; |
| 58 | public static final String SIZE_MOD_END = "]"; |
| 59 | |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 60 | public static final String KEY_CODE_START = "("; |
| 61 | public static final String KEY_IMAGE_DELIM = ":"; |
| 62 | public static final String KEY_CODE_END = ")"; |
| 63 | |
| 64 | protected final LayoutInflater mLayoutInflater; |
| 65 | protected final LayoutInflater mLandscapeInflater; |
| 66 | |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 67 | protected FrameLayout mRot0; |
| 68 | protected FrameLayout mRot90; |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 69 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 70 | private SparseArray<ButtonDispatcher> mButtonDispatchers; |
| 71 | private String mCurrentLayout; |
| 72 | |
| 73 | public NavigationBarInflaterView(Context context, AttributeSet attrs) { |
| 74 | super(context, attrs); |
| 75 | mLayoutInflater = LayoutInflater.from(context); |
| 76 | Configuration landscape = new Configuration(); |
| 77 | landscape.setTo(context.getResources().getConfiguration()); |
| 78 | landscape.orientation = Configuration.ORIENTATION_LANDSCAPE; |
| 79 | mLandscapeInflater = LayoutInflater.from(context.createConfigurationContext(landscape)); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | protected void onFinishInflate() { |
| 84 | super.onFinishInflate(); |
| 85 | mRot0 = (FrameLayout) findViewById(R.id.rot0); |
| 86 | mRot90 = (FrameLayout) findViewById(R.id.rot90); |
| 87 | clearViews(); |
| 88 | inflateLayout(getDefaultLayout()); |
| 89 | } |
| 90 | |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 91 | protected String getDefaultLayout() { |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 92 | return mContext.getString(R.string.config_navBarLayout); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | protected void onAttachedToWindow() { |
| 97 | super.onAttachedToWindow(); |
| 98 | TunerService.get(getContext()).addTunable(this, NAV_BAR_VIEWS); |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | protected void onDetachedFromWindow() { |
| 103 | TunerService.get(getContext()).removeTunable(this); |
| 104 | super.onDetachedFromWindow(); |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public void onTuningChanged(String key, String newValue) { |
| 109 | if (NAV_BAR_VIEWS.equals(key)) { |
| 110 | if (newValue == null) { |
| 111 | newValue = getDefaultLayout(); |
| 112 | } |
| 113 | if (!Objects.equals(mCurrentLayout, newValue)) { |
| 114 | clearViews(); |
| 115 | inflateLayout(newValue); |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | public void setButtonDispatchers(SparseArray<ButtonDispatcher> buttonDisatchers) { |
| 121 | mButtonDispatchers = buttonDisatchers; |
| 122 | for (int i = 0; i < buttonDisatchers.size(); i++) { |
| 123 | initiallyFill(buttonDisatchers.valueAt(i)); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | private void initiallyFill(ButtonDispatcher buttonDispatcher) { |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 128 | addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.ends_group)); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 129 | addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.center_group)); |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 130 | addAll(buttonDispatcher, (ViewGroup) mRot90.findViewById(R.id.ends_group)); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 131 | addAll(buttonDispatcher, (ViewGroup) mRot90.findViewById(R.id.center_group)); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | private void addAll(ButtonDispatcher buttonDispatcher, ViewGroup parent) { |
| 135 | for (int i = 0; i < parent.getChildCount(); i++) { |
| 136 | // Need to manually search for each id, just in case each group has more than one |
| 137 | // of a single id. It probably mostly a waste of time, but shouldn't take long |
| 138 | // and will only happen once. |
| 139 | if (parent.getChildAt(i).getId() == buttonDispatcher.getId()) { |
| 140 | buttonDispatcher.addView(parent.getChildAt(i)); |
| 141 | } else if (parent.getChildAt(i) instanceof ViewGroup) { |
| 142 | addAll(buttonDispatcher, (ViewGroup) parent.getChildAt(i)); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 147 | protected void inflateLayout(String newLayout) { |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 148 | mCurrentLayout = newLayout; |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 149 | String[] sets = newLayout.split(GRAVITY_SEPARATOR, 3); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 150 | String[] start = sets[0].split(BUTTON_SEPARATOR); |
| 151 | String[] center = sets[1].split(BUTTON_SEPARATOR); |
| 152 | String[] end = sets[2].split(BUTTON_SEPARATOR); |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 153 | inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group), |
| 154 | (ViewGroup) mRot0.findViewById(R.id.ends_group_lightsout), false); |
| 155 | inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group), |
| 156 | (ViewGroup) mRot90.findViewById(R.id.ends_group_lightsout), true); |
| 157 | |
Xiaohui Chen | 0691703 | 2016-01-26 11:20:39 -0800 | [diff] [blame] | 158 | inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group), |
| 159 | (ViewGroup) mRot0.findViewById(R.id.center_group_lightsout), false); |
| 160 | inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group), |
| 161 | (ViewGroup) mRot90.findViewById(R.id.center_group_lightsout), true); |
| 162 | |
| 163 | addGravitySpacer((LinearLayout) mRot0.findViewById(R.id.ends_group)); |
| 164 | addGravitySpacer((LinearLayout) mRot90.findViewById(R.id.ends_group)); |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 165 | |
| 166 | inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group), |
| 167 | (ViewGroup) mRot0.findViewById(R.id.ends_group_lightsout), false); |
| 168 | inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group), |
| 169 | (ViewGroup) mRot90.findViewById(R.id.ends_group_lightsout), true); |
| 170 | } |
| 171 | |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 172 | private void addGravitySpacer(LinearLayout layout) { |
| 173 | layout.addView(new Space(mContext), new LinearLayout.LayoutParams(0, 0, 1)); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | private void inflateButtons(String[] buttons, ViewGroup parent, ViewGroup lightsOutParent, |
| 177 | boolean landscape) { |
| 178 | for (int i = 0; i < buttons.length; i++) { |
| 179 | copyToLightsout(inflateButton(buttons[i], parent, landscape), lightsOutParent); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | private void copyToLightsout(View view, ViewGroup lightsOutParent) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 184 | if (view == null) return; |
| 185 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 186 | if (view instanceof FrameLayout) { |
| 187 | // The only ViewGroup we support in here is a FrameLayout, so copy those manually. |
| 188 | FrameLayout original = (FrameLayout) view; |
| 189 | FrameLayout layout = new FrameLayout(view.getContext()); |
| 190 | for (int i = 0; i < original.getChildCount(); i++) { |
| 191 | copyToLightsout(original.getChildAt(i), layout); |
| 192 | } |
| 193 | lightsOutParent.addView(layout, copy(view.getLayoutParams())); |
| 194 | } else if (view instanceof Space) { |
| 195 | lightsOutParent.addView(new Space(view.getContext()), copy(view.getLayoutParams())); |
| 196 | } else { |
| 197 | lightsOutParent.addView(generateLightsOutView(view), copy(view.getLayoutParams())); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | private View generateLightsOutView(View view) { |
| 202 | ImageView imageView = new ImageView(view.getContext()); |
| 203 | // Copy everything we can about the original view. |
| 204 | imageView.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), |
| 205 | view.getPaddingBottom()); |
| 206 | imageView.setContentDescription(view.getContentDescription()); |
| 207 | imageView.setId(view.getId()); |
| 208 | // Only home gets a big dot, everything else will be little. |
| 209 | imageView.setImageResource(view.getId() == R.id.home |
| 210 | ? R.drawable.ic_sysbar_lights_out_dot_large |
| 211 | : R.drawable.ic_sysbar_lights_out_dot_small); |
| 212 | return imageView; |
| 213 | } |
| 214 | |
| 215 | private ViewGroup.LayoutParams copy(ViewGroup.LayoutParams layoutParams) { |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 216 | if (layoutParams instanceof LinearLayout.LayoutParams) { |
| 217 | return new LinearLayout.LayoutParams(layoutParams.width, layoutParams.height, |
| 218 | ((LinearLayout.LayoutParams) layoutParams).weight); |
| 219 | } |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 220 | return new LayoutParams(layoutParams.width, layoutParams.height); |
| 221 | } |
| 222 | |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 223 | @Nullable |
Jason Monk | 46a196e | 2016-01-23 15:28:10 -0500 | [diff] [blame] | 224 | protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 225 | LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater; |
Jason Monk | 46a196e | 2016-01-23 15:28:10 -0500 | [diff] [blame] | 226 | float size = extractSize(buttonSpec); |
| 227 | String button = extractButton(buttonSpec); |
| 228 | View v = null; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 229 | if (HOME.equals(button)) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 230 | v = inflater.inflate(R.layout.home, parent, false); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 231 | if (landscape && isSw600Dp()) { |
| 232 | setupLandButton(v); |
| 233 | } |
| 234 | } else if (BACK.equals(button)) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 235 | v = inflater.inflate(R.layout.back, parent, false); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 236 | if (landscape && isSw600Dp()) { |
| 237 | setupLandButton(v); |
| 238 | } |
| 239 | } else if (RECENT.equals(button)) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 240 | v = inflater.inflate(R.layout.recent_apps, parent, false); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 241 | if (landscape && isSw600Dp()) { |
| 242 | setupLandButton(v); |
| 243 | } |
| 244 | } else if (MENU_IME.equals(button)) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 245 | v = inflater.inflate(R.layout.menu_ime, parent, false); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 246 | } else if (NAVSPACE.equals(button)) { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 247 | v = inflater.inflate(R.layout.nav_key_space, parent, false); |
Jason Monk | 3b58714 | 2016-01-23 16:47:59 -0500 | [diff] [blame] | 248 | } else if (CLIPBOARD.equals(button)) { |
| 249 | v = inflater.inflate(R.layout.clipboard, parent, false); |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 250 | } else if (button.startsWith(KEY)) { |
| 251 | String uri = extractImage(button); |
| 252 | int code = extractKeycode(button); |
| 253 | v = inflater.inflate(R.layout.custom_key, parent, false); |
| 254 | ((KeyButtonView) v).setCode(code); |
| 255 | if (uri != null) { |
| 256 | ((KeyButtonView) v).loadAsync(uri); |
| 257 | } |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 258 | } else { |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 259 | return null; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 260 | } |
Xiaohui Chen | 5481600 | 2016-01-25 11:11:11 -0800 | [diff] [blame] | 261 | |
Jason Monk | 46a196e | 2016-01-23 15:28:10 -0500 | [diff] [blame] | 262 | if (size != 0) { |
| 263 | ViewGroup.LayoutParams params = v.getLayoutParams(); |
| 264 | params.width = (int) (params.width * size); |
| 265 | } |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 266 | parent.addView(v); |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 267 | addToDispatchers(v); |
| 268 | return v; |
| 269 | } |
| 270 | |
Jason Monk | 8457ad8 | 2016-01-24 10:15:55 -0500 | [diff] [blame^] | 271 | public static String extractImage(String buttonSpec) { |
| 272 | if (!buttonSpec.contains(KEY_IMAGE_DELIM)) { |
| 273 | return null; |
| 274 | } |
| 275 | final int start = buttonSpec.indexOf(KEY_IMAGE_DELIM); |
| 276 | String subStr = buttonSpec.substring(start + 1, buttonSpec.indexOf(KEY_CODE_END)); |
| 277 | return subStr; |
| 278 | } |
| 279 | |
| 280 | public static int extractKeycode(String buttonSpec) { |
| 281 | if (!buttonSpec.contains(KEY_CODE_START)) { |
| 282 | return 1; |
| 283 | } |
| 284 | final int start = buttonSpec.indexOf(KEY_CODE_START); |
| 285 | String subStr = buttonSpec.substring(start + 1, buttonSpec.indexOf(KEY_IMAGE_DELIM)); |
| 286 | return Integer.parseInt(subStr); |
| 287 | } |
| 288 | |
Jason Monk | 46a196e | 2016-01-23 15:28:10 -0500 | [diff] [blame] | 289 | public static float extractSize(String buttonSpec) { |
| 290 | if (!buttonSpec.contains(SIZE_MOD_START)) { |
| 291 | return 1; |
| 292 | } |
| 293 | final int sizeStart = buttonSpec.indexOf(SIZE_MOD_START); |
| 294 | String sizeStr = buttonSpec.substring(sizeStart + 1, buttonSpec.indexOf(SIZE_MOD_END)); |
| 295 | return Float.parseFloat(sizeStr); |
| 296 | } |
| 297 | |
| 298 | public static String extractButton(String buttonSpec) { |
| 299 | if (!buttonSpec.contains(SIZE_MOD_START)) { |
| 300 | return buttonSpec; |
| 301 | } |
| 302 | return buttonSpec.substring(0, buttonSpec.indexOf(SIZE_MOD_START)); |
| 303 | } |
| 304 | |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 305 | private void addToDispatchers(View v) { |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 306 | if (mButtonDispatchers != null) { |
| 307 | final int indexOfKey = mButtonDispatchers.indexOfKey(v.getId()); |
| 308 | if (indexOfKey >= 0) { |
| 309 | mButtonDispatchers.valueAt(indexOfKey).addView(v); |
| 310 | } |
| 311 | } |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | private boolean isSw600Dp() { |
| 315 | Configuration configuration = mContext.getResources().getConfiguration(); |
| 316 | return (configuration.smallestScreenWidthDp >= 600); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * This manually sets the width of sw600dp landscape buttons because despite |
| 321 | * overriding the configuration from the overridden resources aren't loaded currently. |
| 322 | */ |
| 323 | private void setupLandButton(View v) { |
| 324 | Resources res = mContext.getResources(); |
| 325 | v.getLayoutParams().width = res.getDimensionPixelOffset( |
| 326 | R.dimen.navigation_key_width_sw600dp_land); |
| 327 | int padding = res.getDimensionPixelOffset(R.dimen.navigation_key_padding_sw600dp_land); |
| 328 | v.setPadding(padding, v.getPaddingTop(), padding, v.getPaddingBottom()); |
| 329 | } |
| 330 | |
| 331 | private void clearViews() { |
| 332 | if (mButtonDispatchers != null) { |
| 333 | for (int i = 0; i < mButtonDispatchers.size(); i++) { |
| 334 | mButtonDispatchers.valueAt(i).clear(); |
| 335 | } |
| 336 | } |
| 337 | clearAllChildren((ViewGroup) mRot0.findViewById(R.id.nav_buttons)); |
| 338 | clearAllChildren((ViewGroup) mRot0.findViewById(R.id.lights_out)); |
| 339 | clearAllChildren((ViewGroup) mRot90.findViewById(R.id.nav_buttons)); |
| 340 | clearAllChildren((ViewGroup) mRot90.findViewById(R.id.lights_out)); |
| 341 | } |
| 342 | |
| 343 | private void clearAllChildren(ViewGroup group) { |
| 344 | for (int i = 0; i < group.getChildCount(); i++) { |
| 345 | ((ViewGroup) group.getChildAt(i)).removeAllViews(); |
| 346 | } |
| 347 | } |
| 348 | } |