|
|
@ -19,6 +19,7 @@ import androidx.drawerlayout.widget.DrawerLayout.SimpleDrawerListener
|
|
|
|
import androidx.fragment.app.FragmentManager
|
|
|
|
import androidx.fragment.app.FragmentManager
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import com.todoroo.andlib.utility.AndroidUtilities
|
|
|
|
import com.todoroo.andlib.utility.AndroidUtilities
|
|
|
|
|
|
|
|
import com.todoroo.astrid.activity.TaskEditFragment.Companion.newTaskEditFragment
|
|
|
|
import com.todoroo.astrid.activity.TaskEditFragment.TaskEditFragmentCallbackHandler
|
|
|
|
import com.todoroo.astrid.activity.TaskEditFragment.TaskEditFragmentCallbackHandler
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment.TaskListFragmentCallbackHandler
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment.TaskListFragmentCallbackHandler
|
|
|
|
import com.todoroo.astrid.api.Filter
|
|
|
|
import com.todoroo.astrid.api.Filter
|
|
|
@ -27,12 +28,15 @@ import com.todoroo.astrid.data.Task
|
|
|
|
import com.todoroo.astrid.service.TaskCreator
|
|
|
|
import com.todoroo.astrid.service.TaskCreator
|
|
|
|
import com.todoroo.astrid.timers.TimerControlSet.TimerControlSetCallback
|
|
|
|
import com.todoroo.astrid.timers.TimerControlSet.TimerControlSetCallback
|
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
|
|
|
|
import kotlinx.coroutines.async
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import org.tasks.LocalBroadcastManager
|
|
|
|
import org.tasks.LocalBroadcastManager
|
|
|
|
import org.tasks.R
|
|
|
|
import org.tasks.R
|
|
|
|
import org.tasks.activities.TagSettingsActivity
|
|
|
|
import org.tasks.activities.TagSettingsActivity
|
|
|
|
import org.tasks.billing.Inventory
|
|
|
|
import org.tasks.billing.Inventory
|
|
|
|
|
|
|
|
import org.tasks.data.LocationDao
|
|
|
|
import org.tasks.data.Place
|
|
|
|
import org.tasks.data.Place
|
|
|
|
|
|
|
|
import org.tasks.data.TagDataDao
|
|
|
|
import org.tasks.databinding.TaskListActivityBinding
|
|
|
|
import org.tasks.databinding.TaskListActivityBinding
|
|
|
|
import org.tasks.dialogs.SortDialog.SortDialogCallback
|
|
|
|
import org.tasks.dialogs.SortDialog.SortDialogCallback
|
|
|
|
import org.tasks.dialogs.WhatsNewDialog
|
|
|
|
import org.tasks.dialogs.WhatsNewDialog
|
|
|
@ -67,6 +71,9 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
@Inject lateinit var playServices: PlayServices
|
|
|
|
@Inject lateinit var playServices: PlayServices
|
|
|
|
@Inject lateinit var inventory: Inventory
|
|
|
|
@Inject lateinit var inventory: Inventory
|
|
|
|
@Inject lateinit var colorProvider: ColorProvider
|
|
|
|
@Inject lateinit var colorProvider: ColorProvider
|
|
|
|
|
|
|
|
@Inject lateinit var locationDao: LocationDao
|
|
|
|
|
|
|
|
@Inject lateinit var tagDataDao: TagDataDao
|
|
|
|
|
|
|
|
|
|
|
|
private lateinit var navigationDrawer: NavigationDrawerFragment
|
|
|
|
private lateinit var navigationDrawer: NavigationDrawerFragment
|
|
|
|
private var currentNightMode = 0
|
|
|
|
private var currentNightMode = 0
|
|
|
|
private var currentPro = false
|
|
|
|
private var currentPro = false
|
|
|
@ -230,7 +237,8 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
private fun openTaskListFragment(taskListFragment: TaskListFragment, force: Boolean) {
|
|
|
|
private fun openTaskListFragment(taskListFragment: TaskListFragment, force: Boolean) {
|
|
|
|
AndroidUtilities.assertMainThread()
|
|
|
|
AndroidUtilities.assertMainThread()
|
|
|
|
val newFilter = taskListFragment.getFilter()
|
|
|
|
val newFilter = taskListFragment.getFilter()
|
|
|
|
if (filter != null && !force
|
|
|
|
if (filter != null
|
|
|
|
|
|
|
|
&& !force
|
|
|
|
&& filter!!.areItemsTheSame(newFilter)
|
|
|
|
&& filter!!.areItemsTheSame(newFilter)
|
|
|
|
&& filter!!.areContentsTheSame(newFilter)) {
|
|
|
|
&& filter!!.areContentsTheSame(newFilter)) {
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -239,12 +247,11 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
navigationDrawer.setSelected(filter)
|
|
|
|
navigationDrawer.setSelected(filter)
|
|
|
|
defaultFilterProvider.lastViewedFilter = newFilter
|
|
|
|
defaultFilterProvider.lastViewedFilter = newFilter
|
|
|
|
applyTheme()
|
|
|
|
applyTheme()
|
|
|
|
val fragmentManager = supportFragmentManager
|
|
|
|
supportFragmentManager
|
|
|
|
fragmentManager
|
|
|
|
|
|
|
|
.beginTransaction()
|
|
|
|
.beginTransaction()
|
|
|
|
.replace(R.id.master, taskListFragment, FRAG_TAG_TASK_LIST)
|
|
|
|
.replace(R.id.master, taskListFragment, FRAG_TAG_TASK_LIST)
|
|
|
|
.commit()
|
|
|
|
.commitNow()
|
|
|
|
fragmentManager.executePendingTransactions()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun applyTheme() {
|
|
|
|
private fun applyTheme() {
|
|
|
@ -301,26 +308,19 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
val taskEditFragment = taskEditFragment
|
|
|
|
val taskEditFragment = taskEditFragment
|
|
|
|
taskEditFragment?.save()
|
|
|
|
taskEditFragment?.save()
|
|
|
|
clearUi()
|
|
|
|
clearUi()
|
|
|
|
if (task.isNew) {
|
|
|
|
|
|
|
|
openTask(task)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
|
|
lifecycleScope.launch {
|
|
|
|
openTask(taskDao.fetch(task.id))
|
|
|
|
val list = async { defaultFilterProvider.getList(task) }
|
|
|
|
}
|
|
|
|
val location = async { locationDao.getLocation(task, preferences) }
|
|
|
|
}
|
|
|
|
val tags = async { tagDataDao.getTags(task) }
|
|
|
|
}
|
|
|
|
val fragment = newTaskEditFragment(
|
|
|
|
|
|
|
|
task, filterColor, list.await(), location.await(), tags.await())
|
|
|
|
private fun openTask(task: Task?) {
|
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
|
supportFragmentManager
|
|
|
|
.replace(R.id.detail, fragment, TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
|
|
|
|
.beginTransaction()
|
|
|
|
|
|
|
|
.replace(
|
|
|
|
|
|
|
|
R.id.detail,
|
|
|
|
|
|
|
|
TaskEditFragment.newTaskEditFragment(task, filterColor),
|
|
|
|
|
|
|
|
TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
|
|
|
|
|
|
|
|
.addToBackStack(TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
|
|
|
|
.addToBackStack(TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
|
|
|
|
.commit()
|
|
|
|
.commit()
|
|
|
|
showDetailFragment()
|
|
|
|
showDetailFragment()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onNavigationIconClicked() {
|
|
|
|
override fun onNavigationIconClicked() {
|
|
|
|
hideKeyboard()
|
|
|
|
hideKeyboard()
|
|
|
|