Skip to content

Commit

Permalink
GWT support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Pronold committed Jun 5, 2016
1 parent 014892f commit f808ccc
Show file tree
Hide file tree
Showing 33 changed files with 920 additions and 787 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.2.0
* HTML/GWT support
* Android module comes with proguard settings included.
* minimum requirements are libGDX 1.9.3
* GDXFacebookSystem.install() and GDXFacebookSystem.getFacebook() return now GDXFacebookIF instances.
* GDXFacebookSystem.install() is now deprecated.

0.5.0
* facebook-android-sdk 4.4.0
* fixed bug on Android (Issued #2 and #3)
Expand Down
2 changes: 1 addition & 1 deletion android/proguard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

-keep class com.badlogic.gdx.Gdx { *; }
-keep class com.badlogic.gdx.backends.android.AndroidEventListener { *; }
-keep class de.tomgrill.gdxfacebook.core.GDXFacebook { public protected *; }
-keep class de.tomgrill.gdxfacebook.core.GDXFacebookBasic { public protected *; }
-keep class de.tomgrill.gdxfacebook.core.FallbackGDXFacebook { public protected *; }
-keep class de.tomgrill.gdxfacebook.android.AndroidGDXFacebook{ public protected *; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.tomgrill.gdxfacebook.android;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication;
import de.tomgrill.gdxfacebook.core.GDXFacebookConfig;
import de.tomgrill.gdxfacebook.core.GDXFacebook;
import de.tomgrill.gdxfacebook.core.FacebookLoader;

public class AndroidFacebookLoader implements FacebookLoader {

@Override
public GDXFacebook load(GDXFacebookConfig config) {

AndroidApplication androidApplication = (AndroidApplication) Gdx.app;
AndroidGDXFacebook androidGDXFacebook = new AndroidGDXFacebook(androidApplication, config);
androidApplication.addAndroidEventListener(androidGDXFacebook);

return androidGDXFacebook;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2015 See AUTHORS file.
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -33,7 +33,8 @@
import java.util.ArrayList;
import java.util.Collection;

public class AndroidGDXFacebook extends GDXFacebook implements AndroidEventListener {

public class AndroidGDXFacebook extends GDXFacebookBasic implements AndroidEventListener {

private Activity activity;
private CallbackManager callbackManager;
Expand Down Expand Up @@ -109,7 +110,7 @@ public void signIn(SignInMode mode, Array<String> permissions, GDXFacebookCallba
* If the user has Facebook App installed
* AccessToken.getCurrentAccessToken() will not be NULL
*
* Only when the Facebook App is not installed we need to load the token
* Only when the Facebook App is not installed we need to setup the token
* manually.
* */
loadAccessToken();
Expand All @@ -128,7 +129,13 @@ public void signIn(SignInMode mode, Array<String> permissions, GDXFacebookCallba
}

@Override
public void showGameRequest(GDXFacebookGameRequest request, final GDXFacebookCallback<GameRequestResult> gameRequestCallback) {
@Deprecated
public void showGameRequest(final GDXFacebookGameRequest request, final GDXFacebookCallback<GameRequestResult> gameRequestCallback) {
gameRequest(request, gameRequestCallback);
}

@Override
public void gameRequest(final GDXFacebookGameRequest request, final GDXFacebookCallback<GameRequestResult> gameRequestCallback) {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Starting Game Request dialog.");

GameRequestContent.Builder builder = new GameRequestContent.Builder();
Expand Down Expand Up @@ -213,7 +220,6 @@ public void onError(FacebookException error) {
requestDialog.show(content);
}


@Override
protected void loadAccessToken() {
super.loadAccessToken();
Expand Down
60 changes: 32 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ project(":android") {
compile project(':core')
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.facebook.android:facebook-android-sdk:$androidSDKVersion"

// compile fileTree(dir: 'libs', include: '*.jar')
}
}

Expand Down Expand Up @@ -133,6 +135,14 @@ project(":html") {
dependencies {
compile project(':core')
}
dependencies {

compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"


}
}


Expand Down Expand Up @@ -173,32 +183,26 @@ project(":ios") {



project(":tests-core") {
apply plugin: 'java'

dependencies {
compile project(':core')

compile "junit:junit:$jUnitVersion"
compile "org.mockito:mockito-all:$mockitoVersion"
compile "org.powermock:powermock-mockito-release-full:$powerMockVersion"

testCompile "junit:junit:$jUnitVersion"
testCompile "org.mockito:mockito-all:$mockitoVersion"
testCompile "org.powermock:powermock-mockito-release-full:$powerMockVersion"
}


eclipse {
project {
name = appName + "-tests-core"
}
}
}



//project(":tests-core") {
// apply plugin: 'java'
//
// dependencies {
// compile project(':core')
//
// compile "junit:junit:$jUnitVersion"
// compile "org.mockito:mockito-all:$mockitoVersion"
// compile "org.powermock:powermock-mockito-release-full:$powerMockVersion"
//
// testCompile "junit:junit:$jUnitVersion"
// testCompile "org.mockito:mockito-all:$mockitoVersion"
// testCompile "org.powermock:powermock-mockito-release-full:$powerMockVersion"
// }
//
//
// eclipse {
// project {
// name = appName + "-tests-core"
// }
// }
//}

tasks.eclipse.doLast {
delete ".project"
}
3 changes: 3 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ apply plugin : 'java'
targetCompatibility = 1.7
sourceCompatibility = 1.7

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.test.java.srcDirs = [ "test/" ]


ext {
Expand Down
5 changes: 5 additions & 0 deletions core/src/de/tomgrill/gdxfacebook/core/FacebookLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.tomgrill.gdxfacebook.core;

public interface FacebookLoader {
GDXFacebook load(GDXFacebookConfig config);
}
41 changes: 25 additions & 16 deletions core/src/de/tomgrill/gdxfacebook/core/FallbackGDXFacebook.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;

public class FallbackGDXFacebook extends GDXFacebook {

public FallbackGDXFacebook(GDXFacebookConfig config) {
super(config);
}
public class FallbackGDXFacebook implements GDXFacebook {

@Override
public void signIn(SignInMode mode, Array<String> permissions, GDXFacebookCallback<SignInResult> callback) {
Expand All @@ -38,31 +34,44 @@ public void showGameRequest(GDXFacebookGameRequest request, GDXFacebookCallback<
callback.onError(new GDXFacebookError("Cannot show GameRequest." + GDXFacebookVars.LOG_TAG + " is not installed."));
}

@Override
public void gameRequest(GDXFacebookGameRequest request, GDXFacebookCallback<GameRequestResult> callback) {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot show GameRequest. " + GDXFacebookVars.LOG_TAG + " is not installed.");
callback.onError(new GDXFacebookError("Cannot do graph API request." + GDXFacebookVars.LOG_TAG + " is not installed."));
}

@Override
public GDXFacebookAccessToken getAccessToken() {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot return accessToken. " + GDXFacebookVars.LOG_TAG + " is not installed.");
return null;
public void newGraphRequest(Request request, GDXFacebookCallback<JsonResult> callback) {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot do graph API request. " + GDXFacebookVars.LOG_TAG + " is not installed.");
callback.onError(new GDXFacebookError("Cannot show GameRequest." + GDXFacebookVars.LOG_TAG + " is not installed."));
}

@Override
public void signOut() {
public void api(Request request, GDXFacebookCallback<JsonResult> callback) {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot do graph API request. " + GDXFacebookVars.LOG_TAG + " is not installed.");
callback.onError(new GDXFacebookError("Cannot do graph API request." + GDXFacebookVars.LOG_TAG + " is not installed."));
}

@Override
public void signOut(boolean keepSessionData) {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot sign out. " + GDXFacebookVars.LOG_TAG + " is not installed.");
}

@Override
public boolean isSignedIn() {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "User is not signed in. " + GDXFacebookVars.LOG_TAG + " is not installed.");
return false;
@Deprecated
public GDXFacebookAccessToken getAccessToken() {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot return accessToken. " + GDXFacebookVars.LOG_TAG + " is not installed.");
return null;
}

@Override
protected void startGUISignIn() {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot start GUI sign in. " + GDXFacebookVars.LOG_TAG + " is not installed.");
public void signOut() {
signOut(true);
}

@Override
protected void startSilentSignIn() {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "Cannot start silent sign in. " + GDXFacebookVars.LOG_TAG + " is not installed.");
public boolean isSignedIn() {
Gdx.app.debug(GDXFacebookVars.LOG_TAG, "User is not signed in. " + GDXFacebookVars.LOG_TAG + " is not installed.");
return false;
}
}
Loading

0 comments on commit f808ccc

Please sign in to comment.