From 7e1a1b22d33426871e0a95dcb4b657ba50250cab Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 9 Jul 2020 09:52:58 -0500 Subject: [PATCH] Remove TaskEditActivity --- app/src/main/AndroidManifest.xml | 3 -- .../astrid/activity/TaskEditActivity.kt | 38 ------------------- .../java/org/tasks/activities/UriHandler.kt | 17 +++++++-- .../tasks/provider/TasksContentProvider.kt | 4 +- 4 files changed, 16 insertions(+), 46 deletions(-) delete mode 100644 app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1eeffb6fa..72418e1a0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -169,9 +169,6 @@ android:scheme="content" android:host="${applicationId}" /> - - - diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.kt b/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.kt deleted file mode 100644 index 79a7b5fbd..000000000 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.todoroo.astrid.activity - -import androidx.lifecycle.lifecycleScope -import com.todoroo.astrid.dao.TaskDao -import com.todoroo.astrid.service.TaskCreator -import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.launch -import org.tasks.injection.InjectingAppCompatActivity -import org.tasks.intents.TaskIntents -import javax.inject.Inject - -@AndroidEntryPoint -class TaskEditActivity : InjectingAppCompatActivity() { - @Inject lateinit var taskCreator: TaskCreator - @Inject lateinit var taskDao: TaskDao - - override fun onResume() { - super.onResume() - - val taskId = intent.getLongExtra(TOKEN_ID, 0) - if (taskId > 0) { - lifecycleScope.launch { - val task = taskDao.fetch(taskId) - task?.let { - startActivity(TaskIntents.getEditTaskIntent(this@TaskEditActivity, it)) - } - finish() - } - } else { - startActivity(TaskIntents.getEditTaskIntent(this, taskCreator.createWithValues(""))) - finish() - } - } - - companion object { - private const val TOKEN_ID = "id" - } -} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/activities/UriHandler.kt b/app/src/main/java/org/tasks/activities/UriHandler.kt index c0e558879..98f4dc0df 100644 --- a/app/src/main/java/org/tasks/activities/UriHandler.kt +++ b/app/src/main/java/org/tasks/activities/UriHandler.kt @@ -33,14 +33,23 @@ class UriHandler : AppCompatActivity() { finish() } } else { - startActivity(TaskIntents.getNewTaskIntent(this, null)) - finish() + newTask() } } else -> { - Timber.w("Invalid uri: ${intent.data}") - finish() + if (intent.type == "vnd.android.cursor.item/task") { + // pure calendar widget '+' + newTask() + } else { + Timber.w("Invalid uri: ${intent.data}") + finish() + } } } } + + private fun newTask() { + startActivity(TaskIntents.getNewTaskIntent(this, null)) + finish() + } } \ No newline at end of file diff --git a/app/src/main/java/org/tasks/provider/TasksContentProvider.kt b/app/src/main/java/org/tasks/provider/TasksContentProvider.kt index 757178656..b7c987596 100644 --- a/app/src/main/java/org/tasks/provider/TasksContentProvider.kt +++ b/app/src/main/java/org/tasks/provider/TasksContentProvider.kt @@ -74,7 +74,8 @@ class TasksContentProvider : ContentProvider() { LEFT JOIN google_task_lists ON gtl_remote_id = gt_list_id LEFT JOIN caldav_tasks ON cd_task = _id LEFT JOIN caldav_lists ON cdl_uuid = cd_calendar""" - private const val AUTHORITY = BuildConfig.APPLICATION_ID; + private const val AUTHORITY = BuildConfig.APPLICATION_ID + private const val PURE_CALENDAR_WIDGET = "org.tasks.tasksprovider" @JvmField val CONTENT_URI: Uri = Uri.parse("content://$AUTHORITY") const val URI_TASKS = 1 const val URI_OPEN_TASK = 2 @@ -87,6 +88,7 @@ class TasksContentProvider : ContentProvider() { addURI(AUTHORITY, "lists", URI_LISTS) addURI(AUTHORITY, "google_lists", URI_GOOGLE_TASK_LISTS) addURI(AUTHORITY, "todoagenda", URI_TODO_AGENDA) + addURI(PURE_CALENDAR_WIDGET, "tasks/*", URI_OPEN_TASK) } } } \ No newline at end of file