diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 69598c1..104ca1f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -30,6 +30,11 @@
android:exported="false"
android:label="@string/settings_label"
android:launchMode="singleTask" />
+
window.setFlags(
+ WindowManager.LayoutParams.FLAG_SECURE,
+ WindowManager.LayoutParams.FLAG_SECURE
+ )
+
+ false -> window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
+ }
+
+ binding = ActivityAllTasksBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+ val viewModel = ViewModelProvider(this)[AllTasksViewModel::class.java]
+
+ val layoutManager = LinearLayoutManager(ToDoApplication.context)
+ binding.allTasksList.layoutManager = layoutManager
+ val adapter = AllTasksAdapter(viewModel.todoListAll)
+ binding.allTasksList.adapter = adapter
+
+ FastScrollerBuilder(binding.allTasksList).apply {
+ useMd2Style()
+ build()
+ }
+
+ binding.toolbar.setNavigationOnClickListener {
+ finish()
+ }
+
+ viewModel.emptyTipVis.observe(this, Observer { visibility ->
+ if (visibility == View.VISIBLE) {
+ binding.allTasksList.alpha = 1f
+ binding.allTasksList.animate().alpha(0f).duration = 200
+ binding.allTasksList.visibility = View.GONE
+
+ binding.emptyTip.alpha = 0f
+ binding.emptyTip.visibility = View.VISIBLE
+ binding.emptyTip.animate().alpha(1f).duration = 200
+ } else {
+ binding.allTasksList.alpha = 0f
+ binding.allTasksList.visibility = View.VISIBLE
+ binding.allTasksList.animate().alpha(1f).duration = 200
+
+ binding.emptyTip.alpha = 1f
+ binding.emptyTip.animate().alpha(0f).duration = 200
+ binding.emptyTip.visibility = View.GONE
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/kotlin/cn/super12138/todo/views/all/AllTasksAdapter.kt b/app/src/main/kotlin/cn/super12138/todo/views/all/AllTasksAdapter.kt
new file mode 100644
index 0000000..bc4f28f
--- /dev/null
+++ b/app/src/main/kotlin/cn/super12138/todo/views/all/AllTasksAdapter.kt
@@ -0,0 +1,38 @@
+package cn.super12138.todo.views.all
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import cn.super12138.todo.R
+import cn.super12138.todo.logic.model.ToDo
+
+class AllTasksAdapter(private val todoList: MutableList) :
+ RecyclerView.Adapter() {
+
+ inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ val todoContext: TextView = view.findViewById(R.id.todo_content_all)
+ val todoSubject: TextView = view.findViewById(R.id.todo_subject_all)
+ }
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.item_all_tasks, parent, false)
+ return ViewHolder(view)
+ }
+
+ override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+ val todo = todoList[position]
+ holder.todoContext.text = todo.content
+ holder.todoSubject.text = todo.subject
+ if (!todo.isAnimated) {
+ holder.itemView.alpha = 0f
+ holder.itemView.animate().alpha(1f).duration = 200
+ todo.isAnimated = true
+ }
+ }
+
+ override fun getItemCount() = todoList.size
+}
\ No newline at end of file
diff --git a/app/src/main/kotlin/cn/super12138/todo/views/all/AllTasksViewModel.kt b/app/src/main/kotlin/cn/super12138/todo/views/all/AllTasksViewModel.kt
new file mode 100644
index 0000000..d833540
--- /dev/null
+++ b/app/src/main/kotlin/cn/super12138/todo/views/all/AllTasksViewModel.kt
@@ -0,0 +1,34 @@
+package cn.super12138.todo.views.all
+
+import android.view.View
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import cn.super12138.todo.logic.Repository
+import cn.super12138.todo.logic.model.ToDo
+import kotlinx.coroutines.launch
+
+class AllTasksViewModel : ViewModel() {
+ val emptyTipVis = MutableLiveData(View.VISIBLE)
+ val todoListAll = ArrayList()
+
+ init {
+ loadToDos()
+ }
+
+ private fun loadToDos() {
+ viewModelScope.launch {
+ val todos = Repository.getAll()
+ var count = 0
+ for (todo in todos) {
+ todoListAll.add(ToDo(todo.uuid, todo.content, todo.subject))
+ count++
+ }
+ if (count == 0) {
+ emptyTipVis.value = View.VISIBLE
+ } else {
+ emptyTipVis.value = View.GONE
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/kotlin/cn/super12138/todo/views/settings/SettingsActivity.kt b/app/src/main/kotlin/cn/super12138/todo/views/settings/SettingsActivity.kt
index ff61a8d..0435292 100644
--- a/app/src/main/kotlin/cn/super12138/todo/views/settings/SettingsActivity.kt
+++ b/app/src/main/kotlin/cn/super12138/todo/views/settings/SettingsActivity.kt
@@ -1,8 +1,8 @@
package cn.super12138.todo.views.settings
+import android.content.Intent
import android.os.Bundle
import android.os.Process
-import android.view.WindowManager
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDelegate
import androidx.lifecycle.lifecycleScope
@@ -18,6 +18,7 @@ import cn.super12138.todo.databinding.DialogRestoreBinding
import cn.super12138.todo.logic.Repository
import cn.super12138.todo.logic.dao.ToDoRoom
import cn.super12138.todo.views.BaseActivity
+import cn.super12138.todo.views.main.MainActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.google.gson.Gson
@@ -72,20 +73,15 @@ class SettingsActivity : BaseActivity() {
}
findPreference("secure_mode")?.apply {
- setOnPreferenceChangeListener { _, newValue ->
- when (newValue) {
- true -> activity?.window?.setFlags(
- WindowManager.LayoutParams.FLAG_SECURE,
- WindowManager.LayoutParams.FLAG_SECURE
- )
-
- false -> activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
- }
+ setOnPreferenceChangeListener { _, _ ->
view?.let {
Snackbar.make(it, R.string.need_restart_app, Snackbar.LENGTH_LONG)
.setAction(R.string.restart_app_now) {
- Process.killProcess(Process.myPid())
- exitProcess(10)
+ val intent = Intent(context, MainActivity::class.java).apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+ }
+ context.startActivity(intent)
+ exitProcess(0)
}
.show()
}
diff --git a/app/src/main/kotlin/cn/super12138/todo/views/todo/ToDoFragment.kt b/app/src/main/kotlin/cn/super12138/todo/views/todo/ToDoFragment.kt
index fb21ec2..6f1c8ee 100644
--- a/app/src/main/kotlin/cn/super12138/todo/views/todo/ToDoFragment.kt
+++ b/app/src/main/kotlin/cn/super12138/todo/views/todo/ToDoFragment.kt
@@ -53,9 +53,9 @@ class ToDoFragment : Fragment() {
}*/
val progressViewModel =
- ViewModelProvider(requireActivity()).get(ProgressFragmentViewModel::class.java)
+ ViewModelProvider(requireActivity())[ProgressFragmentViewModel::class.java]
val todoViewModel =
- ViewModelProvider(requireActivity()).get(ToDoFragmentViewModel::class.java)
+ ViewModelProvider(requireActivity())[ToDoFragmentViewModel::class.java]
val todoList = todoViewModel.todoList
@@ -89,7 +89,7 @@ class ToDoFragment : Fragment() {
ToDoDialogBinding.todoContent.error =
getString(R.string.content_cannot_be_empty)
} else {
- if (todoContent == "/DEV MODE") {
+ if (todoContent == "/DEV_MODE") {
if (Repository.getPreferenceBoolean(
ToDoApplication.context,
"dev_mode",
diff --git a/app/src/main/res/drawable/ic_all_todos.xml b/app/src/main/res/drawable/ic_all_todos.xml
new file mode 100644
index 0000000..8c3bd45
--- /dev/null
+++ b/app/src/main/res/drawable/ic_all_todos.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml
index 37f4dc3..812e6e9 100644
--- a/app/src/main/res/layout-land/activity_main.xml
+++ b/app/src/main/res/layout-land/activity_main.xml
@@ -11,7 +11,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
- app:liftOnScrollTargetViewId="@id/progress_frag">
+ app:liftOnScroll="true">
+ android:fitsSystemWindows="true"
+ app:liftOnScroll="true">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_todo.xml b/app/src/main/res/layout/fragment_todo.xml
index e1c0038..ffd32d4 100644
--- a/app/src/main/res/layout/fragment_todo.xml
+++ b/app/src/main/res/layout/fragment_todo.xml
@@ -20,6 +20,7 @@
android:layout_marginTop="20dp"
android:gravity="center"
android:text="@string/no_tasks"
+ android:textSize="14sp"
android:visibility="visible" />
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index e39852a..720f05d 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -61,4 +61,7 @@
需要重启应用以应用恢复的数据
JSON 数据格式错误
恢复失败,请检查是否重复恢复同一次备份的数据
+ 查看全部待办
+ 全部代办
+ 查看包含已完成的待办在内的全部待办
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ee485a6..a5f97e5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -61,4 +61,7 @@
Need to restart the app to apply the recovered data
JSON data format is incorrect
Restore failed, please check if you are attempting to restore the same backup data again.
+ View all tasks
+ All tasks
+ View all tasks including those that have been checked as completed
\ No newline at end of file
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 54e1246..a01bb97 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -2,12 +2,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
@@ -21,7 +21,7 @@
app:dialogMessage="多个项目请使用英文逗号隔开"
app:summary="自定义创建待办时文本框的预测项" />-->
-
+
+
+
+