diff --git a/src/org/fox/ttrss/Article.java b/src/org/fox/ttrss/Article.java index 56f7adcf..c26e2cf7 100644 --- a/src/org/fox/ttrss/Article.java +++ b/src/org/fox/ttrss/Article.java @@ -16,7 +16,8 @@ public class Article implements Parcelable { String title; String link; int feed_id; - List tags; + List tags; + List attachments; String content; List> labels; @@ -49,6 +50,7 @@ public class Article implements Parcelable { out.writeInt(feed_id); out.writeStringList(tags); out.writeString(content); + out.writeList(attachments); } public void readFromParcel(Parcel in) { @@ -66,6 +68,9 @@ public class Article implements Parcelable { in.readStringList(tags); content = in.readString(); + + attachments = new ArrayList(); + in.readList(attachments, null); } @SuppressWarnings("rawtypes") diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java index fe02aa3d..272dfa34 100644 --- a/src/org/fox/ttrss/ArticleFragment.java +++ b/src/org/fox/ttrss/ArticleFragment.java @@ -1,5 +1,8 @@ package org.fox.ttrss; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date; @@ -142,11 +145,41 @@ public class ArticleFragment extends Fragment { //"" + "" + "" + - "" + articleContent + ""; + "" + articleContent; + + if (m_article.attachments.size() != 0) { + String attachments = "
Attachments: "; + + for (Attachment a : m_article.attachments) { + if (a.content_type != null && a.content_url != null && a.content_type.indexOf("image") != -1) { + + try { + URL url = new URL(a.content_url.trim()); + + String atitle = (a.title != null && a.title.length() > 0) ? a.title : new File(url.getFile()).getName(); + + content += "
"; + + attachments += "" + atitle + ", "; + + } catch (MalformedURLException e) { + // + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + content += attachments.replaceAll(", $", ""); + content += "
"; + } + + content += ""; try { web.loadDataWithBaseURL(null, content, "text/html", "utf-8", null); diff --git a/src/org/fox/ttrss/Attachment.java b/src/org/fox/ttrss/Attachment.java new file mode 100644 index 00000000..38cc16d8 --- /dev/null +++ b/src/org/fox/ttrss/Attachment.java @@ -0,0 +1,54 @@ +package org.fox.ttrss; + +import android.os.Parcel; +import android.os.Parcelable; + +public class Attachment implements Parcelable { + int id; + String content_url; + String content_type; + String title; + String duration; + int post_id; + + public Attachment(Parcel in) { + readFromParcel(in); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(id); + out.writeString(content_url); + out.writeString(content_type); + out.writeString(title); + out.writeString(duration); + out.writeInt(post_id); + } + + public void readFromParcel(Parcel in) { + id = in.readInt(); + content_url = in.readString(); + content_type = in.readString(); + title = in.readString(); + duration = in.readString(); + post_id = in.readInt(); + } + + @SuppressWarnings("rawtypes") + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public Attachment createFromParcel(Parcel in) { + return new Attachment(in); + } + + public Attachment[] newArray(int size) { + return new Attachment[size]; + } + }; + +} diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index b2741417..c93fd248 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -197,6 +197,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, put("sid", sessionId); put("feed_id", String.valueOf(m_feed.id)); put("show_content", "true"); + put("include_attachments", "true"); put("limit", String.valueOf(HEADLINES_REQUEST_SIZE)); put("offset", String.valueOf(0)); put("view_mode", showUnread ? "adaptive" : "all_articles");