diff --git a/modules/juce_core/native/juce_android_Files.cpp b/modules/juce_core/native/juce_android_Files.cpp index 5c0de20908..3dfa21dafc 100644 --- a/modules/juce_core/native/juce_android_Files.cpp +++ b/modules/juce_core/native/juce_android_Files.cpp @@ -44,7 +44,7 @@ private: { auto* env = getEnv(); - auto methodName = juceString ((jstring) env->CallObjectMethod (method, Method.getName)); + auto methodName = juceString ((jstring) env->CallObjectMethod (method, JavaMethod.getName)); if (methodName == "onMediaScannerConnected") { diff --git a/modules/juce_core/native/juce_android_JNIHelpers.h b/modules/juce_core/native/juce_android_JNIHelpers.h index 1b21e6db47..161aa64ed0 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/modules/juce_core/native/juce_android_JNIHelpers.h @@ -330,76 +330,16 @@ DECLARE_JNI_CLASS (JuceAppActivity, JUCE_ANDROID_ACTIVITY_CLASSPATH); //============================================================================== #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "(I)V") \ - METHOD (setColor, "setColor", "(I)V") \ - METHOD (setAlpha, "setAlpha", "(I)V") \ - METHOD (setTypeface, "setTypeface", "(Landroid/graphics/Typeface;)Landroid/graphics/Typeface;") \ - METHOD (ascent, "ascent", "()F") \ - METHOD (descent, "descent", "()F") \ - METHOD (setTextSize, "setTextSize", "(F)V") \ - METHOD (getTextWidths, "getTextWidths", "(Ljava/lang/String;[F)I") \ - METHOD (setTextScaleX, "setTextScaleX", "(F)V") \ - METHOD (getTextPath, "getTextPath", "(Ljava/lang/String;IIFFLandroid/graphics/Path;)V") \ - METHOD (setShader, "setShader", "(Landroid/graphics/Shader;)Landroid/graphics/Shader;") \ + STATICMETHOD (createBitmap, "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;") \ + METHOD (setPixel, "setPixel", "(III)V") -DECLARE_JNI_CLASS (Paint, "android/graphics/Paint"); -#undef JNI_CLASS_MEMBERS - -//============================================================================== -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "()V") \ - METHOD (setValues, "setValues", "([F)V") \ - -DECLARE_JNI_CLASS (Matrix, "android/graphics/Matrix"); -#undef JNI_CLASS_MEMBERS - -//============================================================================== -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "(IIII)V") \ - FIELD (left, "left", "I") \ - FIELD (right, "right", "I") \ - FIELD (top, "top", "I") \ - FIELD (bottom, "bottom", "I") \ - -DECLARE_JNI_CLASS (RectClass, "android/graphics/Rect"); -#undef JNI_CLASS_MEMBERS - -//============================================================================== -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (getName, "getName", "()Ljava/lang/String;") \ - METHOD (getModifiers, "getModifiers", "()I") \ - METHOD (getParameterTypes, "getParameterTypes", "()[Ljava/lang/Class;") \ - METHOD (getReturnType, "getReturnType", "()Ljava/lang/Class;") \ - METHOD (invoke, "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;") \ - METHOD (hashCode, "hashCode", "()I") \ - METHOD (equals, "equals", "(Ljava/lang/Object;)Z") \ - -DECLARE_JNI_CLASS (Method, "java/lang/reflect/Method"); +DECLARE_JNI_CLASS (AndroidBitmap, "android/graphics/Bitmap"); #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (getName, "getName", "()Ljava/lang/String;") \ - METHOD (getModifiers, "getModifiers", "()I") \ - METHOD (isAnnotation, "isAnnotation", "()Z") \ - METHOD (isAnonymousClass, "isAnonymousClass", "()Z") \ - METHOD (isArray, "isArray", "()Z") \ - METHOD (isEnum, "isEnum", "()Z") \ - METHOD (isInterface, "isInterface", "()Z") \ - METHOD (isLocalClass, "isLocalClass", "()Z") \ - METHOD (isMemberClass, "isMemberClass", "()Z") \ - METHOD (isPrimitive, "isPrimitive", "()Z") \ - METHOD (isSynthetic, "isSynthetic", "()Z") \ - METHOD (getComponentType, "getComponentType", "()Ljava/lang/Class;") \ - METHOD (getSuperclass, "getSuperclass", "()Ljava/lang/Class;") \ - METHOD (getClassLoader, "getClassLoader", "()Ljava/lang/ClassLoader;") \ + STATICMETHOD (valueOf, "valueOf", "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;") -DECLARE_JNI_CLASS (JavaClass, "java/lang/Class"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "()V") \ - -DECLARE_JNI_CLASS (JavaObject, "java/lang/Object"); +DECLARE_JNI_CLASS (AndroidBitmapConfig, "android/graphics/Bitmap$Config"); #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ @@ -418,7 +358,60 @@ DECLARE_JNI_CLASS (JavaObject, "java/lang/Object"); METHOD (setPackage, "setPackage", "(Ljava/lang/String;)Landroid/content/Intent;") \ METHOD (setType, "setType", "(Ljava/lang/String;)Landroid/content/Intent;") \ -DECLARE_JNI_CLASS (Intent, "android/content/Intent"); +DECLARE_JNI_CLASS (AndroidIntent, "android/content/Intent"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "()V") \ + METHOD (setValues, "setValues", "([F)V") \ + +DECLARE_JNI_CLASS (AndroidMatrix, "android/graphics/Matrix"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "(I)V") \ + METHOD (setColor, "setColor", "(I)V") \ + METHOD (setAlpha, "setAlpha", "(I)V") \ + METHOD (setTypeface, "setTypeface", "(Landroid/graphics/Typeface;)Landroid/graphics/Typeface;") \ + METHOD (ascent, "ascent", "()F") \ + METHOD (descent, "descent", "()F") \ + METHOD (setTextSize, "setTextSize", "(F)V") \ + METHOD (getTextWidths, "getTextWidths", "(Ljava/lang/String;[F)I") \ + METHOD (setTextScaleX, "setTextScaleX", "(F)V") \ + METHOD (getTextPath, "getTextPath", "(Ljava/lang/String;IIFFLandroid/graphics/Path;)V") \ + METHOD (setShader, "setShader", "(Landroid/graphics/Shader;)Landroid/graphics/Shader;") \ + +DECLARE_JNI_CLASS (AndroidPaint, "android/graphics/Paint"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + STATICMETHOD (getActivity, "getActivity", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;") \ + METHOD (getIntentSender, "getIntentSender", "()Landroid/content/IntentSender;") + +DECLARE_JNI_CLASS (AndroidPendingIntent, "android/app/PendingIntent"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "(IIII)V") \ + FIELD (left, "left", "I") \ + FIELD (right, "right", "I") \ + FIELD (top, "top", "I") \ + FIELD (bottom, "bottom", "I") \ + +DECLARE_JNI_CLASS (AndroidRectClass, "android/graphics/Rect"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (getIdentifier, "getIdentifier", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I") + +DECLARE_JNI_CLASS (AndroidResources, "android/content/res/Resources") +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + STATICMETHOD (parse, "parse", "(Ljava/lang/String;)Landroid/net/Uri;") \ + METHOD (toString, "toString", "()Ljava/lang/String;") + +DECLARE_JNI_CLASS (AndroidUri, "android/net/Uri"); #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ @@ -445,12 +438,87 @@ DECLARE_JNI_CLASS (AndroidView, "android/view/View"); DECLARE_JNI_CLASS (AndroidViewGroup, "android/view/ViewGroup") #undef JNI_CLASS_MEMBERS +//============================================================================== +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "(I)V") \ + METHOD (add, "add", "(Ljava/lang/Object;)Z") \ + METHOD (iterator, "iterator", "()Ljava/util/Iterator;") \ + METHOD (get, "get", "(I)Ljava/lang/Object;") \ + METHOD (size, "size", "()I") + +DECLARE_JNI_CLASS (JavaArrayList, "java/util/ArrayList"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "()V") \ + METHOD (containsKey, "containsKey", "(Ljava/lang/String;)Z") \ + METHOD (get, "get", "(Ljava/lang/String;)Ljava/lang/Object;") \ + METHOD (getBoolean, "getBoolean", "(Ljava/lang/String;)Z") \ + METHOD (getBundle, "getBundle", "(Ljava/lang/String;)Landroid/os/Bundle;") \ + METHOD (getCharSequence, "getCharSequence", "(Ljava/lang/String;)Ljava/lang/CharSequence;") \ + METHOD (getInt, "getInt", "(Ljava/lang/String;)I") \ + METHOD (getLong, "getLong", "(Ljava/lang/String;)J") \ + METHOD (getLongArray, "getLongArray", "(Ljava/lang/String;)[J") \ + METHOD (getParcelable, "getParcelable", "(Ljava/lang/String;)Landroid/os/Parcelable;") \ + METHOD (getString, "getString", "(Ljava/lang/String;)Ljava/lang/String;") \ + METHOD (getStringArrayList, "getStringArrayList", "(Ljava/lang/String;)Ljava/util/ArrayList;") \ + METHOD (keySet, "keySet", "()Ljava/util/Set;") \ + METHOD (putBoolean, "putBoolean", "(Ljava/lang/String;Z)V") \ + METHOD (putBundle, "putBundle", "(Ljava/lang/String;Landroid/os/Bundle;)V") \ + METHOD (putInt, "putInt", "(Ljava/lang/String;I)V") \ + METHOD (putLong, "putLong", "(Ljava/lang/String;J)V") \ + METHOD (putLongArray, "putLongArray", "(Ljava/lang/String;[J)V") \ + METHOD (putString, "putString", "(Ljava/lang/String;Ljava/lang/String;)V") \ + METHOD (putStringArrayList, "putStringArrayList", "(Ljava/lang/String;Ljava/util/ArrayList;)V") + +DECLARE_JNI_CLASS (JavaBundle, "android/os/Bundle"); +#undef JNI_CLASS_MEMBERS + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (toString, "toString", "()Ljava/lang/String;") DECLARE_JNI_CLASS (JavaCharSequence, "java/lang/CharSequence"); #undef JNI_CLASS_MEMBERS +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (getName, "getName", "()Ljava/lang/String;") \ + METHOD (getModifiers, "getModifiers", "()I") \ + METHOD (isAnnotation, "isAnnotation", "()Z") \ + METHOD (isAnonymousClass, "isAnonymousClass", "()Z") \ + METHOD (isArray, "isArray", "()Z") \ + METHOD (isEnum, "isEnum", "()Z") \ + METHOD (isInterface, "isInterface", "()Z") \ + METHOD (isLocalClass, "isLocalClass", "()Z") \ + METHOD (isMemberClass, "isMemberClass", "()Z") \ + METHOD (isPrimitive, "isPrimitive", "()Z") \ + METHOD (isSynthetic, "isSynthetic", "()Z") \ + METHOD (getComponentType, "getComponentType", "()Ljava/lang/Class;") \ + METHOD (getSuperclass, "getSuperclass", "()Ljava/lang/Class;") \ + METHOD (getClassLoader, "getClassLoader", "()Ljava/lang/ClassLoader;") \ + +DECLARE_JNI_CLASS (JavaClass, "java/lang/Class"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "()V") \ + METHOD (constructorWithCapacity, "", "(I)V") + +DECLARE_JNI_CLASS (JavaHashMap, "java/util/HashMap"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + STATICMETHOD (valueOf, "valueOf", "(I)Ljava/lang/Integer;") + +DECLARE_JNI_CLASS (JavaInteger, "java/lang/Integer"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (hasNext, "hasNext", "()Z") \ + METHOD (next, "next", "()Ljava/lang/Object;") + +DECLARE_JNI_CLASS (JavaIterator, "java/util/Iterator"); +#undef JNI_CLASS_MEMBERS + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (get, "get", "(Ljava/lang/Object;)Ljava/lang/Object;") \ METHOD (keySet, "keySet", "()Ljava/util/Set;") \ @@ -460,10 +528,32 @@ DECLARE_JNI_CLASS (JavaMap, "java/util/Map"); #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "()V") \ - METHOD (constructorWithCapacity, "", "(I)V") + METHOD (getName, "getName", "()Ljava/lang/String;") \ + METHOD (getModifiers, "getModifiers", "()I") \ + METHOD (getParameterTypes, "getParameterTypes", "()[Ljava/lang/Class;") \ + METHOD (getReturnType, "getReturnType", "()Ljava/lang/Class;") \ + METHOD (invoke, "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;") \ + METHOD (hashCode, "hashCode", "()I") \ + METHOD (equals, "equals", "(Ljava/lang/Object;)Z") \ -DECLARE_JNI_CLASS (JavaHashMap, "java/util/HashMap"); +DECLARE_JNI_CLASS (JavaMethod, "java/lang/reflect/Method"); +#undef JNI_CLASS_MEMBERS + + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (constructor, "", "()V") \ + METHOD (getClass, "getClass", "()Ljava/lang/Class;") \ + METHOD (toString, "toString", "()Ljava/lang/String;") + +DECLARE_JNI_CLASS (JavaObject, "java/lang/Object"); +#undef JNI_CLASS_MEMBERS + +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + METHOD (contains, "contains", "(Ljava/lang/Object;)Z") \ + METHOD (iterator, "iterator", "()Ljava/util/Iterator;") \ + METHOD (size, "size", "()I") + +DECLARE_JNI_CLASS (JavaSet, "java/util/Set"); #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ diff --git a/modules/juce_core/native/juce_android_SystemStats.cpp b/modules/juce_core/native/juce_android_SystemStats.cpp index a1bdd59ebd..5f2eb11eef 100644 --- a/modules/juce_core/native/juce_android_SystemStats.cpp +++ b/modules/juce_core/native/juce_android_SystemStats.cpp @@ -159,7 +159,7 @@ LocalRef CreateJavaInterface (AndroidInterfaceImplementer* implementer, jobject AndroidInterfaceImplementer::invoke (jobject /*proxy*/, jobject method, jobjectArray args) { auto* env = getEnv(); - return env->CallObjectMethod (method, Method.invoke, javaSubClass.get(), args); + return env->CallObjectMethod (method, JavaMethod.invoke, javaSubClass.get(), args); } jobject juce_invokeImplementer (JNIEnv* env, jlong thisPtr, jobject proxy, jobject method, jobjectArray args) diff --git a/modules/juce_events/native/juce_android_Messaging.cpp b/modules/juce_events/native/juce_android_Messaging.cpp index 2fae17da54..ec4124720b 100644 --- a/modules/juce_events/native/juce_android_Messaging.cpp +++ b/modules/juce_events/native/juce_android_Messaging.cpp @@ -43,7 +43,7 @@ namespace Android jobject invoke (jobject proxy, jobject method, jobjectArray args) override { auto* env = getEnv(); - auto methodName = juce::juceString ((jstring) env->CallObjectMethod (method, Method.getName)); + auto methodName = juce::juceString ((jstring) env->CallObjectMethod (method, JavaMethod.getName)); if (methodName == "run") { diff --git a/modules/juce_graphics/native/juce_android_Fonts.cpp b/modules/juce_graphics/native/juce_android_Fonts.cpp index e703ca63d7..fb7f7728f8 100644 --- a/modules/juce_graphics/native/juce_android_Fonts.cpp +++ b/modules/juce_graphics/native/juce_android_Fonts.cpp @@ -184,15 +184,15 @@ public: void initialise (JNIEnv* const env) { - rect = GlobalRef (env->NewObject (RectClass, RectClass.constructor, 0, 0, 0, 0)); + rect = GlobalRef (env->NewObject (AndroidRectClass, AndroidRectClass.constructor, 0, 0, 0, 0)); paint = GlobalRef (GraphicsHelpers::createPaint (Graphics::highResamplingQuality)); - const LocalRef ignored (paint.callObjectMethod (Paint.setTypeface, typeface.get())); + const LocalRef ignored (paint.callObjectMethod (AndroidPaint.setTypeface, typeface.get())); - paint.callVoidMethod (Paint.setTextSize, referenceFontSize); + paint.callVoidMethod (AndroidPaint.setTextSize, referenceFontSize); - const float fullAscent = std::abs (paint.callFloatMethod (Paint.ascent)); - const float fullDescent = paint.callFloatMethod (Paint.descent); + const float fullAscent = std::abs (paint.callFloatMethod (AndroidPaint.ascent)); + const float fullDescent = paint.callFloatMethod (AndroidPaint.descent); const float totalHeight = fullAscent + fullDescent; ascent = fullAscent / totalHeight; @@ -210,7 +210,7 @@ public: const int numChars = text.length(); jfloatArray widths = env->NewFloatArray (numChars); - const int numDone = paint.callIntMethod (Paint.getTextWidths, javaString (text).get(), widths); + const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, javaString (text).get(), widths); HeapBlock localWidths (static_cast (numDone)); env->GetFloatArrayRegion (widths, 0, numDone, localWidths); @@ -229,7 +229,7 @@ public: const int numChars = text.length(); jfloatArray widths = env->NewFloatArray (numChars); - const int numDone = paint.callIntMethod (Paint.getTextWidths, javaString (text).get(), widths); + const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, javaString (text).get(), widths); HeapBlock localWidths (static_cast (numDone)); env->GetFloatArrayRegion (widths, 0, numDone, localWidths); @@ -306,10 +306,10 @@ public: env->DeleteLocalRef (matrix); - const int left = env->GetIntField (rect.get(), RectClass.left); - const int top = env->GetIntField (rect.get(), RectClass.top); - const int right = env->GetIntField (rect.get(), RectClass.right); - const int bottom = env->GetIntField (rect.get(), RectClass.bottom); + const int left = env->GetIntField (rect.get(), AndroidRectClass.left); + const int top = env->GetIntField (rect.get(), AndroidRectClass.top); + const int right = env->GetIntField (rect.get(), AndroidRectClass.right); + const int bottom = env->GetIntField (rect.get(), AndroidRectClass.bottom); const Rectangle bounds (left, top, right - left, bottom - top); diff --git a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp index 77dabe2e3f..2b354b2921 100644 --- a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp @@ -38,12 +38,12 @@ namespace GraphicsHelpers if (quality > Graphics::lowResamplingQuality) constructorFlags |= 2; /*FILTER_BITMAP_FLAG*/ - return getEnv()->NewObject (Paint, Paint.constructor, constructorFlags); + return getEnv()->NewObject (AndroidPaint, AndroidPaint.constructor, constructorFlags); } const jobject createMatrix (JNIEnv* env, const AffineTransform& t) { - jobject m = env->NewObject (Matrix, Matrix.constructor); + jobject m = env->NewObject (AndroidMatrix, AndroidMatrix.constructor); jfloat values[9] = { t.mat00, t.mat01, t.mat02, t.mat10, t.mat11, t.mat12, @@ -52,7 +52,7 @@ namespace GraphicsHelpers jfloatArray javaArray = env->NewFloatArray (9); env->SetFloatArrayRegion (javaArray, 0, 9, values); - env->CallVoidMethod (m, Matrix.setValues, javaArray); + env->CallVoidMethod (m, AndroidMatrix.setValues, javaArray); env->DeleteLocalRef (javaArray); return m; diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index d1bd290add..53fbfb4537 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -587,10 +587,10 @@ public: void handlePaintCallback (JNIEnv* env, jobject canvas, jobject paint) { jobject rect = env->CallObjectMethod (canvas, CanvasMinimal.getClipBounds); - const int left = env->GetIntField (rect, RectClass.left); - const int top = env->GetIntField (rect, RectClass.top); - const int right = env->GetIntField (rect, RectClass.right); - const int bottom = env->GetIntField (rect, RectClass.bottom); + const int left = env->GetIntField (rect, AndroidRectClass.left); + const int top = env->GetIntField (rect, AndroidRectClass.top); + const int right = env->GetIntField (rect, AndroidRectClass.right); + const int bottom = env->GetIntField (rect, AndroidRectClass.bottom); env->DeleteLocalRef (rect); const Rectangle clip (left, top, right - left, bottom - top); @@ -876,9 +876,9 @@ JUCE_API void JUCE_CALLTYPE Process::hide() { auto* env = getEnv(); - GlobalRef intent (env->NewObject (Intent, Intent.constructor)); - env->CallObjectMethod (intent, Intent.setAction, javaString ("android.intent.action.MAIN") .get()); - env->CallObjectMethod (intent, Intent.addCategory, javaString ("android.intent.category.HOME").get()); + GlobalRef intent (env->NewObject (AndroidIntent, AndroidIntent.constructor)); + env->CallObjectMethod (intent, AndroidIntent.setAction, javaString ("android.intent.action.MAIN") .get()); + env->CallObjectMethod (intent, AndroidIntent.addCategory, javaString ("android.intent.category.HOME").get()); android.activity.callVoidMethod (JuceAppActivity.startActivity, intent.get()); } diff --git a/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp b/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp index a3fe0c1826..787450cb49 100644 --- a/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp +++ b/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp @@ -38,48 +38,6 @@ DECLARE_JNI_CLASS (AudioAttributesBuilder, "android/media/AudioAttributes$Builde #undef JNI_CLASS_MEMBERS #endif -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - STATICMETHOD (createBitmap, "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;") \ - METHOD (setPixel, "setPixel", "(III)V") - -DECLARE_JNI_CLASS (Bitmap, "android/graphics/Bitmap"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - STATICMETHOD (valueOf, "valueOf", "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;") - -DECLARE_JNI_CLASS (BitmapConfig, "android/graphics/Bitmap$Config"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "()V") \ - METHOD (containsKey, "containsKey", "(Ljava/lang/String;)Z") \ - METHOD (get, "get", "(Ljava/lang/String;)Ljava/lang/Object;") \ - METHOD (getBoolean, "getBoolean", "(Ljava/lang/String;)Z") \ - METHOD (getBundle, "getBundle", "(Ljava/lang/String;)Landroid/os/Bundle;") \ - METHOD (getCharSequence, "getCharSequence", "(Ljava/lang/String;)Ljava/lang/CharSequence;") \ - METHOD (getInt, "getInt", "(Ljava/lang/String;)I") \ - METHOD (getLong, "getLong", "(Ljava/lang/String;)J") \ - METHOD (getLongArray, "getLongArray", "(Ljava/lang/String;)[J") \ - METHOD (getString, "getString", "(Ljava/lang/String;)Ljava/lang/String;") \ - METHOD (keySet, "keySet", "()Ljava/util/Set;") \ - METHOD (putBoolean, "putBoolean", "(Ljava/lang/String;Z)V") \ - METHOD (putBundle, "putBundle", "(Ljava/lang/String;Landroid/os/Bundle;)V") \ - METHOD (putInt, "putInt", "(Ljava/lang/String;I)V") \ - METHOD (putLong, "putLong", "(Ljava/lang/String;J)V") \ - METHOD (putLongArray, "putLongArray", "(Ljava/lang/String;[J)V") \ - METHOD (putString, "putString", "(Ljava/lang/String;Ljava/lang/String;)V") - -DECLARE_JNI_CLASS (Bundle, "android/os/Bundle"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (hasNext, "hasNext", "()Z") \ - METHOD (next, "next", "()Ljava/lang/Object;") - -DECLARE_JNI_CLASS (Iterator, "java/util/Iterator"); -#undef JNI_CLASS_MEMBERS - #if __ANDROID_API__ >= 26 #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "(Ljava/lang/String;Ljava/lang/CharSequence;I)V") \ @@ -244,19 +202,6 @@ DECLARE_JNI_CLASS (NotificationManagerApi26, "android/app/NotificationManager"); #undef JNI_CLASS_MEMBERS #endif -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (getClass, "getClass", "()Ljava/lang/Class;") \ - METHOD (toString, "toString", "()Ljava/lang/String;") - -DECLARE_JNI_CLASS (Object, "java/lang/Object"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - STATICMETHOD (getActivity, "getActivity", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;") - -DECLARE_JNI_CLASS (PendingIntent, "android/app/PendingIntent"); -#undef JNI_CLASS_MEMBERS - #if __ANDROID_API__ >= 20 #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICMETHOD (getResultsFromIntent, "getResultsFromIntent", "(Landroid/content/Intent;)Landroid/os/Bundle;") @@ -275,20 +220,6 @@ DECLARE_JNI_CLASS (RemoteInputBuilder, "android/app/RemoteInput$Builder"); #undef JNI_CLASS_MEMBERS #endif -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (getIdentifier, "getIdentifier", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I") - -DECLARE_JNI_CLASS (Resources, "android/content/res/Resources") -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (contains, "contains", "(Ljava/lang/Object;)Z") \ - METHOD (iterator, "iterator", "()Ljava/util/Iterator;") \ - METHOD (size, "size", "()I") - -DECLARE_JNI_CLASS (Set, "java/util/Set"); -#undef JNI_CLASS_MEMBERS - #if __ANDROID_API__ >= 23 #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getNotification, "getNotification", "()Landroid/app/Notification;") @@ -297,13 +228,6 @@ DECLARE_JNI_CLASS (Set, "java/util/Set"); #undef JNI_CLASS_MEMBERS #endif -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - STATICMETHOD (parse, "parse", "(Ljava/lang/String;)Landroid/net/Uri;") \ - METHOD (toString, "toString", "()Ljava/lang/String;") - -DECLARE_JNI_CLASS (Uri, "android/net/Uri"); -#undef JNI_CLASS_MEMBERS - //========================================================================== #if defined(JUCE_FIREBASE_INSTANCE_ID_SERVICE_CLASSNAME) #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ @@ -465,7 +389,7 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto bundle = LocalRef (env->CallObjectMethod (intent, Intent.getExtras)); + auto bundle = LocalRef (env->CallObjectMethod (intent, AndroidIntent.getExtras)); const auto notification = localNotificationBundleToJuceNotification (bundle); @@ -475,7 +399,7 @@ struct PushNotifications::Pimpl String notificationButtonActionString = packageName + ".JUCE_NOTIFICATION_BUTTON_ACTION."; String notificationTextInputActionString = packageName + ".JUCE_NOTIFICATION_TEXT_INPUT_ACTION."; - auto actionString = juceString ((jstring) env->CallObjectMethod (intent, Intent.getAction)); + auto actionString = juceString ((jstring) env->CallObjectMethod (intent, AndroidIntent.getAction)); if (actionString.contains (notificationString)) { @@ -509,7 +433,7 @@ struct PushNotifications::Pimpl if (remoteInputResult.get() != 0) { - auto charSequence = LocalRef (env->CallObjectMethod (remoteInputResult, Bundle.getCharSequence, resultKeyString.get())); + auto charSequence = LocalRef (env->CallObjectMethod (remoteInputResult, JavaBundle.getCharSequence, resultKeyString.get())); auto responseString = LocalRef ((jstring) env->CallObjectMethod (charSequence, JavaCharSequence.toString)); owner.listeners.call (&PushNotifications::Listener::handleNotificationAction, @@ -534,7 +458,7 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto bundle = LocalRef (env->CallObjectMethod (intent, Intent.getExtras)); + auto bundle = LocalRef (env->CallObjectMethod (intent, AndroidIntent.getExtras)); owner.listeners.call (&PushNotifications::Listener::localNotificationDismissedByUser, localNotificationBundleToJuceNotification (bundle)); @@ -663,7 +587,7 @@ struct PushNotifications::Pimpl #if defined(JUCE_FIREBASE_MESSAGING_SERVICE_CLASSNAME) auto* env = getEnv(); - auto bundle = LocalRef (env->CallObjectMethod (intent, Intent.getExtras)); + auto bundle = LocalRef (env->CallObjectMethod (intent, AndroidIntent.getExtras)); owner.listeners.call (&PushNotifications::Listener::handleNotification, false, remoteNotificationBundleToJuceNotification (bundle)); @@ -792,19 +716,19 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto activityClass = LocalRef (env->CallObjectMethod (android.activity, Object.getClass)); - auto notifyIntent = LocalRef (env->NewObject (Intent, Intent.constructorWithContextAndClass, android.activity.get(), activityClass.get())); + auto activityClass = LocalRef (env->CallObjectMethod (android.activity, JavaObject.getClass)); + auto notifyIntent = LocalRef (env->NewObject (AndroidIntent, AndroidIntent.constructorWithContextAndClass, android.activity.get(), activityClass.get())); auto packageNameString = LocalRef ((jstring) (android.activity.callObjectMethod (JuceAppActivity.getPackageName))); auto actionStringSuffix = javaString (".JUCE_NOTIFICATION." + n.identifier); auto actionString = LocalRef ((jstring)env->CallObjectMethod (packageNameString, JavaString.concat, actionStringSuffix.get())); - env->CallObjectMethod (notifyIntent, Intent.setAction, actionString.get()); + env->CallObjectMethod (notifyIntent, AndroidIntent.setAction, actionString.get()); // Packaging entire notification into extras bundle here, so that we can retrieve all the details later on - env->CallObjectMethod (notifyIntent, Intent.putExtras, juceNotificationToBundle (n).get()); + env->CallObjectMethod (notifyIntent, AndroidIntent.putExtras, juceNotificationToBundle (n).get()); - auto notifyPendingIntent = LocalRef (env->CallStaticObjectMethod (PendingIntent, - PendingIntent.getActivity, + auto notifyPendingIntent = LocalRef (env->CallStaticObjectMethod (AndroidPendingIntent, + AndroidPendingIntent.getActivity, android.activity.get(), 1002, notifyIntent.get(), @@ -815,7 +739,7 @@ struct PushNotifications::Pimpl env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setContentIntent, notifyPendingIntent.get()); auto resources = LocalRef (env->CallObjectMethod (android.activity, JuceAppActivity.getResources)); - const int iconId = env->CallIntMethod (resources, Resources.getIdentifier, javaString (n.icon).get(), + const int iconId = env->CallIntMethod (resources, AndroidResources.getIdentifier, javaString (n.icon).get(), javaString ("raw").get(), packageNameString.get()); env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setSmallIcon, iconId); @@ -841,40 +765,40 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto bundle = LocalRef (env->NewObject (Bundle, Bundle.constructor)); + auto bundle = LocalRef (env->NewObject (JavaBundle, JavaBundle.constructor)); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("identifier") .get(), javaString (n.identifier).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("title") .get(), javaString (n.title).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("body") .get(), javaString (n.body).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("subtitle") .get(), javaString (n.subtitle).get()); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("badgeNumber") .get(), n.badgeNumber); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("soundToPlay") .get(), javaString (n.soundToPlay.toString (true)).get()); - env->CallVoidMethod (bundle, Bundle.putBundle, javaString ("properties") .get(), varToBundleWithPropertiesString (n.properties).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("icon") .get(), javaString (n.icon).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("channelId") .get(), javaString (n.channelId).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("tickerText") .get(), javaString (n.tickerText).get()); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("progressMax") .get(), n.progress.max); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("progressCurrent") .get(), n.progress.current); - env->CallVoidMethod (bundle, Bundle.putBoolean, javaString ("progressIndeterminate") .get(), n.progress.indeterminate); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("person") .get(), javaString (n.person).get()); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("type") .get(), n.type); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("priority") .get(), n.priority); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("lockScreenAppearance") .get(), n.lockScreenAppearance); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("groupId") .get(), javaString (n.groupId).get()); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("groupSortKey") .get(), javaString (n.groupSortKey).get()); - env->CallVoidMethod (bundle, Bundle.putBoolean, javaString ("groupSummary") .get(), n.groupSummary); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("accentColour") .get(), n.accentColour.getARGB()); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("ledColour") .get(), n.ledColour.getARGB()); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("ledBlinkPatternMsToBeOn") .get(), n.ledBlinkPattern.msToBeOn); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("ledBlinkPatternMsToBeOff").get(), n.ledBlinkPattern.msToBeOff); - env->CallVoidMethod (bundle, Bundle.putBoolean, javaString ("shouldAutoCancel") .get(), n.shouldAutoCancel); - env->CallVoidMethod (bundle, Bundle.putBoolean, javaString ("localOnly") .get(), n.localOnly); - env->CallVoidMethod (bundle, Bundle.putBoolean, javaString ("ongoing") .get(), n.ongoing); - env->CallVoidMethod (bundle, Bundle.putBoolean, javaString ("alertOnlyOnce") .get(), n.alertOnlyOnce); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("timestampVisibility") .get(), n.timestampVisibility); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("badgeIconType") .get(), n.badgeIconType); - env->CallVoidMethod (bundle, Bundle.putInt, javaString ("groupAlertBehaviour") .get(), n.groupAlertBehaviour); - env->CallVoidMethod (bundle, Bundle.putLong, javaString ("timeoutAfterMs") .get(), (jlong)n.timeoutAfterMs); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("identifier") .get(), javaString (n.identifier).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("title") .get(), javaString (n.title).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("body") .get(), javaString (n.body).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("subtitle") .get(), javaString (n.subtitle).get()); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("badgeNumber") .get(), n.badgeNumber); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("soundToPlay") .get(), javaString (n.soundToPlay.toString (true)).get()); + env->CallVoidMethod (bundle, JavaBundle.putBundle, javaString ("properties") .get(), varToBundleWithPropertiesString (n.properties).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("icon") .get(), javaString (n.icon).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("channelId") .get(), javaString (n.channelId).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("tickerText") .get(), javaString (n.tickerText).get()); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("progressMax") .get(), n.progress.max); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("progressCurrent") .get(), n.progress.current); + env->CallVoidMethod (bundle, JavaBundle.putBoolean, javaString ("progressIndeterminate") .get(), n.progress.indeterminate); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("person") .get(), javaString (n.person).get()); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("type") .get(), n.type); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("priority") .get(), n.priority); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("lockScreenAppearance") .get(), n.lockScreenAppearance); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("groupId") .get(), javaString (n.groupId).get()); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("groupSortKey") .get(), javaString (n.groupSortKey).get()); + env->CallVoidMethod (bundle, JavaBundle.putBoolean, javaString ("groupSummary") .get(), n.groupSummary); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("accentColour") .get(), n.accentColour.getARGB()); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("ledColour") .get(), n.ledColour.getARGB()); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("ledBlinkPatternMsToBeOn") .get(), n.ledBlinkPattern.msToBeOn); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("ledBlinkPatternMsToBeOff").get(), n.ledBlinkPattern.msToBeOff); + env->CallVoidMethod (bundle, JavaBundle.putBoolean, javaString ("shouldAutoCancel") .get(), n.shouldAutoCancel); + env->CallVoidMethod (bundle, JavaBundle.putBoolean, javaString ("localOnly") .get(), n.localOnly); + env->CallVoidMethod (bundle, JavaBundle.putBoolean, javaString ("ongoing") .get(), n.ongoing); + env->CallVoidMethod (bundle, JavaBundle.putBoolean, javaString ("alertOnlyOnce") .get(), n.alertOnlyOnce); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("timestampVisibility") .get(), n.timestampVisibility); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("badgeIconType") .get(), n.badgeIconType); + env->CallVoidMethod (bundle, JavaBundle.putInt, javaString ("groupAlertBehaviour") .get(), n.groupAlertBehaviour); + env->CallVoidMethod (bundle, JavaBundle.putLong, javaString ("timeoutAfterMs") .get(), (jlong)n.timeoutAfterMs); const int size = n.vibrationPattern.size(); @@ -888,7 +812,7 @@ struct PushNotifications::Pimpl elements[i] = (jlong) n.vibrationPattern[i]; env->SetLongArrayRegion (array, 0, size, elements); - env->CallVoidMethod (bundle, Bundle.putLongArray, javaString ("vibrationPattern").get(), array.get()); + env->CallVoidMethod (bundle, JavaBundle.putLongArray, javaString ("vibrationPattern").get(), array.get()); } return bundle; @@ -981,9 +905,9 @@ struct PushNotifications::Pimpl env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setLocalOnly, n.localOnly); - auto extras = LocalRef (env->NewObject (Bundle, Bundle.constructor)); + auto extras = LocalRef (env->NewObject (JavaBundle, JavaBundle.constructor)); - env->CallVoidMethod (extras, Bundle.putBundle, javaString ("notificationData").get(), + env->CallVoidMethod (extras, JavaBundle.putBundle, javaString ("notificationData").get(), juceNotificationToBundle (n).get()); env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addExtras, extras.get()); @@ -1025,18 +949,18 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto activityClass = LocalRef (env->CallObjectMethod (android.activity, Object.getClass)); - auto deleteIntent = LocalRef (env->NewObject (Intent, Intent.constructorWithContextAndClass, android.activity.get(), activityClass.get())); + auto activityClass = LocalRef (env->CallObjectMethod (android.activity, JavaObject.getClass)); + auto deleteIntent = LocalRef (env->NewObject (AndroidIntent, AndroidIntent.constructorWithContextAndClass, android.activity.get(), activityClass.get())); auto packageNameString = LocalRef ((jstring) (android.activity.callObjectMethod (JuceAppActivity.getPackageName))); auto actionStringSuffix = javaString (".JUCE_NOTIFICATION_DELETED." + n.identifier); auto actionString = LocalRef ((jstring)env->CallObjectMethod (packageNameString, JavaString.concat, actionStringSuffix.get())); - env->CallObjectMethod (deleteIntent, Intent.setAction, actionString.get()); - env->CallObjectMethod (deleteIntent, Intent.putExtras, juceNotificationToBundle (n).get()); + env->CallObjectMethod (deleteIntent, AndroidIntent.setAction, actionString.get()); + env->CallObjectMethod (deleteIntent, AndroidIntent.putExtras, juceNotificationToBundle (n).get()); - auto deletePendingIntent = LocalRef (env->CallStaticObjectMethod (PendingIntent, - PendingIntent.getActivity, + auto deletePendingIntent = LocalRef (env->CallStaticObjectMethod (AndroidPendingIntent, + AndroidPendingIntent.getActivity, android.activity.get(), 1002, deleteIntent.get(), @@ -1054,8 +978,8 @@ struct PushNotifications::Pimpl for (const auto& action : n.actions) { - auto activityClass = LocalRef (env->CallObjectMethod (android.activity, Object.getClass)); - auto notifyIntent = LocalRef (env->NewObject (Intent, Intent.constructorWithContextAndClass, android.activity.get(), activityClass.get())); + auto activityClass = LocalRef (env->CallObjectMethod (android.activity, JavaObject.getClass)); + auto notifyIntent = LocalRef (env->NewObject (AndroidIntent, AndroidIntent.constructorWithContextAndClass, android.activity.get(), activityClass.get())); const bool isTextStyle = action.style == PushNotifications::Notification::Action::text; @@ -1064,23 +988,23 @@ struct PushNotifications::Pimpl auto actionStringSuffix = javaString (notificationActionString + n.identifier + "." + String (actionIndex) + "." + action.title); auto actionString = LocalRef ((jstring)env->CallObjectMethod (packageNameString, JavaString.concat, actionStringSuffix.get())); - env->CallObjectMethod (notifyIntent, Intent.setAction, actionString.get()); + env->CallObjectMethod (notifyIntent, AndroidIntent.setAction, actionString.get()); // Packaging entire notification into extras bundle here, so that we can retrieve all the details later on - env->CallObjectMethod (notifyIntent, Intent.putExtras, juceNotificationToBundle (n).get()); + env->CallObjectMethod (notifyIntent, AndroidIntent.putExtras, juceNotificationToBundle (n).get()); - auto notifyPendingIntent = LocalRef (env->CallStaticObjectMethod (PendingIntent, - PendingIntent.getActivity, + auto notifyPendingIntent = LocalRef (env->CallStaticObjectMethod (AndroidPendingIntent, + AndroidPendingIntent.getActivity, android.activity.get(), 1002, notifyIntent.get(), 0)); auto resources = LocalRef (env->CallObjectMethod (android.activity, JuceAppActivity.getResources)); - int iconId = env->CallIntMethod (resources, Resources.getIdentifier, javaString (action.icon).get(), + int iconId = env->CallIntMethod (resources, AndroidResources.getIdentifier, javaString (action.icon).get(), javaString ("raw").get(), packageNameString.get()); if (iconId == 0) - iconId = env->CallIntMethod (resources, Resources.getIdentifier, javaString (n.icon).get(), + iconId = env->CallIntMethod (resources, AndroidResources.getIdentifier, javaString (n.icon).get(), javaString ("raw").get(), packageNameString.get()); #if __ANDROID_API__ >= 20 @@ -1147,7 +1071,7 @@ struct PushNotifications::Pimpl auto packageNameString = LocalRef ((jstring) (android.activity.callObjectMethod (JuceAppActivity.getPackageName))); auto resources = LocalRef (env->CallObjectMethod (android.activity, JuceAppActivity.getResources)); - const int id = env->CallIntMethod (resources, Resources.getIdentifier, javaString (url.toString (true)).get(), + const int id = env->CallIntMethod (resources, AndroidResources.getIdentifier, javaString (url.toString (true)).get(), javaString ("raw").get(), packageNameString.get()); auto schemeString = javaString ("android.resource://"); @@ -1155,7 +1079,7 @@ struct PushNotifications::Pimpl auto uriString = LocalRef ((jstring) env->CallObjectMethod (schemeString, JavaString.concat, packageNameString.get())); uriString = LocalRef ((jstring) env->CallObjectMethod (uriString, JavaString.concat, resourceString.get())); - return LocalRef (env->CallStaticObjectMethod (Uri, Uri.parse, uriString.get())); + return LocalRef (env->CallStaticObjectMethod (AndroidUri, AndroidUri.parse, uriString.get())); } static LocalRef imagetoJavaBitmap (const Image& image) @@ -1164,16 +1088,19 @@ struct PushNotifications::Pimpl Image imageToUse = image.convertedToFormat (Image::PixelFormat::ARGB); - auto bitmapConfig = LocalRef (env->CallStaticObjectMethod (BitmapConfig, BitmapConfig.valueOf, javaString ("ARGB_8888").get())); - auto bitmap = LocalRef (env->CallStaticObjectMethod (Bitmap, - Bitmap.createBitmap, + auto bitmapConfig = LocalRef (env->CallStaticObjectMethod (AndroidBitmapConfig, + AndroidBitmapConfig.valueOf, + javaString ("ARGB_8888").get())); + + auto bitmap = LocalRef (env->CallStaticObjectMethod (AndroidBitmap, + AndroidBitmap.createBitmap, image.getWidth(), image.getHeight(), bitmapConfig.get())); for (int i = 0; i < image.getWidth(); ++i) for (int j = 0; j < image.getHeight(); ++j) - env->CallVoidMethod (bitmap.get(), Bitmap.setPixel, i, j, image.getPixelAt (i, j).getARGB()); + env->CallVoidMethod (bitmap.get(), AndroidBitmap.setPixel, i, j, image.getPixelAt (i, j).getARGB()); return bitmap; } @@ -1207,8 +1134,8 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto bundle = LocalRef (env->NewObject (Bundle, Bundle.constructor)); - env->CallVoidMethod (bundle, Bundle.putString, javaString ("properties").get(), + auto bundle = LocalRef (env->NewObject (JavaBundle, JavaBundle.constructor)); + env->CallVoidMethod (bundle, JavaBundle.putString, javaString ("properties").get(), javaString (JSON::toString (varToParse, false)).get()); return bundle; @@ -1219,7 +1146,7 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto varString = LocalRef ((jstring)env->CallObjectMethod (bundle, Bundle.getString, + auto varString = LocalRef ((jstring)env->CallObjectMethod (bundle, JavaBundle.getString, javaString ("properties").get())); var resultVar; @@ -1289,9 +1216,9 @@ struct PushNotifications::Pimpl { auto keyString = javaString (key); - if (env->CallBooleanMethod (bundle, Bundle.containsKey, keyString.get())) + if (env->CallBooleanMethod (bundle, JavaBundle.containsKey, keyString.get())) { - auto value = LocalRef ((jstring)env->CallObjectMethod (bundle, Bundle.getString, keyString.get())); + auto value = LocalRef ((jstring)env->CallObjectMethod (bundle, JavaBundle.getString, keyString.get())); return juceString (value); } @@ -1302,8 +1229,8 @@ struct PushNotifications::Pimpl { auto keyString = javaString (key); - if (env->CallBooleanMethod (bundle, Bundle.containsKey, keyString.get())) - return env->CallIntMethod (bundle, Bundle.getInt, keyString.get()); + if (env->CallBooleanMethod (bundle, JavaBundle.containsKey, keyString.get())) + return env->CallIntMethod (bundle, JavaBundle.getInt, keyString.get()); return 0; } @@ -1313,8 +1240,8 @@ struct PushNotifications::Pimpl { auto keyString = javaString (key); - if (env->CallBooleanMethod (bundle, Bundle.containsKey, keyString.get())) - return (int) env->CallLongMethod (bundle, Bundle.getLong, keyString.get()); + if (env->CallBooleanMethod (bundle, JavaBundle.containsKey, keyString.get())) + return (int) env->CallLongMethod (bundle, JavaBundle.getLong, keyString.get()); return 0; } @@ -1323,9 +1250,9 @@ struct PushNotifications::Pimpl { auto keyString = javaString (key); - if (env->CallBooleanMethod (bundle, Bundle.containsKey, keyString.get())) + if (env->CallBooleanMethod (bundle, JavaBundle.containsKey, keyString.get())) { - auto value = LocalRef (env->CallObjectMethod (bundle, Bundle.getBundle, keyString.get())); + auto value = LocalRef (env->CallObjectMethod (bundle, JavaBundle.getBundle, keyString.get())); return bundleWithPropertiesStringToVar (value); } @@ -1336,8 +1263,8 @@ struct PushNotifications::Pimpl { auto keyString = javaString (key); - if (env->CallBooleanMethod (bundle, Bundle.containsKey, keyString.get())) - return env->CallBooleanMethod (bundle, Bundle.getBoolean, keyString.get()); + if (env->CallBooleanMethod (bundle, JavaBundle.containsKey, keyString.get())) + return env->CallBooleanMethod (bundle, JavaBundle.getBoolean, keyString.get()); return false; } @@ -1346,9 +1273,9 @@ struct PushNotifications::Pimpl { auto keyString = javaString (key); - if (env->CallBooleanMethod (bundle, Bundle.containsKey, keyString.get())) + if (env->CallBooleanMethod (bundle, JavaBundle.containsKey, keyString.get())) { - auto array = LocalRef ((jlongArray) env->CallObjectMethod (bundle, Bundle.getLongArray, keyString.get())); + auto array = LocalRef ((jlongArray) env->CallObjectMethod (bundle, JavaBundle.getLongArray, keyString.get())); const int size = env->GetArrayLength (array.get()); @@ -1371,7 +1298,7 @@ struct PushNotifications::Pimpl auto* env = getEnv(); auto extras = LocalRef (env->GetObjectField (notification, AndroidNotification.extras)); - auto notificationData = LocalRef (env->CallObjectMethod (extras, Bundle.getBundle, + auto notificationData = LocalRef (env->CallObjectMethod (extras, JavaBundle.getBundle, javaString ("notificationData").get())); return localNotificationBundleToJuceNotification (notificationData); @@ -1396,20 +1323,20 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto keySet = LocalRef (env->CallObjectMethod (bundle, Bundle.keySet)); - auto iterator = LocalRef (env->CallObjectMethod (keySet, Set.iterator)); + auto keySet = LocalRef (env->CallObjectMethod (bundle, JavaBundle.keySet)); + auto iterator = LocalRef (env->CallObjectMethod (keySet, JavaSet.iterator)); DynamicObject::Ptr dynamicObject = new DynamicObject(); for (;;) { - if (! env->CallBooleanMethod (iterator, Iterator.hasNext)) + if (! env->CallBooleanMethod (iterator, JavaIterator.hasNext)) break; - auto key = LocalRef ((jstring) env->CallObjectMethod (iterator, Iterator.next)); - auto object = LocalRef (env->CallObjectMethod (bundle, Bundle.get, key.get())); - auto objectAsString = LocalRef ((jstring) env->CallObjectMethod (object, Object.toString)); - auto objectClass = LocalRef (env->CallObjectMethod (object, Object.getClass)); + auto key = LocalRef ((jstring) env->CallObjectMethod (iterator, JavaIterator.next)); + auto object = LocalRef (env->CallObjectMethod (bundle, JavaBundle.get, key.get())); + auto objectAsString = LocalRef ((jstring) env->CallObjectMethod (object, JavaObject.toString)); + auto objectClass = LocalRef (env->CallObjectMethod (object, JavaObject.getClass)); auto classAsString = LocalRef ((jstring) env->CallObjectMethod (objectClass, JavaClass.getName)); // Note: seems that Firebase delivers values as strings always, so this check is rather unnecessary, @@ -1442,16 +1369,16 @@ struct PushNotifications::Pimpl const int ttl = env->CallIntMethod (remoteNotification, RemoteMessage.getTtl); auto keySet = LocalRef (env->CallObjectMethod (data, JavaMap.keySet)); - auto iterator = LocalRef (env->CallObjectMethod (keySet, Set.iterator)); + auto iterator = LocalRef (env->CallObjectMethod (keySet, JavaSet.iterator)); DynamicObject::Ptr dataDynamicObject = new DynamicObject(); for (;;) { - if (! env->CallBooleanMethod (iterator, Iterator.hasNext)) + if (! env->CallBooleanMethod (iterator, JavaIterator.hasNext)) break; - auto key = LocalRef ((jstring) env->CallObjectMethod (iterator, Iterator.next)); + auto key = LocalRef ((jstring) env->CallObjectMethod (iterator, JavaIterator.next)); auto value = LocalRef ((jstring) env->CallObjectMethod (data, JavaMap.get, key.get())); dataDynamicObject->setProperty (juceString (key.get()), juceString (value.get())); @@ -1624,7 +1551,7 @@ struct PushNotifications::Pimpl JuceAppActivity.getPackageName)) : String{}; - String intentAction = juceString ((jstring) env->CallObjectMethod (intent, Intent.getAction)); + String intentAction = juceString ((jstring) env->CallObjectMethod (intent, AndroidIntent.getAction)); for (const auto& string : strings) if (intentAction.contains (packageName + string)) @@ -1650,28 +1577,28 @@ struct PushNotifications::Pimpl { auto* env = getEnv(); - auto categories = LocalRef (env->CallObjectMethod (intent, Intent.getCategories)); + auto categories = LocalRef (env->CallObjectMethod (intent, AndroidIntent.getCategories)); int categoriesNum = categories != 0 - ? env->CallIntMethod (categories, Set.size) + ? env->CallIntMethod (categories, JavaSet.size) : 0; if (categoriesNum == 0) return false; - if (! env->CallBooleanMethod (categories, Set.contains, javaString ("android.intent.category.LAUNCHER").get())) + if (! env->CallBooleanMethod (categories, JavaSet.contains, javaString ("android.intent.category.LAUNCHER").get())) return false; if (! intentActionContainsAnyOf (intent, StringArray ("android.intent.action.MAIN"), false)) return false; - auto extras = LocalRef (env->CallObjectMethod (intent, Intent.getExtras)); + auto extras = LocalRef (env->CallObjectMethod (intent, AndroidIntent.getExtras)); if (extras == 0) return false; - return env->CallBooleanMethod (extras, Bundle.containsKey, javaString ("google.sent_time").get()) - && env->CallBooleanMethod (extras, Bundle.containsKey, javaString ("google.message_id").get()); + return env->CallBooleanMethod (extras, JavaBundle.containsKey, javaString ("google.sent_time").get()) + && env->CallBooleanMethod (extras, JavaBundle.containsKey, javaString ("google.message_id").get()); } PushNotifications& owner; diff --git a/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp b/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp index 494de7f60f..d4a4bb9827 100644 --- a/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp @@ -45,48 +45,6 @@ DECLARE_JNI_CLASS (IInAppBillingService, "com/android/vending/billing/IInAppBill DECLARE_JNI_CLASS (IInAppBillingServiceStub, "com/android/vending/billing/IInAppBillingService$Stub"); #undef JNI_CLASS_MEMBERS -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "(I)V") \ - METHOD (add, "add", "(Ljava/lang/Object;)Z") \ - METHOD (iterator, "iterator", "()Ljava/util/Iterator;") \ - METHOD (get, "get", "(I)Ljava/lang/Object;") \ - METHOD (size, "size", "()I") - -DECLARE_JNI_CLASS (ArrayList, "java/util/ArrayList"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (constructor, "", "()V") \ - METHOD (putBoolean, "putBoolean", "(Ljava/lang/String;Z)V") \ - METHOD (putStringArrayList, "putStringArrayList", "(Ljava/lang/String;Ljava/util/ArrayList;)V") \ - METHOD (getInt, "getInt", "(Ljava/lang/String;)I") \ - METHOD (getStringArrayList, "getStringArrayList", "(Ljava/lang/String;)Ljava/util/ArrayList;") \ - METHOD (getString, "getString", "(Ljava/lang/String;)Ljava/lang/String;") \ - METHOD (getParcelable, "getParcelable", "(Ljava/lang/String;)Landroid/os/Parcelable;") - -DECLARE_JNI_CLASS (Bundle, "android/os/Bundle"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - STATICMETHOD (valueOf, "valueOf", "(I)Ljava/lang/Integer;") - -DECLARE_JNI_CLASS (Integer, "java/lang/Integer"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (hasNext, "hasNext", "()Z") \ - METHOD (next, "next", "()Ljava/lang/Object;") - -DECLARE_JNI_CLASS (Iterator, "java/util/Iterator"); -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ - METHOD (getIntentSender, "getIntentSender", "()Landroid/content/IntentSender;") - -DECLARE_JNI_CLASS (PendingIntent, "android/app/PendingIntent"); -#undef JNI_CLASS_MEMBERS - - //============================================================================== struct ServiceConnection : public AndroidInterfaceImplementer { @@ -96,7 +54,7 @@ struct ServiceConnection : public AndroidInterfaceImplementer jobject invoke (jobject proxy, jobject method, jobjectArray args) override { auto* env = getEnv(); - auto methodName = juceString ((jstring) env->CallObjectMethod (method, Method.getName)); + auto methodName = juceString ((jstring) env->CallObjectMethod (method, JavaMethod.getName)); if (methodName == "onServiceConnected") { @@ -124,9 +82,9 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, getInAppPurchaseInstances().add (this); auto* env = getEnv(); - auto intent = env->NewObject (Intent, Intent.constructWithString, + auto intent = env->NewObject (AndroidIntent, AndroidIntent.constructWithString, javaString ("com.android.vending.billing.InAppBillingService.BIND").get()); - env->CallObjectMethod (intent, Intent.setPackage, javaString ("com.android.vending").get()); + env->CallObjectMethod (intent, AndroidIntent.setPackage, javaString ("com.android.vending").get()); serviceConnection = GlobalRef (CreateJavaInterface (this, "android/content/ServiceConnection").get()); android.activity.callBooleanMethod (JuceAppActivity.bindService, intent, @@ -176,19 +134,19 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, auto* env = getEnv(); auto responseCodeString = javaString ("RESPONSE_CODE"); - auto responseCode = env->CallIntMethod (buyIntentBundle.get(), Bundle.getInt, responseCodeString.get()); + auto responseCode = env->CallIntMethod (buyIntentBundle.get(), JavaBundle.getInt, responseCodeString.get()); if (responseCode == 0) { auto buyIntentString = javaString ("BUY_INTENT"); - auto pendingIntent = LocalRef (env->CallObjectMethod (buyIntentBundle.get(), Bundle.getParcelable, buyIntentString.get())); + auto pendingIntent = LocalRef (env->CallObjectMethod (buyIntentBundle.get(), JavaBundle.getParcelable, buyIntentString.get())); auto requestCode = 1001; - auto intentSender = LocalRef (env->CallObjectMethod (pendingIntent.get(), PendingIntent.getIntentSender)); - auto fillInIntent = LocalRef (env->NewObject (Intent, Intent.constructor)); - auto flagsMask = LocalRef (env->CallStaticObjectMethod (Integer, Integer.valueOf, 0)); - auto flagsValues = LocalRef (env->CallStaticObjectMethod (Integer, Integer.valueOf, 0)); - auto extraFlags = LocalRef (env->CallStaticObjectMethod (Integer, Integer.valueOf, 0)); + auto intentSender = LocalRef (env->CallObjectMethod (pendingIntent.get(), AndroidPendingIntent.getIntentSender)); + auto fillInIntent = LocalRef (env->NewObject (AndroidIntent, AndroidIntent.constructor)); + auto flagsMask = LocalRef (env->CallStaticObjectMethod (JavaInteger, JavaInteger.valueOf, 0)); + auto flagsValues = LocalRef (env->CallStaticObjectMethod (JavaInteger, JavaInteger.valueOf, 0)); + auto extraFlags = LocalRef (env->CallStaticObjectMethod (JavaInteger, JavaInteger.valueOf, 0)); android.activity.callVoidMethod (JuceAppActivity.startIntentSenderForResult, intentSender.get(), requestCode, fillInIntent.get(), flagsMask.get(), flagsValues.get(), extraFlags.get()); @@ -270,7 +228,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, getPackageName().get(), skuString.get(), productTypeString.get(), devString.get())); - auto skuList = LocalRef (env->NewObject (ArrayList, ArrayList.constructor, + auto skuList = LocalRef (env->NewObject (JavaArrayList, JavaArrayList.constructor, (int) subscriptionIdentifiers.size())); if (skuList.get() == 0) @@ -280,9 +238,9 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, } for (const auto& identifier : subscriptionIdentifiers) - env->CallBooleanMethod (skuList.get(), ArrayList.add, javaString (identifier).get()); + env->CallBooleanMethod (skuList.get(), JavaArrayList.add, javaString (identifier).get()); - auto extraParams = LocalRef (env->NewObject (Bundle, Bundle.constructor)); + auto extraParams = LocalRef (env->NewObject (JavaBundle, JavaBundle.constructor)); if (extraParams.get() == 0) { @@ -293,8 +251,8 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, auto skusToReplaceString = javaString ("skusToReplace"); auto replaceSkusProrationString = javaString ("replaceSkusProration"); - env->CallVoidMethod (extraParams.get(), Bundle.putStringArrayList, skusToReplaceString.get(), skuList.get()); - env->CallVoidMethod (extraParams.get(), Bundle.putBoolean, replaceSkusProrationString.get(), creditForUnusedSubscription); + env->CallVoidMethod (extraParams.get(), JavaBundle.putStringArrayList, skusToReplaceString.get(), skuList.get()); + env->CallVoidMethod (extraParams.get(), JavaBundle.putBoolean, replaceSkusProrationString.get(), creditForUnusedSubscription); return LocalRef (inAppBillingService.callObjectMethod (IInAppBillingService.getBuyIntentExtraParams, 6, getPackageName().get(), skuString.get(), @@ -437,22 +395,22 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, { auto* env = getEnv(); - auto skuList = LocalRef (env->NewObject (ArrayList, ArrayList.constructor, productIdentifiersToQuery.size())); + auto skuList = LocalRef (env->NewObject (JavaArrayList, JavaArrayList.constructor, productIdentifiersToQuery.size())); if (skuList.get() == 0) return LocalRef (0); for (const auto& pi : productIdentifiersToQuery) - env->CallBooleanMethod (skuList.get(), ArrayList.add, javaString (pi).get()); + env->CallBooleanMethod (skuList.get(), JavaArrayList.add, javaString (pi).get()); - auto querySkus = LocalRef (env->NewObject (Bundle, Bundle.constructor)); + auto querySkus = LocalRef (env->NewObject (JavaBundle, JavaBundle.constructor)); if (querySkus.get() == 0) return LocalRef (0); auto itemIdListString = javaString ("ITEM_ID_LIST"); - env->CallVoidMethod (querySkus.get(), Bundle.putStringArrayList, itemIdListString.get(), skuList.get()); + env->CallVoidMethod (querySkus.get(), JavaBundle.putStringArrayList, itemIdListString.get(), skuList.get()); auto productTypeString = javaString (productType); @@ -473,27 +431,27 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, auto responseCodeString = javaString ("RESPONSE_CODE"); - auto responseCode = env->CallIntMethod (retrievedProducts.get(), Bundle.getInt, responseCodeString.get()); + auto responseCode = env->CallIntMethod (retrievedProducts.get(), JavaBundle.getInt, responseCodeString.get()); if (responseCode == 0) { auto detailsListString = javaString ("DETAILS_LIST"); - auto responseList = LocalRef (env->CallObjectMethod (retrievedProducts.get(), Bundle.getStringArrayList, + auto responseList = LocalRef (env->CallObjectMethod (retrievedProducts.get(), JavaBundle.getStringArrayList, detailsListString.get())); if (responseList != 0) { - auto iterator = LocalRef (env->CallObjectMethod (responseList.get(), ArrayList.iterator)); + auto iterator = LocalRef (env->CallObjectMethod (responseList.get(), JavaArrayList.iterator)); if (iterator.get() != 0) { for (;;) { - if (! env->CallBooleanMethod (iterator, Iterator.hasNext)) + if (! env->CallBooleanMethod (iterator, JavaIterator.hasNext)) break; - auto response = juce::LocalRef ((jstring)env->CallObjectMethod (iterator, Iterator.next)); + auto response = juce::LocalRef ((jstring)env->CallObjectMethod (iterator, JavaIterator.next)); if (response.get() != 0) { @@ -601,7 +559,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, if (ownedItems.get() != 0) { auto responseCodeString = javaString ("RESPONSE_CODE"); - auto responseCode = env->CallIntMethod (ownedItems.get(), Bundle.getInt, responseCodeString.get()); + auto responseCode = env->CallIntMethod (ownedItems.get(), JavaBundle.getInt, responseCodeString.get()); if (responseCode == 0) { @@ -610,16 +568,16 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, auto signatureListString = javaString ("INAPP_DATA_SIGNATURE_LIST"); auto continuationTokenString = javaString ("INAPP_CONTINUATION_TOKEN"); - auto ownedSkus = LocalRef (env->CallObjectMethod (ownedItems.get(), Bundle.getStringArrayList, itemListString.get())); - auto purchaseDataList = LocalRef (env->CallObjectMethod (ownedItems.get(), Bundle.getStringArrayList, dataListString.get())); - auto signatureList = LocalRef (env->CallObjectMethod (ownedItems.get(), Bundle.getStringArrayList, signatureListString.get())); - auto newContinuationToken = LocalRef ((jstring) env->CallObjectMethod (ownedItems.get(), Bundle.getString, continuationTokenString.get())); + auto ownedSkus = LocalRef (env->CallObjectMethod (ownedItems.get(), JavaBundle.getStringArrayList, itemListString.get())); + auto purchaseDataList = LocalRef (env->CallObjectMethod (ownedItems.get(), JavaBundle.getStringArrayList, dataListString.get())); + auto signatureList = LocalRef (env->CallObjectMethod (ownedItems.get(), JavaBundle.getStringArrayList, signatureListString.get())); + auto newContinuationToken = LocalRef ((jstring) env->CallObjectMethod (ownedItems.get(), JavaBundle.getString, continuationTokenString.get())); - for (auto i = 0; i < env->CallIntMethod (purchaseDataList.get(), ArrayList.size); ++i) + for (auto i = 0; i < env->CallIntMethod (purchaseDataList.get(), JavaArrayList.size); ++i) { - auto sku = juceString ((jstring) (env->CallObjectMethod (ownedSkus.get(), ArrayList.get, i))); - auto purchaseData = juceString ((jstring) (env->CallObjectMethod (purchaseDataList.get(), ArrayList.get, i))); - auto signature = juceString ((jstring) (env->CallObjectMethod (signatureList.get(), ArrayList.get, i))); + auto sku = juceString ((jstring) (env->CallObjectMethod (ownedSkus.get(), JavaArrayList.get, i))); + auto purchaseData = juceString ((jstring) (env->CallObjectMethod (purchaseDataList.get(), JavaArrayList.get, i))); + auto signature = juceString ((jstring) (env->CallObjectMethod (signatureList.get(), JavaArrayList.get, i))); var responseData = JSON::parse (purchaseData); @@ -727,19 +685,19 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, auto* env = getEnv(); auto responseCodeString = javaString ("RESPONSE_CODE"); - auto responseCode = env->CallIntMethod (ownedItems.get(), Bundle.getInt, responseCodeString.get()); + auto responseCode = env->CallIntMethod (ownedItems.get(), JavaBundle.getInt, responseCodeString.get()); if (responseCode == 0) { auto dataListString = javaString ("INAPP_PURCHASE_DATA_LIST"); auto continuationTokenString = javaString ("INAPP_CONTINUATION_TOKEN"); - auto purchaseDataList = LocalRef (env->CallObjectMethod (ownedItems.get(), Bundle.getStringArrayList, dataListString.get())); - auto newContinuationToken = LocalRef ((jstring) env->CallObjectMethod (ownedItems.get(), Bundle.getString, continuationTokenString.get())); + auto purchaseDataList = LocalRef (env->CallObjectMethod (ownedItems.get(), JavaBundle.getStringArrayList, dataListString.get())); + auto newContinuationToken = LocalRef ((jstring) env->CallObjectMethod (ownedItems.get(), JavaBundle.getString, continuationTokenString.get())); - for (auto i = 0; i < env->CallIntMethod (purchaseDataList.get(), ArrayList.size); ++i) + for (auto i = 0; i < env->CallIntMethod (purchaseDataList.get(), JavaArrayList.size); ++i) { - auto purchaseData = juceString ((jstring) (env->CallObjectMethod (purchaseDataList.get(), ArrayList.get, i))); + auto purchaseData = juceString ((jstring) (env->CallObjectMethod (purchaseDataList.get(), JavaArrayList.get, i))); var responseData = JSON::parse (purchaseData); @@ -826,14 +784,14 @@ struct InAppPurchases::Pimpl : private AsyncUpdater, auto inAppDataSignatureString = javaString ("INAPP_DATA_SIGNATURE"); auto responseCodeString = javaString ("RESPONSE_CODE"); - auto pd = LocalRef ((jstring) env->CallObjectMethod (intentData, Intent.getStringExtra, inAppPurchaseDataString.get())); - auto sig = LocalRef ((jstring) env->CallObjectMethod (intentData, Intent.getStringExtra, inAppDataSignatureString.get())); + auto pd = LocalRef ((jstring) env->CallObjectMethod (intentData, AndroidIntent.getStringExtra, inAppPurchaseDataString.get())); + auto sig = LocalRef ((jstring) env->CallObjectMethod (intentData, AndroidIntent.getStringExtra, inAppDataSignatureString.get())); auto purchaseDataString = pd.get() != 0 ? juceString (pd.get()) : String(); auto dataSignatureString = sig.get() != 0 ? juceString (sig.get()) : String(); var responseData = JSON::parse (purchaseDataString); - auto responseCode = env->CallIntMethod (intentData, Intent.getIntExtra, responseCodeString.get()); + auto responseCode = env->CallIntMethod (intentData, AndroidIntent.getIntExtra, responseCodeString.get()); auto statusCodeUserString = statusCodeToUserString (responseCode); if (auto* object = responseData.getDynamicObject())