blob: 9b4867ec7c9eb1aa4ec8513991ba3ef3f3a7752d [file] [log] [blame]
Jason Monka2081822016-01-18 14:41:03 -05001/*
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
15package com.android.systemui.statusbar.phone;
16
Xiaohui Chen54816002016-01-25 11:11:11 -080017import android.annotation.Nullable;
Jason Monka2081822016-01-18 14:41:03 -050018import android.content.Context;
19import android.content.res.Configuration;
Jason Monkea05f872017-01-24 19:43:36 -050020import android.graphics.drawable.Icon;
Jason Monka2081822016-01-18 14:41:03 -050021import android.util.AttributeSet;
22import android.util.SparseArray;
Xiaohui Chen40e978e2016-11-29 15:10:04 -080023import android.view.Display;
24import android.view.Display.Mode;
Jason Monka2081822016-01-18 14:41:03 -050025import android.view.LayoutInflater;
26import android.view.View;
27import android.view.ViewGroup;
Xiaohui Chen40e978e2016-11-29 15:10:04 -080028import android.view.WindowManager;
Jason Monka2081822016-01-18 14:41:03 -050029import android.widget.FrameLayout;
Jason Monk4f878ef2016-01-23 14:37:38 -050030import android.widget.LinearLayout;
Jason Monka2081822016-01-18 14:41:03 -050031import android.widget.Space;
Annie Chin1ea49352016-05-27 15:23:35 -070032
Jason Monka2081822016-01-18 14:41:03 -050033import com.android.systemui.R;
Jason Monk197f4db2016-08-26 13:28:20 -040034import com.android.systemui.plugins.PluginListener;
35import com.android.systemui.plugins.PluginManager;
36import com.android.systemui.plugins.statusbar.phone.NavBarButtonProvider;
Jason Monk8457ad82016-01-24 10:15:55 -050037import com.android.systemui.statusbar.policy.KeyButtonView;
Jason Monka2081822016-01-18 14:41:03 -050038import com.android.systemui.tuner.TunerService;
Jason Monk197f4db2016-08-26 13:28:20 -040039import com.android.systemui.tuner.TunerService.Tunable;
Jason Monka2081822016-01-18 14:41:03 -050040
Jason Monk197f4db2016-08-26 13:28:20 -040041import java.util.ArrayList;
42import java.util.List;
Jason Monka2081822016-01-18 14:41:03 -050043import java.util.Objects;
44
Jason Monk197f4db2016-08-26 13:28:20 -040045public class NavigationBarInflaterView extends FrameLayout
46 implements Tunable, PluginListener<NavBarButtonProvider> {
Jason Monka2081822016-01-18 14:41:03 -050047
48 private static final String TAG = "NavBarInflater";
49
50 public static final String NAV_BAR_VIEWS = "sysui_nav_bar";
Jason Monkea05f872017-01-24 19:43:36 -050051 public static final String NAV_BAR_LEFT = "sysui_nav_bar_left";
52 public static final String NAV_BAR_RIGHT = "sysui_nav_bar_right";
Jason Monka2081822016-01-18 14:41:03 -050053
Jason Monk3ebd2392016-01-22 10:01:44 -050054 public static final String MENU_IME = "menu_ime";
55 public static final String BACK = "back";
56 public static final String HOME = "home";
57 public static final String RECENT = "recent";
58 public static final String NAVSPACE = "space";
Jason Monk3b587142016-01-23 16:47:59 -050059 public static final String CLIPBOARD = "clipboard";
Jason Monk8457ad82016-01-24 10:15:55 -050060 public static final String KEY = "key";
Jason Monkea05f872017-01-24 19:43:36 -050061 public static final String LEFT = "left";
62 public static final String RIGHT = "right";
Jason Monka2081822016-01-18 14:41:03 -050063
64 public static final String GRAVITY_SEPARATOR = ";";
65 public static final String BUTTON_SEPARATOR = ",";
66
Jason Monk46a196e2016-01-23 15:28:10 -050067 public static final String SIZE_MOD_START = "[";
68 public static final String SIZE_MOD_END = "]";
69
Jason Monk8457ad82016-01-24 10:15:55 -050070 public static final String KEY_CODE_START = "(";
71 public static final String KEY_IMAGE_DELIM = ":";
72 public static final String KEY_CODE_END = ")";
73
Jason Monk197f4db2016-08-26 13:28:20 -040074 private final List<NavBarButtonProvider> mPlugins = new ArrayList<>();
75
Jason Monk67a1cce2016-02-05 13:31:03 -050076 protected LayoutInflater mLayoutInflater;
77 protected LayoutInflater mLandscapeInflater;
Jason Monk8457ad82016-01-24 10:15:55 -050078
Xiaohui Chen54816002016-01-25 11:11:11 -080079 protected FrameLayout mRot0;
80 protected FrameLayout mRot90;
Xiaohui Chen40e978e2016-11-29 15:10:04 -080081 private boolean isRot0Landscape;
Jason Monk8457ad82016-01-24 10:15:55 -050082
Jason Monka2081822016-01-18 14:41:03 -050083 private SparseArray<ButtonDispatcher> mButtonDispatchers;
84 private String mCurrentLayout;
85
Xiaohui Chen40e978e2016-11-29 15:10:04 -080086 private View mLastPortrait;
87 private View mLastLandscape;
Jason Monkc62cf802016-05-10 11:02:24 -040088
Adrian Roosdb12b152016-07-12 15:38:55 -070089 private boolean mAlternativeOrder;
90
Jason Monka2081822016-01-18 14:41:03 -050091 public NavigationBarInflaterView(Context context, AttributeSet attrs) {
92 super(context, attrs);
Jason Monk67a1cce2016-02-05 13:31:03 -050093 createInflaters();
Xiaohui Chen40e978e2016-11-29 15:10:04 -080094 Display display = ((WindowManager)
95 context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
96 Mode displayMode = display.getMode();
97 isRot0Landscape = displayMode.getPhysicalWidth() > displayMode.getPhysicalHeight();
Jason Monk67a1cce2016-02-05 13:31:03 -050098 }
99
100 private void createInflaters() {
101 mLayoutInflater = LayoutInflater.from(mContext);
Jason Monka2081822016-01-18 14:41:03 -0500102 Configuration landscape = new Configuration();
Jason Monk67a1cce2016-02-05 13:31:03 -0500103 landscape.setTo(mContext.getResources().getConfiguration());
Jason Monka2081822016-01-18 14:41:03 -0500104 landscape.orientation = Configuration.ORIENTATION_LANDSCAPE;
Jason Monk67a1cce2016-02-05 13:31:03 -0500105 mLandscapeInflater = LayoutInflater.from(mContext.createConfigurationContext(landscape));
106 }
107
108 @Override
Jason Monka2081822016-01-18 14:41:03 -0500109 protected void onFinishInflate() {
110 super.onFinishInflate();
Jason Monk9a6552d2016-05-20 11:21:59 -0400111 inflateChildren();
Jason Monka2081822016-01-18 14:41:03 -0500112 clearViews();
113 inflateLayout(getDefaultLayout());
114 }
115
Jason Monk9a6552d2016-05-20 11:21:59 -0400116 private void inflateChildren() {
117 removeAllViews();
118 mRot0 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout, this, false);
119 mRot0.setId(R.id.rot0);
120 addView(mRot0);
121 mRot90 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout_rot90, this,
122 false);
123 mRot90.setId(R.id.rot90);
124 addView(mRot90);
Adrian Roosdb12b152016-07-12 15:38:55 -0700125 updateAlternativeOrder();
Jason Monk9a6552d2016-05-20 11:21:59 -0400126 if (getParent() instanceof NavigationBarView) {
127 ((NavigationBarView) getParent()).updateRotatedViews();
128 }
129 }
130
Xiaohui Chen54816002016-01-25 11:11:11 -0800131 protected String getDefaultLayout() {
Jason Monka2081822016-01-18 14:41:03 -0500132 return mContext.getString(R.string.config_navBarLayout);
133 }
134
135 @Override
136 protected void onAttachedToWindow() {
137 super.onAttachedToWindow();
Jason Monkea05f872017-01-24 19:43:36 -0500138 TunerService.get(getContext()).addTunable(this, NAV_BAR_VIEWS, NAV_BAR_LEFT,
139 NAV_BAR_RIGHT);
Jason Monk197f4db2016-08-26 13:28:20 -0400140 PluginManager.getInstance(getContext()).addPluginListener(NavBarButtonProvider.ACTION, this,
141 NavBarButtonProvider.VERSION, true /* Allow multiple */);
Jason Monka2081822016-01-18 14:41:03 -0500142 }
143
144 @Override
145 protected void onDetachedFromWindow() {
146 TunerService.get(getContext()).removeTunable(this);
147 super.onDetachedFromWindow();
148 }
149
150 @Override
151 public void onTuningChanged(String key, String newValue) {
152 if (NAV_BAR_VIEWS.equals(key)) {
Jason Monka2081822016-01-18 14:41:03 -0500153 if (!Objects.equals(mCurrentLayout, newValue)) {
154 clearViews();
155 inflateLayout(newValue);
156 }
Jason Monkea05f872017-01-24 19:43:36 -0500157 } else if (NAV_BAR_LEFT.equals(key) || NAV_BAR_RIGHT.equals(key)) {
158 clearViews();
159 inflateLayout(mCurrentLayout);
Jason Monka2081822016-01-18 14:41:03 -0500160 }
161 }
162
163 public void setButtonDispatchers(SparseArray<ButtonDispatcher> buttonDisatchers) {
164 mButtonDispatchers = buttonDisatchers;
165 for (int i = 0; i < buttonDisatchers.size(); i++) {
166 initiallyFill(buttonDisatchers.valueAt(i));
167 }
168 }
169
Adrian Roosdb12b152016-07-12 15:38:55 -0700170 public void setAlternativeOrder(boolean alternativeOrder) {
171 if (alternativeOrder != mAlternativeOrder) {
172 mAlternativeOrder = alternativeOrder;
173 updateAlternativeOrder();
174 }
175 }
176
177 private void updateAlternativeOrder() {
178 updateAlternativeOrder(mRot0.findViewById(R.id.ends_group));
179 updateAlternativeOrder(mRot0.findViewById(R.id.center_group));
180 updateAlternativeOrder(mRot90.findViewById(R.id.ends_group));
181 updateAlternativeOrder(mRot90.findViewById(R.id.center_group));
182 }
183
184 private void updateAlternativeOrder(View v) {
185 if (v instanceof ReverseLinearLayout) {
186 ((ReverseLinearLayout) v).setAlternativeOrder(mAlternativeOrder);
187 }
188 }
189
Jason Monka2081822016-01-18 14:41:03 -0500190 private void initiallyFill(ButtonDispatcher buttonDispatcher) {
Jason Monk4f878ef2016-01-23 14:37:38 -0500191 addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.ends_group));
Jason Monka2081822016-01-18 14:41:03 -0500192 addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.center_group));
Jason Monk4f878ef2016-01-23 14:37:38 -0500193 addAll(buttonDispatcher, (ViewGroup) mRot90.findViewById(R.id.ends_group));
Jason Monka2081822016-01-18 14:41:03 -0500194 addAll(buttonDispatcher, (ViewGroup) mRot90.findViewById(R.id.center_group));
Jason Monka2081822016-01-18 14:41:03 -0500195 }
196
197 private void addAll(ButtonDispatcher buttonDispatcher, ViewGroup parent) {
198 for (int i = 0; i < parent.getChildCount(); i++) {
199 // Need to manually search for each id, just in case each group has more than one
200 // of a single id. It probably mostly a waste of time, but shouldn't take long
201 // and will only happen once.
202 if (parent.getChildAt(i).getId() == buttonDispatcher.getId()) {
203 buttonDispatcher.addView(parent.getChildAt(i));
204 } else if (parent.getChildAt(i) instanceof ViewGroup) {
205 addAll(buttonDispatcher, (ViewGroup) parent.getChildAt(i));
206 }
207 }
208 }
209
Xiaohui Chen54816002016-01-25 11:11:11 -0800210 protected void inflateLayout(String newLayout) {
Jason Monka2081822016-01-18 14:41:03 -0500211 mCurrentLayout = newLayout;
Jason Monk9a6552d2016-05-20 11:21:59 -0400212 if (newLayout == null) {
213 newLayout = getDefaultLayout();
214 }
Xiaohui Chen54816002016-01-25 11:11:11 -0800215 String[] sets = newLayout.split(GRAVITY_SEPARATOR, 3);
Jason Monka2081822016-01-18 14:41:03 -0500216 String[] start = sets[0].split(BUTTON_SEPARATOR);
217 String[] center = sets[1].split(BUTTON_SEPARATOR);
218 String[] end = sets[2].split(BUTTON_SEPARATOR);
Jason Monkc62cf802016-05-10 11:02:24 -0400219 // Inflate these in start to end order or accessibility traversal will be messed up.
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800220 inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group), isRot0Landscape);
221 inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group), !isRot0Landscape);
Jason Monk4f878ef2016-01-23 14:37:38 -0500222
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800223 inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group), isRot0Landscape);
224 inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group), !isRot0Landscape);
Xiaohui Chen06917032016-01-26 11:20:39 -0800225
226 addGravitySpacer((LinearLayout) mRot0.findViewById(R.id.ends_group));
227 addGravitySpacer((LinearLayout) mRot90.findViewById(R.id.ends_group));
Jason Monk4f878ef2016-01-23 14:37:38 -0500228
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800229 inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group), isRot0Landscape);
230 inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group), !isRot0Landscape);
Jason Monk4f878ef2016-01-23 14:37:38 -0500231 }
232
Jason Monk4f878ef2016-01-23 14:37:38 -0500233 private void addGravitySpacer(LinearLayout layout) {
234 layout.addView(new Space(mContext), new LinearLayout.LayoutParams(0, 0, 1));
Jason Monka2081822016-01-18 14:41:03 -0500235 }
236
Jason Monk5332e592016-02-15 15:16:57 -0500237 private void inflateButtons(String[] buttons, ViewGroup parent, boolean landscape) {
Jason Monka2081822016-01-18 14:41:03 -0500238 for (int i = 0; i < buttons.length; i++) {
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800239 inflateButton(buttons[i], parent, landscape);
Jason Monka2081822016-01-18 14:41:03 -0500240 }
241 }
242
Jason Monka2081822016-01-18 14:41:03 -0500243 private ViewGroup.LayoutParams copy(ViewGroup.LayoutParams layoutParams) {
Jason Monk4f878ef2016-01-23 14:37:38 -0500244 if (layoutParams instanceof LinearLayout.LayoutParams) {
245 return new LinearLayout.LayoutParams(layoutParams.width, layoutParams.height,
246 ((LinearLayout.LayoutParams) layoutParams).weight);
247 }
Jason Monka2081822016-01-18 14:41:03 -0500248 return new LayoutParams(layoutParams.width, layoutParams.height);
249 }
250
Xiaohui Chen54816002016-01-25 11:11:11 -0800251 @Nullable
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800252 protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape) {
Xiaohui Chen54816002016-01-25 11:11:11 -0800253 LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
Jason Monk46a196e2016-01-23 15:28:10 -0500254 float size = extractSize(buttonSpec);
Jason Monk197f4db2016-08-26 13:28:20 -0400255 View v = createView(buttonSpec, parent, inflater, landscape);
256 if (v == null) return null;
257
258 if (size != 0) {
259 ViewGroup.LayoutParams params = v.getLayoutParams();
260 params.width = (int) (params.width * size);
261 }
262 parent.addView(v);
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800263 addToDispatchers(v);
264 View lastView = landscape ? mLastLandscape : mLastPortrait;
Jason Monk197f4db2016-08-26 13:28:20 -0400265 if (lastView != null) {
266 v.setAccessibilityTraversalAfter(lastView.getId());
267 }
268 if (landscape) {
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800269 mLastLandscape = v;
Jason Monk197f4db2016-08-26 13:28:20 -0400270 } else {
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800271 mLastPortrait = v;
Jason Monk197f4db2016-08-26 13:28:20 -0400272 }
273 return v;
274 }
275
276 private View createView(String buttonSpec, ViewGroup parent, LayoutInflater inflater,
277 boolean landscape) {
Jason Monk46a196e2016-01-23 15:28:10 -0500278 View v = null;
Jason Monk197f4db2016-08-26 13:28:20 -0400279 String button = extractButton(buttonSpec);
Jason Monkea05f872017-01-24 19:43:36 -0500280 if (LEFT.equals(button)) {
281 buttonSpec = TunerService.get(mContext).getValue(NAV_BAR_LEFT, NAVSPACE);
282 button = extractButton(buttonSpec);
283 } else if (RIGHT.equals(button)) {
284 buttonSpec = TunerService.get(mContext).getValue(NAV_BAR_RIGHT, MENU_IME);
285 button = extractButton(buttonSpec);
286 }
Jason Monk197f4db2016-08-26 13:28:20 -0400287 // Let plugins go first so they can override a standard view if they want.
288 for (NavBarButtonProvider provider : mPlugins) {
289 v = provider.createView(buttonSpec, parent);
290 if (v != null) return v;
291 }
Jason Monka2081822016-01-18 14:41:03 -0500292 if (HOME.equals(button)) {
Annie Chinb6ab24f2016-06-01 17:46:27 -0700293 v = inflater.inflate(R.layout.home, parent, false);
Jason Monka2081822016-01-18 14:41:03 -0500294 } else if (BACK.equals(button)) {
Xiaohui Chen54816002016-01-25 11:11:11 -0800295 v = inflater.inflate(R.layout.back, parent, false);
Jason Monka2081822016-01-18 14:41:03 -0500296 } else if (RECENT.equals(button)) {
Xiaohui Chen54816002016-01-25 11:11:11 -0800297 v = inflater.inflate(R.layout.recent_apps, parent, false);
Jason Monka2081822016-01-18 14:41:03 -0500298 } else if (MENU_IME.equals(button)) {
Xiaohui Chen54816002016-01-25 11:11:11 -0800299 v = inflater.inflate(R.layout.menu_ime, parent, false);
Jason Monka2081822016-01-18 14:41:03 -0500300 } else if (NAVSPACE.equals(button)) {
Xiaohui Chen54816002016-01-25 11:11:11 -0800301 v = inflater.inflate(R.layout.nav_key_space, parent, false);
Jason Monk3b587142016-01-23 16:47:59 -0500302 } else if (CLIPBOARD.equals(button)) {
303 v = inflater.inflate(R.layout.clipboard, parent, false);
Jason Monk8457ad82016-01-24 10:15:55 -0500304 } else if (button.startsWith(KEY)) {
305 String uri = extractImage(button);
306 int code = extractKeycode(button);
307 v = inflater.inflate(R.layout.custom_key, parent, false);
308 ((KeyButtonView) v).setCode(code);
309 if (uri != null) {
Jason Monkea05f872017-01-24 19:43:36 -0500310 if (uri.contains(":")) {
311 ((KeyButtonView) v).loadAsync(Icon.createWithContentUri(uri));
312 } else if (uri.contains("/")) {
313 int index = uri.indexOf('/');
314 String pkg = uri.substring(0, index);
315 int id = Integer.parseInt(uri.substring(index + 1));
316 ((KeyButtonView) v).loadAsync(Icon.createWithResource(pkg, id));
317 }
Jason Monk8457ad82016-01-24 10:15:55 -0500318 }
Jason Monkc62cf802016-05-10 11:02:24 -0400319 }
Jason Monk4f878ef2016-01-23 14:37:38 -0500320 return v;
321 }
322
Jason Monk8457ad82016-01-24 10:15:55 -0500323 public static String extractImage(String buttonSpec) {
324 if (!buttonSpec.contains(KEY_IMAGE_DELIM)) {
325 return null;
326 }
327 final int start = buttonSpec.indexOf(KEY_IMAGE_DELIM);
328 String subStr = buttonSpec.substring(start + 1, buttonSpec.indexOf(KEY_CODE_END));
329 return subStr;
330 }
331
332 public static int extractKeycode(String buttonSpec) {
333 if (!buttonSpec.contains(KEY_CODE_START)) {
334 return 1;
335 }
336 final int start = buttonSpec.indexOf(KEY_CODE_START);
337 String subStr = buttonSpec.substring(start + 1, buttonSpec.indexOf(KEY_IMAGE_DELIM));
338 return Integer.parseInt(subStr);
339 }
340
Jason Monk46a196e2016-01-23 15:28:10 -0500341 public static float extractSize(String buttonSpec) {
342 if (!buttonSpec.contains(SIZE_MOD_START)) {
343 return 1;
344 }
345 final int sizeStart = buttonSpec.indexOf(SIZE_MOD_START);
346 String sizeStr = buttonSpec.substring(sizeStart + 1, buttonSpec.indexOf(SIZE_MOD_END));
347 return Float.parseFloat(sizeStr);
348 }
349
350 public static String extractButton(String buttonSpec) {
351 if (!buttonSpec.contains(SIZE_MOD_START)) {
352 return buttonSpec;
353 }
354 return buttonSpec.substring(0, buttonSpec.indexOf(SIZE_MOD_START));
355 }
356
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800357 private void addToDispatchers(View v) {
Jason Monka2081822016-01-18 14:41:03 -0500358 if (mButtonDispatchers != null) {
359 final int indexOfKey = mButtonDispatchers.indexOfKey(v.getId());
360 if (indexOfKey >= 0) {
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800361 mButtonDispatchers.valueAt(indexOfKey).addView(v);
Keisuke Kuroyanagi47bd7332016-05-06 10:49:54 -0700362 } else if (v instanceof ViewGroup) {
363 final ViewGroup viewGroup = (ViewGroup)v;
364 final int N = viewGroup.getChildCount();
365 for (int i = 0; i < N; i++) {
Xiaohui Chen40e978e2016-11-29 15:10:04 -0800366 addToDispatchers(viewGroup.getChildAt(i));
Keisuke Kuroyanagi47bd7332016-05-06 10:49:54 -0700367 }
Jason Monka2081822016-01-18 14:41:03 -0500368 }
369 }
Jason Monka2081822016-01-18 14:41:03 -0500370 }
371
Jason Monka2081822016-01-18 14:41:03 -0500372
Jason Monka2081822016-01-18 14:41:03 -0500373
374 private void clearViews() {
375 if (mButtonDispatchers != null) {
376 for (int i = 0; i < mButtonDispatchers.size(); i++) {
377 mButtonDispatchers.valueAt(i).clear();
378 }
379 }
380 clearAllChildren((ViewGroup) mRot0.findViewById(R.id.nav_buttons));
Jason Monka2081822016-01-18 14:41:03 -0500381 clearAllChildren((ViewGroup) mRot90.findViewById(R.id.nav_buttons));
Jason Monka2081822016-01-18 14:41:03 -0500382 }
383
384 private void clearAllChildren(ViewGroup group) {
385 for (int i = 0; i < group.getChildCount(); i++) {
386 ((ViewGroup) group.getChildAt(i)).removeAllViews();
387 }
388 }
Jason Monk197f4db2016-08-26 13:28:20 -0400389
390 @Override
Jason Monk20ff3f92017-01-09 15:13:23 -0500391 public void onPluginConnected(NavBarButtonProvider plugin, Context context) {
Jason Monk197f4db2016-08-26 13:28:20 -0400392 mPlugins.add(plugin);
393 clearViews();
394 inflateLayout(mCurrentLayout);
395 }
396
397 @Override
398 public void onPluginDisconnected(NavBarButtonProvider plugin) {
399 mPlugins.remove(plugin);
400 clearViews();
401 inflateLayout(mCurrentLayout);
402 }
Jason Monka2081822016-01-18 14:41:03 -0500403}