diff --git a/project/android/src/com/mojang/minecraftpe/MainActivity.java b/project/android/src/com/mojang/minecraftpe/MainActivity.java index 95f33f7..7b1e3ae 100755 --- a/project/android/src/com/mojang/minecraftpe/MainActivity.java +++ b/project/android/src/com/mojang/minecraftpe/MainActivity.java @@ -468,17 +468,16 @@ public class MainActivity extends NativeActivity { _userInputStatus = 1; InputMethodManager inputManager = (InputMethodManager)getSystemService("input_method"); - boolean result = inputManager.showSoftInput(this.getCurrentFocus(), InputMethodManager.SHOW_IMPLICIT); - } - - protected void onStart() { - //System.out.println("onStart"); - super.onStart(); - } - - protected void onResume() { - //System.out.println("onResume"); - super.onResume(); + 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 onPause() { diff --git a/project/android_java/src/com/mojang/minecraftpe/MainActivity.java b/project/android_java/src/com/mojang/minecraftpe/MainActivity.java index e1a7d78..365fbe5 100755 --- a/project/android_java/src/com/mojang/minecraftpe/MainActivity.java +++ b/project/android_java/src/com/mojang/minecraftpe/MainActivity.java @@ -583,6 +583,15 @@ public class MainActivity extends Activity { 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) { if (id == 0) return android.os.Build.MODEL; return null; diff --git a/src/AppPlatform_android.h b/src/AppPlatform_android.h index fb2e10e..6ae271c 100755 --- a/src/AppPlatform_android.h +++ b/src/AppPlatform_android.h @@ -151,6 +151,8 @@ public: _methodGetPixelsPerMillimeter = env->GetMethodID( _activityClass, "getPixelsPerMillimeter", "()F"); _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")); _classContext = (jclass)env->NewGlobalRef(env->FindClass("android/content/Context")); @@ -465,7 +467,15 @@ public: env->ReleaseStringUTFChars(stringVar, str); 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() { if (!_isInited) return; if (!_methodFinish) return; @@ -616,6 +626,7 @@ private: jmethodID _methodIsNetworkEnabled; jmethodID _methodGetPlatformStringVar; + jmethodID _methodOpenURL; // new JNI method for launching browser jclass _classWindow; jclass _classContext; diff --git a/src/client/gui/screens/CreditsScreen.cpp b/src/client/gui/screens/CreditsScreen.cpp index 1412fff..ae2c224 100644 --- a/src/client/gui/screens/CreditsScreen.cpp +++ b/src/client/gui/screens/CreditsScreen.cpp @@ -38,7 +38,8 @@ void CreditsScreen::init() { _lines.push_back("InviseDivine"); _lines.push_back("Kolyah35"); _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; _scrollY = height; // start below screen }