| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
| 6 | 6 |
| 7 import android.content.ComponentCallbacks2; | 7 import android.content.ComponentCallbacks2; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.pm.PackageManager; | 9 import android.content.pm.PackageManager; |
| 10 import android.content.res.Configuration; | 10 import android.content.res.Configuration; |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 return mContentViewCore.onCreateInputConnection(outAttrs); | 1216 return mContentViewCore.onCreateInputConnection(outAttrs); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 /** | 1219 /** |
| 1220 * @see android.webkit.WebView#onKeyUp(int, KeyEvent) | 1220 * @see android.webkit.WebView#onKeyUp(int, KeyEvent) |
| 1221 */ | 1221 */ |
| 1222 public boolean onKeyUp(int keyCode, KeyEvent event) { | 1222 public boolean onKeyUp(int keyCode, KeyEvent event) { |
| 1223 return mContentViewCore.onKeyUp(keyCode, event); | 1223 return mContentViewCore.onKeyUp(keyCode, event); |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 private boolean isDpadEvent(KeyEvent event) { |
| 1227 if (event.getAction() == KeyEvent.ACTION_DOWN) { |
| 1228 switch (event.getKeyCode()) { |
| 1229 case KeyEvent.KEYCODE_DPAD_CENTER: |
| 1230 case KeyEvent.KEYCODE_DPAD_DOWN: |
| 1231 case KeyEvent.KEYCODE_DPAD_UP: |
| 1232 case KeyEvent.KEYCODE_DPAD_LEFT: |
| 1233 case KeyEvent.KEYCODE_DPAD_RIGHT: |
| 1234 return true; |
| 1235 } |
| 1236 } |
| 1237 return false; |
| 1238 } |
| 1239 |
| 1226 /** | 1240 /** |
| 1227 * @see android.webkit.WebView#dispatchKeyEvent(KeyEvent) | 1241 * @see android.webkit.WebView#dispatchKeyEvent(KeyEvent) |
| 1228 */ | 1242 */ |
| 1229 public boolean dispatchKeyEvent(KeyEvent event) { | 1243 public boolean dispatchKeyEvent(KeyEvent event) { |
| 1244 if (isDpadEvent(event)) { |
| 1245 mSettings.setSpatialNavigationEnabled(true); |
| 1246 } |
| 1230 return mContentViewCore.dispatchKeyEvent(event); | 1247 return mContentViewCore.dispatchKeyEvent(event); |
| 1231 } | 1248 } |
| 1232 | 1249 |
| 1233 /** | 1250 /** |
| 1234 * Clears the resource cache. Note that the cache is per-application, so thi
s will clear the | 1251 * Clears the resource cache. Note that the cache is per-application, so thi
s will clear the |
| 1235 * cache for all WebViews used. | 1252 * cache for all WebViews used. |
| 1236 * | 1253 * |
| 1237 * @param includeDiskFiles if false, only the RAM cache is cleared | 1254 * @param includeDiskFiles if false, only the RAM cache is cleared |
| 1238 */ | 1255 */ |
| 1239 public void clearCache(boolean includeDiskFiles) { | 1256 public void clearCache(boolean includeDiskFiles) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 //--------------------------------------------------------------------------
------------------ | 1495 //--------------------------------------------------------------------------
------------------ |
| 1479 // View and ViewGroup method implementations | 1496 // View and ViewGroup method implementations |
| 1480 //--------------------------------------------------------------------------
------------------ | 1497 //--------------------------------------------------------------------------
------------------ |
| 1481 | 1498 |
| 1482 /** | 1499 /** |
| 1483 * @see android.webkit.View#onTouchEvent() | 1500 * @see android.webkit.View#onTouchEvent() |
| 1484 */ | 1501 */ |
| 1485 public boolean onTouchEvent(MotionEvent event) { | 1502 public boolean onTouchEvent(MotionEvent event) { |
| 1486 if (mNativeAwContents == 0) return false; | 1503 if (mNativeAwContents == 0) return false; |
| 1487 | 1504 |
| 1505 if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { |
| 1506 mSettings.setSpatialNavigationEnabled(false); |
| 1507 } |
| 1508 |
| 1488 mScrollOffsetManager.setProcessingTouchEvent(true); | 1509 mScrollOffsetManager.setProcessingTouchEvent(true); |
| 1489 boolean rv = mContentViewCore.onTouchEvent(event); | 1510 boolean rv = mContentViewCore.onTouchEvent(event); |
| 1490 mScrollOffsetManager.setProcessingTouchEvent(false); | 1511 mScrollOffsetManager.setProcessingTouchEvent(false); |
| 1491 | 1512 |
| 1492 if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { | 1513 if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { |
| 1493 int actionIndex = event.getActionIndex(); | 1514 int actionIndex = event.getActionIndex(); |
| 1494 | 1515 |
| 1495 // Note this will trigger IPC back to browser even if nothing is hit
. | 1516 // Note this will trigger IPC back to browser even if nothing is hit
. |
| 1496 nativeRequestNewHitTestDataAt(mNativeAwContents, | 1517 nativeRequestNewHitTestDataAt(mNativeAwContents, |
| 1497 (int)Math.round(event.getX(actionIndex
) / mDIPScale), | 1518 (int)Math.round(event.getX(actionIndex
) / mDIPScale), |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 private native int nativeCapturePicture(int nativeAwContents, int width, int
height); | 2064 private native int nativeCapturePicture(int nativeAwContents, int width, int
height); |
| 2044 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled); | 2065 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled); |
| 2045 | 2066 |
| 2046 private native void nativeInvokeGeolocationCallback( | 2067 private native void nativeInvokeGeolocationCallback( |
| 2047 int nativeAwContents, boolean value, String requestingFrame); | 2068 int nativeAwContents, boolean value, String requestingFrame); |
| 2048 | 2069 |
| 2049 private native void nativeSetJsOnlineProperty(int nativeAwContents, boolean
networkUp); | 2070 private native void nativeSetJsOnlineProperty(int nativeAwContents, boolean
networkUp); |
| 2050 | 2071 |
| 2051 private native void nativeTrimMemory(int nativeAwContents, int level); | 2072 private native void nativeTrimMemory(int nativeAwContents, int level); |
| 2052 } | 2073 } |
| OLD | NEW |