diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteConnectionPool.java | 42 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 65 | ||||
| -rw-r--r-- | core/java/android/view/MotionEvent.java | 20 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 20 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 | ||||
| -rw-r--r-- | core/java/android/webkit/WebSettingsClassic.java | 35 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewClassic.java | 45 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 7 | ||||
| -rw-r--r-- | core/java/android/widget/AbsSeekBar.java | 10 | ||||
| -rw-r--r-- | core/java/android/widget/GridView.java | 100 |
10 files changed, 267 insertions, 81 deletions
diff --git a/core/java/android/database/sqlite/SQLiteConnectionPool.java b/core/java/android/database/sqlite/SQLiteConnectionPool.java index 3562e89..00d3309 100644 --- a/core/java/android/database/sqlite/SQLiteConnectionPool.java +++ b/core/java/android/database/sqlite/SQLiteConnectionPool.java @@ -257,7 +257,34 @@ public final class SQLiteConnectionPool implements Closeable { synchronized (mLock) { throwIfClosedLocked(); + boolean restrictToOneConnection = false; + if (mConfiguration.journalMode.equalsIgnoreCase("WAL") + != configuration.journalMode.equalsIgnoreCase("WAL")) { + // WAL mode can only be changed if there are no acquired connections + // because we need to close all but the primary connection first. + if (!mAcquiredConnections.isEmpty()) { + throw new IllegalStateException("Write Ahead Logging (WAL) mode cannot " + + "be enabled or disabled while there are transactions in " + + "progress. Finish all transactions and release all active " + + "database connections first."); + } + + // Close all non-primary connections. This should happen immediately + // because none of them are in use. + closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked(); + assert mAvailableNonPrimaryConnections.isEmpty(); + + restrictToOneConnection = true; + } + if (mConfiguration.openFlags != configuration.openFlags) { + // If we are changing open flags and WAL mode at the same time, then + // we have no choice but to close the primary connection beforehand + // because there can only be one connection open when we change WAL mode. + if (restrictToOneConnection) { + closeAvailableConnectionsAndLogExceptionsLocked(); + } + // Try to reopen the primary connection using the new open flags then // close and discard all existing connections. // This might throw if the database is corrupt or cannot be opened in @@ -453,11 +480,7 @@ public final class SQLiteConnectionPool implements Closeable { // Can't throw. private void closeAvailableConnectionsAndLogExceptionsLocked() { - final int count = mAvailableNonPrimaryConnections.size(); - for (int i = 0; i < count; i++) { - closeConnectionAndLogExceptionsLocked(mAvailableNonPrimaryConnections.get(i)); - } - mAvailableNonPrimaryConnections.clear(); + closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked(); if (mAvailablePrimaryConnection != null) { closeConnectionAndLogExceptionsLocked(mAvailablePrimaryConnection); @@ -466,6 +489,15 @@ public final class SQLiteConnectionPool implements Closeable { } // Can't throw. + private void closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked() { + final int count = mAvailableNonPrimaryConnections.size(); + for (int i = 0; i < count; i++) { + closeConnectionAndLogExceptionsLocked(mAvailableNonPrimaryConnections.get(i)); + } + mAvailableNonPrimaryConnections.clear(); + } + + // Can't throw. private void closeExcessConnectionsAndLogExceptionsLocked() { int availableCount = mAvailableNonPrimaryConnections.size(); while (availableCount-- > mConfiguration.maxConnectionPoolSize - 1) { diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index bf32ea7..24a7800 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -834,8 +834,14 @@ public final class SQLiteDatabase extends SQLiteClosable { synchronized (mLock) { throwIfNotOpenLocked(); + mConfigurationLocked.customFunctions.add(wrapper); - mConnectionPoolLocked.reconfigure(mConfigurationLocked); + try { + mConnectionPoolLocked.reconfigure(mConfigurationLocked); + } catch (RuntimeException ex) { + mConfigurationLocked.customFunctions.remove(wrapper); + throw ex; + } } } @@ -1733,8 +1739,15 @@ public final class SQLiteDatabase extends SQLiteClosable { synchronized (mLock) { throwIfNotOpenLocked(); + + final Locale oldLocale = mConfigurationLocked.locale; mConfigurationLocked.locale = locale; - mConnectionPoolLocked.reconfigure(mConfigurationLocked); + try { + mConnectionPoolLocked.reconfigure(mConfigurationLocked); + } catch (RuntimeException ex) { + mConfigurationLocked.locale = oldLocale; + throw ex; + } } } @@ -1759,8 +1772,15 @@ public final class SQLiteDatabase extends SQLiteClosable { synchronized (mLock) { throwIfNotOpenLocked(); + + final int oldMaxSqlCacheSize = mConfigurationLocked.maxSqlCacheSize; mConfigurationLocked.maxSqlCacheSize = cacheSize; - mConnectionPoolLocked.reconfigure(mConfigurationLocked); + try { + mConnectionPoolLocked.reconfigure(mConfigurationLocked); + } catch (RuntimeException ex) { + mConfigurationLocked.maxSqlCacheSize = oldMaxSqlCacheSize; + throw ex; + } } } @@ -1805,6 +1825,10 @@ public final class SQLiteDatabase extends SQLiteClosable { * </p> * * @return true if write-ahead-logging is set. false otherwise + * + * @throws IllegalStateException if there are transactions in progress at the + * time this method is called. WAL mode can only be changed when there are no + * transactions in progress. */ public boolean enableWriteAheadLogging() { synchronized (mLock) { @@ -1835,18 +1859,32 @@ public final class SQLiteDatabase extends SQLiteClosable { return false; } - mIsWALEnabledLocked = true; + final int oldMaxConnectionPoolSize = mConfigurationLocked.maxConnectionPoolSize; + final String oldSyncMode = mConfigurationLocked.syncMode; + final String oldJournalMode = mConfigurationLocked.journalMode; mConfigurationLocked.maxConnectionPoolSize = SQLiteGlobal.getWALConnectionPoolSize(); mConfigurationLocked.syncMode = SQLiteGlobal.getWALSyncMode(); mConfigurationLocked.journalMode = "WAL"; - mConnectionPoolLocked.reconfigure(mConfigurationLocked); + try { + mConnectionPoolLocked.reconfigure(mConfigurationLocked); + } catch (RuntimeException ex) { + mConfigurationLocked.maxConnectionPoolSize = oldMaxConnectionPoolSize; + mConfigurationLocked.syncMode = oldSyncMode; + mConfigurationLocked.journalMode = oldJournalMode; + throw ex; + } + + mIsWALEnabledLocked = true; } return true; } /** * This method disables the features enabled by {@link #enableWriteAheadLogging()}. - * @hide + * + * @throws IllegalStateException if there are transactions in progress at the + * time this method is called. WAL mode can only be changed when there are no + * transactions in progress. */ public void disableWriteAheadLogging() { synchronized (mLock) { @@ -1856,11 +1894,22 @@ public final class SQLiteDatabase extends SQLiteClosable { return; } - mIsWALEnabledLocked = false; + final int oldMaxConnectionPoolSize = mConfigurationLocked.maxConnectionPoolSize; + final String oldSyncMode = mConfigurationLocked.syncMode; + final String oldJournalMode = mConfigurationLocked.journalMode; mConfigurationLocked.maxConnectionPoolSize = 1; mConfigurationLocked.syncMode = SQLiteGlobal.getDefaultSyncMode(); mConfigurationLocked.journalMode = SQLiteGlobal.getDefaultJournalMode(); - mConnectionPoolLocked.reconfigure(mConfigurationLocked); + try { + mConnectionPoolLocked.reconfigure(mConfigurationLocked); + } catch (RuntimeException ex) { + mConfigurationLocked.maxConnectionPoolSize = oldMaxConnectionPoolSize; + mConfigurationLocked.syncMode = oldSyncMode; + mConfigurationLocked.journalMode = oldJournalMode; + throw ex; + } + + mIsWALEnabledLocked = false; } } diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 92e8f4e..77fd8d2 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1654,14 +1654,22 @@ public final class MotionEvent extends InputEvent implements Parcelable { } } } - + /** - * Scales down the coordination of this event by the given scale. + * Applies a scale factor to all points within this event. + * + * This method is used to adjust touch events to simulate different density + * displays for compatibility mode. The values returned by {@link #getRawX()}, + * {@link #getRawY()}, {@link #getXPrecision()} and {@link #getYPrecision()} + * are also affected by the scale factor. * + * @param scale The scale factor to apply. * @hide */ public final void scale(float scale) { - nativeScale(mNativePtr, scale); + if (scale != 1.0f) { + nativeScale(mNativePtr, scale); + } } /** {@inheritDoc} */ @@ -2631,7 +2639,9 @@ public final class MotionEvent extends InputEvent implements Parcelable { * @param deltaY Amount to add to the current Y coordinate of the event. */ public final void offsetLocation(float deltaX, float deltaY) { - nativeOffsetLocation(mNativePtr, deltaX, deltaY); + if (deltaX != 0.0f || deltaY != 0.0f) { + nativeOffsetLocation(mNativePtr, deltaX, deltaY); + } } /** @@ -2644,7 +2654,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { public final void setLocation(float x, float y) { float oldX = getX(); float oldY = getY(); - nativeOffsetLocation(mNativePtr, x - oldX, y - oldY); + offsetLocation(x - oldX, y - oldY); } /** diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 6c195c4..d403cb9 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11489,7 +11489,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal layerType != LAYER_TYPE_HARDWARE; int restoreTo = -1; - if (!useDisplayListProperties) { + if (!useDisplayListProperties || transformToApply != null) { restoreTo = canvas.save(); } if (offsetForScroll) { @@ -11523,11 +11523,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal if (concatMatrix) { // Undo the scroll translation, apply the transformation matrix, // then redo the scroll translate to get the correct result. - if (!useDisplayListProperties) { - canvas.translate(-transX, -transY); - canvas.concat(transformToApply.getMatrix()); - canvas.translate(transX, transY); - } + canvas.translate(-transX, -transY); + canvas.concat(transformToApply.getMatrix()); + canvas.translate(transX, transY); parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION; } @@ -11556,12 +11554,10 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal layerFlags |= Canvas.CLIP_TO_LAYER_SAVE_FLAG; } if (layerType == LAYER_TYPE_NONE) { - if (!useDisplayListProperties) { - final int scrollX = hasDisplayList ? 0 : sx; - final int scrollY = hasDisplayList ? 0 : sy; - canvas.saveLayerAlpha(scrollX, scrollY, scrollX + mRight - mLeft, - scrollY + mBottom - mTop, multipliedAlpha, layerFlags); - } + final int scrollX = hasDisplayList ? 0 : sx; + final int scrollY = hasDisplayList ? 0 : sy; + canvas.saveLayerAlpha(scrollX, scrollY, scrollX + mRight - mLeft, + scrollY + mBottom - mTop, multipliedAlpha, layerFlags); } } else { // Alpha is handled by the child directly, clobber the layer's alpha diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 4eb70ab..14b8084 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1919,7 +1919,9 @@ public final class ViewRootImpl implements ViewParent, } private void performDraw() { - if (!mAttachInfo.mScreenOn) return; + if (!mAttachInfo.mScreenOn && !mReportNextDraw) { + return; + } final long drawStartTime; if (ViewDebug.DEBUG_LATENCY) { diff --git a/core/java/android/webkit/WebSettingsClassic.java b/core/java/android/webkit/WebSettingsClassic.java index 7e38570..c41bc00 100644 --- a/core/java/android/webkit/WebSettingsClassic.java +++ b/core/java/android/webkit/WebSettingsClassic.java @@ -121,9 +121,6 @@ public class WebSettingsClassic extends WebSettings { private boolean mForceUserScalable = false; // AutoFill Profile data - /** - * @hide for now, pending API council approval. - */ public static class AutoFillProfile { private int mUniqueId; private String mFullName; @@ -644,7 +641,6 @@ public class WebSettingsClassic extends WebSettings { /** * Set the double-tap zoom of the page in percent. Default is 100. * @param doubleTapZoom A percent value for increasing or decreasing the double-tap zoom. - * @hide */ public void setDoubleTapZoom(int doubleTapZoom) { if (mDoubleTapZoom != doubleTapZoom) { @@ -656,7 +652,6 @@ public class WebSettingsClassic extends WebSettings { /** * Get the double-tap zoom of the page in percent. * @return A percent value describing the double-tap zoom. - * @hide */ public int getDoubleTapZoom() { return mDoubleTapZoom; @@ -1012,7 +1007,6 @@ public class WebSettingsClassic extends WebSettings { /** * Set the number of pages cached by the WebKit for the history navigation. * @param size A non-negative integer between 0 (no cache) and 20 (max). - * @hide */ public synchronized void setPageCacheCapacity(int size) { if (size < 0) size = 0; @@ -1108,7 +1102,6 @@ public class WebSettingsClassic extends WebSettings { /** * Tell the WebView to use Skia's hardware accelerated rendering path * @param flag True if the WebView should use Skia's hw-accel path - * @hide */ public synchronized void setHardwareAccelSkiaEnabled(boolean flag) { if (mHardwareAccelSkia != flag) { @@ -1119,7 +1112,6 @@ public class WebSettingsClassic extends WebSettings { /** * @return True if the WebView is using hardware accelerated skia - * @hide */ public synchronized boolean getHardwareAccelSkiaEnabled() { return mHardwareAccelSkia; @@ -1128,7 +1120,6 @@ public class WebSettingsClassic extends WebSettings { /** * Tell the WebView to show the visual indicator * @param flag True if the WebView should show the visual indicator - * @hide */ public synchronized void setShowVisualIndicator(boolean flag) { if (mShowVisualIndicator != flag) { @@ -1139,7 +1130,6 @@ public class WebSettingsClassic extends WebSettings { /** * @return True if the WebView is showing the visual indicator - * @hide */ public synchronized boolean getShowVisualIndicator() { return mShowVisualIndicator; @@ -1283,7 +1273,6 @@ public class WebSettingsClassic extends WebSettings { * @param flag True if the WebView should enable WebWorkers. * Note that this flag only affects V8. JSC does not have * an equivalent setting. - * @hide */ public synchronized void setWorkersEnabled(boolean flag) { if (mWorkersEnabled != flag) { @@ -1305,8 +1294,8 @@ public class WebSettingsClassic extends WebSettings { /** * Sets whether XSS Auditor is enabled. + * Only used by LayoutTestController. * @param flag Whether XSS Auditor should be enabled. - * @hide Only used by LayoutTestController. */ public synchronized void setXSSAuditorEnabled(boolean flag) { if (mXSSAuditorEnabled != flag) { @@ -1507,7 +1496,6 @@ public class WebSettingsClassic extends WebSettings { * of an HTML page to fit the screen. This conflicts with attempts by * the UI to zoom in and out of an image, so it is set false by default. * @param shrink Set true to let webkit shrink the standalone image to fit. - * {@hide} */ public void setShrinksStandaloneImagesToFit(boolean shrink) { if (mShrinksStandaloneImagesToFit != shrink) { @@ -1520,7 +1508,6 @@ public class WebSettingsClassic extends WebSettings { * Specify the maximum decoded image size. The default is * 2 megs for small memory devices and 8 megs for large memory devices. * @param size The maximum decoded size, or zero to set to the default. - * @hide */ public void setMaximumDecodedImageSize(long size) { if (mMaximumDecodedImageSize != size) { @@ -1562,7 +1549,6 @@ public class WebSettingsClassic extends WebSettings { /** * Returns whether the viewport metatag can disable zooming - * @hide */ public boolean forceUserScalable() { return mForceUserScalable; @@ -1571,7 +1557,6 @@ public class WebSettingsClassic extends WebSettings { /** * Sets whether viewport metatag can disable zooming. * @param flag Whether or not to forceably enable user scalable. - * @hide */ public synchronized void setForceUserScalable(boolean flag) { mForceUserScalable = flag; @@ -1584,9 +1569,6 @@ public class WebSettingsClassic extends WebSettings { } } - /** - * @hide - */ public synchronized void setAutoFillEnabled(boolean enabled) { // AutoFill is always disabled in private browsing mode. boolean autoFillEnabled = enabled && !mPrivateBrowsingEnabled; @@ -1596,16 +1578,10 @@ public class WebSettingsClassic extends WebSettings { } } - /** - * @hide - */ public synchronized boolean getAutoFillEnabled() { return mAutoFillEnabled; } - /** - * @hide - */ public synchronized void setAutoFillProfile(AutoFillProfile profile) { if (mAutoFillProfile != profile) { mAutoFillProfile = profile; @@ -1613,9 +1589,6 @@ public class WebSettingsClassic extends WebSettings { } } - /** - * @hide - */ public synchronized AutoFillProfile getAutoFillProfile() { return mAutoFillProfile; } @@ -1633,18 +1606,12 @@ public class WebSettingsClassic extends WebSettings { } } - /** - * @hide - */ public void setProperty(String key, String value) { if (mWebView.nativeSetProperty(key, value)) { mWebView.invalidate(); } } - /** - * @hide - */ public String getProperty(String key) { return mWebView.nativeGetProperty(key); } diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index 13a2c94..e553a2e 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -1255,6 +1255,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc static final int AUTOFILL_FORM = 148; static final int ANIMATE_TEXT_SCROLL = 149; static final int EDIT_TEXT_SIZE_CHANGED = 150; + static final int SHOW_CARET_HANDLE = 151; private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID; private static final int LAST_PACKAGE_MSG_ID = HIT_TEST_RESULT; @@ -4923,7 +4924,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc * startX, startY, endX, endY */ private void getSelectionHandles(int[] handles) { - handles[0] = mSelectCursorBase.right; + handles[0] = mSelectCursorBase.left; handles[1] = mSelectCursorBase.bottom; handles[2] = mSelectCursorExtent.left; handles[3] = mSelectCursorExtent.bottom; @@ -5468,9 +5469,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc private boolean setupWebkitSelect() { syncSelectionCursors(); - if (mIsCaretSelection) { - showPasteWindow(); - } else if (!startSelectActionMode()) { + if (!mIsCaretSelection && !startSelectActionMode()) { selectionDone(); return false; } @@ -5539,7 +5538,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc if (!mIsCaretSelection) { updateWebkitSelection(); } - mIsCaretSelection = false; invalidate(); // redraw without selection mAutoScrollX = 0; mAutoScrollY = 0; @@ -6378,8 +6376,15 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc case MotionEvent.ACTION_UP: { mGestureDetector.onTouchEvent(ev); if (mTouchInEditText && mConfirmMove) { + stopTouch(); break; // We've been scrolling the edit text. } + if (!mConfirmMove && mIsEditingText && mSelectionStarted && + mIsCaretSelection) { + showPasteWindow(); + stopTouch(); + break; + } // pass the touch events from UI thread to WebCore thread if (shouldForwardTouchEvent()) { TouchEventData ted = new TouchEventData(); @@ -6765,7 +6770,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc syncSelectionCursors(); if (mIsCaretSelection) { resetCaretTimer(); - showPasteWindow(); } invalidate(); } @@ -8524,6 +8528,14 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } break; + case SHOW_CARET_HANDLE: + if (!mSelectingText && mIsEditingText && mIsCaretSelection) { + setupWebkitSelect(); + resetCaretTimer(); + showPasteWindow(); + } + break; + default: super.handleMessage(msg); break; @@ -8823,13 +8835,20 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc (data.mStart != data.mEnd || (mFieldPointer == nodePointer && mFieldPointer != 0))) { mIsCaretSelection = (data.mStart == data.mEnd); - if (!mSelectingText) { - setupWebkitSelect(); - } else if (!mSelectionStarted) { - syncSelectionCursors(); - } - if (mIsCaretSelection) { - resetCaretTimer(); + if (mIsCaretSelection && + (mInputConnection == null || + mInputConnection.getEditable().length() == 0)) { + // There's no text, don't show caret handle. + selectionDone(); + } else { + if (!mSelectingText) { + setupWebkitSelect(); + } else if (!mSelectionStarted) { + syncSelectionCursors(); + } + if (mIsCaretSelection) { + resetCaretTimer(); + } } } else { selectionDone(); diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index a36ce06..b47f71d 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -1778,7 +1778,10 @@ public final class WebViewCore { case SELECT_WORD_AT: { int x = msg.arg1; int y = msg.arg2; - nativeSelectWordAt(mNativeClass, x, y); + if (!nativeSelectWordAt(mNativeClass, x, y)) { + mWebViewClassic.mPrivateHandler.obtainMessage(WebViewClassic.SHOW_CARET_HANDLE) + .sendToTarget(); + } break; } case SELECT_ALL: @@ -3120,7 +3123,7 @@ public final class WebViewCore { private native void nativeSelectText(int nativeClass, int startX, int startY, int endX, int endY); private native void nativeClearTextSelection(int nativeClass); - private native void nativeSelectWordAt(int nativeClass, int x, int y); + private native boolean nativeSelectWordAt(int nativeClass, int x, int y); private native void nativeSelectAll(int nativeClass); private static native void nativeCertTrustChanged(); diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index e36afa3..ca5648a 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -133,6 +133,16 @@ public abstract class AbsSeekBar extends ProgressBar { } /** + * Return the drawable used to represent the scroll thumb - the component that + * the user can drag back and forth indicating the current value by its position. + * + * @return The current thumb drawable + */ + public Drawable getThumb() { + return mThumb; + } + + /** * @see #setThumbOffset(int) */ public int getThumbOffset() { diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 739bcce..0f1dab5 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -1908,7 +1908,8 @@ public class GridView extends AbsListView { } /** - * Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT + * Set the gravity for this grid. Gravity describes how the child views + * are horizontally aligned. Defaults to Gravity.LEFT * * @param gravity the gravity to apply to this grid's children * @@ -1922,6 +1923,17 @@ public class GridView extends AbsListView { } /** + * Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT + * + * @return the gravity that will be applied to this grid's children + * + * @attr ref android.R.styleable#GridView_gravity + */ + public int getGravity() { + return mGravity; + } + + /** * Set the amount of horizontal (x) spacing to place between each item * in the grid. * @@ -1937,6 +1949,44 @@ public class GridView extends AbsListView { } } + /** + * Returns the amount of horizontal spacing currently used between each item in the grid. + * + * <p>This is only accurate for the current layout. If {@link #setHorizontalSpacing(int)} + * has been called but layout is not yet complete, this method may return a stale value. + * To get the horizontal spacing that was explicitly requested use + * {@link #getRequestedHorizontalSpacing()}.</p> + * + * @return Current horizontal spacing between each item in pixels + * + * @see #setHorizontalSpacing(int) + * @see #getRequestedHorizontalSpacing() + * + * @attr ref android.R.styleable#GridView_horizontalSpacing + */ + public int getHorizontalSpacing() { + return mHorizontalSpacing; + } + + /** + * Returns the requested amount of horizontal spacing between each item in the grid. + * + * <p>The value returned may have been supplied during inflation as part of a style, + * the default GridView style, or by a call to {@link #setHorizontalSpacing(int)}. + * If layout is not yet complete or if GridView calculated a different horizontal spacing + * from what was requested, this may return a different value from + * {@link #getHorizontalSpacing()}.</p> + * + * @return The currently requested horizontal spacing between items, in pixels + * + * @see #setHorizontalSpacing(int) + * @see #getHorizontalSpacing() + * + * @attr ref android.R.styleable#GridView_horizontalSpacing + */ + public int getRequestedHorizontalSpacing() { + return mRequestedHorizontalSpacing; + } /** * Set the amount of vertical (y) spacing to place between each item @@ -1945,6 +1995,8 @@ public class GridView extends AbsListView { * @param verticalSpacing The amount of vertical space between items, * in pixels. * + * @see #getVerticalSpacing() + * * @attr ref android.R.styleable#GridView_verticalSpacing */ public void setVerticalSpacing(int verticalSpacing) { @@ -1955,6 +2007,19 @@ public class GridView extends AbsListView { } /** + * Returns the amount of vertical spacing between each item in the grid. + * + * @return The vertical spacing between items in pixels + * + * @see #setVerticalSpacing(int) + * + * @attr ref android.R.styleable#GridView_verticalSpacing + */ + public int getVerticalSpacing() { + return mVerticalSpacing; + } + + /** * Control how items are stretched to fill their space. * * @param stretchMode Either {@link #NO_STRETCH}, @@ -1988,6 +2053,39 @@ public class GridView extends AbsListView { } /** + * Return the width of a column in the grid. + * + * <p>This may not be valid yet if a layout is pending.</p> + * + * @return The column width in pixels + * + * @see #setColumnWidth(int) + * @see #getRequestedColumnWidth() + * + * @attr ref android.R.styleable#GridView_columnWidth + */ + public int getColumnWidth() { + return mColumnWidth; + } + + /** + * Return the requested width of a column in the grid. + * + * <p>This may not be the actual column width used. Use {@link #getColumnWidth()} + * to retrieve the current real width of a column.</p> + * + * @return The requested column width in pixels + * + * @see #setColumnWidth(int) + * @see #getColumnWidth() + * + * @attr ref android.R.styleable#GridView_columnWidth + */ + public int getRequestedColumnWidth() { + return mRequestedColumnWidth; + } + + /** * Set the number of columns in the grid * * @param numColumns The desired number of columns. |
