aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgeo-calendar/.classpath1
-rw-r--r--cgeo-calendar/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar (renamed from cgeo-contacts/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar)bin14613 -> 14613 bytes
-rw-r--r--cgeo-calendar/src/cgeo/calendar/AbstractAddEntry.java6
-rw-r--r--cgeo-calendar/src/cgeo/calendar/AddEntry.java4
-rw-r--r--cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java4
-rw-r--r--cgeo-calendar/src/cgeo/calendar/CalendarActivity.java5
-rw-r--r--cgeo-calendar/src/cgeo/calendar/CalendarEntry.java23
-rw-r--r--cgeo-calendar/src/cgeo/calendar/Compatibility.java4
-rw-r--r--cgeo-contacts/.classpath2
-rw-r--r--cgeo-contacts/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jarbin0 -> 14613 bytes
-rw-r--r--cgeo-contacts/src/cgeo/contacts/ContactsActivity.java6
-rw-r--r--main/src/cgeo/calendar/CalendarAddon.java5
-rw-r--r--main/src/cgeo/calendar/ICalendar.java26
-rw-r--r--main/src/cgeo/contacts/ContactsAddon.java4
-rw-r--r--main/src/cgeo/contacts/IContacts.java10
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractApp.java19
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractLocusApp.java20
-rw-r--r--main/src/cgeo/geocaching/apps/App.java3
-rw-r--r--main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java16
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java9
-rw-r--r--main/src/cgeo/geocaching/utils/ProcessUtils.java17
22 files changed, 127 insertions, 63 deletions
diff --git a/cgeo-calendar/.classpath b/cgeo-calendar/.classpath
index 2f1c26a..7d962c2 100644
--- a/cgeo-calendar/.classpath
+++ b/cgeo-calendar/.classpath
@@ -11,4 +11,5 @@
<classpathentry combineaccessrules="false" kind="src" path="/cgeo"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
+ <classpathentry kind="lib" path="compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar"/>
</classpath>
diff --git a/cgeo-contacts/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar b/cgeo-calendar/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar
index daca164..daca164 100644
--- a/cgeo-contacts/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar
+++ b/cgeo-calendar/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar
Binary files differ
diff --git a/cgeo-calendar/src/cgeo/calendar/AbstractAddEntry.java b/cgeo-calendar/src/cgeo/calendar/AbstractAddEntry.java
index 893161c..e35ed19 100644
--- a/cgeo-calendar/src/cgeo/calendar/AbstractAddEntry.java
+++ b/cgeo-calendar/src/cgeo/calendar/AbstractAddEntry.java
@@ -1,13 +1,17 @@
package cgeo.calendar;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.util.Log;
abstract class AbstractAddEntry {
+ @NonNull
protected final CalendarEntry entry;
+ @NonNull
protected final CalendarActivity activity;
- public AbstractAddEntry(final CalendarEntry entry, final CalendarActivity activity) {
+ public AbstractAddEntry(@NonNull final CalendarEntry entry, @NonNull final CalendarActivity activity) {
this.entry = entry;
this.activity = activity;
}
diff --git a/cgeo-calendar/src/cgeo/calendar/AddEntry.java b/cgeo-calendar/src/cgeo/calendar/AddEntry.java
index 30af346..a267e47 100644
--- a/cgeo-calendar/src/cgeo/calendar/AddEntry.java
+++ b/cgeo-calendar/src/cgeo/calendar/AddEntry.java
@@ -1,5 +1,7 @@
package cgeo.calendar;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.content.ContentValues;
import android.net.Uri;
import android.text.Html;
@@ -16,7 +18,7 @@ class AddEntry extends AbstractAddEntry {
* @param calendarId
* The selected calendar
*/
- public AddEntry(final CalendarEntry entry, final CalendarActivity activity, final int calendarId) {
+ public AddEntry(@NonNull final CalendarEntry entry, @NonNull final CalendarActivity activity, final int calendarId) {
super(entry, activity);
this.calendarId = calendarId;
}
diff --git a/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java b/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java
index 11820b4..731a0f8 100644
--- a/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java
+++ b/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java
@@ -1,5 +1,7 @@
package cgeo.calendar;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.content.Intent;
import android.text.Html;
@@ -12,7 +14,7 @@ import java.util.Date;
*/
class AddEntryLevel14 extends AbstractAddEntry {
- public AddEntryLevel14(final CalendarEntry entry, final CalendarActivity activity) {
+ public AddEntryLevel14(@NonNull final CalendarEntry entry, @NonNull final CalendarActivity activity) {
super(entry, activity);
}
diff --git a/cgeo-calendar/src/cgeo/calendar/CalendarActivity.java b/cgeo-calendar/src/cgeo/calendar/CalendarActivity.java
index 2f0c08d..e21de2b 100644
--- a/cgeo-calendar/src/cgeo/calendar/CalendarActivity.java
+++ b/cgeo-calendar/src/cgeo/calendar/CalendarActivity.java
@@ -1,5 +1,7 @@
package cgeo.calendar;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -47,7 +49,7 @@ public final class CalendarActivity extends Activity {
* @param entry
* new entry to be stored
*/
- private void selectCalendarForAdding(final CalendarEntry entry) {
+ private void selectCalendarForAdding(@NonNull final CalendarEntry entry) {
final SparseArray<String> calendars = queryCalendars();
if (calendars.size() == 0) {
@@ -80,6 +82,7 @@ public final class CalendarActivity extends Activity {
builder.create().show();
}
+ @NonNull
private SparseArray<String> queryCalendars() {
final SparseArray<String> calendars = new SparseArray<>();
diff --git a/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java b/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java
index 1e37d6b..8308b7b 100644
--- a/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java
+++ b/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java
@@ -3,6 +3,7 @@ package cgeo.calendar;
import cgeo.geocaching.utils.Log;
import org.apache.commons.lang3.CharEncoding;
+import org.eclipse.jdt.annotation.NonNull;
import android.net.Uri;
import android.text.Html;
@@ -16,16 +17,23 @@ import java.util.Date;
class CalendarEntry {
+ @NonNull
private final String shortDesc;
+ @NonNull
private final String hiddenDate;
+ @NonNull
private final String url;
+ @NonNull
private final String personalNote;
+ @NonNull
private final String name;
+ @NonNull
private final String coords;
private int startTimeMinutes = -1;
+ @NonNull
private final Uri uri;
- public CalendarEntry(final Uri uri) {
+ public CalendarEntry(@NonNull final Uri uri) {
this.uri = uri;
this.shortDesc = getParameter(ICalendar.PARAM_SHORT_DESC);
this.hiddenDate = getParameter(ICalendar.PARAM_HIDDEN_DATE);
@@ -43,7 +51,8 @@ class CalendarEntry {
}
}
- private String getParameter(final String paramKey) {
+ @NonNull
+ private String getParameter(@NonNull final String paramKey) {
try {
final String param = uri.getQueryParameter(paramKey);
if (param == null) {
@@ -60,18 +69,22 @@ class CalendarEntry {
return getName().length() > 0 && getHiddenDate().length() > 0;
}
+ @NonNull
public String getHiddenDate() {
return hiddenDate;
}
+ @NonNull
public String getUrl() {
return url;
}
+ @NonNull
public String getPersonalNote() {
return personalNote;
}
+ @NonNull
public String getShortDesc() {
return shortDesc;
}
@@ -79,6 +92,7 @@ class CalendarEntry {
/**
* @return <code>Date</code> based on hidden date. Time is set to 00:00:00.
*/
+ @NonNull
protected Date parseDate() {
try {
final Calendar cal = Calendar.getInstance();
@@ -90,13 +104,14 @@ class CalendarEntry {
return cal.getTime();
} catch (final NumberFormatException e) {
// cannot happen normally, but static code analysis does not know
+ throw new IllegalStateException("hidden date must be a valid date for cache calendar entries");
}
- return null;
}
/**
* @return description string with images removed and personal note included
*/
+ @NonNull
protected String parseDescription() {
final StringBuilder description = new StringBuilder();
description.append(getUrl());
@@ -121,6 +136,7 @@ class CalendarEntry {
return description.toString();
}
+ @NonNull
public String getName() {
return name;
}
@@ -129,6 +145,7 @@ class CalendarEntry {
return startTimeMinutes;
}
+ @NonNull
public String getCoords() {
return coords;
}
diff --git a/cgeo-calendar/src/cgeo/calendar/Compatibility.java b/cgeo-calendar/src/cgeo/calendar/Compatibility.java
index ff14a0f..61ea636 100644
--- a/cgeo-calendar/src/cgeo/calendar/Compatibility.java
+++ b/cgeo-calendar/src/cgeo/calendar/Compatibility.java
@@ -1,5 +1,7 @@
package cgeo.calendar;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.net.Uri;
import android.os.Build;
@@ -9,10 +11,12 @@ public final class Compatibility {
private final static boolean IS_LEVEL_8 = SDK_VERSION >= 8;
private final static boolean IS_LEVEL_14 = SDK_VERSION >= 14;
+ @NonNull
public static Uri getCalendarProviderURI() {
return Uri.parse(IS_LEVEL_8 ? "content://com.android.calendar/calendars" : "content://calendar/calendars");
}
+ @NonNull
public static Uri getCalendarEventsProviderURI() {
return Uri.parse(IS_LEVEL_8 ? "content://com.android.calendar/events" : "content://calendar/events");
}
diff --git a/cgeo-contacts/.classpath b/cgeo-contacts/.classpath
index 448b12e..e53070a 100644
--- a/cgeo-contacts/.classpath
+++ b/cgeo-contacts/.classpath
@@ -10,6 +10,6 @@
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry combineaccessrules="false" kind="src" path="/cgeo"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry kind="lib" path="org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar"/>
+ <classpathentry kind="lib" path="compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
diff --git a/cgeo-contacts/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar b/cgeo-contacts/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar
new file mode 100644
index 0000000..daca164
--- /dev/null
+++ b/cgeo-contacts/compile-libs/org.eclipse.jdt.annotation_1.1.0.v20130513-1648.jar
Binary files differ
diff --git a/cgeo-contacts/src/cgeo/contacts/ContactsActivity.java b/cgeo-contacts/src/cgeo/contacts/ContactsActivity.java
index 7d2f1e1..60accca 100644
--- a/cgeo-contacts/src/cgeo/contacts/ContactsActivity.java
+++ b/cgeo-contacts/src/cgeo/contacts/ContactsActivity.java
@@ -72,7 +72,7 @@ public final class ContactsActivity extends Activity {
}
}
- private void selectContact(final List<Pair<Integer, String>> contacts) {
+ private void selectContact(@NonNull final List<Pair<Integer, String>> contacts) {
final List<String> list = new ArrayList<>();
for (final Pair<Integer, String> p : contacts) {
list.add(p.second);
@@ -100,6 +100,7 @@ public final class ContactsActivity extends Activity {
finish();
}
+ @NonNull
private List<Pair<Integer, String>> getContacts(final @NonNull String searchName, final Uri uri, final @NonNull String idColumnName, final @NonNull String selectionColumnName, final boolean like) {
final String[] projection = new String[] { idColumnName, selectionColumnName };
final String selection = selectionColumnName + (like ? " LIKE" : " =") + " ? COLLATE NOCASE";
@@ -131,7 +132,8 @@ public final class ContactsActivity extends Activity {
toast.show();
}
- private static String getParameter(final Uri uri, final String paramKey) {
+ @NonNull
+ private static String getParameter(@NonNull final Uri uri, @NonNull final String paramKey) {
try {
final String param = uri.getQueryParameter(paramKey);
if (param == null) {
diff --git a/main/src/cgeo/calendar/CalendarAddon.java b/main/src/cgeo/calendar/CalendarAddon.java
index 8737447..c5bb0a6 100644
--- a/main/src/cgeo/calendar/CalendarAddon.java
+++ b/main/src/cgeo/calendar/CalendarAddon.java
@@ -8,6 +8,7 @@ import cgeo.geocaching.ui.dialog.Dialogs;
import cgeo.geocaching.utils.ProcessUtils;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jdt.annotation.NonNull;
import android.app.Activity;
import android.content.DialogInterface;
@@ -27,7 +28,7 @@ public class CalendarAddon {
return ProcessUtils.isIntentAvailable(ICalendar.INTENT, Uri.parse(ICalendar.URI_SCHEME + "://" + ICalendar.URI_HOST));
}
- public static void addToCalendarWithIntent(final Activity activity, final Geocache cache) {
+ public static void addToCalendarWithIntent(@NonNull final Activity activity, @NonNull final Geocache cache) {
final Resources res = activity.getResources();
if (CalendarAddon.isAvailable()) {
final Date hiddenDate = cache.getHiddenDate();
@@ -51,7 +52,7 @@ public class CalendarAddon {
.append(res.getString(R.string.addon_download_prompt))
.toString(), new DialogInterface.OnClickListener() {
@Override
- public void onClick(DialogInterface dialog, int id) {
+ public void onClick(final DialogInterface dialog, final int id) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(ICalendar.CALENDAR_ADDON_URI));
activity.startActivity(intent);
diff --git a/main/src/cgeo/calendar/ICalendar.java b/main/src/cgeo/calendar/ICalendar.java
index 6ecb6d5..19089f0 100644
--- a/main/src/cgeo/calendar/ICalendar.java
+++ b/main/src/cgeo/calendar/ICalendar.java
@@ -1,19 +1,21 @@
package cgeo.calendar;
+import org.eclipse.jdt.annotation.NonNull;
+
public interface ICalendar {
- static final String CALENDAR_ADDON_URI = "market://details?id=cgeo.calendar";
+ @NonNull static final String CALENDAR_ADDON_URI = "market://details?id=cgeo.calendar";
- static final String INTENT = "cgeo.calendar.RESERVE";
+ @NonNull static final String INTENT = "cgeo.calendar.RESERVE";
- static final String URI_SCHEME = "add";
- static final String URI_HOST = "cgeo.org";
+ @NonNull static final String URI_SCHEME = "add";
+ @NonNull static final String URI_HOST = "cgeo.org";
- static final String PARAM_SHORT_DESC = "shortDesc"; // cache short description
- static final String PARAM_HIDDEN_DATE = "hiddenDate"; // cache hidden date in milliseconds
- static final String PARAM_URL = "url"; // cache URL
- static final String PARAM_NOTE = "note"; // personal note
- static final String PARAM_NAME = "name"; // cache name
- static final String PARAM_LOCATION = "location"; // cache location, or empty string
- static final String PARAM_COORDS = "coords"; // cache coordinates, or empty string
- static final String PARAM_START_TIME_MINUTES = "time"; // time of start
+ @NonNull static final String PARAM_SHORT_DESC = "shortDesc"; // cache short description
+ @NonNull static final String PARAM_HIDDEN_DATE = "hiddenDate"; // cache hidden date in milliseconds
+ @NonNull static final String PARAM_URL = "url"; // cache URL
+ @NonNull static final String PARAM_NOTE = "note"; // personal note
+ @NonNull static final String PARAM_NAME = "name"; // cache name
+ @NonNull static final String PARAM_LOCATION = "location"; // cache location, or empty string
+ @NonNull static final String PARAM_COORDS = "coords"; // cache coordinates, or empty string
+ @NonNull static final String PARAM_START_TIME_MINUTES = "time"; // time of start
}
diff --git a/main/src/cgeo/contacts/ContactsAddon.java b/main/src/cgeo/contacts/ContactsAddon.java
index 7165a77..6c0dd21 100644
--- a/main/src/cgeo/contacts/ContactsAddon.java
+++ b/main/src/cgeo/contacts/ContactsAddon.java
@@ -3,6 +3,8 @@ package cgeo.contacts;
import cgeo.geocaching.network.Parameters;
import cgeo.geocaching.utils.ProcessUtils;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
@@ -13,7 +15,7 @@ public class ContactsAddon {
// utility class
}
- public static void openContactCard(Activity context, String userName) {
+ public static void openContactCard(@NonNull final Activity context, @NonNull final String userName) {
final Parameters params = new Parameters(
IContacts.PARAM_NAME, userName
);
diff --git a/main/src/cgeo/contacts/IContacts.java b/main/src/cgeo/contacts/IContacts.java
index d68b78a..5a6c04d 100644
--- a/main/src/cgeo/contacts/IContacts.java
+++ b/main/src/cgeo/contacts/IContacts.java
@@ -1,10 +1,12 @@
package cgeo.contacts;
+import org.eclipse.jdt.annotation.NonNull;
+
public interface IContacts {
- static final String INTENT = "cgeo.contacts.FIND";
+ @NonNull static final String INTENT = "cgeo.contacts.FIND";
- static final String URI_SCHEME = "find";
- static final String URI_HOST = "cgeo.org";
+ @NonNull static final String URI_SCHEME = "find";
+ @NonNull static final String URI_HOST = "cgeo.org";
- static final String PARAM_NAME = "name"; // user name
+ @NonNull static final String PARAM_NAME = "name"; // user name
}
diff --git a/main/src/cgeo/geocaching/apps/AbstractApp.java b/main/src/cgeo/geocaching/apps/AbstractApp.java
index 494e245..fa052f1 100644
--- a/main/src/cgeo/geocaching/apps/AbstractApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractApp.java
@@ -5,28 +5,31 @@ import cgeo.geocaching.Geocache;
import cgeo.geocaching.utils.ProcessUtils;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import android.content.Intent;
public abstract class AbstractApp implements App {
- private final String packageName;
- private final String intent;
+ @Nullable private final String packageName;
+ @Nullable private final String intent;
+ @NonNull
private final String name;
/**
* a unique id, defined in res/values/ids.xml
*/
private final int id;
- protected AbstractApp(final String name, final int id, final String intent,
- final String packageName) {
+ protected AbstractApp(@NonNull final String name, final int id, @Nullable final String intent,
+ @Nullable final String packageName) {
this.name = name;
this.id = id;
this.intent = intent;
this.packageName = packageName;
}
- protected AbstractApp(final String name, final int id, final String intent) {
+ protected AbstractApp(@NonNull final String name, final int id, @Nullable final String intent) {
this(name, id, intent, null);
}
@@ -38,6 +41,7 @@ public abstract class AbstractApp implements App {
return ProcessUtils.isIntentAvailable(intent);
}
+ @Nullable
protected Intent getLaunchIntent() {
return ProcessUtils.getLaunchIntent(packageName);
}
@@ -48,6 +52,7 @@ public abstract class AbstractApp implements App {
}
@Override
+ @NonNull
public String getName() {
return name;
}
@@ -57,12 +62,12 @@ public abstract class AbstractApp implements App {
return id;
}
- protected static String getString(int ressourceId) {
+ protected static String getString(final int ressourceId) {
return CgeoApplication.getInstance().getString(ressourceId);
}
@Override
- public boolean isEnabled(Geocache cache) {
+ public boolean isEnabled(final Geocache cache) {
return cache != null;
}
}
diff --git a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
index baf36a4..6d1a4c7 100644
--- a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -15,6 +15,9 @@ import menion.android.locus.addon.publiclib.geoData.PointGeocachingData;
import menion.android.locus.addon.publiclib.geoData.PointGeocachingDataWaypoint;
import menion.android.locus.addon.publiclib.geoData.PointsData;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
import android.app.Activity;
import android.location.Location;
@@ -31,7 +34,7 @@ import java.util.Locale;
public abstract class AbstractLocusApp extends AbstractApp {
private static final SynchronizedDateFormat ISO8601DATE = new SynchronizedDateFormat("yyyy-MM-dd'T'", Locale.US);
- protected AbstractLocusApp(final String text, int id, final String intent) {
+ protected AbstractLocusApp(@NonNull final String text, final int id, @NonNull final String intent) {
super(text, id, intent);
}
@@ -57,7 +60,7 @@ public abstract class AbstractLocusApp extends AbstractApp {
final boolean withCacheDetails = objectsToShow.size() < 200;
final PointsData pd = new PointsData("c:geo");
- for (Object o : objectsToShow) {
+ for (final Object o : objectsToShow) {
Point p = null;
// get icon and Point
if (o instanceof Geocache) {
@@ -98,7 +101,8 @@ public abstract class AbstractLocusApp extends AbstractApp {
* should be false for all if more then 200 Caches are transferred
* @return null, when the <code>Point</code> could not be constructed
*/
- private static Point getCachePoint(Geocache cache, boolean withWaypoints, boolean withCacheDetails) {
+ @Nullable
+ private static Point getCachePoint(final Geocache cache, final boolean withWaypoints, final boolean withCacheDetails) {
if (cache == null || cache.getCoords() == null) {
return null;
}
@@ -141,14 +145,14 @@ public abstract class AbstractLocusApp extends AbstractApp {
if (withWaypoints && cache.hasWaypoints()) {
pg.waypoints = new ArrayList<>();
- for (Waypoint waypoint : cache.getWaypoints()) {
+ for (final Waypoint waypoint : cache.getWaypoints()) {
if (waypoint == null || waypoint.getCoords() == null) {
continue;
}
- PointGeocachingDataWaypoint wp = new PointGeocachingDataWaypoint();
+ final PointGeocachingDataWaypoint wp = new PointGeocachingDataWaypoint();
wp.code = waypoint.getGeocode();
wp.name = waypoint.getName();
- String locusWpId = toLocusWaypoint(waypoint.getWaypointType());
+ final String locusWpId = toLocusWaypoint(waypoint.getWaypointType());
if (locusWpId != null) {
wp.type = locusWpId;
}
@@ -177,7 +181,8 @@ public abstract class AbstractLocusApp extends AbstractApp {
* @param waypoint
* @return null, when the <code>Point</code> could not be constructed
*/
- private static Point getWaypointPoint(Waypoint waypoint) {
+ @Nullable
+ private static Point getWaypointPoint(final Waypoint waypoint) {
if (waypoint == null || waypoint.getCoords() == null) {
return null;
}
@@ -248,6 +253,7 @@ public abstract class AbstractLocusApp extends AbstractApp {
}
}
+ @Nullable
private static String toLocusWaypoint(final WaypointType wt) {
switch (wt) {
case FINAL:
diff --git a/main/src/cgeo/geocaching/apps/App.java b/main/src/cgeo/geocaching/apps/App.java
index 7e70581..db306ac 100644
--- a/main/src/cgeo/geocaching/apps/App.java
+++ b/main/src/cgeo/geocaching/apps/App.java
@@ -2,6 +2,8 @@ package cgeo.geocaching.apps;
import cgeo.geocaching.Geocache;
+import org.eclipse.jdt.annotation.NonNull;
+
public interface App {
public boolean isInstalled();
@@ -10,6 +12,7 @@ public interface App {
*/
public boolean isUsableAsDefaultNavigationApp();
+ @NonNull
public String getName();
/**
diff --git a/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java b/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java
index c4f2723..4e542b8 100644
--- a/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java
@@ -4,17 +4,19 @@ import cgeo.geocaching.Geocache;
import cgeo.geocaching.apps.AbstractApp;
import cgeo.geocaching.apps.cache.navi.CacheNavigationApp;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.app.Activity;
import android.content.Intent;
abstract class AbstractGeneralApp extends AbstractApp implements CacheNavigationApp {
- protected AbstractGeneralApp(final String name, final int id, final String packageName) {
+ protected AbstractGeneralApp(@NonNull final String name, final int id, @NonNull final String packageName) {
super(name, id, null, packageName);
}
@Override
- public void navigate(Activity activity, Geocache cache) {
+ public void navigate(final Activity activity, final Geocache cache) {
final Intent intent = getLaunchIntent();
if (intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
index 5e7a5cc..0bf2c1c 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
@@ -7,6 +7,8 @@ import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.AbstractApp;
import cgeo.geocaching.location.Geopoint;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.app.Activity;
import android.content.Intent;
@@ -15,20 +17,20 @@ import android.content.Intent;
*/
abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNavigationApp, WaypointNavigationApp, GeopointNavigationApp {
- protected AbstractPointNavigationApp(final String name, final int id, final String intent) {
+ protected AbstractPointNavigationApp(@NonNull final String name, final int id, final String intent) {
super(name, id, intent);
}
- protected AbstractPointNavigationApp(final String name, final int id, final String intent, final String packageName) {
+ protected AbstractPointNavigationApp(@NonNull final String name, final int id, final String intent, final String packageName) {
super(name, id, intent, packageName);
}
@Override
- public void navigate(Activity activity, Geocache cache) {
+ public void navigate(final Activity activity, final Geocache cache) {
navigateWithNullCheck(activity, cache.getCoords());
}
- private void navigateWithNullCheck(Activity activity, final Geopoint coords) {
+ private void navigateWithNullCheck(final Activity activity, final Geopoint coords) {
if (coords != null) {
navigate(activity, coords);
} else {
@@ -37,17 +39,17 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa
}
@Override
- public void navigate(Activity activity, Waypoint waypoint) {
+ public void navigate(final Activity activity, final Waypoint waypoint) {
navigateWithNullCheck(activity, waypoint.getCoords());
}
@Override
- public boolean isEnabled(Geocache cache) {
+ public boolean isEnabled(final Geocache cache) {
return cache.getCoords() != null;
}
@Override
- public boolean isEnabled(Waypoint waypoint) {
+ public boolean isEnabled(final Waypoint waypoint) {
return waypoint.getCoords() != null;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
index a2a5803..700c8aa 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
@@ -11,11 +11,12 @@ import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.AbstractApp;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jdt.annotation.NonNull;
import android.app.Activity;
abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigationApp, WaypointNavigationApp {
- protected AbstractStaticMapsApp(final String name, final int id) {
+ protected AbstractStaticMapsApp(@NonNull final String name, final int id) {
super(name, id, null);
}
@@ -29,11 +30,11 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat
return false;
}
- protected static boolean hasStaticMap(Waypoint waypoint) {
+ protected static boolean hasStaticMap(final Waypoint waypoint) {
if (waypoint==null) {
return false;
}
- String geocode = waypoint.getGeocode();
+ final String geocode = waypoint.getGeocode();
if (StringUtils.isNotEmpty(geocode) && DataStore.isOffline(geocode, null)) {
return StaticMapsProvider.hasStaticMapForWaypoint(geocode, waypoint);
}
@@ -49,7 +50,7 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat
}
final String geocode = StringUtils.upperCase(logable.getGeocode());
- StaticMapsActivity_.IntentBuilder_ builder = StaticMapsActivity_.intent(activity).geocode(geocode).download(download);
+ final StaticMapsActivity_.IntentBuilder_ builder = StaticMapsActivity_.intent(activity).geocode(geocode).download(download);
if (waypoint != null) {
builder.waypointId(waypoint.getId());
}
diff --git a/main/src/cgeo/geocaching/utils/ProcessUtils.java b/main/src/cgeo/geocaching/utils/ProcessUtils.java
index ce05483..4d45485 100644
--- a/main/src/cgeo/geocaching/utils/ProcessUtils.java
+++ b/main/src/cgeo/geocaching/utils/ProcessUtils.java
@@ -3,6 +3,8 @@ package cgeo.geocaching.utils;
import cgeo.geocaching.CgeoApplication;
import org.apache.commons.collections4.CollectionUtils;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -24,7 +26,7 @@ public final class ProcessUtils {
* @param packageName
* @return
*/
- public static boolean isLaunchable(final String packageName) {
+ public static boolean isLaunchable(@Nullable final String packageName) {
return getLaunchIntent(packageName) != null;
}
@@ -36,14 +38,14 @@ public final class ProcessUtils {
* @param packageName
* @return
*/
- public static boolean isInstalled(final String packageName) {
+ public static boolean isInstalled(@NonNull final String packageName) {
return isLaunchable(packageName) || hasPackageInstalled(packageName);
}
/**
* This will find installed applications even without launch intent (e.g. the streetview plugin).
*/
- private static boolean hasPackageInstalled(final String packageName) {
+ private static boolean hasPackageInstalled(@NonNull final String packageName) {
final List<PackageInfo> packs = CgeoApplication.getInstance().getPackageManager().getInstalledPackages(0);
for (final PackageInfo packageInfo : packs) {
if (packageName.equals(packageInfo.packageName)) {
@@ -56,7 +58,8 @@ public final class ProcessUtils {
/**
* This will find applications, which can be launched.
*/
- public static Intent getLaunchIntent(final String packageName) {
+ @Nullable
+ public static Intent getLaunchIntent(@Nullable final String packageName) {
if (packageName == null) {
return null;
}
@@ -79,16 +82,16 @@ public final class ProcessUtils {
* method queries the package manager for installed packages that can
* respond to an intent with the specified action. If no suitable package is
* found, this method returns false.
- *
+ *
* @param action
* The Intent action to check for availability.
* @param uri
* The Intent URI to check for availability.
- *
+ *
* @return True if an Intent with the specified action can be sent and
* responded to, false otherwise.
*/
- public static boolean isIntentAvailable(final String action, final Uri uri) {
+ public static boolean isIntentAvailable(@NonNull final String action, @Nullable final Uri uri) {
final PackageManager packageManager = CgeoApplication.getInstance().getPackageManager();
final Intent intent;
if (uri == null) {