Browse Source

Minor improvements

Added Share button on every post
Added "sent from mTHMMY" when posting
Github migration changes
Changed Login/Logout messages
Up Gradle
pull/24/head
Ezerous 7 years ago
parent
commit
9db1630b50
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  2. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  3. 22
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  4. 19
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
  5. 1
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  6. 22
      app/src/main/java/gr/thmmy/mthmmy/model/Post.java
  7. 17
      app/src/main/res/layout-v21/activity_topic_post_row.xml
  8. 17
      app/src/main/res/layout/activity_topic_post_row.xml
  9. 2
      app/src/main/res/values-w820dp/dimens.xml
  10. 2
      app/src/main/res/values/dimens.xml
  11. 3
      app/src/main/res/values/strings.xml
  12. 2
      build.gradle

2
app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java

@ -157,7 +157,7 @@ public class LoginActivity extends BaseActivity {
switch (result) { switch (result) {
case SUCCESS: //Successful login case SUCCESS: //Successful login
Toast.makeText(getApplicationContext(), Toast.makeText(getApplicationContext(),
"Login successful!", Toast.LENGTH_LONG) "Welcome, " + sessionManager.getUsername() + "!", Toast.LENGTH_LONG)
.show(); .show();
//Go to main //Go to main
Intent intent = new Intent(LoginActivity.this, MainActivity.class); Intent intent = new Intent(LoginActivity.this, MainActivity.class);

4
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -855,16 +855,16 @@ public class TopicActivity extends BaseActivity {
@Override @Override
protected Boolean doInBackground(String... args) { protected Boolean doInBackground(String... args) {
final String sentFrommTHMMY = "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY[/url][/i][/size][/right]";
RequestBody postBody = new MultipartBody.Builder() RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM) .setType(MultipartBody.FORM)
.addFormDataPart("message", args[1]) .addFormDataPart("message", args[1] + sentFrommTHMMY)
.addFormDataPart("num_replies", args[2]) .addFormDataPart("num_replies", args[2])
.addFormDataPart("seqnum", args[3]) .addFormDataPart("seqnum", args[3])
.addFormDataPart("sc", args[4]) .addFormDataPart("sc", args[4])
.addFormDataPart("subject", args[0]) .addFormDataPart("subject", args[0])
.addFormDataPart("topic", args[5]) .addFormDataPart("topic", args[5])
.build(); .build();
Request post = new Request.Builder() Request post = new Request.Builder()
.url("https://www.thmmy.gr/smf/index.php?action=post2") .url("https://www.thmmy.gr/smf/index.php?action=post2")
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")

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

@ -192,7 +192,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//noinspection ConstantConditions //noinspection ConstantConditions
Picasso.with(context) Picasso.with(context)
.load(currentPost.getThumbnailUrl()) .load(currentPost.getThumbnailURL())
.resize(THUMBNAIL_SIZE, THUMBNAIL_SIZE) .resize(THUMBNAIL_SIZE, THUMBNAIL_SIZE)
.centerCrop() .centerCrop()
.error(ResourcesCompat.getDrawable(context.getResources() .error(ResourcesCompat.getDrawable(context.getResources()
@ -369,10 +369,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Intent intent = new Intent(context, ProfileActivity.class); Intent intent = new Intent(context, ProfileActivity.class);
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString(BUNDLE_PROFILE_URL, currentPost.getProfileURL()); extras.putString(BUNDLE_PROFILE_URL, currentPost.getProfileURL());
if (currentPost.getThumbnailUrl() == null) if (currentPost.getThumbnailURL() == null)
extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, ""); extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, "");
else else
extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, currentPost.getThumbnailUrl()); extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, currentPost.getThumbnailURL());
extras.putString(BUNDLE_PROFILE_USERNAME, currentPost.getAuthor()); extras.putString(BUNDLE_PROFILE_USERNAME, currentPost.getAuthor());
intent.putExtras(extras); intent.putExtras(extras);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK); intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
@ -409,6 +409,16 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.userExtraInfo.setOnClickListener(null); holder.userExtraInfo.setOnClickListener(null);
} }
holder.sharePostButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, currentPost.getPostURL());
context.startActivity(Intent.createChooser(sendIntent, "Share via"));
}
});
//noinspection PointlessBooleanExpression,ConstantConditions //noinspection PointlessBooleanExpression,ConstantConditions
if (!BaseActivity.getSessionManager().isLoggedIn() || !canReply) { if (!BaseActivity.getSessionManager().isLoggedIn() || !canReply) {
holder.quoteToggle.setVisibility(View.GONE); holder.quoteToggle.setVisibility(View.GONE);
@ -426,8 +436,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (toQuoteList.contains(postsList.indexOf(currentPost))) { if (toQuoteList.contains(postsList.indexOf(currentPost))) {
toQuoteList.remove(toQuoteList.indexOf(postsList.indexOf(currentPost))); toQuoteList.remove(toQuoteList.indexOf(postsList.indexOf(currentPost)));
} else } else
Timber.i("An error occurred while trying to exclude post from" + Timber.i("An error occurred while trying to exclude post fromtoQuoteList, post wasn't there!");
"toQuoteList, post wasn't there!");
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked);
} else { } else {
toQuoteList.add(postsList.indexOf(currentPost)); toQuoteList.add(postsList.indexOf(currentPost));
@ -505,7 +514,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final TextView postDate, postNum, username, subject; final TextView postDate, postNum, username, subject;
final ImageView thumbnail; final ImageView thumbnail;
final public WebView post; final public WebView post;
final ImageButton quoteToggle; final ImageButton quoteToggle, sharePostButton;
final RelativeLayout header; final RelativeLayout header;
final LinearLayout userExtraInfo; final LinearLayout userExtraInfo;
final View bodyFooterDivider; final View bodyFooterDivider;
@ -526,6 +535,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
post = view.findViewById(R.id.post); post = view.findViewById(R.id.post);
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);
sharePostButton = view.findViewById(R.id.post_share_button);
bodyFooterDivider = view.findViewById(R.id.body_footer_divider); bodyFooterDivider = view.findViewById(R.id.body_footer_divider);
postFooter = view.findViewById(R.id.post_footer); postFooter = view.findViewById(R.id.post_footer);

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

