通知按钮留边距;选任务第一步标题贴左;项目操作弹层圆角;环图加粗;改名时间简史与 Things 蓝图标

This commit is contained in:
XIGE
2026-11-28 08:29:47 +08:00
parent a7f3ec3425
commit c5d9e3eb65
12 changed files with 150 additions and 43 deletions

View File

@@ -415,6 +415,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
val root = layoutInflater.inflate(R.layout.sheet_pick_task, null)
val tvTitle = root.findViewById<TextView>(R.id.pickTitle)
val tvStep = root.findViewById<TextView>(R.id.pickStep)
val titleBox = root.findViewById<LinearLayout>(R.id.pickTitleBox)
val tvHint = root.findViewById<TextView>(R.id.pickHint)
tvHint.visibility = View.GONE // 两步都只留标题与列表,不再占一行说明文字
val btnBack = root.findViewById<ImageView>(R.id.pickBack)
@@ -456,6 +457,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
val project = Store.project(projectId)
tvTitle.text = project?.name ?: getString(R.string.inbox)
tvStep.text = getString(R.string.pick_step, 2)
(titleBox.layoutParams as LinearLayout.LayoutParams).marginStart = dpi(10f)
btnBack.visibility = View.VISIBLE
btnClear.visibility = View.VISIBLE
list.removeAllViews()
@@ -493,7 +495,9 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
fun showProjects() {
tvTitle.text = getString(R.string.pick_project)
tvStep.text = getString(R.string.pick_step, 1)
btnBack.visibility = View.INVISIBLE
// 第一步没有返回键,连占位一起收掉,标题与步骤贴左边缘
(titleBox.layoutParams as LinearLayout.LayoutParams).marginStart = 0
btnBack.visibility = View.GONE
btnClear.visibility = View.GONE
list.removeAllViews()
val currentPid = if (TimerCore.taskId > 0) TimerCore.projectId else -1L

View File

@@ -2,8 +2,8 @@ package com.focusbox.app.ui.projects
import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@@ -11,6 +11,8 @@ import com.focusbox.app.R
import com.focusbox.app.data.Store
import com.focusbox.app.model.Project
import com.focusbox.app.ui.MainActivity
import com.focusbox.app.ui.SheetDialog
import com.focusbox.app.util.col
import com.focusbox.app.util.visible
class ProjectsFragment : Fragment(R.layout.fragment_projects) {
@@ -81,38 +83,69 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
}
}
/** 与新增/编辑项目同款圆角底部弹层,替代系统 AlertDialog */
private fun actionSheet(
title: String,
message: String? = null,
actions: List<Pair<String, Boolean>>,
onPick: (Int) -> Unit,
) {
val ctx = requireContext()
val sheet = SheetDialog(ctx)
val root = layoutInflater.inflate(R.layout.sheet_project_actions, null)
root.findViewById<TextView>(R.id.actionsTitle).text = title
if (message != null) {
root.findViewById<TextView>(R.id.actionsMessage).apply {
text = message
visibility = View.VISIBLE
}
}
val list = root.findViewById<LinearLayout>(R.id.actionsList)
actions.forEachIndexed { index, (label, destructive) ->
val row = layoutInflater.inflate(R.layout.item_action_row, list, false)
val tv = row.findViewById<TextView>(R.id.actionLabel)
tv.text = label
if (destructive) tv.setTextColor(col(R.color.danger))
row.setOnClickListener {
sheet.dismiss()
onPick(index)
}
list.addView(row)
}
sheet.setContentView(root)
sheet.show()
}
private fun showActions(p: Project) {
val isInbox = p.id == Store.INBOX_ID
val actions = ArrayList<String>()
actions.add(getString(R.string.edit))
val actions = ArrayList<Pair<String, Boolean>>()
actions.add(getString(R.string.edit) to false)
if (!isInbox) {
actions.add(getString(if (p.archived) R.string.unarchive else R.string.archive))
actions.add(getString(R.string.delete))
actions.add(getString(if (p.archived) R.string.unarchive else R.string.archive) to false)
actions.add(getString(R.string.delete) to true)
}
AlertDialog.Builder(requireContext())
.setTitle(p.name)
.setItems(actions.toTypedArray()) { _, which ->
when {
which == 0 -> ProjectSheet(requireContext(), p) { reload() }.show()
which == 1 && !isInbox -> {
Store.updateProject(p.id, p.name, p.color, !p.archived)
reload()
}
which == 2 && !isInbox -> confirmDelete(p)
actionSheet(p.name, actions = actions) { which ->
when {
which == 0 -> ProjectSheet(requireContext(), p) { reload() }.show()
which == 1 && !isInbox -> {
Store.updateProject(p.id, p.name, p.color, !p.archived)
reload()
}
which == 2 && !isInbox -> confirmDelete(p)
}
.show()
}
}
private fun confirmDelete(p: Project) {
AlertDialog.Builder(requireContext())
.setMessage(getString(R.string.delete_project_confirm, p.name))
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.delete) { _, _ ->
actionSheet(
title = getString(R.string.delete),
message = getString(R.string.delete_project_confirm, p.name),
actions = listOf(getString(R.string.cancel) to false, getString(R.string.delete) to true),
) { which ->
if (which == 1) {
Store.deleteProject(p.id)
reload()
}
.show()
}
}
}