diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 200c03dbee8d23e4d5a0d1c73ca8daab44ffe274..f8341f267b96da7740fbc0cd4887aea4ef94de71 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -16,7 +16,7 @@ <activity android:name="com.wordbattle.game.AndroidLauncher" android:label="@string/app_name" - android:screenOrientation="landscape" + android:screenOrientation="portrait" android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout" android:exported="true"> <intent-filter> diff --git a/android/build.gradle b/android/build.gradle index 0d921dcf3cc2e7a44c9a58180b0c42decc13e124..318d1b298dd219eb7e65f782c64a2654d84708d8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,7 +21,7 @@ android { } defaultConfig { applicationId "com.wordbattle.game" - minSdkVersion 14 + minSdkVersion 19 targetSdkVersion 34 versionCode 1 versionName "1.0" diff --git a/android/src/com/wordbattle/game/AndroidInterfaceClass.java b/android/src/com/wordbattle/game/AndroidInterfaceClass.java new file mode 100644 index 0000000000000000000000000000000000000000..e8fccb0bc21a5b11e0ef5979d4455763d7860fc1 --- /dev/null +++ b/android/src/com/wordbattle/game/AndroidInterfaceClass.java @@ -0,0 +1,24 @@ +package com.wordbattle.game; + +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.wordbattle.game.network.FirebaseInterface; + +public class AndroidInterfaceClass implements FirebaseInterface { + + FirebaseDatabase database; + DatabaseReference myRef; + + + + + public AndroidInterfaceClass() { + database = FirebaseDatabase.getInstance("https://wordbattle-96156-default-rtdb.europe-west1.firebasedatabase.app"); + myRef = database.getReference("message"); + myRef.setValue("HelloWorld"); + } + @Override + public void SomeFunction() { + System.out.println("Something works"); + } +} diff --git a/android/src/com/wordbattle/game/AndroidLauncher.java b/android/src/com/wordbattle/game/AndroidLauncher.java index 31028de422ecb6d5e951a18e2514d96acc2f8c03..0d56652b13e2917bcc099afbd4761c1d6bdf38cd 100644 --- a/android/src/com/wordbattle/game/AndroidLauncher.java +++ b/android/src/com/wordbattle/game/AndroidLauncher.java @@ -1,16 +1,22 @@ package com.wordbattle.game; import android.os.Bundle; +import android.util.Log; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; +import com.google.firebase.FirebaseApp; import com.wordbattle.game.WordBattle; public class AndroidLauncher extends AndroidApplication { @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Log.d("AndroidLauncher", "onCreate is called"); // Add this line for logging + FirebaseApp.initializeApp(this); + + AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); - initialize(new WordBattle(), config); + initialize(new WordBattle(new AndroidInterfaceClass()), config); } } diff --git a/build.gradle b/build.gradle index acde66935ce77c600303187ad43332da5a6081b4..3fbc66520c47fdd747136042de79bee98fb5caab 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,12 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:8.2.1' + classpath 'com.android.tools.build:gradle:8.1.4' + + + classpath 'com.google.gms:google-services:4.4.1' + + } } @@ -45,7 +50,7 @@ project(":desktop") { api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" - api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" + implementation "com.badlogicgames.gdx:gdx-freetype-platform:$libGDXVersion:natives-desktop" } } @@ -66,8 +71,27 @@ project(":android") { natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64" - api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" + // Import the Firebase BoM + implementation platform('com.google.firebase:firebase-bom:32.8.0') + implementation 'com.google.firebase:firebase-database' + implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64" + + + + + // TODO: Add the dependencies for Firebase products you want to use + // When using the BoM, don't specify versions in Firebase dependencies + implementation 'com.google.firebase:firebase-analytics' + + } + + apply plugin: 'com.google.gms.google-services' + } project(":core") { @@ -77,5 +101,16 @@ project(":core") { api "com.badlogicgames.gdx:gdx:$gdxVersion" api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" + implementation "com.badlogicgames.gdx:gdx-freetype:$libGDXVersion" + implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" + + implementation 'com.google.firebase:firebase-database:20.3.1' // Use the latest version + + } + + + } + + diff --git a/core/src/com/wordbattle/game/WordBattle.java b/core/src/com/wordbattle/game/WordBattle.java index 5e0a4acaa55866649644bcef036cf7caf4ac44e1..746de232a7905c152d6465bdffdecd26608cd6ea 100644 --- a/core/src/com/wordbattle/game/WordBattle.java +++ b/core/src/com/wordbattle/game/WordBattle.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.ScreenUtils; +import com.wordbattle.game.network.FirebaseInterface; import com.wordbattle.game.states.MainMenuState; import com.wordbattle.game.states.StateManager; @@ -15,10 +16,14 @@ public class WordBattle extends ApplicationAdapter { public static final String TITLE = "WordBattle"; private StateManager stateManager; public SpriteBatch batch; + FirebaseInterface _FBIC; + public WordBattle(FirebaseInterface FBIC) {_FBIC = FBIC;} + @Override public void create() { + _FBIC.SomeFunction(); batch = new SpriteBatch(); stateManager = new StateManager(); ScreenUtils.clear(1, 0, 0, 1); diff --git a/core/src/com/wordbattle/game/network/FirebaseInterface.java b/core/src/com/wordbattle/game/network/FirebaseInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..84cf3337c2756376c41bf2a8bbbb09864cfe7074 --- /dev/null +++ b/core/src/com/wordbattle/game/network/FirebaseInterface.java @@ -0,0 +1,10 @@ +package com.wordbattle.game.network; + +public interface FirebaseInterface { + + public void SomeFunction(); + + + + +} diff --git a/core/src/com/wordbattle/game/network/FirebaseManager.java b/core/src/com/wordbattle/game/network/FirebaseManager.java index 4c858440db2a2e94baa06304d48d72aae7bc9d6c..c0cf27fbd6029f2ba83d1a3831bf5ca0f9b005c3 100644 --- a/core/src/com/wordbattle/game/network/FirebaseManager.java +++ b/core/src/com/wordbattle/game/network/FirebaseManager.java @@ -1,21 +1,12 @@ package com.wordbattle.game.network; -public class FirebaseManager { - private static FirebaseManager instance; +public class FirebaseManager implements FirebaseInterface { - // Private constructor prevents instantiation from other classes - private FirebaseManager() { - // Initialize your FirebaseManager here - } - - // Lazy initialization of the instance - public static synchronized FirebaseManager getInstance() { - if (instance == null) { - instance = new FirebaseManager(); - } - return instance; - } + @Override + public void SomeFunction() { + System.out.println("Wubbadubdub"); + } } diff --git a/desktop/src/com/wordbattle/game/DesktopInterfaceClass.java b/desktop/src/com/wordbattle/game/DesktopInterfaceClass.java new file mode 100644 index 0000000000000000000000000000000000000000..188041efe5933af7551869d4bfc61c5ba12ba86a --- /dev/null +++ b/desktop/src/com/wordbattle/game/DesktopInterfaceClass.java @@ -0,0 +1,4 @@ +package com.wordbattle.game; + + +import com.wordbattle.game.network.FirebaseInterface; diff --git a/desktop/src/com/wordbattle/game/DesktopLauncher.java b/desktop/src/com/wordbattle/game/DesktopLauncher.java index bf7f92a8f9a245d6985f7cc68aa53ce044d0f2bb..5da15ce5d6aafc15e0c66f1ad5f7d6f233b66279 100644 --- a/desktop/src/com/wordbattle/game/DesktopLauncher.java +++ b/desktop/src/com/wordbattle/game/DesktopLauncher.java @@ -14,6 +14,6 @@ public class DesktopLauncher { String title = WordBattle.TITLE; config.setWindowedMode(width, height); config.setTitle(title); - new Lwjgl3Application(new WordBattle(), config); + new Lwjgl3Application(new WordBattle(new DesktopInterfaceClass()), config); } } diff --git a/gradle.properties b/gradle.properties index c5aae14d864197497597618ba42259db5387d116..18fd0470c32ede630deeeb7658e18fc9dab06dc2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,3 +2,5 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms128m -Xmx1500m org.gradle.configureondemand=false android.enableR8.fullMode=false +android.useAndroidX=true +android.enableJetifier=true