diff --git a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java index f8876edc4..872ea242c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java @@ -21,7 +21,6 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.text.format.DateUtils; import android.text.util.Linkify; -import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; 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.StatisticsService; 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; -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 int commentItems = 10; private ImageButton pictureButton; - private Bitmap picture = null; + private Bitmap pendingCommentPicture = null; private final Fragment fragment; private final List listeners = new LinkedList(); @@ -97,7 +96,6 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen public EditNoteActivity(Fragment fragment, View parent, long t) { super(fragment.getActivity()); - Log.d("EditnoteActivity", "Contructor being called"); this.fragment = fragment; DependencyInjectionService.getInstance().inject(this); @@ -143,7 +141,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen private void setUpInterface() { - timerView = commentsBar.findViewById(R.id.timer_container); + timerView = commentsBar.findViewById(R.id.timer_button); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); commentField.setOnEditorActionListener(new OnEditorActionListener() { @@ -196,8 +194,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen final ClearImageCallback clearImage = new ClearImageCallback() { @Override public void clearImage() { - Log.e("Errrr EditNOtes activity", "Picture clear image called"); - picture = null; + pendingCommentPicture = null; pictureButton.setImageResource(R.drawable.camera_button); } }; @@ -205,7 +202,7 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen pictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (picture != null) + if (pendingCommentPicture != null) ActFmCameraModule.showPictureLauncher(fragment, clearImage); else ActFmCameraModule.showPictureLauncher(fragment, null); @@ -224,9 +221,6 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen loadingText = new TextView(getContext()); - for (UpdatesChangedListener l : listeners) { - l.updatesChanged(); - } } private void setUpListAdapter() { @@ -277,7 +271,6 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen this.addView(notesView); } - if ( items.size() > commentItems) { Button loadMore = new Button(getContext()); 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 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); else { commentPictureView.setVisibility(View.VISIBLE); @@ -398,11 +394,11 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen } 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.setValue(Update.MESSAGE, message); 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.CREATION_DATE, DateUtilities.now()); - Log.d("Add comment", "The picture is: " + picture); - if (picture != null) { + if (usePicture && pendingCommentPicture != null) { update.setValue(Update.PICTURE, Update.PICTURE_LOADING); } Flags.set(Flags.ACTFM_SUPPRESS_SYNC); updateDao.createNew(update); final long updateId = update.getId(); - final Bitmap tempPicture = picture; + final Bitmap tempPicture = usePicture ? pendingCommentPicture : null; new Thread() { @Override public void run() { actFmSyncService.pushUpdate(updateId, tempPicture); - Log.d("Run thread", "The picture is: " + picture); } }.start(); commentField.setText(""); //$NON-NLS-1$ - setUpListAdapter(); - picture = null; + pendingCommentPicture = usePicture ? null : pendingCommentPicture; pictureButton.setImageResource(R.drawable.camera_button); StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMMENT); + setUpListAdapter(); for (UpdatesChangedListener l : listeners) { l.commentAdded(); } @@ -463,11 +457,13 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen public static NoteOrUpdate fromMetadata(Metadata m) { if(!m.containsNonNullValue(NoteMetadata.THUMBNAIL)) 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), m.getValue(NoteMetadata.TITLE), m.getValue(NoteMetadata.BODY), - m.getValue(NoteMetadata.COMMENTPICTURE), + m.getValue(NoteMetadata.COMMENT_PICTURE), m.getValue(Metadata.CREATION_DATE)); } @@ -479,8 +475,10 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen String message = u.getValue(Update.MESSAGE); if(u.getValue(Update.ACTION_CODE).equals("task_comment")) description = message; - else if(!TextUtils.isEmpty(message)) + else if(!TextUtils.isEmpty(message) && !TextUtils.isEmpty(description)) description += " " + message; + else + description = message; String commentPicture = u.getValue(Update.PICTURE); return new NoteOrUpdate(user.optString("picture"), @@ -506,33 +504,34 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen } @Override - public void timerStarted(Task task) { - // TODO Auto-generated method stub - addComment(getContext().getString(R.string.TEA_timer_comment_started) + " " + DateUtilities.getTimeString(getContext(), new Date()), "task_started"); //$NON-NLS-1$ - + public void timerStarted(Task t) { + addComment(String.format("%s %s", //$NON-NLS-1$ + getContext().getString(R.string.TEA_timer_comment_started), + DateUtilities.getTimeString(getContext(), new Date())), + "task_started", //$NON-NLS-1$ + false); } @Override - public void timerStopped(Task task) { - // TODO Auto-generated method stub - String elapsedTime = DateUtils.formatElapsedTime(task.getValue(Task.ELAPSED_SECONDS)); - addComment(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$ - + public void timerStopped(Task t) { + String elapsedTime = DateUtils.formatElapsedTime(t.getValue(Task.ELAPSED_SECONDS)); + addComment(String.format("%s %s\n%s %s", //$NON-NLS-1$ + getContext().getString(R.string.TEA_timer_comment_stopped), + 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) { - Log.d("Activity result", "Called on camera for request code: " + requestCode); CameraResultCallback callback = new CameraResultCallback() { @Override public void handleCameraResult(Bitmap bitmap) { - picture = bitmap; - pictureButton.setImageBitmap(picture); - Log.d("Picture", "Picture = " + picture); + pendingCommentPicture = bitmap; + pictureButton.setImageBitmap(pendingCommentPicture); } }; diff --git a/astrid/plugin-src/com/todoroo/astrid/notes/NoteMetadata.java b/astrid/plugin-src/com/todoroo/astrid/notes/NoteMetadata.java index a8cf0be7d..90d61f43f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/notes/NoteMetadata.java +++ b/astrid/plugin-src/com/todoroo/astrid/notes/NoteMetadata.java @@ -24,7 +24,7 @@ public class NoteMetadata { public static final StringProperty THUMBNAIL = Metadata.VALUE3; /** note external id (use for your own purposes) */ - public static final StringProperty COMMENTPICTURE = Metadata.VALUE6; + public static final StringProperty COMMENT_PICTURE = Metadata.VALUE6; /** note external provider (use for your own purposes) */ public static final StringProperty EXT_PROVIDER = Metadata.VALUE4; diff --git a/astrid/plugin-src/com/todoroo/astrid/timers/TimerActionControlSet.java b/astrid/plugin-src/com/todoroo/astrid/timers/TimerActionControlSet.java index d4fed56e9..012e96651 100644 --- a/astrid/plugin-src/com/todoroo/astrid/timers/TimerActionControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/timers/TimerActionControlSet.java @@ -7,8 +7,8 @@ import android.app.Activity; import android.os.SystemClock; import android.view.View; import android.view.View.OnClickListener; -import android.widget.Button; import android.widget.Chronometer; +import android.widget.ImageButton; import com.timsu.astrid.R; import com.todoroo.andlib.utility.DateUtilities; @@ -17,21 +17,18 @@ import com.todoroo.astrid.helper.TaskEditControlSet; public class TimerActionControlSet extends TaskEditControlSet { - private final Button timerButton; + private final ImageButton timerButton; private final Chronometer chronometer; - private final View timerContainer; private boolean timerActive; private final Activity activity; private Task task; - private final List listeners = new LinkedList(); + private final List listeners = new LinkedList(); public TimerActionControlSet(Activity activity, View parent) { super(activity, -1); this.activity = activity; - timerButton = (Button) parent.findViewById(R.id.timer_button); - - timerContainer = (View) parent.findViewById(R.id.timer_container); - timerContainer.setOnClickListener(timerListener); + timerButton = (ImageButton) parent.findViewById(R.id.timer_button); + timerButton.setOnClickListener(timerListener); chronometer = new Chronometer(activity); } @@ -59,14 +56,14 @@ public class TimerActionControlSet extends TaskEditControlSet { @Override public void onClick(View v) { if (timerActive) { - TimerPlugin.updateTimer(activity, task, false); + // TimerPlugin.updateTimer(activity, task, false); - for(TimerStoppedListener listener : listeners) + for(TimerActionListener listener : listeners) listener.timerStopped(task); chronometer.stop(); } else { - TimerPlugin.updateTimer(activity, task, true); - for(TimerStoppedListener listener : listeners) + // TimerPlugin.updateTimer(activity, task, true); + for(TimerActionListener listener : listeners) listener.timerStarted(task); chronometer.start(); } @@ -100,16 +97,16 @@ public class TimerActionControlSet extends TaskEditControlSet { } } - public interface TimerStoppedListener { + public interface TimerActionListener { public void timerStopped(Task task); public void timerStarted(Task task); } - public void addListener(TimerStoppedListener listener) { + public void addListener(TimerActionListener listener) { this.listeners.add(listener); } - public void removeListener(TimerStoppedListener listener) { + public void removeListener(TimerActionListener listener) { if (listeners.contains(listener)) listeners.remove(listener); } diff --git a/astrid/plugin-src/com/todoroo/astrid/timers/TimerControlSet.java b/astrid/plugin-src/com/todoroo/astrid/timers/TimerControlSet.java index 6f2a424d1..b9d17e2ce 100644 --- a/astrid/plugin-src/com/todoroo/astrid/timers/TimerControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/timers/TimerControlSet.java @@ -7,7 +7,7 @@ import com.timsu.astrid.R; import com.todoroo.andlib.data.Property.IntegerProperty; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.helper.TaskEditControlSet; -import com.todoroo.astrid.timers.TimerActionControlSet.TimerStoppedListener; +import com.todoroo.astrid.timers.TimerActionControlSet.TimerActionListener; import com.todoroo.astrid.ui.PopupControlSet; import com.todoroo.astrid.ui.TimeDurationControlSet; @@ -17,7 +17,7 @@ import com.todoroo.astrid.ui.TimeDurationControlSet; * @author Tim Su * */ -public class TimerControlSet extends PopupControlSet implements TimerStoppedListener { +public class TimerControlSet extends PopupControlSet implements TimerActionListener { TaskEditControlSet estimated, elapsed; diff --git a/astrid/res/layout/task_adapter_row.xml b/astrid/res/layout/task_adapter_row.xml index 4d615b2ab..ebe1f3efb 100644 --- a/astrid/res/layout/task_adapter_row.xml +++ b/astrid/res/layout/task_adapter_row.xml @@ -39,9 +39,9 @@ android:id="@+id/completeBox" android:layout_width="45dip" android:layout_height="fill_parent" + android:scaleType="fitCenter" android:layout_alignParentTop="true" - android:layout_marginLeft="10dip" - android:button="@drawable/btn_check" /> + android:layout_marginLeft="12dip" /> diff --git a/astrid/res/layout/task_edit_activity.xml b/astrid/res/layout/task_edit_activity.xml index 2998e0f68..f63f83538 100644 --- a/astrid/res/layout/task_edit_activity.xml +++ b/astrid/res/layout/task_edit_activity.xml @@ -9,10 +9,10 @@ + android:layout_weight="100" > - + + android:visibility="gone" > + + android:src="@android:drawable/ic_menu_close_clear_cancel" /> + + android:src="@android:drawable/ic_menu_save" /> - @@ -79,19 +81,18 @@ android:gravity="center" android:text="@string/TEA_more" android:textStyle="bold" /> - - + android:visibility="gone" > + - @@ -118,10 +118,10 @@ @@ -135,11 +135,11 @@ android:layout_gravity="top" android:layout_marginRight="3dip" android:layout_weight="1" + android:background="#00000000" android:paddingBottom="2dip" android:paddingLeft="7dip" android:paddingRight="7dip" android:scaleType="centerInside" - android:background="#00000000" android:src="@drawable/camera_button" /> @@ -148,47 +148,39 @@ android:id="@+id/commentField" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="1dip" android:layout_marginLeft="1dip" - android:paddingLeft="10dip" + android:layout_marginRight="1dip" android:layout_weight="100" android:autoText="true" android:background="@drawable/footer_comment_edittext" android:capitalize="sentences" android:hint="@string/TVA_add_comment" + android:paddingLeft="10dip" android:textSize="16sp" /> - -