通知按钮留边距;选任务第一步标题贴左;项目操作弹层圆角;环图加粗;改名时间简史与 Things 蓝图标
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
/** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */
|
||||
var maxLabels: Int = 6
|
||||
|
||||
private val strokeW = context.dpf(22f)
|
||||
private val strokeW = context.dpf(28f)
|
||||
|
||||
private val arcPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
style = Paint.Style.STROKE
|
||||
@@ -113,7 +113,7 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
val cy = height / 2f
|
||||
|
||||
// 环的直径同时受宽高约束:宽度让出两侧标注区,高度不足时优先保证标注能排开
|
||||
val outer = minOf(width * 0.48f, height * 0.62f)
|
||||
val outer = minOf(width * 0.48f, height * 0.66f)
|
||||
val r = (outer / 2f - strokeW / 2f).coerceAtLeast(context.dpf(24f))
|
||||
|
||||
canvas.drawCircle(cx, cy, r, trackPaint)
|
||||
@@ -138,14 +138,14 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
|
||||
val arcLen = sweep / 360f * (2 * Math.PI.toFloat() * r)
|
||||
val pct = "${(s.seconds * 100f / total).toInt().coerceAtLeast(1)}%"
|
||||
// 环加粗后百分比必须完整落在色带里:按实测字宽缩字号,左右各留 3dp 边距
|
||||
// 环加粗后百分比必须完整落在色带里:按实测字宽缩字号,两侧各留 5dp 边距
|
||||
var pctSize = 11f
|
||||
pctPaint.textSize = context.spf(pctSize)
|
||||
while (pctPaint.measureText(pct) > arcLen - context.dpf(6f) && pctSize > 8f) {
|
||||
while (pctPaint.measureText(pct) > arcLen - context.dpf(10f) && pctSize > 8f) {
|
||||
pctSize -= 0.5f
|
||||
pctPaint.textSize = context.spf(pctSize)
|
||||
}
|
||||
if (arcLen >= pctPaint.measureText(pct) + context.dpf(4f)) {
|
||||
if (arcLen >= pctPaint.measureText(pct) + context.dpf(8f)) {
|
||||
val rad = Math.toRadians(midDeg.toDouble())
|
||||
val px = cx + r * cos(rad).toFloat()
|
||||
val py = cy + r * sin(rad).toFloat()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:startColor="#C75B45"
|
||||
android:endColor="#A6462F" />
|
||||
android:startColor="#5AA3FF"
|
||||
android:centerColor="#4F97FF"
|
||||
android:endColor="#3D7FE0" />
|
||||
</shape>
|
||||
|
||||
@@ -10,17 +10,18 @@
|
||||
android:strokeWidth="7"
|
||||
android:strokeLineCap="round"
|
||||
android:fillColor="#00000000" />
|
||||
<!-- 指针固定为 10:10:时针左上、分针右上,长短比例与角度都按真实钟面绘制 -->
|
||||
<path
|
||||
android:pathData="M54,54 L54,38"
|
||||
android:pathData="M54,54 L43,46"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="6"
|
||||
android:strokeWidth="6.5"
|
||||
android:strokeLineCap="round" />
|
||||
<path
|
||||
android:pathData="M54,54 L66,60"
|
||||
android:pathData="M54,54 L71,40"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="6"
|
||||
android:strokeWidth="5"
|
||||
android:strokeLineCap="round" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M54,50 m-3.5,0 a3.5,3.5 0 1,0 7,0 a3.5,3.5 0 1,0 -7,0" />
|
||||
android:pathData="M54,50.8 m-3.2,0 a3.2,3.2 0 1,0 6.4,0 a3.2,3.2 0 1,0 -6.4,0" />
|
||||
</vector>
|
||||
|
||||
12
src/main/res/layout/item_action_row.xml
Normal file
12
src/main/res/layout/item_action_row.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/actionLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/bg_pick_row"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="50dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
style="@style/T.Body" />
|
||||
@@ -15,7 +15,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
android:id="@+id/notifPause"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/bg_notif_action"
|
||||
android:scaleType="fitCenter"
|
||||
|
||||
@@ -39,10 +39,10 @@
|
||||
android:contentDescription="@string/pick_back" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/pickTitleBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
||||
48
src/main/res/layout/sheet_project_actions.xml
Normal file
48
src/main/res/layout/sheet_project_actions.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 项目操作弹层:与新增/编辑项目共用同一套圆角底部弹层外观 -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/bg_sheet">
|
||||
|
||||
<View
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="4dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@color/divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingTop="14dp"
|
||||
android:paddingBottom="22dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionsTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
style="@style/T.Title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionsMessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
style="@style/T.Meta" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/actionsList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:orientation="vertical" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -5,7 +5,7 @@
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#C75B45"
|
||||
android:fillColor="#4F97FF"
|
||||
android:pathData="M54,0 L108,0 L108,108 L0,108 L0,0 Z" />
|
||||
<path
|
||||
android:pathData="M54,26 A28,28 0 1 1 53.99,26"
|
||||
@@ -14,13 +14,16 @@
|
||||
android:strokeLineCap="round"
|
||||
android:fillColor="#00000000" />
|
||||
<path
|
||||
android:pathData="M54,54 L54,38"
|
||||
android:pathData="M54,54 L43,46"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="6"
|
||||
android:strokeWidth="6.5"
|
||||
android:strokeLineCap="round" />
|
||||
<path
|
||||
android:pathData="M54,54 L66,60"
|
||||
android:pathData="M54,54 L71,40"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="6"
|
||||
android:strokeWidth="5"
|
||||
android:strokeLineCap="round" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M54,50.8 m-3.2,0 a3.2,3.2 0 1,0 6.4,0 a3.2,3.2 0 1,0 -6.4,0" />
|
||||
</vector>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">专注盒子</string>
|
||||
<string name="app_name">时间简史</string>
|
||||
|
||||
<string name="nav_focus">首页</string>
|
||||
<string name="nav_tasks">任务</string>
|
||||
|
||||
Reference in New Issue
Block a user