diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-12-09 11:30:00 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-12-09 11:30:00 -0800 |
| commit | c7f7c94034ea0708161af9f718678c70b13c9a8d (patch) | |
| tree | a563b070f9d490b0c9a0b46ecfea7c709b9fda93 /core/java | |
| parent | 5f68d6fafc29bb14b4b407b4221395332409fc9c (diff) | |
| parent | f06364b8c69b0e6b497242ef0d1161a2539c1b5a (diff) | |
| download | frameworks_base-c7f7c94034ea0708161af9f718678c70b13c9a8d.zip frameworks_base-c7f7c94034ea0708161af9f718678c70b13c9a8d.tar.gz frameworks_base-c7f7c94034ea0708161af9f718678c70b13c9a8d.tar.bz2 | |
Merge change Id469ba88 into eclair-mr2
* changes:
Listen for window orientation events.
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 40 |
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); } |
