aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2015-02-16 22:55:46 +0100
committerSamuel Tardieu <sam@rfc1149.net>2015-02-16 22:55:46 +0100
commit9e4c5b5882ba0c6d0b26fe65718e15ac87a2b555 (patch)
tree4f8f73982ec0865b42595add1b7c5b5d88b969ff
parent02d7eda64bc7827bc82ddbf969ba537abe542919 (diff)
downloadcgeo-9e4c5b5882ba0c6d0b26fe65718e15ac87a2b555.zip
cgeo-9e4c5b5882ba0c6d0b26fe65718e15ac87a2b555.tar.gz
cgeo-9e4c5b5882ba0c6d0b26fe65718e15ac87a2b555.tar.bz2
Rename DateUtils into CalendarUtils
cgeo uses android.text.format.DateUtils, having a utility class with the same name in a different package might be confusing.
-rw-r--r--main/src/cgeo/geocaching/CacheListActivity.java6
-rw-r--r--main/src/cgeo/geocaching/Geocache.java6
-rw-r--r--main/src/cgeo/geocaching/LogCacheActivity.java6
-rw-r--r--main/src/cgeo/geocaching/ui/CacheListAdapter.java4
-rw-r--r--main/src/cgeo/geocaching/utils/CalendarUtils.java (renamed from main/src/cgeo/geocaching/utils/DateUtils.java)6
-rw-r--r--main/src/cgeo/geocaching/utils/Formatter.java4
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java4
-rw-r--r--tests/src/cgeo/geocaching/utils/CalendarUtilsTest.java (renamed from tests/src/cgeo/geocaching/utils/DateUtilsTest.java)16
8 files changed, 26 insertions, 26 deletions
diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java
index d5e6c92..d4d46fd 100644
--- a/main/src/cgeo/geocaching/CacheListActivity.java
+++ b/main/src/cgeo/geocaching/CacheListActivity.java
@@ -57,7 +57,7 @@ import cgeo.geocaching.ui.dialog.Dialogs;
import cgeo.geocaching.utils.AngleUtils;
import cgeo.geocaching.utils.AsyncTaskWithProgress;
import cgeo.geocaching.utils.CancellableHandler;
-import cgeo.geocaching.utils.DateUtils;
+import cgeo.geocaching.utils.CalendarUtils;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.RxUtils;
@@ -663,7 +663,7 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA
private boolean containsPastEvents() {
for (final Geocache cache : adapter.getCheckedOrAllCaches()) {
- if (DateUtils.isPastEvent(cache)) {
+ if (CalendarUtils.isPastEvent(cache)) {
return true;
}
}
@@ -786,7 +786,7 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA
private void deletePastEvents() {
final List<Geocache> deletion = new ArrayList<>();
for (final Geocache cache : adapter.getCheckedOrAllCaches()) {
- if (DateUtils.isPastEvent(cache)) {
+ if (CalendarUtils.isPastEvent(cache)) {
deletion.add(cache);
}
}
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index 9d4e1b2..e87495f 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -25,7 +25,7 @@ import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.utils.CancellableHandler;
-import cgeo.geocaching.utils.DateUtils;
+import cgeo.geocaching.utils.CalendarUtils;
import cgeo.geocaching.utils.ImageUtils;
import cgeo.geocaching.utils.LazyInitializedList;
import cgeo.geocaching.utils.Log;
@@ -1771,9 +1771,9 @@ public class Geocache implements IWaypoint {
public LogType getDefaultLogType() {
if (isEventCache()) {
final Date eventDate = getHiddenDate();
- final boolean expired = DateUtils.isPastEvent(this);
+ final boolean expired = CalendarUtils.isPastEvent(this);
- if (hasOwnLog(LogType.WILL_ATTEND) || expired || (eventDate != null && DateUtils.daysSince(eventDate.getTime()) == 0)) {
+ if (hasOwnLog(LogType.WILL_ATTEND) || expired || (eventDate != null && CalendarUtils.daysSince(eventDate.getTime()) == 0)) {
return hasOwnLog(LogType.ATTENDED) ? LogType.NOTE : LogType.ATTENDED;
}
return LogType.WILL_ATTEND;
diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java
index c60d2e4..2f50232 100644
--- a/main/src/cgeo/geocaching/LogCacheActivity.java
+++ b/main/src/cgeo/geocaching/LogCacheActivity.java
@@ -19,7 +19,7 @@ import cgeo.geocaching.twitter.Twitter;
import cgeo.geocaching.ui.dialog.DateDialog;
import cgeo.geocaching.ui.dialog.Dialogs;
import cgeo.geocaching.utils.AsyncTaskWithProgress;
-import cgeo.geocaching.utils.DateUtils;
+import cgeo.geocaching.utils.CalendarUtils;
import cgeo.geocaching.utils.Formatter;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.LogTemplateProvider;
@@ -301,7 +301,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
rating = GCVote.NO_RATING;
typeSelected = cache.getDefaultLogType();
// it this is an attended event log, use the event date by default instead of the current date
- if (cache.isEventCache() && DateUtils.isPastEvent(cache) && typeSelected == LogType.ATTENDED) {
+ if (cache.isEventCache() && CalendarUtils.isPastEvent(cache) && typeSelected == LogType.ATTENDED) {
date.setTime(cache.getHiddenDate());
}
text = null;
@@ -618,7 +618,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
Dialogs.message(this, R.string.log_post_not_possible);
return;
}
- if (DateUtils.isFuture(date)) {
+ if (CalendarUtils.isFuture(date)) {
Dialogs.message(this, R.string.log_date_future_not_allowed);
return;
}
diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
index a5146cd..e2daf11 100644
--- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
@@ -18,7 +18,7 @@ import cgeo.geocaching.sorting.EventDateComparator;
import cgeo.geocaching.sorting.InverseComparator;
import cgeo.geocaching.sorting.VisitComparator;
import cgeo.geocaching.utils.AngleUtils;
-import cgeo.geocaching.utils.DateUtils;
+import cgeo.geocaching.utils.CalendarUtils;
import cgeo.geocaching.utils.Formatter;
import cgeo.geocaching.utils.Log;
@@ -414,7 +414,7 @@ public class CacheListAdapter extends ArrayAdapter<Geocache> {
}
Spannable spannable = null;
- if (cache.isDisabled() || cache.isArchived() || DateUtils.isPastEvent(cache)) { // strike
+ if (cache.isDisabled() || cache.isArchived() || CalendarUtils.isPastEvent(cache)) { // strike
spannable = Spannable.Factory.getInstance().newSpannable(cache.getName());
spannable.setSpan(new StrikethroughSpan(), 0, spannable.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
diff --git a/main/src/cgeo/geocaching/utils/DateUtils.java b/main/src/cgeo/geocaching/utils/CalendarUtils.java
index dfed110..ed3b18c 100644
--- a/main/src/cgeo/geocaching/utils/DateUtils.java
+++ b/main/src/cgeo/geocaching/utils/CalendarUtils.java
@@ -5,9 +5,9 @@ import cgeo.geocaching.Geocache;
import java.util.Calendar;
import java.util.Date;
-public final class DateUtils {
+public final class CalendarUtils {
- private DateUtils() {
+ private CalendarUtils() {
// utility class
}
@@ -33,7 +33,7 @@ public final class DateUtils {
return false;
}
final Date hiddenDate = cache.getHiddenDate();
- return hiddenDate != null && DateUtils.daysSince(hiddenDate.getTime()) > 0;
+ return hiddenDate != null && CalendarUtils.daysSince(hiddenDate.getTime()) > 0;
}
/**
diff --git a/main/src/cgeo/geocaching/utils/Formatter.java b/main/src/cgeo/geocaching/utils/Formatter.java
index 9b96aae..db649d8 100644
--- a/main/src/cgeo/geocaching/utils/Formatter.java
+++ b/main/src/cgeo/geocaching/utils/Formatter.java
@@ -89,7 +89,7 @@ public abstract class Formatter {
* @return the formatted string
*/
public static String formatShortDateVerbally(final long date) {
- final int diff = cgeo.geocaching.utils.DateUtils.daysSince(date);
+ final int diff = CalendarUtils.daysSince(date);
switch (diff) {
case 0:
return CgeoApplication.getInstance().getString(R.string.log_today);
@@ -194,7 +194,7 @@ public abstract class Formatter {
}
public static String formatDaysAgo(final long date) {
- final int days = cgeo.geocaching.utils.DateUtils.daysSince(date);
+ final int days = CalendarUtils.daysSince(date);
switch (days) {
case 0:
return CgeoApplication.getInstance().getString(R.string.log_today);
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 8562087..7c40b2a 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -16,7 +16,7 @@ import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
import cgeo.geocaching.test.R;
-import cgeo.geocaching.utils.DateUtils;
+import cgeo.geocaching.utils.CalendarUtils;
import cgeo.geocaching.utils.SynchronizedDateFormat;
import java.io.IOException;
@@ -179,7 +179,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertThat(log.log).isEqualTo("Sehr schöne Runde und wir haben wieder etwas Neues über Hockenheim gelernt. Super Tarnung.\nTFTC, Geoteufel");
assertThat(log.isOwn()).isFalse();
assertThat(log.getDisplayText()).isEqualTo(log.log);
- assertThat(DateUtils.daysSince(log.date) > 700).isTrue();
+ assertThat(CalendarUtils.daysSince(log.date) > 700).isTrue();
// following info is not contained in pocket query gpx file
assertThat(cache.getAttributes()).isEmpty();
diff --git a/tests/src/cgeo/geocaching/utils/DateUtilsTest.java b/tests/src/cgeo/geocaching/utils/CalendarUtilsTest.java
index 44442f6..c074903 100644
--- a/tests/src/cgeo/geocaching/utils/DateUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/CalendarUtilsTest.java
@@ -5,17 +5,17 @@ import static org.assertj.core.api.Assertions.assertThat;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.enumerations.CacheType;
-import java.util.Calendar;
-
import junit.framework.TestCase;
-public class DateUtilsTest extends TestCase {
+import java.util.Calendar;
+
+public class CalendarUtilsTest extends TestCase {
public static void testDaysSince() {
final Calendar start = Calendar.getInstance();
for (int hour = 0; hour < 24; hour++) {
start.set(Calendar.HOUR_OF_DAY, hour);
- assertThat(DateUtils.daysSince(start.getTimeInMillis())).isEqualTo(0);
+ assertThat(CalendarUtils.daysSince(start.getTimeInMillis())).isEqualTo(0);
}
}
@@ -37,17 +37,17 @@ public class DateUtilsTest extends TestCase {
cache.setType(CacheType.EVENT);
cache.setHidden(start.getTime());
- assertThat(DateUtils.isPastEvent(cache)).isEqualTo(expectedPast);
+ assertThat(CalendarUtils.isPastEvent(cache)).isEqualTo(expectedPast);
}
public static void testIsFuture() {
final Calendar date = Calendar.getInstance();
- assertThat(DateUtils.isFuture(date)).isFalse();
+ assertThat(CalendarUtils.isFuture(date)).isFalse();
date.add(Calendar.DAY_OF_MONTH, 1);
- assertThat(DateUtils.isFuture(date)).isFalse();
+ assertThat(CalendarUtils.isFuture(date)).isFalse();
date.add(Calendar.DAY_OF_MONTH, 1);
- assertThat(DateUtils.isFuture(date)).isTrue();
+ assertThat(CalendarUtils.isFuture(date)).isTrue();
}
}