Squash bugs and use another simpler approach

This commit is contained in:
Wisest_wizard 2021-08-16 16:29:50 +05:30 committed by Wisest_wizard
parent c131fec2da
commit 85b7b4c395
3 changed files with 9 additions and 24 deletions

View File

@ -74,8 +74,11 @@ public class LorieService extends Service {
@Override
public void onCreate() {
if (isServiceRunningInForeground(this, LorieService.class)) return;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String Xdgpath = preferences.getString("CustXDG", "/data/data/com.termux/files/usr/tmp/");
compositor = createLorieThread(Xdgpath);
compositor = createLorieThread();
if (compositor == 0) {
Log.e("LorieService", "compositor thread was not created");
return;
@ -397,7 +400,7 @@ public class LorieService extends Service {
private void keyboardKey(int key, int type, int shift, String characters) {keyboardKey(compositor, key, type, shift, characters);}
private native void keyboardKey(long compositor, int key, int type, int shift, String characters);
private native long createLorieThread();
private native long createLorieThread(String CustXdgpath);
private native void terminate(long compositor);

View File

@ -179,31 +179,12 @@ static LorieBackendAndroid* fromLong(jlong v) {
return u.b;
}
jstring spname(JNIEnv *env) {
return env->NewStringUTF("sharedstore");
}
extern "C" JNIEXPORT jlong JNICALL
JNI_DECLARE(LorieService, createLorieThread)(JNIEnv *env, jobject __unused instance) {
JNI_DECLARE(LorieService, createLorieThread)(JNIEnv *env, jobject __unused instance, jstring CustXdgpath) {
jclass spcls = env->FindClass("android/content/SharedPreferences");
jclass contextcls = env->FindClass("android/content/Context");
mainClass = env->NewGlobalRef(activity);
jmethodID mid = env->GetMethodID(contextcls, "getSharedPreferences",
"(Ljava/lang/String;I)Landroid/content/SharedPreferences;");
const char *pathx = env->GetStringUTFChars(CustXdgpath, NULL);
jmethodID midstring = env->GetMethodID(spcls, "getSring",
"(Ljava/lang/String;Z)Z");
jobject jobjectshared = env->CallObjectMethod(mainClass, mid, spname(env), 0);
jstring xdgcustpath = env->CallStringMethod(jobjectshared, mistring, objectname(env), "/data/data/com.termux/files/usr/tmp");
const char *pathxdg = env->GetStringUTFChars(xdgcustpath, 0);
env->ReleaseStringUTFChars(xdgcustpath, pathxdg);
setenv("XDG_RUNTIME_DIR", pathxdg, 1);
setenv("XDG_RUNTIME_DIR", pathx, 1);
return (jlong) new LorieBackendAndroid;
}

View File

@ -24,6 +24,7 @@
android:defaultValue="false"
android:key="showIMEWhileExternalConnected"
android:summary="Show software keyboard while hardware keyboard is connected" />
<CheckBoxPreference
android:title="Reseed Screen While Soft Keyboard is open"
android:defaultValue="false"