Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac9542b9 authored by tobias's avatar tobias
Browse files

- fixed wrong timezone for allday tasks

parent 2c2611ef
Loading
Loading
Loading
Loading
+2 −39
Original line number Diff line number Diff line
@@ -17,10 +17,7 @@

package org.dmfs.tasks.groupings;

import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.dmfs.provider.tasks.TaskContract.Instances;
@@ -29,6 +26,7 @@ import org.dmfs.tasks.groupings.cursorloaders.TimeRangeCursorFactory;
import org.dmfs.tasks.groupings.cursorloaders.TimeRangeCursorLoaderFactory;
import org.dmfs.tasks.groupings.cursorloaders.TimeRangeShortCursorFactory;
import org.dmfs.tasks.model.TaskFieldAdapters;
import org.dmfs.tasks.utils.DueDateFormatter;
import org.dmfs.tasks.utils.ExpandableChildDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter;
@@ -80,16 +78,6 @@ public class ByDueDate extends AbstractGroupingFactory
		 */
		private Time mNow;

		/**
		 * The formatter we use for due dates other than today.
		 */
		private final DateFormat mDateFormatter = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);

		/**
		 * The formatter we use for tasks that are due today.
		 */
		private final DateFormat mTimeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);

		private int mFlingContentViewId = R.id.flingContentView;
		private int mFlingRevealLeftViewId = R.id.fling_reveal_left;
		private int mFlingRevealRightViewId = R.id.fling_reveal_right;
@@ -148,7 +136,7 @@ public class ByDueDate extends AbstractGroupingFactory
					mNow.clear(TimeZone.getDefault().getID());
					mNow.setToNow();

					dueDateField.setText(makeDueDate(dueDate));
					dueDateField.setText(new DueDateFormatter(view.getContext()).format(dueDate));

					// highlight overdue dates & times
					if (dueDate.before(mNow) && !isClosed)
@@ -223,31 +211,6 @@ public class ByDueDate extends AbstractGroupingFactory
		}


		/**
		 * Get the due date to show. It returns just a time for tasks that are due today and a date otherwise.
		 * 
		 * @param due
		 *            The due date to format.
		 * @return A String with the formatted date.
		 */
		private String makeDueDate(Time due)
		{
			if (!due.allDay)
			{
				due.switchTimezone(TimeZone.getDefault().getID());
			}

			if (due.year == mNow.year && due.yearDay == mNow.yearDay)
			{
				return mTimeFormatter.format(new Date(due.toMillis(false)));
			}
			else
			{
				return mDateFormatter.format(new Date(due.toMillis(false)));
			}
		}


		@Override
		public int getFlingContentViewId()
		{
+2 −49
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@

package org.dmfs.tasks.groupings;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.dmfs.provider.tasks.TaskContract.Instances;
@@ -27,6 +24,7 @@ import org.dmfs.provider.tasks.TaskContract.TaskLists;
import org.dmfs.tasks.R;
import org.dmfs.tasks.groupings.cursorloaders.CursorLoaderFactory;
import org.dmfs.tasks.model.TaskFieldAdapters;
import org.dmfs.tasks.utils.DueDateFormatter;
import org.dmfs.tasks.utils.ExpandableChildDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter;
@@ -76,16 +74,6 @@ public class ByList extends AbstractGroupingFactory
		 */
		private Time mNow;

		/**
		 * The formatter we use for due dates other than today.
		 */
		private final DateFormat mDateFormatter = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);

		/**
		 * The formatter we use for tasks that are due today.
		 */
		private final DateFormat mTimeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);

		private int mFlingContentViewId = R.id.flingContentView;
		private int mFlingRevealLeftViewId = R.id.fling_reveal_left;
		private int mFlingRevealRightViewId = R.id.fling_reveal_right;
@@ -144,7 +132,7 @@ public class ByList extends AbstractGroupingFactory
					mNow.clear(TimeZone.getDefault().getID());
					mNow.setToNow();

					dueDateField.setText(makeDueDate(dueDate, view.getContext()));
					new DueDateFormatter(view.getContext()).format(dueDate);

					// highlight overdue dates & times
					if (dueDate.before(mNow) && !isClosed)
