mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-21 05:45:13 +00:00
Fix inline story content. (#497)
This commit is contained in:
parent
da94c64e08
commit
89a53e4c1d
9 changed files with 57 additions and 37 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.newsblur"
|
||||
android:versionCode="62"
|
||||
android:versionName="3.6.4" >
|
||||
android:versionCode="63"
|
||||
android:versionName="3.6.5" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
|
|
|
@ -65,8 +65,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/row_item_sidebar"
|
||||
android:layout_marginRight="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:textSize="14sp"/>
|
||||
|
@ -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"
|
||||
|
|
|
@ -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"/>
|
||||
|
||||
<TextView
|
||||
|
@ -58,11 +58,10 @@
|
|||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:gravity="left"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="2dp"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
|
@ -72,7 +71,7 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/row_item_title_container"
|
||||
android:layout_marginRight="12dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<color name="story_title_unread">#333333</color>
|
||||
<color name="story_title_read">#808080</color>
|
||||
<color name="story_content_unread">#404040</color>
|
||||
<color name="story_content_read">#848484</color>
|
||||
<color name="story_content_read">#909090</color>
|
||||
<color name="story_feed_unread">#606060</color>
|
||||
<color name="story_feed_read">#A0A0A0</color>
|
||||
<color name="story_author_unread">#959595</color>
|
||||
|
|
|
@ -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 + ", " +
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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<Story> {
|
|||
|
||||
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<Story> {
|
|||
@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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue