summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2013-03-26 07:55:30 -0700
committerChet Haase <chet@google.com>2013-04-08 07:30:12 -0700
commitedf6f4b49f6e77c349f5055372ce381b74f12efb (patch)
treea506b5eecd2c19017f46dc9f5982e0a8de3078ef /core/java/android/view/View.java
parenta56b78dcd1292a4291d85113bdeeda8496c1a0c0 (diff)
downloadframeworks_base-edf6f4b49f6e77c349f5055372ce381b74f12efb.zip
frameworks_base-edf6f4b49f6e77c349f5055372ce381b74f12efb.tar.gz
frameworks_base-edf6f4b49f6e77c349f5055372ce381b74f12efb.tar.bz2
Make adding views specific to a ViewGroup's overlay
Adding views to views (possible with the new Overlay API) is weird. This change moves the view-management facilities of Overlay to a subclass that is specific to the overlay returned from ViewGroup.getOverlay(). So now you can add drawables to all view overlays, but only add/remove views to/from the overlay returned from ViewGroup.getOverlay(). Also, the previous approach of using an interface for Overlay was changed to classes for both ViewOverlay and ViewGroupOverlay. Finally, this change makes not handling touch correctly the proper, and documented, behavior of overlay views. There are various tricky issues to sort out with input in overlays (including click handling as well as focus) and we don't want developers starting to use overlays as some kind of general container hierarchy, so we're purposely constraining overlays to have visual-only behavior. Issue #8459085 Overlay needs to handle touch correctly Change-Id: I207b8dbf528f87c92369d270d8b0a6556826d207
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java44
1 files changed, 17 insertions, 27 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 3b06da7..a520e17 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -12107,7 +12107,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
//System.out.println("Attached! " + this);
mAttachInfo = info;
if (mOverlay != null) {
- mOverlay.dispatchAttachedToWindow(info, visibility);
+ mOverlay.getOverlayView().dispatchAttachedToWindow(info, visibility);
}
mWindowAttachCount++;
// We will need to evaluate the drawable state at least once.
@@ -12178,7 +12178,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mAttachInfo = null;
if (mOverlay != null) {
- mOverlay.dispatchDetachedFromWindow();
+ mOverlay.getOverlayView().dispatchDetachedFromWindow();
}
}
@@ -12831,7 +12831,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) {
dispatchDraw(canvas);
if (mOverlay != null && !mOverlay.isEmpty()) {
- mOverlay.draw(canvas);
+ mOverlay.getOverlayView().draw(canvas);
}
} else {
draw(canvas);
@@ -13147,7 +13147,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mPrivateFlags &= ~PFLAG_DIRTY_MASK;
dispatchDraw(canvas);
if (mOverlay != null && !mOverlay.isEmpty()) {
- mOverlay.draw(canvas);
+ mOverlay.getOverlayView().draw(canvas);
}
} else {
draw(canvas);
@@ -13905,7 +13905,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
onDrawScrollBars(canvas);
if (mOverlay != null && !mOverlay.isEmpty()) {
- mOverlay.dispatchDraw(canvas);
+ mOverlay.getOverlayView().dispatchDraw(canvas);
}
// we're done...
@@ -14049,34 +14049,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
onDrawScrollBars(canvas);
if (mOverlay != null && !mOverlay.isEmpty()) {
- mOverlay.dispatchDraw(canvas);
+ mOverlay.getOverlayView().dispatchDraw(canvas);
}
}
/**
- * Called by the addToOverlay() methods to create, attach, and size the overlay as necessary
+ * Returns the overlay for this view, creating it if it does not yet exist.
+ * Adding drawables to the overlay will cause them to be displayed whenever
+ * the view itself is redrawn. Objects in the overlay should be actively
+ * managed: remove them when they should not be displayed anymore. The
+ * overlay will always have the same size as its host view.
+ *
+ * @return The ViewOverlay object for this view.
+ * @see ViewOverlay
*/
- private void setupOverlay() {
+ public ViewOverlay getOverlay() {
if (mOverlay == null) {
mOverlay = new ViewOverlay(mContext, this);
- mOverlay.mAttachInfo = mAttachInfo;
- mOverlay.setRight(mRight);
- mOverlay.setBottom(mBottom);
}
- }
-
- /**
- * Returns the overlay for this view, creating it if it does not yet exist. Adding drawables
- * and/or views to the overlay will cause them to be displayed whenever the view itself is
- * redrawn. Objects in the overlay should be actively managed: remove them when they should
- * not be displayed anymore and invalidate this view appropriately when overlay drawables
- * change. The overlay will always have the same size as its host view.
- *
- * @return The Overlay object for this view.
- * @see Overlay
- */
- public Overlay getOverlay() {
- setupOverlay();
return mOverlay;
}
@@ -14360,8 +14350,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
private void sizeChange(int newWidth, int newHeight, int oldWidth, int oldHeight) {
onSizeChanged(newWidth, newHeight, oldWidth, oldHeight);
if (mOverlay != null) {
- mOverlay.setRight(mRight);
- mOverlay.setBottom(mBottom);
+ mOverlay.getOverlayView().setRight(newWidth);
+ mOverlay.getOverlayView().setBottom(newHeight);
}
}