Skip to content

Commit

Permalink
some style
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Aug 8, 2024
1 parent a819b61 commit 941362d
Show file tree
Hide file tree
Showing 22 changed files with 304 additions and 126 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## 更新日志

### v1.3.3

* 一些樣式優化
* 不同組頻道不合併
* 防止頻道文件被覆蓋
* 修復不顯示全部頻道的問題

### v1.3.2

* 固定遠程配置端口為34567
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ adb install my-tv-0.apk
* 詳細EPG
* 淺色菜單
* 無效的頻道?
* 导入文件后,修改配置地址,防止二次覆盖。判断文件是否被修改

## 讚賞

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fun getVersionName(): String {
}

dependencies {
implementation(libs.appcompat)
// For AGP 7.4+
coreLibraryDesugaring(libs.desugar.jdk.libs)

Expand All @@ -96,7 +97,6 @@ dependencies {

implementation(libs.core.ktx)
implementation(libs.coroutines)
implementation(libs.leanback)

implementation(libs.multidex)
implementation(libs.constraintlayout)
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/lizongying/mytv0/GroupAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class GroupAdapter(
val oldLikeMode = tvGroupModel.isInLikeMode;
tvGroupModel.isInLikeMode = position == 0
if (tvGroupModel.isInLikeMode) {
R.string.favorite_mode.showToast()
// R.string.favorite_mode.showToast()
} else if (oldLikeMode) {
R.string.standard_mode.showToast()
// R.string.standard_mode.showToast()
}
}, 500)
}
Expand Down Expand Up @@ -152,7 +152,11 @@ class GroupAdapter(
class ViewHolder(private val context: Context, private val binding: GroupItemBinding) :
RecyclerView.ViewHolder(binding.root) {
fun bindTitle(text: String) {
binding.title.text = text
binding.title.text = when (text) {
"我的收藏" -> context.getString(R.string.my_favorites)
"全部頻道" -> context.getString(R.string.all_channels)
else -> text
}
}

fun focus(hasFocus: Boolean) {
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/lizongying/mytv0/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import com.lizongying.mytv0.models.TVList
import java.util.Locale


class MainActivity : FragmentActivity() {
class MainActivity : AppCompatActivity() {

private var ok = 0
private var playerFragment = PlayerFragment()
Expand Down Expand Up @@ -144,26 +144,26 @@ class MainActivity : FragmentActivity() {
if (SP.channel > 0) {
if (SP.channel < TVList.listModel.size) {
TVList.setPosition(SP.channel - 1)
R.string.play_default_channel.showToast()
// R.string.play_default_channel.showToast()
} else {
SP.channel = 0
TVList.setPosition(0)
R.string.default_channel_out_of_range.showToast()
// R.string.default_channel_out_of_range.showToast()
}
} else {
if (!TVList.setPosition(SP.position)) {
TVList.setPosition(0)
R.string.last_channel_out_of_range.showToast()
// R.string.last_channel_out_of_range.showToast()
} else {
R.string.play_last_channel.showToast()
// R.string.play_last_channel.showToast()
}
}

TVList.groupModel.isInLikeMode = SP.defaultLike;
if (TVList.groupModel.isInLikeMode) {
R.string.favorite_mode.showToast()
// R.string.favorite_mode.showToast()
} else {
R.string.standard_mode.showToast()
// R.string.standard_mode.showToast()
}

// TODO group position
Expand Down
119 changes: 64 additions & 55 deletions app/src/main/java/com/lizongying/mytv0/SettingFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lizongying.mytv0

import android.Manifest
import android.content.pm.PackageManager
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -188,69 +189,77 @@ class SettingFragment : Fragment() {
val txtTextSize =
application.px2PxFont(binding.versionName.textSize)

binding.checkVersion.layoutParams.width = btnWidth
binding.checkVersion.layoutParams.height = btnHeight
binding.checkVersion.textSize = btnTextSize
binding.checkVersion.layoutParams = btnLayoutParams

binding.versionName.layoutParams.width = txtWidth
binding.versionName.textSize = txtTextSize

binding.qrcode.layoutParams.width = btnWidth
binding.qrcode.layoutParams.height = btnHeight
binding.qrcode.textSize = btnTextSize
binding.qrcode.layoutParams = btnLayoutParams

binding.confirmConfig.layoutParams.width = btnWidth
binding.confirmConfig.layoutParams.height = btnHeight
binding.confirmConfig.textSize = btnTextSize
binding.confirmConfig.layoutParams = btnLayoutParams

binding.clear.layoutParams.width = btnWidth
binding.clear.layoutParams.height = btnHeight
binding.clear.textSize = btnTextSize
binding.clear.layoutParams = btnLayoutParams

binding.appreciate.layoutParams.width = btnWidth
binding.appreciate.layoutParams.height = btnHeight
binding.appreciate.textSize = btnTextSize
binding.appreciate.layoutParams = btnLayoutParams

binding.exit.layoutParams.width = btnWidth
binding.exit.layoutParams.height = btnHeight
binding.exit.textSize = btnTextSize
binding.exit.layoutParams = btnLayoutParams
for (i in listOf(
binding.qrcode,
binding.confirmConfig,
binding.clear,
binding.checkVersion,
binding.exit,
binding.appreciate,
)) {
i.layoutParams.width = btnWidth
i.layoutParams.height = btnHeight
i.textSize = btnTextSize
i.layoutParams = btnLayoutParams
i.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
i.background = ColorDrawable(
ContextCompat.getColor(
context,
R.color.focus
)
)
} else {
i.background = ColorDrawable(
ContextCompat.getColor(
context,
R.color.description_blur
)
)
}
}
}

val textSize = application.px2PxFont(binding.switchChannelReversal.textSize)
val textSizeSwitch = application.px2PxFont(binding.switchChannelReversal.textSize)

val layoutParamsChannelReversal =
val layoutParamsSwitch =
binding.switchChannelReversal.layoutParams as ViewGroup.MarginLayoutParams
layoutParamsChannelReversal.topMargin =
layoutParamsSwitch.topMargin =
application.px2Px(binding.switchChannelReversal.marginTop)

binding.switchChannelReversal.textSize = textSize
binding.switchChannelReversal.layoutParams = layoutParamsChannelReversal

binding.switchChannelNum.textSize = textSize
binding.switchChannelNum.layoutParams = layoutParamsChannelReversal

binding.switchTime.textSize = textSize
binding.switchTime.layoutParams = layoutParamsChannelReversal

binding.switchBootStartup.textSize = textSize
binding.switchBootStartup.layoutParams = layoutParamsChannelReversal

binding.switchRepeatInfo.textSize = textSize
binding.switchRepeatInfo.layoutParams = layoutParamsChannelReversal

binding.switchConfigAutoLoad.textSize = textSize
binding.switchConfigAutoLoad.layoutParams = layoutParamsChannelReversal

binding.switchDefaultLike.textSize = textSize
binding.switchDefaultLike.layoutParams = layoutParamsChannelReversal

binding.switchShowAllChannels.textSize = textSize
binding.switchShowAllChannels.layoutParams = layoutParamsChannelReversal
for (i in listOf(
binding.switchChannelReversal,
binding.switchChannelNum,
binding.switchTime,
binding.switchBootStartup,
binding.switchRepeatInfo,
binding.switchConfigAutoLoad,
binding.switchDefaultLike,
binding.switchShowAllChannels,
)) {
i.textSize = textSizeSwitch
i.layoutParams = layoutParamsSwitch
i.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
i.setTextColor(
ContextCompat.getColor(
context,
R.color.focus
)
)
} else {
i.setTextColor(
ContextCompat.getColor(
context,
R.color.title_blur
)
)
}
}
}

updateManager = UpdateManager(context, context.appVersionCode)

Expand Down
22 changes: 13 additions & 9 deletions app/src/main/java/com/lizongying/mytv0/SimpleServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,26 @@ class SimpleServer(private val context: Context) : NanoHTTPD(PORT) {

override fun serve(session: IHTTPSession): Response {
return when (session.uri) {
"/api/channels" -> handleChannelsRequest(session)
"/api/uri" -> handleUriRequest(session)
"/api/channel" -> handleChannel(session)
"/api/channels" -> handleChannelsFromFile(session)
"/api/uri" -> handleChannelsFromUri(session)
"/api/channel" -> handleDefaultChannel(session)
"/api/proxy" -> handleProxy(session)
"/api/settings" -> handleSettings()
else -> handleStaticContent(session)
}
}

private fun handleChannelsRequest(session: IHTTPSession): Response {
private fun handleChannelsFromFile(session: IHTTPSession): Response {
R.string.start_config_channel.showToast()
val response = ""
try {
val map = HashMap<String, String>()
session.parseBody(map)
map["postData"]?.let {
handler.post {
if (TVList.str2List(it)) {
File(context.filesDir, TVList.FILE_NAME).writeText(it)
SP.config = "file://"
R.string.channel_import_success.showToast()
} else {
R.string.channel_import_error.showToast()
Expand All @@ -62,7 +65,6 @@ class SimpleServer(private val context: Context) : NanoHTTPD(PORT) {
e.message
)
}
val response = ""
return newFixedLengthResponse(Response.Status.OK, "text/plain", response)
}

Expand All @@ -84,7 +86,9 @@ class SimpleServer(private val context: Context) : NanoHTTPD(PORT) {
var uri: String = "",
)

private fun handleUriRequest(session: IHTTPSession): Response {
private fun handleChannelsFromUri(session: IHTTPSession): Response {
R.string.start_config_channel.showToast()
val response = ""
try {
val map = HashMap<String, String>()
session.parseBody(map)
Expand All @@ -103,15 +107,16 @@ class SimpleServer(private val context: Context) : NanoHTTPD(PORT) {
"SERVER INTERNAL ERROR: IOException: " + e.message
)
}
val response = "频道读取中"
return newFixedLengthResponse(Response.Status.OK, "text/plain", response)
}

data class ReqChannel(
val channel: Int,
)

private fun handleChannel(session: IHTTPSession): Response {
private fun handleDefaultChannel(session: IHTTPSession): Response {
R.string.start_set_default_channel.showToast()
val response = ""
try {
val map = HashMap<String, String>()
session.parseBody(map)
Expand All @@ -134,7 +139,6 @@ class SimpleServer(private val context: Context) : NanoHTTPD(PORT) {
e.message
)
}
val response = ""
return newFixedLengthResponse(Response.Status.OK, "text/plain", response)
}

Expand Down
Loading

0 comments on commit 941362d

Please sign in to comment.