Skip to content

Commit e8dc07d

Browse files
author
Fabrice Di Meglio
committed
Make Gravity RTL APIs public
- also move unit tests to CTS - also small improvement for View Javadoc Change-Id: I166d5a10f4a00f1b46c90468c8b11906b438e1ea
1 parent 3bef5e9 commit e8dc07d

File tree

4 files changed

+66
-80
lines changed

4 files changed

+66
-80
lines changed

api/current.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10782,8 +10782,8 @@ package android.media {
1078210782

1078310783
public class MediaActionSound {
1078410784
ctor public MediaActionSound();
10785-
method public void load(int);
10786-
method public void play(int);
10785+
method public synchronized void load(int);
10786+
method public synchronized void play(int);
1078710787
method public void release();
1078810788
field public static final int FOCUS_COMPLETE = 1; // 0x1
1078910789
field public static final int SHUTTER_CLICK = 0; // 0x0
@@ -22096,8 +22096,11 @@ package android.view {
2209622096
public class Gravity {
2209722097
ctor public Gravity();
2209822098
method public static void apply(int, int, int, android.graphics.Rect, android.graphics.Rect);
22099+
method public static void apply(int, int, int, android.graphics.Rect, android.graphics.Rect, int);
2209922100
method public static void apply(int, int, int, android.graphics.Rect, int, int, android.graphics.Rect);
22101+
method public static void apply(int, int, int, android.graphics.Rect, int, int, android.graphics.Rect, int);
2210022102
method public static void applyDisplay(int, android.graphics.Rect, android.graphics.Rect);
22103+
method public static void applyDisplay(int, android.graphics.Rect, android.graphics.Rect, int);
2210122104
method public static int getAbsoluteGravity(int, int);
2210222105
method public static boolean isHorizontal(int);
2210322106
method public static boolean isVertical(int);

core/java/android/view/Gravity.java

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public static void apply(int gravity, int w, int h, Rect container, Rect outRect
153153
* container.
154154
* @param layoutDirection The layout direction.
155155
*
156-
* @hide
156+
* @see {@link View#LAYOUT_DIRECTION_LTR}
157+
* @see {@link View#LAYOUT_DIRECTION_RTL}
157158
*/
158159
public static void apply(int gravity, int w, int h, Rect container,
159160
Rect outRect, int layoutDirection) {
@@ -267,6 +268,37 @@ public static void apply(int gravity, int w, int h, Rect container,
267268
}
268269
}
269270

271+
/**
272+
* Apply a gravity constant to an object.
273+
*
274+
* @param gravity The desired placement of the object, as defined by the
275+
* constants in this class.
276+
* @param w The horizontal size of the object.
277+
* @param h The vertical size of the object.
278+
* @param container The frame of the containing space, in which the object
279+
* will be placed. Should be large enough to contain the
280+
* width and height of the object.
281+
* @param xAdj Offset to apply to the X axis. If gravity is LEFT this
282+
* pushes it to the right; if gravity is RIGHT it pushes it to
283+
* the left; if gravity is CENTER_HORIZONTAL it pushes it to the
284+
* right or left; otherwise it is ignored.
285+
* @param yAdj Offset to apply to the Y axis. If gravity is TOP this pushes
286+
* it down; if gravity is BOTTOM it pushes it up; if gravity is
287+
* CENTER_VERTICAL it pushes it down or up; otherwise it is
288+
* ignored.
289+
* @param outRect Receives the computed frame of the object in its
290+
* container.
291+
* @param layoutDirection The layout direction.
292+
*
293+
* @see {@link View#LAYOUT_DIRECTION_LTR}
294+
* @see {@link View#LAYOUT_DIRECTION_RTL}
295+
*/
296+
public static void apply(int gravity, int w, int h, Rect container,
297+
int xAdj, int yAdj, Rect outRect, int layoutDirection) {
298+
int absGravity = getAbsoluteGravity(gravity, layoutDirection);
299+
apply(absGravity, w, h, container, xAdj, yAdj, outRect);
300+
}
301+
270302
/**
271303
* Apply additional gravity behavior based on the overall "display" that an
272304
* object exists in. This can be used after
@@ -320,7 +352,32 @@ public static void applyDisplay(int gravity, Rect display, Rect inoutObj) {
320352
}
321353
}
322354
}
323-
355+
356+
/**
357+
* Apply additional gravity behavior based on the overall "display" that an
358+
* object exists in. This can be used after
359+
* {@link #apply(int, int, int, Rect, int, int, Rect)} to place the object
360+
* within a visible display. By default this moves or clips the object
361+
* to be visible in the display; the gravity flags
362+
* {@link #DISPLAY_CLIP_HORIZONTAL} and {@link #DISPLAY_CLIP_VERTICAL}
363+
* can be used to change this behavior.
364+
*
365+
* @param gravity Gravity constants to modify the placement within the
366+
* display.
367+
* @param display The rectangle of the display in which the object is
368+
* being placed.
369+
* @param inoutObj Supplies the current object position; returns with it
370+
* modified if needed to fit in the display.
371+
* @param layoutDirection The layout direction.
372+
*
373+
* @see {@link View#LAYOUT_DIRECTION_LTR}
374+
* @see {@link View#LAYOUT_DIRECTION_RTL}
375+
*/
376+
public static void applyDisplay(int gravity, Rect display, Rect inoutObj, int layoutDirection) {
377+
int absGravity = getAbsoluteGravity(gravity, layoutDirection);
378+
applyDisplay(absGravity, display, inoutObj);
379+
}
380+
324381
/**
325382
* <p>Indicate whether the supplied gravity has a vertical pull.</p>
326383
*

core/java/android/view/View.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9719,8 +9719,8 @@ public void resolvePadding() {
97199719
*
97209720
* @param layoutDirection the direction of the layout
97219721
*
9722-
* {@link #LAYOUT_DIRECTION_LTR}
9723-
* {@link #LAYOUT_DIRECTION_RTL}
9722+
* @see {@link #LAYOUT_DIRECTION_LTR}
9723+
* @see {@link #LAYOUT_DIRECTION_RTL}
97249724
*/
97259725
public void onPaddingChanged(int layoutDirection) {
97269726
}

core/tests/coretests/src/android/view/GravityTest.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)