@@ -221,41 +209,6 @@ public class ByList extends AbstractGroupingFactory
		}


		/**
		 * Get the due date to show. It returns just a time for tasks that are due today and a date otherwise.
		 * 
		 * @param due
		 *            The due date to format.
		 * @return A String with the formatted date.
		 */
		private String makeDueDate(Time due, Context context)
		{
			if (!due.allDay)
			{
				due.switchTimezone(TimeZone.getDefault().getID());
			}

			// normalize time to ensure yearDay is set properly
			due.normalize(false);

			if (due.year == mNow.year && due.yearDay == mNow.yearDay)
			{
				if (due.allDay)
				{
					return context.getString(R.string.today);
				}
				else
				{
					return context.getString(R.string.today) + ", " + mTimeFormatter.format(new Date(due.toMillis(false)));
				}
			}
			else
			{
				return mDateFormatter.format(new Date(due.toMillis(false)));
			}
		}


		@Override
		public int getFlingContentViewId()
		{
+2 −49
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@

package org.dmfs.tasks.groupings;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.dmfs.provider.tasks.TaskContract.Instances;
@@ -27,6 +24,7 @@ import org.dmfs.tasks.R;
import org.dmfs.tasks.groupings.cursorloaders.PriorityCursorFactory;
import org.dmfs.tasks.groupings.cursorloaders.PriorityCursorLoaderFactory;
import org.dmfs.tasks.model.TaskFieldAdapters;
import org.dmfs.tasks.utils.DueDateFormatter;
import org.dmfs.tasks.utils.ExpandableChildDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter;
@@ -64,16 +62,6 @@ public class ByPriority extends AbstractGroupingFactory
		 */
		private Time mNow;

		/**
		 * The formatter we use for due dates other than today.
		 */
		private final DateFormat mDateFormatter = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);

		/**
		 * The formatter we use for tasks that are due today.
		 */
		private final DateFormat mTimeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);

		private int mFlingContentViewId = R.id.flingContentView;
		private int mFlingRevealLeftViewId = R.id.fling_reveal_left;
		private int mFlingRevealRightViewId = R.id.fling_reveal_right;
@@ -132,7 +120,7 @@ public class ByPriority extends AbstractGroupingFactory
					mNow.clear(TimeZone.getDefault().getID());
					mNow.setToNow();

					dueDateField.setText(makeDueDate(dueDate, view.getContext()));
					dueDateField.setText(new DueDateFormatter(view.getContext()).format(dueDate));

					// highlight overdue dates & times
					if (dueDate.before(mNow) && !isClosed)
@@ -208,41 +196,6 @@ public class ByPriority extends AbstractGroupingFactory
		}


		/**
		 * Get the due date to show. It returns just a time for tasks that are due today and a date otherwise.
		 * 
		 * @param due
		 *            The due date to format.
		 * @return A String with the formatted date.
		 */
		private String makeDueDate(Time due, Context context)
		{
			if (!due.allDay)
			{
				due.switchTimezone(TimeZone.getDefault().getID());
			}

			// normalize time to ensure yearDay is set properly
			due.normalize(false);

			if (due.year == mNow.year && due.yearDay == mNow.yearDay)
			{
				if (due.allDay)
				{
					return context.getString(R.string.today);
				}
				else
				{
					return context.getString(R.string.today) + ", " + mTimeFormatter.format(new Date(due.toMillis(false)));
				}
			}
			else
			{
				return mDateFormatter.format(new Date(due.toMillis(false)));
			}
		}


		@Override
		public int getFlingContentViewId()
		{
+2 −49
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@

package org.dmfs.tasks.groupings;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.dmfs.provider.tasks.TaskContract.Instances;
@@ -27,6 +24,7 @@ import org.dmfs.tasks.R;
import org.dmfs.tasks.groupings.cursorloaders.ProgressCursorFactory;
import org.dmfs.tasks.groupings.cursorloaders.ProgressCursorLoaderFactory;
import org.dmfs.tasks.model.TaskFieldAdapters;
import org.dmfs.tasks.utils.DueDateFormatter;
import org.dmfs.tasks.utils.ExpandableChildDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter;
@@ -64,16 +62,6 @@ public class ByProgress extends AbstractGroupingFactory
		 */
		private Time mNow;

		/**
		 * The formatter we use for due dates other than today.
		 */
		private final DateFormat mDateFormatter = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);

		/**
		 * The formatter we use for tasks that are due today.
		 */
		private final DateFormat mTimeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);

		private int mFlingContentViewId = R.id.flingContentView;
		private int mFlingRevealLeftViewId = R.id.fling_reveal_left;
		private int mFlingRevealRightViewId = R.id.fling_reveal_right;
