Remove constant parameters from control sets

pull/189/head
Alex Baker 12 years ago
parent 61b59575d3
commit 4bf6610377

@ -352,8 +352,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
controlSetMap = new HashMap<>();
// populate control set
EditTitleControlSet editTitle = new EditTitleControlSet(taskService, getActivity(),
R.layout.control_set_title, R.id.title);
EditTitleControlSet editTitle = new EditTitleControlSet(taskService, getActivity());
title = (EditText) editTitle.getView().findViewById(R.id.title);
controls.add(editTitle);
titleControls.addView(editTitle.getDisplayView(), 0, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));
@ -361,19 +360,14 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
timerAction = new TimerActionControlSet(notificationManager, taskService, getActivity(), getView());
controls.add(timerAction);
TagsControlSet tagsControlSet = new TagsControlSet(preferences, tagService, getActivity(),
R.layout.control_set_tags, R.layout.control_set_default_display, R.string.TEA_tags_label_long);
TagsControlSet tagsControlSet = new TagsControlSet(preferences, tagService, getActivity());
controls.add(tagsControlSet);
controlSetMap.put(getString(R.string.TEA_ctrl_lists_pref),
tagsControlSet);
RepeatControlSet repeatControls = new RepeatControlSet(preferences, getActivity(),
R.layout.control_set_repeat,
R.layout.control_set_repeat_display, R.string.repeat_enabled);
RepeatControlSet repeatControls = new RepeatControlSet(preferences, getActivity());
GCalControlSet gcalControl = new GCalControlSet(preferences, gcalHelper, getActivity(),
R.layout.control_set_gcal, R.layout.control_set_gcal_display,
R.string.gcal_TEA_addToCalendar_label);
GCalControlSet gcalControl = new GCalControlSet(preferences, gcalHelper, getActivity());
// The deadline control set contains the repeat controls and the
// calendar controls.
@ -382,8 +376,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
// otherwise the correct date may not be written to the calendar event.
// Order matters!
DeadlineControlSet deadlineControl = new DeadlineControlSet(
preferences, getActivity(), R.layout.control_set_deadline,
R.layout.control_set_deadline_display, repeatControls,
preferences, getActivity(), R.layout.control_set_deadline_display, repeatControls,
repeatControls.getDisplayView(), gcalControl.getDisplayView());
controlSetMap.put(getString(R.string.TEA_ctrl_when_pref),
deadlineControl);
@ -392,32 +385,25 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
controls.add(deadlineControl);
controls.add(gcalControl);
ImportanceControlSet importanceControl = new ImportanceControlSet(
getActivity(), R.layout.control_set_importance);
ImportanceControlSet importanceControl = new ImportanceControlSet(getActivity());
controls.add(importanceControl);
importanceControl.addListener(editTitle);
controlSetMap.put(getString(R.string.TEA_ctrl_importance_pref),
importanceControl);
notesControlSet = new EditNotesControlSet(preferences, getActivity(),
R.layout.control_set_notes, R.layout.control_set_notes_display);
notesControlSet = new EditNotesControlSet(preferences, getActivity());
notesEditText = (EditText) notesControlSet.getView().findViewById(
R.id.notes);
controls.add(notesControlSet);
controlSetMap.put(getString(R.string.TEA_ctrl_notes_pref),
notesControlSet);
ReminderControlSet reminderControl = new ReminderControlSet(preferences,
alarmService, getActivity(), R.layout.control_set_reminders,
R.layout.control_set_default_display);
ReminderControlSet reminderControl = new ReminderControlSet(preferences, alarmService, getActivity());
controls.add(reminderControl);
controlSetMap.put(getString(R.string.TEA_ctrl_reminders_pref),
reminderControl);
HideUntilControlSet hideUntilControls = new HideUntilControlSet(preferences, getActivity(),
R.layout.control_set_hide,
R.layout.control_set_default_display,
R.string.hide_until_prompt);
HideUntilControlSet hideUntilControls = new HideUntilControlSet(preferences, getActivity());
controls.add(hideUntilControls);
controlSetMap.put(getString(R.string.TEA_ctrl_hide_until_pref), hideUntilControls);
@ -432,8 +418,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
controls.add(timerControl);
controlSetMap.put(getString(R.string.TEA_ctrl_timer_pref), timerControl);
filesControlSet = new FilesControlSet(preferences, taskAttachmentDao, getActivity(),
R.layout.control_set_files, R.layout.control_set_files_display, R.string.TEA_control_files);
filesControlSet = new FilesControlSet(preferences, taskAttachmentDao, getActivity());
controls.add(filesControlSet);
controlSetMap.put(getString(R.string.TEA_ctrl_files_pref), filesControlSet);

