diff --git a/gpgs/api/gpgs.script_api b/gpgs/api/gpgs.script_api index 348fb80..f5c7099 100644 --- a/gpgs/api/gpgs.script_api +++ b/gpgs/api/gpgs.script_api @@ -4,6 +4,25 @@ members: +#***************************************************************************************************** + + - name: is_supported + type: function + desc: Check if Google Play Services are available & ready on the device. + + returns: + - name: is_supported + type: boolean + desc: Status of Google Play Services on the device. + + examples: + - desc: |- + ```lua + if gpgs then + local is_supported = gpgs.is_supported() + end + ``` + #***************************************************************************************************** - name: login diff --git a/gpgs/manifests/android/build.gradle b/gpgs/manifests/android/build.gradle index 7e4ef67..8b55abb 100644 --- a/gpgs/manifests/android/build.gradle +++ b/gpgs/manifests/android/build.gradle @@ -1,6 +1,6 @@ dependencies { // https://developers.google.com/android/guides/setup#split - compile 'com.google.android.gms:play-services-base:17.5.0' - compile 'com.google.android.gms:play-services-auth:18.1.0' - compile 'com.google.android.gms:play-services-games:20.0.1' + implementation 'com.google.android.gms:play-services-base:17.5.0' + implementation 'com.google.android.gms:play-services-auth:18.1.0' + implementation 'com.google.android.gms:play-services-games:20.0.1' } diff --git a/gpgs/src/gpgs_extension.cpp b/gpgs/src/gpgs_extension.cpp index f2ca406..6a4629b 100644 --- a/gpgs/src/gpgs_extension.cpp +++ b/gpgs/src/gpgs_extension.cpp @@ -28,6 +28,7 @@ struct GPGS jmethodID m_getServerAuthCode; jmethodID m_isLoggedIn; jmethodID m_setGravityForPopups; + jmethodID m_isSupported; }; struct GPGS_Disk @@ -317,6 +318,11 @@ static int GpgsAuth_isLoggedIn(lua_State* L) return CallBooleanMethod(L, g_gpgs.m_GpgsJNI, g_gpgs.m_isLoggedIn); } +static int GpgsAuth_isSupported(lua_State* L) +{ + return CallBooleanMethod(L, g_gpgs.m_GpgsJNI, g_gpgs.m_isSupported); +} + //****************************************************************************** // GPGPS misc //****************************************************************************** @@ -745,6 +751,8 @@ JNIEXPORT void JNICALL Java_com_defold_gpgs_GpgsJNI_gpgsAddToQueue(JNIEnv * env, static const luaL_reg Gpgs_methods[] = { + //general + {"is_supported", GpgsAuth_isSupported}, //authorization {"login", GpgsAuth_Login}, {"logout", GpgsAuth_Logout}, @@ -860,6 +868,9 @@ static void LuaInit(lua_State* L) static void InitJNIMethods(JNIEnv* env, jclass cls) { + //general + g_gpgs.m_isSupported = env->GetMethodID(cls, "isSupported", "()Z"); + //authorization g_gpgs.m_silentLogin = env->GetMethodID(cls, "silentLogin", "()V"); g_gpgs.m_login = env->GetMethodID(cls, "login", "()V"); diff --git a/gpgs/src/java/com/defold/gpgs/GpgsJNI.java b/gpgs/src/java/com/defold/gpgs/GpgsJNI.java index c23f624..8e1d01c 100644 --- a/gpgs/src/java/com/defold/gpgs/GpgsJNI.java +++ b/gpgs/src/java/com/defold/gpgs/GpgsJNI.java @@ -14,6 +14,8 @@ import com.google.android.gms.auth.api.signin.GoogleSignInClient; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.common.api.ApiException; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.games.Games; import com.google.android.gms.games.GamesClient; import com.google.android.gms.games.Player; @@ -98,6 +100,7 @@ public class GpgsJNI { private String client_id; private boolean is_request_id_token; private boolean is_request_auth_code; + private boolean is_supported; //-------------------------------------------------- // Authorization @@ -176,6 +179,8 @@ public GpgsJNI(Activity activity, boolean is_disk_active, boolean is_request_aut this.is_request_auth_code = is_request_auth_code; this.is_request_id_token = is_request_id_token; + this.is_supported = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity) == ConnectionResult.SUCCESS; + mGoogleSignInClient = GoogleSignIn.getClient(activity, getSignInOptions()); } @@ -327,6 +332,10 @@ public void setGravityForPopups(int gravity) { mGravity = gravity; } + public boolean isSupported() { + return is_supported; + } + //-------------------------------------------------- // GoogleDrive (Snapshots) diff --git a/main/menu.gui b/main/menu.gui index 7d36550..4634b3b 100644 --- a/main/menu.gui +++ b/main/menu.gui @@ -1141,6 +1141,68 @@ nodes { text_leading: 1.0 text_tracking: 0.0 } +nodes { + position { + x: 977.0 + y: 543.094 + z: 0.0 + w: 1.0 + } + rotation { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + size { + x: 300.0 + y: 100.0 + z: 0.0 + w: 1.0 + } + color { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "Support Status" + font: "larryfont" + id: "support_status" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: true + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + template_node_child: false + text_leading: 1.0 + text_tracking: 0.0 +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT max_nodes: 512 diff --git a/main/menu.gui_script b/main/menu.gui_script index ca06764..b7e4759 100644 --- a/main/menu.gui_script +++ b/main/menu.gui_script @@ -17,6 +17,12 @@ local popup_positions = { function init(self) msg.post(".", "acquire_input_focus") self.popup_pos = 3 + + if gpgs and gpgs.is_supported() then + gui.set_text(gui.get_node("support_status"), "Is Supported") + else + gui.set_text(gui.get_node("support_status"), "Not Supported") + end end