Skip to content

Commit f8f76d5

Browse files
Jean-Baptiste Queruandroid code review
authored andcommitted
Merge "Add the possibility to modify the View focus rect"
2 parents 8c71784 + defdb1e commit f8f76d5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23034,6 +23034,7 @@ package android.view {
2303423034
method public void getDrawingRect(android.graphics.Rect);
2303523035
method public long getDrawingTime();
2303623036
method public boolean getFilterTouchesWhenObscured();
23037+
method public void getFocusRect(android.graphics.Rect);
2303723038
method public java.util.ArrayList<android.view.View> getFocusables(int);
2303823039
method public void getFocusedRect(android.graphics.Rect);
2303923040
method public boolean getGlobalVisibleRect(android.graphics.Rect, android.graphics.Point);

core/java/android/view/FocusFinder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ private View findNextFocus(ViewGroup root, View focused, Rect focusedRect, int d
181181
// only interested in other non-root views
182182
if (focusable == focused || focusable == root) continue;
183183

184-
// get visible bounds of other view in same coordinate system
185-
focusable.getDrawingRect(mOtherRect);
184+
// get focus bounds of other view in same coordinate system
185+
focusable.getFocusRect(mOtherRect);
186186
root.offsetDescendantRectToMyCoords(focusable, mOtherRect);
187187

188188
if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect)) {

core/java/android/view/View.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7129,6 +7129,18 @@ private void updateMatrix() {
71297129
}
71307130

71317131
/**
7132+
* When searching for a view to focus this rectangle is used when considering if this view is
7133+
* a good candidate for receiving focus.
7134+
*
7135+
* By default, the rectangle is the {@link #getDrawingRect}) of the view.
7136+
*
7137+
* @param r The rectangle to fill in, in this view's coordinates.
7138+
*/
7139+
public void getFocusRect(Rect r) {
7140+
getDrawingRect(r);
7141+
}
7142+
7143+
/**
71327144
* Utility method to retrieve the inverse of the current mMatrix property.
71337145
* We cache the matrix to avoid recalculating it when transform properties
71347146
* have not changed.

0 commit comments

Comments
 (0)