Update task and back stack behavior

pull/1051/head
Alex Baker 4 years ago
parent d795f1f6d6
commit 108c1f284b

@ -191,10 +191,11 @@
<!-- Activity launched from ShareLink menu item --> <!-- Activity launched from ShareLink menu item -->
<!-- TODO: clearTaskOnLaunch probable cause of #275 --> <!-- TODO: clearTaskOnLaunch probable cause of #275 -->
<activity <activity
android:clearTaskOnLaunch="true"
android:icon="@mipmap/ic_launcher_blue" android:icon="@mipmap/ic_launcher_blue"
android:label="@string/action_create_new_task" android:label="@string/action_create_new_task"
android:name="com.todoroo.astrid.activity.ShareLinkActivity" android:name="com.todoroo.astrid.activity.ShareLinkActivity"
android:taskAffinity=":share"
android:excludeFromRecents="true"
android:roundIcon="@mipmap/ic_launcher_blue"> android:roundIcon="@mipmap/ic_launcher_blue">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT"/> <action android:name="android.intent.action.PROCESS_TEXT"/>

@ -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

@ -6,13 +6,12 @@ import static com.google.common.collect.Lists.newArrayList;
import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.Strings.isNullOrEmpty;
import static org.tasks.files.FileHelper.copyToUri; import static org.tasks.files.FileHelper.copyToUri;
import static org.tasks.files.FileHelper.getFilename; import static org.tasks.files.FileHelper.getFilename;
import static org.tasks.intents.TaskIntents.getTaskListIntent; import static org.tasks.intents.TaskIntents.getEditTaskIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.core.app.TaskStackBuilder;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.TaskCreator; import com.todoroo.astrid.service.TaskCreator;
@ -37,29 +36,10 @@ public final class ShareLinkActivity extends InjectingAppCompatActivity {
@Inject TaskCreator taskCreator; @Inject TaskCreator taskCreator;
@Inject Preferences preferences; @Inject Preferences preferences;
private static TaskStackBuilder getEditTaskStack(Context context, Task task) {
Intent intent = getTaskListIntent(context, null);
intent.putExtra(MainActivity.OPEN_TASK, task);
return TaskStackBuilder.create(context).addNextIntent(intent);
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
readIntent();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
readIntent();
}
private void readIntent() {
Intent intent = getIntent(); Intent intent = getIntent();
String action = intent.getAction(); String action = intent.getAction();
@ -67,7 +47,7 @@ public final class ShareLinkActivity extends InjectingAppCompatActivity {
CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
if (text != null) { if (text != null) {
Task task = taskCreator.createWithValues(text.toString()); Task task = taskCreator.createWithValues(text.toString());
getEditTaskStack(this, task).startActivities(); editTask(task);
} }
} else if (ACTION_SEND.equals(action)) { } else if (ACTION_SEND.equals(action)) {
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
@ -76,20 +56,26 @@ public final class ShareLinkActivity extends InjectingAppCompatActivity {
if (hasAttachments(intent)) { if (hasAttachments(intent)) {
task.putTransitory(TaskAttachment.KEY, copyAttachment(intent)); task.putTransitory(TaskAttachment.KEY, copyAttachment(intent));
} }
getEditTaskStack(this, task).startActivities(); editTask(task);
} else if (ACTION_SEND_MULTIPLE.equals(action)) { } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Task task = taskCreator.createWithValues(intent.getStringExtra(Intent.EXTRA_SUBJECT)); Task task = taskCreator.createWithValues(intent.getStringExtra(Intent.EXTRA_SUBJECT));
task.setNotes(intent.getStringExtra(Intent.EXTRA_TEXT)); task.setNotes(intent.getStringExtra(Intent.EXTRA_TEXT));
if (hasAttachments(intent)) { if (hasAttachments(intent)) {
task.putTransitory(TaskAttachment.KEY, copyMultipleAttachments(intent)); task.putTransitory(TaskAttachment.KEY, copyMultipleAttachments(intent));
} }
getEditTaskStack(this, task).startActivities(); editTask(task);
} else { } else {
Timber.e("Unhandled intent: %s", intent); Timber.e("Unhandled intent: %s", intent);
} }
finish(); finish();
} }
private void editTask(Task task) {
Intent intent = getEditTaskIntent(this, null, task);
intent.putExtra(MainActivity.FINISH_AFFINITY, true);
startActivity(intent);
}
private ArrayList<Uri> copyAttachment(Intent intent) { private ArrayList<Uri> copyAttachment(Intent intent) {
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
String filename = getFilename(context, uri); String filename = getFilename(context, uri);

@ -85,7 +85,7 @@ public class CalendarAlarmReceiver extends InjectingBroadcastReceiver {
intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, event.getTitle()); intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, event.getTitle());
intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, event.getEnd()); intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, event.getEnd());
intent.putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone); intent.putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent); context.startActivity(intent);
} }
} }

