Fixed bug 3235 - Make the Android window creation similar to iOS' window creation

Sylvain

Here's a patch.
It tries to get the hint first. Resizable will allow any orientation. Otherwise it uses width/height window.

setOrientation method is splitted in static and non-static, so that it can be overloaded in a user subclass.

Some artefact observed :
surfaceChanged() can be called twice at the beginning. When the phone starts in portrait and run a landscape application.
This commit is contained in:
Sam Lantinga 2017-08-13 20:55:59 -07:00
parent 6ef1a25d18
commit 6ee661398d
4 changed files with 72 additions and 0 deletions

View file

@ -636,6 +636,18 @@ void Android_JNI_SetActivityTitle(const char *title)
}
}
void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
{
jmethodID mid;
JNIEnv *mEnv = Android_JNI_GetEnv();
mid = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,"setOrientation","(IIZLjava/lang/String;)V");
if (mid) {
jstring jhint = (jstring)((*mEnv)->NewStringUTF(mEnv, (hint ? hint : "")));
(*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, mid, w, h, (resizable? 1 : 0), jhint);
(*mEnv)->DeleteLocalRef(mEnv, jhint);
}
}
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
{
int i;