diff options
author | defkev <[email protected]> | 2023-05-20 14:39:26 +0200 |
---|---|---|
committer | defkev <[email protected]> | 2023-05-20 14:39:26 +0200 |
commit | 9e169dc3aa7c7e30c11d7d3d1bbc4bc66fa39760 (patch) | |
tree | 05207b24da95ed9ee45582e1c63f7344e97c7a29 /org.fox.ttrss/src | |
parent | e6813c7ffc9d3d876319a8322e9636c3b4694f57 (diff) |
Add hostname of link to article fragment
* only if link hostname differs from comment_link hostname
* omit www. prefix if present
Diffstat (limited to 'org.fox.ttrss/src')
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java | 14 | ||||
-rwxr-xr-x | org.fox.ttrss/src/main/res/layout/fragment_article.xml | 14 |
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" |