|
|
|
@ -39,21 +39,26 @@ import android.support.v4.app.Fragment;
|
|
|
|
|
import android.support.v4.app.SupportActivity;
|
|
|
|
|
import android.support.v4.view.Menu;
|
|
|
|
|
import android.support.v4.view.MenuItem;
|
|
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.View.MeasureSpec;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
import android.view.ViewGroup.LayoutParams;
|
|
|
|
|
import android.view.animation.Animation;
|
|
|
|
|
import android.view.animation.AnimationUtils;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.timsu.astrid.R;
|
|
|
|
@ -94,17 +99,20 @@ import com.todoroo.astrid.ui.EditTitleControlSet;
|
|
|
|
|
import com.todoroo.astrid.ui.HideUntilControlSet;
|
|
|
|
|
import com.todoroo.astrid.ui.ImportanceControlSet;
|
|
|
|
|
import com.todoroo.astrid.ui.ReminderControlSet;
|
|
|
|
|
import com.todoroo.astrid.ui.TaskEditMoreControls;
|
|
|
|
|
import com.todoroo.astrid.voice.VoiceInputAssistant;
|
|
|
|
|
import com.viewpagerindicator.TabPageIndicator;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This activity is responsible for creating new tasks and editing existing
|
|
|
|
|
* ones. It saves a task when it is paused (screen rotated, back button
|
|
|
|
|
* pressed) as long as the task has a title.
|
|
|
|
|
* ones. It saves a task when it is paused (screen rotated, back button pressed)
|
|
|
|
|
* as long as the task has a title.
|
|
|
|
|
*
|
|
|
|
|
* @author timsu
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public final class TaskEditActivity extends Fragment {
|
|
|
|
|
public final class TaskEditActivity extends Fragment implements
|
|
|
|
|
ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
|
|
|
|
|
|
|
|
|
|
public static final String TAG_TASKEDIT_FRAGMENT = "taskedit_fragment";
|
|
|
|
|
|
|
|
|
@ -164,6 +172,9 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
// --- services
|
|
|
|
|
|
|
|
|
|
public static final int TAB_VIEW_UPDATES = 0;
|
|
|
|
|
public static final int TAB_VIEW_MORE = 1;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ExceptionService exceptionService;
|
|
|
|
|
|
|
|
|
@ -191,9 +202,13 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
private HideUntilControlSet hideUntilControls = null;
|
|
|
|
|
private TagsControlSet tagsControlSet = null;
|
|
|
|
|
private EditText title;
|
|
|
|
|
private TaskEditMoreControls moreControls;
|
|
|
|
|
private EditNoteActivity editNotes;
|
|
|
|
|
private ViewPager mPager;
|
|
|
|
|
private TaskEditViewPager mAdapter;
|
|
|
|
|
private TabPageIndicator mIndicator;
|
|
|
|
|
|
|
|
|
|
private final List<TaskEditControlSet> controls =
|
|
|
|
|
Collections.synchronizedList(new ArrayList<TaskEditControlSet>());
|
|
|
|
|
private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>());
|
|
|
|
|
|
|
|
|
|
// --- other instance variables
|
|
|
|
|
|
|
|
|
@ -220,24 +235,30 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
// --- fragment handling variables
|
|
|
|
|
OnTaskEditDetailsClickedListener mListener;
|
|
|
|
|
|
|
|
|
|
private boolean mDualFragments = false;
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
|
private long remoteId = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ======================================================================
|
|
|
|
|
* ======================================================= initialization
|
|
|
|
|
* ====================================================================== */
|
|
|
|
|
* ======================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** 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 OnTaskEditDetailsClickedListener {
|
|
|
|
|
public void onTaskEditDetailsClicked(int category, int position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAttach(SupportActivity 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 {
|
|
|
|
|
mListener = (OnTaskEditDetailsClickedListener) activity;
|
|
|
|
|
} catch (ClassCastException e) {
|
|
|
|
@ -257,7 +278,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
new StartupService().onStartupApplication(getActivity());
|
|
|
|
|
|
|
|
|
|
// if we were editing a task already, restore it
|
|
|
|
|
if(savedInstanceState != null && savedInstanceState.containsKey(TASK_IN_PROGRESS)) {
|
|
|
|
|
if (savedInstanceState != null
|
|
|
|
|
&& savedInstanceState.containsKey(TASK_IN_PROGRESS)) {
|
|
|
|
|
Task task = savedInstanceState.getParcelable(TASK_IN_PROGRESS);
|
|
|
|
|
if (task != null) {
|
|
|
|
|
model = task;
|
|
|
|
@ -265,19 +287,21 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getActivity().setResult(Activity.RESULT_OK);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
|
/*
|
|
|
|
|
* ======================================================================
|
|
|
|
|
* ==================================================== UI initialization
|
|
|
|
|
* ====================================================================== */
|
|
|
|
|
* ======================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
|
|
Bundle savedInstanceState) {
|
|
|
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
|
|
|
|
View v = inflater.inflate(R.layout.task_edit_activity,
|
|
|
|
|
container, false);
|
|
|
|
|
View v = inflater.inflate(R.layout.task_edit_activity, container, false);
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
@ -287,26 +311,89 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
|
|
// We have a menu item to show in action bar.
|
|
|
|
|
setHasOptionsMenu(true);
|
|
|
|
|
getSupportActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
getSupportActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(
|
|
|
|
|
true);
|
|
|
|
|
|
|
|
|
|
Fragment tasklistFrame = getFragmentManager().findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
|
|
|
|
|
Fragment tasklistFrame = getFragmentManager().findFragmentByTag(
|
|
|
|
|
TaskListActivity.TAG_TASKLIST_FRAGMENT);
|
|
|
|
|
mDualFragments = (tasklistFrame != null) && tasklistFrame.isInLayout();
|
|
|
|
|
|
|
|
|
|
setUpUIComponents();
|
|
|
|
|
adjustInfoPopovers();
|
|
|
|
|
|
|
|
|
|
overrideFinishAnim = getActivity().getIntent().getBooleanExtra(OVERRIDE_FINISH_ANIM, true);
|
|
|
|
|
overrideFinishAnim = getActivity().getIntent().getBooleanExtra(
|
|
|
|
|
OVERRIDE_FINISH_ANIM, true);
|
|
|
|
|
|
|
|
|
|
// disable keyboard until user requests it
|
|
|
|
|
AndroidUtilities.suppressVirtualKeyboard(title);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadMoreContainer() {
|
|
|
|
|
View more_tab = (View) getView().findViewById(R.id.more_container);
|
|
|
|
|
View more_container = (View) getView().findViewById(R.id.more_header);
|
|
|
|
|
View commentsBar = (View) getView().findViewById(R.id.updatesFooter);
|
|
|
|
|
|
|
|
|
|
if (moreControls.getParent() != null) {
|
|
|
|
|
((ViewGroup) moreControls.getParent()).removeView(moreControls);
|
|
|
|
|
}
|
|
|
|
|
if (remoteId > 0) {
|
|
|
|
|
|
|
|
|
|
if (mAdapter == null) {
|
|
|
|
|
mAdapter = new TaskEditViewPager(getActivity());
|
|
|
|
|
mAdapter.parent = this;
|
|
|
|
|
|
|
|
|
|
mPager = (ViewPager) getView().findViewById(R.id.pager);
|
|
|
|
|
mPager.setAdapter(mAdapter);
|
|
|
|
|
|
|
|
|
|
mIndicator = (TabPageIndicator) getView().findViewById(
|
|
|
|
|
R.id.indicator);
|
|
|
|
|
mIndicator.setViewPager(mPager);
|
|
|
|
|
mIndicator.setOnPageChangeListener(this);
|
|
|
|
|
|
|
|
|
|
long idParam = getActivity().getIntent().getLongExtra(TOKEN_ID,
|
|
|
|
|
-1L);
|
|
|
|
|
editNotes = new EditNoteActivity(getActivity(), getView(),
|
|
|
|
|
idParam);
|
|
|
|
|
editNotes.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
|
|
|
|
|
|
|
|
|
if (editNotes.numberOfComments() == 0) {
|
|
|
|
|
setCurrentTab(TAB_VIEW_MORE);
|
|
|
|
|
} else {
|
|
|
|
|
setPagerHeightForPosition(TAB_VIEW_UPDATES);
|
|
|
|
|
}
|
|
|
|
|
editNotes.addListener(this);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commentsBar.setVisibility(View.VISIBLE);
|
|
|
|
|
more_tab.setVisibility(View.VISIBLE);
|
|
|
|
|
more_container.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
more_container.setVisibility(View.VISIBLE);
|
|
|
|
|
more_tab.setVisibility(View.GONE);
|
|
|
|
|
commentsBar.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setCurrentTab(int position) {
|
|
|
|
|
mIndicator.setCurrentItem(position);
|
|
|
|
|
mPager.setCurrentItem(position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Initialize UI components */
|
|
|
|
|
private void setUpUIComponents() {
|
|
|
|
|
LinearLayout basicControls = (LinearLayout) getView().findViewById(R.id.basic_controls);
|
|
|
|
|
LinearLayout whenDialogView = (LinearLayout) LayoutInflater.from(getActivity()).inflate(
|
|
|
|
|
R.layout.task_edit_when_controls, null);
|
|
|
|
|
LinearLayout moreControls = (LinearLayout) getView().findViewById(R.id.more_controls);
|
|
|
|
|
|
|
|
|
|
LinearLayout basicControls = (LinearLayout) getView().findViewById(
|
|
|
|
|
R.id.basic_controls);
|
|
|
|
|
LinearLayout titleControls = (LinearLayout) getView().findViewById(
|
|
|
|
|
R.id.title_controls);
|
|
|
|
|
LinearLayout whenDialogView = (LinearLayout) LayoutInflater.from(
|
|
|
|
|
getActivity()).inflate(R.layout.task_edit_when_controls, null);
|
|
|
|
|
moreControls = (TaskEditMoreControls) LayoutInflater.from(getActivity()).inflate(
|
|
|
|
|
R.layout.task_edit_more_controls, null);
|
|
|
|
|
|
|
|
|
|
constructWhenDialog(whenDialogView);
|
|
|
|
|
|
|
|
|
@ -317,43 +404,44 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
R.layout.control_set_title, Task.TITLE, R.id.title);
|
|
|
|
|
title = (EditText) editTitle.getView().findViewById(R.id.title);
|
|
|
|
|
controls.add(editTitle);
|
|
|
|
|
controlSetMap.put(getString(R.string.TEA_ctrl_title_pref), editTitle);
|
|
|
|
|
titleControls.addView(editTitle.getDisplayView());
|
|
|
|
|
|
|
|
|
|
TimerActionControlSet timerAction = new TimerActionControlSet(getActivity(),
|
|
|
|
|
editTitle.getView());
|
|
|
|
|
TimerActionControlSet timerAction = new TimerActionControlSet(
|
|
|
|
|
getActivity(), editTitle.getView());
|
|
|
|
|
controls.add(timerAction);
|
|
|
|
|
|
|
|
|
|
controls.add(peopleControlSet = new EditPeopleControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_assigned,
|
|
|
|
|
R.layout.control_set_assigned_display,
|
|
|
|
|
controls.add(peopleControlSet = new EditPeopleControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_assigned,
|
|
|
|
|
R.layout.control_set_default_display,
|
|
|
|
|
R.string.actfm_EPA_assign_label, REQUEST_LOG_IN));
|
|
|
|
|
controlSetMap.put(getString(R.string.TEA_ctrl_who_pref),
|
|
|
|
|
peopleControlSet);
|
|
|
|
|
|
|
|
|
|
RepeatControlSet repeatControls = new RepeatControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_repeat,
|
|
|
|
|
RepeatControlSet repeatControls = new RepeatControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_repeat,
|
|
|
|
|
R.layout.control_set_repeat_display, R.string.repeat_enabled);
|
|
|
|
|
|
|
|
|
|
GCalControlSet gcalControl = new GCalControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_gcal, R.layout.control_set_gcal_display,
|
|
|
|
|
R.string.gcal_TEA_addToCalendar_label);
|
|
|
|
|
|
|
|
|
|
//The deadline control set contains the repeat controls and the calendar controls.
|
|
|
|
|
//NOTE: we add the gcalControl and repeatControl to the list AFTER the deadline control, because
|
|
|
|
|
//otherwise the correct date may not be written to the calendar event. Order matters!
|
|
|
|
|
// The deadline control set contains the repeat controls and the
|
|
|
|
|
// calendar controls.
|
|
|
|
|
// NOTE: we add the gcalControl and repeatControl to the list AFTER the
|
|
|
|
|
// deadline control, because
|
|
|
|
|
// otherwise the correct date may not be written to the calendar event.
|
|
|
|
|
// Order matters!
|
|
|
|
|
DeadlineControlSet deadlineControl = new DeadlineControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_deadline,
|
|
|
|
|
R.layout.control_set_deadline_display, repeatControls.getDisplayView(), gcalControl.getDisplayView());
|
|
|
|
|
R.layout.control_set_default_display,
|
|
|
|
|
repeatControls.getDisplayView(), gcalControl.getDisplayView());
|
|
|
|
|
controlSetMap.put(getString(R.string.TEA_ctrl_when_pref),
|
|
|
|
|
deadlineControl);
|
|
|
|
|
controls.add(deadlineControl);
|
|
|
|
|
controlSetMap.put(getString(R.string.TEA_ctrl_when_pref), deadlineControl);
|
|
|
|
|
controls.add(repeatControls);
|
|
|
|
|
repeatControls.addListener(editTitle);
|
|
|
|
|
controls.add(gcalControl);
|
|
|
|
|
|
|
|
|
|
hideUntilControls = new HideUntilControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_hide, R.layout.control_set_hide_display,
|
|
|
|
|
R.string.hide_until_prompt);
|
|
|
|
|
controls.add(hideUntilControls);
|
|
|
|
|
|
|
|
|
|
ImportanceControlSet importanceControl = new ImportanceControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_importance);
|
|
|
|
|
controls.add(importanceControl);
|
|
|
|
@ -362,8 +450,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
importanceControl);
|
|
|
|
|
|
|
|
|
|
tagsControlSet = new TagsControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_tags, R.layout.control_set_tags_display,
|
|
|
|
|
R.string.TEA_tags_label);
|
|
|
|
|
R.layout.control_set_tags,
|
|
|
|
|
R.layout.control_set_default_display, R.string.TEA_tags_label);
|
|
|
|
|
controls.add(tagsControlSet);
|
|
|
|
|
controlSetMap.put(getString(R.string.TEA_ctrl_lists_pref),
|
|
|
|
|
tagsControlSet);
|
|
|
|
@ -378,20 +466,21 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
ReminderControlSet reminderControl = new ReminderControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_reminders,
|
|
|
|
|
R.layout.control_set_reminders_display);
|
|
|
|
|
R.layout.control_set_default_display);
|
|
|
|
|
controls.add(reminderControl);
|
|
|
|
|
controlSetMap.put(getString(R.string.TEA_ctrl_reminders_pref),
|
|
|
|
|
reminderControl);
|
|
|
|
|
|
|
|
|
|
hideUntilControls = new HideUntilControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_hide, R.layout.control_set_hide_display,
|
|
|
|
|
R.layout.control_set_hide,
|
|
|
|
|
R.layout.control_set_default_display,
|
|
|
|
|
R.string.hide_until_prompt);
|
|
|
|
|
controls.add(hideUntilControls);
|
|
|
|
|
reminderControl.addViewToBody(hideUntilControls.getDisplayView());
|
|
|
|
|
|
|
|
|
|
TimerControlSet timerControl = new TimerControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_timers,
|
|
|
|
|
R.layout.control_set_timers_extras_display,
|
|
|
|
|
TimerControlSet timerControl = new TimerControlSet(getActivity(),
|
|
|
|
|
R.layout.control_set_timers,
|
|
|
|
|
R.layout.control_set_default_display,
|
|
|
|
|
R.string.TEA_timer_controls);
|
|
|
|
|
timerAction.setListener(timerControl);
|
|
|
|
|
controls.add(timerControl);
|
|
|
|
@ -399,7 +488,10 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (ProducteevUtilities.INSTANCE.isLoggedIn()) {
|
|
|
|
|
ProducteevControlSet producteevControl = new ProducteevControlSet(getActivity(), R.layout.control_set_producteev, R.layout.control_set_producteev_display, R.string.producteev_TEA_control_set_display);
|
|
|
|
|
ProducteevControlSet producteevControl = new ProducteevControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_producteev,
|
|
|
|
|
R.layout.control_set_default_display,
|
|
|
|
|
R.string.producteev_TEA_control_set_display);
|
|
|
|
|
controls.add(producteevControl);
|
|
|
|
|
basicControls.addView(producteevControl.getDisplayView());
|
|
|
|
|
notesEditText.setHint(R.string.producteev_TEA_notes);
|
|
|
|
@ -410,7 +502,10 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (OpencrxCoreUtils.INSTANCE.isLoggedIn()) {
|
|
|
|
|
OpencrxControlSet ocrxControl = new OpencrxControlSet(getActivity(), R.layout.control_set_opencrx, R.layout.control_set_opencrx_display, R.string.opencrx_TEA_opencrx_title);
|
|
|
|
|
OpencrxControlSet ocrxControl = new OpencrxControlSet(
|
|
|
|
|
getActivity(), R.layout.control_set_opencrx,
|
|
|
|
|
R.layout.control_set_opencrx_display,
|
|
|
|
|
R.string.opencrx_TEA_opencrx_title);
|
|
|
|
|
controls.add(ocrxControl);
|
|
|
|
|
basicControls.addView(ocrxControl.getDisplayView());
|
|
|
|
|
notesEditText.setHint(R.string.opencrx_TEA_notes);
|
|
|
|
@ -424,57 +519,77 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
if (orderPreference != null)
|
|
|
|
|
itemOrder = orderPreference.split(BeastModePreferenceActivity.BEAST_MODE_PREF_ITEM_SEPARATOR);
|
|
|
|
|
else
|
|
|
|
|
itemOrder = getResources().getStringArray(R.array.TEA_control_sets_prefs);
|
|
|
|
|
itemOrder = getResources().getStringArray(
|
|
|
|
|
R.array.TEA_control_sets_prefs);
|
|
|
|
|
String moreSectionTrigger = getString(R.string.TEA_ctrl_more_pref);
|
|
|
|
|
String shareViewDescriptor = getString(R.string.TEA_ctrl_share_pref);
|
|
|
|
|
String titleViewDescriptor = getString(R.string.TEA_ctrl_title_pref);
|
|
|
|
|
LinearLayout section = basicControls;
|
|
|
|
|
int controlWidth = basicControls.getLayoutParams().width;
|
|
|
|
|
for (int i = 0; i < itemOrder.length; i++) {
|
|
|
|
|
String item = itemOrder[i];
|
|
|
|
|
if (item.equals(moreSectionTrigger)) {
|
|
|
|
|
section = moreControls;
|
|
|
|
|
} else {
|
|
|
|
|
View control_set = null;
|
|
|
|
|
TaskEditControlSet curr = controlSetMap.get(item);
|
|
|
|
|
if (item.equals(shareViewDescriptor))
|
|
|
|
|
section.addView(peopleControlSet.getSharedWithRow());
|
|
|
|
|
|
|
|
|
|
if (item.equals(titleViewDescriptor))
|
|
|
|
|
control_set = curr.getDisplayView();
|
|
|
|
|
else if (item.equals(shareViewDescriptor))
|
|
|
|
|
control_set = peopleControlSet.getSharedWithRow();
|
|
|
|
|
else if (curr != null)
|
|
|
|
|
section.addView(curr.getDisplayView());
|
|
|
|
|
control_set = (LinearLayout) curr.getDisplayView();
|
|
|
|
|
|
|
|
|
|
if (control_set != null) {
|
|
|
|
|
if ((i + 1 >= itemOrder.length || itemOrder[i + 1].equals(moreSectionTrigger))) {
|
|
|
|
|
removeTeaSeparator(control_set);
|
|
|
|
|
}
|
|
|
|
|
section.addView(control_set);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (moreControls.getChildCount() == 0)
|
|
|
|
|
getView().findViewById(R.id.more_header).setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load task data in background
|
|
|
|
|
new TaskEditBackgroundLoader().start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void removeTeaSeparator(View view) {
|
|
|
|
|
|
|
|
|
|
View teaSeparator = view.findViewById(R.id.TEA_Separator);
|
|
|
|
|
|
|
|
|
|
if (teaSeparator != null) {
|
|
|
|
|
teaSeparator.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Set up button listeners */
|
|
|
|
|
private void setUpListeners() {
|
|
|
|
|
final View.OnClickListener mExpandMoreListener = new View.OnClickListener() {
|
|
|
|
|
final Animation fadeIn = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
|
|
|
|
|
final Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
|
|
|
|
|
final Animation fadeIn = AnimationUtils.loadAnimation(
|
|
|
|
|
getActivity(), android.R.anim.fade_in);
|
|
|
|
|
final Animation fadeOut = AnimationUtils.loadAnimation(
|
|
|
|
|
getActivity(), android.R.anim.fade_out);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
fadeIn.setDuration(300);
|
|
|
|
|
fadeOut.setDuration(300);
|
|
|
|
|
View moreView = getView().findViewById(R.id.more_controls);
|
|
|
|
|
View moreHeader = getView().findViewById(R.id.more_header);
|
|
|
|
|
if (moreView.getVisibility() == View.GONE) {
|
|
|
|
|
moreView.setVisibility(View.VISIBLE);
|
|
|
|
|
moreView.startAnimation(fadeIn);
|
|
|
|
|
moreHeader.setVisibility(View.GONE);
|
|
|
|
|
moreHeader.startAnimation(fadeOut);
|
|
|
|
|
}
|
|
|
|
|
LinearLayout moreHeader = (LinearLayout) getView().findViewById(
|
|
|
|
|
R.id.more_header);
|
|
|
|
|
moreHeader.removeAllViews();
|
|
|
|
|
moreHeader.addView(moreControls);
|
|
|
|
|
moreHeader.setOnClickListener(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// set up save, cancel, and delete buttons
|
|
|
|
|
try {
|
|
|
|
|
getView().findViewById(R.id.more_header).setOnClickListener(mExpandMoreListener);
|
|
|
|
|
getView().findViewById(R.id.more_header).setOnClickListener(
|
|
|
|
|
mExpandMoreListener);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// error loading the proper activity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void constructWhenDialog(View whenDialogView) {
|
|
|
|
@ -492,7 +607,9 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
|
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
|
|
|
|
whenDialog.setTitle(R.string.TEA_when_dialog_title);
|
|
|
|
|
whenDialog.addContentView(whenDialogView, new LayoutParams(metrics.widthPixels - (int)(30 * metrics.density), LayoutParams.WRAP_CONTENT));
|
|
|
|
|
whenDialog.addContentView(whenDialogView, new LayoutParams(
|
|
|
|
|
metrics.widthPixels - (int) (30 * metrics.density),
|
|
|
|
|
LayoutParams.WRAP_CONTENT));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -506,11 +623,12 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
public void onUiThread() {
|
|
|
|
|
// prepare and set listener for voice-button
|
|
|
|
|
if (addOnService.hasPowerPack()) {
|
|
|
|
|
voiceAddNoteButton = (ImageButton) notesControlSet.getView().findViewById(R.id.voiceAddNoteButton);
|
|
|
|
|
voiceAddNoteButton = (ImageButton) notesControlSet.getView().findViewById(
|
|
|
|
|
R.id.voiceAddNoteButton);
|
|
|
|
|
voiceAddNoteButton.setVisibility(View.VISIBLE);
|
|
|
|
|
int prompt = R.string.voice_edit_note_prompt;
|
|
|
|
|
voiceNoteAssistant = new VoiceInputAssistant(getActivity(), voiceAddNoteButton,
|
|
|
|
|
notesEditText, REQUEST_VOICE_RECOG);
|
|
|
|
|
voiceNoteAssistant = new VoiceInputAssistant(getActivity(),
|
|
|
|
|
voiceAddNoteButton, notesEditText, REQUEST_VOICE_RECOG);
|
|
|
|
|
voiceNoteAssistant.setAppend(true);
|
|
|
|
|
voiceNoteAssistant.setLanguageModel(RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
|
|
|
|
|
voiceNoteAssistant.configureMicrophoneButton(prompt);
|
|
|
|
@ -523,18 +641,6 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
if (isNewTask) {
|
|
|
|
|
hideUntilControls.setDefaults();
|
|
|
|
|
}
|
|
|
|
|
autoExpand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void autoExpand() {
|
|
|
|
|
LinearLayout moreControls = (LinearLayout) getView().findViewById(R.id.more_controls);
|
|
|
|
|
LinearLayout moreHeader = (LinearLayout) getView().findViewById(R.id.more_header);
|
|
|
|
|
|
|
|
|
|
if (notesControlSet.hasNotes() && notesControlSet.getDisplayView().getParent() == moreControls) {
|
|
|
|
|
moreHeader.performClick();
|
|
|
|
|
} else if (tagsControlSet.hasLists() && tagsControlSet.getDisplayView().getParent() == moreControls) {
|
|
|
|
|
moreHeader.performClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -557,12 +663,15 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
|
/*
|
|
|
|
|
* ======================================================================
|
|
|
|
|
* =============================================== model reading / saving
|
|
|
|
|
* ====================================================================== */
|
|
|
|
|
* ======================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads action item from the given intent
|
|
|
|
|
*
|
|
|
|
|
* @param intent
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("nls")
|
|
|
|
@ -578,8 +687,11 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
database.openForReading();
|
|
|
|
|
if (idParam > -1L) {
|
|
|
|
|
model = taskService.fetchById(idParam, Task.PROPERTIES);
|
|
|
|
|
if (model != null)
|
|
|
|
|
model.clearValue(Task.REMOTE_ID); // Having this can screw up autosync
|
|
|
|
|
if (model != null) {
|
|
|
|
|
remoteId = model.getValue(Task.REMOTE_ID);
|
|
|
|
|
model.clearValue(Task.REMOTE_ID); // Having this can screw up
|
|
|
|
|
// autosync
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// not found by id or was never passed an id
|
|
|
|
@ -592,7 +704,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// oops, can't serialize
|
|
|
|
|
}
|
|
|
|
|
model = TaskListActivity.createWithValues(values, null, taskService, metadataService);
|
|
|
|
|
model = TaskListActivity.createWithValues(values, null,
|
|
|
|
|
taskService, metadataService);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (model.getValue(Task.TITLE).length() == 0) {
|
|
|
|
@ -614,6 +727,7 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
// clear notification
|
|
|
|
|
Notifications.cancelNotifications(model.getId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Convenience method to populate fields after setting model to null */
|
|
|
|
@ -630,6 +744,9 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
for (TaskEditControlSet controlSet : controls)
|
|
|
|
|
controlSet.readFromTask(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadMoreContainer();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Populate UI component values from the model */
|
|
|
|
@ -657,20 +774,19 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String processedToast = addDueTimeToToast(toast.toString());
|
|
|
|
|
boolean cancelFinish = !onPause && peopleControlSet != null &&
|
|
|
|
|
!peopleControlSet.saveSharingSettings(processedToast);
|
|
|
|
|
boolean cancelFinish = !onPause && peopleControlSet != null
|
|
|
|
|
&& !peopleControlSet.saveSharingSettings(processedToast);
|
|
|
|
|
|
|
|
|
|
model.putTransitory("task-edit-save", true); //$NON-NLS-1$
|
|
|
|
|
taskService.save(model);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!onPause && !cancelFinish) {
|
|
|
|
|
if (!peopleControlSet.isAssignedToMe()) {
|
|
|
|
|
Intent data = new Intent();
|
|
|
|
|
data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true);
|
|
|
|
|
data.putExtra(TOKEN_ASSIGNED_TO, peopleControlSet.getAssignedToString());
|
|
|
|
|
data.putExtra(TOKEN_ASSIGNED_TO,
|
|
|
|
|
peopleControlSet.getAssignedToString());
|
|
|
|
|
getActivity().setResult(Activity.RESULT_OK, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -697,7 +813,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
// abandon editing and delete the newly created task if
|
|
|
|
|
// no title was entered
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (title.getText().length() == 0 && isNewTask && model.isSaved()) {
|
|
|
|
@ -705,9 +822,11 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
|
/*
|
|
|
|
|
* ======================================================================
|
|
|
|
|
* ================================================ edit control handling
|
|
|
|
|
* ====================================================================== */
|
|
|
|
|
* ======================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Receiver which receives intents to add items to the filter list
|
|
|
|
@ -726,14 +845,17 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
exceptionService.reportError("receive-detail-" + //$NON-NLS-1$
|
|
|
|
|
intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON), e);
|
|
|
|
|
intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON),
|
|
|
|
|
e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
|
/*
|
|
|
|
|
* ======================================================================
|
|
|
|
|
* ======================================================= event handlers
|
|
|
|
|
* ====================================================================== */
|
|
|
|
|
* ======================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
protected void saveButtonClick() {
|
|
|
|
|
save(false);
|
|
|
|
@ -743,6 +865,7 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
* Displays a Toast reporting that the selected task has been saved and, if
|
|
|
|
|
* it has a due date, that is due in 'x' amount of time, to 1 time-unit of
|
|
|
|
|
* precision
|
|
|
|
|
*
|
|
|
|
|
* @param additionalMessage
|
|
|
|
|
*/
|
|
|
|
|
private String addDueTimeToToast(String additionalMessage) {
|
|
|
|
@ -752,8 +875,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
String toastMessage;
|
|
|
|
|
if (due != 0) {
|
|
|
|
|
stringResource = R.string.TEA_onTaskSave_due;
|
|
|
|
|
CharSequence formattedDate =
|
|
|
|
|
DateUtilities.getRelativeDay(getActivity(), due);
|
|
|
|
|
CharSequence formattedDate = DateUtilities.getRelativeDay(
|
|
|
|
|
getActivity(), due);
|
|
|
|
|
toastMessage = getString(stringResource, formattedDate);
|
|
|
|
|
} else {
|
|
|
|
|
toastMessage = getString(R.string.TEA_onTaskSave_notDue);
|
|
|
|
@ -766,7 +889,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
shouldSaveState = false;
|
|
|
|
|
|
|
|
|
|
// abandon editing in this case
|
|
|
|
|
if(title.getText().length() == 0 || TextUtils.isEmpty(model.getValue(Task.TITLE))) {
|
|
|
|
|
if (title.getText().length() == 0
|
|
|
|
|
|| TextUtils.isEmpty(model.getValue(Task.TITLE))) {
|
|
|
|
|
if (isNewTask)
|
|
|
|
|
taskService.delete(model);
|
|
|
|
|
}
|
|
|
|
@ -784,12 +908,11 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void deleteButtonClick() {
|
|
|
|
|
new AlertDialog.Builder(getActivity())
|
|
|
|
|
.setTitle(R.string.DLG_confirm_title)
|
|
|
|
|
.setMessage(R.string.DLG_delete_this_task_question)
|
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
|
|
|
.setPositiveButton(android.R.string.ok,
|
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
|
new AlertDialog.Builder(getActivity()).setTitle(
|
|
|
|
|
R.string.DLG_confirm_title).setMessage(
|
|
|
|
|
R.string.DLG_delete_this_task_question).setIcon(
|
|
|
|
|
android.R.drawable.ic_dialog_alert).setPositiveButton(
|
|
|
|
|
android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
taskService.delete(model);
|
|
|
|
|
shouldSaveState = false;
|
|
|
|
@ -797,9 +920,7 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
getActivity().setResult(Activity.RESULT_CANCELED);
|
|
|
|
|
getActivity().onBackPressed();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
.show();
|
|
|
|
|
}).setNegativeButton(android.R.string.cancel, null).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -828,9 +949,6 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
case MENU_DELETE_ID:
|
|
|
|
|
deleteButtonClick();
|
|
|
|
|
return true;
|
|
|
|
|
case MENU_COMMENTS_ID:
|
|
|
|
|
commentsButtonClick();
|
|
|
|
|
return true;
|
|
|
|
|
case android.R.id.home:
|
|
|
|
|
if (title.getText().length() == 0)
|
|
|
|
|
discardButtonClick();
|
|
|
|
@ -847,7 +965,8 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
|
MenuItem item;
|
|
|
|
|
|
|
|
|
|
item = menu.add(Menu.NONE, MENU_DISCARD_ID, 0, R.string.TEA_menu_discard);
|
|
|
|
|
item = menu.add(Menu.NONE, MENU_DISCARD_ID, 0,
|
|
|
|
|
R.string.TEA_menu_discard);
|
|
|
|
|
item.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
|
|
|
|
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
|
|
|
|
|
|
|
@ -859,11 +978,6 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
item.setIcon(android.R.drawable.ic_menu_delete);
|
|
|
|
|
if (((AstridWrapperActivity) getActivity()).isMultipleFragments())
|
|
|
|
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
|
|
|
|
|
|
|
|
item = menu.add(Menu.NONE, MENU_COMMENTS_ID, 0, R.string.TEA_menu_comments);
|
|
|
|
|
item.setIcon(R.drawable.icn_cmmt_off);
|
|
|
|
|
if (((AstridWrapperActivity) getActivity()).isMultipleFragments())
|
|
|
|
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -880,18 +994,24 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
StatisticsService.sessionStart(getActivity());
|
|
|
|
|
getActivity().registerReceiver(controlReceiver,
|
|
|
|
|
new IntentFilter(AstridApiConstants.BROADCAST_SEND_EDIT_CONTROLS));
|
|
|
|
|
getActivity().registerReceiver(
|
|
|
|
|
controlReceiver,
|
|
|
|
|
new IntentFilter(
|
|
|
|
|
AstridApiConstants.BROADCAST_SEND_EDIT_CONTROLS));
|
|
|
|
|
populateFields();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
if(requestCode == REQUEST_VOICE_RECOG && resultCode == Activity.RESULT_OK) {
|
|
|
|
|
// handle the result of voice recognition, put it into the appropiate textfield
|
|
|
|
|
voiceNoteAssistant.handleActivityResult(requestCode, resultCode, data);
|
|
|
|
|
|
|
|
|
|
// write the voicenote into the model, or it will be deleted by onResume.populateFields
|
|
|
|
|
if (requestCode == REQUEST_VOICE_RECOG
|
|
|
|
|
&& resultCode == Activity.RESULT_OK) {
|
|
|
|
|
// handle the result of voice recognition, put it into the
|
|
|
|
|
// appropiate textfield
|
|
|
|
|
voiceNoteAssistant.handleActivityResult(requestCode, resultCode,
|
|
|
|
|
data);
|
|
|
|
|
|
|
|
|
|
// write the voicenote into the model, or it will be deleted by
|
|
|
|
|
// onResume.populateFields
|
|
|
|
|
// (due to the activity-change)
|
|
|
|
|
notesControlSet.writeToModel(model);
|
|
|
|
|
}
|
|
|
|
@ -927,8 +1047,106 @@ public final class TaskEditActivity extends Fragment {
|
|
|
|
|
Preferences.setBoolean(R.string.p_showed_lists_help, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
|
/*
|
|
|
|
|
* ======================================================================
|
|
|
|
|
* ========================================== UI component helper classes
|
|
|
|
|
* ====================================================================== */
|
|
|
|
|
* ======================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the correct view for TaskEditViewPager
|
|
|
|
|
*
|
|
|
|
|
* @param position
|
|
|
|
|
* in the horizontal scroll view
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public View getPageView(int position) {
|
|
|
|
|
if (position == 1) {
|
|
|
|
|
moreControls.setLayoutParams(mPager.getLayoutParams());
|
|
|
|
|
setViewHeightBasedOnChildren(moreControls);
|
|
|
|
|
|
|
|
|
|
// setPagerHeightForView(editNotes, moreControls);
|
|
|
|
|
return moreControls;
|
|
|
|
|
} else if (position == 0) {
|
|
|
|
|
|
|
|
|
|
// setPagerHeightForView(editNotes, moreControls);
|
|
|
|
|
return editNotes;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
TextView text = new TextView(getActivity());
|
|
|
|
|
text.setGravity(Gravity.CENTER);
|
|
|
|
|
text.setText("Activity");
|
|
|
|
|
text.setTextSize(20 * getResources().getDisplayMetrics().density);
|
|
|
|
|
text.setPadding(20, 20, 20, 20);
|
|
|
|
|
|
|
|
|
|
LinearLayout layout = new LinearLayout(getActivity());
|
|
|
|
|
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
|
|
|
|
|
LayoutParams.WRAP_CONTENT));
|
|
|
|
|
layout.setGravity(Gravity.CENTER);
|
|
|
|
|
layout.addView(text);
|
|
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setPagerHeightForPosition(int position) {
|
|
|
|
|
int height = 0;
|
|
|
|
|
View view = (position == TAB_VIEW_MORE) ? moreControls : editNotes;
|
|
|
|
|
|
|
|
|
|
int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(),
|
|
|
|
|
MeasureSpec.AT_MOST);
|
|
|
|
|
view.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
|
|
|
|
|
height = Math.max(view.getMeasuredHeight(), height);
|
|
|
|
|
LayoutParams pagerParams = mPager.getLayoutParams();
|
|
|
|
|
if (position == 0 && height < pagerParams.height)
|
|
|
|
|
return;
|
|
|
|
|
if (height > 0 && height != pagerParams.height) {
|
|
|
|
|
|
|
|
|
|
pagerParams.height = height;
|
|
|
|
|
mPager.setLayoutParams(pagerParams);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void setViewHeightBasedOnChildren(LinearLayout view) {
|
|
|
|
|
|
|
|
|
|
int totalHeight = 0;
|
|
|
|
|
int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(),
|
|
|
|
|
MeasureSpec.AT_MOST);
|
|
|
|
|
for (int i = 0; i < view.getChildCount(); i++) {
|
|
|
|
|
View listItem = view.getChildAt(i);
|
|
|
|
|
listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
|
|
|
|
|
totalHeight += listItem.getMeasuredHeight();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
|
|
|
params.height = totalHeight;
|
|
|
|
|
view.setLayoutParams(params);
|
|
|
|
|
view.requestLayout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tab Page listener when page/tab changes
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageScrolled(int position, float positionOffset,
|
|
|
|
|
int positionOffsetPixels) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageSelected(int position) {
|
|
|
|
|
|
|
|
|
|
this.setPagerHeightForPosition(position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageScrollStateChanged(int state) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// EditNoteActivity Lisener when there are new updates/comments
|
|
|
|
|
@Override
|
|
|
|
|
public void updatesChanged() {
|
|
|
|
|
setCurrentTab(TAB_VIEW_UPDATES);
|
|
|
|
|
this.setPagerHeightForPosition(TAB_VIEW_UPDATES);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|