summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rwxr-xr-xcore/java/android/animation/ValueAnimator.java24
-rw-r--r--core/java/android/net/NetworkIdentity.java20
-rw-r--r--core/java/android/net/NetworkTemplate.java10
-rw-r--r--core/java/android/os/StrictMode.java2
-rw-r--r--core/java/android/webkit/FindActionModeCallback.java11
-rw-r--r--core/java/android/webkit/FindListener.java32
-rw-r--r--core/java/android/webkit/WebView.java29
-rw-r--r--core/java/android/webkit/WebViewClassic.java30
-rw-r--r--core/java/android/webkit/WebViewProvider.java4
9 files changed, 127 insertions, 35 deletions
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index f69120a..e2b8ce4 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -557,12 +557,22 @@ public class ValueAnimator extends Animator {
public void handleMessage(Message msg) {
switch (msg.what) {
case ANIMATION_START:
- doAnimationStart();
+ // If there are already active animations, or if another ANIMATION_START
+ // message was processed during this frame, then the pending list may already
+ // have been cleared. If that's the case, we've already processed the
+ // active animations for this frame - don't do it again.
+ if (mPendingAnimations.size() > 0) {
+ doAnimationFrame();
+ }
break;
}
}
- private void doAnimationStart() {
+ private void doAnimationFrame() {
+ // currentTime holds the common time for all animations processed
+ // during this frame
+ long currentTime = AnimationUtils.currentAnimationTimeMillis();
+
// mPendingAnimations holds any animations that have requested to be started
// We're going to clear mPendingAnimations, but starting animation may
// cause more to be added to the pending list (for example, if one animation
@@ -583,15 +593,7 @@ public class ValueAnimator extends Animator {
}
}
}
- doAnimationFrame();
- }
-
- private void doAnimationFrame() {
- // currentTime holds the common time for all animations processed
- // during this frame
- long currentTime = AnimationUtils.currentAnimationTimeMillis();
-
- // First, process animations currently sitting on the delayed queue, adding
+ // Next, process animations currently sitting on the delayed queue, adding
// them to the active animations if they are ready
int numDelayedAnims = mDelayedAnims.size();
for (int i = 0; i < numDelayedAnims; ++i) {
diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java
index 1a74abf..ee12989 100644
--- a/core/java/android/net/NetworkIdentity.java
+++ b/core/java/android/net/NetworkIdentity.java
@@ -31,6 +31,14 @@ import com.android.internal.util.Objects;
* @hide
*/
public class NetworkIdentity {
+ /**
+ * When enabled, combine all {@link #mSubType} together under
+ * {@link #SUBTYPE_COMBINED}.
+ */
+ public static final boolean COMBINE_SUBTYPE_ENABLED = true;
+
+ public static final int SUBTYPE_COMBINED = -1;
+
final int mType;
final int mSubType;
final String mSubscriberId;
@@ -38,7 +46,7 @@ public class NetworkIdentity {
public NetworkIdentity(int type, int subType, String subscriberId, boolean roaming) {
this.mType = type;
- this.mSubType = subType;
+ this.mSubType = COMBINE_SUBTYPE_ENABLED ? SUBTYPE_COMBINED : subType;
this.mSubscriberId = subscriberId;
this.mRoaming = roaming;
}
@@ -52,9 +60,8 @@ public class NetworkIdentity {
public boolean equals(Object obj) {
if (obj instanceof NetworkIdentity) {
final NetworkIdentity ident = (NetworkIdentity) obj;
- return mType == ident.mType && mSubType == ident.mSubType
- && Objects.equal(mSubscriberId, ident.mSubscriberId)
- && mRoaming == ident.mRoaming;
+ return mType == ident.mType && mSubType == ident.mSubType && mRoaming == ident.mRoaming
+ && Objects.equal(mSubscriberId, ident.mSubscriberId);
}
return false;
}
@@ -63,7 +70,9 @@ public class NetworkIdentity {
public String toString() {
final String typeName = ConnectivityManager.getNetworkTypeName(mType);
final String subTypeName;
- if (ConnectivityManager.isNetworkTypeMobile(mType)) {
+ if (COMBINE_SUBTYPE_ENABLED) {
+ subTypeName = "COMBINED";
+ } else if (ConnectivityManager.isNetworkTypeMobile(mType)) {
subTypeName = TelephonyManager.getNetworkTypeName(mSubType);
} else {
subTypeName = Integer.toString(mSubType);
@@ -130,5 +139,4 @@ public class NetworkIdentity {
}
return new NetworkIdentity(type, subType, subscriberId, roaming);
}
-
}
diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java
index 8ebfd8d..e1fbdcc 100644
--- a/core/java/android/net/NetworkTemplate.java
+++ b/core/java/android/net/NetworkTemplate.java
@@ -20,6 +20,7 @@ import static android.net.ConnectivityManager.TYPE_ETHERNET;
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.ConnectivityManager.TYPE_WIFI_P2P;
import static android.net.ConnectivityManager.TYPE_WIMAX;
+import static android.net.NetworkIdentity.COMBINE_SUBTYPE_ENABLED;
import static android.net.NetworkIdentity.scrubSubscriberId;
import static android.telephony.TelephonyManager.NETWORK_CLASS_2_G;
import static android.telephony.TelephonyManager.NETWORK_CLASS_3_G;
@@ -199,6 +200,7 @@ public class NetworkTemplate implements Parcelable {
* Check if mobile network classified 3G or lower with matching IMSI.
*/
private boolean matchesMobile3gLower(NetworkIdentity ident) {
+ ensureSubtypeAvailable();
if (ident.mType == TYPE_WIMAX) {
return false;
} else if (matchesMobile(ident)) {
@@ -216,6 +218,7 @@ public class NetworkTemplate implements Parcelable {
* Check if mobile network classified 4G with matching IMSI.
*/
private boolean matchesMobile4g(NetworkIdentity ident) {
+ ensureSubtypeAvailable();
if (ident.mType == TYPE_WIMAX) {
// TODO: consider matching against WiMAX subscriber identity
return true;
@@ -268,6 +271,13 @@ public class NetworkTemplate implements Parcelable {
}
}
+ private static void ensureSubtypeAvailable() {
+ if (COMBINE_SUBTYPE_ENABLED) {
+ throw new IllegalArgumentException(
+ "Unable to enforce 3G_LOWER template on combined data.");
+ }
+ }
+
public static final Creator<NetworkTemplate> CREATOR = new Creator<NetworkTemplate>() {
public NetworkTemplate createFromParcel(Parcel in) {
return new NetworkTemplate(in);
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 759be91..ce213fb 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -1201,7 +1201,7 @@ public final class StrictMode {
// throttled back to 60fps via SurfaceFlinger/View
// invalidates, _not_ by posting frame updates every 16
// milliseconds.
- threadHandler.get().post(new Runnable() {
+ threadHandler.get().postAtFrontOfQueue(new Runnable() {
public void run() {
long loopFinishTime = SystemClock.uptimeMillis();
diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java
index 964cf3e..6c331ac 100644
--- a/core/java/android/webkit/FindActionModeCallback.java
+++ b/core/java/android/webkit/FindActionModeCallback.java
@@ -45,7 +45,6 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
private int mNumberOfMatches;
private int mActiveMatchIndex;
private ActionMode mActionMode;
- private String mLastFind;
FindActionModeCallback(Context context) {
mCustomView = LayoutInflater.from(context).inflate(
@@ -134,13 +133,12 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
mWebView.clearMatches();
mMatches.setVisibility(View.GONE);
mMatchesFound = false;
- mLastFind = null;
+ mWebView.findAll(null);
} else {
mMatchesFound = true;
mMatches.setVisibility(View.INVISIBLE);
mNumberOfMatches = 0;
- mLastFind = find.toString();
- mWebView.findAllAsync(mLastFind);
+ mWebView.findAllAsync(find.toString());
}
}
@@ -150,9 +148,8 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
mInput.showSoftInput(mEditText, 0);
}
- public void updateMatchCount(int matchIndex, int matchCount,
- String findText) {
- if (mLastFind != null && mLastFind.equals(findText)) {
+ public void updateMatchCount(int matchIndex, int matchCount, boolean isNewFind) {
+ if (!isNewFind) {
mNumberOfMatches = matchCount;
mActiveMatchIndex = matchIndex;
updateMatchesString();
diff --git a/core/java/android/webkit/FindListener.java b/core/java/android/webkit/FindListener.java
new file mode 100644
index 0000000..124f737
--- /dev/null
+++ b/core/java/android/webkit/FindListener.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2012 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.webkit;
+
+/**
+ * @hide
+ */
+public interface FindListener {
+ /**
+ * Notify the host application that a find result is available.
+ *
+ * @param numberOfMatches How many matches have been found
+ * @param activeMatchOrdinal The ordinal of the currently selected match
+ * @param isDoneCounting Whether we have finished counting matches
+ */
+ public void onFindResultReceived(int numberOfMatches,
+ int activeMatchOrdinal, boolean isDoneCounting);
+}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index a561577..5e09416 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1226,7 +1226,19 @@ public class WebView extends AbsoluteLayout
}
- /*
+ /**
+ * Register the interface to be used when a find-on-page result has become
+ * available. This will replace the current handler.
+ *
+ * @param listener An implementation of FindListener
+ * @hide
+ */
+ public void setFindListener(FindListener listener) {
+ checkThread();
+ mProvider.setFindListener(listener);
+ }
+
+ /**
* Highlight and scroll to the next occurance of String in findAll.
* Wraps the page infinitely, and scrolls. Must be called after
* calling findAll.
@@ -1238,8 +1250,9 @@ public class WebView extends AbsoluteLayout
mProvider.findNext(forward);
}
- /*
+ /**
* Find all instances of find on the page and highlight them.
+ *
* @param find String to find.
* @return int The number of occurances of the String "find"
* that were found.
@@ -1250,6 +1263,18 @@ public class WebView extends AbsoluteLayout
}
/**
+ * Find all instances of find on the page and highlight them,
+ * asynchronously.
+ *
+ * @param find String to find.
+ * @hide
+ */
+ public void findAllAsync(String find) {
+ checkThread();
+ mProvider.findAllAsync(find);
+ }
+
+ /**
* Start an ActionMode for finding text in this WebView. Only works if this
* WebView is attached to the view system.
* @param text If non-null, will be the initial text to search for.
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index ed43043..e5434ce 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -1440,6 +1440,9 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
// Used to notify listeners of a new picture.
private PictureListener mPictureListener;
+ // Used to notify listeners about find-on-page results.
+ private FindListener mFindListener;
+
/**
* Refer to {@link WebView#requestFocusNodeHref(Message)} for more information
*/
@@ -3695,6 +3698,17 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
}
/**
+ * Register the interface to be used when a find-on-page result has become
+ * available. This will replace the current handler.
+ *
+ * @param listener An implementation of FindListener
+ */
+ public void setFindListener(FindListener listener) {
+ checkThread();
+ mFindListener = listener;
+ }
+
+ /**
* See {@link WebView#findNext(boolean)}
*/
@Override
@@ -3723,6 +3737,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
checkThread();
if (0 == mNativeClass) return 0; // client isn't initialized
mLastFind = find;
+ if (find == null) return 0;
mWebViewCore.removeMessages(EventHub.FIND_ALL);
WebViewCore.FindAllRequest request = new
WebViewCore.FindAllRequest(find);
@@ -4909,11 +4924,9 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
*/
private void getSelectionHandles(int[] handles) {
handles[0] = mSelectCursorBase.right;
- handles[1] = mSelectCursorBase.bottom -
- (mSelectCursorBase.height() / 4);
+ handles[1] = mSelectCursorBase.bottom;
handles[2] = mSelectCursorExtent.left;
- handles[3] = mSelectCursorExtent.bottom
- - (mSelectCursorExtent.height() / 4);
+ handles[3] = mSelectCursorExtent.bottom;
if (!nativeIsBaseFirst(mNativeClass)) {
int swap = handles[0];
handles[0] = handles[2];
@@ -8478,10 +8491,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
}
case UPDATE_MATCH_COUNT: {
- if (mFindCallback != null) {
- mFindCallback.updateMatchCount(msg.arg1, msg.arg2,
- (String) msg.obj);
- }
+ boolean isNewFind = mLastFind == null || !mLastFind.equals(msg.obj);
+ if (mFindCallback != null)
+ mFindCallback.updateMatchCount(msg.arg1, msg.arg2, isNewFind);
+ if (mFindListener != null)
+ mFindListener.onFindResultReceived(msg.arg1, msg.arg2, true);
break;
}
case CLEAR_CARET_HANDLE:
diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java
index 2e8ad6d..9016fbc 100644
--- a/core/java/android/webkit/WebViewProvider.java
+++ b/core/java/android/webkit/WebViewProvider.java
@@ -191,10 +191,14 @@ public interface WebViewProvider {
public WebBackForwardList copyBackForwardList();
+ public void setFindListener(FindListener listener);
+
public void findNext(boolean forward);
public int findAll(String find);
+ public void findAllAsync(String find);
+
public boolean showFindDialog(String text, boolean showIme);
public void clearMatches();