Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d0fefdecf | ||
|
|
65dd927d07 | ||
|
|
42b38f5b81 |
No files matched your search
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.iptv807.tv"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
versionCode = 949
|
||||
versionName = "9.4.9"
|
||||
versionCode = 961
|
||||
versionName = "9.6.1"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -92,8 +92,33 @@ object LicenseClient {
|
||||
return code
|
||||
}
|
||||
|
||||
// ===== 免费时长控制(每天1小时)=====
|
||||
// ===== 免费时长控制 =====
|
||||
// 主方案:首 7 天完整体验(不限时)→ 第 8 天起每天 1 小时
|
||||
const val FREE_DAILY_MS = 60 * 60 * 1000L
|
||||
const val FREE_TRIAL_DAYS = 7
|
||||
|
||||
/** 首次安装时间(卸载重装会重新计时,即重新获得 7 天完整体验) */
|
||||
private fun firstInstallAt(ctx: Context): Long {
|
||||
val prefs = ctx.getSharedPreferences("iptv_license", Context.MODE_PRIVATE)
|
||||
val saved = prefs.getLong("first_install_at", 0L)
|
||||
if (saved > 0L) return saved
|
||||
val now = System.currentTimeMillis()
|
||||
prefs.edit().putLong("first_install_at", now).apply()
|
||||
return now
|
||||
}
|
||||
|
||||
/**
|
||||
* 免费试用剩余天数:>0 表示还在完整试用期,0 表示已降级为每日 1 小时
|
||||
* 试用期内:不限时长、不计用量
|
||||
*/
|
||||
fun trialDaysLeft(ctx: Context): Int {
|
||||
val start = firstInstallAt(ctx)
|
||||
val day = ((System.currentTimeMillis() - start) / (24 * 60 * 60 * 1000L)).toInt()
|
||||
return (FREE_TRIAL_DAYS - day).coerceAtLeast(0)
|
||||
}
|
||||
|
||||
/** 是否在首 7 天完整试用期 */
|
||||
fun isInTrial(ctx: Context): Boolean = trialDaysLeft(ctx) > 0
|
||||
|
||||
/** 今天已用免费毫秒数 */
|
||||
fun freeUsedTodayMs(ctx: Context): Long {
|
||||
@@ -104,14 +129,22 @@ object LicenseClient {
|
||||
}
|
||||
|
||||
fun addFreeUsedMs(ctx: Context, delta: Long) {
|
||||
if (isInTrial(ctx)) return // 试用期不计用量
|
||||
val prefs = ctx.getSharedPreferences("iptv_license", Context.MODE_PRIVATE)
|
||||
val today = todayKey()
|
||||
val used = if (prefs.getString("free_date", "") == today) prefs.getLong("free_used_ms", 0) else 0
|
||||
prefs.edit().putString("free_date", today).putLong("free_used_ms", used + delta).apply()
|
||||
}
|
||||
|
||||
fun freeRemainingMs(ctx: Context): Long =
|
||||
(FREE_DAILY_MS - freeUsedTodayMs(ctx)).coerceAtLeast(0)
|
||||
/**
|
||||
* 今日剩余免费时长
|
||||
* 试用期内返回 7 天的毫秒数(远大于每日额度 → UI 不会显示"今日已用完",
|
||||
* 同时也不会把 %s 分 %s 秒 显示成一个夸张的数字,UI 侧会用 trialDaysLeft 分支覆盖显示)
|
||||
*/
|
||||
fun freeRemainingMs(ctx: Context): Long {
|
||||
if (isInTrial(ctx)) return FREE_TRIAL_DAYS * 24 * 60 * 60 * 1000L
|
||||
return (FREE_DAILY_MS - freeUsedTodayMs(ctx)).coerceAtLeast(0)
|
||||
}
|
||||
|
||||
/** 日期键北京时间 */
|
||||
private fun todayKey(): String {
|
||||
|
||||
@@ -113,6 +113,8 @@ class MainActivity : Activity() {
|
||||
private var annTypeTv: TextView? = null
|
||||
private var curAnnId = 0
|
||||
private var annRetry = 0
|
||||
/** 到期引导页只弹一次(防止 showTrialExpired 重复触发) */
|
||||
private var trialExpiredShown = false
|
||||
/** 更新弹窗的可聚焦按钮 + 当前焦点索引(遥控器左右切换用) */
|
||||
private var updBtns: Array<TextView?> = emptyArray()
|
||||
private var updFocusIdx = 0
|
||||
@@ -121,6 +123,13 @@ class MainActivity : Activity() {
|
||||
private var updateOverlay: View? = null
|
||||
private var pendingUpdate: AuthApi.UpdateInfo? = null
|
||||
private var downloadId = -1L
|
||||
/**
|
||||
* ★ 2026-10-15 起:暂时全面免费 —— 关闭授权限制与全部授权提示。
|
||||
* 保留不变:安装统计(check-update)、在线统计(heartbeat 心跳)、公告推送(announcements)。
|
||||
* 将来恢复授权:把这里改回 true 即可(限制与提示逻辑均原样保留在下方各分支里)。
|
||||
*/
|
||||
private val authGateEnabled = false
|
||||
|
||||
private val heartbeatTask = object : Runnable {
|
||||
override fun run() {
|
||||
Thread {
|
||||
@@ -378,7 +387,12 @@ class MainActivity : Activity() {
|
||||
runOnUiThread {
|
||||
isVip = r.ok
|
||||
prefs.edit().putBoolean("is_vip", r.ok).apply()
|
||||
if (r.ok) {
|
||||
if (!authGateEnabled) {
|
||||
// 暂时全面免费:隐藏所有授权相关 UI,不进入任何限制模式
|
||||
trialText.visibility = View.GONE
|
||||
showAuthButton(false)
|
||||
showAuthState(false)
|
||||
} else if (r.ok) {
|
||||
trialText.visibility = View.GONE; trialText.text = "VIP"
|
||||
showAuthButton(false)
|
||||
showAuthState(true) // 右下角显示「✓ 已授权」
|
||||
@@ -534,13 +548,30 @@ class MainActivity : Activity() {
|
||||
}
|
||||
|
||||
private fun onUiTick() {
|
||||
// ★ 暂时全面免费:不显示任何倒计时/试用提示,也不触发到期引导页
|
||||
if (!authGateEnabled) { trialText.visibility = View.GONE; return }
|
||||
if (isVip) return
|
||||
// 每秒累计一次免费用量,这样右上角倒计时才会真正走动
|
||||
// 每秒累计一次免费用量(试用期内 LicenseClient 内部会跳过,不计用量)
|
||||
if (player?.isPlaying == true) LicenseClient.addFreeUsedMs(this, 1000)
|
||||
val r = freeRemainingMs()
|
||||
val days = LicenseClient.trialDaysLeft(this)
|
||||
trialText.visibility = View.VISIBLE
|
||||
trialText.text = if (r <= 0) "⏳ 今日免費已用完"
|
||||
else "⏳ 今日免費 ${r / 60000}分${((r % 60000) / 1000).toString().padStart(2, '0')}秒"
|
||||
trialText.text = when {
|
||||
// ★ 首 7 天完整试用期:显性化"还剩几天"(制造到期紧迫感)
|
||||
days > 0 -> if (days == 1) "🎁 免费试用 · 明天起每天限 1 小时"
|
||||
else "🎁 免费试用 · 还剩 $days 天"
|
||||
r <= 0 -> "⏳ 今日免費已用完"
|
||||
else -> "⏳ 今日免費 ${r / 60000}分${((r % 60000) / 1000).toString().padStart(2, '0')}秒"
|
||||
}
|
||||
|
||||
// ★ 到期钩子:试用期结束(第 8 天起)且今日额度用完 → 弹购买引导页
|
||||
// (原来 showTrialExpired 是死代码、从未被调用,用户只看到文字、画面停住,没有任何付费入口)
|
||||
if (days <= 0 && r <= 0 && !trialExpiredShown) {
|
||||
trialExpiredShown = true
|
||||
handler.removeCallbacks(uiTick)
|
||||
handler.postDelayed({ showTrialExpired() }, 1200) // 让用户看清"已用完"再跳转
|
||||
return
|
||||
}
|
||||
handler.postDelayed(uiTick, 1000)
|
||||
}
|
||||
|
||||
@@ -1101,20 +1132,15 @@ class MainActivity : Activity() {
|
||||
}.getOrDefault(AuthApi.UpdateInfo(msg = AuthApi.lastError))
|
||||
runOnUiThread {
|
||||
if (info.ok) {
|
||||
val sb = StringBuilder("安装上报 ok #${info.installId} · v${AuthApi.clientVersion(this)}")
|
||||
if (info.updateAvailable) sb.append(" · 发现新版 v${info.latestVersion}")
|
||||
statusText.text = sb.toString()
|
||||
handler.postDelayed({
|
||||
val c = channels.getOrNull(currentChannel)
|
||||
if (c != null) statusText.text = "▶ ${c.num} ${c.name}"
|
||||
}, 8000)
|
||||
// ★ 不再把「安装上报 ok #xxx」写到左上角(用户要求去掉该提示);
|
||||
// 上报请求本身照常发出 → 安装统计 / 在线统计 / 版本检查均不受影响。
|
||||
// statusText 交回频道显示逻辑(切换频道时显示「▶ 频道号 频道名」)。
|
||||
if (info.updateAvailable) {
|
||||
pendingUpdate = info
|
||||
showUpdateDialog(info)
|
||||
}
|
||||
} else {
|
||||
statusText.text = "安装上报失败: ${info.msg}"
|
||||
}
|
||||
// 上报失败也不再提示(保持界面干净),失败信息静默丢弃
|
||||
}
|
||||
}.start()
|
||||
handler.removeCallbacks(heartbeatTask)
|
||||
|
||||
@@ -87,10 +87,7 @@ class SettingsActivity : Activity() {
|
||||
} catch (e: Exception) { "1.0" }
|
||||
|
||||
val prefs = getSharedPreferences("iptv_license", MODE_PRIVATE)
|
||||
val isVip = prefs.getBoolean("is_vip", false)
|
||||
val expire = prefs.getString("vip_expire", "")
|
||||
val permanent = prefs.getBoolean("is_permanent", false)
|
||||
val cardKey = prefs.getString("card_key", "")
|
||||
// v9.6.1:暂时全面免费,本页不再读取/展示任何授权状态(isVip/expire/permanent/cardKey 已移除)
|
||||
|
||||
root.addView(TextView(this).apply {
|
||||
text = "版本信息"
|
||||
@@ -98,7 +95,8 @@ class SettingsActivity : Activity() {
|
||||
setPadding(0, 0, 0, 8)
|
||||
})
|
||||
root.addView(TextView(this).apply {
|
||||
text = "App 版本:$versionName\n授权系统:CardAuth(app.88531.cn)\n机器码:${LicenseClient.machineCode(this@SettingsActivity)}"
|
||||
// v9.6.1:暂时全面免费,不再显示授权系统 / 机器码等收费痕迹,只留版本号
|
||||
text = "App 版本:$versionName\n本软件完全免费 · 无广告 · 无第三方 SDK"
|
||||
textSize = 15f; setTextColor(Color.WHITE)
|
||||
setLineSpacing(0f, 1.15f)
|
||||
setBackgroundColor(Color.parseColor("#1C2028"))
|
||||
@@ -134,22 +132,14 @@ class SettingsActivity : Activity() {
|
||||
root.addView(bootSwitch, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 40 })
|
||||
|
||||
// ===== 会员状态 =====
|
||||
root.addView(TextView(this).apply {
|
||||
text = "会员状态"
|
||||
textSize = 15f; setTextColor(Color.parseColor("#7AA7D9"))
|
||||
setPadding(0, 0, 0, 8)
|
||||
})
|
||||
// ===== 状态提示条(切换线路等操作的结果显示在这里)=====
|
||||
// v9.6.1:原来的「会员状态」区块已移除(暂时全面免费,不暴露授权/收费信息)
|
||||
statusText = TextView(this).apply {
|
||||
textSize = 15f; setLineSpacing(0f, 1.15f)
|
||||
setTextColor(Color.WHITE)
|
||||
setBackgroundColor(Color.parseColor("#1C2028"))
|
||||
setPadding(24, 20, 24, 20)
|
||||
text = if (isVip) {
|
||||
"✓ 已是会员\n${if (permanent) "永久有效" else "有效期至:$expire"}${if (cardKey?.isNotEmpty() == true) "\n卡号:$cardKey" else ""}"
|
||||
} else {
|
||||
"当前为免费用户(每天 1 小时)\n尚未成为会员"
|
||||
}
|
||||
text = ""
|
||||
}
|
||||
root.addView(statusText, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 24 })
|
||||
@@ -165,7 +155,7 @@ class SettingsActivity : Activity() {
|
||||
textSize = 15f; setLineSpacing(0f, 1.15f)
|
||||
setTextColor(Color.WHITE); setBackgroundColor(Color.parseColor("#1C2028"))
|
||||
setPadding(24, 20, 24, 20)
|
||||
text = "点击右侧按钮检查是否有新版本\n(安装统计会在启动时自动上报)"
|
||||
text = "点击右侧按钮检查是否有新版本"
|
||||
}
|
||||
root.addView(statusText2, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 12 })
|
||||
@@ -174,34 +164,11 @@ class SettingsActivity : Activity() {
|
||||
root.addView(checkBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 40 })
|
||||
|
||||
// ===== 卡密激活 =====
|
||||
root.addView(TextView(this).apply {
|
||||
text = "卡密激活"
|
||||
textSize = 15f; setTextColor(Color.parseColor("#7AA7D9"))
|
||||
setPadding(0, 8, 0, 8)
|
||||
})
|
||||
val cardInput = EditText(this).apply {
|
||||
hint = "请输入卡密"
|
||||
textSize = 16f
|
||||
setTextColor(Color.WHITE)
|
||||
setHintTextColor(Color.parseColor("#888888"))
|
||||
setPadding(24, 20, 24, 20)
|
||||
isSingleLine = true
|
||||
isFocusable = true
|
||||
isFocusableInTouchMode = true
|
||||
background = focusBg(normal = 0xFF1C2028.toInt())
|
||||
inputType = android.text.InputType.TYPE_CLASS_TEXT
|
||||
}
|
||||
root.addView(cardInput, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 12 })
|
||||
// ===== 卡密激活:v9.6.1 起暂时全面免费,此区块整块移除(恢复见 git 历史)=====
|
||||
|
||||
val actBtn = mkAction("激活") { doActivate(cardInput.text.toString().trim()) }
|
||||
root.addView(actBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 24 })
|
||||
|
||||
// ===== ★ 售后联系方式(授权无效 / 卡密用不了时能找到人)=====
|
||||
// ===== ★ 售后联系方式(安装 / 播放遇到问题时能找到人)=====
|
||||
root.addView(TextView(this).apply {
|
||||
text = "⚠ 授权无效、卡密激活不了?\n售后微信:q3970260761"
|
||||
text = "💬 售后微信:q3970260761\n安装、播放有问题都可以找我"
|
||||
textSize = 16f
|
||||
setTextColor(Color.parseColor("#FFC107")) // 橙色醒目
|
||||
gravity = Gravity.CENTER
|
||||
@@ -214,23 +181,7 @@ class SettingsActivity : Activity() {
|
||||
}, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 40 })
|
||||
|
||||
if (isVip) {
|
||||
root.addView(TextView(this).apply {
|
||||
text = "✓ 已经是会员"
|
||||
textSize = 18f; setTextColor(Color.parseColor("#4CAF50"))
|
||||
gravity = Gravity.CENTER; setPadding(0, 24, 0, 12)
|
||||
})
|
||||
// ★ 新增:撤销本机授权(换机 / 换卡密前先解绑)
|
||||
val revokeBtn = mkAction("撤销本机授权(可重新激活 / 换卡密)") { doRevoke() }
|
||||
root.addView(revokeBtn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 20 })
|
||||
} else {
|
||||
val btn = mkAction("支付成为会员(月/季/年)") {
|
||||
startActivity(Intent(this@SettingsActivity, ShopActivity::class.java))
|
||||
}
|
||||
root.addView(btn, LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { bottomMargin = 20 })
|
||||
}
|
||||
// v9.6.1:已移除「撤销本机授权」与「支付成为会员」入口(暂时全面免费,不出现任何收费/授权入口)
|
||||
|
||||
// ===== 其它操作 =====
|
||||
root.addView(TextView(this).apply {
|
||||
|
||||
Reference in new issue
Block a user