Skip to content

Commit

Permalink
optimize style
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Dec 23, 2024
1 parent 32356cd commit ff89218
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 更新日誌

### v1.3.8.12-kitkat

* 優化樣式

### v1.3.8.11-kitkat

* 新增視頻源後默認選中
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/com/lizongying/mytv0/InfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,18 @@ class InfoFragment : Fragment() {

when (tvModel.tv.title) {
else -> {
val width = Utils.dpToPx(100)
val height = Utils.dpToPx(60)
val width = 300
val height = 180
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)

val text = "${tvModel.tv.id + 1}"
var size = 100f
if (tvModel.tv.id > 999) {
size = 90f
val channelNum = tvModel.tv.id + 1
var size = 150f
if (channelNum > 99) {
size = 100f
}
if (channelNum > 999) {
size = 75f
}
val paint = Paint().apply {
color = ContextCompat.getColor(context, R.color.title_blur)
Expand All @@ -101,7 +104,7 @@ class InfoFragment : Fragment() {
}
val x = width / 2f
val y = height / 2f - (paint.descent() + paint.ascent()) / 2
canvas.drawText(text, x, y, paint)
canvas.drawText(channelNum.toString(), x, y, paint)

val url = tvModel.tv.logo
val name = tvModel.tv.name
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/java/com/lizongying/mytv0/ListAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.lizongying.mytv0
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.os.Handler
import android.os.Looper
Expand All @@ -15,7 +14,6 @@ import android.view.ViewGroup
import android.view.ViewGroup.FOCUS_BEFORE_DESCENDANTS
import android.view.ViewGroup.FOCUS_BLOCK_DESCENDANTS
import androidx.core.content.ContextCompat
import androidx.core.view.marginStart
import androidx.core.view.setPadding
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -185,20 +183,27 @@ class ListAdapter(
}

fun bindImage(url: String?, id: Int, name: String, tvModel: TVModel) {
val width = Utils.dpToPx(40)
val height = Utils.dpToPx(40)
val width = 300
val height = 180
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)

val channelNum = id + 1
var size = 150f
if (channelNum > 99) {
size = 100f
}
if (channelNum > 999) {
size = 75f
}
val paint = Paint().apply {
color = Color.WHITE
textSize = 32f
color = ContextCompat.getColor(context, R.color.title_blur)
textSize = size
textAlign = Paint.Align.CENTER
}
val text = String.format("%3d", id + 1)
val x = width / 2f
val y = height / 2f - (paint.descent() + paint.ascent()) / 2
canvas.drawText(text, x, y, paint)
canvas.drawText(channelNum.toString(), x, y, paint)

var urls =
getUrls(
Expand Down Expand Up @@ -230,13 +235,15 @@ class ListAdapter(
R.drawable.baseline_favorite_24
)
)
binding.heart.setColorFilter(ContextCompat.getColor(context, R.color.heart))
} else {
binding.heart.setImageDrawable(
ContextCompat.getDrawable(
context,
R.drawable.baseline_favorite_border_24
)
)
binding.heart.setColorFilter(ContextCompat.getColor(context, R.color.title_blur))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class MainActivity : AppCompatActivity() {
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_IMMERSIVE
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// View.SYSTEM_UI_FLAG_IMMERSIVE
}

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/ModalFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class ModalFragment : DialogFragment() {
dialog?.window?.apply {
addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

setBackgroundDrawableResource(android.R.color.transparent)

setLayout(binding.modalImage.layoutParams.width, WindowManager.LayoutParams.WRAP_CONTENT)
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/SourcesAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.marginEnd
import androidx.core.view.marginStart
import androidx.core.view.setPadding
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -41,6 +39,8 @@ class SourcesAdapter(
binding.heart.layoutParams.height = application.px2Px(binding.heart.layoutParams.height)
binding.heart.setPadding(application.px2Px(binding.heart.paddingTop))

binding.heart.setColorFilter(ContextCompat.getColor(context, R.color.title_blur))

return ViewHolder(context, binding)
}

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/lizongying/mytv0/SourcesFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ class SourcesFragment : DialogFragment(), SourcesAdapter.ItemListener {
super.onStart()
dialog?.window?.apply {
addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN

setBackgroundDrawableResource(android.R.color.transparent)

setLayout(binding.list.layoutParams.width, WindowManager.LayoutParams.WRAP_CONTENT)
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/sources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
android:id="@+id/sources"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/description_blur"
>
<TextView
android:id="@+id/content"
Expand All @@ -20,13 +19,15 @@
android:visibility="gone"
android:text="@string/no_video_source"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="600dp"
android:layout_height="400dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
</androidx.recyclerview.widget.RecyclerView>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version_code": 16975883, "version_name": "v1.3.8.11-kitkat"}
{"version_code": 16975884, "version_name": "v1.3.8.12-kitkat"}

0 comments on commit ff89218

Please sign in to comment.