79 lines
3.0 KiB
Kotlin
79 lines
3.0 KiB
Kotlin
package com.gh.vspace
|
|
|
|
import android.content.Intent
|
|
import android.os.Bundle
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import androidx.annotation.Keep
|
|
import com.gh.gamecenter.R
|
|
import com.gh.gamecenter.core.utils.ToastUtils
|
|
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
|
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
|
import com.lg.vspace.VaApp
|
|
import com.lg.vspace.plugin.host.PluginHelper
|
|
import com.lightgame.utils.Utils
|
|
import com.lightgame.utils.toast.ToastHelper
|
|
import com.lody.virtual.client.core.VirtualCore
|
|
import java.io.File
|
|
|
|
@Keep
|
|
class ExternalGameUsage : ITestCase {
|
|
|
|
private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) {
|
|
val context = viewParent.context
|
|
viewParent.findViewById<View>(id) ?: run {
|
|
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
|
root.id = id
|
|
fn(this)
|
|
}
|
|
viewParent.addView(binding.root, 0)
|
|
}
|
|
}
|
|
|
|
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
|
val context = viewParent.context
|
|
buttonTemplate(viewParent, R.id.install_game_from_external) {
|
|
it.titleTv.text = context.getString(R.string.title_install_external_game)
|
|
it.iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
|
it.root.setOnClickListener {
|
|
VHelper.connectService {
|
|
context.startActivity(
|
|
InstallExternalGameActivity.getIntent(context)
|
|
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
override fun addInstallPluginButton(viewParent: ViewGroup) {
|
|
buttonTemplate(viewParent, R.id.install_plugin) {
|
|
it.titleTv.text = "安装64位插件"
|
|
it.root.setOnClickListener {
|
|
val file = File("/data/local/tmp/gh-plugins/artifacts.zip")
|
|
if (file.exists()) {
|
|
Utils.log(VHelper.LOG_TAG, "有本地更新文件: 64位插件")
|
|
// TODO: 补充debug插件更新
|
|
ToastUtils.showToast("暂未实现debug功能")
|
|
} else {
|
|
ToastUtils.showToast("data/local/tmp没有push文件")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
override fun addInstallPlugin32Button(viewParent: ViewGroup) {
|
|
buttonTemplate(viewParent, R.id.install_plugin_32) {
|
|
it.titleTv.text = "安装32位插件"
|
|
it.root.setOnClickListener {
|
|
val file = File("/data/local/tmp/gh-plugins/artifacts32.zip")
|
|
if (file.exists()) {
|
|
// TODO: 补充debug插件更新
|
|
ToastUtils.showToast("暂未实现debug功能")
|
|
} else {
|
|
ToastUtils.showToast("data/local/tmp没有push文件")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |