From 1be73390778eb1b033a4db6339c8a8b325dfaad9 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Fri, 15 Oct 2010 16:31:01 +0100 Subject: Rename DeviceOrientationManager to DeviceMotionAndOrientationManager Requires a corresponding change in external/webkit ... https://android-git.corp.google.com/g/74336 Change-Id: Ic8042a77db200cd2b0ea5ae3f70074aaba0cb414 --- .../webkit/DeviceMotionAndOrientationManager.java | 79 ++++++++++++++++++++++ core/java/android/webkit/DeviceMotionService.java | 6 +- .../android/webkit/DeviceOrientationManager.java | 79 ---------------------- .../android/webkit/DeviceOrientationService.java | 6 +- core/java/android/webkit/WebViewCore.java | 15 ++-- 5 files changed, 93 insertions(+), 92 deletions(-) create mode 100644 core/java/android/webkit/DeviceMotionAndOrientationManager.java delete mode 100644 core/java/android/webkit/DeviceOrientationManager.java diff --git a/core/java/android/webkit/DeviceMotionAndOrientationManager.java b/core/java/android/webkit/DeviceMotionAndOrientationManager.java new file mode 100644 index 000000000000..79b78d8f815c --- /dev/null +++ b/core/java/android/webkit/DeviceMotionAndOrientationManager.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 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; + +/** + * This class is simply a container for the methods used to implement DeviceMotion and + * DeviceOrientation, including the mock DeviceOrientationClient for use in LayoutTests. + * + * This could be part of WebViewCore, but have moved it to its own class to + * avoid bloat there. + * @hide + */ +public final class DeviceMotionAndOrientationManager { + private WebViewCore mWebViewCore; + + public DeviceMotionAndOrientationManager(WebViewCore webViewCore) { + mWebViewCore = webViewCore; + } + + /** + * Sets whether the Page for this WebViewCore should use a mock DeviceOrientation + * client. + */ + public void useMock() { + assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); + nativeUseMock(mWebViewCore); + } + + /** + * Set the position for the mock DeviceOrientation service for this WebViewCore. + */ + public void setMockOrientation(boolean canProvideAlpha, double alpha, boolean canProvideBeta, + double beta, boolean canProvideGamma, double gamma) { + assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); + nativeSetMockOrientation(mWebViewCore, canProvideAlpha, alpha, canProvideBeta, beta, + canProvideGamma, gamma); + } + + // We only provide accelerationIncludingGravity. + public void onMotionChange(Double x, Double y, Double z, double interval) { + nativeOnMotionChange(mWebViewCore, + x != null, x != null ? x.doubleValue() : 0.0, + y != null, y != null ? y.doubleValue() : 0.0, + z != null, z != null ? z.doubleValue() : 0.0, + interval); + } + public void onOrientationChange(Double alpha, Double beta, Double gamma) { + nativeOnOrientationChange(mWebViewCore, + alpha != null, alpha != null ? alpha.doubleValue() : 0.0, + beta != null, beta != null ? beta.doubleValue() : 0.0, + gamma != null, gamma != null ? gamma.doubleValue() : 0.0); + } + + // Native functions + private static native void nativeUseMock(WebViewCore webViewCore); + private static native void nativeSetMockOrientation(WebViewCore webViewCore, + boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, + boolean canProvideGamma, double gamma); + private static native void nativeOnMotionChange(WebViewCore webViewCore, + boolean canProvideX, double x, boolean canProvideY, double y, + boolean canProvideZ, double z, double interval); + private static native void nativeOnOrientationChange(WebViewCore webViewCore, + boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, + boolean canProvideGamma, double gamma); +} diff --git a/core/java/android/webkit/DeviceMotionService.java b/core/java/android/webkit/DeviceMotionService.java index 4027c26839a2..7d7a0f05e36e 100755 --- a/core/java/android/webkit/DeviceMotionService.java +++ b/core/java/android/webkit/DeviceMotionService.java @@ -23,13 +23,13 @@ import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Handler; import android.os.Message; -import android.webkit.DeviceOrientationManager; +import android.webkit.DeviceMotionAndOrientationManager; import java.lang.Runnable; import java.util.List; final class DeviceMotionService implements SensorEventListener { - private DeviceOrientationManager mManager; + private DeviceMotionAndOrientationManager mManager; private boolean mIsRunning; private Handler mHandler; private SensorManager mSensorManager; @@ -40,7 +40,7 @@ final class DeviceMotionService implements SensorEventListener { private static final int INTERVAL_MILLIS = 100; - public DeviceMotionService(DeviceOrientationManager manager, Context context) { + public DeviceMotionService(DeviceMotionAndOrientationManager manager, Context context) { mManager = manager; assert(mManager != null); mContext = context; diff --git a/core/java/android/webkit/DeviceOrientationManager.java b/core/java/android/webkit/DeviceOrientationManager.java deleted file mode 100644 index 2076a9e72ee0..000000000000 --- a/core/java/android/webkit/DeviceOrientationManager.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2010 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; - -/** - * This class is simply a container for the methods used to implement DeviceOrientation, - * including the mock DeviceOrientationClient for use in LayoutTests. - * - * This could be part of WebViewCore, but have moved it to its own class to - * avoid bloat there. - * @hide - */ -public final class DeviceOrientationManager { - private WebViewCore mWebViewCore; - - public DeviceOrientationManager(WebViewCore webViewCore) { - mWebViewCore = webViewCore; - } - - /** - * Sets whether the Page for this WebViewCore should use a mock DeviceOrientation - * client. - */ - public void useMock() { - assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); - nativeUseMock(mWebViewCore); - } - - /** - * Set the position for the mock DeviceOrientation service for this WebViewCore. - */ - public void setMockOrientation(boolean canProvideAlpha, double alpha, boolean canProvideBeta, - double beta, boolean canProvideGamma, double gamma) { - assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); - nativeSetMockOrientation(mWebViewCore, canProvideAlpha, alpha, canProvideBeta, beta, - canProvideGamma, gamma); - } - - // We only provide accelerationIncludingGravity. - public void onMotionChange(Double x, Double y, Double z, double interval) { - nativeOnMotionChange(mWebViewCore, - x != null, x != null ? x.doubleValue() : 0.0, - y != null, y != null ? y.doubleValue() : 0.0, - z != null, z != null ? z.doubleValue() : 0.0, - interval); - } - public void onOrientationChange(Double alpha, Double beta, Double gamma) { - nativeOnOrientationChange(mWebViewCore, - alpha != null, alpha != null ? alpha.doubleValue() : 0.0, - beta != null, beta != null ? beta.doubleValue() : 0.0, - gamma != null, gamma != null ? gamma.doubleValue() : 0.0); - } - - // Native functions - private static native void nativeUseMock(WebViewCore webViewCore); - private static native void nativeSetMockOrientation(WebViewCore webViewCore, - boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, - boolean canProvideGamma, double gamma); - private static native void nativeOnMotionChange(WebViewCore webViewCore, - boolean canProvideX, double x, boolean canProvideY, double y, - boolean canProvideZ, double z, double interval); - private static native void nativeOnOrientationChange(WebViewCore webViewCore, - boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, - boolean canProvideGamma, double gamma); -} diff --git a/core/java/android/webkit/DeviceOrientationService.java b/core/java/android/webkit/DeviceOrientationService.java index 9b866d35e840..f3c057627a22 100755 --- a/core/java/android/webkit/DeviceOrientationService.java +++ b/core/java/android/webkit/DeviceOrientationService.java @@ -22,7 +22,7 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Handler; -import android.webkit.DeviceOrientationManager; +import android.webkit.DeviceMotionAndOrientationManager; import java.lang.Runnable; import java.util.List; @@ -33,7 +33,7 @@ final class DeviceOrientationService implements SensorEventListener { // The geomagnetic vector expressed in the body frame. private float[] mMagneticFieldVector; - private DeviceOrientationManager mManager; + private DeviceMotionAndOrientationManager mManager; private boolean mIsRunning; private Handler mHandler; private SensorManager mSensorManager; @@ -45,7 +45,7 @@ final class DeviceOrientationService implements SensorEventListener { private static final double DELTA_DEGRESS = 1.0; - public DeviceOrientationService(DeviceOrientationManager manager, Context context) { + public DeviceOrientationService(DeviceMotionAndOrientationManager manager, Context context) { mManager = manager; assert(mManager != null); mContext = context; diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index d7f46afab1ae..8cd9f6860cb5 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -35,7 +35,7 @@ import android.view.KeyEvent; import android.view.SurfaceView; import android.view.View; import android.webkit.DeviceMotionService; -import android.webkit.DeviceOrientationManager; +import android.webkit.DeviceMotionAndOrientationManager; import android.webkit.DeviceOrientationService; import java.util.ArrayList; @@ -120,7 +120,8 @@ final class WebViewCore { private int mWebkitScrollX = 0; private int mWebkitScrollY = 0; - private DeviceOrientationManager mDeviceOrientationManager = new DeviceOrientationManager(this); + private DeviceMotionAndOrientationManager mDeviceMotionAndOrientationManager = + new DeviceMotionAndOrientationManager(this); private DeviceMotionService mDeviceMotionService; private DeviceOrientationService mDeviceOrientationService; @@ -2535,19 +2536,19 @@ final class WebViewCore { } private void useMockDeviceOrientation() { - mDeviceOrientationManager.useMock(); + mDeviceMotionAndOrientationManager.useMock(); } public void setMockDeviceOrientation(boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma) { - mDeviceOrientationManager.setMockOrientation(canProvideAlpha, alpha, canProvideBeta, beta, - canProvideGamma, gamma); + mDeviceMotionAndOrientationManager.setMockOrientation(canProvideAlpha, alpha, + canProvideBeta, beta, canProvideGamma, gamma); } protected DeviceMotionService getDeviceMotionService() { if (mDeviceMotionService == null) { mDeviceMotionService = - new DeviceMotionService(mDeviceOrientationManager, mContext); + new DeviceMotionService(mDeviceMotionAndOrientationManager, mContext); } return mDeviceMotionService; } @@ -2555,7 +2556,7 @@ final class WebViewCore { protected DeviceOrientationService getDeviceOrientationService() { if (mDeviceOrientationService == null) { mDeviceOrientationService = - new DeviceOrientationService(mDeviceOrientationManager, mContext); + new DeviceOrientationService(mDeviceMotionAndOrientationManager, mContext); } return mDeviceOrientationService; } -- cgit v1.2.3-59-g8ed1b