diff options
author | Lennart Weller <[email protected]> | 2013-05-07 13:49:35 +0200 |
---|---|---|
committer | Lennart Weller <[email protected]> | 2013-05-07 13:49:35 +0200 |
commit | 2b868f1c8ff72b2fccae7cb141800483d288d534 (patch) | |
tree | 3e6a6f1993523cfd465d0c7dc74ba9c161af66f4 /src | |
parent | 777b706dbc87a6052f628f906251d03601a65907 (diff) |
fix for opening links with special characters like whitespace
Diffstat (limited to 'src')
-rw-r--r-- | src/org/fox/ttrss/ArticleFragment.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java index a7a7de0f..396ef730 100644 --- a/src/org/fox/ttrss/ArticleFragment.java +++ b/src/org/fox/ttrss/ArticleFragment.java @@ -1,6 +1,7 @@ package org.fox.ttrss; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date; @@ -115,9 +116,11 @@ public class ArticleFragment extends Fragment implements GestureDetector.OnDoubl @Override public void onClick(View v) { try { - Intent intent = new Intent(Intent.ACTION_VIEW, - Uri.parse(m_article.link.trim())); - startActivity(intent); + URL url = new URL(m_article.link.trim()); + String uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), + url.getPort(), url.getPath(), url.getQuery(), url.getRef()).toString(); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); + startActivity(intent); } catch (Exception e) { e.printStackTrace(); m_activity.toast(R.string.error_other_error); @@ -139,11 +142,12 @@ public class ArticleFragment extends Fragment implements GestureDetector.OnDoubl @Override public void onClick(View v) { try { - String link = (m_article.comments_link != null && m_article.comments_link.length() > 0) ? - m_article.comments_link : m_article.link; - + URL url = new URL((m_article.comments_link != null && m_article.comments_link.length() > 0) ? + m_article.comments_link : m_article.link); + String uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), + url.getPort(), url.getPath(), url.getQuery(), url.getRef()).toString(); Intent intent = new Intent(Intent.ACTION_VIEW, - Uri.parse(link.trim())); + Uri.parse(uri)); startActivity(intent); } catch (Exception e) { e.printStackTrace(); |