@ -155,8 +155,8 @@ class TopicParser {
for (Element thisRow : postRows) { for (Element thisRow : postRows) {
//Variables for Post constructor //Variables for Post constructor
String p_userName, p_thumbnailUrl, p_subject, p_post, p_postDate, p_profileURL, p_rank, String p_userName, p_thumbnailURL, p_subject, p_post, p_postDate, p_profileURL, p_rank,
p_specialRank, p_gender, p_personalText, p_numberOfPosts, p_postLastEditDate; p_specialRank, p_gender, p_personalText, p_numberOfPosts, p_postLastEditDate, p_postURL;
int p_postNum, p_postIndex, p_numberOfStars, p_userColor; int p_postNum, p_postIndex, p_numberOfStars, p_userColor;
boolean p_isDeleted = false; boolean p_isDeleted = false;
ArrayList<ThmmyFile> p_attachedFiles; ArrayList<ThmmyFile> p_attachedFiles;
@ -176,14 +176,17 @@ class TopicParser {
//Language independent parsing //Language independent parsing
//Finds thumbnail url //Finds thumbnail url
Element thumbnailUrl = thisRow.select("img.avatar").first(); Element thumbnailUrl = thisRow.select("img.avatar").first();
p_thumbnailUrl = null; //In case user doesn't have an avatar p_thumbnailURL = null; //In case user doesn't have an avatar
if (thumbnailUrl != null) { if (thumbnailUrl != null) {
p_thumbnailUrl = thumbnailUrl.attr("abs:src"); p_thumbnailURL = thumbnailUrl.attr("abs:src");
} }
//Finds subject //Finds subject
p_subject = thisRow.select("div[id^=subject_]").first().select("a").first().text(); p_subject = thisRow.select("div[id^=subject_]").first().select("a").first().text();
//Finds post's link
p_postURL = thisRow.select("div[id^=subject_]").first().select("a").first() .attr("href");
//Finds post's text //Finds post's text
p_post = ParseHelpers.youtubeEmbeddedFix(thisRow.select("div").select(".post").first()); p_post = ParseHelpers.youtubeEmbeddedFix(thisRow.select("div").select(".post").first());
@ -410,15 +413,15 @@ class TopicParser {
} }
} }
//Add new post in postsList, extended information needed //Add new post in postsList, extended information needed
parsedPostsList.add(new Post(p_thumbnailUrl, p_userName, p_subject, p_post, p_postIndex parsedPostsList.add(new Post(p_thumbnailURL, p_userName, p_subject, p_post, p_postIndex
, 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_attachedFiles, p_postLastEditDate, p_postURL));
} else { //Deleted user } else { //Deleted user
//Add new post in postsList, only standard information needed //Add new post in postsList, only standard information needed
parsedPostsList.add(new Post(p_thumbnailUrl, p_userName, p_subject, p_post, p_postIndex parsedPostsList.add(new Post(p_thumbnailURL, p_userName, p_subject, p_post, p_postIndex
, p_postNum, p_postDate, p_userColor, p_attachedFiles, p_postLastEditDate)); , p_postNum, p_postDate, p_userColor, p_attachedFiles, p_postLastEditDate, p_postURL));
} }
} }
return parsedPostsList; return parsedPostsList;

