diff --git a/clients/android/NewsBlur/AndroidManifest.xml b/clients/android/NewsBlur/AndroidManifest.xml index 0400acca7..02cf4d4d6 100644 --- a/clients/android/NewsBlur/AndroidManifest.xml +++ b/clients/android/NewsBlur/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="63" + android:versionName="3.6.5" > @@ -78,8 +78,8 @@ android:layout_toRightOf="@+id/row_item_sidebar" android:layout_below="@+id/row_item_title" android:layout_marginRight="8dp" - android:paddingTop="8dp" - android:paddingBottom="8dp" + android:paddingTop="2dp" + android:paddingBottom="4dp" android:maxLines="2" android:ellipsize="end" android:textSize="14sp"/> @@ -93,8 +93,7 @@ android:layout_alignParentRight="true" android:layout_below="@+id/row_item_title_container" android:layout_marginRight="12dp" - android:paddingTop="2dp" - android:paddingBottom="6dp" + android:paddingBottom="4dp" android:textColor="@color/darkgray" android:textSize="11dp" /> @@ -103,8 +102,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/row_item_title_container" - android:paddingTop="2dp" - android:paddingBottom="6dp" + android:paddingBottom="4dp" android:layout_toLeftOf="@id/row_item_date" android:layout_toRightOf="@id/row_item_favicon_borderbar_2" android:layout_marginLeft="22dp" diff --git a/clients/android/NewsBlur/res/layout/row_item.xml b/clients/android/NewsBlur/res/layout/row_item.xml index 02d218c75..ac12fab8e 100644 --- a/clients/android/NewsBlur/res/layout/row_item.xml +++ b/clients/android/NewsBlur/res/layout/row_item.xml @@ -44,8 +44,8 @@ android:maxLines="2" android:ellipsize="end" android:gravity="left" - android:paddingBottom="8dp" - android:paddingTop="8dp" + android:paddingBottom="2dp" + android:paddingTop="4dp" android:textSize="14sp"/> - @@ -81,7 +80,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/row_item_title_container" - android:paddingBottom="2dp" + android:paddingBottom="4dp" android:layout_marginLeft="24dp" android:layout_toLeftOf="@id/row_item_date" android:layout_alignLeft="@id/row_item_title_container" diff --git a/clients/android/NewsBlur/res/layout/row_socialitem.xml b/clients/android/NewsBlur/res/layout/row_socialitem.xml index 1bdadad1b..37f23aeb4 100644 --- a/clients/android/NewsBlur/res/layout/row_socialitem.xml +++ b/clients/android/NewsBlur/res/layout/row_socialitem.xml @@ -55,8 +55,8 @@ android:layout_alignLeft="@id/row_item_feedicon" android:layout_below="@id/row_item_feedicon" android:layout_marginRight="8dp" - android:paddingTop="8dp" - android:paddingBottom="12dp" + android:paddingTop="4dp" + android:paddingBottom="2dp" android:textColor="@color/darkgray" android:textSize="14sp"/> @@ -67,8 +67,10 @@ android:layout_alignLeft="@id/row_item_feedicon" android:layout_below="@id/row_item_title" android:layout_marginRight="8dp" - android:paddingTop="8dp" - android:paddingBottom="12dp" + android:paddingTop="2dp" + android:paddingBottom="4dp" + android:maxLines="2" + android:ellipsize="end" android:textColor="@color/darkgray" android:textSize="14sp"/> @@ -79,7 +81,7 @@ android:layout_alignParentRight="true" android:layout_below="@+id/row_item_content" android:layout_marginRight="8dp" - android:paddingBottom="12dp" + android:paddingBottom="4dp" android:textColor="@color/darkgray" android:textSize="11dp" /> @@ -88,7 +90,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/row_item_content" - android:paddingBottom="12dp" + android:paddingBottom="4dp" android:layout_toLeftOf="@id/row_item_date" android:layout_toRightOf="@id/row_item_sidebar" android:ellipsize="end" diff --git a/clients/android/NewsBlur/res/values/colors.xml b/clients/android/NewsBlur/res/values/colors.xml index 480aca707..70dfe2fd5 100644 --- a/clients/android/NewsBlur/res/values/colors.xml +++ b/clients/android/NewsBlur/res/values/colors.xml @@ -25,7 +25,7 @@ #333333 #808080 #404040 - #848484 + #909090 #606060 #A0A0A0 #959595 diff --git a/clients/android/NewsBlur/src/com/newsblur/database/BlurDatabase.java b/clients/android/NewsBlur/src/com/newsblur/database/BlurDatabase.java index 815e6d1de..425a9e6b1 100644 --- a/clients/android/NewsBlur/src/com/newsblur/database/BlurDatabase.java +++ b/clients/android/NewsBlur/src/com/newsblur/database/BlurDatabase.java @@ -86,6 +86,7 @@ public class BlurDatabase extends SQLiteOpenHelper { DatabaseConstants.STORY_HASH + TEXT + ", " + DatabaseConstants.STORY_AUTHORS + TEXT + ", " + DatabaseConstants.STORY_CONTENT + TEXT + ", " + + DatabaseConstants.STORY_SHORT_CONTENT + TEXT + ", " + DatabaseConstants.STORY_TIMESTAMP + INTEGER + ", " + DatabaseConstants.STORY_SHARED_DATE + INTEGER + ", " + DatabaseConstants.STORY_SHORTDATE + TEXT + ", " + diff --git a/clients/android/NewsBlur/src/com/newsblur/database/DatabaseConstants.java b/clients/android/NewsBlur/src/com/newsblur/database/DatabaseConstants.java index f9782445b..e94beb349 100644 --- a/clients/android/NewsBlur/src/com/newsblur/database/DatabaseConstants.java +++ b/clients/android/NewsBlur/src/com/newsblur/database/DatabaseConstants.java @@ -77,7 +77,7 @@ public class DatabaseConstants { public static final String STORY_TIMESTAMP = "timestamp"; public static final String STORY_SHARED_DATE = "sharedDate"; public static final String STORY_CONTENT = "content"; - public static final String STORY_SHORT_CONTENT = "content"; + public static final String STORY_SHORT_CONTENT = "short_content"; public static final String STORY_COMMENT_COUNT = "comment_count"; public static final String STORY_FEED_ID = "feed_id"; public static final String STORY_INTELLIGENCE_AUTHORS = "intelligence_authors"; @@ -172,12 +172,16 @@ public class DatabaseConstants { private static final String STORY_INTELLIGENCE_ALL = DatabaseConstants.SUM_STORY_TOTAL + " >= 0 "; public static final String[] STORY_COLUMNS = { - STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_TIMESTAMP, STORY_SHARED_DATE, STORY_SHORTDATE, STORY_LONGDATE, STORY_TABLE + "." + STORY_FEED_ID, STORY_TABLE + "." + STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, STORY_INTELLIGENCE_TITLE, - STORY_PERMALINK, STORY_READ, STORY_STARRED, STORY_STARRED_DATE, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, STORY_SOCIAL_USER_ID, STORY_SOURCE_USER_ID, STORY_SHARED_USER_IDS, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS, STORY_SUM_TOTAL, STORY_HASH + STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_SHORT_CONTENT, STORY_TIMESTAMP, STORY_SHARED_DATE, STORY_SHORTDATE, STORY_LONGDATE, + STORY_TABLE + "." + STORY_FEED_ID, STORY_TABLE + "." + STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, + STORY_INTELLIGENCE_TITLE, STORY_PERMALINK, STORY_READ, STORY_STARRED, STORY_STARRED_DATE, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, + STORY_SOCIAL_USER_ID, STORY_SOURCE_USER_ID, STORY_SHARED_USER_IDS, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS, STORY_SUM_TOTAL, STORY_HASH }; public static final String[] STARRED_STORY_COLUMNS = { - STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_TIMESTAMP, STORY_SHARED_DATE, STORY_SHORTDATE, STORY_LONGDATE, STARRED_STORIES_TABLE + "." + STORY_FEED_ID, STARRED_STORIES_TABLE + "." + STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, STORY_INTELLIGENCE_TITLE, - STORY_PERMALINK, STORY_READ, STORY_STARRED, STORY_STARRED_DATE, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, STORY_SOCIAL_USER_ID, STORY_SOURCE_USER_ID, STORY_SHARED_USER_IDS, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS, STORY_SUM_TOTAL, STORY_HASH + STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_SHORT_CONTENT, STORY_TIMESTAMP, STORY_SHARED_DATE, STORY_SHORTDATE, STORY_LONGDATE, + STARRED_STORIES_TABLE + "." + STORY_FEED_ID, STARRED_STORIES_TABLE + "." + STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, + STORY_INTELLIGENCE_TITLE, STORY_PERMALINK, STORY_READ, STORY_STARRED, STORY_STARRED_DATE, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, + STORY_SOCIAL_USER_ID, STORY_SOURCE_USER_ID, STORY_SHARED_USER_IDS, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS, STORY_SUM_TOTAL, STORY_HASH }; public static final String STARRED_STORY_ORDER = STORY_STARRED_DATE + " ASC"; diff --git a/clients/android/NewsBlur/src/com/newsblur/domain/Story.java b/clients/android/NewsBlur/src/com/newsblur/domain/Story.java index ddc7c42b4..f078e5ba4 100644 --- a/clients/android/NewsBlur/src/com/newsblur/domain/Story.java +++ b/clients/android/NewsBlur/src/com/newsblur/domain/Story.java @@ -8,7 +8,6 @@ import java.util.List; import android.content.ContentValues; import android.database.Cursor; -import android.text.Html; import android.text.TextUtils; import com.google.gson.annotations.SerializedName; @@ -68,7 +67,7 @@ public class Story implements Serializable { @SerializedName("story_content") public String content; - @SerializedName("story_short_content") + // this isn't actually a serialized feed, but created client-size in StoryTypeAdapter public String shortContent; @SerializedName("story_authors") @@ -104,6 +103,7 @@ public class Story implements Serializable { values.put(DatabaseConstants.STORY_SHORTDATE, shortDate); values.put(DatabaseConstants.STORY_LONGDATE, longDate); values.put(DatabaseConstants.STORY_CONTENT, content); + values.put(DatabaseConstants.STORY_SHORT_CONTENT, shortContent); values.put(DatabaseConstants.STORY_PERMALINK, permalink); values.put(DatabaseConstants.STORY_COMMENT_COUNT, commentCount); values.put(DatabaseConstants.STORY_SHARE_COUNT, shareCount); @@ -133,12 +133,7 @@ public class Story implements Serializable { Story story = new Story(); story.authors = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_AUTHORS)); story.content = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_CONTENT)); - if (story.content != null) { - String shortContent = Html.fromHtml(story.content).toString(); - if (shortContent.length() >= 200) { - story.shortContent = shortContent.substring(0, 200); - } - } + story.shortContent = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHORT_CONTENT)); story.title = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_TITLE)); story.timestamp = cursor.getLong(cursor.getColumnIndex(DatabaseConstants.STORY_TIMESTAMP)); story.sharedDate = new Date(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.STORY_SHARED_DATE))); diff --git a/clients/android/NewsBlur/src/com/newsblur/serialization/StoryTypeAdapter.java b/clients/android/NewsBlur/src/com/newsblur/serialization/StoryTypeAdapter.java index 35544399c..835b69b8d 100644 --- a/clients/android/NewsBlur/src/com/newsblur/serialization/StoryTypeAdapter.java +++ b/clients/android/NewsBlur/src/com/newsblur/serialization/StoryTypeAdapter.java @@ -10,6 +10,11 @@ import com.newsblur.domain.Story; import java.lang.reflect.Type; import java.util.Date; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import android.text.Html; +import android.util.Log; /** * Created by mark on 15/03/2014. @@ -18,6 +23,10 @@ public class StoryTypeAdapter implements JsonDeserializer { private Gson gson; + // the HTML parser puts placeholders for images and other content when parsing to text, but we + // want to remove them. + private final static Pattern HtmlPlaceholders = Pattern.compile("\\uFFFC"); + public StoryTypeAdapter() { this.gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateStringTypeAdapter()) @@ -29,8 +38,20 @@ public class StoryTypeAdapter implements JsonDeserializer { @Override public Story deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { Story story = gson.fromJson(jsonElement, Story.class); + // Convert story_timestamp to milliseconds story.timestamp = story.timestamp * 1000; + + // populate the shortContent field + if (story.content != null) { + CharSequence parsed = Html.fromHtml(story.content).toString(); + int length = 200; + if (parsed.length() < 200) { length = parsed.length(); } + story.shortContent = parsed.subSequence(0, length).toString(); + Matcher m = HtmlPlaceholders.matcher(story.shortContent); + story.shortContent = m.replaceAll(""); + } + return story; } }