src/core/android/SDL_android.c
changeset 11865 af91d564aa40
parent 11844 8e2ca40e07f3
child 11921 88a2982221ec
equal deleted inserted replaced
11864:2eff89e82b60 11865:af91d564aa40
   207 static jclass mActivityClass;
   207 static jclass mActivityClass;
   208 
   208 
   209 /* method signatures */
   209 /* method signatures */
   210 static jmethodID midGetNativeSurface;
   210 static jmethodID midGetNativeSurface;
   211 static jmethodID midSetActivityTitle;
   211 static jmethodID midSetActivityTitle;
       
   212 static jmethodID midSetWindowStyle;
   212 static jmethodID midSetOrientation;
   213 static jmethodID midSetOrientation;
   213 static jmethodID midGetContext;
   214 static jmethodID midGetContext;
   214 static jmethodID midIsAndroidTV;
   215 static jmethodID midIsAndroidTV;
   215 static jmethodID midInputGetInputDeviceIds;
   216 static jmethodID midInputGetInputDeviceIds;
   216 static jmethodID midSendMessage;
   217 static jmethodID midSendMessage;
   300 
   301 
   301     midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   302     midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   302                                 "getNativeSurface","()Landroid/view/Surface;");
   303                                 "getNativeSurface","()Landroid/view/Surface;");
   303     midSetActivityTitle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   304     midSetActivityTitle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   304                                 "setActivityTitle","(Ljava/lang/String;)Z");
   305                                 "setActivityTitle","(Ljava/lang/String;)Z");
       
   306     midSetWindowStyle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
       
   307                                 "setWindowStyle","(Z)V");
   305     midSetOrientation = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   308     midSetOrientation = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   306                                 "setOrientation","(IIZLjava/lang/String;)V");
   309                                 "setOrientation","(IIZLjava/lang/String;)V");
   307     midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   310     midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   308                                 "getContext","()Landroid/content/Context;");
   311                                 "getContext","()Landroid/content/Context;");
   309     midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   312     midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   330 
   333 
   331     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   334     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   332     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   335     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   333 
   336 
   334     if (!midGetNativeSurface ||
   337     if (!midGetNativeSurface ||
   335        !midSetActivityTitle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
   338        !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
   336        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
   339        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
   337        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
   340        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
   338        !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables|| !midGetDisplayDPI) {
   341        !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables|| !midGetDisplayDPI) {
   339         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
   342         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
   340     }
   343     }
   905     jstring jtitle = (jstring)((*mEnv)->NewStringUTF(mEnv, title));
   908     jstring jtitle = (jstring)((*mEnv)->NewStringUTF(mEnv, title));
   906     (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetActivityTitle, jtitle);
   909     (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetActivityTitle, jtitle);
   907     (*mEnv)->DeleteLocalRef(mEnv, jtitle);
   910     (*mEnv)->DeleteLocalRef(mEnv, jtitle);
   908 }
   911 }
   909 
   912 
       
   913 void Android_JNI_SetWindowStyle(SDL_bool fullscreen)
       
   914 {
       
   915     JNIEnv *mEnv = Android_JNI_GetEnv();
       
   916     (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
       
   917 }
       
   918 
   910 void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
   919 void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
   911 {
   920 {
   912     JNIEnv *mEnv = Android_JNI_GetEnv();
   921     JNIEnv *mEnv = Android_JNI_GetEnv();
   913 
   922 
   914     jstring jhint = (jstring)((*mEnv)->NewStringUTF(mEnv, (hint ? hint : "")));
   923     jstring jhint = (jstring)((*mEnv)->NewStringUTF(mEnv, (hint ? hint : "")));