summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/SearchManager.java22
-rw-r--r--core/java/android/content/ContentResolver.java3
-rw-r--r--core/java/android/database/AbstractCursor.java46
-rw-r--r--core/java/android/database/AbstractWindowedCursor.java7
-rw-r--r--core/java/android/database/CrossProcessCursor.java52
-rw-r--r--core/java/android/database/CrossProcessCursorWrapper.java75
-rw-r--r--core/java/android/database/CursorToBulkCursorAdaptor.java71
-rw-r--r--core/java/android/database/CursorWindow.java80
-rw-r--r--core/java/android/database/CursorWrapper.java8
-rw-r--r--core/java/android/database/DatabaseUtils.java79
-rw-r--r--core/java/android/database/sqlite/SQLiteCompiledSql.java10
-rw-r--r--core/java/android/database/sqlite/SQLiteCursor.java10
-rw-r--r--core/java/android/database/sqlite/package.html2
-rw-r--r--core/java/android/nfc/NfcAdapter.java55
-rw-r--r--core/java/android/os/CountDownTimer.java2
-rw-r--r--core/java/android/os/StrictMode.java7
-rw-r--r--core/java/android/provider/CalendarContract.java173
-rw-r--r--core/java/android/text/DynamicLayout.java6
-rw-r--r--core/java/android/text/StaticLayout.java144
-rw-r--r--core/java/android/text/method/ArrowKeyMovementMethod.java12
-rw-r--r--core/java/android/text/style/SuggestionSpan.java1
-rw-r--r--core/java/android/view/View.java13
-rw-r--r--core/java/android/view/ViewRootImpl.java22
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java2
-rw-r--r--core/java/android/view/accessibility/AccessibilityRecord.java8
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java14
-rw-r--r--core/java/android/view/textservice/SpellCheckerSession.java12
-rw-r--r--core/java/android/webkit/JniUtil.java8
-rw-r--r--core/java/android/webkit/WebChromeClient.java46
-rw-r--r--core/java/android/webkit/WebSettings.java2
-rw-r--r--core/java/android/webkit/WebView.java46
-rw-r--r--core/java/android/webkit/ZoomManager.java14
-rw-r--r--core/java/android/widget/NumberPicker.java113
-rw-r--r--core/java/android/widget/RemoteViews.java10
-rw-r--r--core/java/android/widget/SpellChecker.java75
-rw-r--r--core/java/android/widget/TextView.java144
36 files changed, 950 insertions, 444 deletions
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 3290b9d..3aa159e 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
+import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -498,8 +499,24 @@ public class SearchManager
ComponentName launchActivity,
Bundle appSearchData,
boolean globalSearch) {
+ startSearch(initialQuery, selectInitialQuery, launchActivity,
+ appSearchData, globalSearch, null);
+ }
+
+ /**
+ * As {@link #startSearch(String, boolean, ComponentName, Bundle, boolean)} but including
+ * source bounds for the global search intent.
+ *
+ * @hide
+ */
+ public void startSearch(String initialQuery,
+ boolean selectInitialQuery,
+ ComponentName launchActivity,
+ Bundle appSearchData,
+ boolean globalSearch,
+ Rect sourceBounds) {
if (globalSearch) {
- startGlobalSearch(initialQuery, selectInitialQuery, appSearchData);
+ startGlobalSearch(initialQuery, selectInitialQuery, appSearchData, sourceBounds);
return;
}
@@ -520,7 +537,7 @@ public class SearchManager
* Starts the global search activity.
*/
/* package */ void startGlobalSearch(String initialQuery, boolean selectInitialQuery,
- Bundle appSearchData) {
+ Bundle appSearchData, Rect sourceBounds) {
ComponentName globalSearchActivity = getGlobalSearchActivity();
if (globalSearchActivity == null) {
Log.w(TAG, "No global search activity found.");
@@ -546,6 +563,7 @@ public class SearchManager
if (selectInitialQuery) {
intent.putExtra(EXTRA_SELECT_QUERY, selectInitialQuery);
}
+ intent.setSourceBounds(sourceBounds);
try {
if (DBG) Log.d(TAG, "Starting global search: " + intent.toUri(0));
mContext.startActivity(intent);
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index e923349..cc3219b 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -26,6 +26,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
import android.database.ContentObserver;
+import android.database.CrossProcessCursorWrapper;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.IContentObserver;
@@ -1568,7 +1569,7 @@ public abstract class ContentResolver {
samplePercent);
}
- private final class CursorWrapperInner extends CursorWrapper {
+ private final class CursorWrapperInner extends CrossProcessCursorWrapper {
private final IContentProvider mContentProvider;
public static final String TAG="CursorWrapperInner";
diff --git a/core/java/android/database/AbstractCursor.java b/core/java/android/database/AbstractCursor.java
index ee6aec6..74fef29 100644
--- a/core/java/android/database/AbstractCursor.java
+++ b/core/java/android/database/AbstractCursor.java
@@ -53,7 +53,10 @@ public abstract class AbstractCursor implements CrossProcessCursor {
abstract public boolean isNull(int column);
public int getType(int column) {
- throw new UnsupportedOperationException();
+ // Reflects the assumption that all commonly used field types (meaning everything
+ // but blobs) are convertible to strings so it should be safe to call
+ // getString to retrieve them.
+ return FIELD_TYPE_STRING;
}
// TODO implement getBlob in all cursor types
@@ -185,46 +188,9 @@ public abstract class AbstractCursor implements CrossProcessCursor {
return result;
}
- /**
- * Copy data from cursor to CursorWindow
- * @param position start position of data
- * @param window
- */
+ @Override
public void fillWindow(int position, CursorWindow window) {
- if (position < 0 || position >= getCount()) {
- return;
- }
- window.acquireReference();
- try {
- int oldpos = mPos;
- mPos = position - 1;
- window.clear();
- window.setStartPosition(position);
- int columnNum = getColumnCount();
- window.setNumColumns(columnNum);
- while (moveToNext() && window.allocRow()) {
- for (int i = 0; i < columnNum; i++) {
- String field = getString(i);
- if (field != null) {
- if (!window.putString(field, mPos, i)) {
- window.freeLastRow();
- break;
- }
- } else {
- if (!window.putNull(mPos, i)) {
- window.freeLastRow();
- break;
- }
- }
- }
- }
-
- mPos = oldpos;
- } catch (IllegalStateException e){
- // simply ignore it
- } finally {
- window.releaseReference();
- }
+ DatabaseUtils.cursorFillWindow(this, position, window);
}
public final boolean move(int offset) {
diff --git a/core/java/android/database/AbstractWindowedCursor.java b/core/java/android/database/AbstractWindowedCursor.java
index d0aedd2..083485f 100644
--- a/core/java/android/database/AbstractWindowedCursor.java
+++ b/core/java/android/database/AbstractWindowedCursor.java
@@ -188,15 +188,14 @@ public abstract class AbstractWindowedCursor extends AbstractCursor {
/**
* If there is a window, clear it.
- * Otherwise, creates a local window.
+ * Otherwise, creates a new window.
*
* @param name The window name.
* @hide
*/
- protected void clearOrCreateLocalWindow(String name) {
+ protected void clearOrCreateWindow(String name) {
if (mWindow == null) {
- // If there isn't a window set already it will only be accessed locally
- mWindow = new CursorWindow(name, true /* the window is local only */);
+ mWindow = new CursorWindow(name);
} else {
mWindow.clear();
}
diff --git a/core/java/android/database/CrossProcessCursor.java b/core/java/android/database/CrossProcessCursor.java
index 8e6a5aa..26379cc 100644
--- a/core/java/android/database/CrossProcessCursor.java
+++ b/core/java/android/database/CrossProcessCursor.java
@@ -16,27 +16,63 @@
package android.database;
+/**
+ * A cross process cursor is an extension of a {@link Cursor} that also supports
+ * usage from remote processes.
+ * <p>
+ * The contents of a cross process cursor are marshalled to the remote process by
+ * filling {@link CursorWindow} objects using {@link #fillWindow}. As an optimization,
+ * the cursor can provide a pre-filled window to use via {@link #getWindow} thereby
+ * obviating the need to copy the data to yet another cursor window.
+ */
public interface CrossProcessCursor extends Cursor {
/**
- * returns a pre-filled window, return NULL if no such window
+ * Returns a pre-filled window that contains the data within this cursor.
+ * <p>
+ * In particular, the window contains the row indicated by {@link Cursor#getPosition}.
+ * The window's contents are automatically scrolled whenever the current
+ * row moved outside the range covered by the window.
+ * </p>
+ *
+ * @return The pre-filled window, or null if none.
*/
CursorWindow getWindow();
/**
- * copies cursor data into the window start at pos
+ * Copies cursor data into the window.
+ * <p>
+ * Clears the window and fills it with data beginning at the requested
+ * row position until all of the data in the cursor is exhausted
+ * or the window runs out of space.
+ * </p><p>
+ * The filled window uses the same row indices as the original cursor.
+ * For example, if you fill a window starting from row 5 from the cursor,
+ * you can query the contents of row 5 from the window just by asking it
+ * for row 5 because there is a direct correspondence between the row indices
+ * used by the cursor and the window.
+ * </p><p>
+ * The current position of the cursor, as returned by {@link #getPosition},
+ * is not changed by this method.
+ * </p>
+ *
+ * @param position The zero-based index of the first row to copy into the window.
+ * @param window The window to fill.
*/
- void fillWindow(int pos, CursorWindow winow);
+ void fillWindow(int position, CursorWindow window);
/**
* This function is called every time the cursor is successfully scrolled
* to a new position, giving the subclass a chance to update any state it
- * may have. If it returns false the move function will also do so and the
+ * may have. If it returns false the move function will also do so and the
* cursor will scroll to the beforeFirst position.
+ * <p>
+ * This function should be called by methods such as {@link #moveToPosition(int)},
+ * so it will typically not be called from outside of the cursor class itself.
+ * </p>
*
- * @param oldPosition the position that we're moving from
- * @param newPosition the position that we're moving to
- * @return true if the move is successful, false otherwise
+ * @param oldPosition The position that we're moving from.
+ * @param newPosition The position that we're moving to.
+ * @return True if the move is successful, false otherwise.
*/
boolean onMove(int oldPosition, int newPosition);
-
}
diff --git a/core/java/android/database/CrossProcessCursorWrapper.java b/core/java/android/database/CrossProcessCursorWrapper.java
new file mode 100644
index 0000000..8c250b8
--- /dev/null
+++ b/core/java/android/database/CrossProcessCursorWrapper.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package android.database;
+
+import android.database.CrossProcessCursor;
+import android.database.Cursor;
+import android.database.CursorWindow;
+import android.database.CursorWrapper;
+
+/**
+ * Cursor wrapper that implements {@link CrossProcessCursor}.
+ * <p>
+ * If the wrapper cursor implemented {@link CrossProcessCursor}, then delegates
+ * {@link #fillWindow}, {@link #getWindow()} and {@link #onMove} to it. Otherwise,
+ * provides default implementations of these methods that traverse the contents
+ * of the cursor similar to {@link AbstractCursor#fillWindow}.
+ * </p><p>
+ * This wrapper can be used to adapt an ordinary {@link Cursor} into a
+ * {@link CrossProcessCursor}.
+ * </p>
+ */
+public class CrossProcessCursorWrapper extends CursorWrapper implements CrossProcessCursor {
+ /**
+ * Creates a cross process cursor wrapper.
+ * @param cursor The underlying cursor to wrap.
+ */
+ public CrossProcessCursorWrapper(Cursor cursor) {
+ super(cursor);
+ }
+
+ @Override
+ public void fillWindow(int position, CursorWindow window) {
+ if (mCursor instanceof CrossProcessCursor) {
+ final CrossProcessCursor crossProcessCursor = (CrossProcessCursor)mCursor;
+ crossProcessCursor.fillWindow(position, window);
+ return;
+ }
+
+ DatabaseUtils.cursorFillWindow(mCursor, position, window);
+ }
+
+ @Override
+ public CursorWindow getWindow() {
+ if (mCursor instanceof CrossProcessCursor) {
+ final CrossProcessCursor crossProcessCursor = (CrossProcessCursor)mCursor;
+ return crossProcessCursor.getWindow();
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean onMove(int oldPosition, int newPosition) {
+ if (mCursor instanceof CrossProcessCursor) {
+ final CrossProcessCursor crossProcessCursor = (CrossProcessCursor)mCursor;
+ return crossProcessCursor.onMove(oldPosition, newPosition);
+ }
+
+ return true;
+ }
+}
diff --git a/core/java/android/database/CursorToBulkCursorAdaptor.java b/core/java/android/database/CursorToBulkCursorAdaptor.java
index dd2c9b7..215035d 100644
--- a/core/java/android/database/CursorToBulkCursorAdaptor.java
+++ b/core/java/android/database/CursorToBulkCursorAdaptor.java
@@ -25,9 +25,9 @@ import android.util.Log;
/**
* Wraps a BulkCursor around an existing Cursor making it remotable.
* <p>
- * If the wrapped cursor is a {@link AbstractWindowedCursor} then it owns
- * the cursor window. Otherwise, the adaptor takes ownership of the
- * cursor itself and ensures it gets closed as needed during deactivation
+ * If the wrapped cursor returns non-null from {@link CrossProcessCursor#getWindow}
+ * then it is assumed to own the window. Otherwise, the adaptor provides a
+ * window to be filled and ensures it gets closed as needed during deactivation
* and requeries.
* </p>
*
@@ -48,12 +48,11 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
private CrossProcessCursor mCursor;
/**
- * The cursor window used by the cross process cursor.
- * This field is always null for abstract windowed cursors since they are responsible
- * for managing the lifetime of their window.
+ * The cursor window that was filled by the cross process cursor in the
+ * case where the cursor does not support getWindow.
+ * This field is only ever non-null when the window has actually be filled.
*/
- private CursorWindow mWindowForNonWindowedCursor;
- private boolean mWindowForNonWindowedCursorWasFilled;
+ private CursorWindow mFilledWindow;
private static final class ContentObserverProxy extends ContentObserver {
protected IContentObserver mRemote;
@@ -90,11 +89,10 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
public CursorToBulkCursorAdaptor(Cursor cursor, IContentObserver observer,
String providerName) {
- try {
- mCursor = (CrossProcessCursor) cursor;
- } catch (ClassCastException e) {
- throw new UnsupportedOperationException(
- "Only CrossProcessCursor cursors are supported across process for now", e);
+ if (cursor instanceof CrossProcessCursor) {
+ mCursor = (CrossProcessCursor)cursor;
+ } else {
+ mCursor = new CrossProcessCursorWrapper(cursor);
}
mProviderName = providerName;
@@ -103,11 +101,10 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
}
}
- private void closeWindowForNonWindowedCursorLocked() {
- if (mWindowForNonWindowedCursor != null) {
- mWindowForNonWindowedCursor.close();
- mWindowForNonWindowedCursor = null;
- mWindowForNonWindowedCursorWasFilled = false;
+ private void closeFilledWindowLocked() {
+ if (mFilledWindow != null) {
+ mFilledWindow.close();
+ mFilledWindow = null;
}
}
@@ -118,7 +115,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
mCursor = null;
}
- closeWindowForNonWindowedCursorLocked();
+ closeFilledWindowLocked();
}
private void throwIfCursorIsClosed() {
@@ -139,30 +136,24 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
synchronized (mLock) {
throwIfCursorIsClosed();
- CursorWindow window;
- if (mCursor instanceof AbstractWindowedCursor) {
- AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor)mCursor;
- window = windowedCursor.getWindow();
- if (window == null) {
- window = new CursorWindow(mProviderName, false /*localOnly*/);
- windowedCursor.setWindow(window);
- }
+ if (!mCursor.moveToPosition(startPos)) {
+ closeFilledWindowLocked();
+ return null;
+ }
- mCursor.moveToPosition(startPos);
+ CursorWindow window = mCursor.getWindow();
+ if (window != null) {
+ closeFilledWindowLocked();
} else {
- window = mWindowForNonWindowedCursor;
+ window = mFilledWindow;
if (window == null) {
- window = new CursorWindow(mProviderName, false /*localOnly*/);
- mWindowForNonWindowedCursor = window;
- }
-
- mCursor.moveToPosition(startPos);
-
- if (!mWindowForNonWindowedCursorWasFilled
- || startPos < window.getStartPosition()
+ mFilledWindow = new CursorWindow(mProviderName);
+ window = mFilledWindow;
+ mCursor.fillWindow(startPos, window);
+ } else if (startPos < window.getStartPosition()
|| startPos >= window.getStartPosition() + window.getNumRows()) {
+ window.clear();
mCursor.fillWindow(startPos, window);
- mWindowForNonWindowedCursorWasFilled = true;
}
}
@@ -211,7 +202,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
mCursor.deactivate();
}
- closeWindowForNonWindowedCursorLocked();
+ closeFilledWindowLocked();
}
}
@@ -227,7 +218,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
synchronized (mLock) {
throwIfCursorIsClosed();
- closeWindowForNonWindowedCursorLocked();
+ closeFilledWindowLocked();
try {
if (!mCursor.requery()) {
diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java
index a18a721..9c93324 100644
--- a/core/java/android/database/CursorWindow.java
+++ b/core/java/android/database/CursorWindow.java
@@ -31,8 +31,8 @@ import android.util.SparseIntArray;
/**
* A buffer containing multiple cursor rows.
* <p>
- * A {@link CursorWindow} is read-write when created and used locally. When sent
- * to a remote process (by writing it to a {@link Parcel}), the remote process
+ * A {@link CursorWindow} is read-write when initially created and used locally.
+ * When sent to a remote process (by writing it to a {@link Parcel}), the remote process
* receives a read-only view of the cursor window. Typically the cursor window
* will be allocated by the producer, filled with data, and then sent to the
* consumer for reading.
@@ -58,8 +58,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
private final CloseGuard mCloseGuard = CloseGuard.get();
- private static native int nativeCreate(String name,
- int cursorWindowSize, boolean localOnly);
+ private static native int nativeCreate(String name, int cursorWindowSize);
private static native int nativeCreateFromParcel(Parcel parcel);
private static native void nativeDispose(int windowPtr);
private static native void nativeWriteToParcel(int windowPtr, Parcel parcel);
@@ -93,14 +92,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </p>
*
* @param name The name of the cursor window, or null if none.
- * @param localWindow True if this window will be used in this process only,
- * false if it might be sent to another processes.
- *
- * @hide
*/
- public CursorWindow(String name, boolean localWindow) {
+ public CursorWindow(String name) {
mStartPos = 0;
- mWindowPtr = nativeCreate(name, sCursorWindowSize, localWindow);
+ mWindowPtr = nativeCreate(name, sCursorWindowSize);
if (mWindowPtr == 0) {
throw new CursorWindowAllocationException("Cursor window allocation of " +
(sCursorWindowSize / 1024) + " kb failed. " + printStats());
@@ -117,10 +112,14 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </p>
*
* @param localWindow True if this window will be used in this process only,
- * false if it might be sent to another processes.
+ * false if it might be sent to another processes. This argument is ignored.
+ *
+ * @deprecated There is no longer a distinction between local and remote
+ * cursor windows. Use the {@link #CursorWindow(String)} constructor instead.
*/
+ @Deprecated
public CursorWindow(boolean localWindow) {
- this(null, localWindow);
+ this((String)null);
}
private CursorWindow(Parcel source) {
@@ -272,8 +271,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Returns true if the field at the specified row and column index
* has type {@link Cursor#FIELD_TYPE_NULL}.
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if the field has type {@link Cursor#FIELD_TYPE_NULL}.
* @deprecated Use {@link #getType(int, int)} instead.
@@ -287,8 +285,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Returns true if the field at the specified row and column index
* has type {@link Cursor#FIELD_TYPE_BLOB} or {@link Cursor#FIELD_TYPE_NULL}.
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if the field has type {@link Cursor#FIELD_TYPE_BLOB} or
* {@link Cursor#FIELD_TYPE_NULL}.
@@ -304,8 +301,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Returns true if the field at the specified row and column index
* has type {@link Cursor#FIELD_TYPE_INTEGER}.
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if the field has type {@link Cursor#FIELD_TYPE_INTEGER}.
* @deprecated Use {@link #getType(int, int)} instead.
@@ -319,8 +315,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Returns true if the field at the specified row and column index
* has type {@link Cursor#FIELD_TYPE_FLOAT}.
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if the field has type {@link Cursor#FIELD_TYPE_FLOAT}.
* @deprecated Use {@link #getType(int, int)} instead.
@@ -334,8 +329,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Returns true if the field at the specified row and column index
* has type {@link Cursor#FIELD_TYPE_STRING} or {@link Cursor#FIELD_TYPE_NULL}.
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if the field has type {@link Cursor#FIELD_TYPE_STRING}
* or {@link Cursor#FIELD_TYPE_NULL}.
@@ -360,8 +354,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </ul>
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The field type.
*/
@@ -391,8 +384,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </ul>
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as a byte array.
*/
@@ -427,8 +419,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </ul>
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as a string.
*/
@@ -466,8 +457,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </ul>
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @param buffer The {@link CharArrayBuffer} to hold the string. It is automatically
* resized if the requested string is larger than the buffer's current capacity.
@@ -502,8 +492,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </ul>
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as a <code>long</code>.
*/
@@ -535,8 +524,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* </ul>
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as a <code>double</code>.
*/
@@ -557,8 +545,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* result to <code>short</code>.
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as a <code>short</code>.
*/
@@ -574,8 +561,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* result to <code>int</code>.
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as an <code>int</code>.
*/
@@ -591,8 +577,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* result to <code>float</code>.
* </p>
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return The value of the field as an <code>float</code>.
*/
@@ -604,8 +589,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Copies a byte array into the field at the specified row and column index.
*
* @param value The value to store.
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if successful.
*/
@@ -622,8 +606,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Copies a string into the field at the specified row and column index.
*
* @param value The value to store.
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if successful.
*/
@@ -640,8 +623,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* Puts a long integer into the field at the specified row and column index.
*
* @param value The value to store.
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if successful.
*/
@@ -659,8 +641,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* specified row and column index.
*
* @param value The value to store.
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if successful.
*/
@@ -676,8 +657,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
/**
* Puts a null value into the field at the specified row and column index.
*
- * @param row The zero-based row index, relative to the cursor window's
- * start position ({@link #getStartPosition()}).
+ * @param row The zero-based row index.
* @param column The zero-based column index.
* @return True if successful.
*/
diff --git a/core/java/android/database/CursorWrapper.java b/core/java/android/database/CursorWrapper.java
index 320733e..7baeb8c 100644
--- a/core/java/android/database/CursorWrapper.java
+++ b/core/java/android/database/CursorWrapper.java
@@ -25,9 +25,13 @@ import android.os.Bundle;
* use for this class is to extend a cursor while overriding only a subset of its methods.
*/
public class CursorWrapper implements Cursor {
+ /** @hide */
+ protected final Cursor mCursor;
- private final Cursor mCursor;
-
+ /**
+ * Creates a cursor wrapper.
+ * @param cursor The underlying cursor to wrap.
+ */
public CursorWrapper(Cursor cursor) {
mCursor = cursor;
}
diff --git a/core/java/android/database/DatabaseUtils.java b/core/java/android/database/DatabaseUtils.java
index 8e6f699..a10ca15 100644
--- a/core/java/android/database/DatabaseUtils.java
+++ b/core/java/android/database/DatabaseUtils.java
@@ -237,7 +237,8 @@ public class DatabaseUtils {
return Cursor.FIELD_TYPE_BLOB;
} else if (obj instanceof Float || obj instanceof Double) {
return Cursor.FIELD_TYPE_FLOAT;
- } else if (obj instanceof Long || obj instanceof Integer) {
+ } else if (obj instanceof Long || obj instanceof Integer
+ || obj instanceof Short || obj instanceof Byte) {
return Cursor.FIELD_TYPE_INTEGER;
} else {
return Cursor.FIELD_TYPE_STRING;
@@ -245,6 +246,82 @@ public class DatabaseUtils {
}
/**
+ * Fills the specified cursor window by iterating over the contents of the cursor.
+ * The window is filled until the cursor is exhausted or the window runs out
+ * of space.
+ *
+ * The original position of the cursor is left unchanged by this operation.
+ *
+ * @param cursor The cursor that contains the data to put in the window.
+ * @param position The start position for filling the window.
+ * @param window The window to fill.
+ * @hide
+ */
+ public static void cursorFillWindow(final Cursor cursor,
+ int position, final CursorWindow window) {
+ if (position < 0 || position >= cursor.getCount()) {
+ return;
+ }
+ window.acquireReference();
+ try {
+ final int oldPos = cursor.getPosition();
+ final int numColumns = cursor.getColumnCount();
+ window.clear();
+ window.setStartPosition(position);
+ window.setNumColumns(numColumns);
+ if (cursor.moveToPosition(position)) {
+ do {
+ if (!window.allocRow()) {
+ break;
+ }
+ for (int i = 0; i < numColumns; i++) {
+ final int type = cursor.getType(i);
+ final boolean success;
+ switch (type) {
+ case Cursor.FIELD_TYPE_NULL:
+ success = window.putNull(position, i);
+ break;
+
+ case Cursor.FIELD_TYPE_INTEGER:
+ success = window.putLong(cursor.getLong(i), position, i);
+ break;
+
+ case Cursor.FIELD_TYPE_FLOAT:
+ success = window.putDouble(cursor.getDouble(i), position, i);
+ break;
+
+ case Cursor.FIELD_TYPE_BLOB: {
+ final byte[] value = cursor.getBlob(i);
+ success = value != null ? window.putBlob(value, position, i)
+ : window.putNull(position, i);
+ break;
+ }
+
+ default: // assume value is convertible to String
+ case Cursor.FIELD_TYPE_STRING: {
+ final String value = cursor.getString(i);
+ success = value != null ? window.putString(value, position, i)
+ : window.putNull(position, i);
+ break;
+ }
+ }
+ if (!success) {
+ window.freeLastRow();
+ break;
+ }
+ }
+ position += 1;
+ } while (cursor.moveToNext());
+ }
+ cursor.moveToPosition(oldPos);
+ } catch (IllegalStateException e){
+ // simply ignore it
+ } finally {
+ window.releaseReference();
+ }
+ }
+
+ /**
* Appends an SQL string to the given StringBuilder, including the opening
* and closing single quotes. Any single quotes internal to sqlString will
* be escaped.
diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java
index bdb96b1..dafbc79 100644
--- a/core/java/android/database/sqlite/SQLiteCompiledSql.java
+++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java
@@ -49,7 +49,7 @@ import android.util.Log;
/** the following are for debugging purposes */
private String mSqlStmt = null;
- private Throwable mStackTrace = null;
+ private final Throwable mStackTrace;
/** when in cache and is in use, this member is set */
private boolean mInUse = false;
@@ -59,7 +59,11 @@ import android.util.Log;
db.verifyLockOwner();
mDatabase = db;
mSqlStmt = sql;
- mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
+ if (StrictMode.vmSqliteObjectLeaksEnabled()) {
+ mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
+ } else {
+ mStackTrace = null;
+ }
nHandle = db.mNativeHandle;
native_compile(sql);
}
@@ -112,7 +116,7 @@ import android.util.Log;
// but if the database itself is not closed and is GC'ed, then
// all sub-objects attached to the database could end up getting GC'ed too.
// in that case, don't print any warning.
- if (mInUse && StrictMode.vmSqliteObjectLeaksEnabled()) {
+ if (mInUse && mStackTrace != null) {
int len = mSqlStmt.length();
StrictMode.onSqliteObjectLeaked(
"Releasing statement in a finalizer. Please ensure " +
diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java
index a1c36e2..c24acd4 100644
--- a/core/java/android/database/sqlite/SQLiteCursor.java
+++ b/core/java/android/database/sqlite/SQLiteCursor.java
@@ -95,7 +95,11 @@ public class SQLiteCursor extends AbstractWindowedCursor {
if (query.mDatabase == null) {
throw new IllegalArgumentException("query.mDatabase cannot be null");
}
- mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
+ if (StrictMode.vmSqliteObjectLeaksEnabled()) {
+ mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
+ } else {
+ mStackTrace = null;
+ }
mDriver = driver;
mEditTable = editTable;
mColumnNameMap = null;
@@ -155,7 +159,7 @@ public class SQLiteCursor extends AbstractWindowedCursor {
}
private void fillWindow(int startPos) {
- clearOrCreateLocalWindow(getDatabase().getPath());
+ clearOrCreateWindow(getDatabase().getPath());
mWindow.setStartPosition(startPos);
int count = getQuery().fillWindow(mWindow);
if (startPos == 0) { // fillWindow returns count(*) only for startPos = 0
@@ -319,7 +323,7 @@ public class SQLiteCursor extends AbstractWindowedCursor {
try {
// if the cursor hasn't been closed yet, close it first
if (mWindow != null) {
- if (StrictMode.vmSqliteObjectLeaksEnabled()) {
+ if (mStackTrace != null) {
int len = mQuery.mSql.length();
StrictMode.onSqliteObjectLeaked(
"Finalizing a Cursor that has not been deactivated or closed. " +
diff --git a/core/java/android/database/sqlite/package.html b/core/java/android/database/sqlite/package.html
index ff0f9f5..ceed171 100644
--- a/core/java/android/database/sqlite/package.html
+++ b/core/java/android/database/sqlite/package.html
@@ -3,7 +3,7 @@
Contains the SQLite database management
classes that an application would use to manage its own private database.
<p>
-Applications use these classes to maange private databases. If creating a
+Applications use these classes to manage private databases. If creating a
content provider, you will probably have to use these classes to create and
manage your own database to store content. See <a
href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> to learn
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index fe0106d..33310df 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -768,61 +768,6 @@ public final class NfcAdapter {
}
/**
- * TODO: Remove this once pre-built apk's (Maps, Youtube etc) are updated
- * @deprecated use {@link CreateNdefMessageCallback} or {@link OnNdefPushCompleteCallback}
- * @hide
- */
- @Deprecated
- public interface NdefPushCallback {
- /**
- * @deprecated use {@link CreateNdefMessageCallback} instead
- */
- @Deprecated
- NdefMessage createMessage();
- /**
- * @deprecated use{@link OnNdefPushCompleteCallback} instead
- */
- @Deprecated
- void onMessagePushed();
- }
-
- /**
- * TODO: Remove this
- * Converts new callbacks to old callbacks.
- */
- static final class LegacyCallbackWrapper implements CreateNdefMessageCallback,
- OnNdefPushCompleteCallback {
- final NdefPushCallback mLegacyCallback;
- LegacyCallbackWrapper(NdefPushCallback legacyCallback) {
- mLegacyCallback = legacyCallback;
- }
- @Override
- public void onNdefPushComplete(NfcEvent event) {
- mLegacyCallback.onMessagePushed();
- }
- @Override
- public NdefMessage createNdefMessage(NfcEvent event) {
- return mLegacyCallback.createMessage();
- }
- }
-
- /**
- * TODO: Remove this once pre-built apk's (Maps, Youtube etc) are updated
- * @deprecated use {@link #setNdefPushMessageCallback} instead
- * @hide
- */
- @Deprecated
- public void enableForegroundNdefPush(Activity activity, final NdefPushCallback callback) {
- if (activity == null || callback == null) {
- throw new NullPointerException();
- }
- enforceResumed(activity);
- LegacyCallbackWrapper callbackWrapper = new LegacyCallbackWrapper(callback);
- mNfcActivityManager.setNdefPushMessageCallback(activity, callbackWrapper);
- mNfcActivityManager.setOnNdefPushCompleteCallback(activity, callbackWrapper);
- }
-
- /**
* Enable NDEF Push feature.
* <p>This API is for the Settings application.
* @hide
diff --git a/core/java/android/os/CountDownTimer.java b/core/java/android/os/CountDownTimer.java
index 0c5c615..15e6405 100644
--- a/core/java/android/os/CountDownTimer.java
+++ b/core/java/android/os/CountDownTimer.java
@@ -25,7 +25,7 @@ import android.util.Log;
* Example of showing a 30 second countdown in a text field:
*
* <pre class="prettyprint">
- * new CountdownTimer(30000, 1000) {
+ * new CountDownTimer(30000, 1000) {
*
* public void onTick(long millisUntilFinished) {
* mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 4d7a9bb..cc2fa85 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -35,7 +35,6 @@ import dalvik.system.VMDebug;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@@ -902,15 +901,13 @@ public final class StrictMode {
return false;
}
+ // Thread policy controls BlockGuard.
int threadPolicyMask = StrictMode.DETECT_DISK_WRITE |
StrictMode.DETECT_DISK_READ |
StrictMode.DETECT_NETWORK;
if (!IS_USER_BUILD) {
threadPolicyMask |= StrictMode.PENALTY_DROPBOX;
- if (IS_ENG_BUILD) {
- threadPolicyMask |= StrictMode.PENALTY_LOG;
- }
}
if (doFlashes) {
threadPolicyMask |= StrictMode.PENALTY_FLASH;
@@ -918,6 +915,8 @@ public final class StrictMode {
StrictMode.setThreadPolicyMask(threadPolicyMask);
+ // VM Policy controls CloseGuard, detection of Activity leaks,
+ // and instance counting.
if (IS_USER_BUILD) {
setCloseGuardEnabled(false);
} else {
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index 4b4d308..b14ca2b 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -72,7 +72,7 @@ import android.util.Log;
* {@link Calendars#MAX_REMINDERS} which is set by the Sync Adapter that owns
* the given calendar. Reminders are specified in minutes before the event and
* have a type.</li>
- * <li>The {@link ExtendedProperties} table hold opaque data fields used by the
+ * <li>The {@link ExtendedProperties} table holds opaque data fields used by the
* sync adapter. The provider takes no action with items in this table except to
* delete them when their related events are deleted.</li>
* </ul>
@@ -300,8 +300,26 @@ public final class CalendarContract {
public static final String CALENDAR_COLOR = "calendar_color";
/**
+ * An index for looking up a color from the {@link Colors} table. NULL
+ * or an empty string are reserved for indicating that the calendar does
+ * not use an index for looking up the color. The provider will update
+ * {@link #CALENDAR_COLOR} automatically when a valid index is written
+ * to this column. The index must reference an existing row of the
+ * {@link Colors} table. @see Colors
+ * <P>
+ * Type: TEXT
+ * </P>
+ * TODO UNHIDE
+ *
+ * @hide
+ */
+ public static final String CALENDAR_COLOR_INDEX = "calendar_color_index";
+
+ /**
* The display name of the calendar. Column name.
- * <P>Type: TEXT</P>
+ * <P>
+ * Type: TEXT
+ * </P>
*/
public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName";
@@ -392,6 +410,34 @@ public final class CalendarContract {
* <P>Type: TEXT</P>
*/
public static final String ALLOWED_REMINDERS = "allowedReminders";
+
+ /**
+ * A comma separated list of availability types supported for this
+ * calendar in the format "#,#,#". Valid types are
+ * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE},
+ * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only
+ * {@link Events#AVAILABILITY_BUSY} should be used to indicate that
+ * changing the availability is not supported.
+ *
+ * TODO UNHIDE, Update Calendars doc
+ *
+ * @hide
+ */
+ public static final String ALLOWED_AVAILABILITY = "allowedAvailability";
+
+ /**
+ * A comma separated list of attendee types supported for this calendar
+ * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE},
+ * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED},
+ * {@link Attendees#TYPE_RESOURCE}. Setting this field to only
+ * {@link Attendees#TYPE_NONE} should be used to indicate that changing
+ * the attendee type is not supported.
+ *
+ * TODO UNHIDE, Update Calendars doc
+ *
+ * @hide
+ */
+ public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes";
}
/**
@@ -688,13 +734,22 @@ public final class CalendarContract {
/**
* The type of attendee. Column name.
- * <P>Type: Integer (one of {@link #TYPE_REQUIRED}, {@link #TYPE_OPTIONAL})</P>
+ * <P>
+ * Type: Integer (one of {@link #TYPE_REQUIRED}, {@link #TYPE_OPTIONAL}
+ * </P>
*/
public static final String ATTENDEE_TYPE = "attendeeType";
public static final int TYPE_NONE = 0;
public static final int TYPE_REQUIRED = 1;
public static final int TYPE_OPTIONAL = 2;
+ /**
+ * This specifies that an attendee is a resource, such as a room, and
+ * not an actual person. TODO UNHIDE and add to ATTENDEE_TYPE comment
+ *
+ * @hide
+ */
+ public static final int TYPE_RESOURCE = 3;
/**
* The attendance status of the attendee. Column name.
@@ -787,13 +842,29 @@ public final class CalendarContract {
public static final String EVENT_LOCATION = "eventLocation";
/**
- * A secondary color for the individual event. Reserved for future use.
- * Column name.
+ * A secondary color for the individual event. This should only be
+ * updated by the sync adapter for a given account.
* <P>Type: INTEGER</P>
*/
public static final String EVENT_COLOR = "eventColor";
/**
+ * A secondary color index for the individual event. NULL or an empty
+ * string are reserved for indicating that the event does not use an
+ * index for looking up the color. The provider will update
+ * {@link #EVENT_COLOR} automatically when a valid index is written to
+ * this column. The index must reference an existing row of the
+ * {@link Colors} table. @see Colors
+ * <P>
+ * Type: TEXT
+ * </P>
+ * TODO UNHIDE
+ *
+ * @hide
+ */
+ public static final String EVENT_COLOR_INDEX = "eventColor_index";
+
+ /**
* The event status. Column name.
* <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P>
*/
@@ -964,6 +1035,15 @@ public final class CalendarContract {
* other events.
*/
public static final int AVAILABILITY_FREE = 1;
+ /**
+ * Indicates that the owner's availability may change, but should be
+ * considered busy time that will conflict.
+ *
+ * TODO UNHIDE
+ *
+ * @hide
+ */
+ public static final int AVAILABILITY_TENTATIVE = 2;
/**
* Whether the event has an alarm or not. Column name.
@@ -1335,7 +1415,9 @@ public final class CalendarContract {
* <dd>When inserting a new event the following fields must be included:
* <ul>
* <li>dtstart</li>
- * <li>dtend -or- a (rrule or rdate) and a duration</li>
+ * <li>dtend if the event is non-recurring</li>
+ * <li>duration if the event is recurring</li>
+ * <li>rrule or rdate if the event is recurring</li>
* <li>a calendar_id</li>
* </ul>
* There are also further requirements when inserting or updating an event.
@@ -2224,6 +2306,83 @@ public final class CalendarContract {
}
}
+ /**
+ * @hide
+ * TODO UNHIDE
+ */
+ protected interface ColorsColumns extends SyncStateContract.Columns {
+
+ /**
+ * The type of color, which describes how it should be used. Valid types
+ * are {@link #TYPE_CALENDAR} and {@link #TYPE_EVENT}. Column name.
+ * <P>
+ * Type: INTEGER (NOT NULL)
+ * </P>
+ */
+ public static final String COLOR_TYPE = "color_type";
+
+ /**
+ * This indicateds a color that can be used for calendars.
+ */
+ public static final int TYPE_CALENDAR = 0;
+ /**
+ * This indicates a color that can be used for events.
+ */
+ public static final int TYPE_EVENT = 1;
+
+ /**
+ * The index used to reference this color. This can be any non-empty
+ * string, but must be unique for a given {@link #ACCOUNT_TYPE} and
+ * {@link #ACCOUNT_NAME}. Column name.
+ * <P>
+ * Type: TEXT
+ * </P>
+ */
+ public static final String COLOR_INDEX = "color_index";
+
+ /**
+ * The color as an 8-bit ARGB integer value. Colors should specify alpha
+ * as fully opaque (eg 0xFF993322) as the alpha may be ignored or
+ * modified for display. It is reccomended that colors be usable with
+ * light (near white) text. Apps should not depend on that assumption,
+ * however. Column name.
+ * <P>
+ * Type: INTEGER (NOT NULL)
+ * </P>
+ */
+ public static final String COLOR = "color";
+
+ }
+
+ /**
+ * Fields for accessing colors available for a given account. Colors are
+ * referenced by {@link #COLOR_INDEX} which must be unique for a given
+ * account name/type. These values can only be updated by the sync
+ * adapter. Only {@link #COLOR} may be updated after the initial insert. In
+ * addition, a row can only be deleted once all references to that color
+ * have been removed from the {@link Calendars} or {@link Events} tables.
+ * TODO UNHIDE
+ *
+ * @hide
+ */
+ public static final class Colors implements ColorsColumns {
+ /**
+ * @hide
+ */
+ public static final String TABLE_NAME = "Colors";
+ /**
+ * The Uri for querying color information
+ */
+ @SuppressWarnings("hiding")
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors");
+
+ /**
+ * This utility class cannot be instantiated
+ */
+ private Colors() {
+ }
+ }
+
protected interface ExtendedPropertiesColumns {
/**
* The event the extended property belongs to. Column name.
@@ -2247,7 +2406,7 @@ public final class CalendarContract {
/**
* Fields for accessing the Extended Properties. This is a generic set of
- * name/value pairs for use by sync adapters or apps to add extra
+ * name/value pairs for use by sync adapters to add extra
* information to events. There are three writable columns and all three
* must be present when inserting a new value. They are:
* <ul>
diff --git a/core/java/android/text/DynamicLayout.java b/core/java/android/text/DynamicLayout.java
index f82c9c4..026af34 100644
--- a/core/java/android/text/DynamicLayout.java
+++ b/core/java/android/text/DynamicLayout.java
@@ -281,9 +281,9 @@ extends Layout
}
reflowed.generate(text, where, where + after,
- getPaint(), getWidth(), getAlignment(), getTextDirectionHeuristic(),
- getSpacingMultiplier(), getSpacingAdd(),
- false, true, mEllipsizedWidth, mEllipsizeAt);
+ getPaint(), getWidth(), getTextDirectionHeuristic(), getSpacingMultiplier(),
+ getSpacingAdd(), false,
+ true, mEllipsizedWidth, mEllipsizeAt);
int n = reflowed.getLineCount();
// If the new layout has a blank line at the end, but it is not
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 583cbe6..1dd4c8a 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -137,9 +137,9 @@ public class StaticLayout extends Layout {
mMeasured = MeasuredText.obtain();
- generate(source, bufstart, bufend, paint, outerwidth, align, textDir,
- spacingmult, spacingadd, includepad, includepad,
- ellipsizedWidth, ellipsize);
+ generate(source, bufstart, bufend, paint, outerwidth, textDir, spacingmult,
+ spacingadd, includepad, includepad, ellipsizedWidth,
+ ellipsize);
mMeasured = MeasuredText.recycle(mMeasured);
mFontMetricsInt = null;
@@ -157,10 +157,10 @@ public class StaticLayout extends Layout {
/* package */ void generate(CharSequence source, int bufStart, int bufEnd,
TextPaint paint, int outerWidth,
- Alignment align, TextDirectionHeuristic textDir,
- float spacingmult, float spacingadd,
- boolean includepad, boolean trackpad,
- float ellipsizedWidth, TextUtils.TruncateAt ellipsize) {
+ TextDirectionHeuristic textDir, float spacingmult,
+ float spacingadd, boolean includepad,
+ boolean trackpad, float ellipsizedWidth,
+ TextUtils.TruncateAt ellipsize) {
mLineCount = 0;
int v = 0;
@@ -328,9 +328,7 @@ public class StaticLayout extends Layout {
whichPaint = mWorkPaint;
}
- float wid = bm.getWidth() *
- -whichPaint.ascent() /
- bm.getHeight();
+ float wid = bm.getWidth() * -whichPaint.ascent() / bm.getHeight();
w += wid;
hasTabOrEmoji = true;
@@ -398,67 +396,49 @@ public class StaticLayout extends Layout {
okBottom = fitBottom;
}
} else {
- final boolean moreChars = (j + 1 < spanEnd);
- if (ok != here) {
- // Log.e("text", "output ok " + here + " to " +ok);
+ final boolean moreChars = (j + 1 < spanEnd);
+ int endPos;
+ int above, below, top, bottom;
+ float currentTextWidth;
- while (ok < spanEnd && chs[ok - paraStart] == CHAR_SPACE) {
- ok++;
- }
+ if (ok != here) {
+ // If it is a space that makes the length exceed width, cut here
+ if (c == CHAR_SPACE) ok = j + 1;
- v = out(source,
- here, ok,
- okAscent, okDescent, okTop, okBottom,
- v,
- spacingmult, spacingadd, chooseHt,
- chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- ok == bufEnd, includepad, trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth, okWidth,
- paint, moreChars);
-
- here = ok;
- } else if (fit != here) {
- // Log.e("text", "output fit " + here + " to " +fit);
- v = out(source,
- here, fit,
- fitAscent, fitDescent,
- fitTop, fitBottom,
- v,
- spacingmult, spacingadd, chooseHt,
- chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- fit == bufEnd, includepad, trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth, fitWidth,
- paint, moreChars);
-
- here = fit;
- } else {
- // Log.e("text", "output one " + here + " to " +(here + 1));
- // XXX not sure why the existing fm wasn't ok.
- // measureText(paint, mWorkPaint,
- // source, here, here + 1, fm, tab,
- // null);
-
- v = out(source,
- here, here+1,
- fm.ascent, fm.descent,
- fm.top, fm.bottom,
- v,
- spacingmult, spacingadd, chooseHt,
- chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- here + 1 == bufEnd, includepad,
- trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth,
- widths[here - paraStart], paint, moreChars);
-
- here = here + 1;
+ while (ok < spanEnd && chs[ok - paraStart] == CHAR_SPACE) {
+ ok++;
}
+ endPos = ok;
+ above = okAscent;
+ below = okDescent;
+ top = okTop;
+ bottom = okBottom;
+ currentTextWidth = okWidth;
+ } else if (fit != here) {
+ endPos = fit;
+ above = fitAscent;
+ below = fitDescent;
+ top = fitTop;
+ bottom = fitBottom;
+ currentTextWidth = fitWidth;
+ } else {
+ endPos = here + 1;
+ above = fm.ascent;
+ below = fm.descent;
+ top = fm.top;
+ bottom = fm.bottom;
+ currentTextWidth = widths[here - paraStart];
+ }
+
+ v = out(source, here, endPos,
+ above, below, top, bottom,
+ v, spacingmult, spacingadd, chooseHt,chooseHtv, fm, hasTabOrEmoji,
+ needMultiply, chdirs, dir, easy, bufEnd, includepad, trackpad,
+ chs, widths, paraStart, ellipsize, ellipsizedWidth,
+ currentTextWidth, paint, moreChars);
+ here = endPos;
+
if (here < spanStart) {
// didn't output all the text for this span
// we've measured the raw widths, though, so
@@ -501,10 +481,10 @@ public class StaticLayout extends Layout {
v,
spacingmult, spacingadd, chooseHt,
chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- paraEnd == bufEnd, includepad, trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth, w, paint, paraEnd != bufEnd);
+ needMultiply, chdirs, dir, easy, bufEnd,
+ includepad, trackpad, chs,
+ widths, paraStart, ellipsize,
+ ellipsizedWidth, w, paint, paraEnd != bufEnd);
}
paraStart = paraEnd;
@@ -525,10 +505,10 @@ public class StaticLayout extends Layout {
v,
spacingmult, spacingadd, null,
null, fm, false,
- needMultiply, bufEnd, null, DEFAULT_DIR, true,
- true, includepad, trackpad,
- null, null, bufStart,
- ellipsize, ellipsizedWidth, 0, paint, false);
+ needMultiply, null, DEFAULT_DIR, true, bufEnd,
+ includepad, trackpad, null,
+ null, bufStart, ellipsize,
+ ellipsizedWidth, 0, paint, false);
}
}
@@ -628,12 +608,12 @@ public class StaticLayout extends Layout {
float spacingmult, float spacingadd,
LineHeightSpan[] chooseHt, int[] chooseHtv,
Paint.FontMetricsInt fm, boolean hasTabOrEmoji,
- boolean needMultiply, int pstart, byte[] chdirs,
- int dir, boolean easy, boolean last,
- boolean includePad, boolean trackPad,
- char[] chs, float[] widths, int widthStart,
- TextUtils.TruncateAt ellipsize, float ellipsisWidth,
- float textWidth, TextPaint paint, boolean moreChars) {
+ boolean needMultiply, byte[] chdirs, int dir,
+ boolean easy, int bufEnd, boolean includePad,
+ boolean trackPad, char[] chs,
+ float[] widths, int widthStart, TextUtils.TruncateAt ellipsize,
+ float ellipsisWidth, float textWidth,
+ TextPaint paint, boolean moreChars) {
int j = mLineCount;
int off = j * mColumns;
int want = off + mColumns + TOP;
@@ -683,7 +663,7 @@ public class StaticLayout extends Layout {
above = top;
}
}
- if (last) {
+ if (end == bufEnd) {
if (trackPad) {
mBottomPadding = bottom - below;
}
diff --git a/core/java/android/text/method/ArrowKeyMovementMethod.java b/core/java/android/text/method/ArrowKeyMovementMethod.java
index e93039b..4ec4bc4 100644
--- a/core/java/android/text/method/ArrowKeyMovementMethod.java
+++ b/core/java/android/text/method/ArrowKeyMovementMethod.java
@@ -197,16 +197,18 @@ public class ArrowKeyMovementMethod extends BaseMovementMethod implements Moveme
@Override
protected boolean leftWord(TextView widget, Spannable buffer) {
final int selectionEnd = widget.getSelectionEnd();
- mWordIterator.setCharSequence(buffer, selectionEnd, selectionEnd);
- return Selection.moveToPreceding(buffer, mWordIterator, isSelecting(buffer));
+ final WordIterator wordIterator = widget.getWordIterator();
+ wordIterator.setCharSequence(buffer, selectionEnd, selectionEnd);
+ return Selection.moveToPreceding(buffer, wordIterator, isSelecting(buffer));
}
/** {@hide} */
@Override
protected boolean rightWord(TextView widget, Spannable buffer) {
final int selectionEnd = widget.getSelectionEnd();
- mWordIterator.setCharSequence(buffer, selectionEnd, selectionEnd);
- return Selection.moveToFollowing(buffer, mWordIterator, isSelecting(buffer));
+ final WordIterator wordIterator = widget.getWordIterator();
+ wordIterator.setCharSequence(buffer, selectionEnd, selectionEnd);
+ return Selection.moveToFollowing(buffer, wordIterator, isSelecting(buffer));
}
@Override
@@ -322,8 +324,6 @@ public class ArrowKeyMovementMethod extends BaseMovementMethod implements Moveme
return sInstance;
}
- private WordIterator mWordIterator = new WordIterator();
-
private static final Object LAST_TAP_DOWN = new Object();
private static ArrowKeyMovementMethod sInstance;
}
diff --git a/core/java/android/text/style/SuggestionSpan.java b/core/java/android/text/style/SuggestionSpan.java
index 6e95016..ed2af10 100644
--- a/core/java/android/text/style/SuggestionSpan.java
+++ b/core/java/android/text/style/SuggestionSpan.java
@@ -60,7 +60,6 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan {
* Sets this flag if the auto correction is about to be applied to a word/text
* that the user is typing/composing. This type of suggestion is rendered differently
* to indicate the auto correction is happening.
- * @hide
*/
public static final int FLAG_AUTO_CORRECTION = 0x0004;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 61b13d5..fea79d5 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4219,6 +4219,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
*
* @attr ref android.R.styleable#View_contentDescription
*/
+ @RemotableViewMethod
public void setContentDescription(CharSequence contentDescription) {
mContentDescription = contentDescription;
}
@@ -10114,8 +10115,20 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
mLocalDirtyRect.setEmpty();
}
+ // The layer is not valid if the underlying GPU resources cannot be allocated
+ if (!mHardwareLayer.isValid()) {
+ return null;
+ }
+
HardwareCanvas currentCanvas = mAttachInfo.mHardwareCanvas;
final HardwareCanvas canvas = mHardwareLayer.start(currentCanvas);
+
+ // Make sure all the GPU resources have been properly allocated
+ if (canvas == null) {
+ mHardwareLayer.end(currentCanvas);
+ return null;
+ }
+
mAttachInfo.mHardwareCanvas = canvas;
try {
canvas.setViewport(width, height);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 081e267..a36aecb 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -287,7 +287,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
final AccessibilityManager mAccessibilityManager;
- AccessibilityInteractionController mAccessibilityInteractionContrtoller;
+ AccessibilityInteractionController mAccessibilityInteractionController;
AccessibilityInteractionConnectionManager mAccessibilityInteractionConnectionManager;
@@ -431,20 +431,17 @@ public final class ViewRootImpl extends Handler implements ViewParent,
}
}
- // If the application owns the surface, don't enable hardware acceleration
- if (mSurfaceHolder == null) {
- enableHardwareAcceleration(attrs);
- }
-
CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get();
mTranslator = compatibilityInfo.getTranslator();
- if (mTranslator != null) {
- mSurface.setCompatibilityTranslator(mTranslator);
+ // If the application owns the surface, don't enable hardware acceleration
+ if (mSurfaceHolder == null) {
+ enableHardwareAcceleration(attrs);
}
boolean restore = false;
if (mTranslator != null) {
+ mSurface.setCompatibilityTranslator(mTranslator);
restore = true;
attrs.backup();
mTranslator.translateWindowLayout(attrs);
@@ -596,6 +593,9 @@ public final class ViewRootImpl extends Handler implements ViewParent,
mAttachInfo.mHardwareAccelerated = false;
mAttachInfo.mHardwareAccelerationRequested = false;
+ // Don't enable hardware acceleration when the application is in compatibility mode
+ if (mTranslator != null) return;
+
// Try to enable hardware acceleration if requested
final boolean hardwareAccelerated =
(attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
@@ -3526,10 +3526,10 @@ public final class ViewRootImpl extends Handler implements ViewParent,
throw new IllegalStateException("getAccessibilityInteractionController"
+ " called when there is no mView");
}
- if (mAccessibilityInteractionContrtoller == null) {
- mAccessibilityInteractionContrtoller = new AccessibilityInteractionController();
+ if (mAccessibilityInteractionController == null) {
+ mAccessibilityInteractionController = new AccessibilityInteractionController();
}
- return mAccessibilityInteractionContrtoller;
+ return mAccessibilityInteractionController;
}
private int relayoutWindow(WindowManager.LayoutParams params, int viewVisibility,
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 7671312..fa34ee7 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -293,7 +293,7 @@ public class AccessibilityNodeInfo implements Parcelable {
*/
public AccessibilityNodeInfo getParent() {
enforceSealed();
- if (!canPerformRequestOverConnection(mAccessibilityViewId)) {
+ if (!canPerformRequestOverConnection(mParentAccessibilityViewId)) {
return null;
}
AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
diff --git a/core/java/android/view/accessibility/AccessibilityRecord.java b/core/java/android/view/accessibility/AccessibilityRecord.java
index fe06d98..a4e0688 100644
--- a/core/java/android/view/accessibility/AccessibilityRecord.java
+++ b/core/java/android/view/accessibility/AccessibilityRecord.java
@@ -391,8 +391,6 @@ public class AccessibilityRecord {
* Gets the max scroll offset of the source left edge in pixels.
*
* @return The max scroll.
- *
- * @hide
*/
public int getMaxScrollX() {
return mMaxScrollX;
@@ -401,8 +399,6 @@ public class AccessibilityRecord {
* Sets the max scroll offset of the source left edge in pixels.
*
* @param maxScrollX The max scroll.
- *
- * @hide
*/
public void setMaxScrollX(int maxScrollX) {
enforceNotSealed();
@@ -413,8 +409,6 @@ public class AccessibilityRecord {
* Gets the max scroll offset of the source top edge in pixels.
*
* @return The max scroll.
- *
- * @hide
*/
public int getMaxScrollY() {
return mMaxScrollY;
@@ -424,8 +418,6 @@ public class AccessibilityRecord {
* Sets the max scroll offset of the source top edge in pixels.
*
* @param maxScrollY The max scroll.
- *
- * @hide
*/
public void setMaxScrollY(int maxScrollY) {
enforceNotSealed();
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 3ead9df..b41e6f5 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -384,14 +384,18 @@ public final class InputMethodManager {
}
}
- class ControlledInputConnectionWrapper extends IInputConnectionWrapper {
- public ControlledInputConnectionWrapper(Looper mainLooper, InputConnection conn) {
+ private static class ControlledInputConnectionWrapper extends IInputConnectionWrapper {
+ private final InputMethodManager mParentInputMethodManager;
+
+ public ControlledInputConnectionWrapper(final Looper mainLooper, final InputConnection conn,
+ final InputMethodManager inputMethodManager) {
super(mainLooper, conn);
+ mParentInputMethodManager = inputMethodManager;
}
@Override
public boolean isActive() {
- return mActive;
+ return mParentInputMethodManager.mActive;
}
}
@@ -439,7 +443,7 @@ public final class InputMethodManager {
mMainLooper = looper;
mH = new H(looper);
mIInputContext = new ControlledInputConnectionWrapper(looper,
- mDummyInputConnection);
+ mDummyInputConnection, this);
if (mInstance == null) {
mInstance = this;
@@ -1016,7 +1020,7 @@ public final class InputMethodManager {
mCursorCandStart = -1;
mCursorCandEnd = -1;
mCursorRect.setEmpty();
- servedContext = new ControlledInputConnectionWrapper(vh.getLooper(), ic);
+ servedContext = new ControlledInputConnectionWrapper(vh.getLooper(), ic, this);
} else {
servedContext = null;
}
diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java
index 793f514..5c3f089 100644
--- a/core/java/android/view/textservice/SpellCheckerSession.java
+++ b/core/java/android/view/textservice/SpellCheckerSession.java
@@ -123,7 +123,7 @@ public class SpellCheckerSession {
}
mSpellCheckerInfo = info;
mSpellCheckerSessionListenerImpl = new SpellCheckerSessionListenerImpl(mHandler);
- mInternalListener = new InternalListener();
+ mInternalListener = new InternalListener(mSpellCheckerSessionListenerImpl);
mTextServicesManager = tsm;
mIsUsed = true;
mSpellCheckerSessionListener = listener;
@@ -316,13 +316,19 @@ public class SpellCheckerSession {
public void onGetSuggestions(SuggestionsInfo[] results);
}
- private class InternalListener extends ITextServicesSessionListener.Stub {
+ private static class InternalListener extends ITextServicesSessionListener.Stub {
+ private final SpellCheckerSessionListenerImpl mParentSpellCheckerSessionListenerImpl;
+
+ public InternalListener(SpellCheckerSessionListenerImpl spellCheckerSessionListenerImpl) {
+ mParentSpellCheckerSessionListenerImpl = spellCheckerSessionListenerImpl;
+ }
+
@Override
public void onServiceConnected(ISpellCheckerSession session) {
if (DBG) {
Log.w(TAG, "SpellCheckerSession connected.");
}
- mSpellCheckerSessionListenerImpl.onServiceConnected(session);
+ mParentSpellCheckerSessionListenerImpl.onServiceConnected(session);
}
}
diff --git a/core/java/android/webkit/JniUtil.java b/core/java/android/webkit/JniUtil.java
index 7759ff3..4662040 100644
--- a/core/java/android/webkit/JniUtil.java
+++ b/core/java/android/webkit/JniUtil.java
@@ -22,6 +22,7 @@ import android.net.Uri;
import android.provider.Settings;
import android.util.Log;
+import java.io.File;
import java.io.InputStream;
class JniUtil {
@@ -79,7 +80,12 @@ class JniUtil {
checkInitialized();
if (sCacheDirectory == null) {
- sCacheDirectory = sContext.getCacheDir().getAbsolutePath();
+ File cacheDir = sContext.getCacheDir();
+ if (cacheDir == null) {
+ sCacheDirectory = "";
+ } else {
+ sCacheDirectory = cacheDir.getAbsolutePath();
+ }
}
return sCacheDirectory;
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index ae40ded..3d129f7 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -95,27 +95,33 @@ public class WebChromeClient {
public void onHideCustomView() {}
/**
- * Request the host application to create a new Webview. The host
- * application should handle placement of the new WebView in the view
- * system. The default behavior returns null.
- * @param view The WebView that initiated the callback.
- * @param dialog True if the new window is meant to be a small dialog
- * window.
- * @param userGesture True if the request was initiated by a user gesture
- * such as clicking a link.
- * @param resultMsg The message to send when done creating a new WebView.
- * Set the new WebView through resultMsg.obj which is
- * WebView.WebViewTransport() and then call
- * resultMsg.sendToTarget();
- * @return Similar to javscript dialogs, this method should return true if
- * the client is going to handle creating a new WebView. Note that
- * the WebView will halt processing if this method returns true so
- * make sure to call resultMsg.sendToTarget(). It is undefined
- * behavior to call resultMsg.sendToTarget() after returning false
- * from this method.
+ * Request the host application to create a new window. If the host
+ * application chooses to honor this request, it should return true from
+ * this method, create a new WebView to host the window, insert it into the
+ * View system and send the supplied resultMsg message to its target with
+ * the new WebView as an argument. If the host application chooses not to
+ * honor the request, it should return false from this method. The default
+ * implementation of this method does nothing and hence returns false.
+ * @param view The WebView from which the request for a new window
+ * originated.
+ * @param isDialog True if the new window should be a dialog, rather than
+ * a full-size window.
+ * @param isUserGesture True if the request was initiated by a user gesture,
+ * such as the user clicking a link.
+ * @param resultMsg The message to send when once a new WebView has been
+ * created. resultMsg.obj is a
+ * {@link WebView.WebViewTransport} object. This should be
+ * used to transport the new WebView, by calling
+ * {@link WebView.WebViewTransport#setWebView(WebView)
+ * WebView.WebViewTransport.setWebView(WebView)}.
+ * @return This method should return true if the host application will
+ * create a new window, in which case resultMsg should be sent to
+ * its target. Otherwise, this method should return false. Returning
+ * false from this method but also sending resultMsg will result in
+ * undefined behavior.
*/
- public boolean onCreateWindow(WebView view, boolean dialog,
- boolean userGesture, Message resultMsg) {
+ public boolean onCreateWindow(WebView view, boolean isDialog,
+ boolean isUserGesture, Message resultMsg) {
return false;
}
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index f1c2bde..f240a2e 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -777,7 +777,7 @@ public class WebSettings {
public void setDoubleTapZoom(int doubleTapZoom) {
if (mDoubleTapZoom != doubleTapZoom) {
mDoubleTapZoom = doubleTapZoom;
- mWebView.updateDoubleTapZoom();
+ mWebView.updateDoubleTapZoom(doubleTapZoom);
}
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index fef9b02..3731097 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2004,15 +2004,18 @@ public class WebView extends AbsoluteLayout
}
/**
- * Load the given url with the extra headers.
- * @param url The url of the resource to load.
- * @param extraHeaders The extra headers sent with this url. This should not
- * include the common headers like "user-agent". If it does, it
- * will be replaced by the intrinsic value of the WebView.
- */
- public void loadUrl(String url, Map<String, String> extraHeaders) {
+ * Load the given URL with the specified additional HTTP headers.
+ * @param url The URL of the resource to load.
+ * @param additionalHttpHeaders The additional headers to be used in the
+ * HTTP request for this URL, specified as a map from name to
+ * value. Note that if this map contains any of the headers
+ * that are set by default by the WebView, such as those
+ * controlling caching, accept types or the User-Agent, their
+ * values may be overriden by the WebView's defaults.
+ */
+ public void loadUrl(String url, Map<String, String> additionalHttpHeaders) {
checkThread();
- loadUrlImpl(url, extraHeaders);
+ loadUrlImpl(url, additionalHttpHeaders);
}
private void loadUrlImpl(String url, Map<String, String> extraHeaders) {
@@ -2025,8 +2028,8 @@ public class WebView extends AbsoluteLayout
}
/**
- * Load the given url.
- * @param url The url of the resource to load.
+ * Load the given URL.
+ * @param url The URL of the resource to load.
*/
public void loadUrl(String url) {
checkThread();
@@ -2992,8 +2995,8 @@ public class WebView extends AbsoluteLayout
/**
* Update the double-tap zoom.
*/
- /* package */ void updateDoubleTapZoom() {
- mZoomManager.updateDoubleTapZoom();
+ /* package */ void updateDoubleTapZoom(int doubleTapZoom) {
+ mZoomManager.updateDoubleTapZoom(doubleTapZoom);
}
private int computeRealHorizontalScrollRange() {
@@ -4504,6 +4507,9 @@ public class WebView extends AbsoluteLayout
if (mHeldMotionless == MOTIONLESS_FALSE) {
mPrivateHandler.sendMessageDelayed(mPrivateHandler
.obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
+ mPrivateHandler.sendMessageDelayed(mPrivateHandler
+ .obtainMessage(AWAKEN_SCROLL_BARS),
+ ViewConfiguration.getScrollDefaultDelay());
mHeldMotionless = MOTIONLESS_PENDING;
}
}
@@ -6006,6 +6012,7 @@ public class WebView extends AbsoluteLayout
mTouchMode = TOUCH_DRAG_START_MODE;
mConfirmMove = true;
mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
+ nativeSetIsScrolling(false);
} else if (mPrivateHandler.hasMessages(RELEASE_SINGLE_TAP)) {
mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
if (USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
@@ -6288,9 +6295,16 @@ public class WebView extends AbsoluteLayout
}
mLastTouchX = x;
mLastTouchY = y;
- if ((deltaX | deltaY) != 0) {
+
+ if (deltaX * deltaX + deltaY * deltaY > mTouchSlopSquare) {
mHeldMotionless = MOTIONLESS_FALSE;
+ nativeSetIsScrolling(true);
+ } else {
+ mHeldMotionless = MOTIONLESS_TRUE;
+ nativeSetIsScrolling(false);
+ keepScrollBarsVisible = true;
}
+
mLastTouchTime = eventTime;
}
@@ -6306,9 +6320,15 @@ public class WebView extends AbsoluteLayout
// keep the scrollbar on the screen even there is no scroll
awakenScrollBars(ViewConfiguration.getScrollDefaultDelay(),
false);
+ // Post a message so that we'll keep them alive while we're not scrolling.
+ mPrivateHandler.sendMessageDelayed(mPrivateHandler
+ .obtainMessage(AWAKEN_SCROLL_BARS),
+ ViewConfiguration.getScrollDefaultDelay());
// return false to indicate that we can't pan out of the
// view space
return !done;
+ } else {
+ mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
}
break;
}
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index 9151fdd..7d3cf8e 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -152,6 +152,12 @@ class ZoomManager {
private float mDisplayDensity;
/*
+ * The factor that is used to tweak the zoom scale on a double-tap,
+ * and can be changed via WebSettings. Range is from 0.75f to 1.25f.
+ */
+ private float mDoubleTapZoomFactor = 1.0f;
+
+ /*
* The scale factor that is used as the minimum increment when going from
* overview to reading level on a double tap.
*/
@@ -314,10 +320,7 @@ class ZoomManager {
* Returns the zoom scale used for reading text on a double-tap.
*/
public final float getReadingLevelScale() {
- WebSettings settings = mWebView.getSettings();
- final float doubleTapZoomFactor = settings != null
- ? settings.getDoubleTapZoom() / 100.f : 1.0f;
- return mDisplayDensity * doubleTapZoomFactor;
+ return mDisplayDensity * mDoubleTapZoomFactor;
}
public final float getInvDefaultScale() {
@@ -516,8 +519,9 @@ class ZoomManager {
return mZoomScale != 0 || mInHWAcceleratedZoom;
}
- public void updateDoubleTapZoom() {
+ public void updateDoubleTapZoom(int doubleTapZoom) {
if (mInZoomOverview) {
+ mDoubleTapZoomFactor = doubleTapZoom / 100.0f;
mTextWrapScale = getReadingLevelScale();
refreshZoomScale(true);
}
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index cf015c4..320c650 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -203,6 +203,16 @@ public class NumberPicker extends LinearLayout {
private final EditText mInputText;
/**
+ * The max height of this widget.
+ */
+ private final int mMaxHeight;
+
+ /**
+ * The max width of this widget.
+ */
+ private final int mMaxWidth;
+
+ /**
* The height of the text.
*/
private final int mTextSize;
@@ -517,6 +527,8 @@ public class NumberPicker extends LinearLayout {
getResources().getDisplayMetrics());
mSelectionDividerHeight = attributesArray.getDimensionPixelSize(
R.styleable.NumberPicker_selectionDividerHeight, defSelectionDividerHeight);
+ mMaxHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxHeight, 0);
+ mMaxWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxWidth, 0);
attributesArray.recycle();
mShowInputControlsAnimimationDuration = getResources().getInteger(
@@ -665,7 +677,38 @@ public class NumberPicker extends LinearLayout {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
+ if (mMaxHeight <= 0 && mMaxWidth <= 0) {
+ super.onLayout(changed, left, top, right, bottom);
+ } else {
+ final int msrdWdth = getMeasuredWidth();
+ final int msrdHght = getMeasuredHeight();
+
+ // Increment button at the top.
+ final int inctBtnMsrdWdth = mIncrementButton.getMeasuredWidth();
+ final int incrBtnLeft = (msrdWdth - inctBtnMsrdWdth) / 2;
+ final int incrBtnTop = 0;
+ final int incrBtnRight = incrBtnLeft + inctBtnMsrdWdth;
+ final int incrBtnBottom = incrBtnTop + mIncrementButton.getMeasuredHeight();
+ mIncrementButton.layout(incrBtnLeft, incrBtnTop, incrBtnRight, incrBtnBottom);
+
+ // Input text centered horizontally.
+ final int inptTxtMsrdWdth = mInputText.getMeasuredWidth();
+ final int inptTxtMsrdHght = mInputText.getMeasuredHeight();
+ final int inptTxtLeft = (msrdWdth - inptTxtMsrdWdth) / 2;
+ final int inptTxtTop = (msrdHght - inptTxtMsrdHght) / 2;
+ final int inptTxtRight = inptTxtLeft + inptTxtMsrdWdth;
+ final int inptTxtBottom = inptTxtTop + inptTxtMsrdHght;
+ mInputText.layout(inptTxtLeft, inptTxtTop, inptTxtRight, inptTxtBottom);
+
+ // Decrement button at the top.
+ final int decrBtnMsrdWdth = mIncrementButton.getMeasuredWidth();
+ final int decrBtnLeft = (msrdWdth - decrBtnMsrdWdth) / 2;
+ final int decrBtnTop = msrdHght - mDecrementButton.getMeasuredHeight();
+ final int decrBtnRight = decrBtnLeft + decrBtnMsrdWdth;
+ final int decrBtnBottom = msrdHght;
+ mDecrementButton.layout(decrBtnLeft, decrBtnTop, decrBtnRight, decrBtnBottom);
+ }
+
if (!mScrollWheelAndFadingEdgesInitialized) {
mScrollWheelAndFadingEdgesInitialized = true;
// need to do all this when we know our size
@@ -675,6 +718,24 @@ public class NumberPicker extends LinearLayout {
}
@Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ final int measuredWidth;
+ if (mMaxWidth > 0) {
+ measuredWidth = getMaxSize(widthMeasureSpec, mMaxWidth);
+ } else {
+ measuredWidth = getMeasuredWidth();
+ }
+ final int measuredHeight;
+ if (mMaxHeight > 0) {
+ measuredHeight = getMaxSize(heightMeasureSpec, mMaxHeight);
+ } else {
+ measuredHeight = getMeasuredHeight();
+ }
+ setMeasuredDimension(measuredWidth, measuredHeight);
+ }
+
+ @Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (!isEnabled() || !mFlingable) {
return false;
@@ -700,17 +761,14 @@ public class NumberPicker extends LinearLayout {
hideInputControls();
return true;
}
- if (isEventInViewHitRect(event, mInputText)
- || (!mIncrementButton.isShown()
- && isEventInViewHitRect(event, mIncrementButton))
- || (!mDecrementButton.isShown()
- && isEventInViewHitRect(event, mDecrementButton))) {
- mAdjustScrollerOnUpEvent = false;
- setSelectorWheelState(SELECTOR_WHEEL_STATE_LARGE);
- hideInputControls();
- return true;
+ if (isEventInVisibleViewHitRect(event, mIncrementButton)
+ || isEventInVisibleViewHitRect(event, mDecrementButton)) {
+ return false;
}
- break;
+ mAdjustScrollerOnUpEvent = false;
+ setSelectorWheelState(SELECTOR_WHEEL_STATE_LARGE);
+ hideInputControls();
+ return true;
case MotionEvent.ACTION_MOVE:
float currentMoveY = event.getY();
int deltaDownY = (int) Math.abs(currentMoveY - mLastDownEventY);
@@ -1240,6 +1298,28 @@ public class NumberPicker extends LinearLayout {
}
/**
+ * Gets the max value for a size based on the measure spec passed by
+ * the parent and the max value for that size.
+ *
+ * @param measureSpec The measure spec.
+ * @param maxValue The max value for the size.
+ * @return The max size.
+ */
+ private int getMaxSize(int measureSpec, int maxValue) {
+ final int mode = MeasureSpec.getMode(measureSpec);
+ switch (mode) {
+ case MeasureSpec.EXACTLY:
+ return MeasureSpec.getSize(measureSpec);
+ case MeasureSpec.AT_MOST:
+ return Math.min(MeasureSpec.getSize(measureSpec), maxValue);
+ case MeasureSpec.UNSPECIFIED:
+ return maxValue;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
* Resets the selector indices and clear the cached
* string representation of these indices.
*/
@@ -1335,11 +1415,14 @@ public class NumberPicker extends LinearLayout {
}
/**
- * @return If the <code>event</code> is in the <code>view</code>.
+ * @return If the <code>event</code> is in the visible <code>view</code>.
*/
- private boolean isEventInViewHitRect(MotionEvent event, View view) {
- view.getHitRect(mTempRect);
- return mTempRect.contains((int) event.getX(), (int) event.getY());
+ private boolean isEventInVisibleViewHitRect(MotionEvent event, View view) {
+ if (view.getVisibility() == VISIBLE) {
+ view.getHitRect(mTempRect);
+ return mTempRect.contains((int) event.getX(), (int) event.getY());
+ }
+ return false;
}
/**
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 9cf2718..1592061 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -1546,6 +1546,16 @@ public class RemoteViews implements Parcelable, Filter {
}
/**
+ * Equivalent to calling View.setContentDescription
+ *
+ * @param viewId The id of the view whose content description should change
+ * @param contentDescription The new content description for the view
+ */
+ public void setContentDescription(int viewId, CharSequence contentDescription) {
+ setCharSequence(viewId, "setContentDescription", contentDescription);
+ }
+
+ /**
* Inflates the view hierarchy represented by this object and applies
* all of the actions.
*
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index 510e2d4..5fbbe4d 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -32,6 +32,7 @@ import android.view.textservice.TextServicesManager;
import com.android.internal.util.ArrayUtils;
import java.text.BreakIterator;
+import java.util.Locale;
/**
@@ -45,7 +46,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
private final TextView mTextView;
- final SpellCheckerSession mSpellCheckerSession;
+ SpellCheckerSession mSpellCheckerSession;
final int mCookie;
// Paired arrays for the (id, spellCheckSpan) pair. A negative id means the associated
@@ -61,23 +62,54 @@ public class SpellChecker implements SpellCheckerSessionListener {
private int mSpanSequenceCounter = 0;
+ private Locale mCurrentLocale;
+
+ // Shared by all SpellParsers. Cannot be shared with TextView since it may be used
+ // concurrently due to the asynchronous nature of onGetSuggestions.
+ private WordIterator mWordIterator;
+
public SpellChecker(TextView textView) {
mTextView = textView;
- final TextServicesManager textServicesManager = (TextServicesManager) textView.getContext().
- getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
- mSpellCheckerSession = textServicesManager.newSpellCheckerSession(
- null /* not currently used by the textServicesManager */,
- null /* null locale means use the languages defined in Settings
- if referToSpellCheckerLanguageSettings is true */,
- this, true /* means use the languages defined in Settings */);
- mCookie = hashCode();
-
- // Arbitrary: 4 simultaneous spell check spans. Will automatically double size on demand
+ // Arbitrary: these arrays will automatically double their sizes on demand
final int size = ArrayUtils.idealObjectArraySize(1);
mIds = new int[size];
mSpellCheckSpans = new SpellCheckSpan[size];
+
+ setLocale(mTextView.getLocale());
+
+ mCookie = hashCode();
+ }
+
+ private void setLocale(Locale locale) {
+ final TextServicesManager textServicesManager = (TextServicesManager)
+ mTextView.getContext().getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
+ mSpellCheckerSession = textServicesManager.newSpellCheckerSession(
+ null /* Bundle not currently used by the textServicesManager */,
+ locale, this, false /* means any available languages from current spell checker */);
+ mCurrentLocale = locale;
+
+ // Restore SpellCheckSpans in pool
+ for (int i = 0; i < mLength; i++) {
+ mSpellCheckSpans[i].setSpellCheckInProgress(false);
+ mIds[i] = -1;
+ }
mLength = 0;
+
+ // Change SpellParsers' wordIterator locale
+ mWordIterator = new WordIterator(locale);
+
+ // Stop all SpellParsers
+ final int length = mSpellParsers.length;
+ for (int i = 0; i < length; i++) {
+ mSpellParsers[i].finish();
+ }
+
+ // Remove existing misspelled SuggestionSpans
+ mTextView.removeMisspelledSpans((Editable) mTextView.getText());
+
+ // This class is the listener for locale change: warn other locale-aware objects
+ mTextView.onLocaleChanged();
}
/**
@@ -95,7 +127,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
final int length = mSpellParsers.length;
for (int i = 0; i < length; i++) {
- mSpellParsers[i].close();
+ mSpellParsers[i].finish();
}
}
@@ -140,12 +172,20 @@ public class SpellChecker implements SpellCheckerSessionListener {
}
public void spellCheck(int start, int end) {
+ final Locale locale = mTextView.getLocale();
+ if (mCurrentLocale == null || (!(mCurrentLocale.equals(locale)))) {
+ setLocale(locale);
+ // Re-check the entire text
+ start = 0;
+ end = mTextView.getText().length();
+ }
+
if (!isSessionActive()) return;
final int length = mSpellParsers.length;
for (int i = 0; i < length; i++) {
final SpellParser spellParser = mSpellParsers[i];
- if (spellParser.isDone()) {
+ if (spellParser.isFinished()) {
spellParser.init(start, end);
spellParser.parse();
return;
@@ -229,7 +269,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
final int length = mSpellParsers.length;
for (int i = 0; i < length; i++) {
final SpellParser spellParser = mSpellParsers[i];
- if (!spellParser.isDone()) {
+ if (!spellParser.isFinished()) {
spellParser.parse();
}
}
@@ -239,6 +279,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
SuggestionsInfo suggestionsInfo, SpellCheckSpan spellCheckSpan) {
final int start = editable.getSpanStart(spellCheckSpan);
final int end = editable.getSpanEnd(spellCheckSpan);
+ if (start < 0 || end < 0) return; // span was removed in the meantime
// Other suggestion spans may exist on that region, with identical suggestions, filter
// them out to avoid duplicates. First, filter suggestion spans on that exact region.
@@ -249,7 +290,6 @@ public class SpellChecker implements SpellCheckerSessionListener {
final int spanEnd = editable.getSpanEnd(suggestionSpans[i]);
if (spanStart != start || spanEnd != end) {
suggestionSpans[i] = null;
- break;
}
}
@@ -301,7 +341,6 @@ public class SpellChecker implements SpellCheckerSessionListener {
}
private class SpellParser {
- private WordIterator mWordIterator = new WordIterator(/*TODO Locale*/);
private Object mRange = new Object();
public void init(int start, int end) {
@@ -309,11 +348,11 @@ public class SpellChecker implements SpellCheckerSessionListener {
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
- public void close() {
+ public void finish() {
((Editable) mTextView.getText()).removeSpan(mRange);
}
- public boolean isDone() {
+ public boolean isFinished() {
return ((Editable) mTextView.getText()).getSpanStart(mRange) < 0;
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 7f03adf..5a300e8 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -132,6 +132,7 @@ import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.RemoteViews.RemoteView;
@@ -147,6 +148,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.Locale;
/**
* Displays text to the user and optionally allows them to edit it. A TextView
@@ -357,6 +359,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private SpellChecker mSpellChecker;
+ private boolean mSoftInputShownOnFocus = true;
+
// The alignment to pass to Layout, or null if not resolved.
private Layout.Alignment mLayoutAlignment;
@@ -605,6 +609,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mLinksClickable = a.getBoolean(attr, true);
break;
+// TODO uncomment when this attribute is made public in the next release
+// also add TextView_showSoftInputOnFocus to the list of attributes above
+// case com.android.internal.R.styleable.TextView_showSoftInputOnFocus:
+// setShowSoftInputOnFocus(a.getBoolean(attr, true));
+// break;
+
case com.android.internal.R.styleable.TextView_drawableLeft:
drawableLeft = a.getDrawable(attr);
break;
@@ -2368,6 +2378,29 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
/**
+ * Sets whether the soft input method will be made visible when this
+ * TextView gets focused. The default is true.
+ *
+ * @attr ref android.R.styleable#TextView_softInputShownOnFocus
+ * @hide
+ */
+ @android.view.RemotableViewMethod
+ public final void setSoftInputShownOnFocus(boolean show) {
+ mSoftInputShownOnFocus = show;
+ }
+
+ /**
+ * Returns whether the soft input method will be made visible when this
+ * TextView gets focused. The default is true.
+ *
+ * @attr ref android.R.styleable#TextView_softInputShownOnFocus
+ * @hide
+ */
+ public final boolean getSoftInputShownOnFocus() {
+ return mSoftInputShownOnFocus;
+ }
+
+ /**
* Returns the list of URLSpans attached to the text
* (by {@link Linkify} or otherwise) if any. You can call
* {@link URLSpan#getURL} on them to find where they link to
@@ -2942,15 +2975,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
sp.removeSpan(cw);
}
- SuggestionSpan[] suggestionSpans = sp.getSpans(0, sp.length(), SuggestionSpan.class);
- for (int i = 0; i < suggestionSpans.length; i++) {
- int flags = suggestionSpans[i].getFlags();
- if ((flags & SuggestionSpan.FLAG_EASY_CORRECT) != 0
- && (flags & SuggestionSpan.FLAG_MISSPELLED) != 0) {
- sp.removeSpan(suggestionSpans[i]);
- }
- }
-
+ removeMisspelledSpans(sp);
sp.removeSpan(mSuggestionRangeSpan);
ss.text = sp;
@@ -2970,6 +2995,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return superState;
}
+ void removeMisspelledSpans(Spannable spannable) {
+ SuggestionSpan[] suggestionSpans = spannable.getSpans(0, spannable.length(),
+ SuggestionSpan.class);
+ for (int i = 0; i < suggestionSpans.length; i++) {
+ int flags = suggestionSpans[i].getFlags();
+ if ((flags & SuggestionSpan.FLAG_EASY_CORRECT) != 0
+ && (flags & SuggestionSpan.FLAG_MISSPELLED) != 0) {
+ spannable.removeSpan(suggestionSpans[i]);
+ }
+ }
+ }
+
@Override
public void onRestoreInstanceState(Parcelable state) {
if (!(state instanceof SavedState)) {
@@ -5465,7 +5502,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
&& mLayout != null && onCheckIsTextEditor()) {
InputMethodManager imm = InputMethodManager.peekInstance();
viewClicked(imm);
- if (imm != null) {
+ if (imm != null && mSoftInputShownOnFocus) {
imm.showSoftInput(this, 0);
}
}
@@ -8207,6 +8244,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
hideControllers();
+ if (mSuggestionsPopupWindow != null) {
+ mSuggestionsPopupWindow.onParentLostFocus();
+ }
}
startStopMarquee(hasWindowFocus);
@@ -8304,7 +8344,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Show the IME, except when selecting in read-only text.
final InputMethodManager imm = InputMethodManager.peekInstance();
viewClicked(imm);
- if (!mTextIsSelectable) {
+ if (!mTextIsSelectable && mSoftInputShownOnFocus) {
handled |= imm != null && imm.showSoftInput(this, 0);
}
@@ -8840,15 +8880,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
selectionStart = ((Spanned) mText).getSpanStart(urlSpan);
selectionEnd = ((Spanned) mText).getSpanEnd(urlSpan);
} else {
- if (mWordIterator == null) {
- mWordIterator = new WordIterator();
- }
- mWordIterator.setCharSequence(mText, minOffset, maxOffset);
+ final WordIterator wordIterator = getWordIterator();
+ wordIterator.setCharSequence(mText, minOffset, maxOffset);
- selectionStart = mWordIterator.getBeginning(minOffset);
+ selectionStart = wordIterator.getBeginning(minOffset);
if (selectionStart == BreakIterator.DONE) return false;
- selectionEnd = mWordIterator.getEnd(maxOffset);
+ selectionEnd = wordIterator.getEnd(maxOffset);
if (selectionEnd == BreakIterator.DONE) return false;
if (selectionStart == selectionEnd) {
@@ -8863,6 +8901,43 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return selectionEnd > selectionStart;
}
+ /**
+ * This is a temporary method. Future versions may support multi-locale text.
+ *
+ * @return The current locale used in this TextView, based on the current IME's locale,
+ * or the system default locale if this is not defined.
+ * @hide
+ */
+ public Locale getLocale() {
+ Locale locale = Locale.getDefault();
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) {
+ final InputMethodSubtype currentInputMethodSubtype = imm.getCurrentInputMethodSubtype();
+ if (currentInputMethodSubtype != null) {
+ String localeString = currentInputMethodSubtype.getLocale();
+ if (!TextUtils.isEmpty(localeString)) {
+ locale = new Locale(localeString);
+ }
+ }
+ }
+ return locale;
+ }
+
+ void onLocaleChanged() {
+ // Will be re-created on demand in getWordIterator with the proper new locale
+ mWordIterator = null;
+ }
+
+ /**
+ * @hide
+ */
+ public WordIterator getWordIterator() {
+ if (mWordIterator == null) {
+ mWordIterator = new WordIterator(getLocale());
+ }
+ return mWordIterator;
+ }
+
private long getCharRange(int offset) {
final int textLength = mText.length();
if (offset + 1 < textLength) {
@@ -9547,6 +9622,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private SuggestionInfo[] mSuggestionInfos;
private int mNumberOfSuggestions;
private boolean mCursorWasVisibleBeforeSuggestions;
+ private boolean mIsShowingUp = false;
private SuggestionAdapter mSuggestionsAdapter;
private final Comparator<SuggestionSpan> mSuggestionSpanComparator;
private final HashMap<SuggestionSpan, Integer> mSpansLengths;
@@ -9602,6 +9678,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
+ public boolean isShowingUp() {
+ return mIsShowingUp;
+ }
+
+ public void onParentLostFocus() {
+ mIsShowingUp = false;
+ }
+
private class SuggestionInfo {
int suggestionStart, suggestionEnd; // range of actual suggestion within text
SuggestionSpan suggestionSpan; // the SuggestionSpan that this TextView represents
@@ -9609,15 +9693,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
SpannableStringBuilder text = new SpannableStringBuilder();
TextAppearanceSpan highlightSpan = new TextAppearanceSpan(mContext,
android.R.style.TextAppearance_SuggestionHighlight);
-
- void removeMisspelledFlag() {
- int suggestionSpanFlags = suggestionSpan.getFlags();
- if ((suggestionSpanFlags & SuggestionSpan.FLAG_MISSPELLED) > 0) {
- suggestionSpanFlags &= ~SuggestionSpan.FLAG_MISSPELLED;
- suggestionSpanFlags &= ~SuggestionSpan.FLAG_EASY_CORRECT;
- suggestionSpan.setFlags(suggestionSpanFlags);
- }
- }
}
private class SuggestionAdapter extends BaseAdapter {
@@ -9714,6 +9789,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
updateSuggestions();
mCursorWasVisibleBeforeSuggestions = mCursorVisible;
setCursorVisible(false);
+ mIsShowingUp = true;
super.show();
}
@@ -9935,6 +10011,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
suggestionSpansStarts[i] = editable.getSpanStart(suggestionSpan);
suggestionSpansEnds[i] = editable.getSpanEnd(suggestionSpan);
suggestionSpansFlags[i] = editable.getSpanFlags(suggestionSpan);
+
+ // Remove potential misspelled flags
+ int suggestionSpanFlags = suggestionSpan.getFlags();
+ if ((suggestionSpanFlags & SuggestionSpan.FLAG_MISSPELLED) > 0) {
+ suggestionSpanFlags &= ~SuggestionSpan.FLAG_MISSPELLED;
+ suggestionSpanFlags &= ~SuggestionSpan.FLAG_EASY_CORRECT;
+ suggestionSpan.setFlags(suggestionSpanFlags);
+ }
}
final int suggestionStart = suggestionInfo.suggestionStart;
@@ -9943,8 +10027,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
suggestionStart, suggestionEnd).toString();
editable.replace(spanStart, spanEnd, suggestion);
- suggestionInfo.removeMisspelledFlag();
-
// Notify source IME of the suggestion pick. Do this before swaping texts.
if (!TextUtils.isEmpty(
suggestionInfo.suggestionSpan.getNotificationTargetClassName())) {
@@ -10120,7 +10202,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final boolean selectionStarted = mSelectionActionMode != null ||
extractedTextModeWillBeStartedFullScreen;
- if (selectionStarted && !mTextIsSelectable && imm != null) {
+ if (selectionStarted && !mTextIsSelectable && imm != null && mSoftInputShownOnFocus) {
// Show the IME to be able to replace text, except when selecting non editable text.
imm.showSoftInput(this, 0, null);
}
@@ -11120,6 +11202,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private void hideCursorControllers() {
+ if (mSuggestionsPopupWindow != null && !mSuggestionsPopupWindow.isShowingUp()) {
+ // Should be done before hide insertion point controller since it triggers a show of it
+ mSuggestionsPopupWindow.hide();
+ }
hideInsertionPointCursorController();
stopSelectionActionMode();
}