diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 5344f2c91..6915f60c2 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -150,16 +150,6 @@ - - - - - - - - item : filter.valuesForNewTasks.valueSet()) { - String key = ShortcutActivity.TOKEN_FILTER_VALUES_ITEM + item.getKey(); - Object value = item.getValue(); - putExtra(shortcutIntent, key, value); - } - } - return shortcutIntent; - } - - private static void putExtra(Intent intent, String key, Object value) { - // assume one of the big 4... - if (value instanceof String) { - intent.putExtra(key, (String) value); - } else if (value instanceof Integer) { - intent.putExtra(key, (Integer) value); - } else if (value instanceof Double) { - intent.putExtra(key, (Double) value); - } else if (value instanceof Long) { - intent.putExtra(key, (Long) value); - } else { - throw new IllegalStateException( - "Unsupported bundle type " + value.getClass()); //$NON-NLS-1$ - } - } - @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); diff --git a/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java b/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java deleted file mode 100644 index 7dd0e29fb..000000000 --- a/src/main/java/com/todoroo/astrid/activity/ShortcutActivity.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.astrid.activity; - -import android.content.ComponentName; -import android.content.ContentValues; -import android.content.Intent; -import android.os.Bundle; - -import com.todoroo.andlib.utility.AndroidUtilities; -import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.api.FilterWithCustomIntent; - -import org.tasks.injection.ActivityComponent; -import org.tasks.injection.InjectingAppCompatActivity; - -import java.util.Set; - -/** - * This activity is launched when a user opens up a notification from the - * tray. It launches the appropriate activity based on the passed in parameters. - * - * @author timsu - * - */ -public class ShortcutActivity extends InjectingAppCompatActivity { - - // --- constants - - /** token for passing a {@link Filter}'s title through extras */ - public static final String TOKEN_FILTER_TITLE = "title"; //$NON-NLS-1$ - - /** token for passing a {@link Filter}'s sql through extras */ - public static final String TOKEN_FILTER_SQL = "sql"; //$NON-NLS-1$ - - /** token for passing a {@link Filter}'s values for new tasks through extras as exploded ContentValues */ - public static final String TOKEN_FILTER_VALUES_ITEM = "v4ntp_"; //$NON-NLS-1$ - - /** token for passing a ComponentNameto launch */ - public static final String TOKEN_CUSTOM_CLASS = "class"; //$NON-NLS-1$ - - /** List of the above constants for searching */ - private static final String[] CUSTOM_EXTRAS = { - TOKEN_FILTER_TITLE, - TOKEN_FILTER_SQL, - TOKEN_FILTER_VALUES_ITEM, - TOKEN_CUSTOM_CLASS - }; - - // --- implementation - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - launchShortcut(); - } - - @Override - public void inject(ActivityComponent component) { - component.inject(this); - } - - @Override - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - - setIntent(intent); - - launchShortcut(); - } - - private void launchShortcut() { - Intent intent = getIntent(); - - Bundle extras = intent.getExtras(); - - Intent taskListIntent = new Intent(this, TaskListActivity.class); - - if (extras != null) { - if(extras.containsKey(TOKEN_CUSTOM_CLASS)) { - taskListIntent.putExtras(intent.getExtras()); - } - - // launched from desktop shortcut, must create a fake filter - String title = extras.getString(TOKEN_FILTER_TITLE); - String sql = extras.getString(TOKEN_FILTER_SQL); - sql = sql.replace("tasks.userId=0", "1"); // TODO: replace dirty hack for missing column - ContentValues values = new ContentValues(); - for(String key : extras.keySet()) { - if(!key.startsWith(TOKEN_FILTER_VALUES_ITEM)) { - continue; - } - - Object value = extras.get(key); - key = key.substring(TOKEN_FILTER_VALUES_ITEM.length()); - - // assume one of the big 4... - if(value instanceof String) { - values.put(key, (String) value); - } else if(value instanceof Integer) { - values.put(key, (Integer) value); - } else if(value instanceof Double) { - values.put(key, (Double) value); - } else if(value instanceof Long) { - values.put(key, (Long) value); - } else { - throw new IllegalStateException("Unsupported bundle type " + value.getClass()); //$NON-NLS-1$ - } - } - - Filter filter; - if (extras.containsKey(TOKEN_CUSTOM_CLASS)) { - filter = new FilterWithCustomIntent(title, sql, values); - Bundle customExtras = new Bundle(); - Set keys = extras.keySet(); - for (String key : keys) { - if (AndroidUtilities.indexOf(CUSTOM_EXTRAS, key) < 0) { - AndroidUtilities.putInto(customExtras, key, extras.get(key)); - } - } - - ((FilterWithCustomIntent) filter).customExtras = customExtras; // Something - ((FilterWithCustomIntent) filter).customTaskList = ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS)); - } else { - filter = new Filter(title, sql, values); - } - taskListIntent.putExtra(TaskListActivity.OPEN_FILTER, filter); - } - - startActivity(taskListIntent); - finish(); - } -} diff --git a/src/main/java/com/todoroo/astrid/api/FilterWithCustomIntent.java b/src/main/java/com/todoroo/astrid/api/FilterWithCustomIntent.java index 449174ad1..5d6700519 100644 --- a/src/main/java/com/todoroo/astrid/api/FilterWithCustomIntent.java +++ b/src/main/java/com/todoroo/astrid/api/FilterWithCustomIntent.java @@ -17,8 +17,6 @@ import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.astrid.actfm.TagViewFragment; import com.todoroo.astrid.subtasks.SubtasksTagListFragment; -import org.tasks.BuildConfig; - public class FilterWithCustomIntent extends Filter { /** @@ -39,10 +37,6 @@ public class FilterWithCustomIntent extends Filter { super(listingTitle, sqlQuery, valuesForNewTasks); } - public FilterWithCustomIntent(String listingTitle, String sqlQuery, ContentValues valuesForNewTasks) { - super(listingTitle, sqlQuery, valuesForNewTasks); - } - public Intent getCustomIntent() { Intent intent = new Intent(); if(customExtras != null) { diff --git a/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java b/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java index 6c8d3bad7..b0f60ce9e 100644 --- a/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java +++ b/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java @@ -14,14 +14,13 @@ import android.support.v7.app.NotificationCompat; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.astrid.activity.FilterShortcutActivity; -import com.todoroo.astrid.activity.ShortcutActivity; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.utility.Constants; import org.tasks.R; +import org.tasks.intents.TaskIntents; import org.tasks.notifications.NotificationManager; import static org.tasks.time.DateTimeUtils.currentTimeMillis; @@ -78,7 +77,7 @@ public class TimerPlugin { notificationManager.cancel(Constants.NOTIFICATION_TIMER); } else { Filter filter = TimerFilterExposer.createFilter(context); - Intent notifyIntent = FilterShortcutActivity.createShortcutIntent(context, filter); + Intent notifyIntent = TaskIntents.getTaskListIntent(context, filter); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, Constants.NOTIFICATION_TIMER, notifyIntent, 0); diff --git a/src/main/java/org/tasks/injection/BaseActivityComponent.java b/src/main/java/org/tasks/injection/BaseActivityComponent.java index 0ed9f2b97..fc0fdf86d 100644 --- a/src/main/java/org/tasks/injection/BaseActivityComponent.java +++ b/src/main/java/org/tasks/injection/BaseActivityComponent.java @@ -5,7 +5,6 @@ import com.todoroo.astrid.actfm.TagSettingsActivity; import com.todoroo.astrid.activity.BeastModePreferences; import com.todoroo.astrid.activity.FilterShortcutActivity; import com.todoroo.astrid.activity.ShareLinkActivity; -import com.todoroo.astrid.activity.ShortcutActivity; import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.core.CustomFilterActivity; import com.todoroo.astrid.core.DefaultsPreferences; @@ -67,8 +66,6 @@ public interface BaseActivityComponent { void inject(TaskListActivity taskListActivity); - void inject(ShortcutActivity shortcutActivity); - void inject(BeastModePreferences beastModePreferences); void inject(NotificationActivity notificationActivity);