Compare commits
1
Commits
v9.4.2
..
b8d2cbeb08
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8d2cbeb08 |
No files matched your search
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId = "com.iptv807.tv"
|
applicationId = "com.iptv807.tv"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 942
|
versionCode = 943
|
||||||
versionName = "9.4.2"
|
versionName = "9.4.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ class MainActivity : Activity() {
|
|||||||
/** 首次启动简易教程遮罩 */
|
/** 首次启动简易教程遮罩 */
|
||||||
private var tutorialOverlay: View? = null
|
private var tutorialOverlay: View? = null
|
||||||
private var tutorialVisible = false
|
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 updateOverlay: View? = null
|
||||||
private var pendingUpdate: AuthApi.UpdateInfo? = null
|
private var pendingUpdate: AuthApi.UpdateInfo? = null
|
||||||
@@ -876,6 +880,28 @@ class MainActivity : Activity() {
|
|||||||
}
|
}
|
||||||
return true
|
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 确认)
|
// 退出确认框显示时:返回=取消,其余交给按钮焦点系统处理(左右切换,OK 确认)
|
||||||
if (confirmVisible) {
|
if (confirmVisible) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) { hideExitConfirm(); return true }
|
if (keyCode == KeyEvent.KEYCODE_BACK) { hideExitConfirm(); return true }
|
||||||
@@ -1112,10 +1138,11 @@ class MainActivity : Activity() {
|
|||||||
} else setBackgroundColor(Color.parseColor("#2A2F3A"))
|
} else setBackgroundColor(Color.parseColor("#2A2F3A"))
|
||||||
setOnClickListener { onClick() }
|
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()
|
pendingUpdate?.let { startUpdateDownload(it) }; hideUpdateDialog()
|
||||||
}
|
}.apply { tag = "dl" }
|
||||||
row.addView(laterBtn, LinearLayout.LayoutParams(
|
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 = 32 })
|
||||||
row.addView(dlBtn, LinearLayout.LayoutParams(
|
row.addView(dlBtn, LinearLayout.LayoutParams(
|
||||||
@@ -1137,12 +1164,48 @@ class MainActivity : Activity() {
|
|||||||
meta.text = "当前 v${AuthApi.clientVersion(this)}" + (if (mb.isNotEmpty()) " · $mb" else "") +
|
meta.text = "当前 v${AuthApi.clientVersion(this)}" + (if (mb.isNotEmpty()) " · $mb" else "") +
|
||||||
(if (force) "\n⚠ 请升级到此版本" else "")
|
(if (force) "\n⚠ 请升级到此版本" else "")
|
||||||
chg.text = info.changelog.ifEmpty { "本次更新包含功能优化与问题修复" }
|
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!!.visibility = View.VISIBLE
|
||||||
// 强制更新时不给"稍后"
|
// ★ 必须主动聚焦,否则遥控器按 OK 不会命中任何按钮
|
||||||
updateOverlay!!.findViewWithTag<TextView>("ver") // touch to ensure rendered
|
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" 之类 */
|
/** 比较 "9.10.0" vs "9.3.0" 之类 */
|
||||||
fun compareVersion(a: String, b: String): Int {
|
fun compareVersion(a: String, b: String): Int {
|
||||||
|
|||||||
Reference in new issue
Block a user