mirror of https://github.com/tasks/tasks
New task actions--killed the quick action bar and REQUEST_ACTIONS api constant
parent
d814380b0b
commit
451abd43c6
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.actfm;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
||||
import com.todoroo.astrid.activity.TaskEditFragment;
|
||||
import com.todoroo.astrid.activity.TaskEditActivity;
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.api.TaskAction;
|
||||
import com.todoroo.astrid.api.TaskDecoration;
|
||||
import com.todoroo.astrid.service.AstridDependencyInjector;
|
||||
|
||||
/**
|
||||
* Exposes {@link TaskDecoration} for timers
|
||||
*
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
public class EditPeopleExposer extends BroadcastReceiver {
|
||||
|
||||
private static final String ACTION = "com.todoroo.astrid.EDIT_PEOPLE"; //$NON-NLS-1$
|
||||
|
||||
static {
|
||||
AstridDependencyInjector.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
ContextManager.setContext(context);
|
||||
long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
|
||||
if(taskId == -1)
|
||||
return;
|
||||
|
||||
if(AstridApiConstants.BROADCAST_REQUEST_ACTIONS.equals(intent.getAction())) {
|
||||
final String label = context.getString(R.string.EPE_action);
|
||||
final int drawable = R.drawable.ic_qbar_share;
|
||||
Intent newIntent = new Intent(ACTION);
|
||||
newIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
TaskAction action = new TaskAction(label,
|
||||
PendingIntent.getBroadcast(context, (int)taskId, newIntent, 0), null);
|
||||
action.drawable = drawable;
|
||||
|
||||
// transmit
|
||||
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_ACTIONS);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ActFmPreferenceService.IDENTIFIER);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, action);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
||||
} else if(ACTION.equals(intent.getAction())) {
|
||||
Intent launchIntent = new Intent(context, TaskEditActivity.class);
|
||||
launchIntent.putExtra(TaskEditFragment.TOKEN_ID, taskId);
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ContextManager.getContext().startActivity(launchIntent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/**
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.notes;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.api.TaskAction;
|
||||
import com.todoroo.astrid.api.TaskDecoration;
|
||||
import com.todoroo.astrid.core.PluginServices;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.service.AstridDependencyInjector;
|
||||
|
||||
/**
|
||||
* Exposes {@link TaskDecoration} for timers
|
||||
*
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
public class EditNoteExposer extends BroadcastReceiver {
|
||||
|
||||
private static final String ACTION = "com.todoroo.astrid.EDIT_NOTES"; //$NON-NLS-1$
|
||||
|
||||
@Autowired ActFmPreferenceService actFmPreferenceService;
|
||||
|
||||
static {
|
||||
AstridDependencyInjector.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
ContextManager.setContext(context);
|
||||
DependencyInjectionService.getInstance().inject(this);
|
||||
long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
|
||||
if(taskId == -1)
|
||||
return;
|
||||
|
||||
if(AstridApiConstants.BROADCAST_REQUEST_ACTIONS.equals(intent.getAction())) {
|
||||
String label;
|
||||
int drawable;
|
||||
|
||||
if(!actFmPreferenceService.isLoggedIn()) {
|
||||
Task task = PluginServices.getTaskService().fetchById(taskId, Task.ID, Task.NOTES);
|
||||
if(task == null || !NotesPlugin.hasNotes(task))
|
||||
return;
|
||||
label = context.getString(R.string.ENE_label);
|
||||
drawable = R.drawable.ic_qbar_comments;
|
||||
} else {
|
||||
label = context.getString(R.string.ENE_label_comments);
|
||||
drawable = R.drawable.ic_qbar_comments;
|
||||
}
|
||||
Intent newIntent = new Intent(ACTION);
|
||||
newIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
TaskAction action = new TaskAction(label,
|
||||
PendingIntent.getBroadcast(context, (int)taskId, newIntent, 0), null);
|
||||
action.drawable = drawable;
|
||||
|
||||
// transmit
|
||||
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_ACTIONS);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, NotesPlugin.IDENTIFIER);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, action);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
||||
} else if(ACTION.equals(intent.getAction())) {
|
||||
Intent launchIntent = new Intent(context, EditNoteActivity.class);
|
||||
launchIntent.putExtra(EditNoteActivity.EXTRA_TASK_ID, taskId);
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ContextManager.getContext().startActivity(launchIntent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
package com.todoroo.astrid.tags;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.data.TodorooCursor;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.andlib.sql.Criterion;
|
||||
import com.todoroo.andlib.sql.QueryTemplate;
|
||||
import com.todoroo.andlib.utility.AndroidUtilities;
|
||||
import com.todoroo.astrid.activity.TaskListFragment;
|
||||
import com.todoroo.astrid.activity.TaskListActivity;
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.api.Filter;
|
||||
import com.todoroo.astrid.api.TaskAction;
|
||||
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
|
||||
import com.todoroo.astrid.data.Metadata;
|
||||
import com.todoroo.astrid.tags.TagService.Tag;
|
||||
|
||||
public class FilterByTagExposer extends BroadcastReceiver {
|
||||
|
||||
private static final String FILTER_ACTION = "com.todoroo.astrid.FILTER_BY_TAG"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
ContextManager.setContext(context);
|
||||
long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
|
||||
if(taskId == -1)
|
||||
return;
|
||||
|
||||
TodorooCursor<Metadata> cursor = TagService.getInstance().getTags(taskId);
|
||||
try {
|
||||
if(cursor.getCount() == 0)
|
||||
return;
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
if(AstridApiConstants.BROADCAST_REQUEST_ACTIONS.equals(intent.getAction())) {
|
||||
final String label = context.getString(R.string.TAd_contextFilterByTag);
|
||||
final Drawable drawable = context.getResources().getDrawable(R.drawable.med_tag);
|
||||
Intent newIntent = new Intent(FILTER_ACTION);
|
||||
newIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
Bitmap icon = ((BitmapDrawable)drawable).getBitmap();
|
||||
TaskAction action = new TaskAction(label,
|
||||
PendingIntent.getBroadcast(context, (int)taskId, newIntent, 0), icon);
|
||||
|
||||
// transmit
|
||||
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_ACTIONS);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, TagsPlugin.IDENTIFIER);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, action);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
||||
} else if(FILTER_ACTION.equals(intent.getAction())) {
|
||||
invoke(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
public void invoke(long taskId) {
|
||||
final List<String> tags;
|
||||
final TodorooCursor<Metadata> cursor = TagService.getInstance().getTags(
|
||||
taskId);
|
||||
try {
|
||||
if (!cursor.moveToFirst())
|
||||
return;
|
||||
tags = new ArrayList<String>();
|
||||
do {
|
||||
tags.add(cursor.get(TagService.TAG));
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
Collator collator = Collator.getInstance();
|
||||
collator.setStrength(Collator.PRIMARY);
|
||||
Collections.sort(tags, collator);
|
||||
|
||||
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tag tag = new Tag(tags.get(which), 0, 0);
|
||||
|
||||
String listTitle = tag.tag;
|
||||
String title = tag.tag;
|
||||
Criterion criterion = TaskCriteria.activeAndVisible();
|
||||
QueryTemplate tagTemplate = tag.queryTemplate(criterion);
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(Metadata.KEY.name, TagService.KEY);
|
||||
contentValues.put(TagService.TAG.name, tag.tag);
|
||||
|
||||
Filter tagFilter = new Filter(listTitle, title,
|
||||
tagTemplate, contentValues);
|
||||
Intent tagIntent = new Intent(ContextManager.getContext(),
|
||||
TaskListActivity.class);
|
||||
tagIntent.putExtra(TaskListFragment.TOKEN_FILTER, tagFilter);
|
||||
|
||||
ContextManager.getContext().startActivity(tagIntent);
|
||||
if (ContextManager.getContext() instanceof Activity)
|
||||
AndroidUtilities.callOverridePendingTransition((Activity) ContextManager.getContext(), R.anim.slide_left_in, R.anim.slide_left_out);
|
||||
}
|
||||
};
|
||||
|
||||
if (tags.size() == 1) {
|
||||
listener.onClick(null, 0);
|
||||
} else {
|
||||
new AlertDialog.Builder(ContextManager.getContext()).setTitle(
|
||||
R.string.TAd_contextFilterByTag).setAdapter(
|
||||
new ArrayAdapter<String>(ContextManager.getContext(),
|
||||
android.R.layout.select_dialog_item, tags),
|
||||
listener).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.timers;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.api.TaskAction;
|
||||
import com.todoroo.astrid.api.TaskDecoration;
|
||||
import com.todoroo.astrid.core.PluginServices;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
/**
|
||||
* Exposes {@link TaskDecoration} for timers
|
||||
*
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
public class TimerActionExposer extends BroadcastReceiver {
|
||||
|
||||
private static final String TIMER_ACTION = "com.todoroo.astrid.TIMER_BUTTON"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
ContextManager.setContext(context);
|
||||
long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
|
||||
if(taskId == -1)
|
||||
return;
|
||||
|
||||
Task task = PluginServices.getTaskService().fetchById(taskId, Task.ID, Task.TIMER_START,
|
||||
Task.ELAPSED_SECONDS);
|
||||
if(task == null)
|
||||
return;
|
||||
|
||||
// was part of a broadcast for actions
|
||||
if(AstridApiConstants.BROADCAST_REQUEST_ACTIONS.equals(intent.getAction())) {
|
||||
final String label;
|
||||
final int drawable;
|
||||
if(task.getValue(Task.TIMER_START) == 0) {
|
||||
label = context.getString(R.string.TAE_startTimer);
|
||||
drawable = R.drawable.ic_qbar_timer_start;
|
||||
} else {
|
||||
label = context.getString(R.string.TAE_stopTimer);
|
||||
drawable = R.drawable.ic_qbar_timer_stop;
|
||||
}
|
||||
Intent newIntent = new Intent(TIMER_ACTION);
|
||||
newIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
TaskAction action = new TaskAction(label,
|
||||
PendingIntent.getBroadcast(context, (int)taskId, newIntent, 0), null);
|
||||
action.drawable = drawable;
|
||||
|
||||
// transmit
|
||||
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_ACTIONS);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, TimerPlugin.IDENTIFIER);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, action);
|
||||
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
||||
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
||||
} else if(TIMER_ACTION.equals(intent.getAction())) {
|
||||
if(task.getValue(Task.TIMER_START) == 0)
|
||||
TimerPlugin.updateTimer(context, task, true);
|
||||
else
|
||||
TimerPlugin.updateTimer(context, task, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 726 B |
Loading…
Reference in New Issue