Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebe6df7072 | ||
|
|
a2b58ec078 | ||
|
|
b8d2cbeb08 |
No files matched your search
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.iptv807.tv"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
versionCode = 942
|
||||
versionName = "9.4.2"
|
||||
versionCode = 945
|
||||
versionName = "9.4.5"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -96,4 +96,8 @@ class AiSettingsActivity : Activity() {
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
override fun onKeyDown(keyCode: Int, event: android.view.KeyEvent?): Boolean {
|
||||
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) { finish(); return true }
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
}
|
||||
@@ -140,4 +140,9 @@ class LoginActivity : Activity() {
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
/** ★ 返回键显式处理(原来缺失 → 走系统默认,用户按返回无提示) */
|
||||
override fun onKeyDown(keyCode: Int, event: android.view.KeyEvent?): Boolean {
|
||||
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) { finish(); return true }
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,10 @@ class MainActivity : Activity() {
|
||||
/** 首次启动简易教程遮罩 */
|
||||
private var tutorialOverlay: View? = null
|
||||
private var tutorialVisible = false
|
||||
/** 更新弹窗的可聚焦按钮 + 当前焦点索引(遥控器左右切换用) */
|
||||
private var updBtns: Array<TextView?> = emptyArray()
|
||||
private var updFocusIdx = 0
|
||||
private var updForce = false
|
||||
// 安装统计 + 版本推送
|
||||
private var updateOverlay: View? = null
|
||||
private var pendingUpdate: AuthApi.UpdateInfo? = null
|
||||
@@ -876,6 +880,28 @@ class MainActivity : Activity() {
|
||||
}
|
||||
return true
|
||||
}
|
||||
// ★ 更新弹窗显示时:所有按键都由弹窗接管。
|
||||
// 否则会落到下面的 showPanel()/exitApp()/换台 —— 遥控器就"选不了"了
|
||||
if (isUpdateDialogVisible()) {
|
||||
when (keyCode) {
|
||||
KeyEvent.KEYCODE_BACK -> { hideUpdateDialog(); return true }
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_ENTER,
|
||||
KeyEvent.KEYCODE_NUMPAD_ENTER, KeyEvent.KEYCODE_SPACE -> {
|
||||
val btn = updBtns.getOrNull(updFocusIdx)
|
||||
?.takeIf { it.visibility == View.VISIBLE }
|
||||
?: updBtns.filterNotNull().firstOrNull { it.visibility == View.VISIBLE }
|
||||
btn?.performClick()
|
||||
return true
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_UP -> { moveUpdateFocus(-1); return true }
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT, KeyEvent.KEYCODE_DPAD_DOWN -> { moveUpdateFocus( 1); return true }
|
||||
|
||||
else -> return true // 数字键 / 菜单键 等全部吞掉(弹窗期间不能换台、不能进设置)
|
||||
}
|
||||
}
|
||||
|
||||
// 退出确认框显示时:返回=取消,其余交给按钮焦点系统处理(左右切换,OK 确认)
|
||||
if (confirmVisible) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) { hideExitConfirm(); return true }
|
||||
@@ -1076,35 +1102,49 @@ class MainActivity : Activity() {
|
||||
/** 新版本提示(自绘浮层,电视全屏主题下 AlertDialog 不可靠) */
|
||||
private fun showUpdateDialog(info: AuthApi.UpdateInfo) {
|
||||
if (updateOverlay == null) {
|
||||
// ★ 尺寸自适应:原字号/内边距按 TV 写死且卡片宽度无约束,手机竖屏会溢出
|
||||
val dm = resources.displayMetrics
|
||||
val wDp = dm.widthPixels / dm.density
|
||||
val s = when {
|
||||
wDp < 500f -> 0.62f // 手机竖屏(约 360-430dp 宽)
|
||||
wDp < 760f -> 0.80f // 手机横屏 / 小平板
|
||||
else -> 1.00f // 电视 / 平板横屏(960dp+)保持原样
|
||||
}
|
||||
fun sp(v: Float): Float = v * s
|
||||
fun px(v: Int): Int = (v * s).toInt()
|
||||
|
||||
val mask = FrameLayout(this).apply { setBackgroundColor(0xCC000000u.toInt()) }
|
||||
val card = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(Color.parseColor("#22262E"))
|
||||
setPadding(64, 48, 64, 48)
|
||||
setPadding(px(64), px(48), px(64), px(48))
|
||||
}
|
||||
card.addView(TextView(this).apply {
|
||||
text = "发现新版本"; textSize = 24f; setTextColor(Color.WHITE)
|
||||
gravity = Gravity.CENTER; setPadding(0, 0, 0, 12)
|
||||
text = "发现新版本"; textSize = sp(24f); setTextColor(Color.WHITE)
|
||||
gravity = Gravity.CENTER; setPadding(0, 0, 0, px(12))
|
||||
})
|
||||
card.addView(TextView(this).apply {
|
||||
tag = "ver"; textSize = 40f; setTextColor(Color.parseColor("#4CAF50"))
|
||||
gravity = Gravity.CENTER; setPadding(0, 0, 0, 16)
|
||||
tag = "ver"; textSize = sp(40f); setTextColor(Color.parseColor("#4CAF50"))
|
||||
gravity = Gravity.CENTER; setPadding(0, 0, 0, px(16))
|
||||
})
|
||||
card.addView(TextView(this).apply {
|
||||
tag = "meta"; textSize = 15f; setTextColor(Color.LTGRAY)
|
||||
gravity = Gravity.CENTER; setLineSpacing(0f, 1.2f); setPadding(0, 0, 0, 24)
|
||||
tag = "meta"; textSize = sp(15f); setTextColor(Color.LTGRAY)
|
||||
gravity = Gravity.CENTER; setLineSpacing(0f, 1.2f); setPadding(0, 0, 0, px(24))
|
||||
})
|
||||
card.addView(TextView(this).apply {
|
||||
tag = "chg"; textSize = 15f; setTextColor(Color.WHITE)
|
||||
tag = "chg"; textSize = sp(15f); setTextColor(Color.WHITE)
|
||||
setBackgroundColor(Color.parseColor("#1C2028"))
|
||||
setPadding(24, 20, 24, 20); setLineSpacing(0f, 1.25f)
|
||||
maxLines = 8; gravity = Gravity.CENTER
|
||||
setPadding(px(24), px(20), px(24), px(20)); setLineSpacing(0f, 1.25f)
|
||||
// ★ 限行 + 省略 + 高度上限:长 changelog 不再把卡片撑出屏幕
|
||||
maxLines = 6; ellipsize = android.text.TextUtils.TruncateAt.END
|
||||
maxHeight = (dm.heightPixels * 0.34f).toInt()
|
||||
gravity = Gravity.CENTER
|
||||
})
|
||||
val row = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL; gravity = Gravity.CENTER; setPadding(0, 28, 0, 0) }
|
||||
val row = LinearLayout(this).apply { orientation = LinearLayout.HORIZONTAL; gravity = Gravity.CENTER; setPadding(0, px(28), 0, 0) }
|
||||
fun mkBtn(label: String, focusable: Boolean, onClick: () -> Unit): TextView =
|
||||
TextView(this).apply {
|
||||
text = label; textSize = 18f; setTextColor(Color.WHITE); gravity = Gravity.CENTER
|
||||
setPadding(56, 22, 56, 22); isFocusable = focusable; isFocusableInTouchMode = focusable
|
||||
text = label; textSize = sp(18f); setTextColor(Color.WHITE); gravity = Gravity.CENTER
|
||||
setPadding(px(56), px(22), px(56), px(22)); isFocusable = focusable; isFocusableInTouchMode = focusable
|
||||
if (focusable) background = android.graphics.drawable.StateListDrawable().apply {
|
||||
addState(intArrayOf(android.R.attr.state_focused),
|
||||
android.graphics.drawable.ColorDrawable(Color.parseColor("#1B6EF3")))
|
||||
@@ -1112,17 +1152,20 @@ class MainActivity : Activity() {
|
||||
} else setBackgroundColor(Color.parseColor("#2A2F3A"))
|
||||
setOnClickListener { onClick() }
|
||||
}
|
||||
val laterBtn = mkBtn("稍后", true) { hideUpdateDialog() }
|
||||
val dlBtn = mkBtn("立即更新", false) {
|
||||
// ★ 两个按钮都必须可聚焦,否则遥控器永远选不到「立即更新」
|
||||
val laterBtn = mkBtn("稍后", true) { hideUpdateDialog() }.apply { tag = "later" }
|
||||
val dlBtn = mkBtn("立即更新", true) {
|
||||
pendingUpdate?.let { startUpdateDownload(it) }; hideUpdateDialog()
|
||||
}
|
||||
}.apply { tag = "dl" }
|
||||
row.addView(laterBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { rightMargin = 32 })
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { rightMargin = px(32) })
|
||||
row.addView(dlBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
||||
card.addView(row)
|
||||
// ★ 卡片宽度 = 屏幕 90%(左右各留 5%),任何屏幕都不会溢出
|
||||
val cardW = (dm.widthPixels * 0.90f).toInt()
|
||||
mask.addView(card, FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER))
|
||||
cardW, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER))
|
||||
root.addView(mask, FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
||||
updateOverlay = mask
|
||||
@@ -1137,12 +1180,48 @@ class MainActivity : Activity() {
|
||||
meta.text = "当前 v${AuthApi.clientVersion(this)}" + (if (mb.isNotEmpty()) " · $mb" else "") +
|
||||
(if (force) "\n⚠ 请升级到此版本" else "")
|
||||
chg.text = info.changelog.ifEmpty { "本次更新包含功能优化与问题修复" }
|
||||
|
||||
// ★ 强制更新时不给「稍后」(原代码只写了注释没实现)
|
||||
val laterB = updateOverlay!!.findViewWithTag<TextView>("later")
|
||||
val dlB = updateOverlay!!.findViewWithTag<TextView>("dl")
|
||||
updForce = info.updateRequired || (info.minClientVersion.isNotEmpty() &&
|
||||
compareVersion(AuthApi.clientVersion(this), info.minClientVersion) < 0)
|
||||
laterB?.visibility = if (updForce) View.GONE else View.VISIBLE
|
||||
// 可见的按钮列表(强制更新时只剩「立即更新」)
|
||||
updBtns = arrayOf(if (updForce) null else laterB, dlB)
|
||||
updFocusIdx = if (updForce) 1 else 1 // 默认聚焦「立即更新」(主操作)
|
||||
|
||||
updateOverlay!!.visibility = View.VISIBLE
|
||||
// 强制更新时不给"稍后"
|
||||
updateOverlay!!.findViewWithTag<TextView>("ver") // touch to ensure rendered
|
||||
// ★ 必须主动聚焦,否则遥控器按 OK 不会命中任何按钮
|
||||
handler.postDelayed({
|
||||
if (updateOverlay?.visibility == View.VISIBLE) {
|
||||
updBtns.getOrNull(updFocusIdx)?.requestFocus()
|
||||
}
|
||||
}, 120)
|
||||
}
|
||||
|
||||
private fun hideUpdateDialog() { updateOverlay?.visibility = View.GONE }
|
||||
private fun hideUpdateDialog() {
|
||||
updateOverlay?.visibility = View.GONE
|
||||
// 清掉焦点,避免残留焦点挡住后续按键
|
||||
updBtns.forEach { it?.clearFocus() }
|
||||
updFocusIdx = 0
|
||||
}
|
||||
|
||||
/** 更新弹窗内切换按钮焦点(遥控器左右/上下) */
|
||||
private fun moveUpdateFocus(delta: Int) {
|
||||
val visible = updBtns.filterNotNull().filter { it.visibility == View.VISIBLE }
|
||||
if (visible.isEmpty()) return
|
||||
val cur = updBtns.getOrNull(updFocusIdx)
|
||||
var i = visible.indexOf(cur)
|
||||
if (i < 0) i = 0
|
||||
i = (i + delta + visible.size) % visible.size
|
||||
val target = visible[i]
|
||||
updFocusIdx = updBtns.indexOf(target)
|
||||
target.requestFocus()
|
||||
}
|
||||
|
||||
/** 更新弹窗是否显示 */
|
||||
private fun isUpdateDialogVisible(): Boolean = updateOverlay?.visibility == View.VISIBLE
|
||||
|
||||
/** 比较 "9.10.0" vs "9.3.0" 之类 */
|
||||
fun compareVersion(a: String, b: String): Int {
|
||||
|
||||
@@ -48,16 +48,40 @@ class TrialExpiredActivity : Activity() {
|
||||
gravity = android.view.Gravity.CENTER; setPadding(0, 0, 0, 56)
|
||||
})
|
||||
|
||||
root.addView(Button(this).apply {
|
||||
text = "购买套餐(OK键)"
|
||||
textSize = 19f
|
||||
setOnClickListener { startActivity(android.content.Intent(this@TrialExpiredActivity, ShopActivity::class.java)); finish() }
|
||||
})
|
||||
// ★ 可聚焦按钮 + 遥控器高亮(原来 Button 无人聚焦,遥控器按 OK 没反应)
|
||||
fun focusableBtn(label: String, size: Float, onClick: () -> Unit) =
|
||||
Button(this).apply {
|
||||
text = label; textSize = size
|
||||
isFocusable = true; isFocusableInTouchMode = true
|
||||
setTextColor(0xFFFFFFFFu.toInt())
|
||||
background = android.graphics.drawable.StateListDrawable().apply {
|
||||
addState(intArrayOf(android.R.attr.state_focused),
|
||||
android.graphics.drawable.ColorDrawable(0xFF1B6EF3.toInt()))
|
||||
addState(intArrayOf(),
|
||||
android.graphics.drawable.ColorDrawable(0xFF2A2F3A.toInt()))
|
||||
}
|
||||
setPadding(48, 26, 48, 26)
|
||||
setOnClickListener { onClick() }
|
||||
}
|
||||
|
||||
val buyBtn = focusableBtn("购买套餐(OK 键)", 19f) {
|
||||
try {
|
||||
startActivity(android.content.Intent(this@TrialExpiredActivity, ShopActivity::class.java))
|
||||
} catch (e: Exception) { }
|
||||
finish()
|
||||
}
|
||||
root.addView(buyBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 20 })
|
||||
|
||||
// ★ 新增:明确的关闭入口(原来只能靠按 BACK,而 BACK 走的是系统默认)
|
||||
val closeBtn = focusableBtn("关闭(返回键也可以)", 17f) { finish() }
|
||||
root.addView(closeBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 8 })
|
||||
|
||||
root.addView(TextView(this).apply {
|
||||
text = "或直接访问:http://app.88531.cn:8881/#/shop"
|
||||
textSize = 13f; setTextColor(0xFF888888u.toInt())
|
||||
gravity = android.view.Gravity.CENTER; setPadding(0, 32, 0, 0)
|
||||
gravity = android.view.Gravity.CENTER; setPadding(0, 28, 0, 0)
|
||||
})
|
||||
|
||||
root.addView(TextView(this).apply {
|
||||
@@ -65,6 +89,15 @@ class TrialExpiredActivity : Activity() {
|
||||
textSize = 14f; setTextColor(0xFF7799AAu.toInt())
|
||||
gravity = android.view.Gravity.CENTER; setPadding(0, 24, 0, 0)
|
||||
})
|
||||
|
||||
// 默认聚焦「购买套餐」,遥控器 OK 直接可按;左右/上下在两个按钮间切换
|
||||
buyBtn.post { buyBtn.requestFocus() }
|
||||
}
|
||||
|
||||
/** ★ 返回键显式处理(原来没有,走系统默认,用户不知道能关) */
|
||||
override fun onKeyDown(keyCode: Int, event: android.view.KeyEvent?): Boolean {
|
||||
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) { finish(); return true }
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
private fun openShop() {
|
||||
|
||||
Reference in new issue
Block a user