mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 740190 - Screen Orientation API: implement locking in Android. r=dougt
This commit is contained in:
parent
aaec9372e9
commit
15a94acd89
@ -1855,4 +1855,12 @@ public class GeckoAppShell
|
|||||||
public static void disableScreenOrientationNotifications() {
|
public static void disableScreenOrientationNotifications() {
|
||||||
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void lockScreenOrientation(int aOrientation) {
|
||||||
|
GeckoScreenOrientationListener.getInstance().lockScreenOrientation(aOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unlockScreenOrientation() {
|
||||||
|
GeckoScreenOrientationListener.getInstance().unlockScreenOrientation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,12 @@ import android.content.Context;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.OrientationEventListener;
|
import android.view.OrientationEventListener;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
|
||||||
public class GeckoScreenOrientationListener
|
public class GeckoScreenOrientationListener
|
||||||
{
|
{
|
||||||
|
private static final String LOGTAG = "GeckoScreenOrientationListener";
|
||||||
|
|
||||||
static class OrientationEventListenerImpl extends OrientationEventListener {
|
static class OrientationEventListenerImpl extends OrientationEventListener {
|
||||||
public OrientationEventListenerImpl(Context c) {
|
public OrientationEventListenerImpl(Context c) {
|
||||||
super(c);
|
super(c);
|
||||||
@ -25,10 +28,13 @@ public class GeckoScreenOrientationListener
|
|||||||
static private GeckoScreenOrientationListener sInstance = null;
|
static private GeckoScreenOrientationListener sInstance = null;
|
||||||
|
|
||||||
// Make sure that any change in dom/base/ScreenOrientation.h happens here too.
|
// Make sure that any change in dom/base/ScreenOrientation.h happens here too.
|
||||||
|
static public final short eScreenOrientation_None = 0;
|
||||||
static public final short eScreenOrientation_PortraitPrimary = 1;
|
static public final short eScreenOrientation_PortraitPrimary = 1;
|
||||||
static public final short eScreenOrientation_PortraitSecondary = 2;
|
static public final short eScreenOrientation_PortraitSecondary = 2;
|
||||||
|
static public final short eScreenOrientation_Portrait = 3;
|
||||||
static public final short eScreenOrientation_LandscapePrimary = 4;
|
static public final short eScreenOrientation_LandscapePrimary = 4;
|
||||||
static public final short eScreenOrientation_LandscapeSecondary = 8;
|
static public final short eScreenOrientation_LandscapeSecondary = 8;
|
||||||
|
static public final short eScreenOrientation_Landscape = 12;
|
||||||
|
|
||||||
private short mOrientation;
|
private short mOrientation;
|
||||||
private OrientationEventListenerImpl mListener = null;
|
private OrientationEventListenerImpl mListener = null;
|
||||||
@ -107,7 +113,7 @@ public class GeckoScreenOrientationListener
|
|||||||
} else if (rotation == Surface.ROTATION_90) {
|
} else if (rotation == Surface.ROTATION_90) {
|
||||||
mOrientation = eScreenOrientation_LandscapePrimary;
|
mOrientation = eScreenOrientation_LandscapePrimary;
|
||||||
} else {
|
} else {
|
||||||
Log.e("GeckoScreenOrientationListener", "Unexpected value received! (" + rotation + ")");
|
Log.e(LOGTAG, "Unexpected value received! (" + rotation + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,4 +125,39 @@ public class GeckoScreenOrientationListener
|
|||||||
public short getScreenOrientation() {
|
public short getScreenOrientation() {
|
||||||
return mOrientation;
|
return mOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void lockScreenOrientation(int aOrientation) {
|
||||||
|
int orientation = 0;
|
||||||
|
|
||||||
|
switch (aOrientation) {
|
||||||
|
case eScreenOrientation_PortraitPrimary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_PortraitSecondary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_Portrait:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_LandscapePrimary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_LandscapeSecondary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_Landscape:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e(LOGTAG, "Unexpected value received! (" + aOrientation + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
GeckoApp.mAppContext.setRequestedOrientation(orientation);
|
||||||
|
updateScreenOrientation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unlockScreenOrientation() {
|
||||||
|
GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
updateScreenOrientation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,12 +220,24 @@ GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
|
|||||||
bool
|
bool
|
||||||
LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
|
LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
|
||||||
{
|
{
|
||||||
|
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||||
|
if (!bridge) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bridge->LockScreenOrientation(dom::ScreenOrientationWrapper(aOrientation));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UnlockScreenOrientation()
|
UnlockScreenOrientation()
|
||||||
{
|
{
|
||||||
|
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||||
|
if (!bridge) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bridge->UnlockScreenOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // hal_impl
|
} // hal_impl
|
||||||
|
@ -2052,4 +2052,12 @@ public class GeckoAppShell
|
|||||||
public static void disableScreenOrientationNotifications() {
|
public static void disableScreenOrientationNotifications() {
|
||||||
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void lockScreenOrientation(int aOrientation) {
|
||||||
|
GeckoScreenOrientationListener.getInstance().lockScreenOrientation(aOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unlockScreenOrientation() {
|
||||||
|
GeckoScreenOrientationListener.getInstance().unlockScreenOrientation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,12 @@ import android.content.Context;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.OrientationEventListener;
|
import android.view.OrientationEventListener;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
|
||||||
public class GeckoScreenOrientationListener
|
public class GeckoScreenOrientationListener
|
||||||
{
|
{
|
||||||
|
private static final String LOGTAG = "GeckoScreenOrientationListener";
|
||||||
|
|
||||||
static class OrientationEventListenerImpl extends OrientationEventListener {
|
static class OrientationEventListenerImpl extends OrientationEventListener {
|
||||||
public OrientationEventListenerImpl(Context c) {
|
public OrientationEventListenerImpl(Context c) {
|
||||||
super(c);
|
super(c);
|
||||||
@ -25,10 +28,13 @@ public class GeckoScreenOrientationListener
|
|||||||
static private GeckoScreenOrientationListener sInstance = null;
|
static private GeckoScreenOrientationListener sInstance = null;
|
||||||
|
|
||||||
// Make sure that any change in dom/base/ScreenOrientation.h happens here too.
|
// Make sure that any change in dom/base/ScreenOrientation.h happens here too.
|
||||||
|
static public final short eScreenOrientation_None = 0;
|
||||||
static public final short eScreenOrientation_PortraitPrimary = 1;
|
static public final short eScreenOrientation_PortraitPrimary = 1;
|
||||||
static public final short eScreenOrientation_PortraitSecondary = 2;
|
static public final short eScreenOrientation_PortraitSecondary = 2;
|
||||||
|
static public final short eScreenOrientation_Portrait = 3;
|
||||||
static public final short eScreenOrientation_LandscapePrimary = 4;
|
static public final short eScreenOrientation_LandscapePrimary = 4;
|
||||||
static public final short eScreenOrientation_LandscapeSecondary = 8;
|
static public final short eScreenOrientation_LandscapeSecondary = 8;
|
||||||
|
static public final short eScreenOrientation_Landscape = 12;
|
||||||
|
|
||||||
private short mOrientation;
|
private short mOrientation;
|
||||||
private OrientationEventListenerImpl mListener = null;
|
private OrientationEventListenerImpl mListener = null;
|
||||||
@ -107,7 +113,7 @@ public class GeckoScreenOrientationListener
|
|||||||
} else if (rotation == Surface.ROTATION_90) {
|
} else if (rotation == Surface.ROTATION_90) {
|
||||||
mOrientation = eScreenOrientation_LandscapePrimary;
|
mOrientation = eScreenOrientation_LandscapePrimary;
|
||||||
} else {
|
} else {
|
||||||
Log.e("GeckoScreenOrientationListener", "Unexpected value received! (" + rotation + ")");
|
Log.e(LOGTAG, "Unexpected value received! (" + rotation + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,4 +125,39 @@ public class GeckoScreenOrientationListener
|
|||||||
public short getScreenOrientation() {
|
public short getScreenOrientation() {
|
||||||
return mOrientation;
|
return mOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void lockScreenOrientation(int aOrientation) {
|
||||||
|
int orientation = 0;
|
||||||
|
|
||||||
|
switch (aOrientation) {
|
||||||
|
case eScreenOrientation_PortraitPrimary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_PortraitSecondary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_Portrait:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_LandscapePrimary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_LandscapeSecondary:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
case eScreenOrientation_Landscape:
|
||||||
|
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e(LOGTAG, "Unexpected value received! (" + aOrientation + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
GeckoApp.mAppContext.setRequestedOrientation(orientation);
|
||||||
|
updateScreenOrientation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unlockScreenOrientation() {
|
||||||
|
GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
updateScreenOrientation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,8 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
|||||||
jGetScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getScreenOrientation", "()S");
|
jGetScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getScreenOrientation", "()S");
|
||||||
jEnableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableScreenOrientationNotifications", "()V");
|
jEnableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableScreenOrientationNotifications", "()V");
|
||||||
jDisableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableScreenOrientationNotifications", "()V");
|
jDisableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableScreenOrientationNotifications", "()V");
|
||||||
|
jLockScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "lockScreenOrientation", "(I)V");
|
||||||
|
jUnlockScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "unlockScreenOrientation", "()V");
|
||||||
|
|
||||||
jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
|
jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
|
||||||
jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
|
jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
|
||||||
@ -2095,6 +2097,19 @@ AndroidBridge::DisableScreenOrientationNotifications()
|
|||||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
|
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AndroidBridge::LockScreenOrientation(const dom::ScreenOrientationWrapper& aOrientation)
|
||||||
|
{
|
||||||
|
ALOG_BRIDGE("AndroidBridge::LockScreenOrientation");
|
||||||
|
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jLockScreenOrientation, aOrientation.orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AndroidBridge::UnlockScreenOrientation()
|
||||||
|
{
|
||||||
|
ALOG_BRIDGE("AndroidBridge::UnlockScreenOrientation");
|
||||||
|
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jUnlockScreenOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
/* attribute nsIAndroidBrowserApp browserApp; */
|
/* attribute nsIAndroidBrowserApp browserApp; */
|
||||||
NS_IMETHODIMP nsAndroidBridge::GetBrowserApp(nsIAndroidBrowserApp * *aBrowserApp)
|
NS_IMETHODIMP nsAndroidBridge::GetBrowserApp(nsIAndroidBrowserApp * *aBrowserApp)
|
||||||
|
@ -422,6 +422,8 @@ public:
|
|||||||
void GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation);
|
void GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation);
|
||||||
void EnableScreenOrientationNotifications();
|
void EnableScreenOrientationNotifications();
|
||||||
void DisableScreenOrientationNotifications();
|
void DisableScreenOrientationNotifications();
|
||||||
|
void LockScreenOrientation(const dom::ScreenOrientationWrapper& aOrientation);
|
||||||
|
void UnlockScreenOrientation();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static AndroidBridge *sBridge;
|
static AndroidBridge *sBridge;
|
||||||
@ -530,6 +532,8 @@ protected:
|
|||||||
jmethodID jGetScreenOrientation;
|
jmethodID jGetScreenOrientation;
|
||||||
jmethodID jEnableScreenOrientationNotifications;
|
jmethodID jEnableScreenOrientationNotifications;
|
||||||
jmethodID jDisableScreenOrientationNotifications;
|
jmethodID jDisableScreenOrientationNotifications;
|
||||||
|
jmethodID jLockScreenOrientation;
|
||||||
|
jmethodID jUnlockScreenOrientation;
|
||||||
|
|
||||||
// stuff we need for CallEglCreateWindowSurface
|
// stuff we need for CallEglCreateWindowSurface
|
||||||
jclass jEGLSurfaceImplClass;
|
jclass jEGLSurfaceImplClass;
|
||||||
|
Loading…
Reference in New Issue
Block a user