Skip to content

Commit

Permalink
fix proguard
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Sep 10, 2024
1 parent 15344b0 commit 1e296a6
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 50 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 更新日誌

### v1.3.7.15

* 修復無法配置的問題
* 修復配置頁面默認EPG不顯示的問題

### v1.3.7.14

* 在遠程配置二維碼基礎上加入文字
Expand Down
6 changes: 5 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep class com.lizongying.mytv0.data.** {
<fields>;
}
13 changes: 7 additions & 6 deletions app/src/main/java/com/lizongying/mytv0/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.lizongying.mytv0.R
import com.lizongying.mytv0.SP
import com.lizongying.mytv0.Utils.getDateFormat
import com.lizongying.mytv0.models.EPGXmlParser
import com.lizongying.mytv0.models.SourceType
import com.lizongying.mytv0.models.TV
import com.lizongying.mytv0.data.SourceType
import com.lizongying.mytv0.data.TV
import com.lizongying.mytv0.models.TVGroupModel
import com.lizongying.mytv0.models.TVListModel
import com.lizongying.mytv0.models.TVModel
Expand All @@ -27,7 +27,6 @@ import java.io.File


class MainViewModel : ViewModel() {
val FILE_NAME = "channels.txt"
private var timeFormat = if (SP.displaySeconds) "HH:mm:ss" else "HH:mm"

private lateinit var appDirectory: File
Expand Down Expand Up @@ -137,6 +136,7 @@ class MainViewModel : ViewModel() {
if (str2List(str)) {
file.writeText(str)
SP.config = serverUrl
_channelsOk.value = true
R.string.channel_import_success.showToast()
} else {
R.string.channel_import_error.showToast()
Expand Down Expand Up @@ -318,18 +318,18 @@ class MainViewModel : ViewModel() {
}
}
for ((title, uris) in tvMap) {
val channel_group = uris.first();
val channelGroup = uris.first();
uris.drop(1);
val tv = TV(
-1,
"",
title.removePrefix(channel_group),
title.removePrefix(channelGroup),
"",
"",
"",
uris,
mapOf(),
channel_group,
channelGroup,
SourceType.UNKNOWN,
listOf(),
)
Expand Down Expand Up @@ -381,5 +381,6 @@ class MainViewModel : ViewModel() {

companion object {
private const val TAG = "MainViewModel"
const val FILE_NAME = "channels.txt"
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/lizongying/mytv0/PlayerFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil
import com.lizongying.mytv0.databinding.PlayerBinding
import com.lizongying.mytv0.models.SourceType
import com.lizongying.mytv0.data.SourceType
import com.lizongying.mytv0.models.TVModel


Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/lizongying/mytv0/SP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object SP {
private const val KEY_LOG_TIMES = "log_times"

const val DEFAULT_CONFIG_URL = ""
const val DEFAULT_CHANNEL_NUM = false
const val DEFAULT_EPG = "https://live.fanmingming.com/e.xml"
const val DEFAULT_CHANNEL = 0
const val DEFAULT_SHOW_ALL_CHANNELS = false
Expand All @@ -76,7 +77,7 @@ object SP {
set(value) = sp.edit().putBoolean(KEY_CHANNEL_REVERSAL, value).apply()

var channelNum: Boolean
get() = sp.getBoolean(KEY_CHANNEL_NUM, true)
get() = sp.getBoolean(KEY_CHANNEL_NUM, DEFAULT_CHANNEL_NUM)
set(value) = sp.edit().putBoolean(KEY_CHANNEL_NUM, value).apply()

var time: Boolean
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/SettingFragment.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lizongying.mytv0

import MainViewModel
import MainViewModel.Companion.FILE_NAME
import android.Manifest
import android.content.pm.PackageManager
import android.graphics.drawable.ColorDrawable
Expand Down Expand Up @@ -120,7 +121,7 @@ class SettingFragment : Fragment() {
val size = Utils.dpToPx(200)
val img = QrCodeUtil().createQRCodeBitmap(server, size, size)
val args = Bundle()
args.putString(KEY_TEXT, server)
args.putString(KEY_TEXT, server.removePrefix("http://"))
args.putParcelable(KEY_BITMAP, img)
imageModalFragment.arguments = args

Expand Down Expand Up @@ -282,6 +283,8 @@ class SettingFragment : Fragment() {
}

binding.clear.setOnClickListener {
SP.channelNum = SP.DEFAULT_CHANNEL_NUM

SP.positionGroup = SP.DEFAULT_POSITION_GROUP
viewModel.groupModel.setPosition(SP.DEFAULT_POSITION_GROUP)
viewModel.groupModel.setPositionPlaying(SP.DEFAULT_POSITION_GROUP)
Expand All @@ -298,7 +301,7 @@ class SettingFragment : Fragment() {
SP.channel = SP.DEFAULT_CHANNEL
confirmChannel()

context.deleteFile(viewModel.FILE_NAME)
context.deleteFile(FILE_NAME)
SP.deleteLike()
SP.position = 0
val tvModel = viewModel.groupModel.getPosition(0)
Expand Down
36 changes: 11 additions & 25 deletions app/src/main/java/com/lizongying/mytv0/SimpleServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.lizongying.mytv0


import MainViewModel
import MainViewModel.Companion.FILE_NAME
import android.content.Context
import android.net.Uri
import android.os.Handler
import android.os.Looper
import android.util.Log
import com.google.gson.Gson
import com.lizongying.mytv0.data.ReqSettings
import com.lizongying.mytv0.data.RespSettings
import fi.iki.elonen.NanoHTTPD
import java.io.File
import java.io.IOException
Expand All @@ -34,17 +36,10 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
"/api/proxy" -> handleProxy(session)
"/api/epg" -> handleEPG(session)
"/api/channel" -> handleDefaultChannel(session)
else -> handleStaticContent(session)
else -> handleStaticContent()
}
}

data class RespSettings(
val channelUri: String,
val channelDefault: Int,
val proxy: String,
val epg: String,
)

private fun handleSettings(): Response {
val response: String
try {
Expand All @@ -67,21 +62,14 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
return newFixedLengthResponse(Response.Status.OK, "application/json", response)
}

data class Req(
var uri: String? = "",
val proxy: String?,
val epg: String?,
val channel: Int?,
)

private fun handleChannelsFromFile(session: IHTTPSession): Response {
R.string.start_config_channel.showToast()
val response = ""
try {
readBody(session)?.let {
handler.post {
if (viewModel.str2List(it)) {
File(context.filesDir, viewModel.FILE_NAME).writeText(it)
File(context.filesDir, FILE_NAME).writeText(it)
SP.config = "file://"
R.string.channel_import_success.showToast()
} else {
Expand All @@ -105,11 +93,9 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
val response = ""
try {
readBody(session)?.let {
val req = Gson().fromJson(it, Req::class.java)
val req = Gson().fromJson(it, ReqSettings::class.java)
if (req.uri != null) {
val url = req.uri
val uri = Uri.parse(url)
Log.i(TAG, "uri $uri")
val uri = Uri.parse(req.uri)
handler.post {
viewModel.parseUri(uri)
}
Expand All @@ -129,7 +115,7 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
try {
readBody(session)?.let {
handler.post {
val req = Gson().fromJson(it, Req::class.java)
val req = Gson().fromJson(it, ReqSettings::class.java)
if (req.proxy != null) {
SP.proxy = req.proxy
R.string.default_proxy_set_success.showToast()
Expand All @@ -154,7 +140,7 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
try {
readBody(session)?.let {
handler.post {
val req = Gson().fromJson(it, Req::class.java)
val req = Gson().fromJson(it, ReqSettings::class.java)
if (req.epg != null) {
SP.epg = req.epg
R.string.default_epg_set_success.showToast()
Expand All @@ -181,7 +167,7 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
try {
readBody(session)?.let {
handler.post {
val req = Gson().fromJson(it, Req::class.java)
val req = Gson().fromJson(it, ReqSettings::class.java)
if (req.channel != null && req.channel > -1) {
SP.channel = req.channel
R.string.default_channel_set_success.showToast()
Expand All @@ -207,7 +193,7 @@ class SimpleServer(private val context: Context, private val viewModel: MainView
return map["postData"]
}

private fun handleStaticContent(session: IHTTPSession): Response {
private fun handleStaticContent(): Response {
val html = loadHtmlFromResource(R.raw.index)
return newFixedLengthResponse(Response.Status.OK, "text/html", html)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lizongying.mytv0.models
package com.lizongying.mytv0.data


data class EPG(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lizongying.mytv0.models
package com.lizongying.mytv0.data

import java.io.Serializable

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/data/ReqSettings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.lizongying.mytv0.data

data class ReqSettings(
var uri: String? = "",
val proxy: String?,
val epg: String?,
val channel: Int?,
)
8 changes: 8 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/data/RespSettings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.lizongying.mytv0.data

data class RespSettings(
val channelUri: String,
val channelDefault: Int,
val proxy: String,
val epg: String,
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lizongying.mytv0.models
package com.lizongying.mytv0.data

enum class SourceType {
UNKNOWN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lizongying.mytv0.models
package com.lizongying.mytv0.data

import java.io.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lizongying.mytv0.models

import android.util.Xml
import com.lizongying.mytv0.data.EPG
import org.xmlpull.v1.XmlPullParser
import java.io.InputStream
import java.text.SimpleDateFormat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class TVGroupModel : ViewModel() {

init {
_position.value = SP.positionGroup
Log.i(TAG, "SP.positionGroup ${SP.positionGroup}")
Log.i(TAG, "default positionGroup ${SP.positionGroup}")
isInLikeMode = SP.defaultLike && _position.value == 0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class TVListModel(private val name: String, private val groupIndex: Int) : ViewM

init {
_position.value = SP.position
Log.i(TAG, "SP.position ${SP.position}")
Log.i(TAG, "default position ${SP.position}")
}

fun size(): Int {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/models/TVModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import androidx.media3.exoplayer.rtsp.RtspMediaSource
import androidx.media3.exoplayer.source.MediaSource
import androidx.media3.exoplayer.source.ProgressiveMediaSource
import com.lizongying.mytv0.SP
import com.lizongying.mytv0.data.EPG
import com.lizongying.mytv0.data.Program
import com.lizongying.mytv0.data.SourceType
import com.lizongying.mytv0.data.TV
import kotlin.math.max
import kotlin.math.min

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/channels.txt

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions app/src/main/res/raw/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
label {
display: inline-block;
width: 100%;
margin-bottom: .5rem;
}

input {
Expand Down Expand Up @@ -104,7 +105,7 @@ <h1 class="title">我的電視·〇</h1>
appName: '我的電視·〇',
uriLabel: '視頻源地址',
uploadFileLabel: '選擇視頻源文件後會自動上傳保存',
channelLabel: '默認播放頻道,從1開始',
channelLabel: '默認播放頻道,從1開始。0代表沒有設置',
epgLabel: 'EPG',
proxyLabel: '代理地址',
confirm: '確認',
Expand All @@ -113,7 +114,7 @@ <h1 class="title">我的電視·〇</h1>
appName: '我的电视·〇',
uriLabel: '视频源地址',
uploadFileLabel: '选择视频源文件后会自动上传保存',
channelLabel: '默认播放频道,从1开始',
channelLabel: '默认播放频道,从1开始。0代表沒有设置',
epgLabel: 'EPG',
proxyLabel: '代理地址',
confirm: '确认',
Expand Down Expand Up @@ -202,6 +203,7 @@ <h1 class="title">我的電視·〇</h1>
console.log(json);
document.querySelector('#channel').value = json.channelDefault;
document.querySelector('#uri').value = json.channelUri;
document.querySelector('#epg').value = json.epg;
document.querySelector('#proxy').value = json.proxy;
})()
</script>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<string name="default_proxy_set_failure">代理地址设置失败</string>
<string name="default_epg_set_success">EPG设置成功</string>
<string name="default_epg_set_failure">EPG设置失败</string>
<string name="start_config_channel">开始配置频道</string>
<string name="start_config_channel">开始导入频道</string>
<string name="start_set_default_channel">开始设置默认频道</string>
<string name="my_favorites">我的收藏</string>
<string name="all_channels">全部频道</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<string name="default_proxy_set_failure">代理地址設定失敗</string>
<string name="default_epg_set_success">EPG設定成功</string>
<string name="default_epg_set_failure">EPG設定失敗</string>
<string name="start_config_channel">開始配置頻道</string>
<string name="start_config_channel">開始導入頻道</string>
<string name="start_set_default_channel">開始設置默認頻道</string>
<string name="my_favorites">我的收藏</string>
<string name="all_channels">全部頻道</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<string name="default_proxy_set_failure">Failed to set proxy</string>
<string name="default_epg_set_success">EPG set successfully</string>
<string name="default_epg_set_failure">Failed to set EPG</string>
<string name="start_config_channel">Start Configuring Channel</string>
<string name="start_set_default_channel">Start Setting Default Channel</string>
<string name="start_config_channel">Start import channel</string>
<string name="start_set_default_channel">Start setting default channel</string>
<string name="my_favorites">My Favorites</string>
<string name="all_channels">All Channels</string>
<string name="compact_menu">Compact Menu</string>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version_code": 16975630, "version_name": "v1.3.7.14"}
{"version_code": 16975631, "version_name": "v1.3.7.15"}

0 comments on commit 1e296a6

Please sign in to comment.