Compare commits

..
16 changed files with 89 additions and 150 deletions

No files matched your search

@@ -55,8 +55,7 @@
</activity>
<activity
android:name=".LauncherActivity"
android:label="@string/app_short_name"
android:windowSoftInputMode="adjustResize"/>
android:label="@string/app_short_name" />
<activity
android:name=".ImportControlActivity"
android:configChanges="keyboard|keyboardHidden"
@@ -18,13 +18,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.BaseAdapter;
import android.widget.Toast;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.core.content.res.ResourcesCompat;
@@ -189,10 +188,7 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
}
public void removeCurrentAccount(){
removeAccount(getSelectedItemPosition());
}
private void removeAccount(int position) {
int position = getSelectedItemPosition();
if(position == 0) return;
File accountFile = new File(Tools.DIR_ACCOUNT_NEW, mAccountList.get(position)+".json");
if(accountFile.exists()) accountFile.delete();
@@ -325,9 +321,8 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
BitmapDrawable oldBitmapDrawable = mHeadDrawable;
if(mSelectecAccount != null){
View layout = getSelectedView();
if(layout != null){
ExtendedTextView view = layout.findViewById(R.id.account_item);
ExtendedTextView view = ((ExtendedTextView) getSelectedView());
if(view != null){
Bitmap bitmap = mSelectecAccount.getSkinFace();
if(bitmap != null) {
mHeadDrawable = new BitmapDrawable(getResources(), bitmap);
@@ -344,7 +339,8 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
}
}
private class AccountAdapter extends ArrayAdapter<String> {
private static class AccountAdapter extends ArrayAdapter<String> {
private final HashMap<String, Drawable> mImageCache = new HashMap<>();
public AccountAdapter(@NonNull Context context, int resource, @NonNull String[] objects) {
@@ -353,19 +349,20 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
@Override
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
return getView(position, convertView, parent);
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
if(convertView == null){
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_minecraft_account, parent, false);
}
ExtendedTextView textview = convertView.findViewById(R.id.account_item);
ImageView deleteButton = convertView.findViewById(R.id.delete_account_button);
ExtendedTextView textview = (ExtendedTextView) convertView;
textview.setText(super.getItem(position));
// Handle the "Add account section"
if(position == 0) {
textview.setCompoundDrawables(ResourcesCompat.getDrawable(parent.getResources(), R.drawable.ic_add, null), null, null, null);
deleteButton.setVisibility(View.GONE);
}
if(position == 0) textview.setCompoundDrawables(ResourcesCompat.getDrawable(parent.getResources(), R.drawable.ic_add, null), null, null, null);
else {
String username = super.getItem(position);
Drawable accountHead = mImageCache.get(username);
@@ -374,37 +371,9 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
mImageCache.put(username, accountHead);
}
textview.setCompoundDrawables(accountHead, null, null, null);
deleteButton.setVisibility(View.VISIBLE);
deleteButton.setOnClickListener(v -> {
showDeleteDialog(getContext(), position);
});
}
return convertView;
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View view = getDropDownView(position, convertView, parent);
view.findViewById(R.id.delete_account_button).setVisibility(View.GONE);
return view;
}
private void showDeleteDialog(Context context, int position) {
new AlertDialog.Builder(context)
.setMessage(R.string.warning_remove_account)
.setPositiveButton(android.R.string.cancel, null)
.setNeutralButton(R.string.global_delete, (dialog, which) -> {
onDetachedFromWindow();
removeAccount(position);
})
.show();
}
}
}
@@ -59,7 +59,7 @@ public class LauncherActivity extends BaseActivity {
private mcAccountSpinner mAccountSpinner;
private FragmentContainerView mFragmentView;
private ImageButton mSettingsButton;
private ImageButton mSettingsButton, mDeleteAccountButton;
private ProgressLayout mProgressLayout;
private ProgressServiceKeeper mProgressServiceKeeper;
private ModloaderInstallTracker mInstallTracker;
@@ -101,6 +101,13 @@ public class LauncherActivity extends BaseActivity {
}
};
/* Listener for account deletion */
private final View.OnClickListener mAccountDeleteButtonListener = v -> new AlertDialog.Builder(this)
.setMessage(R.string.warning_remove_account)
.setPositiveButton(android.R.string.cancel, null)
.setNeutralButton(R.string.global_delete, (dialog, which) -> mAccountSpinner.removeCurrentAccount())
.show();
private final ExtraListener<Boolean> mLaunchGameListener = (key, value) -> {
if(mProgressLayout.hasProcesses()){
Toast.makeText(this, R.string.tasks_ongoing, Toast.LENGTH_LONG).show();
@@ -193,6 +200,7 @@ public class LauncherActivity extends BaseActivity {
ProgressKeeper.addTaskCountListener((mProgressServiceKeeper = new ProgressServiceKeeper(this)));
mSettingsButton.setOnClickListener(mSettingButtonListener);
mDeleteAccountButton.setOnClickListener(mAccountDeleteButtonListener);
ProgressKeeper.addTaskCountListener(mProgressLayout);
ExtraCore.addExtraListener(ExtraConstants.BACK_PREFERENCE, mBackPreferenceListener);
ExtraCore.addExtraListener(ExtraConstants.SELECT_AUTH_METHOD, mSelectAuthMethod);
@@ -335,6 +343,7 @@ public class LauncherActivity extends BaseActivity {
private void bindViews(){
mFragmentView = findViewById(R.id.container_fragment);
mSettingsButton = findViewById(R.id.setting_button);
mDeleteAccountButton = findViewById(R.id.delete_account_button);
mAccountSpinner = findViewById(R.id.account_spinner);
mProgressLayout = findViewById(R.id.progress_layout);
}
@@ -17,15 +17,14 @@ public class RightClickGesture extends ValidatorGesture {
public final void inputEvent() {
if(!mGestureEnabled) return;
if(submit()) {
mGestureStartX = mGestureEndX = CallbackBridge.mouseX;
mGestureStartY = mGestureEndY = CallbackBridge.mouseY;
mGestureStartX = CallbackBridge.mouseX;
mGestureStartY = CallbackBridge.mouseY;
mGestureEnabled = false;
mGestureValid = true;
}
}
public void setMotion(float deltaX, float deltaY) {
System.out.println("set motion called");
mGestureEndX += deltaX;
mGestureEndY += deltaY;
}
@@ -50,7 +49,6 @@ public class RightClickGesture extends ValidatorGesture {
mGestureEnabled = true;
if(!mGestureValid || isSwitching) return;
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY, LeftClickGesture.FINGER_STILL_THRESHOLD);
System.out.println("Right click: " + fingerStill);
if(!fingerStill) return;
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
@@ -55,6 +55,25 @@ static void gl4esi_get_display_dimensions(int* width, int* height) {
*height = 0;
}
static bool already_initialized = false;
static void gl_init_gl4es_internals() {
if(already_initialized) return;
already_initialized = true;
void* gl4es = dlopen("libgl4es_114.so", RTLD_NOLOAD);
if(gl4es == NULL) return;
void (*set_getmainfbsize)(void (*new_getMainFBSize)(int* width, int* height));
set_getmainfbsize = dlsym(gl4es, "set_getmainfbsize");
if(set_getmainfbsize == NULL) goto warn;
set_getmainfbsize(gl4esi_get_display_dimensions);
goto cleanup;
warn:
printf("gl4esinternals warning: gl4es was found but internals not initialized. expect rendering issues.\n");
cleanup:
// dlclose just decreases a ref counter, so this is fine
dlclose(gl4es);
}
gl_render_window_t* gl_init_context(gl_render_window_t *share) {
gl_render_window_t* bundle = malloc(sizeof(gl_render_window_t));
memset(bundle, 0, sizeof(gl_render_window_t));
@@ -126,6 +145,10 @@ void gl_swap_surface(gl_render_window_t* bundle) {
}
void gl_make_current(gl_render_window_t* bundle) {
// Perform initialization here as the renderer may not be loaded when gl_init or gl_init_context is called.
// Yes, even though it is dlopened on MC startup by Pojav, due to linker namespacing weirdness
// on API 29/MIUI it may not be loaded at the point of the gl_init call in the current namespace.
gl_init_gl4es_internals();
if(bundle == NULL) {
if(eglMakeCurrent_p(g_EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
@@ -188,20 +211,3 @@ void gl_swap_interval(int swapInterval) {
eglSwapInterval_p(g_EglDisplay, swapInterval);
}
JNIEXPORT void JNICALL
Java_org_lwjgl_opengl_PojavRendererInit_nativeInitGl4esInternals(JNIEnv *env, jclass clazz,
jobject function_provider) {
__android_log_print(ANDROID_LOG_INFO, g_LogTag, "GL4ES internals initializing...");
jclass funcProviderClass = (*env)->GetObjectClass(env, function_provider);
jmethodID method_getFunctionAddress = (*env)->GetMethodID(env, funcProviderClass, "getFunctionAddress", "(Ljava/lang/CharSequence;)J");
#define GETSYM(N) ((*env)->CallLongMethod(env, function_provider, method_getFunctionAddress, (*env)->NewStringUTF(env, N)));
void (*set_getmainfbsize)(void (*new_getMainFBSize)(int* width, int* height)) = (void*)GETSYM("set_getmainfbsize");
if(set_getmainfbsize != NULL) {
__android_log_print(ANDROID_LOG_INFO, g_LogTag, "GL4ES internals initialized dimension callback");
set_getmainfbsize(gl4esi_get_display_dimensions);
}
#undef GETSYM
}
+1 -1
View File
@@ -173,7 +173,7 @@ static void set_vulkan_ptr(void* ptr) {
void load_vulkan() {
if(getenv("POJAV_ZINK_PREFER_SYSTEM_DRIVER") == NULL &&
android_get_device_api_level() >= 28) { // the loader does not support below that
android_get_device_api_level() >= 29) { // the loader does not support below API 28, turnip requires 29
#ifdef ADRENO_POSSIBLE
void* result = load_turnip_vulkan();
if(result != NULL) {
@@ -57,7 +57,7 @@ jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) {
jobject mouseDownBufferJ = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, field_mouseDownBuffer);
pojav_environ->mouseDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(pojav_environ->runtimeJNIEnvPtr_JRE, mouseDownBufferJ);
hookExec();
installLwjglDlopenHook();
installLinkerBugMitigation();
installEMUIIteratorMititgation();
}
@@ -52,7 +52,7 @@ static jint hooked_ProcessImpl_forkAndExec(JNIEnv *env, jobject process, jint mo
if(strcmp(prog_basename, "xdg-open") == 0) {
// When invoking xdg-open, send the open URL into Android
Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(env, NULL, CLIPBOARD_OPEN, argBlock);
Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(env, NULL, /* CLIPBOARD_OPEN */ 2002, argBlock);
return 0;
}else if(strcmp(prog_basename, "ffmpeg") == 0) {
// When invoking ffmpeg, always replace the program path with the path to ffmpeg from the plugin.
@@ -45,8 +45,8 @@ static jlong ndlopen_bugfix(__attribute__((unused)) JNIEnv *env,
/**
* Install the LWJGL dlopen hook. This allows us to mitigate linker bugs and add custom library overrides.
*/
void installLwjglDlopenHook() {
__android_log_print(ANDROID_LOG_INFO, "LwjglLinkerHook", "Installing LWJGL dlopen() hook");
void installLinkerBugMitigation() {
__android_log_print(ANDROID_LOG_INFO, "LwjglLinkerHook", "API < 30 detected, installing linker bug mitigation");
JNIEnv* env = pojav_environ->runtimeJNIEnvPtr_JRE;
jclass dynamicLinkLoader = (*env)->FindClass(env, "org/lwjgl/system/linux/DynamicLinkLoader");
if(dynamicLinkLoader == NULL) {
+2 -4
View File
@@ -2,9 +2,7 @@
#include <stdbool.h>
#define CLIPBOARD_COPY 2000
#define CLIPBOARD_PASTE 2001
#define CLIPBOARD_OPEN 2002
char** convert_to_char_array(JNIEnv *env, jobjectArray jstringArray);
jobjectArray convert_from_char_array(JNIEnv *env, char **charArray, int num_rows);
@@ -12,7 +10,7 @@ void free_char_array(JNIEnv *env, jobjectArray jstringArray, const char **charAr
jstring convertStringJVM(JNIEnv* srcEnv, JNIEnv* dstEnv, jstring srcStr);
void hookExec();
void installLwjglDlopenHook();
void installLinkerBugMitigation();
void installEMUIIteratorMititgation();
JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNIEnv* env, jclass clazz, jint action, jbyteArray copySrc);
@@ -28,8 +28,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/delete_account_button"
android:layout_width="@dimen/_52sdp"
android:layout_height="@dimen/_42sdp"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_menu_delete_forever"
android:scaleType="fitCenter"
app:layout_constraintEnd_toStartOf="@id/setting_button"
app:layout_constraintTop_toTopOf="parent" />
<!-- Holding most of the dynamic content -->
<androidx.fragment.app.FragmentContainerView
android:id="@+id/container_fragment"
@@ -28,6 +28,19 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/delete_account_button"
android:layout_width="@dimen/_52sdp"
android:layout_height="@dimen/_52sdp"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_menu_delete_forever"
android:scaleType="fitCenter"
android:paddingVertical="@dimen/_8sdp"
app:layout_constraintEnd_toStartOf="@id/setting_button"
app:layout_constraintTop_toTopOf="parent" />
<!-- Holding most of the dynamic content -->
<androidx.fragment.app.FragmentContainerView
android:id="@+id/container_fragment"
@@ -1,39 +1,17 @@
<LinearLayout
<fr.spse.extended_view.ExtendedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="@dimen/_52sdp"
android:layout_width="match_parent"
android:orientation="horizontal">
android:textSize="@dimen/_16ssp"
android:gravity="center_vertical"
android:drawablePadding="@dimen/_6sdp"
android:paddingStart="@dimen/_8sdp"
app:drawableStartSize="@dimen/_30sdp"
<fr.spse.extended_view.ExtendedTextView
android:id="@+id/account_item"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
tools:text="HELLO THERE"
tools:drawableStart="@mipmap/ic_launcher"
android:textSize="@dimen/_16ssp"
android:gravity="center_vertical"
android:drawablePadding="@dimen/_6sdp"
android:paddingStart="@dimen/_8sdp"
app:drawableStartSize="@dimen/_30sdp"
tools:text="HELLO THERE"
tools:drawableStart="@mipmap/ic_launcher"
tools:ignore="RtlSymmetry" />
<!-- Fun fact, if I put an Image button, the spinner fails to put an onclick listener on the extended view -->
<ImageView
android:id="@+id/delete_account_button"
android:layout_width="@dimen/_52sdp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_menu_delete_forever"
android:padding="@dimen/padding_moderate"
/>
</LinearLayout>
tools:ignore="RtlSymmetry" />
@@ -4792,8 +4792,6 @@ public final class GLCapabilities {
GLCapabilities(FunctionProvider provider, Set<String> ext, boolean fc, IntFunction<PointerBuffer> bufferFactory) {
forwardCompatible = fc;
PojavRendererInit.onCreateCapabilities(provider);
PointerBuffer caps = bufferFactory.apply(ADDRESS_BUFFER_SIZE);
OpenGL11 = check_GL11(provider, caps, ext, fc);
@@ -1,39 +0,0 @@
package org.lwjgl.opengl;
import org.lwjgl.system.FunctionProvider;
import org.lwjgl.system.SharedLibrary;
import javax.annotation.Nullable;
/**
* Class for initializing renderer-specific callbacks. Allows to reliably initialize
* any callbacks needed for renderers by using the same FunctionProvider as used for loading
* GL symbols.
* */
public class PojavRendererInit {
public static void onCreateCapabilities(FunctionProvider functionProvider) {
String rendererName = null;
if(functionProvider instanceof SharedLibrary) {
SharedLibrary rendererLibrary = (SharedLibrary) functionProvider;
rendererName = rendererLibrary.getName();
}
if(!isValidString(rendererName)) {
rendererName = System.getProperty("org.lwjgl.opengl.libname");
}
if(!isValidString(rendererName)) {
System.out.println("PojavRendererInit: Failed to find Pojav renderer name! " +
"Renderer-specific initialization may not work properly");
}
// NOTE: hardcoded gl4es libname
if(rendererName.endsWith("libgl4es_114.so")) {
nativeInitGl4esInternals(functionProvider);
}
}
private static boolean isValidString(@Nullable String s) {
return s != null && !s.isEmpty();
}
public static native void nativeInitGl4esInternals(FunctionProvider functionProvider);
}