diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java index 09cb421b0..6a66fff17 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java @@ -269,9 +269,15 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener body.setOrientation(LinearLayout.VERTICAL); body.setPadding(10, 0, 10, 0); - final EditText name = addEditField(body, - R.string.actfm_ALA_name_label); - name.setInputType(InputType.TYPE_CLASS_TEXT | + final EditText firstNameField = addEditField(body, + R.string.actfm_ALA_firstname_label); + firstNameField.setInputType(InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_VARIATION_PERSON_NAME | + InputType.TYPE_TEXT_FLAG_CAP_WORDS); + + final EditText lastNameField = addEditField(body, + R.string.actfm_ALA_lastname_label); + lastNameField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME | InputType.TYPE_TEXT_FLAG_CAP_WORDS); @@ -282,7 +288,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener @Override public void onClick(View v) { isNew.set(!isNew.get()); - int nameIndex = body.indexOfChild(name); + int nameIndex = body.indexOfChild(lastNameField); int visibility = isNew.get() ? View.VISIBLE : View.GONE; int passwordVisibility = isNew.get() ? View.GONE : View.VISIBLE; toggleNew.setText(isNew.get() ? R.string.actfm_ALA_pw_returning @@ -290,6 +296,8 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener dialog.get().setTitle( isNew.get() ? R.string.actfm_ALA_signup_title : R.string.actfm_ALA_login_title); + body.getChildAt(nameIndex - 3).setVisibility(visibility); + body.getChildAt(nameIndex - 2).setVisibility(visibility); body.getChildAt(nameIndex - 1).setVisibility(visibility); body.getChildAt(nameIndex).setVisibility(visibility); @@ -331,11 +339,14 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int which) { - String nameString = isNew.get() ? name.getText().toString() + String firstName = isNew.get() ? firstNameField.getText().toString() : null; - AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, name, email, password); + String lastName = isNew.get() ? lastNameField.getText().toString() + : null; + + AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, firstNameField, lastNameField, email, password); authenticate(email.getText().toString(), - nameString, ActFmInvoker.PROVIDER_PASSWORD, + firstName, lastName, ActFmInvoker.PROVIDER_PASSWORD, password.getText().toString()); if (isNew.get()) @@ -346,7 +357,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int which) { - AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, name, email, password); + AndroidUtilities.hideSoftInputForViews(ActFmLoginActivity.this, firstNameField, lastNameField, email, password); } }).show()); @@ -427,10 +438,11 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener JSONObject json; try { json = Util.parseJson(response); - String name = json.getString("name"); //$NON-NLS-1$ + String firstName = json.getString("first_name"); //$NON-NLS-1$ + String lastName = json.getString("last_name"); String email = json.getString("email"); //$NON-NLS-1$ - authenticate(email, name, ActFmInvoker.PROVIDER_FACEBOOK, + authenticate(email, firstName, lastName, ActFmInvoker.PROVIDER_FACEBOOK, facebook.getAccessToken()); StatisticsService.reportEvent(StatisticsConstants.ACTFM_LOGIN_FB); } catch (FacebookError e) { @@ -467,7 +479,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener // --- utilities @SuppressWarnings("nls") - public void authenticate(final String email, final String name, final String provider, + public void authenticate(final String email, final String firstName, final String lastName, final String provider, final String secret) { if (progressDialog == null) progressDialog = DialogUtilities.progressDialog(this, @@ -477,7 +489,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener @Override public void run() { try { - final JSONObject result = actFmInvoker.authenticate(email, name, + final JSONObject result = actFmInvoker.authenticate(email, firstName, lastName, provider, secret); final String token = actFmInvoker.getToken(); @@ -591,7 +603,7 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener } else if (requestCode == REQUEST_CODE_GOOGLE) { String email= data.getStringExtra(ActFmGoogleAuthActivity.RESULT_EMAIL); String token = data.getStringExtra(ActFmGoogleAuthActivity.RESULT_TOKEN); - authenticate(email, email, "google", token); + authenticate(email, email, "", "google", token); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java index e0b26ba10..838b0728d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java @@ -21,7 +21,6 @@ import android.graphics.Color; import android.support.v4.app.Fragment; import android.text.TextUtils; import android.util.DisplayMetrics; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -59,6 +58,7 @@ import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.ui.PeopleContainer; import com.todoroo.astrid.ui.PeopleContainer.OnAddNewPersonListener; +import com.todoroo.astrid.ui.PeopleContainer.ParseSharedException; import com.todoroo.astrid.ui.PopupControlSet; public class EditPeopleControlSet extends PopupControlSet { @@ -570,9 +570,6 @@ public class EditPeopleControlSet extends PopupControlSet { selected = 0;*/ return true; } - else { - Log.d("Edit People control set", "Does not equal task rabbit"); - } userJson = item.user; } } @@ -626,7 +623,12 @@ public class EditPeopleControlSet extends PopupControlSet { } } - JSONObject sharedWith = parseSharedWithAndTags(); + JSONObject sharedWith = sharedWithContainer.parseSharedWithAndTags(activity, false); + if(cbFacebook.isChecked()) + sharedWith.put("fb", true); + if(cbTwitter.isChecked()) + sharedWith.put("tw", true); + dirty = dirty || sharedWith.has("p"); if(dirty && !actFmPreferenceService.isLoggedIn()) { DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() { @@ -690,46 +692,6 @@ public class EditPeopleControlSet extends PopupControlSet { Toast.makeText(activity, saveToast, length).show(); } - private class ParseSharedException extends Exception { - private static final long serialVersionUID = -4135848250086302970L; - public TextView view; - public String message; - - public ParseSharedException(TextView view, String message) { - this.view = view; - this.message = message; - } - } - - @SuppressWarnings("nls") - private JSONObject parseSharedWithAndTags() throws - JSONException, ParseSharedException { - JSONObject sharedWith = new JSONObject(); - if(cbFacebook.isChecked()) - sharedWith.put("fb", true); - if(cbTwitter.isChecked()) - sharedWith.put("tw", true); - - JSONArray peopleList = new JSONArray(); - for(int i = 0; i < sharedWithContainer.getChildCount(); i++) { - TextView textView = sharedWithContainer.getTextView(i); - textView.setTextAppearance(activity, android.R.style.TextAppearance_Medium_Inverse); - String text = textView.getText().toString(); - - if(text.length() == 0) - continue; - - if(text.indexOf('@') == -1) - throw new ParseSharedException(textView, - activity.getString(R.string.actfm_EPA_invalid_email, text)); - peopleList.put(text); - } - if(peopleList.length() > 0) - sharedWith.put("p", peopleList); - - return sharedWith; - } - @SuppressWarnings("nls") protected Object[] buildSharingArgs(JSONArray emails) throws JSONException { ArrayList values = new ArrayList(); diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java index 94536df7d..57f5ed40a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java @@ -13,6 +13,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; +import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.ActionBar; import android.support.v4.app.FragmentActivity; @@ -31,6 +32,7 @@ import android.widget.Toast; import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; +import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; @@ -48,6 +50,7 @@ import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.tags.TagFilterExposer; import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.ui.PeopleContainer; +import com.todoroo.astrid.ui.PeopleContainer.ParseSharedException; import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.welcome.HelpInfoPopover; @@ -71,6 +74,8 @@ public class TagSettingsActivity extends FragmentActivity { @Autowired ActFmPreferenceService actFmPreferenceService; + @Autowired ExceptionService exceptionService; + private PeopleContainer tagMembers; private AsyncImageView picture; private EditText tagName; @@ -227,7 +232,22 @@ public class TagSettingsActivity extends FragmentActivity { tagData.setValue(TagData.TAG_DESCRIPTION, newDesc); - JSONArray members = tagMembers.toJSONArray(); + JSONArray members; + try { + members = tagMembers.parseSharedWithAndTags(this, true).optJSONArray("p"); + } catch (JSONException e) { + exceptionService.displayAndReportError(this, "save-people", e); + return; + } catch (ParseSharedException e) { + if(e.view != null) { + e.view.setTextColor(Color.RED); + e.view.requestFocus(); + } + DialogUtilities.okDialog(this, e.message, null); + return; + } + if (members == null) + members = new JSONArray(); if(members.length() > 0 && !actFmPreferenceService.isLoggedIn()) { if(newName.length() > 0 && oldName.length() == 0) { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java index adf0d05cb..90f50073d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java @@ -1,5 +1,6 @@ package com.todoroo.astrid.actfm; +import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; @@ -36,6 +37,7 @@ import com.todoroo.astrid.actfm.ActFmCameraModule.ClearImageCallback; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmSyncService; import com.todoroo.astrid.activity.AstridActivity; +import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.adapter.UpdateAdapter; import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.data.TagData; @@ -198,9 +200,16 @@ public class TagUpdatesFragment extends ListFragment { cursor.requery(); getActivity().startManagingCursor(cursor); } + if (getActivity() instanceof TagUpdatesActivity) + setLastViewed(); + } - if(tagData != null && tagData.getValue(Task.REMOTE_ID) <= 0) { + public void setLastViewed() { + if(tagData != null && tagData.getValue(Task.REMOTE_ID) > 0) { Preferences.setLong(UPDATES_LAST_VIEWED + tagData.getValue(TagData.REMOTE_ID), DateUtilities.now()); + Activity activity = getActivity(); + if (activity instanceof TaskListActivity) + ((TaskListActivity) activity).setCommentsCount(0); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java index 845715fc5..3a7b10159 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java @@ -172,8 +172,9 @@ public class TagViewFragment extends TaskListFragment { dataLoaded = true; } - String tag = getActivity().getIntent().getStringExtra(EXTRA_TAG_NAME); - long remoteId = getActivity().getIntent().getLongExtra(EXTRA_TAG_REMOTE_ID, 0); + TaskListActivity activity = (TaskListActivity) getActivity(); + String tag = activity.getIntent().getStringExtra(EXTRA_TAG_NAME); + long remoteId = activity.getIntent().getLongExtra(EXTRA_TAG_REMOTE_ID, 0); if(tag == null && remoteId == 0) return; @@ -198,17 +199,10 @@ public class TagViewFragment extends TaskListFragment { super.onNewIntent(intent); -// if (intent.getBooleanExtra(TOKEN_START_ACTIVITY, false)) { -// getView().findViewById(R.id.activity).postDelayed(new Runnable() { -// @Override -// public void run() { -// Intent i = new Intent(getActivity(), TagUpdatesActivity.class); -// i.putExtra(EXTRA_TAG_DATA, tagData); -// startActivity(i); -// AndroidUtilities.callOverridePendingTransition(getActivity(), R.anim.slide_left_in, R.anim.slide_left_out); -// } -// }, 500); -// } + if (activity.getIntent().getBooleanExtra(TOKEN_START_ACTIVITY, false)) { + activity.getIntent().removeExtra(TOKEN_START_ACTIVITY); + activity.showComments(); + } } @Override @@ -230,6 +224,10 @@ public class TagViewFragment extends TaskListFragment { tagDataService.save(tagData); } + updateCommentCount(); + } + + private void updateCommentCount() { if (tagData != null) { long lastViewedComments = Preferences.getLong(TagUpdatesFragment.UPDATES_LAST_VIEWED + tagData.getValue(TagData.REMOTE_ID), 0); int unreadCount = 0; @@ -441,6 +439,7 @@ public class TagViewFragment extends TaskListFragment { getActivity().registerReceiver(notifyReceiver, intentFilter); showListSettingsPopover(); + updateCommentCount(); } @Override diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java index e6814d1c8..464c30965 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java @@ -34,7 +34,7 @@ public class ActFmInvoker { public static final String PROVIDER_GOOGLE= "google"; public static final String PROVIDER_PASSWORD = "password"; - private static final int API_VERSION = 5; + private static final int API_VERSION = 6; @Autowired private RestClient restClient; @@ -68,12 +68,13 @@ public class ActFmInvoker { /** * Authentication user with Act.fm server, returning a token */ - public JSONObject authenticate(String email, String name, String provider, + public JSONObject authenticate(String email, String firstName, String lastName, String provider, String secret) throws ActFmServiceException, IOException { JSONObject result = invoke( "user_signin", "email", email, - "name", name, + "first_name", firstName, + "last_name", lastName, "provider", provider, "secret", secret); try { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java index 6c6597fe3..ad99fe4d2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java @@ -296,15 +296,26 @@ public final class ActFmSyncService { * Synchronize with server when data changes */ public void pushTaskOnSave(Task task, ContentValues values) { + Task taskForRemote = taskService.fetchById(task.getId(), Task.REMOTE_ID, Task.CREATION_DATE); + long remoteId; if(task.containsValue(Task.REMOTE_ID)) { remoteId = task.getValue(Task.REMOTE_ID); } else { - Task taskForRemote = taskService.fetchById(task.getId(), Task.REMOTE_ID); if(taskForRemote == null) return; remoteId = taskForRemote.getValue(Task.REMOTE_ID); } + + long creationDate; + if (task.containsValue(Task.CREATION_DATE)) { + creationDate = task.getValue(Task.CREATION_DATE); + } else { + if (taskForRemote == null) + return; + creationDate = taskForRemote.getValue(Task.CREATION_DATE); + } + boolean newlyCreated = remoteId == 0; ArrayList params = new ArrayList(); @@ -402,6 +413,8 @@ public final class ActFmSyncService { if(params.size() == 0 || !checkForToken()) return; + params.add("created_at"); params.add(creationDate); + if(!newlyCreated) { params.add("id"); params.add(remoteId); } else if(!values.containsKey(Task.TITLE.name)) { diff --git a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatControlSet.java b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatControlSet.java index 707d7469b..c25204e3f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatControlSet.java @@ -36,6 +36,7 @@ import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; +import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.ui.NumberPicker; import com.todoroo.astrid.ui.NumberPickerDialog; import com.todoroo.astrid.ui.NumberPickerDialog.OnNumberPickedListener; @@ -324,6 +325,9 @@ public class RepeatControlSet extends PopupControlSet { result = rrule.toIcal(); } + + if (!result.equals(task.getValue(Task.RECURRENCE))) + task.putTransitory(TaskService.TRANS_REPEAT_CHANGED, true); task.setValue(Task.RECURRENCE, result); switch(type.getSelectedItemPosition()) { diff --git a/astrid/res/layout/task_adapter_draggable_row.xml b/astrid/res/layout/task_adapter_draggable_row.xml index 3580d7094..544a3675a 100644 --- a/astrid/res/layout/task_adapter_draggable_row.xml +++ b/astrid/res/layout/task_adapter_draggable_row.xml @@ -32,9 +32,9 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:drawable/list_selector_background" - android:paddingTop="1dip" - android:paddingLeft="5dip" - android:paddingBottom="1dip"> + android:layout_marginTop="6dip" + android:layout_marginBottom="6dip" + android:paddingLeft="5dip"> + android:layout_marginTop="6dip" + android:layout_marginBottom="6dip" + android:minHeight="45dip"> Name + + First Name + + + Last Name + Email diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 423dde17a..820d7147e 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -163,6 +163,13 @@ Don\'t display future confirmations + + + New repeating task %s + + + I\'ll remind you about this %s. + highest priority high priority diff --git a/astrid/src/com/todoroo/astrid/activity/DraggableTaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/DraggableTaskListFragment.java index 009206958..51ff0fd00 100644 --- a/astrid/src/com/todoroo/astrid/activity/DraggableTaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/DraggableTaskListFragment.java @@ -19,6 +19,7 @@ import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.core.SortHelper; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.helper.SyncActionHelper; /** * Activity for working with draggable task lists, like Google Tasks lists @@ -83,6 +84,7 @@ public class DraggableTaskListFragment extends TaskListFragment { getListView().setOnScrollListener(this); registerForContextMenu(getListView()); + syncActionHelper = new SyncActionHelper(getActivity()); loadTaskListContent(false); getTouchListView().setOnTouchListener(new OnTouchListener() { diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index 380f1f8f6..bf98505ac 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -89,6 +89,7 @@ import com.todoroo.astrid.tags.TagsControlSet; import com.todoroo.astrid.taskrabbit.TaskRabbitControlSet; import com.todoroo.astrid.timers.TimerActionControlSet; import com.todoroo.astrid.timers.TimerControlSet; +import com.todoroo.astrid.ui.DateChangedAlerts; import com.todoroo.astrid.ui.DeadlineControlSet; import com.todoroo.astrid.ui.EditNotesControlSet; import com.todoroo.astrid.ui.EditTitleControlSet; @@ -168,6 +169,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { public static final String TOKEN_ASSIGNED_TO = "task_assigned_to"; //$NON-NLS-1$ public static final String TOKEN_TAGS_CHANGED = "tags_changed"; //$NON-NLS-1$ + public static final String TOKEN_NEW_REPEATING_TASK = "new_repeating"; //$NON-NLS-1$ // --- services @@ -812,16 +814,21 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { taskService.save(model); if (!onPause && !cancelFinish) { - boolean setActivityResult = (getActivity() instanceof TaskEditActivity); + boolean taskEditActivity = (getActivity() instanceof TaskEditActivity); boolean isAssignedToMe = peopleControlSet.isAssignedToMe(); + boolean showRepeatAlert = model.getTransitory(TaskService.TRANS_REPEAT_CHANGED) != null + && !TextUtils.isEmpty(model.getValue(Task.RECURRENCE)); String assignedTo = peopleControlSet.getAssignedToString(); - if (setActivityResult) { + if (taskEditActivity) { Intent data = new Intent(); if (!isAssignedToMe) { data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true); data.putExtra(TOKEN_ASSIGNED_TO, assignedTo); } + if (showRepeatAlert) { + data.putExtra(TOKEN_NEW_REPEATING_TASK, model); + } data.putExtra(TOKEN_TAGS_CHANGED, tagsChanged); getActivity().setResult(Activity.RESULT_OK, data); @@ -831,6 +838,9 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { TaskListActivity tla = (TaskListActivity) getActivity(); if (!isAssignedToMe) tla.switchToAssignedFilter(assignedTo); + else if (showRepeatAlert) + DateChangedAlerts.showRepeatChangedDialog(tla, model); + if (tagsChanged) tla.tagsChanged(); tla.refreshTaskList(); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index a6ee7d16e..1fd14eeba 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -33,9 +33,11 @@ import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.core.CustomFilterExposer; +import com.todoroo.astrid.data.Task; import com.todoroo.astrid.reminders.NotificationFragment; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.tags.TagFilterExposer; +import com.todoroo.astrid.ui.DateChangedAlerts; import com.todoroo.astrid.ui.FragmentPopover; import com.todoroo.astrid.ui.MainMenuPopover; import com.todoroo.astrid.ui.MainMenuPopover.MainMenuListener; @@ -84,6 +86,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener if (frag != null) { setupPopoverWithFragment(commentsPopover, frag, null); commentsPopover.show(listsNav); + frag.setLastViewed(); } } else { // In this case we should be in LAYOUT_SINGLE--delegate to the task list fragment @@ -341,6 +344,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener commentsButton.setBackgroundResource(tv.data); } + public void showComments() { + commentsButton.performClick(); + } + @Override public void onBackPressed() { // manage task edit visibility @@ -389,6 +396,9 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener if (data.getBooleanExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) { String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO); switchToAssignedFilter(assignedTo); + } else if (data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK) != null) { + Task repeating = data.getParcelableExtra(TaskEditFragment.TOKEN_NEW_REPEATING_TASK); + DateChangedAlerts.showRepeatChangedDialog(this, repeating); } if (data.getBooleanExtra(TaskEditFragment.TOKEN_TAGS_CHANGED, false)) tagsChanged(true); diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index 863377c70..1624c107e 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -213,7 +213,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { displayMetrics = new DisplayMetrics(); fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); - this.minRowHeight = (int) (57 * displayMetrics.density); + this.minRowHeight = (int) (4 * displayMetrics.density); startDetailThread(); startTaskActionsThread(); diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java index 5b7b358d6..d77eee3b5 100644 --- a/astrid/src/com/todoroo/astrid/service/TaskService.java +++ b/astrid/src/com/todoroo/astrid/service/TaskService.java @@ -44,6 +44,8 @@ public class TaskService { public static final String TRANS_QUICK_ADD_MARKUP = "markup"; //$NON-NLS-1$ + public static final String TRANS_REPEAT_CHANGED = "repeat_changed"; //$NON-NLS-1$ + @Autowired private TaskDao taskDao; diff --git a/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java b/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java index 63fb56fca..e44bac9a0 100644 --- a/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java +++ b/astrid/src/com/todoroo/astrid/ui/DateChangedAlerts.java @@ -53,9 +53,9 @@ public class DateChangedAlerts { d.setContentView(R.layout.astrid_reminder_view); Button okButton = (Button) d.findViewById(R.id.reminder_complete); + okButton.setText(R.string.DLG_ok); d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE); - okButton.setText(R.string.DLG_ok); ((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.TLA_quickadd_confirm_title, originalText)); Spanned speechBubbleText = constructSpeechBubbleTextForQuickAdd(activity, task); @@ -77,6 +77,31 @@ public class DateChangedAlerts { d.show(); } + public static void showRepeatChangedDialog(final AstridActivity activity, Task task) { + if (!Preferences.getBoolean(PREF_SHOW_HELPERS, true)) + return; + + final Dialog d = new Dialog(activity, R.style.ReminderDialog); + d.setContentView(R.layout.astrid_reminder_view); + + Button okButton = (Button) d.findViewById(R.id.reminder_complete); + okButton.setText(R.string.DLG_ok); + + d.findViewById(R.id.reminder_snooze).setVisibility(View.GONE); + d.findViewById(R.id.reminder_edit).setVisibility(View.GONE); + ((TextView) d.findViewById(R.id.reminder_title)).setText(activity.getString(R.string.TLA_repeat_scheduled_title, task.getValue(Task.TITLE))); + + String speechBubbleText = constructSpeechBubbleTextForRepeat(activity, task); + + ((TextView) d.findViewById(R.id.reminder_message)).setText(speechBubbleText); + + setupOkAndDismissButtons(d); + setupHideCheckbox(d); + + d.setOwnerActivity(activity); + d.show(); + } + public static final Property[] REPEAT_RESCHEDULED_PROPERTIES = new Property[] { @@ -190,6 +215,11 @@ public class DateChangedAlerts { return Html.fromHtml(fullString); } + private static String constructSpeechBubbleTextForRepeat(Context context, Task task) { + String recurrence = getRecurrenceString(context, task); + return context.getString(R.string.TLA_repeat_scheduled_speech_bubble, recurrence); + } + @SuppressWarnings("nls") private static String getRelativeDateAndTimeString(Context context, long date) { String dueString = date > 0 ? DateUtilities.getRelativeDay(context, date, false) : ""; diff --git a/astrid/src/com/todoroo/astrid/ui/PeopleContainer.java b/astrid/src/com/todoroo/astrid/ui/PeopleContainer.java index 173570f3a..5de4d2ce3 100644 --- a/astrid/src/com/todoroo/astrid/ui/PeopleContainer.java +++ b/astrid/src/com/todoroo/astrid/ui/PeopleContainer.java @@ -4,6 +4,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; import android.text.Editable; @@ -170,6 +171,48 @@ public class PeopleContainer extends LinearLayout { return people; } + @SuppressWarnings("nls") + public JSONObject parseSharedWithAndTags(Activity activity, boolean peopleAsJSON) throws + JSONException, ParseSharedException { + JSONObject sharedWith = new JSONObject(); + + JSONArray peopleList = new JSONArray(); + for(int i = 0; i < getChildCount(); i++) { + TextView textView = getTextView(i); + textView.setTextAppearance(activity, android.R.style.TextAppearance_Medium_Inverse); + String text = textView.getText().toString(); + + if(text.length() == 0) + continue; + + if(text.indexOf('@') == -1) + throw new ParseSharedException(textView, + activity.getString(R.string.actfm_EPA_invalid_email, text)); + if (peopleAsJSON) { + JSONObject person = PeopleContainer.createUserJson(textView); + if (person != null) + peopleList.put(person); + } else { + peopleList.put(text); + } + } + if(peopleList.length() > 0) + sharedWith.put("p", peopleList); + + return sharedWith; + } + + public static class ParseSharedException extends Exception { + private static final long serialVersionUID = -4135848250086302970L; + public TextView view; + public String message; + + public ParseSharedException(TextView view, String message) { + this.view = view; + this.message = message; + } + } + /** * Add people from JSON Array * @param people diff --git a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java index 6f1710db1..a7330a2ac 100644 --- a/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java +++ b/astrid/src/com/todoroo/astrid/ui/QuickAddBar.java @@ -287,6 +287,8 @@ public class QuickAddBar extends LinearLayout { Uri calendarUri = GCalHelper.createTaskEvent(task, activity.getContentResolver(), new ContentValues()); task.setValue(Task.CALENDAR_URI, calendarUri.toString()); + Flags.set(Flags.ACTFM_SUPPRESS_SYNC); + Flags.set(Flags.GTASKS_SUPPRESS_SYNC); taskService.save(task); } @@ -301,6 +303,8 @@ public class QuickAddBar extends LinearLayout { fragment.selectCustomId(task.getId()); if (task.getTransitory(TaskService.TRANS_QUICK_ADD_MARKUP) != null) { showAlertForMarkupTask((AstridActivity) activity, task, title); + } else if (!TextUtils.isEmpty(task.getValue(Task.RECURRENCE))) { + showAlertForRepeatingTask((AstridActivity) activity, task); } } @@ -317,6 +321,10 @@ public class QuickAddBar extends LinearLayout { DateChangedAlerts.showQuickAddMarkupDialog(activity, task, originalText); } + private static void showAlertForRepeatingTask(AstridActivity activity, Task task) { + DateChangedAlerts.showRepeatChangedDialog(activity, task); + } + // --- instance methods public EditText getQuickAddBox() {