@ -628,8 +628,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
private void showFilesDialog(Task task) {
FilesControlSet filesControlSet = new FilesControlSet(preferences, taskAttachmentDao,
fragment.getActivity(), R.layout.control_set_files,
R.layout.control_set_files_display, R.string.TEA_control_files);
fragment.getActivity());
filesControlSet.readFromTask(task);
filesControlSet.getDisplayView().performClick();
}

@ -44,8 +44,8 @@ public final class AlarmControlSet extends TaskEditControlSet {
private LinearLayout alertsContainer;
private DateAndTimeDialog pickerDialog;
public AlarmControlSet(ActivityPreferences preferences, AlarmService alarmService, Activity activity, int layout) {
super(activity, layout);
public AlarmControlSet(ActivityPreferences preferences, AlarmService alarmService, Activity activity) {
super(activity, R.layout.control_set_alarms);
this.preferences = preferences;
this.alarmService = alarmService;
}

@ -56,8 +56,8 @@ public class FilesControlSet extends PopupControlSet {
private final ImageView image;
private final TaskAttachmentDao taskAttachmentDao;
public FilesControlSet(ActivityPreferences preferences, TaskAttachmentDao taskAttachmentDao, Activity activity, int viewLayout, int displayViewLayout, int title) {
super(preferences, activity, viewLayout, displayViewLayout, title);
public FilesControlSet(ActivityPreferences preferences, TaskAttachmentDao taskAttachmentDao, Activity activity) {
super(preferences, activity, R.layout.control_set_files, R.layout.control_set_files_display, R.string.TEA_control_files);
this.taskAttachmentDao = taskAttachmentDao;
fileDisplayList = (LinearLayout) getDisplayView().findViewById(R.id.files_list);
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);

@ -45,6 +45,7 @@ import static org.tasks.preferences.ResourceResolver.getResource;
public class GCalControlSet extends PopupControlSet {
private static final Logger log = LoggerFactory.getLogger(GCalControlSet.class);
private static final int title = R.string.gcal_TEA_addToCalendar_label;
// --- instance variables
@ -55,13 +56,11 @@ public class GCalControlSet extends PopupControlSet {
private final GCalHelper.CalendarResult calendars;
private boolean hasEvent = false;
private Spinner calendarSelector;
private final int title;
private final ImageView image;
public GCalControlSet(ActivityPreferences preferences, GCalHelper gcal, final Activity activity, int viewLayout, int displayViewLayout, int title) {
super(preferences, activity, viewLayout, displayViewLayout, title);
public GCalControlSet(ActivityPreferences preferences, GCalHelper gcal, final Activity activity) {
super(preferences, activity, R.layout.control_set_gcal, R.layout.control_set_gcal_display, title);
this.gcal = gcal;
this.title = title;
this.calendars = gcal.getCalendars();
getView(); // Hack to force initialized
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);

@ -94,8 +94,8 @@ public class RepeatControlSet extends PopupControlSet {
// --- implementation
public RepeatControlSet(ActivityPreferences preferences, Activity activity, int viewLayout, int displayViewLayout, int title) {
super(preferences, activity, viewLayout, displayViewLayout, title);
public RepeatControlSet(ActivityPreferences preferences, Activity activity) {
super(preferences, activity, R.layout.control_set_repeat, R.layout.control_set_repeat_display, R.string.repeat_enabled);
}
/** Set up the repeat value button */

@ -66,8 +66,8 @@ public final class TagsControlSet extends PopupControlSet {
private final TagService tagService;
public TagsControlSet(ActivityPreferences preferences, TagService tagService, Activity activity, int viewLayout, int displayViewLayout, int title) {
super(preferences, activity, viewLayout, displayViewLayout, title);
public TagsControlSet(ActivityPreferences preferences, TagService tagService, Activity activity) {
super(preferences, activity, R.layout.control_set_tags, R.layout.control_set_default_display, R.string.TEA_tags_label_long);
this.tagService = tagService;
tagsDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);

@ -45,12 +45,8 @@ public class TimerControlSet extends PopupControlSet implements TimerActionListe
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);
estimated = new TimeDurationTaskEditControlSet(activity, getView(), Task.ESTIMATED_SECONDS,
R.id.estimatedDuration, 0, R.string.DLG_hour_minutes
);
elapsed = new TimeDurationTaskEditControlSet(activity, getView(), Task.ELAPSED_SECONDS, R.id.elapsedDuration,
0, R.string.DLG_hour_minutes
);
estimated = new TimeDurationTaskEditControlSet(activity, getView(), Task.ESTIMATED_SECONDS,R.id.estimatedDuration);
elapsed = new TimeDurationTaskEditControlSet(activity, getView(), Task.ELAPSED_SECONDS, R.id.elapsedDuration);
}
@Override
@ -83,12 +79,10 @@ public class TimerControlSet extends PopupControlSet implements TimerActionListe
private final TimeDurationControlSet controlSet;
private final IntegerProperty property;
public TimeDurationTaskEditControlSet(Activity activity, View v, IntegerProperty property, int timeButtonId,
int prefixResource, int titleResource) {
public TimeDurationTaskEditControlSet(Activity activity, View v, IntegerProperty property, int timeButtonId) {
super(activity, -1);
this.property = property;
this.controlSet = new TimeDurationControlSet(activity, v, property,
timeButtonId, prefixResource, titleResource);
this.controlSet = new TimeDurationControlSet(activity, v, property, timeButtonId);
}
@Override

@ -36,9 +36,9 @@ public class DeadlineControlSet extends PopupControlSet {
private final RepeatControlSet repeatControlSet;
private final ImageView image;
public DeadlineControlSet(ActivityPreferences preferences, Activity activity, int viewLayout, int displayViewLayout,
public DeadlineControlSet(ActivityPreferences preferences, Activity activity, int displayViewLayout,
RepeatControlSet repeatControlSet, View...extraViews) {
super(preferences, activity, viewLayout, displayViewLayout, 0);
super(preferences, activity, R.layout.control_set_deadline, displayViewLayout, 0);
this.extraViews = extraViews;
this.repeatControlSet = repeatControlSet;
this.image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);

@ -29,8 +29,8 @@ public class EditNotesControlSet extends PopupControlSet {
protected TextView notesPreview;
protected ImageView image;
public EditNotesControlSet(ActivityPreferences preferences, Activity activity, int viewLayout, int displayViewLayout) {
super(preferences, activity, viewLayout, displayViewLayout, R.string.TEA_note_label);
public EditNotesControlSet(ActivityPreferences preferences, Activity activity) {
super(preferences, activity, R.layout.control_set_notes, R.layout.control_set_notes_display, R.string.TEA_note_label);
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);
}

@ -32,19 +32,20 @@ import org.tasks.R;
*
*/
public class EditTitleControlSet extends TaskEditControlSet implements ImportanceChangedListener, RepeatChangedListener {
private static final int editTextId = R.id.title;
private EditText editText;
protected CheckableImageView completeBox;
private final int editTextId;
private boolean isRepeating;
private int importanceValue;
private final TaskService taskService;
public EditTitleControlSet(TaskService taskService, Activity activity, int layout, int editText) {
super(activity, layout);
public EditTitleControlSet(TaskService taskService, Activity activity) {
super(activity, R.layout.control_set_title);
this.taskService = taskService;
this.editTextId = editText;
}
@Override

@ -36,21 +36,21 @@ import static org.tasks.preferences.ResourceResolver.getResource;
*/
public class HideUntilControlSet extends PopupControlSet implements OnItemSelectedListener {
private static final int title = R.string.hide_until_prompt;
private static final int SPECIFIC_DATE = -1;
private static final int EXISTING_TIME_UNSET = -2;
//private final CheckBox enabled;
private Spinner spinner;
private int previousSetting = Task.HIDE_UNTIL_NONE;
private final int title;
private int selection;
private final ImageView image;
private long existingDate = EXISTING_TIME_UNSET;
public HideUntilControlSet(ActivityPreferences preferences, Activity activity, int viewLayout, int displayViewLayout, int title) {
super(preferences, activity, viewLayout, displayViewLayout, title);
this.title = title;
public HideUntilControlSet(ActivityPreferences preferences, Activity activity) {
super(preferences, activity, R.layout.control_set_hide, R.layout.control_set_default_display, title);
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);
}

@ -40,8 +40,8 @@ public class ImportanceControlSet extends TaskEditControlSet {
public void importanceChanged(int i);
}
public ImportanceControlSet(Activity activity, int layout) {
super(activity, layout);
public ImportanceControlSet(Activity activity) {
super(activity, R.layout.control_set_importance);
colors = Task.getImportanceColors(activity.getResources());
}

@ -202,16 +202,11 @@ public class QuickAddBar extends LinearLayout {
private void setUpQuickAddControlSets() {
repeatControl = new RepeatControlSet(preferences, activity,
R.layout.control_set_repeat,
R.layout.control_set_repeat_display, R.string.repeat_enabled);
repeatControl = new RepeatControlSet(preferences, activity);
gcalControl = new GCalControlSet(preferences, gcalHelper, activity,
R.layout.control_set_gcal, R.layout.control_set_gcal_display,
R.string.gcal_TEA_addToCalendar_label);
gcalControl = new GCalControlSet(preferences, gcalHelper, activity);
deadlineControl = new DeadlineControlSet(preferences, activity,
R.layout.control_set_deadline,
R.layout.control_set_default_display, null,
repeatControl.getDisplayView(), gcalControl.getDisplayView());
deadlineControl.setIsQuickadd();

@ -49,8 +49,8 @@ public class ReminderControlSet extends PopupControlSet {
private final AlarmService alarmService;
public ReminderControlSet(ActivityPreferences preferences, AlarmService alarmService,
Activity activity, int viewLayout, int displayViewLayout) {
super(preferences, activity, viewLayout, displayViewLayout, R.string.TEA_reminders_group_label);
Activity activity) {
super(preferences, activity, R.layout.control_set_reminders, R.layout.control_set_default_display, R.string.TEA_reminders_group_label);
this.alarmService = alarmService;
extraViews = new ArrayList<>();
label = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
@ -115,7 +115,7 @@ public class ReminderControlSet extends PopupControlSet {
});
randomControlSet = new RandomReminderControlSet(activity, getView(), -1);
alarmControl = new AlarmControlSet(preferences, alarmService, activity, R.layout.control_set_alarms);
alarmControl = new AlarmControlSet(preferences, alarmService, activity);
alarmControl.readFromTask(model);
remindersBody = (LinearLayout) getView().findViewById(R.id.reminders_body);

@ -21,20 +21,15 @@ public class TimeDurationControlSet implements OnNNumberPickedListener, View.OnC
private final Activity activity;
private final TextView timeButton;
private final int prefixResource;
private int timeDuration;
private int[] initialValues = null;
private final int titleResource;
private NNumberPickerDialog dialog = null;
private Task model;
private final IntegerProperty property;
public TimeDurationControlSet(Activity activity, View view, IntegerProperty property,
int timeButtonId, int prefixResource, int titleResource) {
int timeButtonId) {
this.activity = activity;
this.prefixResource = prefixResource;
this.titleResource = titleResource;
this.property = property;
timeButton = (TextView)view.findViewById(timeButtonId);
@ -63,9 +58,6 @@ public class TimeDurationControlSet implements OnNNumberPickedListener, View.OnC
}
String prefix = "";
if (prefixResource != 0) {
prefix = r.getString(prefixResource) + " ";
}
timeButton.setText(prefix + DateUtils.formatElapsedTime(timeDuration));
int hours = timeDuration / 3600;
int minutes = timeDuration / 60 - 60 * hours;
@ -87,7 +79,7 @@ public class TimeDurationControlSet implements OnNNumberPickedListener, View.OnC
public void onClick(View v) {
if(dialog == null) {
dialog = new NNumberPickerDialog(activity, this,
activity.getResources().getString(titleResource),
activity.getResources().getString(R.string.DLG_hour_minutes),
new int[] {0, 0}, new int[] {1, 5}, new int[] {0, 0},
new int[] {999, 59}, new String[] {":", null});
final NumberPicker hourPicker = dialog.getPicker(0);

Loading…
Cancel
Save