diff options
| author | Dianne Hackborn <hackbod@google.com> | 2010-11-04 15:08:59 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2010-11-04 15:34:41 -0700 |
| commit | e213677037f836529efcc0ac201fc61dd95481c5 (patch) | |
| tree | 0b5f5644a7ea7618b4c5e2bdc1c98a62ad602725 | |
| parent | c63de86ad37772cfe488663fe043157ac36c14ab (diff) | |
| download | frameworks_base-e213677037f836529efcc0ac201fc61dd95481c5.zip frameworks_base-e213677037f836529efcc0ac201fc61dd95481c5.tar.gz frameworks_base-e213677037f836529efcc0ac201fc61dd95481c5.tar.bz2 | |
Push the jumpDrawablesToCurrentState() thing off everywhere it should be.
Also add a new interface that items in AbsListView can implement to
adjust the bounds of the selection shown for them. This will allow
contacts to use list view's regular selection facility rather than
implementing something special in their item views.
Change-Id: I29cbdbc7122111ee97e47fe7d6ec55ff07be79cc
| -rw-r--r-- | api/current.xml | 21 | ||||
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 10 | ||||
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 25 | ||||
| -rw-r--r-- | core/java/android/widget/AbsSeekBar.java | 6 | ||||
| -rw-r--r-- | core/java/android/widget/CompoundButton.java | 6 | ||||
| -rw-r--r-- | core/java/android/widget/FrameLayout.java | 6 | ||||
| -rw-r--r-- | core/java/android/widget/ImageView.java | 6 | ||||
| -rw-r--r-- | core/java/android/widget/ProgressBar.java | 7 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 19 | ||||
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java | 6 |
10 files changed, 112 insertions, 0 deletions
diff --git a/api/current.xml b/api/current.xml index 02e76c7..a3428db 100644 --- a/api/current.xml +++ b/api/current.xml @@ -226127,6 +226127,27 @@ </parameter> </method> </interface> +<interface name="AbsListView.SelectionBoundsAdjuster" + abstract="true" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="adjustListItemSelectionBounds" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="bounds" type="android.graphics.Rect"> +</parameter> +</method> +</interface> <class name="AbsSeekBar" extends="android.widget.ProgressBar" abstract="true" diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index ad343a3..17384c1 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -4284,6 +4284,16 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + final View[] children = mChildren; + final int count = mChildrenCount; + for (int i = 0; i < count; i++) { + children[i].jumpDrawablesToCurrentState(); + } + } + + @Override protected int[] onCreateDrawableState(int extraSpace) { if ((mGroupFlags & FLAG_ADD_STATES_FROM_CHILDREN) == 0) { return super.onCreateDrawableState(extraSpace); diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 7629673..2107e43 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -586,6 +586,22 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te int totalItemCount); } + /** + * The top-level view of a list item can implement this interface to allow + * itself to modify the bounds of the selection shown for that item. + */ + public interface SelectionBoundsAdjuster { + /** + * Called to allow the list item to adjust the bounds shown for + * its selection. + * + * @param bounds On call, this contains the bounds the list has + * selected for the item (that is the bounds of the entire view). The + * values can be modified as desired. + */ + public void adjustListItemSelectionBounds(Rect bounds); + } + public AbsListView(Context context) { super(context); initAbsListView(); @@ -1756,6 +1772,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te final Rect selectorRect = mSelectorRect; selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom()); + if (sel instanceof SelectionBoundsAdjuster) { + ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect); + } positionSelector(selectorRect.left, selectorRect.top, selectorRect.right, selectorRect.bottom); @@ -2003,6 +2022,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mSelector != null) mSelector.jumpToCurrentState(); + } + + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index d6dd872..dd71b3f 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -154,6 +154,12 @@ public abstract class AbsSeekBar extends ProgressBar { } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mThumb != null) mThumb.jumpToCurrentState(); + } + + @Override protected void drawableStateChanged() { super.drawableStateChanged(); diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index bf02ad3..0df45cc 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -279,6 +279,12 @@ public abstract class CompoundButton extends Button implements Checkable { return super.verifyDrawable(who) || who == mButtonDrawable; } + @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mButtonDrawable != null) mButtonDrawable.jumpToCurrentState(); + } + static class SavedState extends BaseSavedState { boolean checked; diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index 559a5fe..bcab7a9 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -156,6 +156,12 @@ public class FrameLayout extends ViewGroup { return super.verifyDrawable(who) || (who == mForeground); } + @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mForeground != null) mForeground.jumpToCurrentState(); + } + /** * {@inheritDoc} */ diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 5c4a156..bad74d4 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -160,6 +160,12 @@ public class ImageView extends View { } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mDrawable != null) mDrawable.jumpToCurrentState(); + } + + @Override public void invalidateDrawable(Drawable dr) { if (dr == mDrawable) { /* we invalidate the whole view in this case because it's very diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 3a4487c..b7048fc 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -455,6 +455,13 @@ public class ProgressBar extends View { } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mProgressDrawable != null) mProgressDrawable.jumpToCurrentState(); + if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState(); + } + + @Override public void postInvalidate() { if (!mNoInvalidate) { super.postInvalidate(); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 7c129b0..eb5a092 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3935,6 +3935,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mDrawables != null) { + if (mDrawables.mDrawableLeft != null) { + mDrawables.mDrawableLeft.jumpToCurrentState(); + } + if (mDrawables.mDrawableTop != null) { + mDrawables.mDrawableTop.jumpToCurrentState(); + } + if (mDrawables.mDrawableRight != null) { + mDrawables.mDrawableRight.jumpToCurrentState(); + } + if (mDrawables.mDrawableBottom != null) { + mDrawables.mDrawableBottom.jumpToCurrentState(); + } + } + } + + @Override public void invalidateDrawable(Drawable drawable) { if (verifyDrawable(drawable)) { final Rect dirty = drawable.getBounds(); diff --git a/policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java b/policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java index 7c99e87..8d87728 100644 --- a/policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java +++ b/policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java @@ -72,6 +72,12 @@ public class RecentApplicationsBackground extends LinearLayout { } @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + if (mBackground != null) mBackground.jumpToCurrentState(); + } + + @Override protected void drawableStateChanged() { Drawable d = mBackground; if (d != null && d.isStateful()) { |
