All the when control sets working in quickadd

pull/14/head
Sam Bosley 13 years ago
parent 7f43c9e2c1
commit 2bf26ee51e

@ -153,8 +153,12 @@ public class EditPeopleControlSet extends PopupControlSet {
@Override @Override
public void readFromTask(Task sourceTask) { public void readFromTask(Task sourceTask) {
task = sourceTask; setTask(sourceTask);
setUpData(); setUpData(task);
}
public void setTask(Task task) {
this.task = task;
} }
public View getSharedWithRow() { public View getSharedWithRow() {
@ -166,7 +170,7 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")
private void setUpData() { public void setUpData(final Task task) {
try { try {
JSONObject sharedWith; JSONObject sharedWith;
if(task.getValue(Task.SHARED_WITH).length() > 0) if(task.getValue(Task.SHARED_WITH).length() > 0)
@ -220,7 +224,7 @@ public class EditPeopleControlSet extends PopupControlSet {
if(collaborators.size() > 0) if(collaborators.size() > 0)
buildCollaborators(collaborators); buildCollaborators(collaborators);
buildAssignedToSpinner(sharedPeople); buildAssignedToSpinner(task, sharedPeople);
} catch (JSONException e) { } catch (JSONException e) {
exceptionService.reportError("json-reading-data", e); exceptionService.reportError("json-reading-data", e);
} finally { } finally {
@ -284,13 +288,13 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")
private void buildAssignedToSpinner(ArrayList<JSONObject> sharedPeople) throws JSONException { private void buildAssignedToSpinner(Task model, ArrayList<JSONObject> sharedPeople) throws JSONException {
HashSet<Long> userIds = new HashSet<Long>(); HashSet<Long> userIds = new HashSet<Long>();
HashSet<String> emails = new HashSet<String>(); HashSet<String> emails = new HashSet<String>();
HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>(); HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>();
if(task.getValue(Task.USER_ID) > 0) { if(model.getValue(Task.USER_ID) > 0) {
JSONObject user = new JSONObject(task.getValue(Task.USER)); JSONObject user = new JSONObject(model.getValue(Task.USER));
sharedPeople.add(0, user); sharedPeople.add(0, user);
} }
@ -298,8 +302,8 @@ public class EditPeopleControlSet extends PopupControlSet {
myself.put("id", Task.USER_ID_SELF); myself.put("id", Task.USER_ID_SELF);
sharedPeople.add(0, myself); sharedPeople.add(0, myself);
boolean hasTags = task.getTransitory("tags") != null && boolean hasTags = model.getTransitory("tags") != null &&
((HashSet<String>)task.getTransitory("tags")).size() > 0; ((HashSet<String>)model.getTransitory("tags")).size() > 0;
if (actFmPreferenceService.isLoggedIn() && hasTags) { if (actFmPreferenceService.isLoggedIn() && hasTags) {
JSONObject unassigned = new JSONObject(); JSONObject unassigned = new JSONObject();
unassigned.put("id", Task.USER_ID_UNASSIGNED); unassigned.put("id", Task.USER_ID_UNASSIGNED);
@ -347,7 +351,7 @@ public class EditPeopleControlSet extends PopupControlSet {
names.put(name, atu); names.put(name, atu);
} }
String assignedStr = task.getValue(Task.USER); String assignedStr = model.getValue(Task.USER);
int assignedIndex = 0; int assignedIndex = 0;
if (!TextUtils.isEmpty(assignedStr)) { if (!TextUtils.isEmpty(assignedStr)) {
JSONObject assigned = new JSONObject(assignedStr); JSONObject assigned = new JSONObject(assignedStr);

@ -324,6 +324,10 @@ public class RepeatControlSet extends PopupControlSet {
return null; return null;
} }
public boolean isRecurrenceSet() {
return doRepeat;
}
@Override @Override
protected void refreshDisplayView() { protected void refreshDisplayView() {
TextView repeatDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit); TextView repeatDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit);

@ -17,7 +17,7 @@
android:id="@+id/display_row_title" android:id="@+id/display_row_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="15dip" android:layout_marginRight="10dip"
style="@style/TextAppearance.GEN_EditLabel" /> style="@style/TextAppearance.GEN_EditLabel" />
<TextView <TextView
android:id="@+id/display_row_edit" android:id="@+id/display_row_edit"

@ -22,13 +22,37 @@
android:id="@+id/taskListFooter" android:id="@+id/taskListFooter"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="50dip"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"
style="@style/Content">
<View
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="?attr/asSeparatorBackground"/>
<LinearLayout
android:id="@+id/taskListQuickaddControls"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal">
<View
android:layout_height="fill_parent"
android:layout_width="1px"
android:background="?attr/asSeparatorBackground"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="50dip"
android:padding="3dip" android:padding="3dip"
android:paddingBottom="5dip" android:paddingBottom="5dip"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
style="@style/Content">
<!-- Voice Add Button --> <!-- Voice Add Button -->
<ImageButton android:id="@+id/voiceAddButton" <ImageButton android:id="@+id/voiceAddButton"
@ -73,5 +97,6 @@
android:scaleType="center"/> android:scaleType="center"/>
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -150,7 +150,7 @@ public final class TaskEditFragment extends Fragment implements
// --- request codes // --- request codes
private static final int REQUEST_LOG_IN = 0; public static final int REQUEST_LOG_IN = 0;
private static final int REQUEST_VOICE_RECOG = 1; private static final int REQUEST_VOICE_RECOG = 1;
// --- menu codes // --- menu codes

@ -46,6 +46,7 @@ import android.view.View.OnClickListener;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -55,6 +56,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
@ -76,6 +78,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.andlib.widget.GestureService; import com.todoroo.andlib.widget.GestureService;
import com.todoroo.andlib.widget.GestureService.GestureInterface; import com.todoroo.andlib.widget.GestureService.GestureInterface;
import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.actfm.ActFmLoginActivity;
import com.todoroo.astrid.actfm.EditPeopleControlSet;
import com.todoroo.astrid.actfm.TagUpdatesActivity; import com.todoroo.astrid.actfm.TagUpdatesActivity;
import com.todoroo.astrid.actfm.TagViewFragment; import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener; import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener;
@ -96,12 +99,14 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.GCalControlSet;
import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.gcal.GCalHelper;
import com.todoroo.astrid.helper.MetadataHelper; import com.todoroo.astrid.helper.MetadataHelper;
import com.todoroo.astrid.helper.ProgressBarSyncResultCallback; import com.todoroo.astrid.helper.ProgressBarSyncResultCallback;
import com.todoroo.astrid.helper.TaskListContextMenuExtensionLoader; import com.todoroo.astrid.helper.TaskListContextMenuExtensionLoader;
import com.todoroo.astrid.helper.TaskListContextMenuExtensionLoader.ContextMenuItem; import com.todoroo.astrid.helper.TaskListContextMenuExtensionLoader.ContextMenuItem;
import com.todoroo.astrid.reminders.ReminderDebugContextActions; import com.todoroo.astrid.reminders.ReminderDebugContextActions;
import com.todoroo.astrid.repeats.RepeatControlSet;
import com.todoroo.astrid.service.AddOnService; import com.todoroo.astrid.service.AddOnService;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
@ -115,6 +120,7 @@ import com.todoroo.astrid.service.UpgradeService;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import com.todoroo.astrid.sync.SyncV2Provider; import com.todoroo.astrid.sync.SyncV2Provider;
import com.todoroo.astrid.ui.DateChangedAlerts; import com.todoroo.astrid.ui.DateChangedAlerts;
import com.todoroo.astrid.ui.DeadlineControlSet;
import com.todoroo.astrid.utility.AstridPreferences; import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.utility.Flags;
@ -229,6 +235,11 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
protected OnTaskListItemClickedListener mListener; protected OnTaskListItemClickedListener mListener;
private boolean mDualFragments = false; private boolean mDualFragments = false;
private DeadlineControlSet deadlineControl;
private RepeatControlSet repeatControl;
private GCalControlSet gcalControl;
private EditPeopleControlSet peopleControl;
/* /*
* ====================================================================== * ======================================================================
* ======================================================= initialization * ======================================================= initialization
@ -503,6 +514,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
} }
}); });
setUpQuickAddControlSets();
// set listener for pressing enter in quick-add box // set listener for pressing enter in quick-add box
quickAddBox = (EditText) getView().findViewById(R.id.quickAddText); quickAddBox = (EditText) getView().findViewById(R.id.quickAddText);
quickAddBox.setOnEditorActionListener(new OnEditorActionListener() { quickAddBox.setOnEditorActionListener(new OnEditorActionListener() {
@ -595,6 +608,44 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
getView().findViewById(R.id.progressBar).setVisibility(View.GONE); getView().findViewById(R.id.progressBar).setVisibility(View.GONE);
} }
private void setUpQuickAddControlSets() {
repeatControl = new RepeatControlSet(getActivity(),
R.layout.control_set_repeat,
R.layout.control_set_repeat_display, R.string.repeat_enabled);
gcalControl = new GCalControlSet(getActivity(),
R.layout.control_set_gcal, R.layout.control_set_gcal_display,
R.string.gcal_TEA_addToCalendar_label);
deadlineControl = new DeadlineControlSet(
getActivity(), R.layout.control_set_deadline,
R.layout.control_set_default_display,
repeatControl.getDisplayView(), gcalControl.getDisplayView());
deadlineControl.setUseNewlineForDisplaySeparator(true);
peopleControl = new EditPeopleControlSet(getActivity(),
R.layout.control_set_assigned,
R.layout.control_set_default_display,
R.string.actfm_EPA_assign_label, TaskEditFragment.REQUEST_LOG_IN);
resetControlSets();
LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1.0f);
LinearLayout container = (LinearLayout) getView().findViewById(R.id.taskListQuickaddControls);
container.addView(peopleControl.getDisplayView(), 0, lp);
container.addView(deadlineControl.getDisplayView(), 2, lp);
}
private void resetControlSets() {
Task empty = new Task();
repeatControl.readFromTask(empty);
gcalControl.readFromTask(empty);
deadlineControl.readFromTask(empty);
peopleControl.setUpData(empty);
peopleControl.setTask(null);
}
// Subclasses can override these to customize extras in quickadd intent // Subclasses can override these to customize extras in quickadd intent
protected Intent getOnClickQuickAddIntent(Task t) { protected Intent getOnClickQuickAddIntent(Task t) {
Intent intent = new Intent(getActivity(), TaskEditActivity.class); Intent intent = new Intent(getActivity(), TaskEditActivity.class);
@ -1079,6 +1130,18 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
Task task = createWithValues(filter.valuesForNewTasks, title, Task task = createWithValues(filter.valuesForNewTasks, title,
taskService, metadataService); taskService, metadataService);
//TODO: fix assigned
if (repeatControl.isRecurrenceSet())
repeatControl.writeToModel(task);
if (deadlineControl.isDeadlineSet())
deadlineControl.writeToModel(task);
gcalControl.writeToModel(task);
//peopleControl.setTask(task);
//peopleControl.saveSharingSettings("");
taskService.save(task);
resetControlSets();
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( && !Preferences.getStringValue(R.string.gcal_p_default).equals(
"-1"); "-1");

@ -93,10 +93,10 @@ public class DateAndTimeDialog extends Dialog {
} }
public String getDisplayString(Context context) { public String getDisplayString(Context context) {
return dateAndTimePicker.getDisplayString(context); return dateAndTimePicker.getDisplayString(context, false);
} }
public String getDisplayString(Context context, long forDate) { public String getDisplayString(Context context, long forDate) {
return DateAndTimePicker.getDisplayString(context, forDate); return DateAndTimePicker.getDisplayString(context, forDate, false);
} }
} }

@ -223,18 +223,18 @@ public class DateAndTimePicker extends LinearLayout {
this.listener = listener; this.listener = listener;
} }
public String getDisplayString(Context context) { public String getDisplayString(Context context, boolean useNewline) {
long dueDate = constructDueDate(); long dueDate = constructDueDate();
return getDisplayString(context, dueDate); return getDisplayString(context, dueDate, useNewline);
} }
public static String getDisplayString(Context context, long forDate) { public static String getDisplayString(Context context, long forDate, boolean useNewline) {
StringBuilder displayString = new StringBuilder(); StringBuilder displayString = new StringBuilder();
Date d = new Date(forDate); Date d = new Date(forDate);
if (d.getTime() > 0) { if (d.getTime() > 0) {
displayString.append(DateUtilities.getDateString(context, d)); displayString.append(DateUtilities.getDateString(context, d));
if (Task.hasDueTime(forDate)) { if (Task.hasDueTime(forDate)) {
displayString.append(", "); //$NON-NLS-1$ displayString.append(useNewline ? "\n" : ", "); //$NON-NLS-1$ //$NON-NLS-2$
displayString.append(DateUtilities.getTimeString(context, d)); displayString.append(DateUtilities.getTimeString(context, d));
} }
} }

@ -15,6 +15,7 @@ import com.todoroo.astrid.data.Task;
public class DeadlineControlSet extends PopupControlSet { public class DeadlineControlSet extends PopupControlSet {
private boolean useNewline = false;
private final DateAndTimePicker dateAndTimePicker; private final DateAndTimePicker dateAndTimePicker;
public DeadlineControlSet(Activity activity, int viewLayout, int displayViewLayout, View...extraViews) { public DeadlineControlSet(Activity activity, int viewLayout, int displayViewLayout, View...extraViews) {
@ -43,14 +44,14 @@ public class DeadlineControlSet extends PopupControlSet {
@Override @Override
protected void refreshDisplayView() { protected void refreshDisplayView() {
TextView dateDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit); TextView dateDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
String toDisplay = dateAndTimePicker.getDisplayString(activity); String toDisplay = dateAndTimePicker.getDisplayString(activity, useNewline);
dateDisplay.setText(toDisplay); dateDisplay.setText(toDisplay);
} }
@Override @Override
public void readFromTask(Task task) { public void readFromTask(Task task) {
long dueDate = task.getValue(Task.DUE_DATE); long dueDate = task.getValue(Task.DUE_DATE);
dateAndTimePicker.initializeWithDate(dueDate); initializeWithDate(dueDate);
refreshDisplayView(); refreshDisplayView();
} }
@ -60,4 +61,20 @@ public class DeadlineControlSet extends PopupControlSet {
task.setValue(Task.DUE_DATE, dueDate); task.setValue(Task.DUE_DATE, dueDate);
return null; return null;
} }
public void initializeWithDate(long dueDate) {
dateAndTimePicker.initializeWithDate(dueDate);
}
public boolean isDeadlineSet() {
return dateAndTimePicker.constructDueDate() != 0;
}
/**
* Set whether date and time should be separated by a newline or a comma
* in the display view
*/
public void setUseNewlineForDisplaySeparator(boolean useNewline) {
this.useNewline = useNewline;
}
} }

@ -249,7 +249,7 @@ public class HideUntilControlSet extends PopupControlSet implements OnItemSelect
task.setValue(Task.HIDE_UNTIL, value); task.setValue(Task.HIDE_UNTIL, value);
if (value != 0) if (value != 0)
return activity.getString(R.string.TEA_hideUntil_message, DateAndTimePicker.getDisplayString(activity, value)); return activity.getString(R.string.TEA_hideUntil_message, DateAndTimePicker.getDisplayString(activity, value, false));
return null; return null;
} }

Loading…
Cancel
Save