|
|
@ -180,9 +180,12 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
val intent = intent
|
|
|
|
val intent = intent
|
|
|
|
val openFilter = intent.getFilter
|
|
|
|
val openFilter = intent.getFilter
|
|
|
|
val loadFilter = intent.getFilterString
|
|
|
|
val loadFilter = intent.getFilterString
|
|
|
|
|
|
|
|
val openTask = !intent.isFromHistory
|
|
|
|
|
|
|
|
&& (intent.hasExtra(OPEN_TASK) || intent.hasExtra(CREATE_TASK))
|
|
|
|
Timber.d("""
|
|
|
|
Timber.d("""
|
|
|
|
|
|
|
|
|
|
|
|
**********
|
|
|
|
**********
|
|
|
|
|
|
|
|
broughtToFront: ${intent.broughtToFront}
|
|
|
|
isFromHistory: ${intent.isFromHistory}
|
|
|
|
isFromHistory: ${intent.isFromHistory}
|
|
|
|
flags: ${intent.flagsToString}
|
|
|
|
flags: ${intent.flagsToString}
|
|
|
|
OPEN_FILTER: ${openFilter?.let { "${it.listingTitle}: $it" }}
|
|
|
|
OPEN_FILTER: ${openFilter?.let { "${it.listingTitle}: $it" }}
|
|
|
@ -192,7 +195,7 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
taskListFragment: ${taskListFragment?.getFilter()?.let { "${it.listingTitle}: $it" }}
|
|
|
|
taskListFragment: ${taskListFragment?.getFilter()?.let { "${it.listingTitle}: $it" }}
|
|
|
|
taskEditFragment: ${taskEditFragment?.editViewModel?.task}
|
|
|
|
taskEditFragment: ${taskEditFragment?.editViewModel?.task}
|
|
|
|
**********""")
|
|
|
|
**********""")
|
|
|
|
if (openFilter != null || loadFilter != null) {
|
|
|
|
if (!openTask && (openFilter != null || !loadFilter.isNullOrBlank())) {
|
|
|
|
taskEditFragment?.let {
|
|
|
|
taskEditFragment?.let {
|
|
|
|
lifecycleScope.launch {
|
|
|
|
lifecycleScope.launch {
|
|
|
|
it.save()
|
|
|
|
it.save()
|
|
|
@ -207,19 +210,49 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
defaultFilterProvider.getFilterFromPreference(loadFilter)
|
|
|
|
defaultFilterProvider.getFilterFromPreference(loadFilter)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clearUi()
|
|
|
|
clearUi()
|
|
|
|
openTaskListFragment(filter)
|
|
|
|
if (isSinglePaneLayout) {
|
|
|
|
openTask(filter)
|
|
|
|
if (openTask) {
|
|
|
|
|
|
|
|
setFilter(filter)
|
|
|
|
|
|
|
|
openTask(filter)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
openTaskListFragment(filter, true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
openTaskListFragment(filter, true)
|
|
|
|
|
|
|
|
openTask(filter)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (openFilter != null) {
|
|
|
|
} else if (openFilter != null) {
|
|
|
|
clearUi()
|
|
|
|
clearUi()
|
|
|
|
openTaskListFragment(openFilter)
|
|
|
|
if (isSinglePaneLayout) {
|
|
|
|
openTask(openFilter)
|
|
|
|
if (openTask) {
|
|
|
|
|
|
|
|
setFilter(openFilter)
|
|
|
|
|
|
|
|
openTask(openFilter)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
openTaskListFragment(openFilter, true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
openTaskListFragment(openFilter, true)
|
|
|
|
|
|
|
|
openTask(openFilter)
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
val existing = taskListFragment
|
|
|
|
val existing = taskListFragment
|
|
|
|
openTaskListFragment(
|
|
|
|
val target = if (existing == null || existing.getFilter() !== filter) {
|
|
|
|
if (existing == null || existing.getFilter() !== filter) TaskListFragment.newTaskListFragment(applicationContext, filter) else existing,
|
|
|
|
TaskListFragment.newTaskListFragment(applicationContext, filter)
|
|
|
|
false)
|
|
|
|
} else {
|
|
|
|
openTask(filter)
|
|
|
|
existing
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSinglePaneLayout) {
|
|
|
|
|
|
|
|
if (openTask) {
|
|
|
|
|
|
|
|
setFilter(null)
|
|
|
|
|
|
|
|
openTask(null)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
openTaskListFragment(filter, false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
openTaskListFragment(target, false)
|
|
|
|
|
|
|
|
openTask(filter)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (intent.hasExtra(TOKEN_CREATE_NEW_LIST_NAME)) {
|
|
|
|
if (intent.hasExtra(TOKEN_CREATE_NEW_LIST_NAME)) {
|
|
|
|
val listName = intent.getStringExtra(TOKEN_CREATE_NEW_LIST_NAME)
|
|
|
|
val listName = intent.getStringExtra(TOKEN_CREATE_NEW_LIST_NAME)
|
|
|
@ -238,16 +271,23 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun hideDetailFragment() {
|
|
|
|
private fun hideDetailFragment() {
|
|
|
|
supportFragmentManager
|
|
|
|
filter?.let {
|
|
|
|
.beginTransaction()
|
|
|
|
supportFragmentManager
|
|
|
|
.replace(R.id.detail, newEmptyTaskEditFragment(filter!!))
|
|
|
|
.beginTransaction()
|
|
|
|
.commit()
|
|
|
|
.replace(R.id.detail, newEmptyTaskEditFragment(it))
|
|
|
|
|
|
|
|
.commit()
|
|
|
|
|
|
|
|
}
|
|
|
|
if (isSinglePaneLayout) {
|
|
|
|
if (isSinglePaneLayout) {
|
|
|
|
binding.master.visibility = View.VISIBLE
|
|
|
|
binding.master.visibility = View.VISIBLE
|
|
|
|
binding.detail.visibility = View.GONE
|
|
|
|
binding.detail.visibility = View.GONE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setFilter(newFilter: Filter?) {
|
|
|
|
|
|
|
|
filter = newFilter
|
|
|
|
|
|
|
|
applyTheme()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun openTaskListFragment(filter: Filter?, force: Boolean = false) {
|
|
|
|
private fun openTaskListFragment(filter: Filter?, force: Boolean = false) {
|
|
|
|
openTaskListFragment(TaskListFragment.newTaskListFragment(applicationContext, filter), force)
|
|
|
|
openTaskListFragment(TaskListFragment.newTaskListFragment(applicationContext, filter), force)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -268,7 +308,7 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
supportFragmentManager
|
|
|
|
supportFragmentManager
|
|
|
|
.beginTransaction()
|
|
|
|
.beginTransaction()
|
|
|
|
.replace(R.id.master, taskListFragment, FRAG_TAG_TASK_LIST)
|
|
|
|
.replace(R.id.master, taskListFragment, FRAG_TAG_TASK_LIST)
|
|
|
|
.commitNow()
|
|
|
|
.commit()
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -318,7 +358,7 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
if (task == null) {
|
|
|
|
if (task == null) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lifecycleScope.launch {
|
|
|
|
lifecycleScope.launchWhenResumed {
|
|
|
|
taskEditFragment?.let {
|
|
|
|
taskEditFragment?.let {
|
|
|
|
it.editViewModel.cleared.removeObservers(this@MainActivity)
|
|
|
|
it.editViewModel.cleared.removeObservers(this@MainActivity)
|
|
|
|
it.save()
|
|
|
|
it.save()
|
|
|
@ -383,12 +423,24 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
get() = !resources.getBoolean(R.bool.two_pane_layout)
|
|
|
|
get() = !resources.getBoolean(R.bool.two_pane_layout)
|
|
|
|
|
|
|
|
|
|
|
|
fun removeTaskEditFragment() {
|
|
|
|
fun removeTaskEditFragment() {
|
|
|
|
supportFragmentManager
|
|
|
|
supportFragmentManager.popBackStack(
|
|
|
|
.popBackStackImmediate(
|
|
|
|
TaskEditFragment.TAG_TASKEDIT_FRAGMENT,
|
|
|
|
TaskEditFragment.TAG_TASKEDIT_FRAGMENT, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
|
|
|
FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
|
|
|
hideDetailFragment()
|
|
|
|
val removeTask = intent.removeTask
|
|
|
|
hideKeyboard()
|
|
|
|
val finishAffinity = intent.finishAffinity
|
|
|
|
taskListFragment?.loadTaskListContent()
|
|
|
|
if (finishAffinity || taskListFragment == null) {
|
|
|
|
|
|
|
|
finishAffinity()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (removeTask && intent.broughtToFront) {
|
|
|
|
|
|
|
|
moveTaskToBack(true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hideKeyboard()
|
|
|
|
|
|
|
|
hideDetailFragment()
|
|
|
|
|
|
|
|
taskListFragment?.let {
|
|
|
|
|
|
|
|
setFilter(it.getFilter())
|
|
|
|
|
|
|
|
it.loadTaskListContent()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun hideKeyboard() {
|
|
|
|
private fun hideKeyboard() {
|
|
|
@ -452,6 +504,8 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
const val LOAD_FILTER = "load_filter"
|
|
|
|
const val LOAD_FILTER = "load_filter"
|
|
|
|
const val CREATE_TASK = "open_task" // $NON-NLS-1$
|
|
|
|
const val CREATE_TASK = "open_task" // $NON-NLS-1$
|
|
|
|
const val OPEN_TASK = "open_new_task" // $NON-NLS-1$
|
|
|
|
const val OPEN_TASK = "open_new_task" // $NON-NLS-1$
|
|
|
|
|
|
|
|
const val REMOVE_TASK = "remove_task"
|
|
|
|
|
|
|
|
const val FINISH_AFFINITY = "finish_affinity"
|
|
|
|
private const val FRAG_TAG_TASK_LIST = "frag_tag_task_list"
|
|
|
|
private const val FRAG_TAG_TASK_LIST = "frag_tag_task_list"
|
|
|
|
private const val FRAG_TAG_WHATS_NEW = "frag_tag_whats_new"
|
|
|
|
private const val FRAG_TAG_WHATS_NEW = "frag_tag_whats_new"
|
|
|
|
private const val EXTRA_FILTER = "extra_filter"
|
|
|
|
private const val EXTRA_FILTER = "extra_filter"
|
|
|
@ -478,9 +532,32 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val Intent.removeTask: Boolean
|
|
|
|
|
|
|
|
get() = if (isFromHistory) {
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
getBooleanExtra(REMOVE_TASK, false).let {
|
|
|
|
|
|
|
|
removeExtra(REMOVE_TASK)
|
|
|
|
|
|
|
|
it
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val Intent.finishAffinity: Boolean
|
|
|
|
|
|
|
|
get() = if (isFromHistory) {
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
getBooleanExtra(FINISH_AFFINITY, false).let {
|
|
|
|
|
|
|
|
removeExtra(FINISH_AFFINITY)
|
|
|
|
|
|
|
|
it
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val Intent.isFromHistory: Boolean
|
|
|
|
val Intent.isFromHistory: Boolean
|
|
|
|
get() = flags and FLAG_FROM_HISTORY == FLAG_FROM_HISTORY
|
|
|
|
get() = flags and FLAG_FROM_HISTORY == FLAG_FROM_HISTORY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val Intent.broughtToFront: Boolean
|
|
|
|
|
|
|
|
get() = flags and Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT > 0
|
|
|
|
|
|
|
|
|
|
|
|
val Intent.flagsToString
|
|
|
|
val Intent.flagsToString
|
|
|
|
get() = if (BuildConfig.DEBUG) "" else
|
|
|
|
get() = if (BuildConfig.DEBUG) "" else
|
|
|
|
Intent::class.java.declaredFields
|
|
|
|
Intent::class.java.declaredFields
|
|
|
|