mirror of https://github.com/tasks/tasks
Created EditNoteActivity for viewing and adding task comments and notes.
parent
948731dc61
commit
e9db48b229
@ -0,0 +1,333 @@
|
||||
package com.todoroo.astrid.notes;
|
||||
|
||||
import greendroid.widget.AsyncImageView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.data.TodorooCursor;
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||
import com.todoroo.andlib.sql.Order;
|
||||
import com.todoroo.andlib.sql.Query;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
import com.todoroo.andlib.utility.DialogUtilities;
|
||||
import com.todoroo.andlib.utility.Preferences;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
||||
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
||||
import com.todoroo.astrid.core.PluginServices;
|
||||
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
|
||||
import com.todoroo.astrid.dao.UpdateDao;
|
||||
import com.todoroo.astrid.data.Metadata;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.data.Update;
|
||||
import com.todoroo.astrid.service.MetadataService;
|
||||
import com.todoroo.astrid.utility.Flags;
|
||||
|
||||
public class EditNoteActivity extends ListActivity {
|
||||
|
||||
public static final String EXTRA_TASK_ID = "task"; //$NON-NLS-1$
|
||||
private static final int MENU_REFRESH_ID = Menu.FIRST;
|
||||
private static final String LAST_FETCH_KEY = "task-fetch-"; //$NON-NLS-1$
|
||||
|
||||
private Task task;
|
||||
|
||||
@Autowired ActFmSyncService actFmSyncService;
|
||||
@Autowired ActFmPreferenceService actFmPreferenceService;
|
||||
@Autowired MetadataService metadataService;
|
||||
@Autowired UpdateDao updateDao;
|
||||
|
||||
private final ArrayList<NoteOrUpdate> items = new ArrayList<NoteOrUpdate>();
|
||||
private NoteAdapter adapter;
|
||||
private EditText commentField;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
DependencyInjectionService.getInstance().inject(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.edit_note_activity);
|
||||
|
||||
long taskId = getIntent().getLongExtra(EXTRA_TASK_ID, -1);
|
||||
task = PluginServices.getTaskService().fetchById(taskId, Task.NOTES, Task.ID, Task.REMOTE_ID, Task.TITLE);
|
||||
if(task == null)
|
||||
return;
|
||||
|
||||
setTitle(task.getValue(Task.TITLE));
|
||||
|
||||
setUpListAdapter();
|
||||
setUpInterface();
|
||||
|
||||
if(actFmPreferenceService.isLoggedIn() && task.getValue(Task.REMOTE_ID) > 0) {
|
||||
findViewById(R.id.add_comment).setVisibility(View.VISIBLE);
|
||||
|
||||
String fetchKey = LAST_FETCH_KEY + task.getId();
|
||||
long lastFetchDate = Preferences.getLong(fetchKey, 0);
|
||||
if(DateUtilities.now() > lastFetchDate + 300000L) {
|
||||
refreshData(false);
|
||||
Preferences.setLong(fetchKey, DateUtilities.now());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- UI preparation
|
||||
|
||||
private void setUpInterface() {
|
||||
final View commentButton = findViewById(R.id.commentButton);
|
||||
commentField = (EditText) findViewById(R.id.commentField);
|
||||
commentField.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
|
||||
if(actionId == EditorInfo.IME_NULL && commentField.getText().length() > 0) {
|
||||
addComment();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
commentField.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
commentButton.setVisibility((s.length() > 0) ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
//
|
||||
}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//
|
||||
}
|
||||
});
|
||||
commentButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addComment();
|
||||
}
|
||||
});
|
||||
|
||||
if(!TextUtils.isEmpty(task.getValue(Task.NOTES))) {
|
||||
TextView notes = new TextView(this);
|
||||
notes.setGravity(Gravity.CENTER);
|
||||
notes.setTextSize(20);
|
||||
getListView().addHeaderView(notes);
|
||||
notes.setText(task.getValue(Task.NOTES));
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpListAdapter() {
|
||||
items.clear();
|
||||
TodorooCursor<Metadata> notes = metadataService.query(
|
||||
Query.select(Metadata.PROPERTIES).where(
|
||||
MetadataCriteria.byTaskAndwithKey(task.getId(),
|
||||
NoteMetadata.METADATA_KEY)).orderBy(Order.desc(Metadata.CREATION_DATE)));
|
||||
try {
|
||||
Metadata metadata = new Metadata();
|
||||
for(notes.moveToFirst(); !notes.isAfterLast(); notes.moveToNext()) {
|
||||
metadata.readFromCursor(notes);
|
||||
items.add(NoteOrUpdate.fromMetadata(metadata));
|
||||
}
|
||||
} finally {
|
||||
notes.close();
|
||||
}
|
||||
TodorooCursor<Update> updates = updateDao.query(Query.select(Update.PROPERTIES).where(
|
||||
Update.TASK.eq(task.getValue(Task.REMOTE_ID))).orderBy(Order.desc(Update.CREATION_DATE)));
|
||||
try {
|
||||
Update update = new Update();
|
||||
for(updates.moveToFirst(); !updates.isAfterLast(); updates.moveToNext()) {
|
||||
update.readFromCursor(updates);
|
||||
items.add(NoteOrUpdate.fromUpdate(update));
|
||||
}
|
||||
} finally {
|
||||
updates.close();
|
||||
}
|
||||
Collections.sort(items, new Comparator<NoteOrUpdate>() {
|
||||
@Override
|
||||
public int compare(NoteOrUpdate a, NoteOrUpdate b) {
|
||||
return (int)(b.createdAt - a.createdAt);
|
||||
}
|
||||
});
|
||||
adapter = new NoteAdapter(this, R.id.name, items);
|
||||
setListAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
if(menu.size() > 0)
|
||||
return true;
|
||||
|
||||
MenuItem item;
|
||||
if(actFmPreferenceService.isLoggedIn()) {
|
||||
item = menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE,
|
||||
R.string.ENA_refresh_comments);
|
||||
item.setIcon(R.drawable.ic_menu_refresh);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- events
|
||||
|
||||
private void refreshData(boolean manual) {
|
||||
final ProgressDialog progressDialog;
|
||||
if(manual)
|
||||
progressDialog = DialogUtilities.progressDialog(this, getString(R.string.DLG_please_wait));
|
||||
else
|
||||
progressDialog = null;
|
||||
|
||||
actFmSyncService.fetchUpdatesForTask(task, manual, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setUpListAdapter();
|
||||
DialogUtilities.dismissDialog(EditNoteActivity.this, progressDialog);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addComment() {
|
||||
Update update = new Update();
|
||||
update.setValue(Update.MESSAGE, commentField.getText().toString());
|
||||
update.setValue(Update.ACTION_CODE, "task_comment"); //$NON-NLS-1$
|
||||
update.setValue(Update.USER_ID, 0L);
|
||||
update.setValue(Update.TASK, task.getValue(Task.REMOTE_ID));
|
||||
update.setValue(Update.CREATION_DATE, DateUtilities.now());
|
||||
Flags.checkAndClear(Flags.SUPPRESS_SYNC);
|
||||
updateDao.createNew(update);
|
||||
|
||||
commentField.setText(""); //$NON-NLS-1$
|
||||
setUpListAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||
// handle my own menus
|
||||
switch (item.getItemId()) {
|
||||
|
||||
case MENU_REFRESH_ID: {
|
||||
refreshData(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
// --- adapter
|
||||
|
||||
private static class NoteOrUpdate {
|
||||
private final String picture;
|
||||
private final String title;
|
||||
private final String body;
|
||||
private final long createdAt;
|
||||
|
||||
public NoteOrUpdate(String picture, String title, String body,
|
||||
long createdAt) {
|
||||
super();
|
||||
this.picture = picture;
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public static NoteOrUpdate fromMetadata(Metadata m) {
|
||||
return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL),
|
||||
m.getValue(NoteMetadata.TITLE),
|
||||
m.getValue(NoteMetadata.BODY),
|
||||
m.getValue(Metadata.CREATION_DATE));
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
public static NoteOrUpdate fromUpdate(Update u) {
|
||||
JSONObject user = ActFmPreferenceService.userFromModel(u);
|
||||
|
||||
String description = u.getValue(Update.ACTION);
|
||||
String message = u.getValue(Update.MESSAGE);
|
||||
if(u.getValue(Update.ACTION_CODE).equals("task_comment"))
|
||||
description = message;
|
||||
else if(!TextUtils.isEmpty(message))
|
||||
description += " " + message;
|
||||
|
||||
return new NoteOrUpdate(user.optString("picture"),
|
||||
user.optString("name", ""),
|
||||
description,
|
||||
u.getValue(Update.CREATION_DATE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title + ": " + body; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private class NoteAdapter extends ArrayAdapter<NoteOrUpdate> {
|
||||
|
||||
public NoteAdapter(Context context, int textViewResourceId, List<NoteOrUpdate> list) {
|
||||
super(context, textViewResourceId, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if(convertView == null) {
|
||||
convertView = getLayoutInflater().inflate(R.layout.update_adapter_row, parent, false);
|
||||
}
|
||||
bindView(convertView, items.get(position));
|
||||
return convertView;
|
||||
}
|
||||
|
||||
/** Helper method to set the contents and visibility of each field */
|
||||
public synchronized void bindView(View view, NoteOrUpdate item) {
|
||||
// picture
|
||||
final AsyncImageView pictureView = (AsyncImageView)view.findViewById(R.id.picture); {
|
||||
pictureView.setUrl(item.picture);
|
||||
}
|
||||
|
||||
// name
|
||||
final TextView nameView = (TextView)view.findViewById(R.id.title); {
|
||||
nameView.setText(item.title);
|
||||
}
|
||||
|
||||
// description
|
||||
final TextView descriptionView = (TextView)view.findViewById(R.id.description); {
|
||||
descriptionView.setText(item.body);
|
||||
}
|
||||
|
||||
// date
|
||||
final TextView date = (TextView)view.findViewById(R.id.date); {
|
||||
CharSequence dateString = DateUtils.getRelativeTimeSpanString(item.createdAt,
|
||||
DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE);
|
||||
date.setText(dateString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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 android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@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;
|
||||
Drawable drawable;
|
||||
|
||||
if(!actFmPreferenceService.isLoggedIn()) {
|
||||
Task task = PluginServices.getTaskService().fetchById(taskId, Task.NOTES);
|
||||
if(task == null || TextUtils.isEmpty(task.getValue(Task.NOTES)))
|
||||
return;
|
||||
label = context.getString(R.string.ENE_label);
|
||||
drawable = context.getResources().getDrawable(R.drawable.tango_notes);
|
||||
} else {
|
||||
label = context.getString(R.string.ENE_label_comments);
|
||||
drawable = context.getResources().getDrawable(R.drawable.tango_chat);
|
||||
}
|
||||
Intent newIntent = new Intent(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, 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, EditNoteActivity.class);
|
||||
launchIntent.putExtra(EditNoteActivity.EXTRA_TASK_ID, taskId);
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ContextManager.getContext().startActivity(launchIntent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package com.todoroo.astrid.notes;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.text.util.Linkify;
|
||||
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 com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.data.TodorooCursor;
|
||||
import com.todoroo.andlib.sql.Order;
|
||||
import com.todoroo.andlib.sql.Query;
|
||||
import com.todoroo.astrid.core.PluginServices;
|
||||
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
|
||||
import com.todoroo.astrid.data.Metadata;
|
||||
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
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.empty_linear_layout);
|
||||
getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
LinearLayout body = (LinearLayout) findViewById(R.id.body);
|
||||
|
||||
task = getIntent().getParcelableExtra(EXTRA_TASK);
|
||||
setTitle(task.getValue(Task.TITLE));
|
||||
|
||||
ScrollView scrollView = new ScrollView(this);
|
||||
LinearLayout scrollViewBody = new LinearLayout(this);
|
||||
scrollViewBody.setOrientation(LinearLayout.VERTICAL);
|
||||
scrollView.addView(scrollViewBody);
|
||||
body.addView(scrollView);
|
||||
|
||||
if(!TextUtils.isEmpty(task.getValue(Task.NOTES))) {
|
||||
TextView note = new TextView(this);
|
||||
note.setText(task.getValue(Task.NOTES));
|
||||
Linkify.addLinks(note, Linkify.ALL);
|
||||
note.setPadding(0, 0, 0, 10);
|
||||
scrollViewBody.addView(note);
|
||||
}
|
||||
|
||||
TodorooCursor<Metadata> cursor = PluginServices.getMetadataService().query(
|
||||
Query.select(Metadata.PROPERTIES).where(
|
||||
MetadataCriteria.byTaskAndwithKey(task.getId(),
|
||||
NoteMetadata.METADATA_KEY)).orderBy(Order.desc(Metadata.CREATION_DATE)));
|
||||
Metadata metadata = new Metadata();
|
||||
try {
|
||||
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
||||
metadata.readFromCursor(cursor);
|
||||
|
||||
TextView title = new TextView(this);
|
||||
title.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
title.setText(metadata.getValue(NoteMetadata.TITLE));
|
||||
scrollViewBody.addView(title);
|
||||
|
||||
TextView note = new TextView(this);
|
||||
note.setText(metadata.getValue(NoteMetadata.BODY));
|
||||
Linkify.addLinks(note, Linkify.ALL);
|
||||
note.setPadding(0, 0, 0, 10);
|
||||
scrollViewBody.addView(note);
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
Button ok = new Button(this);
|
||||
ok.setText(android.R.string.ok);
|
||||
ok.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
||||
LayoutParams.WRAP_CONTENT));
|
||||
ok.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
body.addView(ok);
|
||||
}
|
||||
}
|
||||
@ -1,54 +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.Intent;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.service.ContextManager;
|
||||
import com.todoroo.andlib.utility.Preferences;
|
||||
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(Preferences.getBoolean(R.string.p_showNotes, false))
|
||||
return null;
|
||||
|
||||
if(task == null || !NotesPlugin.hasNotes(task))
|
||||
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,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/background_gradient">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="100">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:text="@string/ENA_no_comments"
|
||||
style="@style/TextAppearance.TLA_NoItems" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!-- Footer -->
|
||||
<LinearLayout
|
||||
android:id="@+id/add_comment"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- Add Button -->
|
||||
<ImageButton android:id="@+id/commentButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/tango_chat"
|
||||
android:scaleType="fitCenter"/>
|
||||
|
||||
<!-- Comment Field -->
|
||||
<EditText android:id="@+id/commentField"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="100"
|
||||
android:hint="@string/TVA_add_comment"
|
||||
android:singleLine="true"
|
||||
android:autoText="true"
|
||||
android:capitalize="sentences"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue