v3.42(versionCode 63)
This commit is contained in:
@@ -30,7 +30,7 @@ object CodeHighlight {
|
||||
val LIGHT = Palette(
|
||||
keyword = 0xFF8250DF.toInt(),
|
||||
string = 0xFF0A7D33.toInt(),
|
||||
comment = 0xFF7A828E.toInt(),
|
||||
comment = 0xFF6B7280.toInt(),
|
||||
number = 0xFFB35900.toInt(),
|
||||
annotation = 0xFFB25F35.toInt(),
|
||||
function = 0xFF0550AE.toInt(),
|
||||
@@ -40,7 +40,7 @@ object CodeHighlight {
|
||||
val DARK = Palette(
|
||||
keyword = 0xFFC792EA.toInt(),
|
||||
string = 0xFF9ECE6A.toInt(),
|
||||
comment = 0xFF6F7784.toInt(),
|
||||
comment = 0xFF8A93A0.toInt(),
|
||||
number = 0xFFE0AF68.toInt(),
|
||||
annotation = 0xFFD4814F.toInt(),
|
||||
function = 0xFF7DCFFF.toInt(),
|
||||
|
||||
@@ -285,17 +285,21 @@ class FeedAdapter(
|
||||
* 不依赖运行期配置状态,从根上消除混色。
|
||||
*/
|
||||
private fun themedContext(): Context {
|
||||
val appCtx = context.applicationContext
|
||||
/* 用**页面自己的**资源判断深浅,不用 applicationContext:
|
||||
AppCompatDelegate 切夜间模式时更新的是 Activity 的资源,
|
||||
应用级 resources 可能还停在旧配置——那样卡片文字会取到另一套颜色,
|
||||
出现「深色卡片配浅色模式的近黑标题」。Ui.popupPalette 踩过同一个坑。 */
|
||||
val base = context
|
||||
val dark = when (prefs.darkMode) {
|
||||
Prefs.MODE_DARK -> true
|
||||
Prefs.MODE_LIGHT -> false
|
||||
else -> (appCtx.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
else -> (base.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
val conf = Configuration(appCtx.resources.configuration)
|
||||
val conf = Configuration(base.resources.configuration)
|
||||
conf.uiMode = (conf.uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()) or
|
||||
if (dark) Configuration.UI_MODE_NIGHT_YES else Configuration.UI_MODE_NIGHT_NO
|
||||
return appCtx.createConfigurationContext(conf)
|
||||
return base.createConfigurationContext(conf)
|
||||
}
|
||||
|
||||
private var themeCtx: Context = themedContext()
|
||||
|
||||
@@ -95,7 +95,7 @@ class ImagePreviewActivity : AppCompatActivity() {
|
||||
|
||||
errorView = TextView(this).apply {
|
||||
setTextColor(Color.WHITE)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
|
||||
gravity = Gravity.CENTER
|
||||
setPadding(dp(24), dp(16), dp(24), dp(16))
|
||||
layoutParams = FrameLayout.LayoutParams(
|
||||
|
||||
@@ -350,7 +350,7 @@ class MailDetailActivity : AppCompatActivity() {
|
||||
*/
|
||||
private fun themeMailCss(dark: Boolean): String = buildString {
|
||||
if (dark) {
|
||||
append("html,body{background:#191B1F!important;color:#EFEBE4!important;}")
|
||||
append("html,body{background:#191B1F!important;color:#E6E1D8!important;}")
|
||||
append(".pp-wrap,.pp-wrap table,.pp-wrap thead,.pp-wrap tbody,.pp-wrap tfoot,")
|
||||
append(".pp-wrap tr,.pp-wrap td,.pp-wrap th,.pp-wrap div,.pp-wrap span,")
|
||||
append(".pp-wrap p,.pp-wrap li,.pp-wrap ul,.pp-wrap ol,.pp-wrap dl,.pp-wrap dd,")
|
||||
@@ -359,11 +359,11 @@ class MailDetailActivity : AppCompatActivity() {
|
||||
append(".pp-wrap code,.pp-wrap font,.pp-wrap label,.pp-wrap small,")
|
||||
append(".pp-wrap h1,.pp-wrap h2,.pp-wrap h3,.pp-wrap h4,.pp-wrap h5,.pp-wrap h6")
|
||||
append("{background-color:transparent!important;border-color:#33383F!important;}")
|
||||
append(".pp-wrap{color:#EFEBE4!important;}")
|
||||
append(".pp-wrap{color:#E6E1D8!important;}")
|
||||
append(".pp-wrap *{color:inherit!important;}")
|
||||
append(".pp-wrap a,.pp-wrap a *{color:#D4814F!important;}")
|
||||
append(".pp-wrap h1,.pp-wrap h2,.pp-wrap h3,.pp-wrap h4,.pp-wrap h5,.pp-wrap h6")
|
||||
append("{color:#FAF7F1!important;}")
|
||||
append("{color:#F3EEE5!important;}")
|
||||
append(".pp-wrap hr{border-color:#33383F!important;}")
|
||||
} else {
|
||||
append("html,body{background:#FFFFFF!important;}")
|
||||
@@ -379,7 +379,7 @@ class MailDetailActivity : AppCompatActivity() {
|
||||
val input = EditText(this).apply {
|
||||
hint = "输入回复内容"
|
||||
minLines = 4
|
||||
setTextSize(14f)
|
||||
setTextSize(15f)
|
||||
setPadding(
|
||||
(16 * resources.displayMetrics.density).toInt(),
|
||||
(12 * resources.displayMetrics.density).toInt(),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shitoucuo.postpad
|
||||
|
||||
import android.content.Context
|
||||
import android.util.TypedValue
|
||||
import androidx.core.content.ContextCompat
|
||||
import io.noties.markwon.AbstractMarkwonPlugin
|
||||
import io.noties.markwon.core.MarkwonTheme
|
||||
@@ -14,19 +15,24 @@ class MdThemePlugin(private val context: Context) : AbstractMarkwonPlugin() {
|
||||
|
||||
private val d = context.resources.displayMetrics.density
|
||||
|
||||
/** 代码字号用 sp:跟着系统字体大小走,与正文同一套缩放规则 */
|
||||
private fun sp(value: Float): Int = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP, value, context.resources.displayMetrics,
|
||||
).toInt()
|
||||
|
||||
override fun configureTheme(builder: MarkwonTheme.Builder) {
|
||||
builder
|
||||
// # / ## / ### ... 字号逐级递减(正文 16sp 起算,h1 约 23sp)
|
||||
// # / ## / ### ... 字号逐级递减(正文 17sp 起算,h1 约 24.7sp)
|
||||
.headingTextSizeMultipliers(floatArrayOf(1.45f, 1.3f, 1.18f, 1.08f, 1.02f, 1f))
|
||||
.headingBreakHeight((1 * d).toInt())
|
||||
.headingBreakColor(ContextCompat.getColor(context, R.color.divider))
|
||||
// 行内代码与代码块
|
||||
// 行内代码与代码块:统一 13sp,与代码卡的等宽正文同一档
|
||||
.codeBackgroundColor(ContextCompat.getColor(context, R.color.input_bg))
|
||||
.codeTextColor(ContextCompat.getColor(context, R.color.text))
|
||||
.codeTextSize((14 * d).toInt())
|
||||
.codeTextSize(sp(13f))
|
||||
.codeBlockBackgroundColor(ContextCompat.getColor(context, R.color.input_bg))
|
||||
.codeBlockTextColor(ContextCompat.getColor(context, R.color.text))
|
||||
.codeBlockTextSize((14 * d).toInt())
|
||||
.codeBlockTextSize(sp(13f))
|
||||
.codeBlockMargin((8 * d).toInt())
|
||||
// 引用条用品牌橙,分割线用主题分隔色,链接可点击
|
||||
.blockQuoteColor(ContextCompat.getColor(context, R.color.brand))
|
||||
|
||||
@@ -304,7 +304,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
setPadding(0, dp(6), 0, dp(6))
|
||||
scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
|
||||
}
|
||||
val popupW = Ui.menuWidth(this, entries, textSizeSp = 13f, extraDp = 52, minDp = 120, maxDp = 240)
|
||||
val popupW = Ui.menuWidth(this, entries, textSizeSp = 15f, extraDp = 52, minDp = 120, maxDp = 240)
|
||||
val popupH = entries.size * dp(46) + dp(12)
|
||||
val popup = PopupWindow(listView, popupW, popupH, true).apply {
|
||||
isOutsideTouchable = true
|
||||
@@ -479,7 +479,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
tags.forEach { tag ->
|
||||
val chip = TextView(this).apply {
|
||||
text = "#$tag"
|
||||
textSize = 11.5f
|
||||
textSize = 12f
|
||||
setTextColor(ContextCompat.getColor(context, R.color.brand))
|
||||
background = ContextCompat.getDrawable(context, R.drawable.bg_brand_soft)
|
||||
setPadding(dp(10), dp(4), dp(10), dp(5))
|
||||
@@ -906,7 +906,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
if (lang.isNotBlank() && lang.length <= 16) {
|
||||
val label = TextView(this).apply {
|
||||
text = lang.lowercase()
|
||||
textSize = 10f
|
||||
textSize = 11f
|
||||
letterSpacing = 0.08f
|
||||
setTextColor(ContextCompat.getColor(context, R.color.code_lang))
|
||||
setPadding(dp(14), dp(9), dp(14), 0)
|
||||
@@ -915,7 +915,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
}
|
||||
val body = TextView(this).apply {
|
||||
typeface = Typeface.MONOSPACE
|
||||
textSize = 12.5f
|
||||
textSize = 13f
|
||||
includeFontPadding = false
|
||||
setLineSpacing(0f, 1.42f)
|
||||
setTextColor(ContextCompat.getColor(context, R.color.code_text))
|
||||
@@ -989,10 +989,11 @@ class ReaderActivity : AppCompatActivity() {
|
||||
private fun addTextSegment(text: String) {
|
||||
if (text.isBlank()) return
|
||||
val tv = TextView(this).apply {
|
||||
// 正文 16sp + 1.4 倍行高:中文长文按 15sp/1.25 排,段落一多就糊成一片
|
||||
textSize = 16f
|
||||
// 正文 17sp + 1.45 倍行高(约 1.68 行距):中文长文的舒适区在 1.6~1.75,
|
||||
// 字号与行距必须同向调整,只加字号会让行贴着行、更像「密不透风」。
|
||||
textSize = 17f
|
||||
setTextColor(ContextCompat.getColor(context, R.color.text))
|
||||
setLineSpacing(dp(4).toFloat(), 1.4f)
|
||||
setLineSpacing(dp(4).toFloat(), 1.45f)
|
||||
movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
markwon.setMarkdown(tv, text)
|
||||
|
||||
Reference in New Issue
Block a user