summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefkev <[email protected]>2023-05-20 14:39:26 +0200
committerdefkev <[email protected]>2023-05-20 14:39:26 +0200
commit9e169dc3aa7c7e30c11d7d3d1bbc4bc66fa39760 (patch)
tree05207b24da95ed9ee45582e1c63f7344e97c7a29
parente6813c7ffc9d3d876319a8322e9636c3b4694f57 (diff)
Add hostname of link to article fragment
* only if link hostname differs from comment_link hostname * omit www. prefix if present
-rwxr-xr-xorg.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java14
-rwxr-xr-xorg.fox.ttrss/src/main/res/layout/fragment_article.xml14
2 files changed, 28 insertions, 0 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java
index beff9a1f..bf89e324 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java
@@ -335,6 +335,20 @@ public class ArticleFragment extends StateSavedFragment {
}
}
+ TextView host = view.findViewById(R.id.host);
+ if (host != null) {
+ try {
+ URL inurl = new URL(m_article.comments_link); /* This could be improved if /tt-rss/api:getArticle returned feed_url */
+ URL outurl = new URL(m_article.link);
+ String inhost = inurl.getHost();
+ String outhost = outurl.getHost();
+ if (!inhost.equals(outhost)) {
+ host.setVisibility(View.VISIBLE);
+ host.setText(outhost.replaceFirst("^www\\.", ""));
+ }
+ } catch (MalformedURLException ignored) {}
+ }
+
TextView note = view.findViewById(R.id.note);
if (note != null) {
diff --git a/org.fox.ttrss/src/main/res/layout/fragment_article.xml b/org.fox.ttrss/src/main/res/layout/fragment_article.xml
index 013b898c..61215a40 100755
--- a/org.fox.ttrss/src/main/res/layout/fragment_article.xml
+++ b/org.fox.ttrss/src/main/res/layout/fragment_article.xml
@@ -97,6 +97,20 @@
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp" />
+ <TextView
+ android:id="@+id/host"
+ tools:text="host"
+ android:background="@drawable/ripple"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAlignment="viewStart"
+ android:layout_weight="1"
+ android:fontFamily="sans-serif-light"
+ android:paddingTop="8dp"
+ android:textColor="?headlineSecondaryTextColor"
+ android:textSize="12sp"
+ android:visibility="gone"/>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"