From fc42b73ba599211bbdeda5da42d7710eb6976f81 Mon Sep 17 00:00:00 2001 From: Brad Stewart Date: Sun, 31 Mar 2013 16:47:05 -0400 Subject: [PATCH] View title text on images Conflicts: res/values-fr/strings.xml res/values/strings.xml --- res/menu/article_content_img_context_menu.xml | 7 +++- res/values-fr/strings.xml | 2 + res/values/strings.xml | 2 + src/org/fox/ttrss/OnlineActivity.java | 38 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/res/menu/article_content_img_context_menu.xml b/res/menu/article_content_img_context_menu.xml index 3c46c1a1..0f14dd92 100644 --- a/res/menu/article_content_img_context_menu.xml +++ b/res/menu/article_content_img_context_menu.xml @@ -9,10 +9,15 @@ android:id="@+id/article_img_share" android:showAsAction="" android:title="@string/article_img_share"/> + + - \ No newline at end of file + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 4aa9633c..388a1656 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -55,6 +55,7 @@ Activer les icônes des flux Activer les catégories des flux Aucun flux à afficher + Aucun sous-titre trouvé Aucun titre à afficher Parcourir les catégories comme les flux Utilisez le menu contexte des catégories pour redéfinir ce paramètre. @@ -189,4 +190,5 @@ Ouvrir l\'image Partager l\'image Nécessite la version 1.7.6 + Montrer le sous-titre diff --git a/res/values/strings.xml b/res/values/strings.xml index ff2fb2cd..4c0e8922 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -56,6 +56,7 @@ Enable feed categories No feeds to display No headlines to display + No caption to display Browse categories like feeds Use category context menu to override this setting Mark read @@ -190,4 +191,5 @@ Share image Requires version 1.7.6 Labels + View Caption diff --git a/src/org/fox/ttrss/OnlineActivity.java b/src/org/fox/ttrss/OnlineActivity.java index 13b2925c..945ac3b2 100644 --- a/src/org/fox/ttrss/OnlineActivity.java +++ b/src/org/fox/ttrss/OnlineActivity.java @@ -44,12 +44,19 @@ import android.webkit.WebView.HitTestResult; import android.widget.EditText; import android.widget.SearchView; import android.widget.ShareActionProvider; +import android.widget.TextView; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + + public class OnlineActivity extends CommonActivity { private final String TAG = this.getClass().getSimpleName(); @@ -564,6 +571,37 @@ public class OnlineActivity extends CommonActivity { startActivity(Intent.createChooser(intent, getLastContentImageHitTestUrl())); } return true; + case R.id.article_img_view_caption: + if (getLastContentImageHitTestUrl() != null) { + + // Android doesn't give us an easy way to access title tags; + // we'll use Jsoup on the body text to grab the title text + // from the first image tag with this url. This will show + // the wrong text if an image is used multiple times. + Document doc = Jsoup.parse(ap.getSelectedArticle().content); + Elements es = doc.getElementsByAttributeValue("src", getLastContentImageHitTestUrl()); + if (es.size() > 0){ + if (es.get(0).hasAttr("title")){ + Dialog dia = new Dialog(this); + if (es.get(0).hasAttr("alt")){ + dia.setTitle(es.get(0).attr("alt")); + } else { + dia.setTitle(es.get(0).attr("title")); + } + TextView titleText = new TextView(this); + titleText.setPaddingRelative(24, 24, 24, 24); + titleText.setTextSize(16); + titleText.setText(es.get(0).attr("title")); + dia.setContentView(titleText); + dia.show(); + } else { + toast(R.string.no_caption_to_display); + } + } else { + toast(R.string.no_caption_to_display); + } + } + return true; case R.id.article_link_share: if (ap != null && ap.getSelectedArticle() != null) { shareArticle(ap.getSelectedArticle());