summaryrefslogtreecommitdiff
path: root/src/com/android/systemui/navigation/BaseNavigationBar.java
blob: 517d6619721fd4b587a45d2a5fd15256a6f6c556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/**
 * Copyright (C) 2008 The Android Open Source Project
 * Copyright (C) 2014 The TeamEos Project
 * Copyright (C) 2016 The DirtyUnicorns Project
 * 
 * @author: Randall Rushing <randall.rushing@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Base navigation bar abstraction for managing keyguard policy, internal
 * bar behavior, and everything else not feature implementation specific
 * 
 */

package com.android.systemui.navigation;

import java.io.FileDescriptor;
import java.io.PrintWriter;

import com.android.systemui.navigation.Navigator;
import com.android.systemui.navigation.Res;
import com.android.systemui.navigation.NavbarOverlayResources;
import com.android.systemui.navigation.pulse.PulseController;
import com.android.systemui.navigation.pulse.PulseController.PulseStateListener;
import com.android.systemui.navigation.utils.SmartObserver;
import com.android.systemui.plugins.statusbar.phone.NavGesture;
import com.android.systemui.statusbar.phone.BarTransitions;
import com.android.systemui.Dependency;
import com.android.systemui.R;

import com.android.internal.utils.ActionUtils;
import com.android.internal.utils.ImageHelper;

import com.facebook.rebound.Spring;
import com.facebook.rebound.SpringSystem;

import android.animation.LayoutTransition;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

public abstract class BaseNavigationBar extends LinearLayout implements Navigator, PulseStateListener {
    final static String TAG = "PhoneStatusBar/BaseNavigationBar";
    public final static boolean DEBUG = false;
    public static final boolean NAVBAR_ALWAYS_AT_RIGHT = true;
    // slippery nav bar when everything is disabled, e.g. during setup
    final static boolean SLIPPERY_WHEN_DISABLED = true;

    // workaround for LayoutTransitions leaving the nav buttons in a weird state (bug 5549288)
    final static boolean WORKAROUND_INVALID_LAYOUT = true;
    final static int MSG_CHECK_INVALID_LAYOUT = 8686;

    public static final int MSG_SET_DISABLED_FLAGS = 101;
    public static final int MSG_INVALIDATE = 102;
    public static boolean sIsTablet;

    private boolean mKeyguardShowing;

    protected H mHandler = new H();
    protected final Display mDisplay;
    private final WindowManager mWm;
    protected View[] mRotatedViews = new View[4];
    protected View mCurrentView = null;
    protected FrameLayout mRot0, mRot90;
    protected int mDisabledFlags = 0;
    protected int mNavigationIconHints = 0;
    private int mCurrentRotation = -1;
    protected boolean mVertical;
    protected boolean mScreenOn;
    protected boolean mLeftInLandscape;
    protected boolean mLayoutTransitionsEnabled;
    protected boolean mWakeAndUnlocking;
    protected boolean mScreenPinningEnabled;
    protected OnVerticalChangedListener mOnVerticalChangedListener;
    protected SmartObserver mSmartObserver;
    protected PulseController mPulse;

    public NavbarOverlayResources mResourceMap;

    // use access methods to keep state proper
    private SpringSystem mSpringSystem;

    protected boolean mCarMode = false;
    protected boolean mDockedStackExists;

    private class H extends Handler {
        public void handleMessage(Message m) {
            switch (m.what) {
                case MSG_CHECK_INVALID_LAYOUT:
                    final String how = "" + m.obj;
                    final int w = getWidth();
                    final int h = getHeight();
                    final int vw = mCurrentView.getWidth();
                    final int vh = mCurrentView.getHeight();

                    if (h != vh || w != vw) {
                        Log.w(TAG, String.format(
                            "*** Invalid layout in navigation bar (%s this=%dx%d cur=%dx%d)",
                            how, w, h, vw, vh));
                        if (WORKAROUND_INVALID_LAYOUT) {
                            requestLayout();
                        }
                    }
                    break;
                case MSG_SET_DISABLED_FLAGS:
                    setDisabledFlags(mDisabledFlags, true);
                    break;
                case MSG_INVALIDATE:
                    invalidate();
                    break;
            }
        }
    }

