项目排序模式序号与置顶;横屏锁屏遮状态栏、排版对称化;版本 1.2
This commit is contained in:
@@ -51,7 +51,6 @@ class LockScreenActivity : AppCompatActivity() {
|
||||
private lateinit var tvDate: TextView
|
||||
private lateinit var tvClock: TextView
|
||||
private lateinit var tvCountdown: TextView
|
||||
private lateinit var tvMode: TextView
|
||||
private lateinit var tvTask: TextView
|
||||
|
||||
private val clockFmt = SimpleDateFormat("HH:mm", Locale.getDefault())
|
||||
@@ -86,11 +85,12 @@ class LockScreenActivity : AppCompatActivity() {
|
||||
tvDate = findViewById(R.id.tvLockDate)
|
||||
tvClock = findViewById(R.id.tvLockClock)
|
||||
tvCountdown = findViewById(R.id.tvLockCountdown)
|
||||
tvMode = findViewById(R.id.tvLockMode)
|
||||
tvTask = findViewById(R.id.tvLockTask)
|
||||
|
||||
findViewById<View>(R.id.lockRoot).setOnClickListener { finish() }
|
||||
|
||||
applyImmersive()
|
||||
|
||||
ContextCompat.registerReceiver(
|
||||
this,
|
||||
unlockReceiver,
|
||||
@@ -156,7 +156,8 @@ class LockScreenActivity : AppCompatActivity() {
|
||||
tvClock.text = clockFmt.format(cal.time)
|
||||
tvCountdown.text = Dates.clock(now)
|
||||
|
||||
tvMode.text = getString(
|
||||
// 工作中/休息中提示只有竖屏布局有(横屏排版里删掉了),横屏下 findViewById 返回 null
|
||||
findViewById<TextView>(R.id.tvLockMode)?.text = getString(
|
||||
if (TimerCore.mode == TimerCore.MODE_FOCUS) R.string.lock_mode_focus else R.string.lock_mode_break
|
||||
)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -431,6 +431,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "1.1"
|
||||
const val VERSION = "1.2"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user