add not completely functional headline thumbnails for compact mode
This commit is contained in:
parent
d7677ec893
commit
49f820110d
@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -170,5 +171,12 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
|||||||
|
|
||||||
m_needRestart = Arrays.asList(filter).indexOf(key) != -1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
|
|||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
@ -341,7 +342,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
m_compactLayoutMode = savedInstanceState.getBoolean("compactLayoutMode");
|
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;
|
m_compactLayoutMode = true;
|
||||||
|
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
@ -680,11 +683,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT;
|
private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT;
|
||||||
private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round();
|
private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round();
|
||||||
private final DisplayImageOptions displayImageOptions;
|
private final DisplayImageOptions displayImageOptions;
|
||||||
|
boolean showFlavorImage;
|
||||||
|
|
||||||
public ArticleListAdapter(Context context, int textViewResourceId, ArrayList<Article> items) {
|
public ArticleListAdapter(Context context, int textViewResourceId, ArrayList<Article> items) {
|
||||||
super(context, textViewResourceId, items);
|
super(context, textViewResourceId, items);
|
||||||
this.items = 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();
|
Theme theme = context.getTheme();
|
||||||
TypedValue tv = new TypedValue();
|
TypedValue tv = new TypedValue();
|
||||||
theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true);
|
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) : "?";
|
String tmp = item.title.length() > 0 ? item.title.substring(0, 1) : "?";
|
||||||
|
|
||||||
if (item.selected) {
|
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);
|
holder.textChecked.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} 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);
|
holder.textChecked.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -800,7 +809,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
holder = (HeadlineViewHolder) v.getTag();
|
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) {
|
if (holder.headlineFooter != null) {
|
||||||
holder.headlineFooter.setOnClickListener(new OnClickListener() {
|
holder.headlineFooter.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@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) {
|
if (holder.textImage != null) {
|
||||||
updateTextCheckedState(holder, article);
|
updateTextCheckedState(holder, article);
|
||||||
|
|
||||||
holder.textImage.setOnClickListener(new OnClickListener() {
|
if (article.flavorImage != null) {
|
||||||
@Override
|
String imgSrc = article.flavorImage.attr("src");
|
||||||
public void onClick(View view) {
|
final String imgSrcFirst = imgSrc;
|
||||||
Log.d(TAG, "textImage : onclicked");
|
|
||||||
|
|
||||||
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 (holder.excerptView != null) {
|
||||||
if (!m_prefs.getBoolean("headlines_show_content", true)) {
|
if (!m_prefs.getBoolean("headlines_show_content", true)) {
|
||||||
holder.excerptView.setVisibility(View.GONE);
|
holder.excerptView.setVisibility(View.GONE);
|
||||||
@ -930,7 +980,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_compactLayoutMode) {
|
if (!m_compactLayoutMode) {
|
||||||
boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"));
|
|
||||||
|
|
||||||
if (showFlavorImage && holder.flavorImageView != null) {
|
if (showFlavorImage && holder.flavorImageView != null) {
|
||||||
holder.flavorImageArrow.setVisibility(View.GONE);
|
holder.flavorImageArrow.setVisibility(View.GONE);
|
||||||
@ -939,25 +988,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
holder.flavorImageHolder.setVisibility(View.GONE);
|
holder.flavorImageHolder.setVisibility(View.GONE);
|
||||||
} else if (article.articleDoc != null) {
|
} 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) {
|
if (article.flavorImage != null) {
|
||||||
String imgSrc = article.flavorImage.attr("src");
|
String imgSrc = article.flavorImage.attr("src");
|
||||||
final String imgSrcFirst = imgSrc;
|
final String imgSrcFirst = imgSrc;
|
||||||
@ -1057,7 +1087,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
String articleAuthor = article.author != null ? article.author : "";
|
String articleAuthor = article.author != null ? article.author : "";
|
||||||
|
|
||||||
|
|
||||||
if (holder.authorView != null) {
|
if (holder.authorView != null) {
|
||||||
holder.authorView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
|
holder.authorView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
|
||||||
|
|
||||||
|
@ -292,8 +292,10 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
m_activity.getDatabase().execSQL("UPDATE articles SET selected = 0 ");
|
m_activity.getDatabase().execSQL("UPDATE articles SET selected = 0 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("HL_COMPACT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT")))
|
String headlineMode = m_prefs.getString("headline_mode", "HL_DEFAULT");
|
||||||
m_compactLayoutMode = true;
|
|
||||||
|
if ("HL_COMPACT".equals(headlineMode) || "HL_COMPACT_NOIMAGES".equals(headlineMode))
|
||||||
|
m_compactLayoutMode = true;
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.fragment_headlines, container, false);
|
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) {
|
if (holder.textImage != null) {
|
||||||
updateTextCheckedState(holder, article);
|
updateTextCheckedState(holder, article);
|
||||||
|
|
||||||
|
holder.textImage.getLayoutParams().width = m_activity.dpToPx(48);
|
||||||
|
holder.textImage.getLayoutParams().height = m_activity.dpToPx(48);
|
||||||
|
|
||||||
holder.textImage.setOnClickListener(new OnClickListener() {
|
holder.textImage.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -10,22 +10,24 @@
|
|||||||
tools:ignore="HardcodedText" >
|
tools:ignore="HardcodedText" >
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_gravity="center_vertical|left"
|
android:layout_gravity="center_vertical|left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:layout_width="48dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:id="@+id/text_image"/>
|
android:id="@+id/text_image"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:src="@drawable/check_sm"
|
android:src="@drawable/check_sm"
|
||||||
android:id="@+id/text_checked"/>
|
android:id="@+id/text_checked"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -11,22 +11,24 @@
|
|||||||
tools:ignore="HardcodedText" >
|
tools:ignore="HardcodedText" >
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_gravity="center_vertical|left"
|
android:layout_gravity="center_vertical|left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="64dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="64dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:layout_width="48dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:id="@+id/text_image"/>
|
android:id="@+id/text_image"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:src="@drawable/check_sm"
|
android:src="@drawable/check_sm"
|
||||||
android:id="@+id/text_checked"/>
|
android:id="@+id/text_checked"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -11,22 +11,24 @@
|
|||||||
tools:ignore="HardcodedText" >
|
tools:ignore="HardcodedText" >
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_gravity="center_vertical|left"
|
android:layout_gravity="center_vertical|left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="64dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="64dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:layout_width="48dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:id="@+id/text_image"/>
|
android:id="@+id/text_image"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:src="@drawable/check_sm"
|
android:src="@drawable/check_sm"
|
||||||
android:id="@+id/text_checked"/>
|
android:id="@+id/text_checked"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
<item>@string/headline_display_mode_default</item>
|
<item>@string/headline_display_mode_default</item>
|
||||||
<item>@string/headline_display_mode_no_images</item>
|
<item>@string/headline_display_mode_no_images</item>
|
||||||
<item>@string/headline_display_mode_compact</item>
|
<item>@string/headline_display_mode_compact</item>
|
||||||
|
<item>@string/headline_display_mode_compact_noimages</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="headline_mode_values" translatable="false">
|
<string-array name="headline_mode_values" translatable="false">
|
||||||
<item>HL_DEFAULT</item>
|
<item>HL_DEFAULT</item>
|
||||||
<item>HL_NOIMAGES</item>
|
<item>HL_NOIMAGES</item>
|
||||||
<item>HL_COMPACT</item>
|
<item>HL_COMPACT</item>
|
||||||
|
<item>HL_COMPACT_NOIMAGES</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="pref_offline_amounts" translatable="false">
|
<string-array name="pref_offline_amounts" translatable="false">
|
||||||
<item>150</item>
|
<item>150</item>
|
||||||
|
@ -215,6 +215,7 @@
|
|||||||
<string name="headline_display_mode_default">Default</string>
|
<string name="headline_display_mode_default">Default</string>
|
||||||
<string name="headline_display_mode_no_images">No images</string>
|
<string name="headline_display_mode_no_images">No images</string>
|
||||||
<string name="headline_display_mode_compact">Compact</string>
|
<string name="headline_display_mode_compact">Compact</string>
|
||||||
|
<string name="headline_display_mode_compact_noimages">Compact (no images)</string>
|
||||||
<string name="prefs_version">%1$s (%2$d)</string>
|
<string name="prefs_version">%1$s (%2$d)</string>
|
||||||
<string name="prefs_version_title">Version</string>
|
<string name="prefs_version_title">Version</string>
|
||||||
<string name="prefs_build_timestamp">%1$s</string>
|
<string name="prefs_build_timestamp">%1$s</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user