Move request codes to FilterProvider

pull/2945/head
Alex Baker 4 months ago
parent 939f801382
commit a538c25dcc

@ -69,6 +69,9 @@ import org.tasks.extensions.Context.openUri
import org.tasks.extensions.hideKeyboard import org.tasks.extensions.hideKeyboard
import org.tasks.filters.Filter import org.tasks.filters.Filter
import org.tasks.filters.FilterProvider import org.tasks.filters.FilterProvider
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_LIST
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_PLACE
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_TAGS
import org.tasks.filters.NavigationDrawerSubheader import org.tasks.filters.NavigationDrawerSubheader
import org.tasks.filters.PlaceFilter import org.tasks.filters.PlaceFilter
import org.tasks.location.LocationPickerActivity import org.tasks.location.LocationPickerActivity
@ -502,9 +505,6 @@ class MainActivity : AppCompatActivity() {
private const val FRAG_TAG_TASK_EDIT = "frag_tag_task_edit" private const val FRAG_TAG_TASK_EDIT = "frag_tag_task_edit"
private const val FLAG_FROM_HISTORY private const val FLAG_FROM_HISTORY
= Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
const val REQUEST_NEW_LIST = 10100
const val REQUEST_NEW_TAGS = 10101
const val REQUEST_NEW_PLACE = 10104
val Intent.getFilter: Filter? val Intent.getFilter: Filter?
get() = if (isFromHistory) { get() = if (isFromHistory) {

@ -4,9 +4,6 @@ import android.app.Activity
import android.content.Intent import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.todoroo.astrid.activity.MainActivity.Companion.REQUEST_NEW_LIST
import com.todoroo.astrid.activity.MainActivity.Companion.REQUEST_NEW_PLACE
import com.todoroo.astrid.activity.MainActivity.Companion.REQUEST_NEW_TAGS
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.tasks.LocalBroadcastManager import org.tasks.LocalBroadcastManager
import org.tasks.activities.GoogleTaskListSettingsActivity import org.tasks.activities.GoogleTaskListSettingsActivity
@ -16,6 +13,9 @@ import org.tasks.data.dao.CaldavDao
import org.tasks.data.listSettingsClass import org.tasks.data.listSettingsClass
import org.tasks.dialogs.NewFilterDialog import org.tasks.dialogs.NewFilterDialog
import org.tasks.filters.FilterProvider import org.tasks.filters.FilterProvider
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_LIST
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_PLACE
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_TAGS
import org.tasks.filters.NavigationDrawerSubheader import org.tasks.filters.NavigationDrawerSubheader
import org.tasks.filters.NavigationDrawerSubheader.SubheaderType.CALDAV import org.tasks.filters.NavigationDrawerSubheader.SubheaderType.CALDAV
import org.tasks.filters.NavigationDrawerSubheader.SubheaderType.ETESYNC import org.tasks.filters.NavigationDrawerSubheader.SubheaderType.ETESYNC

@ -4,7 +4,6 @@ import android.app.Dialog
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.todoroo.astrid.activity.MainActivity
import com.todoroo.astrid.api.CustomFilterCriterion import com.todoroo.astrid.api.CustomFilterCriterion
import com.todoroo.astrid.core.CriterionInstance import com.todoroo.astrid.core.CriterionInstance
import com.todoroo.astrid.core.CriterionInstance.Companion.TYPE_INTERSECT import com.todoroo.astrid.core.CriterionInstance.Companion.TYPE_INTERSECT
@ -15,6 +14,7 @@ import dagger.hilt.android.AndroidEntryPoint
import org.tasks.R import org.tasks.R
import org.tasks.activities.FilterSettingsActivity import org.tasks.activities.FilterSettingsActivity
import org.tasks.filters.FilterCriteriaProvider import org.tasks.filters.FilterCriteriaProvider
import org.tasks.filters.FilterProvider.Companion.REQUEST_NEW_LIST
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
@ -123,7 +123,7 @@ class NewFilterDialog : DialogFragment() {
intent.putExtra(FilterSettingsActivity.EXTRA_TITLE, title) intent.putExtra(FilterSettingsActivity.EXTRA_TITLE, title)
intent.putExtra(FilterSettingsActivity.EXTRA_CRITERIA, serialize(list)) intent.putExtra(FilterSettingsActivity.EXTRA_CRITERIA, serialize(list))
} }
activity?.startActivityForResult(intent, MainActivity.REQUEST_NEW_LIST) activity?.startActivityForResult(intent, REQUEST_NEW_LIST)
dismiss() dismiss()
} }

@ -1,7 +1,6 @@
package org.tasks.filters package org.tasks.filters
import android.content.Context import android.content.Context
import com.todoroo.astrid.activity.MainActivity
import com.todoroo.astrid.api.CustomFilter import com.todoroo.astrid.api.CustomFilter
import com.todoroo.astrid.core.BuiltInFilterExposer import com.todoroo.astrid.core.BuiltInFilterExposer
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
@ -128,7 +127,7 @@ class FilterProvider @Inject constructor(
collapsed, collapsed,
SubheaderType.PREFERENCE, SubheaderType.PREFERENCE,
R.string.p_collapse_tags.toLong(), R.string.p_collapse_tags.toLong(),
if (showCreate) MainActivity.REQUEST_NEW_TAGS else 0, if (showCreate) REQUEST_NEW_TAGS else 0,
) )
) )
.apply { if (collapsed) return this } .apply { if (collapsed) return this }
@ -156,7 +155,7 @@ class FilterProvider @Inject constructor(
collapsed, collapsed,
SubheaderType.PREFERENCE, SubheaderType.PREFERENCE,
R.string.p_collapse_locations.toLong(), R.string.p_collapse_locations.toLong(),
if (showCreate) MainActivity.REQUEST_NEW_PLACE else 0, if (showCreate) REQUEST_NEW_PLACE else 0,
) )
) )
.apply { if (collapsed) return this } .apply { if (collapsed) return this }
@ -200,7 +199,7 @@ class FilterProvider @Inject constructor(
collapsed, collapsed,
SubheaderType.GOOGLE_TASKS, SubheaderType.GOOGLE_TASKS,
account.id, account.id,
if (showCreate) MainActivity.REQUEST_NEW_LIST else 0, if (showCreate) REQUEST_NEW_LIST else 0,
) )
) )
.apply { if (collapsed) return this } .apply { if (collapsed) return this }
@ -252,7 +251,7 @@ class FilterProvider @Inject constructor(
else -> SubheaderType.CALDAV else -> SubheaderType.CALDAV
}, },
account.id, account.id,
if (showCreate) MainActivity.REQUEST_NEW_LIST else 0, if (showCreate) REQUEST_NEW_LIST else 0,
) )
) )
.apply { if (collapsed) return this } .apply { if (collapsed) return this }
@ -269,6 +268,9 @@ class FilterProvider @Inject constructor(
} }
companion object { companion object {
const val REQUEST_NEW_LIST = 10100
const val REQUEST_NEW_TAGS = 10101
const val REQUEST_NEW_PLACE = 10104
const val REQUEST_NEW_FILTER = 101015 const val REQUEST_NEW_FILTER = 101015
private val COMPARATOR = Comparator<Filter> { f1, f2 -> private val COMPARATOR = Comparator<Filter> { f1, f2 ->
when { when {

Loading…
Cancel
Save