@ -126,7 +126,7 @@ public class TaskCreator {
} }
public Task createWithValues(Filter filter, String title) { public Task createWithValues(Filter filter, String title) {
return create(filter.valuesForNewTasks, title); return create(filter == null ? null : filter.valuesForNewTasks, title);
} }
/** /**
* Create task from the given content values, saving it. This version doesn't need to start with a * Create task from the given content values, saving it. This version doesn't need to start with a

@ -90,7 +90,6 @@ public class TimerPlugin {
} else { } else {
Filter filter = createFilter(context); Filter filter = createFilter(context);
Intent notifyIntent = TaskIntents.getTaskListIntent(context, filter); Intent notifyIntent = TaskIntents.getTaskListIntent(context, filter);
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent pendingIntent =
PendingIntent.getActivity(context, Constants.NOTIFICATION_TIMER, notifyIntent, 0); PendingIntent.getActivity(context, Constants.NOTIFICATION_TIMER, notifyIntent, 0);

@ -2,15 +2,14 @@ package org.tasks
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.andlib.utility.AndroidUtilities
import com.todoroo.astrid.activity.MainActivity
import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.Filter
import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.dao.TaskDaoBlocking
import com.todoroo.astrid.reminders.ReminderService import com.todoroo.astrid.reminders.ReminderService
import com.todoroo.astrid.voice.VoiceOutputAssistant import com.todoroo.astrid.voice.VoiceOutputAssistant
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import org.tasks.intents.TaskIntents
import org.tasks.notifications.AudioManager import org.tasks.notifications.AudioManager
import org.tasks.notifications.Notification import org.tasks.notifications.Notification
import org.tasks.notifications.NotificationManager import org.tasks.notifications.NotificationManager
@ -40,9 +39,7 @@ class Notifier @Inject constructor(
if (count == 0) { if (count == 0) {
return return
} }
val intent = Intent(context, MainActivity::class.java) val intent = TaskIntents.getTaskListIntent(context, filter)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
intent.putExtra(MainActivity.OPEN_FILTER, filter)
val pendingIntent = PendingIntent.getActivity( val pendingIntent = PendingIntent.getActivity(
context, filter.listingTitle.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT) context, filter.listingTitle.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
val summaryTitle = context.resources.getQuantityString(R.plurals.task_count, count, count) val summaryTitle = context.resources.getQuantityString(R.plurals.task_count, count, count)

@ -28,7 +28,7 @@ class UriHandler : AppCompatActivity() {
lifecycleScope.launch { lifecycleScope.launch {
val task = taskDao.fetch(id) val task = taskDao.fetch(id)
task?.let { task?.let {
startActivity(TaskIntents.getEditTaskIntent(this@UriHandler, it)) startActivity(TaskIntents.getEditTaskIntent(this@UriHandler, null, it))
} }
finish() finish()
} }
@ -49,7 +49,9 @@ class UriHandler : AppCompatActivity() {
} }
private fun newTask() { private fun newTask() {
startActivity(TaskIntents.getNewTaskIntent(this, null)) val intent = TaskIntents.getNewTaskIntent(this@UriHandler, null)
intent.flags = TaskIntents.FLAGS
startActivity(intent)
finish() finish()
} }
} }

@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import com.google.android.apps.dashclock.api.ExtensionData; import com.google.android.apps.dashclock.api.ExtensionData;
import com.todoroo.astrid.activity.MainActivity;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.dao.TaskDaoBlocking;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
@ -13,6 +12,7 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.LocalBroadcastManager; import org.tasks.LocalBroadcastManager;
import org.tasks.R; import org.tasks.R;
import org.tasks.intents.TaskIntents;
import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
import timber.log.Timber; import timber.log.Timber;
@ -61,8 +61,7 @@ public class DashClockExtension extends com.google.android.apps.dashclock.api.Da
if (count == 0) { if (count == 0) {
publish(null); publish(null);
} else { } else {
Intent clickIntent = new Intent(this, MainActivity.class); Intent clickIntent = TaskIntents.getTaskListIntent(this, filter);
clickIntent.putExtra(MainActivity.OPEN_FILTER, filter);
ExtensionData extensionData = ExtensionData extensionData =
new ExtensionData() new ExtensionData()
.visible(true) .visible(true)

@ -10,26 +10,31 @@ import com.todoroo.astrid.data.Task;
public class TaskIntents { public class TaskIntents {
public static Intent getEditTaskIntent(Context context, Task task) { public static final int FLAGS = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP;
return getEditTaskIntent(context, null, task);
}
public static Intent getNewTaskIntent(Context context, @Nullable Filter filter) { public static Intent getNewTaskIntent(Context context, @Nullable Filter filter) {
Intent intent = TaskIntents.getTaskListIntent(context, filter); Intent intent = new Intent(context, MainActivity.class);
if (filter != null) {
intent.putExtra(MainActivity.OPEN_FILTER, filter);
}
intent.putExtra(MainActivity.CREATE_TASK, 0L); intent.putExtra(MainActivity.CREATE_TASK, 0L);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(MainActivity.REMOVE_TASK, true);
return intent; return intent;
} }
public static Intent getEditTaskIntent(Context context, @Nullable Filter filter, Task task) { public static Intent getEditTaskIntent(Context context, @Nullable Filter filter, Task task) {
Intent intent = getTaskListIntent(context, filter); Intent intent = new Intent(context, MainActivity.class);
if (filter != null) {
intent.putExtra(MainActivity.OPEN_FILTER, filter);
}
intent.putExtra(MainActivity.OPEN_TASK, task); intent.putExtra(MainActivity.OPEN_TASK, task);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(MainActivity.REMOVE_TASK, true);
return intent; return intent;
} }
public static Intent getTaskListIntent(Context context, @Nullable Filter filter) { public static Intent getTaskListIntent(Context context, @Nullable Filter filter) {
Intent intent = new Intent(context, MainActivity.class); Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(FLAGS);
if (filter != null) { if (filter != null) {
intent.putExtra(MainActivity.OPEN_FILTER, filter); intent.putExtra(MainActivity.OPEN_FILTER, filter);
} }

@ -88,7 +88,7 @@ public class NotificationActivity extends InjectingAppCompatActivity
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
task -> { task -> {
startActivity(TaskIntents.getEditTaskIntent(this, task)); startActivity(TaskIntents.getEditTaskIntent(this, null, task));
finish(); finish();
}, },
e -> Timber.e("Task not found: %s", taskId))); e -> Timber.e("Task not found: %s", taskId)));

@ -123,7 +123,6 @@ class TasksWidget : AppWidgetProvider() {
private fun getOpenListIntent(context: Context, filter: Filter, widgetId: Int): PendingIntent { private fun getOpenListIntent(context: Context, filter: Filter, widgetId: Int): PendingIntent {
val intent = TaskIntents.getTaskListIntent(context, filter) val intent = TaskIntents.getTaskListIntent(context, filter)
intent.flags = flags
intent.action = "open_list" intent.action = "open_list"
return PendingIntent.getActivity(context, widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT) return PendingIntent.getActivity(context, widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
} }
@ -136,7 +135,7 @@ class TasksWidget : AppWidgetProvider() {
private fun getWidgetConfigIntent(context: Context, widgetId: Int): PendingIntent { private fun getWidgetConfigIntent(context: Context, widgetId: Int): PendingIntent {
val intent = Intent(context, WidgetConfigActivity::class.java) val intent = Intent(context, WidgetConfigActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK intent.flags = flags
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId) intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId)
intent.action = "widget_settings" intent.action = "widget_settings"
return PendingIntent.getActivity(context, widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT) return PendingIntent.getActivity(context, widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
@ -144,7 +143,7 @@ class TasksWidget : AppWidgetProvider() {
private fun getChooseListIntent(context: Context, filter: Filter, widgetId: Int): PendingIntent { private fun getChooseListIntent(context: Context, filter: Filter, widgetId: Int): PendingIntent {
val intent = Intent(context, FilterSelectionActivity::class.java) val intent = Intent(context, FilterSelectionActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK intent.flags = flags
intent.putExtra(FilterSelectionActivity.EXTRA_FILTER, filter) intent.putExtra(FilterSelectionActivity.EXTRA_FILTER, filter)
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId) intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId)
intent.action = "choose_list" intent.action = "choose_list"

@ -7,5 +7,9 @@ import org.tasks.intents.TaskIntents
@RequiresApi(api = VERSION_CODES.N) @RequiresApi(api = VERSION_CODES.N)
class TileService : TileService() { class TileService : TileService() {
override fun onClick() = startActivityAndCollapse(TaskIntents.getNewTaskIntent(this, null)) override fun onClick() {
val newTaskIntent = TaskIntents.getNewTaskIntent(this, null)
.addFlags(TaskIntents.FLAGS)
startActivityAndCollapse(newTaskIntent)
}
} }
Loading…
Cancel
Save