    @Override
    public void onReceive(Intent intent) {
        if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
            notifyScreenOn(true);
        } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
            notifyScreenOn(false);
        }
    }

    public BaseNavigationBar(Context context) {
        this(context, null);
    }

    public BaseNavigationBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        mDisplay = ((WindowManager) context.getSystemService(
                Context.WINDOW_SERVICE)).getDefaultDisplay();
        mWm = (WindowManager) context.getSystemService(
                Context.WINDOW_SERVICE);
        mSmartObserver = new SmartObserver(mHandler, context.getContentResolver());
        mSpringSystem = SpringSystem.create();
        mPulse = Dependency.get(PulseController.class);
        sIsTablet = !ActionUtils.navigationBarCanMove();
    }

    // require implementation. Surely they have something to clean up
    protected abstract void onDispose();

    // any implementation specific handling can be handled here
    protected void onInflateFromUser() {}

    protected void onKeyguardShowing(boolean showing){}

    public void abortCurrentGesture(){}

    public void setMenuVisibility(final boolean show) {}
    public void setMenuVisibility(final boolean show, final boolean force) {} 
    public void setNavigationIconHints(int hints) {}
    public void setNavigationIconHints(int hints, boolean force) {}
    public void onHandlePackageChanged(){}

    public Editor getEditor() { return null; }

    //public boolean isInEditMode() { return false; }

    public void onRecreateStatusbar() {}

    public void setResourceMap(NavbarOverlayResources resourceMap) {
        mResourceMap = resourceMap;
        getBarTransitions().updateResources(mResourceMap);
    }

    public void updateNavbarThemedResources(Resources res){
        getBarTransitions().updateResources(mResourceMap);
    }

    protected static float alphaIntToFloat(int alpha) {
        return (float) Math.max(0, Math.min(255, alpha)) / 255;
    }

    @Override
    public void setWakeAndUnlocking(boolean wakeAndUnlocking) {
        setUseFadingAnimations(wakeAndUnlocking);
        mWakeAndUnlocking = wakeAndUnlocking;
        updateLayoutTransitionsEnabled();
    }

    @Override
    public boolean needsReorient(int rotation) {
        return mCurrentRotation != rotation;
    }

    public SpringSystem getSpringSystem() {
        if (mSpringSystem == null) {
            mSpringSystem = SpringSystem.create();
        }
        return mSpringSystem;
    }

    public void flushSpringSystem() {
        if (mSpringSystem != null) {
            for (Spring spring : mSpringSystem.getAllSprings()) {
                spring.setAtRest();
                spring.removeAllListeners();
                spring.destroy();
            }
            mSpringSystem.removeAllListeners();
            mSpringSystem = null;
        }
    }

    protected boolean areAnyHintsActive() {
        return ((mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0)
                || ((mDisabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0)
                || (((mDisabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0
                && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0)));

    }

    private WindowManager.LayoutParams getParamsFromParent() {
        // we need to get params from the parent container otherwise we'd get FrameLayout params
        return  (WindowManager.LayoutParams) ((ViewGroup) getParent()).getLayoutParams();
    }

    protected void setUseFadingAnimations(boolean useFadingAnimations) {
        WindowManager.LayoutParams lp = getParamsFromParent();
        if (lp != null) {
            boolean old = lp.windowAnimations != 0;
            if (!old && useFadingAnimations) {
                lp.windowAnimations = R.style.Animation_NavigationBarFadeIn;
            } else if (old && !useFadingAnimations) {
                lp.windowAnimations = 0;
            } else {
                return;
            }
            mWm.updateViewLayout((View) getParent(), lp);
        }
    }

    protected void updateLayoutTransitionsEnabled() {
        boolean enabled = !mWakeAndUnlocking && mLayoutTransitionsEnabled;
        ViewGroup navButtons = (ViewGroup) getCurrentView().findViewById(R.id.nav_buttons);
        if (navButtons == null) {
            navButtons = (ViewGroup) mCurrentView.findViewWithTag(Res.Common.NAV_BUTTONS);
        }
        LayoutTransition lt = navButtons.getLayoutTransition();
        if (lt != null) {
            if (enabled) {
                lt.enableTransitionType(LayoutTransition.APPEARING);
                lt.enableTransitionType(LayoutTransition.DISAPPEARING);
                lt.enableTransitionType(LayoutTransition.CHANGE_APPEARING);
                lt.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
            } else {
                lt.disableTransitionType(LayoutTransition.APPEARING);
                lt.disableTransitionType(LayoutTransition.DISAPPEARING);
                lt.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
                lt.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
            }
        }
    }

    @Override
    public void setLayoutTransitionsEnabled(boolean enabled) {
        mLayoutTransitionsEnabled = enabled;
        updateLayoutTransitionsEnabled();
    }

    public int findViewByIdName(String name) {
        return ActionUtils.getId(getContext(), name,
                ActionUtils.PACKAGE_SYSTEMUI);
    }

    public void setBackgroundColor(Drawable drawable) {
        // setBackground(drawable != null ? drawable : null);
    }

    public void setLeftInLandscape(boolean leftInLandscape) {
        if (mLeftInLandscape != leftInLandscape) {
            mLeftInLandscape = leftInLandscape;
        }
    }

    // keep keyguard methods final and use getter to access
    public final void setKeyguardShowing(boolean showing) {
        if (mKeyguardShowing != showing) {
            mKeyguardShowing = showing;
            onKeyguardShowing(showing);
        }
    }

    public final boolean isKeyguardShowing() {
        return mKeyguardShowing;
    }

    public boolean isLandscape() {
        return mCurrentView == mRot90;
    }

    // if a bar instance is created from a user mode switch
    // PhoneStatusBar should call this. This allows the view
    // to make adjustments that are otherwise not needed when
    // inflating on boot, such as setting proper transition flags
    public final void notifyInflateFromUser() {
        getBarTransitions().transitionTo(BarTransitions.MODE_TRANSPARENT, false);
        mScreenOn = true;
        onInflateFromUser();
    }

    public View getCurrentView() {
        return mCurrentView;
    }

    public View getHiddenView() {
        if (mCurrentView.equals(mRot0)) {
            return mRot90;
        } else {
            return mRot0;
        }
    }

    public void setDisabledFlags(int disabledFlags) {
        setDisabledFlags(disabledFlags, false);
    }

    public boolean isVertical() {
        return mVertical;
    }

    public final void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) {
        mOnVerticalChangedListener = onVerticalChangedListener;
        notifyVerticalChangedListener(mVertical);
    }

    public final void dispose() {
        mSmartObserver.cleanUp();
        flushSpringSystem();
        onDispose();
    }

    private void notifyVerticalChangedListener(boolean newVertical) {
        if (mOnVerticalChangedListener != null) {
            mOnVerticalChangedListener.onVerticalChanged(mVertical);
        }
    }

    public void notifyScreenOn(boolean screenOn) {
        mScreenOn = screenOn;
        setDisabledFlags(mDisabledFlags, true);
    }

    public void reorient() {
        final int rot = mDisplay.getRotation();
        for (int i=0; i<4; i++) {
            mRotatedViews[i].setVisibility(View.GONE);
        }
        mCurrentView = mRotatedViews[rot];
        mCurrentView.setVisibility(View.VISIBLE);
        mCurrentRotation = rot;

        if (DEBUG) {
            Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
        }
    }

    protected void setSlippery(boolean newSlippery) {
        WindowManager.LayoutParams lp = getParamsFromParent();
        if (lp != null) {
            boolean oldSlippery = (lp.flags & WindowManager.LayoutParams.FLAG_SLIPPERY) != 0;
            if (!oldSlippery && newSlippery) {
                lp.flags |= WindowManager.LayoutParams.FLAG_SLIPPERY;
            } else if (oldSlippery && !newSlippery) {
                lp.flags &= ~WindowManager.LayoutParams.FLAG_SLIPPERY;
            } else {
                return;
            }
            mWm.updateViewLayout((View) getParent(), lp);
        }
    }

    public void setNotificationPanelExpanded(boolean expanded) {
    }

    @Override
    public void onFinishInflate() {
        mRot0 = (FrameLayout) findViewById(R.id.rot0);
        mRot90 = (FrameLayout) findViewById(R.id.rot90);
        mRotatedViews[Surface.ROTATION_0] =
        mRotatedViews[Surface.ROTATION_180] = mRot0;
        mRotatedViews[Surface.ROTATION_90] = mRot90;
        mRotatedViews[Surface.ROTATION_270] = mRotatedViews[Surface.ROTATION_90];
        mCurrentView = mRotatedViews[Surface.ROTATION_0];
    }

    public void setDisabledFlags(int disabledFlags, boolean force) {
        if (!force && mDisabledFlags == disabledFlags)
            return;
        mDisabledFlags = disabledFlags;

        final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
        final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
        final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)
                && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
        final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);
    }

    @Override
    public final View getBaseView() {
        return (View)this;
    }

    @Override
    public void onPluginConnected(NavGesture plugin, Context context) {

    }

    @Override
    public void onPluginDisconnected(NavGesture plugin) {

    }

    // for when we don't inflate xml
    protected void createBaseViews() {
        LinearLayout rot0NavButton = new LinearLayout(getContext());
        rot0NavButton.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        rot0NavButton.setOrientation(LinearLayout.HORIZONTAL);
        rot0NavButton.setClipChildren(false);
        rot0NavButton.setClipToPadding(false);
        rot0NavButton.setLayoutTransition(new LayoutTransition());
        rot0NavButton.setTag(Res.Common.NAV_BUTTONS);

        LinearLayout rot90NavButton = new LinearLayout(getContext());
        rot90NavButton.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        rot90NavButton.setOrientation(sIsTablet ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
        rot90NavButton.setClipChildren(false);
        rot90NavButton.setClipToPadding(false);
        rot90NavButton.setLayoutTransition(new LayoutTransition());
        rot90NavButton.setTag(Res.Common.NAV_BUTTONS);

        mRot0 = new FrameLayout(getContext());
        mRot0.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));

        mRot90 = new FrameLayout(getContext());
        mRot90.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        mRot90.setVisibility(View.GONE);
        mRot90.setPadding(mRot90.getPaddingLeft(), 0, mRot90.getPaddingRight(),
                mRot90.getPaddingBottom());

