项目排序模式序号与置顶;横屏锁屏遮状态栏、排版对称化;版本 1.2
This commit is contained in:
@@ -28,6 +28,8 @@ class ProjectSheet(
|
||||
|
||||
private val root = LayoutInflater.from(context).inflate(R.layout.sheet_project, null)
|
||||
private val etName: EditText = root.findViewById(R.id.etName)
|
||||
private val etSortIndex: EditText = root.findViewById(R.id.etSortIndex)
|
||||
private val swPinned: androidx.appcompat.widget.SwitchCompat = root.findViewById(R.id.swPinned)
|
||||
private val colorRow: LinearLayout = root.findViewById(R.id.colorRow)
|
||||
|
||||
private var color: Int = existing?.color ?: Palette.colorAt(0)
|
||||
@@ -38,6 +40,11 @@ class ProjectSheet(
|
||||
if (existing == null) R.string.add_project else R.string.edit
|
||||
)
|
||||
etName.setText(existing?.name ?: "")
|
||||
// 编辑已有序号才回填;未设置过序号显示空,保存时按 0 处理(同级按创建先后排)
|
||||
if (existing != null && existing.sortIndex > 0) {
|
||||
etSortIndex.setText(existing.sortIndex.toString())
|
||||
}
|
||||
swPinned.isChecked = (existing?.pinnedAt ?: 0L) > 0L
|
||||
renderColors()
|
||||
|
||||
val btnDelete = root.findViewById<TextView>(R.id.btnDelete)
|
||||
@@ -62,10 +69,20 @@ class ProjectSheet(
|
||||
etName.error = context.getString(R.string.project_name_hint)
|
||||
return@setOnClickListener
|
||||
}
|
||||
val sortIndex = etSortIndex.text.toString().trim().toIntOrNull() ?: 0
|
||||
val pinned = swPinned.isChecked
|
||||
if (existing == null) {
|
||||
Store.addProject(name, color)
|
||||
// 新建置顶:置顶时间取当下,排进置顶组
|
||||
Store.addProject(name, color, sortIndex, pinned)
|
||||
} else {
|
||||
Store.updateProject(existing.id, name, color, existing.archived)
|
||||
// 已置顶且保持置顶 → 保留原置顶时间(重复保存不刷新排序);
|
||||
// 新勾置顶 → 以保存这一刻为置顶时间;取消置顶 → Store 里归 0
|
||||
val pinnedAt = when {
|
||||
!pinned -> 0L
|
||||
existing.pinnedAt > 0L -> existing.pinnedAt
|
||||
else -> System.currentTimeMillis()
|
||||
}
|
||||
Store.updateProject(existing.id, name, color, existing.archived, sortIndex, pinned, pinnedAt)
|
||||
}
|
||||
onSaved()
|
||||
dismiss()
|
||||
|
||||
@@ -128,7 +128,11 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
||||
when {
|
||||
which == 0 -> ProjectSheet(requireContext(), p) { reload() }.show()
|
||||
which == 1 && !isInbox -> {
|
||||
Store.updateProject(p.id, p.name, p.color, !p.archived)
|
||||
// 归档/取消归档只切 archived,序号与置顶状态原样保留
|
||||
Store.updateProject(
|
||||
p.id, p.name, p.color, !p.archived,
|
||||
p.sortIndex, p.pinnedAt > 0, p.pinnedAt,
|
||||
)
|
||||
reload()
|
||||
}
|
||||
which == 2 && !isInbox -> confirmDelete(p)
|
||||
|
||||
Reference in New Issue
Block a user