Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback for onGetPlayerImageError, try/catch failure dialog, manifest merging #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies/gpgex/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gpgex">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-sdk android:minSdkVersion="::ANDROID_MINIMUM_SDK_VERSION::" android:targetSdkVersion="::ANDROID_TARGET_SDK_VERSION::" />
<application android:debuggable="::DEBUG::">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/APP_ID" />
Expand Down
3 changes: 2 additions & 1 deletion dependencies/gpgex/project.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
android.library=true
manifestmerger.enabled = true
target=android-::ANDROID_TARGET_SDK_VERSION::
android.library.reference.1=../extension-api
android.library.reference.2=../google-play-services-basement
android.library.reference.3=../google-play-services-plus
android.library.reference.4=../google-play-services-drive
android.library.reference.5=../google-play-services-games
android.library.reference.6=../google-play-services-base
android.library.reference.6=../google-play-services-base
83 changes: 47 additions & 36 deletions dependencies/gpgex/src/com/gpgex/GameHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public interface GameHelperListener {
SignInFailureReason mSignInFailureReason = null;

// Should we show error dialog boxes?
boolean mShowErrorDialogs = true;
boolean mShowErrorDialogs = false;

// Print debug logs?
boolean mDebugLog = false;
Expand Down Expand Up @@ -809,16 +809,21 @@ public void onConnectionSuspended(int cause) {
}

public void showFailureDialog() {
if (mSignInFailureReason != null) {
int errorCode = mSignInFailureReason.getServiceErrorCode();
int actResp = mSignInFailureReason.getActivityResultCode();

if (mShowErrorDialogs) {
showFailureDialog(mActivity, actResp, errorCode);
} else {
debugLog("Not showing error dialog because mShowErrorDialogs==false. " + "" +
"Error was: " + mSignInFailureReason);
try {
if (mSignInFailureReason != null) {
int errorCode = mSignInFailureReason.getServiceErrorCode();
int actResp = mSignInFailureReason.getActivityResultCode();

if (mShowErrorDialogs) {
showFailureDialog(mActivity, actResp, errorCode);
} else {
debugLog("Not showing error dialog because mShowErrorDialogs==false. " + "" +
"Error was: " + mSignInFailureReason);
}
}
} catch (Exception e) {
debugLog("Could not show failure dialog : " + e.getMessage());
}
}

Expand All @@ -830,34 +835,40 @@ public static void showFailureDialog(Activity activity, int actResp, int errorCo
}
Dialog errorDialog = null;

switch (actResp) {
case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(activity,
GameHelperUtils.R_APP_MISCONFIGURED));
break;
case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(activity,
GameHelperUtils.R_SIGN_IN_FAILED));
break;
case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(activity,
GameHelperUtils.R_LICENSE_FAILED));
break;
default:
// No meaningful Activity response code, so generate default Google
// Play services dialog
errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, activity,
RC_UNUSED, null);
if (errorDialog == null) {
// get fallback dialog
Log.e("GameHelper", "No standard error dialog available. Making fallback dialog.");
errorDialog = makeSimpleDialog(activity,
GameHelperUtils.getString(activity, GameHelperUtils.R_UNKNOWN_ERROR)
+ " " + GameHelperUtils.errorCodeToString(errorCode));
}
}
try {

switch (actResp) {
case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(activity,
GameHelperUtils.R_APP_MISCONFIGURED));
break;
case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(activity,
GameHelperUtils.R_SIGN_IN_FAILED));
break;
case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(activity,
GameHelperUtils.R_LICENSE_FAILED));
break;
default:
// No meaningful Activity response code, so generate default Google
// Play services dialog
errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, activity,
RC_UNUSED, null);
if (errorDialog == null) {
// get fallback dialog
Log.e("GameHelper", "No standard error dialog available. Making fallback dialog.");
errorDialog = makeSimpleDialog(activity,
GameHelperUtils.getString(activity, GameHelperUtils.R_UNKNOWN_ERROR)
+ " " + GameHelperUtils.errorCodeToString(errorCode));
}
}

errorDialog.show();
errorDialog.show();

} catch (Exception e) {
Log.e("GameHelper", "*** Could not show failure dialog : " + e.getMessage());
}
}

static Dialog makeSimpleDialog(Activity activity, String text) {
Expand Down
2 changes: 2 additions & 0 deletions dependencies/gpgex/src/com/gpgex/GooglePlayGames.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ public void onResult(Players.LoadPlayersResult loadPlayersResult) {
}catch(Exception e) {
Log.i(TAG, "PlayGames: getPlayerImage Exception");
Log.i(TAG, e.toString());
callbackObject.call1("onGetPlayerImageError", e.toString());
}
}
});
Expand Down Expand Up @@ -331,6 +332,7 @@ public void onImageLoaded(Uri uri, Drawable drawable, boolean isRequestedDrawabl
Log.i(TAG, "PlayGames: getPlayerImage exception trying to save: ");
Log.i(TAG, e.toString());
//TODO: Handle exception
callbackObject.call1("onGetPlayerImageError", e.toString());
}
}
}, uri);
Expand Down
5 changes: 5 additions & 0 deletions extension/gpg/GooglePlayGames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class GooglePlayGames {
public static var onLoadConnectedPlayers : Array<Player>->Void = null;
public static var onLoadInvitablePlayers : Array<Player>->Void = null;
public static var onLoadPlayerImage : String->String->Void = null;
public static var onLoadPlayerImageError : String->Void = null;
public static var onGetPlayerCurrentSteps : String->Int->Void = null;

private static var initted:Bool=false;
Expand Down Expand Up @@ -243,5 +244,9 @@ class GooglePlayGames {
public function onGetPlayerImage(id:String, path:String) {
if(onLoadPlayerImage!=null) Timer.delay(function(){ onLoadPlayerImage(id, path); },0);
}

public function onGetPlayerImageError(e:String) {
if(onLoadPlayerImageError!=null) Timer.delay(function(){ onLoadPlayerImageError(e); },0);
}

}