Skip to content
Snippets Groups Projects
Commit d17927e1 authored by Sixten Müller's avatar Sixten Müller
Browse files

Merge branch '5-set-up-firebase' into 'main'

Resolve "Set up Firebase"

Closes #5

See merge request !6
parents e4360344 31f1473a
Branches
No related tags found
1 merge request!6Resolve "Set up Firebase"
......@@ -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>
......
......@@ -21,7 +21,7 @@ android {
}
defaultConfig {
applicationId "com.wordbattle.game"
minSdkVersion 14
minSdkVersion 19
targetSdkVersion 34
versionCode 1
versionName "1.0"
......
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");
}
}
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);
}
}
......@@ -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
}
}
......@@ -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);
......
package com.wordbattle.game.network;
public interface FirebaseInterface {
public void SomeFunction();
}
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");
}
}
package com.wordbattle.game;
import com.wordbattle.game.network.FirebaseInterface;
......@@ -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);
}
}
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment