v3.17 类型分布、完成任务口径、重复任务删除修复
- 专注页选任务不再自动开跑,底部文案改为「请选择任务后开始专注」 - 项目新增 type 字段(DB v10),设置页可配置类型,统计页新增类型分布卡 - 今日完成任务只统计真实专注(sessions.completed=1 且 seconds>0) - 重复任务删除不再复活:只从真根滚动、完成副本不写悬空 origin、 新增 pruneDanglingInstances 清理断链残渣、滚动前校验根存在
This commit is contained in:
@@ -127,6 +127,15 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
},
|
||||
)
|
||||
|
||||
section(R.string.section_types)
|
||||
card(
|
||||
// 类型只是给项目打的标签:值列表可改,改完项目弹层与统计页的类型分布立刻跟着变
|
||||
action(
|
||||
getString(R.string.type_settings),
|
||||
Prefs.projectTypes.joinToString("、"),
|
||||
) { inputProjectTypes() },
|
||||
)
|
||||
|
||||
section(R.string.section_appearance)
|
||||
card(
|
||||
action(
|
||||
@@ -285,6 +294,9 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
textSize = 13f
|
||||
setTextColor(col(R.color.text_secondary))
|
||||
setPadding(0, 0, dpi(6f), 0)
|
||||
// 值可能是「工作、学习、娱乐、提升」这种长串,单行省略,别把右边箭头挤出去
|
||||
maxLines = 1
|
||||
ellipsize = android.text.TextUtils.TruncateAt.END
|
||||
})
|
||||
}
|
||||
if (showArrow) {
|
||||
@@ -421,6 +433,98 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}, 100L)
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目类型列表:一行英文逗号分隔的文本。
|
||||
*
|
||||
* 用纯文本而不是逐条增删的列表,是因为这个字段就是"几个词",
|
||||
* 一次粘贴「工作,学习,娱乐,提升」比点四次添加更快;
|
||||
* 解析时统一 trim / 去空项 / 去重,所以中文逗号、多余空格不会存进去
|
||||
* (中文逗号会被当成普通字符,所以在说明里明确写了要用英文逗号)。
|
||||
*/
|
||||
private fun inputProjectTypes() {
|
||||
val ctx = requireContext()
|
||||
val dialog = android.app.Dialog(ctx)
|
||||
dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
|
||||
|
||||
val panel = LinearLayout(ctx).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
background = ctx.roundBg(ctx.col(R.color.surface), 16f, ctx.col(R.color.card_stroke), 1f)
|
||||
setPadding(dpi(20f), dpi(20f), dpi(20f), dpi(14f))
|
||||
}
|
||||
panel.addView(TextView(ctx).apply {
|
||||
text = getString(R.string.type_settings)
|
||||
textSize = 16f
|
||||
typeface = Typeface.DEFAULT_BOLD
|
||||
setTextColor(col(R.color.text))
|
||||
})
|
||||
panel.addView(TextView(ctx).apply {
|
||||
text = getString(R.string.type_settings_hint)
|
||||
textSize = 12f
|
||||
setTextColor(col(R.color.text_tertiary))
|
||||
setPadding(0, dpi(6f), 0, 0)
|
||||
})
|
||||
val et = android.widget.EditText(ctx).apply {
|
||||
inputType = android.text.InputType.TYPE_CLASS_TEXT
|
||||
setText(Prefs.projectTypes.joinToString(","))
|
||||
textSize = 15f
|
||||
setTextColor(col(R.color.text))
|
||||
setSingleLine(true)
|
||||
background = ctx.roundBg(ctx.col(R.color.surface_alt), 12f)
|
||||
setPadding(dpi(14f), dpi(12f), dpi(14f), dpi(12f))
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
).apply { topMargin = dpi(12f) }
|
||||
}
|
||||
panel.addView(et)
|
||||
et.requestFocus()
|
||||
et.setSelection(et.text.length)
|
||||
|
||||
val btnRow = LinearLayout(ctx).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
gravity = Gravity.END
|
||||
setPadding(0, dpi(12f), 0, 0)
|
||||
}
|
||||
fun btn(labelRes: Int, onClick: () -> Unit) = TextView(ctx).apply {
|
||||
text = getString(labelRes)
|
||||
textSize = 14f
|
||||
typeface = Typeface.DEFAULT_BOLD
|
||||
gravity = Gravity.CENTER
|
||||
setTextColor(col(R.color.brand))
|
||||
background = ctx.roundBg(ctx.col(R.color.surface_alt), 12f)
|
||||
setPadding(dpi(22f), dpi(10f), dpi(22f), dpi(10f))
|
||||
setOnClickListener { onClick() }
|
||||
}
|
||||
btnRow.addView(btn(R.string.cancel) { dialog.dismiss() })
|
||||
btnRow.addView(btn(R.string.save) {
|
||||
val parsed = et.text.toString()
|
||||
.split(',')
|
||||
.map { it.trim() }
|
||||
.filter { it.isNotEmpty() }
|
||||
.distinct()
|
||||
if (parsed.isEmpty()) {
|
||||
// 全空等于把"类型"变成死字段,直接拦住
|
||||
et.error = getString(R.string.type_settings_empty)
|
||||
} else {
|
||||
Prefs.projectTypes = parsed
|
||||
dialog.dismiss()
|
||||
build()
|
||||
}
|
||||
}, LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
).apply { marginStart = dpi(10f) })
|
||||
panel.addView(btnRow)
|
||||
|
||||
dialog.setContentView(panel)
|
||||
dialog.show()
|
||||
et.postDelayed({
|
||||
val imm = ctx.getSystemService(android.content.Context.INPUT_METHOD_SERVICE)
|
||||
as? android.view.inputmethod.InputMethodManager
|
||||
imm?.showSoftInput(et, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT)
|
||||
}, 100L)
|
||||
}
|
||||
|
||||
/** 悬浮窗权限:标准 Android 特殊权限,有公开检测 API 和授权页,一键直达本应用 */
|
||||
private fun openOverlayPerm() {
|
||||
val ctx = requireContext()
|
||||
@@ -612,6 +716,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "3.16"
|
||||
const val VERSION = "3.17"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user