This commit is contained in:
InviseDivine
2026-03-11 19:52:59 +02:00
4 changed files with 33 additions and 13 deletions

View File

@@ -468,17 +468,16 @@ public class MainActivity extends NativeActivity {
_userInputStatus = 1; _userInputStatus = 1;
InputMethodManager inputManager = (InputMethodManager)getSystemService("input_method"); InputMethodManager inputManager = (InputMethodManager)getSystemService("input_method");
boolean result = inputManager.showSoftInput(this.getCurrentFocus(), InputMethodManager.SHOW_IMPLICIT); View focused = this.getCurrentFocus();
if (focused != null) {
boolean result = inputManager.showSoftInput(focused, InputMethodManager.SHOW_IMPLICIT);
} else {
// fallback: try to show using decor view token
View decor = getWindow().getDecorView();
if (decor != null) {
inputManager.showSoftInput(decor, InputMethodManager.SHOW_IMPLICIT);
} }
protected void onStart() {
//System.out.println("onStart");
super.onStart();
} }
protected void onResume() {
//System.out.println("onResume");
super.onResume();
} }
protected void onPause() { protected void onPause() {

View File

@@ -583,6 +583,15 @@ public class MainActivity extends Activity {
return kcm.get(keyCode, metaState); return kcm.get(keyCode, metaState);
} }
public void openURL(String url) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(url));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getPlatformStringVar(int id) { public String getPlatformStringVar(int id) {
if (id == 0) return android.os.Build.MODEL; if (id == 0) return android.os.Build.MODEL;
return null; return null;

View File

@@ -151,6 +151,8 @@ public:
_methodGetPixelsPerMillimeter = env->GetMethodID( _activityClass, "getPixelsPerMillimeter", "()F"); _methodGetPixelsPerMillimeter = env->GetMethodID( _activityClass, "getPixelsPerMillimeter", "()F");
_methodGetPlatformStringVar = env->GetMethodID( _activityClass, "getPlatformStringVar", "(I)Ljava/lang/String;"); _methodGetPlatformStringVar = env->GetMethodID( _activityClass, "getPlatformStringVar", "(I)Ljava/lang/String;");
// custom helper to launch external URLs
_methodOpenURL = env->GetMethodID(_activityClass, "openURL", "(Ljava/lang/String;)V");
_classWindow = (jclass)env->NewGlobalRef(env->FindClass("android/view/Window")); _classWindow = (jclass)env->NewGlobalRef(env->FindClass("android/view/Window"));
_classContext = (jclass)env->NewGlobalRef(env->FindClass("android/content/Context")); _classContext = (jclass)env->NewGlobalRef(env->FindClass("android/content/Context"));
@@ -465,7 +467,15 @@ public:
env->ReleaseStringUTFChars(stringVar, str); env->ReleaseStringUTFChars(stringVar, str);
return out; return out;
} }
// Opens a webpage using an Android intent. Called from native code.
virtual void openURL(const std::string& url) {
if (!_isInited || !_methodOpenURL) return;
JVMAttacher ta(_vm);
JNIEnv* env = ta.getEnv();
jstring jurl = env->NewStringUTF(url.c_str());
env->CallVoidMethod(instance, _methodOpenURL, jurl);
env->DeleteLocalRef(jurl);
}
virtual void finish() { virtual void finish() {
if (!_isInited) return; if (!_isInited) return;
if (!_methodFinish) return; if (!_methodFinish) return;
@@ -616,6 +626,7 @@ private:
jmethodID _methodIsNetworkEnabled; jmethodID _methodIsNetworkEnabled;
jmethodID _methodGetPlatformStringVar; jmethodID _methodGetPlatformStringVar;
jmethodID _methodOpenURL; // new JNI method for launching browser
jclass _classWindow; jclass _classWindow;
jclass _classContext; jclass _classContext;

View File

@@ -38,7 +38,8 @@ void CreditsScreen::init() {
_lines.push_back("InviseDivine"); _lines.push_back("InviseDivine");
_lines.push_back("Kolyah35"); _lines.push_back("Kolyah35");
_lines.push_back(""); _lines.push_back("");
_lines.push_back("[Gold]Join our Discord server:[/Gold] [Green]url.....[/Green]"); // avoid color tags around the URL so it isn't mangled by the parser please
_lines.push_back("Join our Discord server: https://discord.gg/c58YesBxve");
_scrollSpeed = 0.5f; _scrollSpeed = 0.5f;
_scrollY = height; // start below screen _scrollY = height; // start below screen
} }