Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65dd927d07 | ||
|
|
42b38f5b81 | ||
|
|
087bbf52d4 |
No files matched your search
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.iptv807.tv"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
versionCode = 948
|
||||
versionName = "9.4.8"
|
||||
versionCode = 960
|
||||
versionName = "9.6.0"
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 28 KiB |
Reference in new issue
Block a user