summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/BrowserFrame.java
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2009-12-02 08:57:09 -0500
committerPatrick Scott <phanna@android.com>2009-12-09 14:27:24 -0500
commitf06364b8c69b0e6b497242ef0d1161a2539c1b5a (patch)
treea5308f44b648ee238bdc5a7fafc3b8dfb28ae676 /core/java/android/webkit/BrowserFrame.java
parent47fabbfcbf99e5e3b73a6ee09059c77932ef1b7b (diff)
downloadframeworks_base-f06364b8c69b0e6b497242ef0d1161a2539c1b5a.zip
frameworks_base-f06364b8c69b0e6b497242ef0d1161a2539c1b5a.tar.gz
frameworks_base-f06364b8c69b0e6b497242ef0d1161a2539c1b5a.tar.bz2
Listen for window orientation events.
These will be sent to webcore as orientation events.
Diffstat (limited to 'core/java/android/webkit/BrowserFrame.java')
-rw-r--r--core/java/android/webkit/BrowserFrame.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index e94f485..f71af20 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -30,6 +30,8 @@ import android.os.Message;
import android.provider.OpenableColumns;
import android.util.Log;
import android.util.TypedValue;
+import android.view.Surface;
+import android.view.WindowOrientationListener;
import junit.framework.Assert;
@@ -67,9 +69,14 @@ class BrowserFrame extends Handler {
// Attached Javascript interfaces
private Map<String, Object> mJSInterfaceMap;
+ // Orientation listener
+ private WindowOrientationListener mOrientationListener;
+
// message ids
// a message posted when a frame loading is completed
static final int FRAME_COMPLETED = 1001;
+ // orientation change message
+ static final int ORIENTATION_CHANGED = 1002;
// a message posted when the user decides the policy
static final int POLICY_FUNCTION = 1003;
@@ -141,6 +148,31 @@ class BrowserFrame extends Handler {
if (DebugFlags.BROWSER_FRAME) {
Log.v(LOGTAG, "BrowserFrame constructor: this=" + this);
}
+
+ mOrientationListener = new WindowOrientationListener(context) {
+ @Override
+ public void onOrientationChanged(int orientation) {
+ switch (orientation) {
+ case Surface.ROTATION_90:
+ orientation = 90;
+ break;
+ case Surface.ROTATION_180:
+ orientation = 180;
+ break;
+ case Surface.ROTATION_270:
+ orientation = -90;
+ break;
+ case Surface.ROTATION_0:
+ orientation = 0;
+ break;
+ default:
+ break;
+ }
+ sendMessage(
+ obtainMessage(ORIENTATION_CHANGED, orientation, 0));
+ }
+ };
+ mOrientationListener.enable();
}
/**
@@ -345,6 +377,7 @@ class BrowserFrame extends Handler {
* Destroy all native components of the BrowserFrame.
*/
public void destroy() {
+ mOrientationListener.disable();
nativeDestroyFrame();
removeCallbacksAndMessages(null);
}
@@ -379,6 +412,11 @@ class BrowserFrame extends Handler {
break;
}
+ case ORIENTATION_CHANGED: {
+ nativeOrientationChanged(msg.arg1);
+ break;
+ }
+
default:
break;
}
@@ -899,4 +937,6 @@ class BrowserFrame extends Handler {
* returns null.
*/
private native HashMap getFormTextData();
+
+ private native void nativeOrientationChanged(int orientation);
}