1
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -406,7 +406,6 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
protected void onPostExecute(Integer result) { protected void onPostExecute(Integer result) {
Toast.makeText(getBaseContext(), "Logged out successfully!", Toast.LENGTH_LONG).show();
updateDrawer(); updateDrawer();
if (mainActivity != null) if (mainActivity != null)
mainActivity.updateTabs(); mainActivity.updateTabs();

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

@ -28,6 +28,7 @@ public class Post {
private final int userColor; private final int userColor;
private final ArrayList<ThmmyFile> attachedFiles; private final ArrayList<ThmmyFile> attachedFiles;
private final String lastEdit; private final String lastEdit;
private final String postURL;
//Extra info //Extra info
private final String profileURL; private final String profileURL;
@ -59,6 +60,7 @@ public class Post {
numberOfStars = 0; numberOfStars = 0;
attachedFiles = null; attachedFiles = null;
lastEdit = null; lastEdit = null;
postURL = null;
} }
/** /**
@ -83,12 +85,13 @@ public class Post {
* @param userColor author's user color * @param userColor author's user color
* @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
*/ */
public Post(@Nullable String thumbnailUrl, String author, String subject, String content public Post(@Nullable String thumbnailUrl, String author, String subject, String content
, int postIndex, int postNumber, String postDate, String profileURl, @Nullable String rank , 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) { , @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL) {
if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null; if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null;
else this.thumbnailUrl = thumbnailUrl; else this.thumbnailUrl = thumbnailUrl;
this.author = author; this.author = author;
@ -108,6 +111,7 @@ public class Post {
this.numberOfPosts = numberOfPosts; this.numberOfPosts = numberOfPosts;
this.personalText = personalText; this.personalText = personalText;
this.numberOfStars = numberOfStars; this.numberOfStars = numberOfStars;
this.postURL = postURL;
} }
/** /**
@ -125,10 +129,11 @@ public class Post {
* @param userColor author's user color * @param userColor author's user color
* @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
*/ */
public Post(@Nullable String thumbnailUrl, String author, String subject, String content public Post(@Nullable String thumbnailUrl, String author, String subject, String content
, int postIndex, int postNumber, String postDate, int userColor , int postIndex, int postNumber, String postDate, int userColor
, @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit) { , @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL) {
if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null; if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null;
else this.thumbnailUrl = thumbnailUrl; else this.thumbnailUrl = thumbnailUrl;
this.author = author; this.author = author;
@ -148,6 +153,7 @@ public class Post {
numberOfPosts = "Posts: 0"; numberOfPosts = "Posts: 0";
personalText = ""; personalText = "";
numberOfStars = 0; numberOfStars = 0;
this.postURL = postURL;
} }
//Getters //Getters
@ -158,7 +164,7 @@ public class Post {
* @return author's thumbnail url * @return author's thumbnail url
*/ */
@Nullable @Nullable
public String getThumbnailUrl() { public String getThumbnailURL() {
return thumbnailUrl; return thumbnailUrl;
} }
@ -326,4 +332,14 @@ public class Post {
public String getLastEdit() { public String getLastEdit() {
return lastEdit; return lastEdit;
} }
/**
* Gets this post's url.
*
* @return post's url
*/
@Nullable
public String getPostURL() {
return postURL;
}
} }

17
app/src/main/res/layout-v21/activity_topic_post_row.xml

@ -85,18 +85,27 @@
android:maxLines="1" android:maxLines="1"
android:text="@string/post_subject" /> android:text="@string/post_subject" />
</RelativeLayout> </RelativeLayout>
<ImageButton <ImageButton
android:id="@+id/toggle_quote_button" android:id="@+id/toggle_quote_button"
android:layout_width="@dimen/quote_button" android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/quote_button" android:layout_height="@dimen/post_image_button"
android:layout_marginEnd="9dp"
android:layout_marginTop="9dp" android:layout_marginTop="9dp"
android:background="@color/card_background" android:background="@color/card_background"
android:clickable="true" android:clickable="true"
android:contentDescription="@string/post_quote_button" android:contentDescription="@string/post_quote_button"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_format_quote_unchecked" /> android:src="@drawable/ic_format_quote_unchecked" />
<ImageButton
android:id="@+id/post_share_button"
android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/post_image_button"
android:layout_marginEnd="9dp"
android:layout_marginTop="9dp"
android:background="@color/card_background"
android:clickable="true"
android:contentDescription="@string/post_share_button"
android:focusable="true"
android:src="@drawable/ic_share" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

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

@ -84,18 +84,27 @@
android:maxLines="1" android:maxLines="1"
android:text="@string/post_subject" /> android:text="@string/post_subject" />
</RelativeLayout> </RelativeLayout>
<ImageButton <ImageButton
android:id="@+id/toggle_quote_button" android:id="@+id/toggle_quote_button"
android:layout_width="@dimen/quote_button" android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/quote_button" android:layout_height="@dimen/post_image_button"
android:layout_marginEnd="9dp"
android:layout_marginTop="9dp" android:layout_marginTop="9dp"
android:background="@color/card_background" android:background="@color/card_background"
android:clickable="true" android:clickable="true"
android:contentDescription="@string/post_quote_button" android:contentDescription="@string/post_quote_button"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_format_quote_unchecked" /> android:src="@drawable/ic_format_quote_unchecked" />
<ImageButton
android:id="@+id/post_share_button"
android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/post_image_button"
android:layout_marginEnd="9dp"
android:layout_marginTop="9dp"
android:background="@color/card_background"
android:clickable="true"
android:contentDescription="@string/post_share_button"
android:focusable="true"
android:src="@drawable/ic_share" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

2
app/src/main/res/values-w820dp/dimens.xml

@ -6,7 +6,7 @@
<dimen name="activity_vertical_margin">64dp</dimen> <dimen name="activity_vertical_margin">64dp</dimen>
<dimen name="appbar_padding_top">32dp</dimen> <dimen name="appbar_padding_top">32dp</dimen>
<dimen name="thumbnail_size">176dp</dimen> <dimen name="thumbnail_size">176dp</dimen>
<dimen name="quote_button">144dp</dimen> <dimen name="post_image_button">144dp</dimen>
<dimen name="fab_margins">64dp</dimen> <dimen name="fab_margins">64dp</dimen>
<dimen name="progress_bar_height">40dp</dimen> <dimen name="progress_bar_height">40dp</dimen>
<dimen name="big_text">24sp</dimen> <dimen name="big_text">24sp</dimen>

2
app/src/main/res/values/dimens.xml

@ -4,7 +4,7 @@
<dimen name="activity_vertical_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="appbar_padding_top">8dp</dimen> <dimen name="appbar_padding_top">8dp</dimen>
<dimen name="thumbnail_size">44dp</dimen> <dimen name="thumbnail_size">44dp</dimen>
<dimen name="quote_button">36dp</dimen> <dimen name="post_image_button">36dp</dimen>
<dimen name="fab_margins">16dp</dimen> <dimen name="fab_margins">16dp</dimen>
<dimen name="progress_bar_height">10dp</dimen> <dimen name="progress_bar_height">10dp</dimen>
<dimen name="big_text">24sp</dimen> <dimen name="big_text">24sp</dimen>

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

@ -37,6 +37,7 @@
<string name="post">Post</string> <string name="post">Post</string>
<string name="post_thumbnail">Thumbnail</string> <string name="post_thumbnail">Thumbnail</string>
<string name="post_quote_button">Quote button</string> <string name="post_quote_button">Quote button</string>
<string name="post_share_button">Share button</string>
<string name="user_number_of_posts">#%1$d</string> <string name="user_number_of_posts">#%1$d</string>
<string name="button_first">first</string> <string name="button_first">first</string>
<string name="button_previous">previous</string> <string name="button_previous">previous</string>
@ -66,7 +67,7 @@
<string name="contact">Contact</string> <string name="contact">Contact</string>
<string name="contact_text">Do not hesitate to contact us for any matter either by email at thmmynolife@gmail.com, or by joining our discord server at https://discord.gg/CVt3yrn.</string> <string name="contact_text">Do not hesitate to contact us for any matter either by email at thmmynolife@gmail.com, or by joining our discord server at https://discord.gg/CVt3yrn.</string>
<string name="open_source">Open Source</string> <string name="open_source">Open Source</string>
<string name="open_source_text">The source code of mTHMMY can be found on GitLab (https://gitlab.com/ThmmyNoLife/mTHMMY) along with further details of how one can contribute.</string> <string name="open_source_text">The source code of mTHMMY can be found on Github (https://github.com/ThmmyNoLife/mTHMMY) along with further details of how one can contribute.</string>
<string name="trollPic">You should see a funny pic!</string> <string name="trollPic">You should see a funny pic!</string>
<!--Bookmarks--> <!--Bookmarks-->

2
build.gradle

@ -8,7 +8,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.0' classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.1.1' classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

Loading…
Cancel
Save