Moved notes from action into a decoration

pull/14/head
Tim Su 14 years ago
parent f46a92938a
commit 2f87b67248

@ -418,12 +418,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="com.todoroo.astrid.notes.NotesActionExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_ACTIONS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name="com.todoroo.astrid.notes.NoteViewingActivity"
android:theme="@style/Theme.Dialog" />

@ -7,15 +7,17 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
import com.timsu.astrid.R;
import com.todoroo.astrid.data.Task;
public class NoteViewingActivity extends Activity {
public static final String EXTRA_TASK = "task"; //$NON-NLS-1$
private Task task;
@Override
@ -27,7 +29,7 @@ public class NoteViewingActivity extends Activity {
LinearLayout body = (LinearLayout) findViewById(R.id.body);
task = getIntent().getParcelableExtra(NotesActionExposer.EXTRA_TASK);
task = getIntent().getParcelableExtra(EXTRA_TASK);
setTitle(task.getValue(Task.TITLE));
ScrollView scrollView = new ScrollView(this);

@ -28,8 +28,6 @@ import com.todoroo.astrid.data.Task;
*/
public class NotesActionExposer extends BroadcastReceiver {
static final String EXTRA_TASK = "task"; //$NON-NLS-1$
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
@ -50,7 +48,7 @@ public class NotesActionExposer extends BroadcastReceiver {
private void displayNote(Context context, Task task) {
Intent intent = new Intent(context, NoteViewingActivity.class);
intent.putExtra(EXTRA_TASK, task);
intent.putExtra(NoteViewingActivity.EXTRA_TASK, task);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}

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

@ -59,6 +59,7 @@ import com.todoroo.astrid.api.TaskDecoration;
import com.todoroo.astrid.api.TaskDecorationExposer;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.helper.TaskAdapterAddOnManager;
import com.todoroo.astrid.notes.NotesDecorationExposer;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.timers.TimerDecorationExposer;
import com.todoroo.astrid.utility.Constants;
@ -639,6 +640,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
private final TaskDecorationExposer[] exposers = new TaskDecorationExposer[] {
new TimerDecorationExposer(),
new NotesDecorationExposer(),
};
/**
@ -660,8 +662,10 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
for(TaskDecorationExposer exposer : exposers) {
TaskDecoration deco = exposer.expose(viewHolder.task);
if(deco != null)
if(deco != null) {
addNew(viewHolder.task.getId(), exposer.getAddon(), deco);
System.err.println("new chilli - " + exposer.getAddon());
}
}
return true;
@ -694,6 +698,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
viewHolder.taskRow.addView(view, 2);
break;
case TaskDecoration.POSITION_RIGHT:
System.err.println("addin da child");
viewHolder.taskRow.addView(view, viewHolder.taskRow.getChildCount() - 1);
}
}

Loading…
Cancel
Save