From 49f820110d8c6a4520fc5e5e8b5c83e1b9eac0a1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 15:09:29 +0300 Subject: [PATCH 1/7] add not completely functional headline thumbnails for compact mode --- .../java/org/fox/ttrss/CommonActivity.java | 8 ++ .../java/org/fox/ttrss/HeadlinesFragment.java | 115 +++++++++++------- .../offline/OfflineHeadlinesFragment.java | 9 +- .../main/res/layout/headlines_row_compact.xml | 10 +- .../layout/headlines_row_selected_compact.xml | 14 ++- .../layout/headlines_row_unread_compact.xml | 14 ++- org.fox.ttrss/src/main/res/values/arrays.xml | 2 + org.fox.ttrss/src/main/res/values/strings.xml | 1 + 8 files changed, 112 insertions(+), 61 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java index 326b88f6..f78ae6c1 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java @@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v7.app.ActionBarActivity; +import android.util.DisplayMetrics; import android.util.Log; import android.view.Display; import android.widget.Toast; @@ -170,5 +171,12 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc m_needRestart = Arrays.asList(filter).indexOf(key) != -1; } + + public int dpToPx(int dp) { + DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); + int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); + return px; + } + } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 2b031d3c..334e57f8 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -38,6 +38,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckBox; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; import android.widget.ProgressBar; @@ -341,7 +342,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_compactLayoutMode = savedInstanceState.getBoolean("compactLayoutMode"); } - if ("HL_COMPACT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"))) + String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT"); + + if ("HL_COMPACT".equals(headlineMode) || "HL_COMPACT_NOIMAGES".equals(headlineMode)) m_compactLayoutMode = true; DisplayMetrics metrics = new DisplayMetrics(); @@ -680,11 +683,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT; private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round(); private final DisplayImageOptions displayImageOptions; + boolean showFlavorImage; public ArticleListAdapter(Context context, int textViewResourceId, ArrayList
items) { super(context, textViewResourceId, items); this.items = items; + String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT"); + showFlavorImage = "HL_DEFAULT".equals(headlineMode) || "HL_COMPACT".equals(headlineMode); + Theme theme = context.getTheme(); TypedValue tv = new TypedValue(); theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true); @@ -728,11 +735,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, String tmp = item.title.length() > 0 ? item.title.substring(0, 1) : "?"; if (item.selected) { - holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161)); + if (item.flavorImage == null) + holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161)); holder.textChecked.setVisibility(View.VISIBLE); } else { - holder.textImage.setImageDrawable(m_drawableBuilder.build(tmp, m_colorGenerator.getColor(item.title))); + if (item.flavorImage == null) + holder.textImage.setImageDrawable(m_drawableBuilder.build(tmp, m_colorGenerator.getColor(item.title))); holder.textChecked.setVisibility(View.GONE); } @@ -800,7 +809,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, holder = (HeadlineViewHolder) v.getTag(); } - // block footer clicks to make button/selection clicking easier + String articleContent = article.content != null ? article.content : ""; + + String articleContentReduced = articleContent.length() > CommonActivity.EXCERPT_MAX_QUERY_LENGTH ? + articleContent.substring(0, CommonActivity.EXCERPT_MAX_QUERY_LENGTH) : articleContent; + + if (article.articleDoc == null) + article.articleDoc = Jsoup.parse(articleContentReduced); + + // block footer clicks to make button/selection clicking easier if (holder.headlineFooter != null) { holder.headlineFooter.setOnClickListener(new OnClickListener() { @Override @@ -810,23 +827,64 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, }); } + if (showFlavorImage && article.flavorImage == null) { + + Elements imgs = article.articleDoc.select("img"); + + for (Element tmp : imgs) { + try { + if (Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_WIDTH && Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_HEIGHT) { + article.flavorImage = tmp; + break; + } + } catch (NumberFormatException e) { + // + } + } + + if (article.flavorImage == null) + article.flavorImage = imgs.first(); + } + if (holder.textImage != null) { updateTextCheckedState(holder, article); - holder.textImage.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - Log.d(TAG, "textImage : onclicked"); + if (article.flavorImage != null) { + String imgSrc = article.flavorImage.attr("src"); + final String imgSrcFirst = imgSrc; - article.selected = !article.selected; + // retarded schema-less urls + if (imgSrc.indexOf("//") == 0) + imgSrc = "http:" + imgSrc; - updateTextCheckedState(holder, article); + if (!imgSrc.equals(holder.textImage.getTag())) { + ImageAware imageAware = new ImageViewAware(holder.textImage, false); + m_imageLoader.displayImage(imgSrc, imageAware, displayImageOptions); + holder.textImage.setTag(imgSrc); + } - m_listener.onArticleListSelectionChange(getSelectedArticles()); + holder.textImage.getLayoutParams().width = m_activity.dpToPx(64); + holder.textImage.getLayoutParams().height = m_activity.dpToPx(64); - Log.d(TAG, "num selected: " + getSelectedArticles().size()); - } - }); + } else { + holder.textImage.getLayoutParams().width = m_activity.dpToPx(48); + holder.textImage.getLayoutParams().height = m_activity.dpToPx(48); + } + + holder.textImage.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + Log.d(TAG, "textImage : onclicked"); + + article.selected = !article.selected; + + updateTextCheckedState(holder, article); + + m_listener.onArticleListSelectionChange(getSelectedArticles()); + + Log.d(TAG, "num selected: " + getSelectedArticles().size()); + } + }); } @@ -898,14 +956,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, }); } - String articleContent = article.content != null ? article.content : ""; - - String articleContentReduced = articleContent.length() > CommonActivity.EXCERPT_MAX_QUERY_LENGTH ? - articleContent.substring(0, CommonActivity.EXCERPT_MAX_QUERY_LENGTH) : articleContent; - - if (article.articleDoc == null) - article.articleDoc = Jsoup.parse(articleContentReduced); - if (holder.excerptView != null) { if (!m_prefs.getBoolean("headlines_show_content", true)) { holder.excerptView.setVisibility(View.GONE); @@ -930,7 +980,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, } if (!m_compactLayoutMode) { - boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT")); if (showFlavorImage && holder.flavorImageView != null) { holder.flavorImageArrow.setVisibility(View.GONE); @@ -939,25 +988,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, holder.flavorImageHolder.setVisibility(View.GONE); } else if (article.articleDoc != null) { - if (article.flavorImage == null) { - - Elements imgs = article.articleDoc.select("img"); - - for (Element tmp : imgs) { - try { - if (Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_WIDTH && Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_HEIGHT) { - article.flavorImage = tmp; - break; - } - } catch (NumberFormatException e) { - // - } - } - - if (article.flavorImage == null) - article.flavorImage = imgs.first(); - } - if (article.flavorImage != null) { String imgSrc = article.flavorImage.attr("src"); final String imgSrcFirst = imgSrc; @@ -1057,7 +1087,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, String articleAuthor = article.author != null ? article.author : ""; - if (holder.authorView != null) { holder.authorView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 93e8e8a3..f8868d70 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -292,8 +292,10 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis m_activity.getDatabase().execSQL("UPDATE articles SET selected = 0 "); } - if ("HL_COMPACT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"))) - m_compactLayoutMode = true; + String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT"); + + if ("HL_COMPACT".equals(headlineMode) || "HL_COMPACT_NOIMAGES".equals(headlineMode)) + m_compactLayoutMode = true; View view = inflater.inflate(R.layout.fragment_headlines, container, false); @@ -601,6 +603,9 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis if (holder.textImage != null) { updateTextCheckedState(holder, article); + holder.textImage.getLayoutParams().width = m_activity.dpToPx(48); + holder.textImage.getLayoutParams().height = m_activity.dpToPx(48); + holder.textImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml b/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml index 74184cd1..09106ef6 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml @@ -10,22 +10,24 @@ tools:ignore="HardcodedText" > + android:id="@+id/text_checked" + android:layout_gravity="center" /> diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml b/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml index 5e6f3011..f963aa86 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml @@ -11,22 +11,24 @@ tools:ignore="HardcodedText" > + android:layout_width="64dp" + android:layout_height="64dp"> + android:id="@+id/text_checked" + android:layout_gravity="center" /> diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml b/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml index 58317014..b9db0c48 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml @@ -11,22 +11,24 @@ tools:ignore="HardcodedText" > + android:layout_width="64dp" + android:layout_height="64dp"> + android:id="@+id/text_checked" + android:layout_gravity="center" /> diff --git a/org.fox.ttrss/src/main/res/values/arrays.xml b/org.fox.ttrss/src/main/res/values/arrays.xml index 1ac11814..aa14bd62 100644 --- a/org.fox.ttrss/src/main/res/values/arrays.xml +++ b/org.fox.ttrss/src/main/res/values/arrays.xml @@ -15,11 +15,13 @@ @string/headline_display_mode_default @string/headline_display_mode_no_images @string/headline_display_mode_compact + @string/headline_display_mode_compact_noimages HL_DEFAULT HL_NOIMAGES HL_COMPACT + HL_COMPACT_NOIMAGES 150 diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml index 1d88f150..746451f8 100755 --- a/org.fox.ttrss/src/main/res/values/strings.xml +++ b/org.fox.ttrss/src/main/res/values/strings.xml @@ -215,6 +215,7 @@ Default No images Compact + Compact (no images) %1$s (%2$d) Version %1$s From 618fe0aa1d4ffddc22e2c9cbf018f6dc69273e63 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 15:28:24 +0300 Subject: [PATCH 2/7] some more work on thumbnails --- .../src/main/java/org/fox/ttrss/CommonActivity.java | 6 ------ .../src/main/java/org/fox/ttrss/HeadlinesFragment.java | 7 ------- .../org/fox/ttrss/offline/OfflineHeadlinesFragment.java | 3 --- .../src/main/res/layout/headlines_row_compact.xml | 4 ++-- .../main/res/layout/headlines_row_selected_compact.xml | 8 ++++---- .../src/main/res/layout/headlines_row_unread_compact.xml | 8 ++++---- 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java index f78ae6c1..c2fe90a1 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java @@ -172,11 +172,5 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc m_needRestart = Arrays.asList(filter).indexOf(key) != -1; } - public int dpToPx(int dp) { - DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); - int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); - return px; - } - } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 334e57f8..04cc564a 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -862,13 +862,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_imageLoader.displayImage(imgSrc, imageAware, displayImageOptions); holder.textImage.setTag(imgSrc); } - - holder.textImage.getLayoutParams().width = m_activity.dpToPx(64); - holder.textImage.getLayoutParams().height = m_activity.dpToPx(64); - - } else { - holder.textImage.getLayoutParams().width = m_activity.dpToPx(48); - holder.textImage.getLayoutParams().height = m_activity.dpToPx(48); } holder.textImage.setOnClickListener(new OnClickListener() { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index f8868d70..9e12cc94 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -603,9 +603,6 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis if (holder.textImage != null) { updateTextCheckedState(holder, article); - holder.textImage.getLayoutParams().width = m_activity.dpToPx(48); - holder.textImage.getLayoutParams().height = m_activity.dpToPx(48); - holder.textImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml b/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml index 09106ef6..8b645529 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row_compact.xml @@ -17,8 +17,8 @@ diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml b/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml index f963aa86..306f87b4 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row_selected_compact.xml @@ -13,13 +13,13 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content"> diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml b/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml index b9db0c48..e5539b8d 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row_unread_compact.xml @@ -13,13 +13,13 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content"> From dbd7d09a6999f280b5ccdaa78dd107148fe61509 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 16:23:38 +0300 Subject: [PATCH 3/7] rounded compact thumbnails --- .../java/org/fox/ttrss/HeadlinesFragment.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 04cc564a..899e3fd1 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -38,7 +38,6 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckBox; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; import android.widget.ProgressBar; @@ -53,6 +52,7 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; +import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer; import com.nostra13.universalimageloader.core.imageaware.ImageAware; import com.nostra13.universalimageloader.core.imageaware.ImageViewAware; import com.nostra13.universalimageloader.core.listener.ImageLoadingListener; @@ -701,8 +701,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, .cacheInMemory(true) .resetViewBeforeLoading(true) .cacheOnDisk(true) - .displayer(new FadeInBitmapDisplayer(500)) + .displayer(m_compactLayoutMode ? new RoundedBitmapDisplayer(100) : new FadeInBitmapDisplayer(500)) .build(); + } public int getViewTypeCount() { @@ -735,13 +736,27 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, String tmp = item.title.length() > 0 ? item.title.substring(0, 1) : "?"; if (item.selected) { - if (item.flavorImage == null) - holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161)); + holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161)); + holder.textImage.setTag(null); holder.textChecked.setVisibility(View.VISIBLE); } else { - if (item.flavorImage == null) + if (item.flavorImage == null) { holder.textImage.setImageDrawable(m_drawableBuilder.build(tmp, m_colorGenerator.getColor(item.title))); + holder.textImage.setTag(null); + } else { + String imgSrc = item.flavorImage.attr("src"); + + // retarded schema-less urls + if (imgSrc.indexOf("//") == 0) + imgSrc = "http:" + imgSrc; + + if (!imgSrc.equals(holder.textImage.getTag())) { + ImageAware imageAware = new ImageViewAware(holder.textImage, false); + m_imageLoader.displayImage(imgSrc, imageAware, displayImageOptions); + holder.textImage.setTag(imgSrc); + } + } holder.textChecked.setVisibility(View.GONE); } @@ -849,21 +864,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (holder.textImage != null) { updateTextCheckedState(holder, article); - if (article.flavorImage != null) { - String imgSrc = article.flavorImage.attr("src"); - final String imgSrcFirst = imgSrc; - - // retarded schema-less urls - if (imgSrc.indexOf("//") == 0) - imgSrc = "http:" + imgSrc; - - if (!imgSrc.equals(holder.textImage.getTag())) { - ImageAware imageAware = new ImageViewAware(holder.textImage, false); - m_imageLoader.displayImage(imgSrc, imageAware, displayImageOptions); - holder.textImage.setTag(imgSrc); - } - } - holder.textImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { From 40bce03f2ddcdcd91bbbb75b093f5d4a794148fe Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 16:36:28 +0300 Subject: [PATCH 4/7] use text drawables as a fallback when drawing compact thumbnails --- .../java/org/fox/ttrss/HeadlinesFragment.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 899e3fd1..af7b412e 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.res.Resources.Theme; import android.graphics.Bitmap; import android.graphics.Paint; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -701,7 +702,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, .cacheInMemory(true) .resetViewBeforeLoading(true) .cacheOnDisk(true) - .displayer(m_compactLayoutMode ? new RoundedBitmapDisplayer(100) : new FadeInBitmapDisplayer(500)) + .displayer(new FadeInBitmapDisplayer(500)) .build(); } @@ -741,8 +742,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, holder.textChecked.setVisibility(View.VISIBLE); } else { + Drawable textDrawable = m_drawableBuilder.build(tmp, m_colorGenerator.getColor(item.title)); + if (item.flavorImage == null) { - holder.textImage.setImageDrawable(m_drawableBuilder.build(tmp, m_colorGenerator.getColor(item.title))); + holder.textImage.setImageDrawable(textDrawable); holder.textImage.setTag(null); } else { String imgSrc = item.flavorImage.attr("src"); @@ -753,7 +756,19 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (!imgSrc.equals(holder.textImage.getTag())) { ImageAware imageAware = new ImageViewAware(holder.textImage, false); - m_imageLoader.displayImage(imgSrc, imageAware, displayImageOptions); + + DisplayImageOptions options = new DisplayImageOptions.Builder() + .cacheInMemory(true) + .resetViewBeforeLoading(true) + .cacheOnDisk(true) + .showImageOnLoading(textDrawable) + .showImageOnFail(textDrawable) + .showImageForEmptyUri(textDrawable) + .displayer(new RoundedBitmapDisplayer(100)) + .build(); + + + m_imageLoader.displayImage(imgSrc, imageAware, options); holder.textImage.setTag(imgSrc); } } From 8207b3a1f87c1b3c01debbddd985f73020b0db99 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 16:38:37 +0300 Subject: [PATCH 5/7] uppercase text drawable --- .../src/main/java/org/fox/ttrss/HeadlinesFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index af7b412e..534f2832 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -734,7 +734,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, } private void updateTextCheckedState(HeadlineViewHolder holder, Article item) { - String tmp = item.title.length() > 0 ? item.title.substring(0, 1) : "?"; + String tmp = item.title.length() > 0 ? item.title.substring(0, 1).toUpperCase() : "?"; if (item.selected) { holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161)); From 3599b91766d36d1a2d9701a5330bff946a0e3cae Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 16:50:18 +0300 Subject: [PATCH 6/7] minor thumbnail fixes --- .../main/java/org/fox/ttrss/HeadlinesFragment.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 534f2832..557e5cb8 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -860,20 +860,30 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (showFlavorImage && article.flavorImage == null) { Elements imgs = article.articleDoc.select("img"); + Element firstImg = null; for (Element tmp : imgs) { try { + if (tmp.attr("src") != null && tmp.attr("src").indexOf("data:") == 0) { + continue; + } + + if (firstImg != null) firstImg = tmp; + if (Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_WIDTH && Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_HEIGHT) { article.flavorImage = tmp; break; } + } catch (NumberFormatException e) { // } } + Log.d(TAG, "" + firstImg); + if (article.flavorImage == null) - article.flavorImage = imgs.first(); + article.flavorImage = firstImg; } if (holder.textImage != null) { From 49a4128833e2430033ed1ec96813cd27ffacc7ec Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 8 Jul 2015 17:03:17 +0300 Subject: [PATCH 7/7] minor thumbnail fixes (2) --- .../java/org/fox/ttrss/HeadlinesFragment.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 557e5cb8..8f6f583f 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -860,7 +860,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (showFlavorImage && article.flavorImage == null) { Elements imgs = article.articleDoc.select("img"); - Element firstImg = null; for (Element tmp : imgs) { try { @@ -868,8 +867,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, continue; } - if (firstImg != null) firstImg = tmp; - if (Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_WIDTH && Integer.valueOf(tmp.attr("width")) > FLAVOR_IMG_MIN_HEIGHT) { article.flavorImage = tmp; break; @@ -880,10 +877,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, } } - Log.d(TAG, "" + firstImg); - if (article.flavorImage == null) - article.flavorImage = firstImg; + article.flavorImage = imgs.first(); } if (holder.textImage != null) { @@ -903,6 +898,32 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, Log.d(TAG, "num selected: " + getSelectedArticles().size()); } }); + ViewCompat.setTransitionName(holder.textImage, "TRANSITION:ARTICLE_IMAGES_PAGER"); + + if (article.flavorImage != null) { + final String imgSrcFirst = article.flavorImage.attr("src"); + + holder.textImage.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + + Intent intent = new Intent(m_activity, ArticleImagesPagerActivity.class); + intent.putExtra("firstSrc", imgSrcFirst); + intent.putExtra("title", article.title); + intent.putExtra("content", article.content); + + ActivityOptionsCompat options = + ActivityOptionsCompat.makeSceneTransitionAnimation(m_activity, + holder.textImage, // The view which starts the transition + "TRANSITION:ARTICLE_IMAGES_PAGER" // The transitionName of the view we’re transitioning to + ); + ActivityCompat.startActivity(m_activity, intent, options.toBundle()); + + return true; + } + }); + + } }