From 68bf5bd3858684dbaa79f265943d7adaba982e85 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Thu, 5 Sep 2013 16:27:28 -0700 Subject: Show view overlays in hierarchyviewer ViewOverlays can hold Drawables and Views. But none of these things show up in hierarchyviewer, so what you see on the screen is not necessarily what you see in hierarchyviewer. This CL adds logic to ViewDebug to enable these views/drawables to be displayed. Issue #8943158 plumb overlay views through into hierarchy viewer Change-Id: I020e85530a68390b37986269fa3e9e7e43725bab --- core/java/android/view/View.java | 3 +++ core/java/android/view/ViewDebug.java | 39 ++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index ce9cdfa324d7..1be3bb042547 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -13410,6 +13410,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Fast path for layouts with no backgrounds if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) { dispatchDraw(canvas); + if (mOverlay != null && !mOverlay.isEmpty()) { + mOverlay.getOverlayView().draw(canvas); + } } else { draw(canvas); } diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index ed128b073156..92e5e964fd34 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -698,6 +698,11 @@ public class ViewDebug { captureViewLayer(group.getChildAt(i), clientStream, localVisible); } } + + if (view.mOverlay != null) { + ViewGroup overlayContainer = view.getOverlay().mOverlayViewGroup; + captureViewLayer(overlayContainer, clientStream, localVisible); + } } private static void outputDisplayList(View root, String parameter) throws IOException { @@ -743,7 +748,7 @@ public class ViewDebug { } } - private static Bitmap performViewCapture(final View captureView, final boolean skpiChildren) { + private static Bitmap performViewCapture(final View captureView, final boolean skipChildren) { if (captureView != null) { final CountDownLatch latch = new CountDownLatch(1); final Bitmap[] cache = new Bitmap[1]; @@ -752,7 +757,7 @@ public class ViewDebug { public void run() { try { cache[0] = captureView.createSnapshot( - Bitmap.Config.ARGB_8888, 0, skpiChildren); + Bitmap.Config.ARGB_8888, 0, skipChildren); } catch (OutOfMemoryError e) { Log.w("View", "Out of memory for bitmap"); } finally { @@ -815,6 +820,13 @@ public class ViewDebug { } else if (isRequestedView(view, className, hashCode)) { return view; } + if (view.mOverlay != null) { + final View found = findView((ViewGroup) view.mOverlay.mOverlayViewGroup, + className, hashCode); + if (found != null) { + return found; + } + } if (view instanceof HierarchyHandler) { final View found = ((HierarchyHandler)view) .findHierarchyView(className, hashCode); @@ -823,12 +835,19 @@ public class ViewDebug { } } } - return null; } private static boolean isRequestedView(View view, String className, int hashCode) { - return view.getClass().getName().equals(className) && view.hashCode() == hashCode; + if (view.hashCode() == hashCode) { + String viewClassName = view.getClass().getName(); + if (className.equals("ViewOverlay")) { + return viewClassName.equals("android.view.ViewOverlay$OverlayViewGroup"); + } else { + return className.equals(viewClassName); + } + } + return false; } private static void dumpViewHierarchy(Context context, ViewGroup group, @@ -850,6 +869,12 @@ public class ViewDebug { } else { dumpView(context, view, out, level + 1, includeProperties); } + if (view.mOverlay != null) { + ViewOverlay overlay = view.getOverlay(); + ViewGroup overlayContainer = overlay.mOverlayViewGroup; + dumpViewHierarchy(context, overlayContainer, out, level + 2, skipChildren, + includeProperties); + } } if (group instanceof HierarchyHandler) { ((HierarchyHandler)group).dumpViewHierarchyWithProperties(out, level + 1); @@ -863,7 +888,11 @@ public class ViewDebug { for (int i = 0; i < level; i++) { out.write(' '); } - out.write(view.getClass().getName()); + String className = view.getClass().getName(); + if (className.equals("android.view.ViewOverlay$OverlayViewGroup")) { + className = "ViewOverlay"; + } + out.write(className); out.write('@'); out.write(Integer.toHexString(view.hashCode())); out.write(' '); -- cgit v1.2.3-59-g8ed1b