|
|
@ -21,7 +21,6 @@ import android.text.TextUtils;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.format.DateUtils;
|
|
|
|
import android.text.format.DateUtils;
|
|
|
|
import android.text.util.Linkify;
|
|
|
|
import android.text.util.Linkify;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
@ -58,10 +57,10 @@ import com.todoroo.astrid.service.MetadataService;
|
|
|
|
import com.todoroo.astrid.service.StatisticsConstants;
|
|
|
|
import com.todoroo.astrid.service.StatisticsConstants;
|
|
|
|
import com.todoroo.astrid.service.StatisticsService;
|
|
|
|
import com.todoroo.astrid.service.StatisticsService;
|
|
|
|
import com.todoroo.astrid.service.SyncV2Service.SyncResultCallback;
|
|
|
|
import com.todoroo.astrid.service.SyncV2Service.SyncResultCallback;
|
|
|
|
import com.todoroo.astrid.timers.TimerActionControlSet.TimerStoppedListener;
|
|
|
|
import com.todoroo.astrid.timers.TimerActionControlSet.TimerActionListener;
|
|
|
|
import com.todoroo.astrid.utility.Flags;
|
|
|
|
import com.todoroo.astrid.utility.Flags;
|
|
|
|
|
|
|
|
|
|
|
|
public class EditNoteActivity extends LinearLayout implements TimerStoppedListener {
|
|
|
|
public class EditNoteActivity extends LinearLayout implements TimerActionListener {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,7 +83,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
private View commentButton;
|
|
|
|
private View commentButton;
|
|
|
|
private int commentItems = 10;
|
|
|
|
private int commentItems = 10;
|
|
|
|
private ImageButton pictureButton;
|
|
|
|
private ImageButton pictureButton;
|
|
|
|
private Bitmap picture = null;
|
|
|
|
private Bitmap pendingCommentPicture = null;
|
|
|
|
private final Fragment fragment;
|
|
|
|
private final Fragment fragment;
|
|
|
|
|
|
|
|
|
|
|
|
private final List<UpdatesChangedListener> listeners = new LinkedList<UpdatesChangedListener>();
|
|
|
|
private final List<UpdatesChangedListener> listeners = new LinkedList<UpdatesChangedListener>();
|
|
|
@ -97,7 +96,6 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
public EditNoteActivity(Fragment fragment, View parent, long t) {
|
|
|
|
public EditNoteActivity(Fragment fragment, View parent, long t) {
|
|
|
|
super(fragment.getActivity());
|
|
|
|
super(fragment.getActivity());
|
|
|
|
|
|
|
|
|
|
|
|
Log.d("EditnoteActivity", "Contructor being called");
|
|
|
|
|
|
|
|
this.fragment = fragment;
|
|
|
|
this.fragment = fragment;
|
|
|
|
|
|
|
|
|
|
|
|
DependencyInjectionService.getInstance().inject(this);
|
|
|
|
DependencyInjectionService.getInstance().inject(this);
|
|
|
@ -143,7 +141,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
private void setUpInterface() {
|
|
|
|
private void setUpInterface() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timerView = commentsBar.findViewById(R.id.timer_container);
|
|
|
|
timerView = commentsBar.findViewById(R.id.timer_button);
|
|
|
|
commentButton = commentsBar.findViewById(R.id.commentButton);
|
|
|
|
commentButton = commentsBar.findViewById(R.id.commentButton);
|
|
|
|
commentField = (EditText) commentsBar.findViewById(R.id.commentField);
|
|
|
|
commentField = (EditText) commentsBar.findViewById(R.id.commentField);
|
|
|
|
commentField.setOnEditorActionListener(new OnEditorActionListener() {
|
|
|
|
commentField.setOnEditorActionListener(new OnEditorActionListener() {
|
|
|
@ -196,8 +194,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
final ClearImageCallback clearImage = new ClearImageCallback() {
|
|
|
|
final ClearImageCallback clearImage = new ClearImageCallback() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void clearImage() {
|
|
|
|
public void clearImage() {
|
|
|
|
Log.e("Errrr EditNOtes activity", "Picture clear image called");
|
|
|
|
pendingCommentPicture = null;
|
|
|
|
picture = null;
|
|
|
|
|
|
|
|
pictureButton.setImageResource(R.drawable.camera_button);
|
|
|
|
pictureButton.setImageResource(R.drawable.camera_button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -205,7 +202,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
pictureButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
pictureButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
if (picture != null)
|
|
|
|
if (pendingCommentPicture != null)
|
|
|
|
ActFmCameraModule.showPictureLauncher(fragment, clearImage);
|
|
|
|
ActFmCameraModule.showPictureLauncher(fragment, clearImage);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActFmCameraModule.showPictureLauncher(fragment, null);
|
|
|
|
ActFmCameraModule.showPictureLauncher(fragment, null);
|
|
|
@ -224,9 +221,6 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
loadingText = new TextView(getContext());
|
|
|
|
loadingText = new TextView(getContext());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (UpdatesChangedListener l : listeners) {
|
|
|
|
|
|
|
|
l.updatesChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setUpListAdapter() {
|
|
|
|
private void setUpListAdapter() {
|
|
|
@ -277,7 +271,6 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
this.addView(notesView);
|
|
|
|
this.addView(notesView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( items.size() > commentItems) {
|
|
|
|
if ( items.size() > commentItems) {
|
|
|
|
Button loadMore = new Button(getContext());
|
|
|
|
Button loadMore = new Button(getContext());
|
|
|
|
loadMore.setText(R.string.TEA_load_more);
|
|
|
|
loadMore.setText(R.string.TEA_load_more);
|
|
|
@ -303,6 +296,9 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (UpdatesChangedListener l : listeners) {
|
|
|
|
|
|
|
|
l.updatesChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -347,7 +343,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
|
|
|
|
|
|
|
|
// picture
|
|
|
|
// picture
|
|
|
|
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); {
|
|
|
|
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); {
|
|
|
|
if(TextUtils.isEmpty(item.commentPicture))
|
|
|
|
if(TextUtils.isEmpty(item.commentPicture) || item.commentPicture.equals("null")) //$NON-NLS-1$
|
|
|
|
commentPictureView.setVisibility(View.GONE);
|
|
|
|
commentPictureView.setVisibility(View.GONE);
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
commentPictureView.setVisibility(View.VISIBLE);
|
|
|
|
commentPictureView.setVisibility(View.VISIBLE);
|
|
|
@ -398,11 +394,11 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void addComment() {
|
|
|
|
private void addComment() {
|
|
|
|
addComment(commentField.getText().toString(), "task_comment"); //$NON-NLS-1$
|
|
|
|
addComment(commentField.getText().toString(), "task_comment", true); //$NON-NLS-1$
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addComment(String message, String actionCode) {
|
|
|
|
private void addComment(String message, String actionCode, boolean usePicture) {
|
|
|
|
Update update = new Update();
|
|
|
|
Update update = new Update();
|
|
|
|
update.setValue(Update.MESSAGE, message);
|
|
|
|
update.setValue(Update.MESSAGE, message);
|
|
|
|
update.setValue(Update.ACTION_CODE, actionCode);
|
|
|
|
update.setValue(Update.ACTION_CODE, actionCode);
|
|
|
@ -410,30 +406,28 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
update.setValue(Update.TASK, task.getValue(Task.REMOTE_ID));
|
|
|
|
update.setValue(Update.TASK, task.getValue(Task.REMOTE_ID));
|
|
|
|
update.setValue(Update.CREATION_DATE, DateUtilities.now());
|
|
|
|
update.setValue(Update.CREATION_DATE, DateUtilities.now());
|
|
|
|
|
|
|
|
|
|
|
|
Log.d("Add comment", "The picture is: " + picture);
|
|
|
|
if (usePicture && pendingCommentPicture != null) {
|
|
|
|
if (picture != null) {
|
|
|
|
|
|
|
|
update.setValue(Update.PICTURE, Update.PICTURE_LOADING);
|
|
|
|
update.setValue(Update.PICTURE, Update.PICTURE_LOADING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
updateDao.createNew(update);
|
|
|
|
updateDao.createNew(update);
|
|
|
|
|
|
|
|
|
|
|
|
final long updateId = update.getId();
|
|
|
|
final long updateId = update.getId();
|
|
|
|
final Bitmap tempPicture = picture;
|
|
|
|
final Bitmap tempPicture = usePicture ? pendingCommentPicture : null;
|
|
|
|
new Thread() {
|
|
|
|
new Thread() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
actFmSyncService.pushUpdate(updateId, tempPicture);
|
|
|
|
actFmSyncService.pushUpdate(updateId, tempPicture);
|
|
|
|
|
|
|
|
|
|
|
|
Log.d("Run thread", "The picture is: " + picture);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
}.start();
|
|
|
|
commentField.setText(""); //$NON-NLS-1$
|
|
|
|
commentField.setText(""); //$NON-NLS-1$
|
|
|
|
setUpListAdapter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
picture = null;
|
|
|
|
pendingCommentPicture = usePicture ? null : pendingCommentPicture;
|
|
|
|
pictureButton.setImageResource(R.drawable.camera_button);
|
|
|
|
pictureButton.setImageResource(R.drawable.camera_button);
|
|
|
|
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMMENT);
|
|
|
|
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMMENT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setUpListAdapter();
|
|
|
|
for (UpdatesChangedListener l : listeners) {
|
|
|
|
for (UpdatesChangedListener l : listeners) {
|
|
|
|
l.commentAdded();
|
|
|
|
l.commentAdded();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -463,11 +457,13 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
public static NoteOrUpdate fromMetadata(Metadata m) {
|
|
|
|
public static NoteOrUpdate fromMetadata(Metadata m) {
|
|
|
|
if(!m.containsNonNullValue(NoteMetadata.THUMBNAIL))
|
|
|
|
if(!m.containsNonNullValue(NoteMetadata.THUMBNAIL))
|
|
|
|
m.setValue(NoteMetadata.THUMBNAIL, ""); //$NON-NLS-1$
|
|
|
|
m.setValue(NoteMetadata.THUMBNAIL, ""); //$NON-NLS-1$
|
|
|
|
|
|
|
|
if(!m.containsNonNullValue(NoteMetadata.COMMENT_PICTURE))
|
|
|
|
|
|
|
|
m.setValue(NoteMetadata.COMMENT_PICTURE, ""); //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL),
|
|
|
|
return new NoteOrUpdate(m.getValue(NoteMetadata.THUMBNAIL),
|
|
|
|
m.getValue(NoteMetadata.TITLE),
|
|
|
|
m.getValue(NoteMetadata.TITLE),
|
|
|
|
m.getValue(NoteMetadata.BODY),
|
|
|
|
m.getValue(NoteMetadata.BODY),
|
|
|
|
m.getValue(NoteMetadata.COMMENTPICTURE),
|
|
|
|
m.getValue(NoteMetadata.COMMENT_PICTURE),
|
|
|
|
m.getValue(Metadata.CREATION_DATE));
|
|
|
|
m.getValue(Metadata.CREATION_DATE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -479,8 +475,10 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
String message = u.getValue(Update.MESSAGE);
|
|
|
|
String message = u.getValue(Update.MESSAGE);
|
|
|
|
if(u.getValue(Update.ACTION_CODE).equals("task_comment"))
|
|
|
|
if(u.getValue(Update.ACTION_CODE).equals("task_comment"))
|
|
|
|
description = message;
|
|
|
|
description = message;
|
|
|
|
else if(!TextUtils.isEmpty(message))
|
|
|
|
else if(!TextUtils.isEmpty(message) && !TextUtils.isEmpty(description))
|
|
|
|
description += " " + message;
|
|
|
|
description += " " + message;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
description = message;
|
|
|
|
String commentPicture = u.getValue(Update.PICTURE);
|
|
|
|
String commentPicture = u.getValue(Update.PICTURE);
|
|
|
|
|
|
|
|
|
|
|
|
return new NoteOrUpdate(user.optString("picture"),
|
|
|
|
return new NoteOrUpdate(user.optString("picture"),
|
|
|
@ -506,33 +504,34 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void timerStarted(Task task) {
|
|
|
|
public void timerStarted(Task t) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
addComment(String.format("%s %s", //$NON-NLS-1$
|
|
|
|
addComment(getContext().getString(R.string.TEA_timer_comment_started) + " " + DateUtilities.getTimeString(getContext(), new Date()), "task_started"); //$NON-NLS-1$
|
|
|
|
getContext().getString(R.string.TEA_timer_comment_started),
|
|
|
|
|
|
|
|
DateUtilities.getTimeString(getContext(), new Date())),
|
|
|
|
|
|
|
|
"task_started", //$NON-NLS-1$
|
|
|
|
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void timerStopped(Task task) {
|
|
|
|
public void timerStopped(Task t) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
String elapsedTime = DateUtils.formatElapsedTime(t.getValue(Task.ELAPSED_SECONDS));
|
|
|
|
String elapsedTime = DateUtils.formatElapsedTime(task.getValue(Task.ELAPSED_SECONDS));
|
|
|
|
addComment(String.format("%s %s\n%s %s", //$NON-NLS-1$
|
|
|
|
addComment(getContext().getString(R.string.TEA_timer_comment_stopped) + " " +
|
|
|
|
getContext().getString(R.string.TEA_timer_comment_stopped),
|
|
|
|
DateUtilities.getTimeString(getContext(), new Date()) + "\n" + getContext().getString(R.string.TEA_timer_comment_spent) + " " + elapsedTime, "task_stopped"); //$NON-NLS-1$
|
|
|
|
DateUtilities.getTimeString(getContext(), new Date()),
|
|
|
|
|
|
|
|
getContext().getString(R.string.TEA_timer_comment_spent),
|
|
|
|
|
|
|
|
elapsedTime), "task_stopped", false); //$NON-NLS-1$
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Callback from edittask when picture is added
|
|
|
|
* Call back from edit task when picture is added
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean activityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
public boolean activityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
|
|
|
|
|
|
|
Log.d("Activity result", "Called on camera for request code: " + requestCode);
|
|
|
|
|
|
|
|
CameraResultCallback callback = new CameraResultCallback() {
|
|
|
|
CameraResultCallback callback = new CameraResultCallback() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void handleCameraResult(Bitmap bitmap) {
|
|
|
|
public void handleCameraResult(Bitmap bitmap) {
|
|
|
|
picture = bitmap;
|
|
|
|
pendingCommentPicture = bitmap;
|
|
|
|
pictureButton.setImageBitmap(picture);
|
|
|
|
pictureButton.setImageBitmap(pendingCommentPicture);
|
|
|
|
Log.d("Picture", "Picture = " + picture);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|