Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebe6df7072 | ||
|
|
a2b58ec078 | ||
|
|
b8d2cbeb08 | ||
|
|
1c35ecec2b | ||
|
|
74ef196ee5 |
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 = 940
|
versionCode = 945
|
||||||
versionName = "9.4.0"
|
versionName = "9.4.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|||||||
@@ -96,4 +96,8 @@ class AiSettingsActivity : Activity() {
|
|||||||
}.start()
|
}.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))
|
startActivity(Intent(this, MainActivity::class.java))
|
||||||
finish()
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -99,9 +99,15 @@ class MainActivity : Activity() {
|
|||||||
private var confirmOverlay: View? = null
|
private var confirmOverlay: View? = null
|
||||||
/** 右上角「立即授权」按钮(未授权时显示) */
|
/** 右上角「立即授权」按钮(未授权时显示) */
|
||||||
private var authBtn: TextView? = null
|
private var authBtn: TextView? = null
|
||||||
|
/** 右下角「已授权」小字标识(已授权时显示,未授权隐藏) */
|
||||||
|
private var authStateText: TextView? = null
|
||||||
/** 首次启动简易教程遮罩 */
|
/** 首次启动简易教程遮罩 */
|
||||||
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
|
||||||
@@ -216,6 +222,20 @@ class MainActivity : Activity() {
|
|||||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP or Gravity.END)
|
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP or Gravity.END)
|
||||||
root.addView(rightCol, rcLP)
|
root.addView(rightCol, rcLP)
|
||||||
|
|
||||||
|
// 4b) 右下角:已授权标识(小字,不打扰观看;未授权时隐藏)
|
||||||
|
authStateText = TextView(this).apply {
|
||||||
|
text = "✓ 已授权"
|
||||||
|
textSize = 12f
|
||||||
|
setTextColor(0xB3FFFFFF.toInt()) // 70% 白,弱化存在感
|
||||||
|
setBackgroundColor(0x59000000.toInt()) // 35% 黑底,保证在亮画面上也看得清
|
||||||
|
setPadding(14, 6, 14, 6)
|
||||||
|
setShadowLayer(3f, 1f, 1f, Color.BLACK)
|
||||||
|
visibility = View.GONE
|
||||||
|
}
|
||||||
|
root.addView(authStateText, FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.BOTTOM or Gravity.END).apply { setMargins(0, 0, 26, 26) })
|
||||||
|
|
||||||
// 5) 数字键大字
|
// 5) 数字键大字
|
||||||
digitText = TextView(this).apply {
|
digitText = TextView(this).apply {
|
||||||
textSize = 56f; setTextColor(Color.WHITE)
|
textSize = 56f; setTextColor(Color.WHITE)
|
||||||
@@ -229,8 +249,9 @@ class MainActivity : Activity() {
|
|||||||
// 6) 加载罩
|
// 6) 加载罩
|
||||||
loadingMask = FrameLayout(this).apply { setBackgroundColor(0xB2000000u.toInt()); visibility = View.GONE }
|
loadingMask = FrameLayout(this).apply { setBackgroundColor(0xB2000000u.toInt()); visibility = View.GONE }
|
||||||
loadingText = TextView(this).apply {
|
loadingText = TextView(this).apply {
|
||||||
textSize = 28f; setTextColor(Color.WHITE); gravity = Gravity.CENTER
|
textSize = 16f; setTextColor(0xE6FFFFFF.toInt()); gravity = Gravity.CENTER
|
||||||
setShadowLayer(6f, 3f, 3f, Color.BLACK)
|
setShadowLayer(4f, 2f, 2f, Color.BLACK)
|
||||||
|
setPadding(32, 0, 32, 0)
|
||||||
}
|
}
|
||||||
loadingMask.addView(loadingText, FrameLayout.LayoutParams(
|
loadingMask.addView(loadingText, FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
||||||
@@ -347,7 +368,11 @@ class MainActivity : Activity() {
|
|||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
isVip = r.ok
|
isVip = r.ok
|
||||||
prefs.edit().putBoolean("is_vip", r.ok).apply()
|
prefs.edit().putBoolean("is_vip", r.ok).apply()
|
||||||
if (r.ok) { trialText.visibility = View.GONE; trialText.text = "VIP"; showAuthButton(false) } else enterFreeMode()
|
if (r.ok) {
|
||||||
|
trialText.visibility = View.GONE; trialText.text = "VIP"
|
||||||
|
showAuthButton(false)
|
||||||
|
showAuthState(true) // 右下角显示「✓ 已授权」
|
||||||
|
} else enterFreeMode()
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
@@ -355,10 +380,20 @@ class MainActivity : Activity() {
|
|||||||
private fun enterFreeMode() {
|
private fun enterFreeMode() {
|
||||||
trialText.visibility = View.VISIBLE
|
trialText.visibility = View.VISIBLE
|
||||||
showAuthButton(true)
|
showAuthButton(true)
|
||||||
|
showAuthState(false) // 免费模式下不显示右下角标识
|
||||||
handler.removeCallbacks(uiTick)
|
handler.removeCallbacks(uiTick)
|
||||||
handler.post(uiTick)
|
handler.post(uiTick)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 右下角「✓ 已授权」标识 显示/隐藏 */
|
||||||
|
private fun showAuthState(show: Boolean) {
|
||||||
|
runOnUiThread {
|
||||||
|
val t = authStateText ?: return@runOnUiThread
|
||||||
|
t.visibility = if (show) View.VISIBLE else View.GONE
|
||||||
|
t.text = if (show) "✓ 已授权" else ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 显示/隐藏右上角「立即授权」按钮 */
|
/** 显示/隐藏右上角「立即授权」按钮 */
|
||||||
private fun showAuthButton(show: Boolean) {
|
private fun showAuthButton(show: Boolean) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
@@ -377,16 +412,38 @@ class MainActivity : Activity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 打开授权/激活页面(含卡密激活与购买入口) */
|
/** 菜单键/其他入口统一打开设置页;带三重诊断,打不开时屏幕上有原因 */
|
||||||
private fun openAuthPage() {
|
private fun openSettingsPage() {
|
||||||
try {
|
val intent = Intent(this, SettingsActivity::class.java)
|
||||||
startActivity(Intent(this, SettingsActivity::class.java))
|
// ① 预检查:系统能否解析到这个 Activity(manifest 没注册会返回 null)
|
||||||
} catch (e: Exception) {
|
val resolve = try { packageManager.resolveActivity(intent, 0) } catch (e: Exception) { null }
|
||||||
statusText.text = "打开授权页失败: ${e.javaClass.simpleName}: ${e.message}"
|
if (resolve == null) {
|
||||||
android.widget.Toast.makeText(this, "打开授权页失败: ${e.message}", android.widget.Toast.LENGTH_LONG).show()
|
statusText.text = "⚠ 设置页无法解析:manifest 未注册 SettingsActivity"
|
||||||
|
android.widget.Toast.makeText(this, "设置页无法解析(manifest 未注册)", android.widget.Toast.LENGTH_LONG).show()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
// ② 启动
|
||||||
|
val before = try { getSharedPreferences("iptv_main", MODE_PRIVATE).getLong("settings_opened_at", 0L) } catch (e: Exception) { 0L }
|
||||||
|
try {
|
||||||
|
startActivity(intent)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
statusText.text = "⚠ 打开设置失败: ${e.javaClass.simpleName}: ${e.message}"
|
||||||
|
android.widget.Toast.makeText(this, "打开设置失败: ${e.message}", android.widget.Toast.LENGTH_LONG).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// ③ 1.4 秒后核对:SettingsActivity.onCreate 有没有真的跑起来
|
||||||
|
handler.postDelayed({
|
||||||
|
val after = try { getSharedPreferences("iptv_main", MODE_PRIVATE).getLong("settings_opened_at", 0L) } catch (e: Exception) { 0L }
|
||||||
|
if (after <= before) {
|
||||||
|
statusText.text = "⚠ 设置页未响应:onCreate 未执行(启动被拦截或立刻结束)"
|
||||||
|
android.widget.Toast.makeText(this, "设置页未响应,请把这行字告诉我", android.widget.Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}, 1400)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 打开授权/激活页面(就是设置页:卡密激活 + 购买入口 + 撤销授权) */
|
||||||
|
private fun openAuthPage() { openSettingsPage() }
|
||||||
|
|
||||||
/** 首次启动:简易使用教程(可关闭,只弹一次) */
|
/** 首次启动:简易使用教程(可关闭,只弹一次) */
|
||||||
private fun maybeShowTutorial() {
|
private fun maybeShowTutorial() {
|
||||||
try {
|
try {
|
||||||
@@ -575,13 +632,7 @@ class MainActivity : Activity() {
|
|||||||
setItemsCanFocus(false)
|
setItemsCanFocus(false)
|
||||||
onItemClickListener = AdapterView.OnItemClickListener { _, _, pos, _ ->
|
onItemClickListener = AdapterView.OnItemClickListener { _, _, pos, _ ->
|
||||||
if (pos == 0) {
|
if (pos == 0) {
|
||||||
try { startActivity(Intent(this@MainActivity, SettingsActivity::class.java)) }
|
openSettingsPage(); hidePanel(); return@OnItemClickListener
|
||||||
catch (e: Exception) {
|
|
||||||
statusText.text = "打开设置失败: ${e.javaClass.simpleName}: ${e.message}"
|
|
||||||
android.widget.Toast.makeText(this@MainActivity, "打开设置失败: ${e.message}", android.widget.Toast.LENGTH_LONG).show()
|
|
||||||
return@OnItemClickListener
|
|
||||||
}
|
|
||||||
hidePanel(); return@OnItemClickListener
|
|
||||||
}
|
}
|
||||||
if (pos == 0) return@OnItemClickListener
|
if (pos == 0) return@OnItemClickListener
|
||||||
curGroupPos = pos - 1
|
curGroupPos = pos - 1
|
||||||
@@ -829,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 }
|
||||||
@@ -912,13 +985,7 @@ class MainActivity : Activity() {
|
|||||||
if (panelCol == 0) {
|
if (panelCol == 0) {
|
||||||
val np = groupAdapter?.selected ?: 0
|
val np = groupAdapter?.selected ?: 0
|
||||||
if (np == 0) {
|
if (np == 0) {
|
||||||
// 保险:打开失败要能在屏幕上看到原因,便于排查
|
openSettingsPage() // 统一走带诊断的入口
|
||||||
try { startActivity(Intent(this, SettingsActivity::class.java)) }
|
|
||||||
catch (e: Exception) {
|
|
||||||
statusText.text = "打开设置失败: ${e.javaClass.simpleName}: ${e.message}"
|
|
||||||
android.widget.Toast.makeText(this@MainActivity, "打开设置失败: ${e.message}", android.widget.Toast.LENGTH_LONG).show()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
hidePanel()
|
hidePanel()
|
||||||
}
|
}
|
||||||
else { curGroupPos = np - 1; updateChannelListOfGroup(curGroupPos); panelCol = 1; refreshPanelHighlight() }
|
else { curGroupPos = np - 1; updateChannelListOfGroup(curGroupPos); panelCol = 1; refreshPanelHighlight() }
|
||||||
@@ -936,7 +1003,8 @@ class MainActivity : Activity() {
|
|||||||
// ★ 修复:返回键必须弹退出确认,绝不直接 finish(原来漏了这个分支,
|
// ★ 修复:返回键必须弹退出确认,绝不直接 finish(原来漏了这个分支,
|
||||||
// 导致 BACK 落到 super.onKeyDown() = 系统默认无提示退出)
|
// 导致 BACK 落到 super.onKeyDown() = 系统默认无提示退出)
|
||||||
KeyEvent.KEYCODE_BACK -> { exitApp(); return true }
|
KeyEvent.KEYCODE_BACK -> { exitApp(); return true }
|
||||||
KeyEvent.KEYCODE_MENU -> { autoSwitchLine(); return true }
|
// ★ 菜单键 → 打开设置页(原来这里是「换线」,换线已移到设置页里)
|
||||||
|
KeyEvent.KEYCODE_MENU -> { openSettingsPage(); return true }
|
||||||
KeyEvent.KEYCODE_CHANNEL_UP -> { playChannel((currentChannel - 1 + channels.size) % channels.size); return true }
|
KeyEvent.KEYCODE_CHANNEL_UP -> { playChannel((currentChannel - 1 + channels.size) % channels.size); return true }
|
||||||
KeyEvent.KEYCODE_CHANNEL_DOWN -> { playChannel((currentChannel + 1) % channels.size); return true }
|
KeyEvent.KEYCODE_CHANNEL_DOWN -> { playChannel((currentChannel + 1) % channels.size); return true }
|
||||||
KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_DOWN -> {
|
KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_DOWN -> {
|
||||||
@@ -1034,35 +1102,49 @@ class MainActivity : Activity() {
|
|||||||
/** 新版本提示(自绘浮层,电视全屏主题下 AlertDialog 不可靠) */
|
/** 新版本提示(自绘浮层,电视全屏主题下 AlertDialog 不可靠) */
|
||||||
private fun showUpdateDialog(info: AuthApi.UpdateInfo) {
|
private fun showUpdateDialog(info: AuthApi.UpdateInfo) {
|
||||||
if (updateOverlay == null) {
|
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 mask = FrameLayout(this).apply { setBackgroundColor(0xCC000000u.toInt()) }
|
||||||
val card = LinearLayout(this).apply {
|
val card = LinearLayout(this).apply {
|
||||||
orientation = LinearLayout.VERTICAL
|
orientation = LinearLayout.VERTICAL
|
||||||
setBackgroundColor(Color.parseColor("#22262E"))
|
setBackgroundColor(Color.parseColor("#22262E"))
|
||||||
setPadding(64, 48, 64, 48)
|
setPadding(px(64), px(48), px(64), px(48))
|
||||||
}
|
}
|
||||||
card.addView(TextView(this).apply {
|
card.addView(TextView(this).apply {
|
||||||
text = "发现新版本"; textSize = 24f; setTextColor(Color.WHITE)
|
text = "发现新版本"; textSize = sp(24f); setTextColor(Color.WHITE)
|
||||||
gravity = Gravity.CENTER; setPadding(0, 0, 0, 12)
|
gravity = Gravity.CENTER; setPadding(0, 0, 0, px(12))
|
||||||
})
|
})
|
||||||
card.addView(TextView(this).apply {
|
card.addView(TextView(this).apply {
|
||||||
tag = "ver"; textSize = 40f; setTextColor(Color.parseColor("#4CAF50"))
|
tag = "ver"; textSize = sp(40f); setTextColor(Color.parseColor("#4CAF50"))
|
||||||
gravity = Gravity.CENTER; setPadding(0, 0, 0, 16)
|
gravity = Gravity.CENTER; setPadding(0, 0, 0, px(16))
|
||||||
})
|
})
|
||||||
card.addView(TextView(this).apply {
|
card.addView(TextView(this).apply {
|
||||||
tag = "meta"; textSize = 15f; setTextColor(Color.LTGRAY)
|
tag = "meta"; textSize = sp(15f); setTextColor(Color.LTGRAY)
|
||||||
gravity = Gravity.CENTER; setLineSpacing(0f, 1.2f); setPadding(0, 0, 0, 24)
|
gravity = Gravity.CENTER; setLineSpacing(0f, 1.2f); setPadding(0, 0, 0, px(24))
|
||||||
})
|
})
|
||||||
card.addView(TextView(this).apply {
|
card.addView(TextView(this).apply {
|
||||||
tag = "chg"; textSize = 15f; setTextColor(Color.WHITE)
|
tag = "chg"; textSize = sp(15f); setTextColor(Color.WHITE)
|
||||||
setBackgroundColor(Color.parseColor("#1C2028"))
|
setBackgroundColor(Color.parseColor("#1C2028"))
|
||||||
setPadding(24, 20, 24, 20); setLineSpacing(0f, 1.25f)
|
setPadding(px(24), px(20), px(24), px(20)); setLineSpacing(0f, 1.25f)
|
||||||
maxLines = 8; gravity = Gravity.CENTER
|
// ★ 限行 + 省略 + 高度上限:长 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 =
|
fun mkBtn(label: String, focusable: Boolean, onClick: () -> Unit): TextView =
|
||||||
TextView(this).apply {
|
TextView(this).apply {
|
||||||
text = label; textSize = 18f; setTextColor(Color.WHITE); gravity = Gravity.CENTER
|
text = label; textSize = sp(18f); setTextColor(Color.WHITE); gravity = Gravity.CENTER
|
||||||
setPadding(56, 22, 56, 22); isFocusable = focusable; isFocusableInTouchMode = focusable
|
setPadding(px(56), px(22), px(56), px(22)); isFocusable = focusable; isFocusableInTouchMode = focusable
|
||||||
if (focusable) background = android.graphics.drawable.StateListDrawable().apply {
|
if (focusable) background = android.graphics.drawable.StateListDrawable().apply {
|
||||||
addState(intArrayOf(android.R.attr.state_focused),
|
addState(intArrayOf(android.R.attr.state_focused),
|
||||||
android.graphics.drawable.ColorDrawable(Color.parseColor("#1B6EF3")))
|
android.graphics.drawable.ColorDrawable(Color.parseColor("#1B6EF3")))
|
||||||
@@ -1070,17 +1152,20 @@ 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 = px(32) })
|
||||||
row.addView(dlBtn, LinearLayout.LayoutParams(
|
row.addView(dlBtn, LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
||||||
card.addView(row)
|
card.addView(row)
|
||||||
|
// ★ 卡片宽度 = 屏幕 90%(左右各留 5%),任何屏幕都不会溢出
|
||||||
|
val cardW = (dm.widthPixels * 0.90f).toInt()
|
||||||
mask.addView(card, FrameLayout.LayoutParams(
|
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(
|
root.addView(mask, FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
||||||
updateOverlay = mask
|
updateOverlay = mask
|
||||||
@@ -1095,12 +1180,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 {
|
||||||
@@ -1242,10 +1363,12 @@ class MainActivity : Activity() {
|
|||||||
isVip = true
|
isVip = true
|
||||||
trialText.visibility = View.GONE
|
trialText.visibility = View.GONE
|
||||||
showAuthButton(false)
|
showAuthButton(false)
|
||||||
|
showAuthState(true) // 右下角显示「✓ 已授权」
|
||||||
handler.removeCallbacks(uiTick)
|
handler.removeCallbacks(uiTick)
|
||||||
} else if (!nowVip && isVip) {
|
} else if (!nowVip && isVip) {
|
||||||
// ★ 设置页里撤销了授权 → 回到免费模式(倒计时 + 立即授权按钮都恢复)
|
// ★ 设置页里撤销了授权 → 回到免费模式(倒计时 + 立即授权按钮都恢复)
|
||||||
isVip = false
|
isVip = false
|
||||||
|
showAuthState(false) // 右下角标识隐藏
|
||||||
enterFreeMode()
|
enterFreeMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1276,6 +1399,14 @@ class MainActivity : Activity() {
|
|||||||
playRequested = -1
|
playRequested = -1
|
||||||
if (idx >= 0) playChannel(idx)
|
if (idx >= 0) playChannel(idx)
|
||||||
}
|
}
|
||||||
|
// 设置页点「切换线路」→ 回来执行(原菜单键功能,现已移到设置页)
|
||||||
|
run {
|
||||||
|
val sp = getSharedPreferences("iptv_main", MODE_PRIVATE)
|
||||||
|
if (sp.getString("pending_action", "") == "switch_line") {
|
||||||
|
sp.edit().remove("pending_action").apply()
|
||||||
|
autoSwitchLine()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 点「继续播放」→ 重新连接当前频道(直播流最稳的恢复方式) */
|
/** 点「继续播放」→ 重新连接当前频道(直播流最稳的恢复方式) */
|
||||||
|
|||||||
@@ -214,8 +214,33 @@ class SettingsActivity : Activity() {
|
|||||||
startActivity(Intent(this@SettingsActivity, ShopActivity::class.java))
|
startActivity(Intent(this@SettingsActivity, ShopActivity::class.java))
|
||||||
}
|
}
|
||||||
root.addView(btn, LinearLayout.LayoutParams(
|
root.addView(btn, LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 20 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 其它操作 =====
|
||||||
|
root.addView(TextView(this).apply {
|
||||||
|
text = "其它操作"
|
||||||
|
textSize = 15f; setTextColor(Color.parseColor("#7AA7D9"))
|
||||||
|
setPadding(0, 8, 0, 8)
|
||||||
|
})
|
||||||
|
// 原菜单键的功能(手动换线),现在放在这里
|
||||||
|
val switchBtn = mkAction("切换线路(当前线路不通时手动换)") {
|
||||||
|
try {
|
||||||
|
getSharedPreferences("iptv_main", MODE_PRIVATE).edit()
|
||||||
|
.putString("pending_action", "switch_line").apply()
|
||||||
|
} catch (e: Exception) { }
|
||||||
|
statusText.text = "已请求切换线路,返回主界面后生效"
|
||||||
|
android.widget.Toast.makeText(this, "返回主界面后自动切换线路", android.widget.Toast.LENGTH_LONG).show()
|
||||||
|
try { finish() } catch (e: Exception) { }
|
||||||
|
}
|
||||||
|
root.addView(switchBtn, LinearLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 20 })
|
||||||
|
|
||||||
|
// ★ 诊断标记:证明本页 onCreate 确实跑到了(主界面 1.4 秒后会核对)
|
||||||
|
try {
|
||||||
|
getSharedPreferences("iptv_main", MODE_PRIVATE).edit()
|
||||||
|
.putLong("settings_opened_at", System.currentTimeMillis()).apply()
|
||||||
|
} catch (e: Exception) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 撤销本机授权:清除本地授权信息 → 恢复免费模式,可重新输入卡密或换机 */
|
/** 撤销本机授权:清除本地授权信息 → 恢复免费模式,可重新输入卡密或换机 */
|
||||||
|
|||||||
@@ -48,16 +48,40 @@ class TrialExpiredActivity : Activity() {
|
|||||||
gravity = android.view.Gravity.CENTER; setPadding(0, 0, 0, 56)
|
gravity = android.view.Gravity.CENTER; setPadding(0, 0, 0, 56)
|
||||||
})
|
})
|
||||||
|
|
||||||
root.addView(Button(this).apply {
|
// ★ 可聚焦按钮 + 遥控器高亮(原来 Button 无人聚焦,遥控器按 OK 没反应)
|
||||||
text = "购买套餐(OK键)"
|
fun focusableBtn(label: String, size: Float, onClick: () -> Unit) =
|
||||||
textSize = 19f
|
Button(this).apply {
|
||||||
setOnClickListener { startActivity(android.content.Intent(this@TrialExpiredActivity, ShopActivity::class.java)); finish() }
|
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 {
|
root.addView(TextView(this).apply {
|
||||||
text = "或直接访问:http://app.88531.cn:8881/#/shop"
|
text = "或直接访问:http://app.88531.cn:8881/#/shop"
|
||||||
textSize = 13f; setTextColor(0xFF888888u.toInt())
|
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 {
|
root.addView(TextView(this).apply {
|
||||||
@@ -65,6 +89,15 @@ class TrialExpiredActivity : Activity() {
|
|||||||
textSize = 14f; setTextColor(0xFF7799AAu.toInt())
|
textSize = 14f; setTextColor(0xFF7799AAu.toInt())
|
||||||
gravity = android.view.Gravity.CENTER; setPadding(0, 24, 0, 0)
|
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() {
|
private fun openShop() {
|
||||||
|
|||||||
Reference in new issue
Block a user