Skip to content

Commit

Permalink
dont worry bout it
Browse files Browse the repository at this point in the history
  • Loading branch information
The Judge committed Oct 21, 2024
1 parent 8f42cbc commit 553ea62
Show file tree
Hide file tree
Showing 32 changed files with 509 additions and 617 deletions.
18 changes: 14 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id("com.android.library") version("7.1.0")
id("com.android.application") version("7.1.0")
}

android {
ndkVersion = "26.1.10909125"
compileSdkVersion = "android-32"
compileSdkVersion = "android-34"
defaultConfig {
minSdk 29
multiDexEnabled true
ndk.stl = "c++_shared"
targetSdk 32
targetSdk 34
}

buildTypes {
Expand All @@ -28,6 +28,13 @@ android {
}

buildToolsVersion = "30.0.3"
buildFeatures {
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

build {
Expand All @@ -52,5 +59,8 @@ dependencies {
implementation("androidx.core:core:1.13.1")
implementation("com.microsoft.azure:msal4j:1.14.0")
implementation("com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3")
implementation("blank:unity-classes")
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.8.1'
implementation 'androidx.navigation:navigation-ui:2.8.1'
}
Binary file removed libs/unity-classes.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ dependencyResolutionManagement {
}

rootProject.name = "Pojlib"
include ":jre_lwjgl3glfw", ':wrapper', ':wrapper:launcher', "wrapper:unityLibrary", "wrapper:unityLibrary:xrmanifest.androidlib"
include ":jre_lwjgl3glfw"

21 changes: 19 additions & 2 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pojlib.android">
package="pojlib.android" >

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:allowNativeHeapPointerTagging="false"/>

<application
android:allowNativeHeapPointerTagging="false"
android:extractNativeLibs="true" >
<activity
android:name="pojlib.MainActivity"
android:exported="true"
android:theme="@style/Theme.Pojlib" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
2 changes: 1 addition & 1 deletion src/main/assets/lwjgl/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1728465869857
1729463321072
11 changes: 5 additions & 6 deletions src/main/java/org/lwjgl/glfw/CallbackBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.ArrayList;

import dalvik.annotation.optimization.CriticalNative;
import pojlib.UnityPlayerActivity;
import pojlib.MainActivity;
import pojlib.input.GrabListener;
import pojlib.input.LwjglGlfwKeycode;

Expand Down Expand Up @@ -108,12 +108,12 @@ public static boolean isGrabbing() {
public static @Nullable String accessAndroidClipboard(int type, String copy) {
switch (type) {
case CLIPBOARD_COPY:
UnityPlayerActivity.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy));
MainActivity.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy));
return null;

case CLIPBOARD_PASTE:
if (UnityPlayerActivity.GLOBAL_CLIPBOARD.hasPrimaryClip() && UnityPlayerActivity.GLOBAL_CLIPBOARD.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
return UnityPlayerActivity.GLOBAL_CLIPBOARD.getPrimaryClip().getItemAt(0).getText().toString();
if (MainActivity.GLOBAL_CLIPBOARD.hasPrimaryClip() && MainActivity.GLOBAL_CLIPBOARD.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
return MainActivity.GLOBAL_CLIPBOARD.getPrimaryClip().getItemAt(0).getText().toString();
} else {
return "";
}
Expand Down Expand Up @@ -179,8 +179,7 @@ private static void onGrabStateChanged(final boolean grabbing) {
}

public static void restartUnitySession(Activity activity) {
UnityPlayerActivity unity = (UnityPlayerActivity) activity;
unity.reinitUnity();
MainActivity unity = (MainActivity) activity;
}

public static void addGrabListener(GrabListener listener) {
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/pojlib/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
import com.google.gson.JsonObject;

import pojlib.account.MinecraftAccount;
import pojlib.account.Msa;
import pojlib.util.Logger;
import pojlib.util.json.MinecraftInstances;
import pojlib.util.Constants;
import pojlib.account.LoginHelper;

import java.io.IOException;
import java.util.Date;

/**
* This class is the only class used by the launcher to communicate and talk to pojlib. This keeps pojlib and launcher separate.
Expand Down Expand Up @@ -178,11 +176,6 @@ public static void updateMods(MinecraftInstances instances, MinecraftInstances.I
* or {@link API#load(MinecraftInstances, String)}
*/
public static void launchInstance(Activity activity, MinecraftAccount account, MinecraftInstances.Instance instance) {
try {
UnityPlayerActivity.installLWJGL(activity);
} catch (IOException e) {
Logger.getInstance().appendToLog("WARN! LWJGL install failed, " + e);
}
InstanceHandler.launchInstance(activity, account, instance);
}

Expand Down
58 changes: 58 additions & 0 deletions src/main/java/pojlib/FirstFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package pojlib;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;

import java.util.ArrayList;

import pojlib.android.R;
import pojlib.android.databinding.FragmentFirstBinding;
import pojlib.util.JREUtils;
import pojlib.util.json.MinecraftInstances;

public class FirstFragment extends Fragment {

private FragmentFirstBinding binding;

@Override
public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {

binding = FragmentFirstBinding.inflate(inflater, container, false);
return binding.getRoot();

}

public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

binding.buttonFirst.setOnClickListener(v -> {
NavHostFragment.findNavController(FirstFragment.this)
.navigate(R.id.action_FirstFragment_to_SecondFragment);

MinecraftInstances.Instance instance = new MinecraftInstances.Instance();
instance.gameDir = this.getActivity().getFilesDir().getAbsolutePath();
try {
JREUtils.launchJavaVM(this.getActivity(), new ArrayList<>(), instance);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
);
}

@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}

}
5 changes: 2 additions & 3 deletions src/main/java/pojlib/InstanceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Locale;

import pojlib.account.MinecraftAccount;
import pojlib.account.Msa;
import pojlib.install.FabricMeta;
import pojlib.install.Installer;
import pojlib.install.MinecraftMeta;
Expand Down Expand Up @@ -182,9 +181,9 @@ public static MinecraftInstances.Instance create(Activity activity, MinecraftIns
String clientClasspath = Installer.installClient(minecraftVersionInfo, gameDir);
String minecraftClasspath = Installer.installLibraries(minecraftVersionInfo, gameDir);
String modLoaderClasspath = Installer.installLibraries(finalModLoaderVersionInfo, gameDir);
String lwjgl = UnityPlayerActivity.installLWJGL(activity);
// String lwjgl = MainActivity.installLWJGL(activity);

instance.classpath = clientClasspath + File.pathSeparator + minecraftClasspath + File.pathSeparator + modLoaderClasspath + File.pathSeparator + lwjgl;
instance.classpath = clientClasspath + File.pathSeparator + minecraftClasspath + File.pathSeparator + modLoaderClasspath + File.pathSeparator;

instance.assetsDir = Installer.installAssets(minecraftVersionInfo, gameDir, activity, instance);
} catch (IOException e) {
Expand Down
81 changes: 81 additions & 0 deletions src/main/java/pojlib/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package pojlib;

import android.content.ClipboardManager;
import android.os.Bundle;

import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;

import android.view.View;

import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import org.lwjgl.glfw.CallbackBridge;

import java.util.ArrayList;
import java.util.List;

import fr.spse.gamepad_remapper.RemapperManager;
import fr.spse.gamepad_remapper.RemapperView;
import pojlib.android.databinding.ActivityMain2Binding;

import pojlib.android.R;
import pojlib.input.gamepad.Gamepad;
import pojlib.util.JREUtils;
import pojlib.util.json.MinecraftInstances;

public class MainActivity extends AppCompatActivity {
public static volatile ClipboardManager GLOBAL_CLIPBOARD;
private Gamepad mGamepad = null;

private RemapperManager mInputManager;
private AppBarConfiguration appBarConfiguration;
private ActivityMain2Binding binding;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

binding = ActivityMain2Binding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

setSupportActionBar(binding.toolbar);

NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main2);
appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);

GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);

/*
mInputManager = new RemapperManager(this, new RemapperView.Builder(null)
.remapA(true)
.remapB(true)
.remapX(true)
.remapY(true)
.remapLeftJoystick(true)
.remapRightJoystick(true)
.remapStart(true)
.remapSelect(true)
.remapLeftShoulder(true)
.remapRightShoulder(true)
.remapLeftTrigger(true)
.remapRightTrigger(true)
.remapDpad(true));
CallbackBridge.nativeSetUseInputStackQueue(true);
*/
}

@Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main2);
return NavigationUI.navigateUp(navController, appBarConfiguration)
|| super.onSupportNavigateUp();
}
}
Loading

0 comments on commit 553ea62

Please sign in to comment.