//        addBatteryBarLayout(mRot0);
        mRot0.addView(rot0NavButton);

//        addBatteryBarLayout(mRot90);
        mRot90.addView(rot90NavButton);

        addView(mRot0);
        addView(mRot90);

        mRotatedViews[Surface.ROTATION_0] =
                mRotatedViews[Surface.ROTATION_180] = mRot0;
        mRotatedViews[Surface.ROTATION_90] = mRot90;
        mRotatedViews[Surface.ROTATION_270] = mRotatedViews[Surface.ROTATION_90];
        mCurrentView = mRotatedViews[Surface.ROTATION_0];
    }
/*
    private void addBatteryBarLayout(ViewGroup parent) {
        int which = -1;
        if (parent.equals(mRot0)) {
            which = R.layout.battery_bar_rot0;
        } else if (parent.equals(mRot90)) {
            which = R.layout.battery_bar_rot90;
        } else {
            return;
        }
        try {
            View bar = View.inflate(getContext(), which, null);
            parent.addView(bar);
        } catch (Exception e) {
            Log.e(TAG, "BatteryBarController failed to inflate");
        }
    }
*/
    protected void setVisibleOrGone(View view, boolean visible) {
        if (view != null) {
            view.setVisibility(visible ? VISIBLE : GONE);
        }
    }

    private void postCheckForInvalidLayout(final String how) {
        mHandler.obtainMessage(MSG_CHECK_INVALID_LAYOUT, 0, 0, how).sendToTarget();
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        if (DEBUG) Log.d(TAG, String.format(
                    "onSizeChanged: (%dx%d) old: (%dx%d)", w, h, oldw, oldh));

        final boolean newVertical = w > 0 && h > w;
        if (newVertical != mVertical) {
            mVertical = newVertical;
            //Log.v(TAG, String.format("onSizeChanged: h=%d, w=%d, vert=%s", h, w, mVertical?"y":"n"));
            reorient();
            notifyVerticalChangedListener(newVertical);
        }
        postCheckForInvalidLayout("sizeChanged");
        super.onSizeChanged(w, h, oldw, oldh);
    }

    @Override
    protected void onAttachedToWindow() {
        mPulse.addStateListener(this);
        super.onAttachedToWindow();
    }

    @Override
    protected void onDetachedFromWindow() {
        mPulse.removeStateListener(this);
        super.onDetachedFromWindow();
    }

    @Override
    public void onStartPulse() {}

    @Override
    public void onStopPulse() {}

    @Override
    public Handler getHandler() {
        return mHandler;
    }

    protected String getResourceName(int resId) {
        if (resId != 0) {
            final android.content.res.Resources res = getContext().getResources();
            try {
                return res.getResourceName(resId);
            } catch (android.content.res.Resources.NotFoundException ex) {
                return "(unknown)";
            }
        } else {
            return "(null)";
        }
    }

    protected static String visibilityToString(int vis) {
        switch (vis) {
            case View.INVISIBLE:
                return "INVISIBLE";
            case View.GONE:
                return "GONE";
            default:
                return "VISIBLE";
        }
    }

    public Drawable getLocalDrawable(String resName, Resources res) {
        int id = getDrawableId(resName);
        Drawable icon = ImageHelper.getVector(res, id, false);
        if (icon == null) {
            icon = res.getDrawable(id);
        }
        return icon;
    }

    public int getDrawableId(String resName) {
        try {
            int ident = getContext().getResources().getIdentifier(resName, "drawable",
                    getContext().getPackageName());
            return ident;
        } catch (Exception e) {
            return -1;
        }
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("NavigationBarView {");
        final Rect r = new Rect();
        final Point size = new Point();
        mDisplay.getRealSize(size);

        pw.println(String.format("      this: " + viewInfo(this)
                        + " " + visibilityToString(getVisibility())));

        getWindowVisibleDisplayFrame(r);
        final boolean offscreen = r.right > size.x || r.bottom > size.y;
        pw.println("      window: "
                + r.toShortString()
                + " " + visibilityToString(getWindowVisibility())
                + (offscreen ? " OFFSCREEN!" : ""));

        pw.println(String.format("      mCurrentView: id=%s (%dx%d) %s",
                        getResourceName(mCurrentView.getId()),
                        mCurrentView.getWidth(), mCurrentView.getHeight(),
                        visibilityToString(mCurrentView.getVisibility())));

        pw.println("    }");
    }

    protected static String viewInfo(View v) {
        return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom()
                + ") " + v.getWidth() + "x" + v.getHeight() + "]";
    }
}