Task timer should add to your activity stream

pull/14/head
Andrew Shaw 13 years ago
parent 2c9e4126bc
commit 554690d3bb

@ -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,19 +504,22 @@ 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$
} }
/* /*
@ -526,13 +527,11 @@ public class EditNoteActivity extends LinearLayout implements TimerStoppedListen
*/ */
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);
} }
}; };

@ -24,7 +24,7 @@ public class NoteMetadata {
public static final StringProperty THUMBNAIL = Metadata.VALUE3; public static final StringProperty THUMBNAIL = Metadata.VALUE3;
/** note external id (use for your own purposes) */ /** 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) */ /** note external provider (use for your own purposes) */
public static final StringProperty EXT_PROVIDER = Metadata.VALUE4; public static final StringProperty EXT_PROVIDER = Metadata.VALUE4;

@ -7,8 +7,8 @@ import android.app.Activity;
import android.os.SystemClock; import android.os.SystemClock;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Chronometer; import android.widget.Chronometer;
import android.widget.ImageButton;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
@ -17,21 +17,18 @@ import com.todoroo.astrid.helper.TaskEditControlSet;
public class TimerActionControlSet extends TaskEditControlSet { public class TimerActionControlSet extends TaskEditControlSet {
private final Button timerButton; private final ImageButton timerButton;
private final Chronometer chronometer; private final Chronometer chronometer;
private final View timerContainer;
private boolean timerActive; private boolean timerActive;
private final Activity activity; private final Activity activity;
private Task task; private Task task;
private final List<TimerStoppedListener> listeners = new LinkedList<TimerStoppedListener>(); private final List<TimerActionListener> listeners = new LinkedList<TimerActionListener>();
public TimerActionControlSet(Activity activity, View parent) { public TimerActionControlSet(Activity activity, View parent) {
super(activity, -1); super(activity, -1);
this.activity = activity; this.activity = activity;
timerButton = (Button) parent.findViewById(R.id.timer_button); timerButton = (ImageButton) parent.findViewById(R.id.timer_button);
timerButton.setOnClickListener(timerListener);
timerContainer = (View) parent.findViewById(R.id.timer_container);
timerContainer.setOnClickListener(timerListener);
chronometer = new Chronometer(activity); chronometer = new Chronometer(activity);
} }
@ -59,14 +56,14 @@ public class TimerActionControlSet extends TaskEditControlSet {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (timerActive) { if (timerActive) {
TimerPlugin.updateTimer(activity, task, false); // TimerPlugin.updateTimer(activity, task, false);
for(TimerStoppedListener listener : listeners) for(TimerActionListener listener : listeners)
listener.timerStopped(task); listener.timerStopped(task);
chronometer.stop(); chronometer.stop();
} else { } else {
TimerPlugin.updateTimer(activity, task, true); // TimerPlugin.updateTimer(activity, task, true);
for(TimerStoppedListener listener : listeners) for(TimerActionListener listener : listeners)
listener.timerStarted(task); listener.timerStarted(task);
chronometer.start(); chronometer.start();
} }
@ -100,16 +97,16 @@ public class TimerActionControlSet extends TaskEditControlSet {
} }
} }
public interface TimerStoppedListener { public interface TimerActionListener {
public void timerStopped(Task task); public void timerStopped(Task task);
public void timerStarted(Task task); public void timerStarted(Task task);
} }
public void addListener(TimerStoppedListener listener) { public void addListener(TimerActionListener listener) {
this.listeners.add(listener); this.listeners.add(listener);
} }
public void removeListener(TimerStoppedListener listener) { public void removeListener(TimerActionListener listener) {
if (listeners.contains(listener)) if (listeners.contains(listener))
listeners.remove(listener); listeners.remove(listener);
} }

@ -7,7 +7,7 @@ import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.IntegerProperty; import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.helper.TaskEditControlSet; 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.PopupControlSet;
import com.todoroo.astrid.ui.TimeDurationControlSet; import com.todoroo.astrid.ui.TimeDurationControlSet;
@ -17,7 +17,7 @@ import com.todoroo.astrid.ui.TimeDurationControlSet;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
public class TimerControlSet extends PopupControlSet implements TimerStoppedListener { public class TimerControlSet extends PopupControlSet implements TimerActionListener {
TaskEditControlSet estimated, elapsed; TaskEditControlSet estimated, elapsed;

@ -39,9 +39,9 @@
android:id="@+id/completeBox" android:id="@+id/completeBox"
android:layout_width="45dip" android:layout_width="45dip"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginLeft="10dip" android:layout_marginLeft="12dip" />
android:button="@drawable/btn_check" />
<!-- assignee photo --> <!-- assignee photo -->

@ -9,10 +9,10 @@
<ScrollView <ScrollView
android:id="@+id/edit_scroll" android:id="@+id/edit_scroll"
style="@style/Content_EditScroll"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_weight="100" android:layout_weight="100" >
style="@style/Content_EditScroll" >
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -22,11 +22,11 @@
<LinearLayout <LinearLayout
android:id="@+id/title_controls" android:id="@+id/title_controls"
style="@style/EditRow"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dip" android:layout_margin="3dip"
android:gravity="center_vertical" android:gravity="center_vertical"
style="@style/EditRow"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingRight="6dip" > android:paddingRight="6dip" >
@ -36,6 +36,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone" > android:visibility="gone" >
<ImageButton <ImageButton
android:id="@+id/cancel" android:id="@+id/cancel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -43,6 +44,7 @@
android:layout_marginRight="10dip" android:layout_marginRight="10dip"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:src="@android:drawable/ic_menu_close_clear_cancel" /> android:src="@android:drawable/ic_menu_close_clear_cancel" />
<ImageButton <ImageButton
android:id="@+id/save" android:id="@+id/save"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -54,20 +56,20 @@
<LinearLayout <LinearLayout
android:id="@+id/basic_controls" android:id="@+id/basic_controls"
style="@style/EditRow"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_margin="3dip" android:layout_margin="3dip"
android:layout_marginTop="10dip" android:layout_marginTop="10dip"
style="@style/EditRow"
android:orientation="vertical" > android:orientation="vertical" >
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/more_header" android:id="@+id/more_header"
style="@style/EditRow"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:orientation="vertical"
style="@style/EditRow"
android:visibility="gone" > android:visibility="gone" >
- -
@ -79,16 +81,15 @@
android:gravity="center" android:gravity="center"
android:text="@string/TEA_more" android:text="@string/TEA_more"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/more_container" android:id="@+id/more_container"
style="@style/EditRow"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dip" android:layout_margin="3dip"
android:layout_marginBottom="0dip" android:layout_marginBottom="0dip"
style="@style/EditRow"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" > android:visibility="gone" >
@ -109,7 +110,6 @@
android:id="@+id/pager" android:id="@+id/pager"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
@ -118,10 +118,10 @@
<LinearLayout <LinearLayout
android:id="@+id/updatesFooter" android:id="@+id/updatesFooter"
style="@style/Content"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
style="@style/Content"
android:minHeight="47dip" android:minHeight="47dip"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="3dip" > android:padding="3dip" >
@ -135,11 +135,11 @@
android:layout_gravity="top" android:layout_gravity="top"
android:layout_marginRight="3dip" android:layout_marginRight="3dip"
android:layout_weight="1" android:layout_weight="1"
android:background="#00000000"
android:paddingBottom="2dip" android:paddingBottom="2dip"
android:paddingLeft="7dip" android:paddingLeft="7dip"
android:paddingRight="7dip" android:paddingRight="7dip"
android:scaleType="centerInside" android:scaleType="centerInside"
android:background="#00000000"
android:src="@drawable/camera_button" /> android:src="@drawable/camera_button" />
<!-- Quick Add Task --> <!-- Quick Add Task -->
@ -148,47 +148,39 @@
android:id="@+id/commentField" android:id="@+id/commentField"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="1dip"
android:layout_marginLeft="1dip" android:layout_marginLeft="1dip"
android:paddingLeft="10dip" android:layout_marginRight="1dip"
android:layout_weight="100" android:layout_weight="100"
android:autoText="true" android:autoText="true"
android:background="@drawable/footer_comment_edittext" android:background="@drawable/footer_comment_edittext"
android:capitalize="sentences" android:capitalize="sentences"
android:hint="@string/TVA_add_comment" android:hint="@string/TVA_add_comment"
android:paddingLeft="10dip"
android:textSize="16sp" /> android:textSize="16sp" />
<!-- Extended Add Button --> <!-- Extended Add Button -->
<LinearLayout <ImageButton
android:id="@+id/timer_container" android:id="@+id/timer_button"
android:layout_width="35dip" android:layout_width="35dip"
android:layout_height="35dip" android:layout_height="35dip"
android:layout_marginLeft="3dip" android:layout_marginLeft="3dip"
android:orientation="vertical" android:layout_marginTop="3dip"
android:layout_weight="1"> android:padding="7dip"
<Button
android:id="@+id/timer_button"
android:layout_width="30dip"
android:layout_height="25dip"
android:layout_marginTop="7dip"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:layout_weight="1"/> android:layout_weight="1"/>
</LinearLayout>
<ImageButton <ImageButton
android:id="@+id/commentButton" android:id="@+id/commentButton"
android:layout_width="35dip" android:layout_width="39dip"
android:layout_height="35dip" android:layout_height="39dip"
android:layout_gravity="top" android:layout_gravity="top"
android:layout_marginRight="3dip" android:layout_marginRight="3dip"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/footer_button" android:background="?attr/asAddButtonImg"
android:scaleType="center" android:scaleType="center"
android:visibility="gone" android:visibility="gone" />
android:src="@drawable/ic_footer_add" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

@ -56,6 +56,7 @@
android:paddingTop="5dip" android:paddingTop="5dip"
astrid:defaultSrc="@drawable/icn_default_person_image" astrid:defaultSrc="@drawable/icn_default_person_image"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:layout_marginLeft="50dip"
android:visibility="gone" /> android:visibility="gone" />
<!-- activity date --> <!-- activity date -->

@ -34,6 +34,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.speech.RecognizerIntent; import android.speech.RecognizerIntent;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.SupportActivity; import android.support.v4.app.SupportActivity;
@ -212,6 +213,16 @@ public final class TaskEditActivity extends Fragment implements
private TaskEditViewPager mAdapter; private TaskEditViewPager mAdapter;
private TabPageIndicator mIndicator; private TabPageIndicator mIndicator;
private final Runnable refreshActivity = new Runnable()
{
@Override
public void run()
{
//Change state here
setPagerHeightForPosition(TAB_VIEW_UPDATES);
}
};
private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>()); private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>());
// --- other instance variables // --- other instance variables
@ -377,11 +388,6 @@ public final class TaskEditActivity extends Fragment implements
mAdapter = new TaskEditViewPager(getActivity()); mAdapter = new TaskEditViewPager(getActivity());
mAdapter.parent = this; mAdapter.parent = this;
editNotes = new EditNoteActivity(this, getView(),
idParam);
editNotes.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
mPager = (ViewPager) getView().findViewById(R.id.pager); mPager = (ViewPager) getView().findViewById(R.id.pager);
mPager.setAdapter(mAdapter); mPager.setAdapter(mAdapter);
@ -393,7 +399,9 @@ public final class TaskEditActivity extends Fragment implements
if (editNotes.numberOfComments() == 0) { if (editNotes.numberOfComments() == 0) {
setCurrentTab(TAB_VIEW_MORE); setCurrentTab(TAB_VIEW_MORE);
} else { } else {
setPagerHeightForPosition(TAB_VIEW_UPDATES); Handler refreshHandler = new Handler();
refreshHandler.postDelayed(refreshActivity, 1000);
} }
editNotes.addListener(this); editNotes.addListener(this);
} }
@ -1155,6 +1163,7 @@ public final class TaskEditActivity extends Fragment implements
private void setPagerHeightForPosition(int position) { private void setPagerHeightForPosition(int position) {
int height = 0; int height = 0;
View view = (position == TAB_VIEW_MORE) ? moreControls : editNotes; View view = (position == TAB_VIEW_MORE) ? moreControls : editNotes;
if (view == null || mPager == null) return;
int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(), int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(),
MeasureSpec.AT_MOST); MeasureSpec.AT_MOST);

