mirror of https://github.com/tasks/tasks
Moved notes from action into a decoration
parent
f46a92938a
commit
2f87b67248
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.notes;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.astrid.api.TaskDecoration;
|
||||
import com.todoroo.astrid.api.TaskDecorationExposer;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
/**
|
||||
* Exposes {@link TaskDecoration} for notes
|
||||
*
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
public class NotesDecorationExposer implements TaskDecorationExposer {
|
||||
|
||||
@Override
|
||||
public TaskDecoration expose(Task task) {
|
||||
if(task == null || TextUtils.isEmpty(task.getValue(Task.NOTES)))
|
||||
return null;
|
||||
|
||||
TaskDecoration decoration;
|
||||
RemoteViews remoteViews = new RemoteViews(ContextManager.getContext().getPackageName(),
|
||||
R.layout.note_decoration);
|
||||
decoration = new TaskDecoration(remoteViews, TaskDecoration.POSITION_RIGHT, 0);
|
||||
|
||||
Intent intent = new Intent(ContextManager.getContext(), NoteViewingActivity.class);
|
||||
intent.putExtra(NoteViewingActivity.EXTRA_TASK, task);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(ContextManager.getContext(),
|
||||
(int)task.getId(), intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
remoteViews.setOnClickPendingIntent(R.id.icon, pendingIntent);
|
||||
|
||||
return decoration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddon() {
|
||||
return NotesPlugin.IDENTIFIER;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- See the file "LICENSE" for the full license governing this code. -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="3px">
|
||||
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="5"
|
||||
android:gravity="center_horizontal"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/tango_notes" />
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue