addresses = null;
-
- Geocoder gcd = getGeocoder(context);
-
- if (gcd == null) {
- return null;
- }
-
- try {
- addresses = gcd.getFromLocationName(locationName, maxResults);
- } catch (IOException e) {
- AppLog.e(AppLog.T.UTILS, "Failed to get coordinates from location", e);
- }
-
- // addresses may be null or empty if network isn't connected
- if (addresses != null && addresses.size() > 0) {
- address = addresses.get(0);
- }
-
- return address;
- }
-
- public static String getLocationNameFromAddress(Address address) {
- String locality = "", adminArea = "", country = "";
- if (address.getLocality() != null) {
- locality = address.getLocality();
- }
-
- if (address.getAdminArea() != null) {
- adminArea = address.getAdminArea();
- }
-
- if (address.getCountryName() != null) {
- country = address.getCountryName();
- }
-
- return ((locality.equals("")) ? locality : locality + ", ")
- + ((adminArea.equals("")) ? adminArea : adminArea + " ") + country;
- }
-
- public static double[] getCoordsFromAddress(Address address) {
- double[] coordinates = new double[2];
-
- if (address.hasLatitude() && address.hasLongitude()) {
- coordinates[0] = address.getLatitude();
- coordinates[1] = address.getLongitude();
- }
-
- return coordinates;
- }
-}
diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/GravatarUtils.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/GravatarUtils.java
deleted file mode 100644
index f650dea0dcf5..000000000000
--- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/GravatarUtils.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.wordpress.android.util;
-
-import android.text.TextUtils;
-
-/**
- * see https://en.gravatar.com/site/implement/images/
- */
-public class GravatarUtils {
- // by default tell gravatar to respond to non-existent images with a 404 - this means
- // it's up to the caller to catch the 404 and provide a suitable default image
- private static final DefaultImage DEFAULT_GRAVATAR = DefaultImage.MYSTERY_MAN;
-
- public enum DefaultImage {
- MYSTERY_MAN,
- STATUS_404,
- IDENTICON,
- MONSTER,
- WAVATAR,
- RETRO,
- BLANK;
-
- @Override
- public String toString() {
- switch (this) {
- case MYSTERY_MAN:
- return "mm";
- case STATUS_404:
- return "404";
- case IDENTICON:
- return "identicon";
- case MONSTER:
- return "monsterid";
- case WAVATAR:
- return "wavatar";
- case RETRO:
- return "retro";
- default:
- return "blank";
- }
- }
- }
-
- /*
- * gravatars often contain the ?s= parameter which determines their size - detect this and
- * replace it with a new ?s= parameter which requests the avatar at the exact size needed
- */
- public static String fixGravatarUrl(final String imageUrl, int avatarSz) {
- return fixGravatarUrl(imageUrl, avatarSz, DEFAULT_GRAVATAR);
- }
-
- public static String fixGravatarUrl(final String imageUrl, int avatarSz, DefaultImage defaultImage) {
- if (TextUtils.isEmpty(imageUrl)) {
- return "";
- }
-
- // if this isn't a gravatar image, return as resized photon image url
- if (!imageUrl.contains("gravatar.com")) {
- return PhotonUtils.getPhotonImageUrl(imageUrl, avatarSz, avatarSz);
- }
-
- // remove all other params, then add query string for size and default image
- return UrlUtils.removeQuery(imageUrl) + "?s=" + avatarSz + "&d=" + defaultImage.toString();
- }
-
- public static String gravatarFromEmail(final String email, int size) {
- return gravatarFromEmail(email, size, DEFAULT_GRAVATAR);
- }
-
- public static String gravatarFromEmail(final String email, int size, DefaultImage defaultImage) {
- return "http://gravatar.com/avatar/"
- + StringUtils.getMd5Hash(StringUtils.notNullStr(email))
- + "?d=" + defaultImage.toString()
- + "&size=" + Integer.toString(size);
- }
-
- public static String blavatarFromUrl(final String url, int size) {
- return blavatarFromUrl(url, size, DEFAULT_GRAVATAR);
- }
-
- public static String blavatarFromUrl(final String url, int size, DefaultImage defaultImage) {
- return "http://gravatar.com/blavatar/"
- + StringUtils.getMd5Hash(UrlUtils.getHost(url))
- + "?d=" + defaultImage.toString()
- + "&size=" + Integer.toString(size);
- }
-}
diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/HtmlUtils.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/HtmlUtils.java
deleted file mode 100644
index e91024b12587..000000000000
--- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/HtmlUtils.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.wordpress.android.util;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.text.Html;
-import android.text.Html.ImageGetter;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.TextUtils;
-import android.text.style.ForegroundColorSpan;
-import android.text.style.QuoteSpan;
-
-import org.apache.commons.text.StringEscapeUtils;
-import org.wordpress.android.util.helpers.WPHtmlTagHandler;
-import org.wordpress.android.util.helpers.WPQuoteSpan;
-
-import static org.wordpress.android.util.AppLog.T.UTILS;
-
-public class HtmlUtils {
- /**
- * Removes html from the passed string - relies on Html.fromHtml which handles invalid HTML,
- * but it's very slow, so avoid using this where performance is important
- * @param text String containing html
- * @return String without HTML
- */
- public static String stripHtml(final String text) {
- if (TextUtils.isEmpty(text)) {
- return "";
- }
- return Html.fromHtml(text).toString().trim();
- }
-
- /**
- * This is much faster than stripHtml() but should only be used when we know the html is valid
- * since the regex will be unpredictable with invalid html
- * @param str String containing only valid html
- * @return String without HTML
- */
- public static String fastStripHtml(String str) {
- if (TextUtils.isEmpty(str)) {
- return str;
- }
-
- // insert a line break before P tags unless the only one is at the start
- if (str.lastIndexOf(" 0) {
- str = str.replaceAll("
", "\n
");
- }
-
- // convert BR tags to line breaks
- if (str.contains("
", "\n");
- }
-
- // use regex to strip tags, then convert entities in the result
- return trimStart(StringEscapeUtils.unescapeHtml4(str.replaceAll("<(.|\n)*?>", "")));
- }
-
- /*
- * Same as apache.commons.lang.StringUtils.stripStart() but also removes non-breaking
- * space (160) chars
- */
- private static String trimStart(final String str) {
- int strLen;
- if (str == null || (strLen = str.length()) == 0) {
- return "";
- }
- int start = 0;
- while (start != strLen && (Character.isWhitespace(str.charAt(start)) || str.charAt(start) == 160)) {
- start++;
- }
- return str.substring(start);
- }
-
- /**
- * Converts an R.color.xxx resource to an HTML hex color
- * @param context Android Context
- * @param resId Android R.color.xxx
- * @return A String HTML hex color code
- */
- public static String colorResToHtmlColor(Context context, int resId) {
- try {
- return String.format("#%06X", 0xFFFFFF & context.getResources().getColor(resId));
- } catch (Resources.NotFoundException e) {
- return "#000000";
- }
- }
-
- /**
- * Remove {@code } blocks from the passed string - added to project after noticing
- * comments on posts that use the "Sociable" plugin ( http://wordpress.org/plugins/sociable/ )
- * may have a script block which contains {@code } followed by a CDATA section followed by {@code ,}
- * all of which will show up if we don't strip it here.
- * @see Wordpress Sociable Plugin
- * @return String without {@code }, {@code } blocks followed by a CDATA section
- * followed by {@code ,}
- * @param text String containing script tags
- */
- public static String stripScript(final String text) {
- if (text == null) {
- return null;
- }
-
- StringBuilder sb = new StringBuilder(text);
- int start = sb.indexOf("", start);
- if (end == -1) {
- return sb.toString();
- }
- sb.delete(start, end + 9);
- start = sb.indexOf("