From 688fb0cf84c9f069e4afe2d8baa5cddb7e9854b2 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Thu, 21 Aug 2014 15:02:57 +0200 Subject: [PATCH] fix #1762: show blog url in the share blog spinner if the blog title is an empty string --- .../java/org/wordpress/android/util/BlogUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java index 166085a4f066..1da5d104384d 100644 --- a/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/BlogUtils.java @@ -22,4 +22,15 @@ public int compare(Object blog1, Object blog2) { return blogName1.compareToIgnoreCase(blogName2); } }; + + /** + * Return a blog name or blog url (host part only) if trimmed name is an empty string + */ + public static String getBlogNameFromAccountMap(Map account) { + String blogName = StringUtils.unescapeHTML(MapUtils.getMapStr(account, "blogName")); + if (blogName.trim().length() == 0) { + blogName = StringUtils.getHost(MapUtils.getMapStr(account, "url")); + } + return blogName; + } } \ No newline at end of file