Browse Source

feat: add online status dot to TopicActivity

develop
Ezerous 3 months ago
parent
commit
13011c01a9
  1. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  2. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
  3. 18
      app/src/main/java/gr/thmmy/mthmmy/model/Post.java
  4. 27
      app/src/main/res/layout/activity_topic_post_row.xml
  5. 1
      app/src/main/res/values/colors.xml
  6. 7
      app/src/main/res/values/strings.xml

7
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -378,6 +378,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//Sets username,submit date, index number, subject, post's and attached files texts //Sets username,submit date, index number, subject, post's and attached files texts
holder.username.setText(currentPost.getAuthor()); holder.username.setText(currentPost.getAuthor());
if(currentPost.getUserOnlineStatus())
holder.onlineStatusDot.setVisibility(View.VISIBLE);
holder.postDate.setText(currentPost.getPostDate()); holder.postDate.setText(currentPost.getPostDate());
if (currentPost.getPostNumber() != 0) if (currentPost.getPostNumber() != 0)
holder.postNum.setText(context.getString( holder.postNum.setText(context.getString(
@ -822,7 +826,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final View bodyFooterDivider; final View bodyFooterDivider;
final LinearLayout postFooter; final LinearLayout postFooter;
final TextView specialRank, rank, gender, numberOfPosts, personalText, stars; final TextView specialRank, rank, gender, numberOfPosts, personalText, stars, onlineStatusDot;
PostViewHolder(View view) { PostViewHolder(View view) {
super(view); super(view);
@ -835,6 +839,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
username = view.findViewById(R.id.username); username = view.findViewById(R.id.username);
subject = view.findViewById(R.id.subject); subject = view.findViewById(R.id.subject);
post = view.findViewById(R.id.post); post = view.findViewById(R.id.post);
onlineStatusDot = view.findViewById(R.id.online_status_dot);
post.setBackgroundColor(Color.argb(1, 255, 255, 255)); post.setBackgroundColor(Color.argb(1, 255, 255, 255));
quoteToggle = view.findViewById(R.id.toggle_quote_button); quoteToggle = view.findViewById(R.id.toggle_quote_button);
overflowButton = view.findViewById(R.id.post_overflow_menu); overflowButton = view.findViewById(R.id.post_overflow_menu);

12
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

@ -178,7 +178,7 @@ public class TopicParser {
p_specialRank, p_gender, p_personalText, p_numberOfPosts, p_postLastEditDate, p_specialRank, p_gender, p_personalText, p_numberOfPosts, p_postLastEditDate,
p_postURL, p_deletePostURL, p_editPostURL; p_postURL, p_deletePostURL, p_editPostURL;
int p_postNum, p_postIndex, p_numberOfStars, p_userColor; int p_postNum, p_postIndex, p_numberOfStars, p_userColor;
boolean p_isDeleted = false, p_isUserMentionedInPost = false; boolean p_isDeleted = false, p_isUserMentionedInPost = false, p_isUserOnline = false;
ArrayList<ThmmyFile> p_attachedFiles; ArrayList<ThmmyFile> p_attachedFiles;
//Initialize variables //Initialize variables
@ -403,6 +403,7 @@ public class TopicParser {
final String genderMaleStr = displayedLanguageGreek ? "Φύλο: Άντρας" : "Gender: Male"; final String genderMaleStr = displayedLanguageGreek ? "Φύλο: Άντρας" : "Gender: Male";
final String genderFemaleStr = displayedLanguageGreek ? "Φύλο: Γυναίκα" : "Gender: Female"; final String genderFemaleStr = displayedLanguageGreek ? "Φύλο: Γυναίκα" : "Gender: Female";
final String postsStr = displayedLanguageGreek ? "Μηνύματα:" : "Posts:"; final String postsStr = displayedLanguageGreek ? "Μηνύματα:" : "Posts:";
final String pmTitleWithOnlineStatusStr = displayedLanguageGreek ? "title=\"Προσωπικό μήνυμα (Σε σύνδεση)\"" : "title=\"Personal Message (Online)\"";
Document starsHtml= Jsoup.parse(""); Document starsHtml= Jsoup.parse("");
@ -422,6 +423,8 @@ public class TopicParser {
starsLineIndex = infoList.indexOf(line); starsLineIndex = infoList.indexOf(line);
starsHtml = Jsoup.parse(line); starsHtml = Jsoup.parse(line);
} }
if (line.contains(pmTitleWithOnlineStatusStr))
p_isUserOnline = true;
} }
p_numberOfStars = starsHtml.select("img[alt]").size(); p_numberOfStars = starsHtml.select("img[alt]").size();
@ -437,7 +440,10 @@ public class TopicParser {
p_rank = infoList.get(1).trim(); //Second line has the rank p_rank = infoList.get(1).trim(); //Second line has the rank
} }
p_userColor = colorPicker(starsHtml.select("img[alt]").first().attr("abs:src"), p_specialRank); Element starsHtmlEl = starsHtml.select("img[alt]").first();
if (p_numberOfStars>0 && starsHtmlEl!=null)
p_userColor = colorPicker(starsHtmlEl.attr("abs:src"), p_specialRank);
for (int i = postsLineIndex + 1; i < infoList.size() - 1; ++i) { for (int i = postsLineIndex + 1; i < infoList.size() - 1; ++i) {
//Searches under "Posts:" //Searches under "Posts:"
@ -463,7 +469,7 @@ public class TopicParser {
, p_postNum, p_postDate, p_profileURL, p_rank, p_specialRank, p_gender , p_postNum, p_postDate, p_profileURL, p_rank, p_specialRank, p_gender
, p_numberOfPosts, p_personalText, p_numberOfStars, p_userColor , p_numberOfPosts, p_personalText, p_numberOfStars, p_userColor
, p_attachedFiles, p_postLastEditDate, p_postURL, p_deletePostURL, p_editPostURL , p_attachedFiles, p_postLastEditDate, p_postURL, p_deletePostURL, p_editPostURL
, p_isUserMentionedInPost, Post.TYPE_POST)); , p_isUserOnline, p_isUserMentionedInPost, Post.TYPE_POST));
} }
else { //Deleted user else { //Deleted user

18
app/src/main/java/gr/thmmy/mthmmy/model/Post.java

@ -47,6 +47,7 @@ public class Post extends TopicItem {
private final String personalText; private final String personalText;
private final int numberOfStars; private final int numberOfStars;
private final boolean isUserMentionedInPost; private final boolean isUserMentionedInPost;
private final boolean isUserOnline;
// Suppresses default constructor // Suppresses default constructor
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -73,6 +74,7 @@ public class Post extends TopicItem {
postURL = null; postURL = null;
postDeleteURL = null; postDeleteURL = null;
postEditURL = null; postEditURL = null;
isUserOnline = false;
isUserMentionedInPost = false; isUserMentionedInPost = false;
postType = -1; postType = -1;
} }
@ -101,13 +103,14 @@ public class Post extends TopicItem {
* @param attachedFiles post's attached files * @param attachedFiles post's attached files
* @param lastEdit post's last edit date * @param lastEdit post's last edit date
* @param postURL post's URL * @param postURL post's URL
* @param isUserOnline author's online status
*/ */
public Post(@Nullable String thumbnailUrl, String author, String subject, String content public Post(@Nullable String thumbnailUrl, String author, String subject, String content
, String bbContent, int postIndex, int postNumber, String postDate, String profileURl, @Nullable String rank , String bbContent, int postIndex, int postNumber, String postDate, String profileURl, @Nullable String rank
, @Nullable String special_rank, @Nullable String gender, @Nullable String numberOfPosts , @Nullable String special_rank, @Nullable String gender, @Nullable String numberOfPosts
, @Nullable String personalText, int numberOfStars, int userColor , @Nullable String personalText, int numberOfStars, int userColor
, @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL , @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL
, @Nullable String postDeleteURL, @Nullable String postEditURL, boolean isUserMentionedInPost , @Nullable String postDeleteURL, @Nullable String postEditURL, boolean isUserOnline, boolean isUserMentionedInPost
, int postType) { , int postType) {
this.bbContent = bbContent; this.bbContent = bbContent;
if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null; if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null;
@ -132,6 +135,7 @@ public class Post extends TopicItem {
this.postURL = postURL; this.postURL = postURL;
this.postDeleteURL = postDeleteURL; this.postDeleteURL = postDeleteURL;
this.postEditURL = postEditURL; this.postEditURL = postEditURL;
this.isUserOnline = isUserOnline;
this.isUserMentionedInPost = isUserMentionedInPost; this.isUserMentionedInPost = isUserMentionedInPost;
this.postType = postType; this.postType = postType;
} }
@ -182,6 +186,7 @@ public class Post extends TopicItem {
this.postURL = postURL; this.postURL = postURL;
this.postDeleteURL = postDeleteURL; this.postDeleteURL = postDeleteURL;
this.postEditURL = postEditURL; this.postEditURL = postEditURL;
this.isUserOnline = false;
this.isUserMentionedInPost = isUserMentionedInPost; this.isUserMentionedInPost = isUserMentionedInPost;
this.postType = postType; this.postType = postType;
} }
@ -362,6 +367,17 @@ public class Post extends TopicItem {
return userColor; return userColor;
} }
/**
* Gets the online status of this post's author.
*
* @return online status of this post's author
*/
@Nullable
public boolean getUserOnlineStatus() {
return isUserOnline;
}
/** /**
* Gets this post's attached files. * Gets this post's attached files.
* *

27
app/src/main/res/layout/activity_topic_post_row.xml

@ -9,17 +9,17 @@
android:paddingStart="4dp" android:paddingStart="4dp"
tools:ignore="SmallSp"> tools:ignore="SmallSp">
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" <androidx.cardview.widget.CardView
android:id="@+id/card_view" android:id="@+id/card_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_gravity="center"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="@color/background_light" app:cardBackgroundColor="@color/background_light"
card_view:cardCornerRadius="5dp" app:cardCornerRadius="5dp"
card_view:cardElevation="2dp" app:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false" app:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> app:cardUseCompatPadding="true">
<LinearLayout <LinearLayout
android:id="@+id/card_child_linear" android:id="@+id/card_child_linear"
@ -63,11 +63,24 @@
</FrameLayout> </FrameLayout>
<TextView <TextView
android:id="@+id/username" android:id="@+id/online_status_dot"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginEnd="4dp"
android:layout_toEndOf="@+id/thumbnail_holder" android:layout_toEndOf="@+id/thumbnail_holder"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="@string/online_status_dot"
android:textColor="@color/online_green"
android:visibility="gone" />
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/online_status_dot"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:text="@string/post_author" android:text="@string/post_author"

1
app/src/main/res/values/colors.xml

@ -21,6 +21,7 @@
<color name="link_color">#FF9800</color> <color name="link_color">#FF9800</color>
<color name="mention_color">#FAA61A</color> <color name="mention_color">#FAA61A</color>
<color name="error_red">#890d0d</color> <color name="error_red">#890d0d</color>
<color name="online_green">#4CAF50</color>
<color name="white">#FFFFFF</color> <color name="white">#FFFFFF</color>
<color name="iron">#CCCCCC</color> <color name="iron">#CCCCCC</color>

7
app/src/main/res/values/strings.xml

@ -73,13 +73,14 @@
<string name="unauthorized_topic_error">This topic is either missing or off limits to you</string> <string name="unauthorized_topic_error">This topic is either missing or off limits to you</string>
<string name="remove_vote_button">Remove vote</string> <string name="remove_vote_button">Remove vote</string>
<string name="show_vote_results_button">show results</string> <string name="show_vote_results_button">show results</string>
<string name="show_vote_options_button">hide results</string>
<string name="pref_topic_drafts_key">preference-topic-drafts-key</string>
<string name="reply_button">Reply</string>
<string name="online_status_dot"></string>
<plurals name="error_too_many_checked"> <plurals name="error_too_many_checked">
<item quantity="one">You may only select %d option</item> <item quantity="one">You may only select %d option</item>
<item quantity="other">You may only select %d options</item> <item quantity="other">You may only select %d options</item>
</plurals> </plurals>
<string name="show_vote_options_button">hide results</string>
<string name="pref_topic_drafts_key">preference-topic-drafts-key</string>
<string name="reply_button">Reply</string>
<!--Profile Activity--> <!--Profile Activity-->
<string name="username">Username</string> <string name="username">Username</string>

Loading…
Cancel
Save