aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/rssin/android/ArticleActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/rssin/android/ArticleActivity.java')
-rwxr-xr-x[-rw-r--r--]app/src/main/java/org/rssin/android/ArticleActivity.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/app/src/main/java/org/rssin/android/ArticleActivity.java b/app/src/main/java/org/rssin/android/ArticleActivity.java
index 6c80fb6..0951a48 100644..100755
--- a/app/src/main/java/org/rssin/android/ArticleActivity.java
+++ b/app/src/main/java/org/rssin/android/ArticleActivity.java
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
+import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
@@ -32,6 +33,9 @@ import org.rssin.rss.FeedSorterProvider;
import org.rssin.rss.FeedSorterTrainer;
import org.rssin.rssin.R;
+import java.net.MalformedURLException;
+import java.net.URL;
+
import static org.rssin.neurons.Feedback.Dislike;
import static org.rssin.neurons.Feedback.Like;
@@ -55,8 +59,28 @@ public class ArticleActivity extends ActionBarActivity {
title.setText(item.getTitle());
setTitle(item.getTitle());
+ String descriptionStr = item.getDescription();
+
+ try
+ {
+ // Transform <a> tags into absolute URLs.
+ // This may add a double slash after the domain name, but most - if not all - webservers will still
+ // parse the URL the same way.
+ URL url = new URL(item.getLink());
+ descriptionStr = descriptionStr.replaceAll("href=\"(((?!http).)*)\"", "href=\"http://" + url.getHost() + "/$1\"");
+ }catch(MalformedURLException e)
+ {
+ e.printStackTrace();
+ }
+
+ // Remove <img> & <media> tags
+ descriptionStr = descriptionStr.replaceAll("(<img.*\\/>|<img.*><\\/img>|<img.*>)", "");
+ descriptionStr = descriptionStr.replaceAll("(<media.*\\/>|<media.*><\\/media>)", "");
+
TextView description = (TextView) findViewById(R.id.article_description);
- description.setText(Html.fromHtml(item.getDescription()));
+ description.setText(Html.fromHtml(descriptionStr));
+ description.setLinksClickable(true);
+ description.setMovementMethod(LinkMovementMethod.getInstance());
TextView author = (TextView) findViewById(R.id.article_author);
if (item.getAuthor() != null) {