diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 8a9e4804..9f1633d3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -431,6 +431,7 @@ public class TopicActivity extends BaseActivity { } } } + replyFAB.setEnabled(true); } //--------------------------------------POPULATE UI METHOD END-------------------------------------- diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 23e1f0e4..b76b13bd 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -11,7 +11,9 @@ import android.os.Handler; import android.support.v4.content.res.ResourcesCompat; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; +import android.text.Html; import android.text.TextUtils; +import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -66,6 +68,8 @@ class TopicAdapter extends RecyclerView.Adapter { final ImageButton quoteToggle; final RelativeLayout header; final LinearLayout userExtraInfo; + final View bodyFooterDivider; + final LinearLayout postFooter; final TextView specialRank, rank, gender, numberOfPosts, personalText, stars; @@ -83,6 +87,8 @@ class TopicAdapter extends RecyclerView.Adapter { subject = (TextView) view.findViewById(R.id.subject); post = (WebView) view.findViewById(R.id.post); quoteToggle = (ImageButton) view.findViewById(R.id.toggle_quote_button); + bodyFooterDivider = view.findViewById(R.id.body_footer_divider); + postFooter = (LinearLayout) view.findViewById(R.id.post_footer); //User's extra header = (RelativeLayout) view.findViewById(R.id.header); @@ -187,6 +193,23 @@ class TopicAdapter extends RecyclerView.Adapter { } }); + if (currentPost.getAttachedFiles().size() != 0) { + holder.bodyFooterDivider.setVisibility(View.VISIBLE); + for (String attachedFile : currentPost.getAttachedFiles()) { + TextView attached = new TextView(context); + attached.setTextSize(10f); + attached.setClickable(true); + attached.setMovementMethod(LinkMovementMethod.getInstance()); + + attached.setText(Html.fromHtml(attachedFile)); + + holder.postFooter.addView(attached); + } + } else { + holder.bodyFooterDivider.setVisibility(View.GONE); + holder.postFooter.removeAllViews(); + } + //If user is not deleted then we have more to do if (!currentPost.isDeleted()) { //Set extra info //Variables with content @@ -239,8 +262,7 @@ class TopicAdapter extends RecyclerView.Adapter { if (viewProperties.get(position)[isUserExtraInfoVisibile]) { //Expanded holder.userExtraInfo.setVisibility(View.VISIBLE); holder.userExtraInfo.setAlpha(1.0f); - } - else { //Collapsed + } else { //Collapsed holder.userExtraInfo.setVisibility(View.GONE); holder.userExtraInfo.setAlpha(0.0f); } @@ -495,5 +517,4 @@ class TopicAdapter extends RecyclerView.Adapter { } } //------------------------------------CUSTOM WEBVIEW CLIENT END------------------------------------- - } \ No newline at end of file diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java index 20bbfe57..eb5b128e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java @@ -1,6 +1,7 @@ package gr.thmmy.mthmmy.activities.topic; import android.graphics.Color; +import android.util.Log; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -91,6 +92,7 @@ class TopicParser { p_specialRank, p_gender, p_personalText, p_numberOfPosts; int p_postNum, p_postIndex, p_numberOfStars, p_userColor; boolean p_isDeleted = false; + ArrayList p_attachedFiles; //Initialize variables p_rank = "Rank"; @@ -100,6 +102,7 @@ class TopicParser { p_numberOfPosts = ""; p_numberOfStars = 0; p_userColor = USER_COLOR_YELLOW; + p_attachedFiles = new ArrayList<>(); //Find the Username Element userName = item.select("a[title^=" + userNameSelection + "]").first(); @@ -179,6 +182,23 @@ class TopicParser { p_postIndex = Integer.parseInt(tmp.substring(tmp.indexOf("msg") + 3)); } + //Find attached file's urls, names and info, if present + Elements postAttachments = item.select("div:containsOwn(downloaded)"); + if (postAttachments != null) { + for (Element attached : postAttachments) { + //Get file's url and filename + Element tmpAttachedFileUrlAndName = attached.select("a").first(); + tmpAttachedFileUrlAndName.select("img").remove().first(); + + //Get file's info (size and download count) + String tmpAttachedFileInfo = attached.text().trim(); + tmpAttachedFileInfo = tmpAttachedFileInfo.substring( + tmpAttachedFileInfo.indexOf("(")); + + p_attachedFiles.add(tmpAttachedFileUrlAndName + " " + tmpAttachedFileInfo); + } + } + if (!p_isDeleted) { //Active user //Get extra info int postsLineIndex = -1; @@ -238,12 +258,12 @@ class TopicParser { returnList.add(new Post(p_thumbnailUrl, p_userName, p_subject, p_post , p_postIndex, p_postNum, p_postDate, p_rank , p_specialRank, p_gender, p_numberOfPosts, p_personalText - , p_numberOfStars, p_userColor)); + , p_numberOfStars, p_userColor, p_attachedFiles)); } else { //Deleted user //Add new post in postsList, only standard information needed - returnList.add(new Post(p_thumbnailUrl, p_userName, p_subject - , p_post, p_postIndex, p_postNum, p_postDate, p_userColor)); + returnList.add(new Post(p_thumbnailUrl, p_userName, p_subject, p_post + , p_postIndex, p_postNum, p_postDate, p_userColor, p_attachedFiles)); } } return returnList; diff --git a/app/src/main/java/gr/thmmy/mthmmy/data/Post.java b/app/src/main/java/gr/thmmy/mthmmy/data/Post.java index c4c631d0..f2dd074c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/data/Post.java +++ b/app/src/main/java/gr/thmmy/mthmmy/data/Post.java @@ -1,7 +1,9 @@ package gr.thmmy.mthmmy.data; +import java.util.ArrayList; + public class Post { - //Standard info + //Standard info (exists in every post) private final String thumbnailUrl; private final String author; private final String subject; @@ -17,13 +19,15 @@ public class Post { private final String gender; private final String numberOfPosts; private final String personalText; - private int numberOfStars; + private final int numberOfStars; private final int userColor; + private final ArrayList attachedFiles; public Post(String thumbnailUrl, String author, String subject, String content , int postIndex, int postNumber, String postDate, String rank , String special_rank, String gender, String numberOfPosts - , String personalText, int numberOfStars, int userColor) { + , String personalText, int numberOfStars, int userColor + , ArrayList attachedFiles) { this.thumbnailUrl = thumbnailUrl; this.author = author; this.subject = subject; @@ -39,10 +43,12 @@ public class Post { this.personalText = personalText; this.numberOfStars = numberOfStars; this.userColor = userColor; + this.attachedFiles = attachedFiles; } public Post(String thumbnailUrl, String author, String subject, String content - , int postIndex, int postNumber, String postDate, int userColor) { + , int postIndex, int postNumber, String postDate, int userColor + , ArrayList attachedFiles) { this.thumbnailUrl = thumbnailUrl; this.author = author; this.subject = subject; @@ -57,6 +63,8 @@ public class Post { gender = "Gender"; numberOfPosts = "Posts: 0"; personalText = ""; + numberOfStars = 0; + this.attachedFiles = attachedFiles; } //Getters @@ -76,19 +84,25 @@ public class Post { return subject; } - public String getPostDate() { return postDate;} + public String getPostDate() { + return postDate; + } public int getPostNumber() { return postNumber; } - public int getPostIndex() { return postIndex;} + public int getPostIndex() { + return postIndex; + } public boolean isDeleted() { return isDeleted; } - public String getRank() {return rank; } + public String getRank() { + return rank; + } public String getSpecialRank() { return specialRank; @@ -106,7 +120,15 @@ public class Post { return personalText; } - public int getNumberOfStars() {return numberOfStars; } + public int getNumberOfStars() { + return numberOfStars; + } + + public int getUserColor() { + return userColor; + } - public int getUserColor() {return userColor; } + public ArrayList getAttachedFiles() { + return attachedFiles; + } } diff --git a/app/src/main/res/layout/activity_topic_post_row.xml b/app/src/main/res/layout/activity_topic_post_row.xml index dc9fcc6a..5b98b65c 100644 --- a/app/src/main/res/layout/activity_topic_post_row.xml +++ b/app/src/main/res/layout/activity_topic_post_row.xml @@ -191,7 +191,7 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d132c800..e144e8d0 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -28,7 +28,6 @@ #333333 #3C3F41 #BF4040 - #E7E7E7 #757575 #303234 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 17b2d004..5e09cba8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ last Home + #%1$d diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c85c2991..b3a619f3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,6 +1,6 @@ - +