@@ -132,7 +120,7 @@ public class ByProgress extends AbstractGroupingFactory
					mNow.clear(TimeZone.getDefault().getID());
					mNow.setToNow();

					dueDateField.setText(makeDueDate(dueDate, view.getContext()));
					dueDateField.setText(new DueDateFormatter(view.getContext()).format(dueDate));

					// highlight overdue dates & times
					if (dueDate.before(mNow) && !isClosed)
@@ -208,41 +196,6 @@ public class ByProgress extends AbstractGroupingFactory
		}


		/**
		 * Get the due date to show. It returns just a time for tasks that are due today and a date otherwise.
		 * 
		 * @param due
		 *            The due date to format.
		 * @return A String with the formatted date.
		 */
		private String makeDueDate(Time due, Context context)
		{
			if (!due.allDay)
			{
				due.switchTimezone(TimeZone.getDefault().getID());
			}

			// normalize time to ensure yearDay is set properly
			due.normalize(false);

			if (due.year == mNow.year && due.yearDay == mNow.yearDay)
			{
				if (due.allDay)
				{
					return context.getString(R.string.today);
				}
				else
				{
					return context.getString(R.string.today) + ", " + mTimeFormatter.format(new Date(due.toMillis(false)));
				}
			}
			else
			{
				return mDateFormatter.format(new Date(due.toMillis(false)));
			}
		}


		@Override
		public int getFlingContentViewId()
		{
+2 −48
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@
package org.dmfs.tasks.groupings;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.dmfs.provider.tasks.TaskContract.Tasks;
@@ -27,6 +25,7 @@ import org.dmfs.tasks.R;
import org.dmfs.tasks.groupings.cursorloaders.SearchHistoryCursorLoaderFactory;
import org.dmfs.tasks.model.TaskFieldAdapters;
import org.dmfs.tasks.model.adapters.TimeFieldAdapter;
import org.dmfs.tasks.utils.DueDateFormatter;
import org.dmfs.tasks.utils.ExpandableChildDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptor;
import org.dmfs.tasks.utils.ExpandableGroupDescriptorAdapter;
@@ -80,16 +79,6 @@ public class BySearch extends AbstractGroupingFactory
		 */
		private Time mNow;

		/**
		 * The formatter we use for due dates other than today.
		 */
		private final DateFormat mDateFormatter = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);

		/**
		 * The formatter we use for tasks that are due today.
		 */
		private final DateFormat mTimeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);

		private int mFlingContentViewId = R.id.flingContentView;
		private int mFlingRevealLeftViewId = R.id.fling_reveal_left;
		private int mFlingRevealRightViewId = R.id.fling_reveal_right;
@@ -149,7 +138,7 @@ public class BySearch extends AbstractGroupingFactory
					mNow.clear(TimeZone.getDefault().getID());
					mNow.setToNow();

					dueDateField.setText(makeDueDate(dueDate, view.getContext()));
					dueDateField.setText(new DueDateFormatter(view.getContext()).format(dueDate));

					// highlight overdue dates & times
					if (dueDate.before(mNow) && !isClosed)
@@ -225,41 +214,6 @@ public class BySearch extends AbstractGroupingFactory
		}


		/**
		 * Get the due date to show. It returns just a time for tasks that are due today and a date otherwise.
		 * 
		 * @param due
		 *            The due date to format.
		 * @return A String with the formatted date.
		 */
		private String makeDueDate(Time due, Context context)
		{
			if (!due.allDay)
			{
				due.switchTimezone(TimeZone.getDefault().getID());
			}

			// normalize time to ensure yearDay is set properly
			due.normalize(false);

			if (due.year == mNow.year && due.yearDay == mNow.yearDay)
			{
				if (due.allDay)
				{
					return context.getString(R.string.today);
				}
				else
				{
					return context.getString(R.string.today) + ", " + mTimeFormatter.format(new Date(due.toMillis(false)));
				}
			}
			else
			{
				return mDateFormatter.format(new Date(due.toMillis(false)));
			}
		}


		@Override
		public int getFlingContentViewId()
		{
Loading