This commit is contained in:
HapeLee
2025-06-10 17:08:11 +08:00
parent 5a55aee755
commit 32e7e78c69
9 changed files with 222 additions and 62 deletions
@@ -136,7 +136,8 @@ abstract class BaseActivity<VB : ViewBinding>(
when (getPrefString("app_theme", "0")) {
"0" -> DynamicColors.applyToActivitiesIfAvailable(application)
"1" -> setTheme(R.style.Theme_Base_GR)
"2" -> setTheme(R.style.Theme_Base_WH)
"2" -> setTheme(R.style.Theme_Base_Lemon)
"3" -> setTheme(R.style.Theme_Base_WH)
}
}
@@ -91,8 +91,9 @@ class ThemeCardPreference(
private val themeResIdMap = mapOf(
"0" to R.style.Base_AppTheme,
"1" to R.style.Theme_Base_GR,
"2" to R.style.Theme_Base_WH
)
"2" to R.style.Theme_Base_Lemon,
"3" to R.style.Theme_Base_WH,
)
private fun getThemeColors(value: String): List<Int> {
val themeResId = themeResIdMap[value] ?: return listOf(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY)
@@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.view.textclassifier.TextClassifier
import androidx.lifecycle.lifecycleScope
import io.legato.kazusa.R
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
import io.legato.kazusa.base.BaseDialogFragment
import io.legato.kazusa.databinding.DialogTextViewBinding
import io.legato.kazusa.help.IntentData
@@ -25,7 +26,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class TextDialog() : BaseDialogFragment(R.layout.dialog_text_view) {
class TextDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_text_view) {
enum class Mode {
MD, HTML, TEXT
@@ -44,8 +45,6 @@ class TextDialog() : BaseDialogFragment(R.layout.dialog_text_view) {
putString("mode", mode.name)
putLong("time", time)
}
isCancelable = false
this.autoClose = autoClose
}
private val binding by viewBinding(DialogTextViewBinding::bind)
@@ -54,21 +53,21 @@ class TextDialog() : BaseDialogFragment(R.layout.dialog_text_view) {
override fun onStart() {
super.onStart()
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 0.9f)
//setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 0.9f)
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
//binding.toolBar.setBackgroundColor(primaryColor)
binding.toolBar.inflateMenu(R.menu.dialog_text)
binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_close -> dismissAllowingStateLoss()
}
true
}
//binding.toolBar.inflateMenu(R.menu.dialog_text)
//binding.toolBar.menu.applyTint(requireContext())
// binding.toolBar.setOnMenuItemClickListener {
// when (it.itemId) {
// R.id.menu_close -> dismissAllowingStateLoss()
// }
// true
// }
arguments?.let {
binding.toolBar.title = it.getString("title")
//binding.toolBar.title = it.getString("title")
val content = IntentData.get(it.getString("content")) ?: ""
when (it.getString("mode")) {
Mode.MD.name -> viewLifecycleOwner.lifecycleScope.launch {
@@ -100,26 +99,26 @@ class TextDialog() : BaseDialogFragment(R.layout.dialog_text_view) {
}
time = it.getLong("time", 0L)
}
if (time > 0) {
binding.badgeView.setBadgeCount((time / 1000).toInt())
lifecycleScope.launch {
while (time > 0) {
delay(1000)
time -= 1000
binding.badgeView.setBadgeCount((time / 1000).toInt())
if (time <= 0) {
view.post {
dialog?.setCancelable(true)
if (autoClose) dialog?.cancel()
}
}
}
}
} else {
view.post {
dialog?.setCancelable(true)
}
}
// if (time > 0) {
// binding.badgeView.setBadgeCount((time / 1000).toInt())
// lifecycleScope.launch {
// while (time > 0) {
// delay(1000)
// time -= 1000
// binding.badgeView.setBadgeCount((time / 1000).toInt())
// if (time <= 0) {
// view.post {
// dialog?.setCancelable(true)
// if (autoClose) dialog?.cancel()
// }
// }
// }
// }
// } else {
// view.post {
// dialog?.setCancelable(true)
// }
// }
}
}