@ -122,8 +122,8 @@ import com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough;
import com.todoroo.astrid.widget.TasksWidget; import com.todoroo.astrid.widget.TasksWidget;
/** /**
* Primary activity for the Bente application. Shows a list of upcoming * Primary activity for the Bente application. Shows a list of upcoming tasks
* tasks and a user's coaches. * and a user's coaches.
* *
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
@ -171,26 +171,33 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
// --- instance variables // --- instance variables
@Autowired ExceptionService exceptionService; @Autowired
ExceptionService exceptionService;
@Autowired protected TaskService taskService; @Autowired
protected TaskService taskService;
@Autowired MetadataService metadataService; @Autowired
MetadataService metadataService;
@Autowired Database database; @Autowired
Database database;
@Autowired AddOnService addOnService; @Autowired
AddOnService addOnService;
@Autowired UpgradeService upgradeService; @Autowired
UpgradeService upgradeService;
@Autowired protected SyncV2Service syncService; @Autowired
protected SyncV2Service syncService;
@Autowired TagDataService tagDataService; @Autowired
TagDataService tagDataService;
private final TaskContextActionExposer[] contextItemExposers = new TaskContextActionExposer[] { private final TaskContextActionExposer[] contextItemExposers = new TaskContextActionExposer[] {
new ReminderDebugContextActions.MakeNotification(), new ReminderDebugContextActions.MakeNotification(),
new ReminderDebugContextActions.WhenReminder(), new ReminderDebugContextActions.WhenReminder(), };
};
protected TaskAdapter taskAdapter = null; protected TaskAdapter taskAdapter = null;
protected DetailReceiver detailReceiver = new DetailReceiver(); protected DetailReceiver detailReceiver = new DetailReceiver();
@ -218,16 +225,19 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
OnTaskListItemClickedListener mListener; OnTaskListItemClickedListener mListener;
private boolean mDualFragments = false; private boolean mDualFragments = false;
/* ====================================================================== /*
* ======================================================================
* ======================================================= initialization * ======================================================= initialization
* ====================================================================== */ * ======================================================================
*/
static { static {
AstridDependencyInjector.initialize(); AstridDependencyInjector.initialize();
} }
/** Container Activity must implement this interface and we ensure /**
* that it does during the onAttach() callback * Container Activity must implement this interface and we ensure that it
* does during the onAttach() callback
*/ */
public interface OnTaskListItemClickedListener { public interface OnTaskListItemClickedListener {
public void onTaskListItemClicked(long taskId); public void onTaskListItemClicked(long taskId);
@ -236,7 +246,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
@Override @Override
public void onAttach(SupportActivity activity) { public void onAttach(SupportActivity activity) {
super.onAttach(activity); super.onAttach(activity);
// Check that the container activity has implemented the callback interface // Check that the container activity has implemented the callback
// interface
try { try {
mListener = (OnTaskListItemClickedListener) activity; mListener = (OnTaskListItemClickedListener) activity;
} catch (ClassCastException e) { } catch (ClassCastException e) {
@ -252,9 +263,11 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
*/ */
protected View getListBody(ViewGroup root) { protected View getListBody(ViewGroup root) {
if (AndroidUtilities.getSdkVersion() > 3) if (AndroidUtilities.getSdkVersion() > 3)
return getActivity().getLayoutInflater().inflate(R.layout.task_list_body_standard, root, false); return getActivity().getLayoutInflater().inflate(
R.layout.task_list_body_standard, root, false);
else else
return getActivity().getLayoutInflater().inflate(R.layout.task_list_body_api3, root, false); return getActivity().getLayoutInflater().inflate(
R.layout.task_list_body_api3, root, false);
} }
/** Called when loading up the activity */ /** Called when loading up the activity */
@ -275,9 +288,12 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
database.openForWriting(); database.openForWriting();
} }
/*
/* (non-Javadoc) * (non-Javadoc)
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) *
* @see
* android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
* android.view.ViewGroup, android.os.Bundle)
*/ */
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -298,8 +314,10 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
setUpUiComponents(); setUpUiComponents();
onNewIntent(getActivity().getIntent()); onNewIntent(getActivity().getIntent());
Fragment filterlistFrame = getFragmentManager().findFragmentByTag(FilterListActivity.TAG_FILTERLIST_FRAGMENT); Fragment filterlistFrame = getFragmentManager().findFragmentByTag(
mDualFragments = (filterlistFrame != null) && filterlistFrame.isInLayout(); FilterListActivity.TAG_FILTERLIST_FRAGMENT);
mDualFragments = (filterlistFrame != null)
&& filterlistFrame.isInLayout();
if (mDualFragments) { if (mDualFragments) {
// In dual-pane mode, the list view highlights the selected item. // In dual-pane mode, the list view highlights the selected item.
@ -308,10 +326,12 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
if (Preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1) > -1) if (Preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1) > -1)
upgradeService.showChangeLog(getActivity(), Preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1)); upgradeService.showChangeLog(getActivity(),
Preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1));
if (getActivity().getIntent().hasExtra(TOKEN_SOURCE)) { if (getActivity().getIntent().hasExtra(TOKEN_SOURCE)) {
switch(getActivity().getIntent().getIntExtra(TOKEN_SOURCE, Constants.SOURCE_DEFAULT)) { switch (getActivity().getIntent().getIntExtra(TOKEN_SOURCE,
Constants.SOURCE_DEFAULT)) {
case Constants.SOURCE_NOTIFICATION: case Constants.SOURCE_NOTIFICATION:
StatisticsService.reportEvent(StatisticsConstants.LAUNCH_FROM_NOTIFICATION); StatisticsService.reportEvent(StatisticsConstants.LAUNCH_FROM_NOTIFICATION);
break; break;
@ -347,8 +367,10 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
String intentAction = intent.getAction(); String intentAction = intent.getAction();
if (Intent.ACTION_SEARCH.equals(intentAction)) { if (Intent.ACTION_SEARCH.equals(intentAction)) {
String query = intent.getStringExtra(SearchManager.QUERY).trim(); String query = intent.getStringExtra(SearchManager.QUERY).trim();
Filter searchFilter = new Filter(null, getString(R.string.FLA_search_filter, query), Filter searchFilter = new Filter(null, getString(
new QueryTemplate().where(Functions.upper(Task.TITLE).like("%" + //$NON-NLS-1$ R.string.FLA_search_filter, query),
new QueryTemplate().where(Functions.upper(Task.TITLE).like(
"%" + //$NON-NLS-1$
query.toUpperCase() + "%")), //$NON-NLS-1$ query.toUpperCase() + "%")), //$NON-NLS-1$
null); null);
intent = new Intent(getActivity(), TaskListWrapperActivity.class); intent = new Intent(getActivity(), TaskListWrapperActivity.class);
@ -356,7 +378,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
startActivity(intent); startActivity(intent);
getActivity().finish(); getActivity().finish();
if (overrideFinishAnim) { if (overrideFinishAnim) {
AndroidUtilities.callOverridePendingTransition(getActivity(), R.anim.slide_right_in, R.anim.slide_right_out); AndroidUtilities.callOverridePendingTransition(getActivity(),
R.anim.slide_right_in, R.anim.slide_right_out);
} }
return; return;
} else if (extras != null && extras.containsKey(TOKEN_FILTER)) { } else if (extras != null && extras.containsKey(TOKEN_FILTER)) {
@ -396,7 +419,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
MenuItem item; MenuItem item;
if (!(this instanceof DraggableTaskListActivity)) { if (!(this instanceof DraggableTaskListActivity)) {
item = menu.add(Menu.NONE, MENU_SORT_ID, Menu.NONE, R.string.TLA_menu_sort); item = menu.add(Menu.NONE, MENU_SORT_ID, Menu.NONE,
R.string.TLA_menu_sort);
item.setIcon(android.R.drawable.ic_menu_sort_by_size); item.setIcon(android.R.drawable.ic_menu_sort_by_size);
if (((AstridWrapperActivity) getActivity()).isMultipleFragments()) if (((AstridWrapperActivity) getActivity()).isMultipleFragments())
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
@ -419,10 +443,12 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
item.setIcon(android.R.drawable.ic_menu_preferences); item.setIcon(android.R.drawable.ic_menu_preferences);
// ask about plug-ins // ask about plug-ins
Intent queryIntent = new Intent(AstridApiConstants.ACTION_TASK_LIST_MENU); Intent queryIntent = new Intent(
AstridApiConstants.ACTION_TASK_LIST_MENU);
PackageManager pm = getActivity().getPackageManager(); PackageManager pm = getActivity().getPackageManager();
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent, 0); List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(
queryIntent, 0);
int length = resolveInfoList.size(); int length = resolveInfoList.size();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
ResolveInfo resolveInfo = resolveInfoList.get(i); ResolveInfo resolveInfo = resolveInfoList.get(i);
@ -449,7 +475,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
View selected = getListView().getSelectedView(); View selected = getListView().getSelectedView();
// hot-key to set task priority - 1-4 or ALT + Q-R // hot-key to set task priority - 1-4 or ALT + Q-R
if(!filterOn && event.getUnicodeChar() >= '1' && event.getUnicodeChar() <= '4' && selected != null) { if (!filterOn && event.getUnicodeChar() >= '1'
&& event.getUnicodeChar() <= '4' && selected != null) {
int importance = event.getNumber() - '1'; int importance = event.getNumber() - '1';
Task task = ((ViewHolder) selected.getTag()).task; Task task = ((ViewHolder) selected.getTag()).task;
task.setValue(Task.IMPORTANCE, importance); task.setValue(Task.IMPORTANCE, importance);
@ -459,10 +486,12 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
// filter // filter
else if (!filterOn && event.getUnicodeChar() != 0) { else if (!filterOn && event.getUnicodeChar() != 0) {
getListView().setTextFilterEnabled(true); getListView().setTextFilterEnabled(true);
getListView().setFilterText(Character.toString((char)event.getUnicodeChar())); getListView().setFilterText(
Character.toString((char) event.getUnicodeChar()));
} }
// turn off filter if nothing is selected // turn off filter if nothing is selected
else if(filterOn && TextUtils.isEmpty(getListView().getTextFilter())) { else if (filterOn
&& TextUtils.isEmpty(getListView().getTextFilter())) {
getListView().setTextFilterEnabled(false); getListView().setTextFilterEnabled(false);
} }
@ -477,8 +506,10 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
* When user presses enter, quick-add the task * When user presses enter, quick-add the task
*/ */
@Override @Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { public boolean onEditorAction(TextView view, int actionId,
if(actionId == EditorInfo.IME_NULL && !TextUtils.isEmpty(quickAddBox.getText().toString().trim())) { KeyEvent event) {
if (actionId == EditorInfo.IME_NULL
&& !TextUtils.isEmpty(quickAddBox.getText().toString().trim())) {
quickAddTask(quickAddBox.getText().toString(), true); quickAddTask(quickAddBox.getText().toString(), true);
return true; return true;
} }
@ -486,8 +517,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
}); });
quickAddButton = ((ImageButton) getView().findViewById(
quickAddButton = ((ImageButton)getView().findViewById(R.id.quickAddButton)); R.id.quickAddButton));
// set listener for quick add button // set listener for quick add button
quickAddButton.setOnClickListener(new OnClickListener() { quickAddButton.setOnClickListener(new OnClickListener() {
@ -500,18 +531,21 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
}); });
// prepare and set listener for voice add button // prepare and set listener for voice add button
voiceAddButton = (ImageButton) getView().findViewById(R.id.voiceAddButton); voiceAddButton = (ImageButton) getView().findViewById(
R.id.voiceAddButton);
int prompt = R.string.voice_edit_title_prompt; int prompt = R.string.voice_edit_title_prompt;
if (Preferences.getBoolean(R.string.p_voiceInputCreatesTask, false)) if (Preferences.getBoolean(R.string.p_voiceInputCreatesTask, false))
prompt = R.string.voice_create_prompt; prompt = R.string.voice_create_prompt;
voiceInputAssistant = new VoiceInputAssistant(getActivity(),voiceAddButton,quickAddBox); voiceInputAssistant = new VoiceInputAssistant(getActivity(),
voiceAddButton, quickAddBox);
voiceInputAssistant.configureMicrophoneButton(prompt); voiceInputAssistant.configureMicrophoneButton(prompt);
// set listener for extended addbutton // set listener for extended addbutton
quickAddButton.setOnLongClickListener(new OnLongClickListener() { quickAddButton.setOnLongClickListener(new OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
Task task = quickAddTask(quickAddBox.getText().toString(), false); Task task = quickAddTask(quickAddBox.getText().toString(),
false);
if (task == null) if (task == null)
return true; return true;
@ -528,10 +562,10 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
}); });
// gestures / animation // gestures / animation
try { try {
GestureService.registerGestureDetector(getActivity(), R.id.gestures, R.raw.gestures, this); GestureService.registerGestureDetector(getActivity(),
R.id.gestures, R.raw.gestures, this);
} catch (VerifyError e) { } catch (VerifyError e) {
// failed check, no gestures :P // failed check, no gestures :P
} }
@ -542,13 +576,16 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
// dithering // dithering
getActivity().getWindow().setFormat(PixelFormat.RGBA_8888); getActivity().getWindow().setFormat(PixelFormat.RGBA_8888);
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); getActivity().getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DITHER);
syncResultCallback = new ProgressBarSyncResultCallback(getActivity(), syncResultCallback = new ProgressBarSyncResultCallback(getActivity(),
R.id.progressBar, new Runnable() { R.id.progressBar, new Runnable() {
@Override @Override
public void run() { public void run() {
ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); ContextManager.getContext().sendBroadcast(
new Intent(
AstridApiConstants.BROADCAST_EVENT_REFRESH));
} }
}); });
} }
@ -562,7 +599,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
public void transitionForTaskEdit() { public void transitionForTaskEdit() {
AndroidUtilities.callOverridePendingTransition(getActivity(), R.anim.slide_left_in, R.anim.slide_left_out); AndroidUtilities.callOverridePendingTransition(getActivity(),
R.anim.slide_left_in, R.anim.slide_left_out);
} }
private void setUpBackgroundJobs() { private void setUpBackgroundJobs() {
@ -588,9 +626,11 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
}, BACKGROUND_REFRESH_INTERVAL, BACKGROUND_REFRESH_INTERVAL); }, BACKGROUND_REFRESH_INTERVAL, BACKGROUND_REFRESH_INTERVAL);
} }
/* ====================================================================== /*
* ======================================================================
* ============================================================ lifecycle * ============================================================ lifecycle
* ====================================================================== */ * ======================================================================
*/
@Override @Override
public void onStart() { public void onStart() {
@ -608,9 +648,9 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
super.onResume(); super.onResume();
StatisticsService.sessionStart(getActivity()); StatisticsService.sessionStart(getActivity());
if (addOnService.hasPowerPack() && if (addOnService.hasPowerPack()
Preferences.getBoolean(R.string.p_voiceInputEnabled, true) && && Preferences.getBoolean(R.string.p_voiceInputEnabled, true)
voiceInputAssistant.isVoiceInputAvailable()) { && voiceInputAssistant.isVoiceInputAvailable()) {
voiceAddButton.setVisibility(View.VISIBLE); voiceAddButton.setVisibility(View.VISIBLE);
} else { } else {
voiceAddButton.setVisibility(View.GONE); voiceAddButton.setVisibility(View.GONE);
@ -624,26 +664,34 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
new IntentFilter(AstridApiConstants.BROADCAST_SEND_ACTIONS)); new IntentFilter(AstridApiConstants.BROADCAST_SEND_ACTIONS));
getActivity().registerReceiver(refreshReceiver, getActivity().registerReceiver(refreshReceiver,
new IntentFilter(AstridApiConstants.BROADCAST_EVENT_REFRESH)); new IntentFilter(AstridApiConstants.BROADCAST_EVENT_REFRESH));
getActivity().registerReceiver(syncActionReceiver, getActivity().registerReceiver(
syncActionReceiver,
new IntentFilter(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS)); new IntentFilter(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS));
setUpBackgroundJobs(); setUpBackgroundJobs();
if (!Preferences.getBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, false)) { if (!Preferences.getBoolean(
Preferences.setBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, true); WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, false)) {
Intent showWelcomeLogin = new Intent(getActivity(), WelcomeWalkthrough.class); Preferences.setBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN,
true);
Intent showWelcomeLogin = new Intent(getActivity(),
WelcomeWalkthrough.class);
showWelcomeLogin.putExtra(ActFmLoginActivity.SHOW_TOAST, false); showWelcomeLogin.putExtra(ActFmLoginActivity.SHOW_TOAST, false);
startActivity(showWelcomeLogin); startActivity(showWelcomeLogin);
return; return;
} }
if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) { if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) {
HelpInfoPopover.showPopover(getActivity(), quickAddBox, R.string.help_popover_add_task, null); HelpInfoPopover.showPopover(getActivity(), quickAddBox,
R.string.help_popover_add_task, null);
Preferences.setBoolean(R.string.p_showed_add_task_help, true); Preferences.setBoolean(R.string.p_showed_add_task_help, true);
} else if (!Preferences.getBoolean(R.string.p_showed_tap_task_help, false)) { } else if (!Preferences.getBoolean(R.string.p_showed_tap_task_help,
false)) {
showTaskEditHelpPopover(); showTaskEditHelpPopover();
} else if (Preferences.isSet(getString(R.string.p_showed_lists_help)) && } else if (Preferences.isSet(getString(R.string.p_showed_lists_help))
!Preferences.getBoolean(R.string.p_showed_lists_help, false)) { && !Preferences.getBoolean(R.string.p_showed_lists_help, false)) {
//HelpInfoPopover.showPopover(getActivity(), getView().findViewById(R.id.back), R.string.help_popover_lists, null); // HelpInfoPopover.showPopover(getActivity(),
// getView().findViewById(R.id.back), R.string.help_popover_lists,
// null);
Preferences.setBoolean(R.string.p_showed_lists_help, true); Preferences.setBoolean(R.string.p_showed_lists_help, true);
} }
@ -673,7 +721,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
protected class RefreshReceiver extends BroadcastReceiver { protected class RefreshReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if(intent == null || !AstridApiConstants.BROADCAST_EVENT_REFRESH.equals(intent.getAction())) if (intent == null
|| !AstridApiConstants.BROADCAST_EVENT_REFRESH.equals(intent.getAction()))
return; return;
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@ -685,7 +734,6 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
} }
/** /**
* Called by the RefreshReceiver when the task list receives a refresh * Called by the RefreshReceiver when the task list receives a refresh
* broadcast. Subclasses should override this. * broadcast. Subclasses should override this.
@ -704,7 +752,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
protected class SyncActionReceiver extends BroadcastReceiver { protected class SyncActionReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if(intent == null || !AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS.equals(intent.getAction())) if (intent == null
|| !AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS.equals(intent.getAction()))
return; return;
try { try {
@ -713,7 +762,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
syncActions.add(syncAction); syncActions.add(syncAction);
} catch (Exception e) { } catch (Exception e) {
exceptionService.reportError("receive-sync-action-" + //$NON-NLS-1$ exceptionService.reportError("receive-sync-action-" + //$NON-NLS-1$
intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON), e); intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON),
e);
} }
} }
} }
@ -734,17 +784,20 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
if (AstridApiConstants.BROADCAST_SEND_DECORATIONS.equals(intent.getAction())) { if (AstridApiConstants.BROADCAST_SEND_DECORATIONS.equals(intent.getAction())) {
TaskDecoration deco = extras.getParcelable(AstridApiConstants.EXTRAS_RESPONSE); TaskDecoration deco = extras.getParcelable(AstridApiConstants.EXTRAS_RESPONSE);
taskAdapter.decorationManager.addNew(taskId, addOn, deco, null); taskAdapter.decorationManager.addNew(taskId, addOn, deco,
null);
} else if (AstridApiConstants.BROADCAST_SEND_DETAILS.equals(intent.getAction())) { } else if (AstridApiConstants.BROADCAST_SEND_DETAILS.equals(intent.getAction())) {
String detail = extras.getString(AstridApiConstants.EXTRAS_RESPONSE); String detail = extras.getString(AstridApiConstants.EXTRAS_RESPONSE);
taskAdapter.addDetails(taskId, detail); taskAdapter.addDetails(taskId, detail);
} else if (AstridApiConstants.BROADCAST_SEND_ACTIONS.equals(intent.getAction())) { } else if (AstridApiConstants.BROADCAST_SEND_ACTIONS.equals(intent.getAction())) {
TaskAction action = extras.getParcelable(AstridApiConstants.EXTRAS_RESPONSE); TaskAction action = extras.getParcelable(AstridApiConstants.EXTRAS_RESPONSE);
taskAdapter.taskActionManager.addNew(taskId, addOn, action, null); taskAdapter.taskActionManager.addNew(taskId, addOn, action,
null);
} }
} catch (Exception e) { } catch (Exception e) {
exceptionService.reportError("receive-detail-" + //$NON-NLS-1$ exceptionService.reportError("receive-detail-" + //$NON-NLS-1$
intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON), e); intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON),
e);
} }
} }
} }
@ -761,35 +814,44 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
// handle the result of voice recognition, put it into the textfield // handle the result of voice recognition, put it into the textfield
if (voiceInputAssistant.handleActivityResult(requestCode, resultCode, data)) { if (voiceInputAssistant.handleActivityResult(requestCode, resultCode,
// if user wants, create the task directly (with defaultvalues) after saying it data)) {
// if user wants, create the task directly (with defaultvalues)
// after saying it
Flags.set(Flags.TLA_RESUMED_FROM_VOICE_ADD); Flags.set(Flags.TLA_RESUMED_FROM_VOICE_ADD);
if (Preferences.getBoolean(R.string.p_voiceInputCreatesTask, false)) if (Preferences.getBoolean(R.string.p_voiceInputCreatesTask, false))
quickAddTask(quickAddBox.getText().toString(), true); quickAddTask(quickAddBox.getText().toString(), true);
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
// the rest of onActivityResult is totally unrelated to voicerecognition, so bail out // the rest of onActivityResult is totally unrelated to
// voicerecognition, so bail out
return; return;
} }
if(requestCode == ACTIVITY_SETTINGS && resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED) { if (requestCode == ACTIVITY_SETTINGS
&& resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED) {
getActivity().finish(); getActivity().finish();
if (overrideFinishAnim) { if (overrideFinishAnim) {
AndroidUtilities.callOverridePendingTransition(getActivity(), R.anim.slide_right_in, R.anim.slide_right_out); AndroidUtilities.callOverridePendingTransition(getActivity(),
R.anim.slide_right_in, R.anim.slide_right_out);
} }
getActivity().startActivity(getActivity().getIntent()); getActivity().startActivity(getActivity().getIntent());
} }
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) { if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) {
HelpInfoPopover.showPopover(getActivity(), quickAddBox, R.string.help_popover_add_task, null); HelpInfoPopover.showPopover(getActivity(), quickAddBox,
R.string.help_popover_add_task, null);
Preferences.setBoolean(R.string.p_showed_add_task_help, true); Preferences.setBoolean(R.string.p_showed_add_task_help, true);
} }
if (resultCode != Activity.RESULT_CANCELED) { if (resultCode != Activity.RESULT_CANCELED) {
if (data != null && data.hasExtra(TaskEditActivity.TOKEN_TASK_WAS_ASSIGNED) && data.getBooleanExtra(TaskEditActivity.TOKEN_TASK_WAS_ASSIGNED, false) && !isFilter) { if (data != null
&& data.hasExtra(TaskEditActivity.TOKEN_TASK_WAS_ASSIGNED)
&& data.getBooleanExtra(
TaskEditActivity.TOKEN_TASK_WAS_ASSIGNED, false)
&& !isFilter) {
String assignedTo = data.getStringExtra(TaskEditActivity.TOKEN_ASSIGNED_TO); String assignedTo = data.getStringExtra(TaskEditActivity.TOKEN_ASSIGNED_TO);
switchToAssignedFilter(assignedTo); switchToAssignedFilter(assignedTo);
} else { } else {
@ -806,7 +868,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Filter assignedFilter = CustomFilterExposer.getAssignedByMeFilter(getResources()); Filter assignedFilter = CustomFilterExposer.getAssignedByMeFilter(getResources());
Intent intent = new Intent(getActivity(), TaskListWrapperActivity.class); Intent intent = new Intent(getActivity(),
TaskListWrapperActivity.class);
intent.putExtra(TaskListActivity.TOKEN_FILTER, assignedFilter); intent.putExtra(TaskListActivity.TOKEN_FILTER, assignedFilter);
intent.putExtra(TaskListActivity.TOKEN_OVERRIDE_ANIM, true); intent.putExtra(TaskListActivity.TOKEN_OVERRIDE_ANIM, true);
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
@ -814,19 +877,20 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
}; };
DialogUtilities.okCancelCustomDialog(getActivity(), DialogUtilities.okCancelCustomDialog(getActivity(),
getString(R.string.actfm_view_task_title), getString(R.string.actfm_view_task_text, assignedEmail), getString(R.string.actfm_view_task_title),
R.string.actfm_view_task_ok, R.string.actfm_view_task_cancel, 0, getString(R.string.actfm_view_task_text, assignedEmail),
okListener, null); R.string.actfm_view_task_ok, R.string.actfm_view_task_cancel,
0, okListener, null);
} }
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, public void onScroll(AbsListView view, int firstVisibleItem,
int totalItemCount) { int visibleItemCount, int totalItemCount) {
// do nothing // do nothing
} }
/** /**
* Detect when user is flinging the task, disable task adapter loading * Detect when user is flinging the task, disable task adapter loading when
* when this occurs to save resources and time. * this occurs to save resources and time.
*/ */
public void onScrollStateChanged(AbsListView view, int scrollState) { public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) { switch (scrollState) {
@ -846,12 +910,15 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
} }
/* ====================================================================== /*
* ======================================================================
* =================================================== managing list view * =================================================== managing list view
* ====================================================================== */ * ======================================================================
*/
/** /**
* Load or re-load action items and update views * Load or re-load action items and update views
*
* @param requery * @param requery
*/ */
public void loadTaskListContent(boolean requery) { public void loadTaskListContent(boolean requery) {
@ -870,26 +937,30 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
getActivity().startManagingCursor(taskCursor); getActivity().startManagingCursor(taskCursor);
if(oldListItemSelected != ListView.INVALID_POSITION && if (oldListItemSelected != ListView.INVALID_POSITION
oldListItemSelected < taskCursor.getCount()) && oldListItemSelected < taskCursor.getCount())
getListView().setSelection(oldListItemSelected); getListView().setSelection(oldListItemSelected);
// also load sync actions // also load sync actions
syncActions.clear(); syncActions.clear();
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_REQUEST_SYNC_ACTIONS); Intent broadcastIntent = new Intent(
getActivity().sendOrderedBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); AstridApiConstants.BROADCAST_REQUEST_SYNC_ACTIONS);
getActivity().sendOrderedBroadcast(broadcastIntent,
AstridApiConstants.PERMISSION_READ);
} }
/** /**
* Fill in the Task List with current items * Fill in the Task List with current items
* @param withCustomId force task with given custom id to be part of list *
* @param withCustomId
* force task with given custom id to be part of list
*/ */
protected void setUpTaskList() { protected void setUpTaskList() {
if (filter == null) if (filter == null)
return; return;
sqlQueryTemplate.set(SortHelper.adjustQueryForFlagsAndSort(filter.sqlQuery, sqlQueryTemplate.set(SortHelper.adjustQueryForFlagsAndSort(
sortFlags, sortSort)); filter.sqlQuery, sortFlags, sortSort));
// perform query // perform query
TodorooCursor<Task> currentCursor = taskService.fetchFiltered( TodorooCursor<Task> currentCursor = taskService.fetchFiltered(
@ -898,7 +969,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
// set up list adapters // set up list adapters
taskAdapter = new TaskAdapter(this, R.layout.task_adapter_row, taskAdapter = new TaskAdapter(this, R.layout.task_adapter_row,
currentCursor, sqlQueryTemplate, false, new OnCompletedTaskListener() { currentCursor, sqlQueryTemplate, false,
new OnCompletedTaskListener() {
@Override @Override
public void onCompletedTask(Task item, boolean newState) { public void onCompletedTask(Task item, boolean newState) {
if (newState == true) if (newState == true)
@ -913,8 +985,9 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
/** /**
* Select a custom task id in the list. If it doesn't exist, create * Select a custom task id in the list. If it doesn't exist, create a new
* a new custom filter * custom filter
*
* @param withCustomId * @param withCustomId
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
@ -932,12 +1005,14 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
// create a custom cursor // create a custom cursor
if (!sqlQueryTemplate.get().contains("WHERE")) if (!sqlQueryTemplate.get().contains("WHERE"))
sqlQueryTemplate.set(sqlQueryTemplate.get() + " WHERE " + TaskCriteria.byId(withCustomId)); sqlQueryTemplate.set(sqlQueryTemplate.get() + " WHERE "
+ TaskCriteria.byId(withCustomId));
else else
sqlQueryTemplate.set(sqlQueryTemplate.get().replace("WHERE ", "WHERE " + sqlQueryTemplate.set(sqlQueryTemplate.get().replace("WHERE ",
TaskCriteria.byId(withCustomId) + " OR ")); "WHERE " + TaskCriteria.byId(withCustomId) + " OR "));
currentCursor = taskService.fetchFiltered(sqlQueryTemplate.get(), null, TaskAdapter.PROPERTIES); currentCursor = taskService.fetchFiltered(sqlQueryTemplate.get(), null,
TaskAdapter.PROPERTIES);
getListView().setFilterText(""); getListView().setFilterText("");
getActivity().startManagingCursor(currentCursor); getActivity().startManagingCursor(currentCursor);
@ -961,25 +1036,35 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
private void showTaskEditHelpPopover() { private void showTaskEditHelpPopover() {
if (!Preferences.getBoolean(R.string.p_showed_tap_task_help, false)) { if (!Preferences.getBoolean(R.string.p_showed_tap_task_help, false)) {
Preferences.setBoolean(R.string.p_showed_tap_task_help, true); Preferences.setBoolean(R.string.p_showed_tap_task_help, true);
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(quickAddBox.getWindowToken(), 0); imm.hideSoftInputFromWindow(quickAddBox.getWindowToken(), 0);
getListView().postDelayed(new Runnable() { getListView().postDelayed(new Runnable() {
public void run() { public void run() {
if (taskAdapter.getCount() > 0) { if (taskAdapter.getCount() > 0) {
final View view = getListView().getChildAt(getListView().getChildCount() - 1); final View view = getListView().getChildAt(
getListView().getChildCount() - 1);
if (view != null) { if (view != null) {
OnDismissListener onDismiss = new OnDismissListener() { OnDismissListener onDismiss = new OnDismissListener() {
@Override @Override
public void onDismiss() { public void onDismiss() {
if (!Preferences.isSet(getString(R.string.p_showed_lists_help))) { if (!Preferences.isSet(getString(R.string.p_showed_lists_help))) {
Preferences.setBoolean(R.string.p_showed_lists_help, false); Preferences.setBoolean(
} else if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) { R.string.p_showed_lists_help,
Preferences.setBoolean(R.string.p_showed_lists_help, true); false);
//HelpInfoPopover.showPopover(getActivity(), getView().findViewById(R.id.back), R.string.help_popover_lists, null); } else if (!Preferences.getBoolean(
R.string.p_showed_lists_help, false)) {
Preferences.setBoolean(
R.string.p_showed_lists_help,
true);
// HelpInfoPopover.showPopover(getActivity(),
// getView().findViewById(R.id.back),
// R.string.help_popover_lists, null);
} }
} }
}; };
HelpInfoPopover.showPopover(getActivity(), view, R.string.help_popover_tap_task, onDismiss); HelpInfoPopover.showPopover(getActivity(), view,
R.string.help_popover_tap_task, onDismiss);
} }
} }
} }
@ -988,13 +1073,17 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
} }
/* ====================================================================== /*
* ======================================================================
* ============================================================== actions * ============================================================== actions
* ====================================================================== */ * ======================================================================
*/
/** /**
* A task was completed from the task adapter * A task was completed from the task adapter
* @param item task that was completed *
* @param item
* task that was completed
*/ */
protected void onTaskCompleted(Task item) { protected void onTaskCompleted(Task item) {
if (isFilter) if (isFilter)
@ -1005,6 +1094,7 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
/** /**
* Quick-add a new task * Quick-add a new task
*
* @param title * @param title
* @return * @return
*/ */
@ -1013,18 +1103,21 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
try { try {
if (title != null) if (title != null)
title = title.trim(); title = title.trim();
Task task = createWithValues(filter.valuesForNewTasks, Task task = createWithValues(filter.valuesForNewTasks, title,
title, taskService, metadataService); taskService, metadataService);
boolean gcalCreateEventEnabled = Preferences.getStringValue(R.string.gcal_p_default) != null && boolean gcalCreateEventEnabled = Preferences.getStringValue(R.string.gcal_p_default) != null
!Preferences.getStringValue(R.string.gcal_p_default).equals("-1"); && !Preferences.getStringValue(R.string.gcal_p_default).equals(
"-1");
if (title.length() > 0 && gcalCreateEventEnabled) { if (title.length() > 0 && gcalCreateEventEnabled) {
Uri calendarUri = GCalHelper.createTaskEvent(task, getActivity().getContentResolver(), new ContentValues()); Uri calendarUri = GCalHelper.createTaskEvent(task,
getActivity().getContentResolver(), new ContentValues());
task.setValue(Task.CALENDAR_URI, calendarUri.toString()); task.setValue(Task.CALENDAR_URI, calendarUri.toString());
taskService.save(task); taskService.save(task);
} }
TextView quickAdd = (TextView)getView().findViewById(R.id.quickAddText); TextView quickAdd = (TextView) getView().findViewById(
R.id.quickAddText);
quickAdd.setText(""); //$NON-NLS-1$ quickAdd.setText(""); //$NON-NLS-1$
if (selectNewTask) { if (selectNewTask) {
@ -1035,21 +1128,23 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
StatisticsService.reportEvent(StatisticsConstants.TASK_CREATED_TASKLIST); StatisticsService.reportEvent(StatisticsConstants.TASK_CREATED_TASKLIST);
return task; return task;
} catch (Exception e) { } catch (Exception e) {
exceptionService.displayAndReportError(getActivity(), "quick-add-task", e); exceptionService.displayAndReportError(getActivity(),
"quick-add-task", e);
return new Task(); return new Task();
} }
} }
/** /**
* Create task from the given content values, saving it. * Create task from the given content values, saving it.
*
* @param values * @param values
* @param title * @param title
* @param taskService * @param taskService
* @param metadataService * @param metadataService
* @return * @return
*/ */
public static Task createWithValues(ContentValues values, String title, TaskService taskService, public static Task createWithValues(ContentValues values, String title,
MetadataService metadataService) { TaskService taskService, MetadataService metadataService) {
Task task = new Task(); Task task = new Task();
if (title != null) if (title != null)
task.setValue(Task.TITLE, title); task.setValue(Task.TITLE, title);
@ -1111,16 +1206,18 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
Object label = contextItemExposers[i].getLabel(task); Object label = contextItemExposers[i].getLabel(task);
if (label != null) { if (label != null) {
if (label instanceof Integer) if (label instanceof Integer)
menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i, Menu.NONE, (Integer)label); menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i,
Menu.NONE, (Integer) label);
else else
menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i, Menu.NONE, (String)label); menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i,
Menu.NONE, (String) label);
} }
} }
long taskId = task.getId(); long taskId = task.getId();
for (ContextMenuItem item : contextMenuExtensionLoader.getList()) { for (ContextMenuItem item : contextMenuExtensionLoader.getList()) {
android.view.MenuItem menuItem = menu.add(id, CONTEXT_MENU_BROADCAST_INTENT_ID, Menu.NONE, android.view.MenuItem menuItem = menu.add(id,
item.title); CONTEXT_MENU_BROADCAST_INTENT_ID, Menu.NONE, item.title);
item.intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId); item.intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
menuItem.setIntent(item.intent); menuItem.setIntent(item.intent);
} }
@ -1133,30 +1230,31 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
/** Show a dialog box and delete the task specified */ /** Show a dialog box and delete the task specified */
private void deleteTask(final Task task) { private void deleteTask(final Task task) {
new AlertDialog.Builder(getActivity()).setTitle(R.string.DLG_confirm_title) new AlertDialog.Builder(getActivity()).setTitle(
.setMessage(R.string.DLG_delete_this_task_question).setIcon( R.string.DLG_confirm_title).setMessage(
R.string.DLG_delete_this_task_question).setIcon(
android.R.drawable.ic_dialog_alert).setPositiveButton( android.R.drawable.ic_dialog_alert).setPositiveButton(
android.R.string.ok, android.R.string.ok, new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {
public void onClick(DialogInterface dialog,
int which) {
taskService.delete(task); taskService.delete(task);
loadTaskListContent(true); loadTaskListContent(true);
} }
}).setNegativeButton(android.R.string.cancel, null) }).setNegativeButton(android.R.string.cancel, null).show();
.show();
} }
/** /**
* Intent object with custom label returned by toString. * Intent object with custom label returned by toString.
*
* @author joshuagross <joshua.gross@gmail.com> * @author joshuagross <joshua.gross@gmail.com>
*/ */
protected static class IntentWithLabel extends Intent { protected static class IntentWithLabel extends Intent {
private final String label; private final String label;
public IntentWithLabel(Intent in, String labelIn) { public IntentWithLabel(Intent in, String labelIn) {
super(in); super(in);
label = labelIn; label = labelIn;
} }
@Override @Override
public String toString() { public String toString() {
return label; return label;
@ -1166,7 +1264,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
private static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$ private static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$
protected void initiateAutomaticSync() { protected void initiateAutomaticSync() {
if (filter == null || filter.title == null || !filter.title.equals(getString(R.string.BFE_Active))) if (filter == null || filter.title == null
|| !filter.title.equals(getString(R.string.BFE_Active)))
return; return;
long lastAutoSync = Preferences.getLong(PREF_LAST_AUTO_SYNC, 0); long lastAutoSync = Preferences.getLong(PREF_LAST_AUTO_SYNC, 0);
@ -1204,9 +1303,11 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
intent.setClassName(resolveInfo.activityInfo.packageName, intent.setClassName(resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name); resolveInfo.activityInfo.name);
String category = MetadataHelper.resolveActivityCategoryName(resolveInfo, pm); String category = MetadataHelper.resolveActivityCategoryName(
if(MilkPreferences.class.getName().equals(resolveInfo.activityInfo.name) && resolveInfo, pm);
!MilkUtilities.INSTANCE.isLoggedIn()) if (MilkPreferences.class.getName().equals(
resolveInfo.activityInfo.name)
&& !MilkUtilities.INSTANCE.isLoggedIn())
continue; continue;
if (category.equals(desiredCategory)) { if (category.equals(desiredCategory)) {
@ -1242,13 +1343,15 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
if (actions[which] instanceof SyncAction) { if (actions[which] instanceof SyncAction) {
try { try {
((SyncAction) actions[which]).intent.send(); ((SyncAction) actions[which]).intent.send();
Toast.makeText(getActivity(), R.string.SyP_progress_toast, Toast.makeText(getActivity(),
R.string.SyP_progress_toast,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} catch (CanceledException e) { } catch (CanceledException e) {
// //
} }
} else { } else {
((SyncV2Provider)actions[which]).synchronizeActiveTasks(true, syncResultCallback); ((SyncV2Provider) actions[which]).synchronizeActiveTasks(
true, syncResultCallback);
} }
} }
}; };
@ -1257,13 +1360,15 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
} }
/** /**
* Show menu of sync options. This is shown when you're not logged into any services, or logged into * Show menu of sync options. This is shown when you're not logged into any
* more than one. * services, or logged into more than one.
*
* @param <TYPE> * @param <TYPE>
* @param items * @param items
* @param listener * @param listener
*/ */
private <TYPE> void showSyncOptionMenu(TYPE[] items, DialogInterface.OnClickListener listener) { private <TYPE> void showSyncOptionMenu(TYPE[] items,
DialogInterface.OnClickListener listener) {
if (items.length == 1) { if (items.length == 1) {
listener.onClick(null, 0); listener.onClick(null, 0);
return; return;
@ -1273,14 +1378,16 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
android.R.layout.simple_spinner_dropdown_item, items); android.R.layout.simple_spinner_dropdown_item, items);
// show a menu of available options // show a menu of available options
new AlertDialog.Builder(getActivity()) new AlertDialog.Builder(getActivity()).setTitle(R.string.SyP_label).setAdapter(
.setTitle(R.string.SyP_label) adapter, listener).show().setOwnerActivity(getActivity());
.setAdapter(adapter, listener)
.show().setOwnerActivity(getActivity());
} }
/* (non-Javadoc) /*
* @see android.support.v4.app.ListFragment#onListItemClick(android.widget.ListView, android.view.View, int, long) * (non-Javadoc)
*
* @see
* android.support.v4.app.ListFragment#onListItemClick(android.widget.ListView
* , android.view.View, int, long)
*/ */
@Override @Override
public void onListItemClick(ListView l, View v, int position, long id) { public void onListItemClick(ListView l, View v, int position, long id) {
@ -1314,8 +1421,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
return true; return true;
case MENU_SORT_ID: case MENU_SORT_ID:
StatisticsService.reportEvent(StatisticsConstants.TLA_MENU_SORT); StatisticsService.reportEvent(StatisticsConstants.TLA_MENU_SORT);
AlertDialog dialog = SortSelectionActivity.createDialog(getActivity(), AlertDialog dialog = SortSelectionActivity.createDialog(
this, sortFlags, sortSort); getActivity(), this, sortFlags, sortSort);
dialog.show(); dialog.show();
return true; return true;
case MENU_SYNC_ID: case MENU_SYNC_ID:
@ -1329,7 +1436,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
return true; return true;
case MENU_ADDON_INTENT_ID: case MENU_ADDON_INTENT_ID:
intent = item.getIntent(); intent = item.getIntent();
AndroidUtilities.startExternalIntent(getActivity(), intent, ACTIVITY_MENU_EXTERNAL); AndroidUtilities.startExternalIntent(getActivity(), intent,
ACTIVITY_MENU_EXTERNAL);
return true; return true;
// --- context menu items // --- context menu items
@ -1435,7 +1543,8 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
editor.putInt(SortHelper.PREF_SORT_FLAGS, flags); editor.putInt(SortHelper.PREF_SORT_FLAGS, flags);
editor.putInt(SortHelper.PREF_SORT_SORT, sort); editor.putInt(SortHelper.PREF_SORT_SORT, sort);
editor.commit(); editor.commit();
ContextManager.getContext().startService(new Intent(ContextManager.getContext(), ContextManager.getContext().startService(
new Intent(ContextManager.getContext(),
TasksWidget.WidgetUpdateService.class)); TasksWidget.WidgetUpdateService.class));
} }

Loading…
Cancel
Save