summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RelativeLayout.java
diff options
context:
space:
mode:
authorsvetoslavganov <svetoslavganov@google.com>2009-05-14 22:28:01 -0700
committersvetoslavganov <svetoslavganov@google.com>2009-05-14 23:47:05 -0700
commit75986cf9bc57ef11ad70f36fb77fbbf5d63af6ec (patch)
tree84e1843368037d24f83749d152f818d537267bfa /core/java/android/widget/RelativeLayout.java
parent669ec3a6e47248fee0a3a0f4877b46875eb42140 (diff)
Accessibility feature - framework changes (replacing 698, 699, 700, 701 and merging with the latest Donut)
Diffstat (limited to 'core/java/android/widget/RelativeLayout.java')
-rw-r--r--core/java/android/widget/RelativeLayout.java66
1 files changed, 62 insertions, 4 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index edbb3db255ab..ef240e098069 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -16,17 +16,22 @@
package android.widget;
+import com.android.internal.R;
+
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.Rect;
import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
import android.view.Gravity;
+import android.view.View;
import android.view.ViewDebug;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.RemoteViews.RemoteView;
-import android.graphics.Rect;
-import com.android.internal.R;
+import java.util.Comparator;
+import java.util.SortedSet;
+import java.util.TreeSet;
/**
* A Layout where the positions of the children can be described in relation to each other or to the
@@ -137,6 +142,8 @@ public class RelativeLayout extends ViewGroup {
private final Rect mSelfBounds = new Rect();
private int mIgnoreGravity;
+ private static SortedSet<View> mTopToBottomLeftToRightSet = null;
+
public RelativeLayout(Context context) {
super(context);
}
@@ -782,6 +789,57 @@ public class RelativeLayout extends ViewGroup {
return new LayoutParams(p);
}
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ if (mTopToBottomLeftToRightSet == null) {
+ mTopToBottomLeftToRightSet = new TreeSet<View>(new TopToBottomLeftToRightComparator());
+ }
+
+ // sort children top-to-bottom and left-to-right
+ for (int i = 0, count = getChildCount(); i < count; i++) {
+ mTopToBottomLeftToRightSet.add(getChildAt(i));
+ }
+
+ for (View view : mTopToBottomLeftToRightSet) {
+ if (view.dispatchPopulateAccessibilityEvent(event)) {
+ mTopToBottomLeftToRightSet.clear();
+ return true;
+ }
+ }
+
+ mTopToBottomLeftToRightSet.clear();
+ return false;
+ }
+
+ /**
+ * Compares two views in left-to-right and top-to-bottom fashion.
+ */
+ private class TopToBottomLeftToRightComparator implements Comparator<View> {
+ public int compare(View first, View second) {
+ // top - bottom
+ int topDifference = first.getTop() - second.getTop();
+ if (topDifference != 0) {
+ return topDifference;
+ }
+ // left - right
+ int leftDifference = first.getLeft() - second.getLeft();
+ if (leftDifference != 0) {
+ return leftDifference;
+ }
+ // break tie by height
+ int heightDiference = first.getHeight() - second.getHeight();
+ if (heightDiference != 0) {
+ return heightDiference;
+ }
+ // break tie by width
+ int widthDiference = first.getWidth() - second.getWidth();
+ if (widthDiference != 0) {
+ return widthDiference;
+ }
+ return 0;
+ }
+ }
+
/**
* Per-child layout information associated with RelativeLayout.
*