按审查报告修复 M1-M4 与 L1-L8;版本 0.7(versionCode 23)
This commit is contained in:
@@ -10,6 +10,8 @@ import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.focusbox.app.R
|
||||
@@ -74,6 +76,13 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
buildNav()
|
||||
|
||||
// 返回键:非首页时回到首页,首页时退出(onBackPressed 已废弃,走 Dispatcher)
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (current != TAB_FOCUS) showTab(TAB_FOCUS) else finish()
|
||||
}
|
||||
})
|
||||
|
||||
val restored = savedInstanceState?.getInt(KEY_TAB, -1) ?: -1
|
||||
val fromIntent = intent?.getIntExtra(EXTRA_TAB, -1) ?: -1
|
||||
val start = when {
|
||||
@@ -227,30 +236,24 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
/** 任务行的播放键:把该任务设为当前任务并回到首页,圆环套用任务时长并直接开始 */
|
||||
fun startFocusOn(task: Task) {
|
||||
if (TimerCore.running) {
|
||||
// 计时中换任务会把本轮记录归到新任务头上(起点还是旧轮的),必须禁止
|
||||
Toast.makeText(this, R.string.timer_busy, Toast.LENGTH_SHORT).show()
|
||||
showTab(TAB_FOCUS)
|
||||
return
|
||||
}
|
||||
TimerCore.setCountUp(false)
|
||||
TimerCore.setTask(task.id, task.projectId, task.focusMinutes)
|
||||
if (!TimerCore.running && TimerCore.mode != TimerCore.MODE_FOCUS) {
|
||||
if (TimerCore.mode != TimerCore.MODE_FOCUS) {
|
||||
TimerCore.setMode(TimerCore.MODE_FOCUS)
|
||||
}
|
||||
// 空闲时自动开跑,不用回到专注页再点一次「开始专注」;
|
||||
// 已在计时(本轮进行中)则只换任务与时长,不打断当前进度
|
||||
if (!TimerCore.running && TimerCore.elapsedNow() <= 0) {
|
||||
// 空闲时自动开跑,不用回到专注页再点一次「开始专注」
|
||||
if (TimerCore.elapsedNow() <= 0) {
|
||||
TimerCore.start()
|
||||
}
|
||||
showTab(TAB_FOCUS)
|
||||
}
|
||||
|
||||
fun goFocus() = showTab(TAB_FOCUS)
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (current != TAB_FOCUS) {
|
||||
showTab(TAB_FOCUS)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
/** 设置改动后(清空数据、改主题)统一刷新其余页面 */
|
||||
fun refreshAll() {
|
||||
for (f in fragments) {
|
||||
|
||||
Reference in New Issue
Block a user