diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 251c7c2b..728a642b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -265,7 +265,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo for (Element topicRow : topicRows) { if (!Objects.equals(topicRow.className(), "titlebg")) { String pTopicUrl, pSubject, pStartedBy, pLastPost, pLastPostUrl, pStats; - boolean pLocked = false, pSticky = false; + boolean pLocked = false, pSticky = false, pUnread = false; Elements topicColumns = topicRow.select(">td"); { Element column = topicColumns.get(2); @@ -276,6 +276,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo pSticky = true; if (column.select("img[id^=lockicon]").first() != null) pLocked = true; + if (column.select("a[id^=newicon]").first() != null) + pUnread = true; } pStartedBy = topicColumns.get(3).text(); pStats = "Replies " + topicColumns.get(4).text() + ", Views " + topicColumns.get(5).text(); @@ -290,7 +292,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo } pLastPostUrl = topicColumns.last().select("a:has(img)").first().attr("href"); parsedTopics.add(new Topic(pTopicUrl, pSubject, pStartedBy, pLastPost, pLastPostUrl, - pStats, pLocked, pSticky)); + pStats, pLocked, pSticky, pUnread)); } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index bb43c065..90a98e53 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -6,6 +6,7 @@ import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; import android.support.v7.widget.RecyclerView; +import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -231,12 +232,14 @@ class BoardAdapter extends RecyclerView.Adapter { }); topicViewHolder.topicSubject.setTypeface(Typeface.createFromAsset(context.getAssets() , "fonts/fontawesome-webfont.ttf")); - String lockedSticky = topic.getSubject(); + String lockedSticky = topic.isUnread() ? + Html.fromHtml("" + context.getString(R.string.fa_circle) + " ").toString() : ""; + lockedSticky += topic.getSubject(); if (topic.isLocked()) lockedSticky += " " + context.getResources().getString(R.string.fa_lock); if (topic.isSticky()) { //topicViewHolder.topicSubject.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_pin, 0); - lockedSticky += " " + context.getResources().getString(R.string.fa_sticky); + lockedSticky += " " + context.getResources().getString(R.string.fa_thumbtack); } topicViewHolder.topicSubject.setText(lockedSticky); topicViewHolder.topicStartedBy.setText(context.getString(R.string.topic_started_by, topic.getStarter())); diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/Topic.java b/app/src/main/java/gr/thmmy/mthmmy/model/Topic.java index 27f22c31..207e2c2e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/Topic.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/Topic.java @@ -5,11 +5,11 @@ package gr.thmmy.mthmmy.model; * Class has one constructor and getter methods for all variables. *

A topic is described by its url, subject, username of creator, its date and time of this * topic's last post, url of this topic's last post, its view and reply stats, whether it's locked or - * not and whether it's sticky or not.. + * not, whether it's sticky or not and whether it contains an unread post or not.. */ public class Topic extends TopicSummary { private final String lastPostUrl, stats; - private final boolean locked, sticky; + private final boolean locked, sticky, unread; // Suppresses default constructor @SuppressWarnings("unused") @@ -19,6 +19,7 @@ public class Topic extends TopicSummary { this.stats = null; this.locked = false; this.sticky = false; + this.unread = false; } /** @@ -33,14 +34,16 @@ public class Topic extends TopicSummary { * @param stats this topic's view and reply stats * @param locked whether this topic is locked or not * @param sticky whether this topic is sticky or not + * @param unread whether this topic contains an unread post or not */ public Topic(String topicUrl, String subject, String starter, String lastPost, String lastPostUrl, - String stats, boolean locked, boolean sticky) { + String stats, boolean locked, boolean sticky, boolean unread) { super(topicUrl, subject, starter, lastPost); this.lastPostUrl = lastPostUrl; this.stats = stats; this.locked = locked; this.sticky = sticky; + this.unread = unread; } /** @@ -114,4 +117,13 @@ public class Topic extends TopicSummary { public boolean isSticky() { return sticky; } + + /** + * Gets this topic's unread status. True if it contains an unread post, false otherwise. + * + * @return this topic's unread status + */ + public boolean isUnread() { + return unread; + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2517070c..d3d7b1e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,9 +89,9 @@ - + File \"%1$s\" already exists. Download again?"