Fix dialog display exception

This commit is contained in:
方块君 2022-05-12 18:31:27 +08:00
parent 7f2cc78878
commit 1034405543
3 changed files with 108 additions and 81 deletions

View File

@ -34,6 +34,7 @@ import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
import java.util.regex.Pattern
import kotlin.system.exitProcess
class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
@ -104,11 +105,21 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
}
findMethod("com.miHoYo.GetMobileInfo.MainActivity") { name == "onCreate" }.hookBefore { param ->
activity = param.thisObject as Activity
showDialog()
}
}
private fun showDialog() {
AlertDialog.Builder(activity).apply {
setCancelable(false)
setTitle(moduleRes.getString(R.string.SelectServer))
setMessage(moduleRes.getString(R.string.Tips))
setView(LinearLayout(activity).apply {
setNegativeButton(moduleRes.getString(R.string.Settings)) {_, _ ->
AlertDialog.Builder(activity).apply {
setMessage(moduleRes.getString(R.string.Tips2))
setCancelable(false)
setView(ScrollView(context).apply {
addView(LinearLayout(activity).apply {
orientation = LinearLayout.VERTICAL
addView(EditText(activity).apply {
hint = "http(s)://server.com:1234"
@ -172,6 +183,15 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
}
})
})
})
setPositiveButton(moduleRes.getString(R.string.Back)) { _, _ ->
showDialog()
}
setNeutralButton(moduleRes.getString(R.string.ExitGames)) {_, _ ->
exitProcess(0)
}
}.show()
}
setPositiveButton(moduleRes.getString(R.string.CustomServer)) { _, _ ->
val ip = sp.getString("serverip", "") ?: ""
if (ip == "") {
@ -189,7 +209,6 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
}
}.show()
}
}
inner class MoveOnTouchListener : View.OnTouchListener {
private var originalXPos = 0

View File

@ -4,10 +4,14 @@
<string name="CustomServer">自定义服务器</string>
<string name="OfficialServer">官方服务器</string>
<string name="SelectServer">选择服务器</string>
<string name="Tips">第一次使用请输入好服务器地址后进入官方服务器下载资源,之后便可进入私服。\n强制模式: 强制替换全部域名\n\n请输入服务器地址: </string>
<string name="Tips">第一次使用请输入好服务器地址后进入官方服务器下载资源,之后便可进入私服。</string>
<string name="ForcedMode">强制模式 (需重启)</string>
<string name="ServerAddressError">服务器地址错误</string>
<string name="ProxyList">只代理列表内的地址 (需重启)</string>
<string name="EnableTools">启用悬浮球工具</string>
<string name="HookConfig">Hook 配置文件? (需重启)</string>
<string name="Tips2">强制模式: 强制替换全部域名\n\n请输入服务器地址: </string>
<string name="Back">返回</string>
<string name="ExitGames">退出游戏</string>
<string name="Settings">设置</string>
</resources>

View File

@ -3,10 +3,14 @@
<string name="CustomServer">Custom server</string>
<string name="OfficialServer">Official server</string>
<string name="SelectServer">Select server</string>
<string name="Tips">For the first time, please enter the server address and enter the official server to download resources. Then you can enter the private server.\nForced mode: Forced replacement of all domain names\n\nInput server address: </string>
<string name="Tips">For the first time, please enter the server address and enter the official server to download resources. Then you can enter the private server.</string>
<string name="ForcedMode">Forced mode (restart required)</string>
<string name="ServerAddressError">Server address error.</string>
<string name="ProxyList">Only addresses in the proxy list (restart required)</string>
<string name="EnableTools">Enable tools</string>
<string name="HookConfig">Hook profile? (restart required)</string>
<string name="Tips2">Forced mode: Forced replacement of all domain names\n\nInput server address: </string>
<string name="Back">Back</string>
<string name="ExitGames">Exit games</string>
<string name="Settings">Settings</string>
</resources>