Browse Source

Version 1.8.5

master v1.8.5
Ezerous 4 years ago
parent
commit
eabbb28eb7
  1. 4
      README.md
  2. 4
      app/build.gradle
  3. 1
      app/src/main/assets/style.css
  4. 32
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
  5. 22
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  6. 5
      app/src/main/java/gr/thmmy/mthmmy/views/CustomRecyclerView.java
  7. 48
      app/src/main/java/gr/thmmy/mthmmy/views/ScrollAwareRecyclerView.java
  8. 5
      app/src/main/res/layout-v21/activity_topic_post_row.xml
  9. 2
      app/src/main/res/layout/activity_topic.xml
  10. 5
      app/src/main/res/layout/activity_topic_post_row.xml
  11. 3
      app/src/main/res/layout/fragment_profile_latest_posts_row.xml
  12. 3
      app/src/main/res/layout/fragment_shoutbox_shout_row.xml

4
README.md

@ -1,8 +1,8 @@
# mTHMMY
[![GitHub release](https://img.shields.io/github/release/ThmmyNoLife/mTHMMY.svg)](https://github.com/ThmmyNoLife/mTHMMY/releases)
[![GitHub release](https://img.shields.io/github/release/ThmmyNoLife/mTHMMY.svg?color=orange)](https://github.com/ThmmyNoLife/mTHMMY/releases)
[![API](https://img.shields.io/badge/API-19%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=19)
[![Discord Channel](https://img.shields.io/badge/discord-public@mTHMMY-738bd7.svg?style=flat)][discord-server]
[![Discord Channel](https://img.shields.io/discord/252539000571559947?style=flat&color=738bd7&label=discord)][discord-server]
![Last Commit](https://img.shields.io/github/last-commit/ThmmyNoLife/mTHMMY/develop.svg?style=flat)
![mTHMMY logo](app/src/main/res/mipmap-xhdpi/ic_launcher_round.png)

4
app/build.gradle

@ -15,8 +15,8 @@ android {
applicationId "gr.thmmy.mthmmy"
minSdkVersion 19
targetSdkVersion 29
versionCode 27
versionName "1.8.4"
versionCode 28
versionName "1.8.5"
archivesBaseName = "mTHMMY-v$versionName"
buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\""
buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\""

1
app/src/main/assets/style.css

@ -107,6 +107,7 @@ body {
background: #3C3F41;
margin: 0;
padding: 0;
word-wrap: break-word;
}

32
app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java

@ -61,22 +61,24 @@ class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@SuppressLint("ClickableViewAccessibility")
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
PostSummary topic = parsedTopicSummaries.get(position);
final LatestPostViewHolder latestPostViewHolder = (LatestPostViewHolder) holder;
latestPostViewHolder.postTitle.setText(topic.getSubject());
latestPostViewHolder.postDate.setText(topic.getDateTime());
latestPostViewHolder.post.setBackgroundColor(Color.argb(1, 255, 255, 255));
latestPostViewHolder.post.loadDataWithBaseURL("file:///android_asset/"
, topic.getPost(), "text/html", "UTF-8", null);
if (holder instanceof LatestPostViewHolder){
PostSummary topic = parsedTopicSummaries.get(position);
final LatestPostViewHolder latestPostViewHolder = (LatestPostViewHolder) holder;
latestPostViewHolder.postTitle.setText(topic.getSubject());
latestPostViewHolder.postDate.setText(topic.getDateTime());
latestPostViewHolder.post.setBackgroundColor(Color.argb(1, 255, 255, 255));
latestPostViewHolder.post.loadDataWithBaseURL("file:///android_asset/"
, topic.getPost(), "text/html", "UTF-8", null);
latestPostViewHolder.latestPostsRow.setOnClickListener(v -> {
if (interactionListener != null) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that a post has been selected.
interactionListener.onLatestPostsFragmentInteraction(
parsedTopicSummaries.get(holder.getAdapterPosition()));
}
});
latestPostViewHolder.latestPostsRow.setOnClickListener(v -> {
if (interactionListener != null) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that a post has been selected.
interactionListener.onLatestPostsFragmentInteraction(
parsedTopicSummaries.get(holder.getAdapterPosition()));
}
});
}
}
@Override

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

@ -693,13 +693,13 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}
holder.replyEditor.setText(replyText);
holder.replyEditor.getEditText().setSelection(holder.replyEditor.getText().length());
holder.replyEditor.getEditText().addTextChangedListener(createTextWatcher(holder));
holder.replyEditor.getEditText().addTextChangedListener(createTextWatcher(holder, TextWatcherType.CONTENT));
if (backPressHidden) {
holder.replyEditor.requestEditTextFocus();
backPressHidden = false;
}
holder.quickReplySubject.addTextChangedListener(createTextWatcher(holder));
holder.quickReplySubject.addTextChangedListener(createTextWatcher(holder, TextWatcherType.SUBJECT));
} else if (currentHolder instanceof EditMessageViewHolder) {
final EditMessageViewHolder holder = (EditMessageViewHolder) currentHolder;
@ -735,8 +735,8 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
viewModel.editPost(position, holder.editSubject.getText().toString(), holder.editEditor.getText().toString());
});
holder.editSubject.addTextChangedListener(createTextWatcher(holder));
holder.editEditor.getEditText().addTextChangedListener(createTextWatcher(holder));
holder.editSubject.addTextChangedListener(createTextWatcher(holder, TextWatcherType.SUBJECT));
holder.editEditor.getEditText().addTextChangedListener(createTextWatcher(holder, TextWatcherType.CONTENT));
if (backPressHidden) {
holder.editEditor.requestEditTextFocus();
@ -746,7 +746,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}
}
private TextWatcher createTextWatcher(@NonNull final RecyclerView.ViewHolder holder){
private enum TextWatcherType {
CONTENT, SUBJECT
}
private TextWatcher createTextWatcher(@NonNull final RecyclerView.ViewHolder holder, TextWatcherType type){
return new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { }
@ -754,8 +757,13 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
int position = holder.getAdapterPosition();
if (position >= 0 && position < topicItems.size())
((Post) topicItems.get(position)).setBbContent(charSequence.toString());
if (position >= 0 && position < topicItems.size()){
Post post = ((Post) topicItems.get(position));
if(type == TextWatcherType.CONTENT)
post.setBbContent(charSequence.toString());
else if(type == TextWatcherType.SUBJECT)
post.setSubject(charSequence.toString());
}
}
@Override

5
app/src/main/java/gr/thmmy/mthmmy/views/CustomRecyclerView.java

@ -5,10 +5,9 @@ import android.util.AttributeSet;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
//Custom RecyclerView, so EdgeEffect and SwipeRefresh both work
public class CustomRecyclerView extends RecyclerView {
public class CustomRecyclerView extends ScrollAwareRecyclerView {
private volatile boolean enableRefreshing = true;
public CustomRecyclerView(Context context) {
@ -40,7 +39,6 @@ public class CustomRecyclerView extends RecyclerView {
else if (((LinearLayoutManager) getLayoutManager()).findFirstCompletelyVisibleItemPosition() != 0)
enableRefreshing = false;
super.onScrollStateChanged(state);
}
@ -51,5 +49,4 @@ public class CustomRecyclerView extends RecyclerView {
else
return super.dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, 0, offsetInWindow);
}
}

48
app/src/main/java/gr/thmmy/mthmmy/views/ScrollAwareRecyclerView.java

@ -0,0 +1,48 @@
package gr.thmmy.mthmmy.views;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.recyclerview.widget.RecyclerView;
// Based on https://stackoverflow.com/a/46453825
// Not needed in LatestPostsFragment as there are no other ScrollAware Behaviors to steal touch events
public class ScrollAwareRecyclerView extends RecyclerView {
public ScrollAwareRecyclerView(Context context) {
super(context);
}
public ScrollAwareRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollAwareRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
final int scrollState = getScrollState();
boolean requestCancelDisallowInterceptTouchEvent
= ((scrollState == SCROLL_STATE_SETTLING) || (scrollState == SCROLL_STATE_IDLE));
boolean consumed = super.onInterceptTouchEvent(event);
final int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
if (requestCancelDisallowInterceptTouchEvent) {
getParent().requestDisallowInterceptTouchEvent(false);
// only if it touched the top or the bottom
if (!canScrollVertically(-1) || !canScrollVertically(1)) {
// stop scroll to enable child view to get the touch event
stopScroll();
// do not consume the event
return false;
}
}
}
return consumed;
}
}

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

@ -223,7 +223,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp">
android:layout_marginBottom="16dp"
android:descendantFocusability="blocksDescendants">
<gr.thmmy.mthmmy.views.ReactiveWebView
android:id="@+id/post"
@ -233,8 +234,6 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@color/background_light"
android:clickable="true"
android:focusable="true"
android:text="@string/post" />
</FrameLayout>

2
app/src/main/res/layout/activity_topic.xml

@ -37,7 +37,7 @@
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
<gr.thmmy.mthmmy.views.ScrollAwareRecyclerView
android:id="@+id/topic_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

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

@ -223,7 +223,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp">
android:layout_marginBottom="16dp"
android:descendantFocusability="blocksDescendants">
<gr.thmmy.mthmmy.views.ReactiveWebView
android:id="@+id/post"
@ -233,8 +234,6 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@color/background_light"
android:clickable="true"
android:focusable="true"
android:text="@string/post" />
</FrameLayout>

3
app/src/main/res/layout/fragment_profile_latest_posts_row.xml

@ -68,7 +68,8 @@
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="6dp"
android:paddingBottom="8dp">
android:paddingBottom="8dp"
android:descendantFocusability="blocksDescendants">
<gr.thmmy.mthmmy.views.ReactiveWebView
android:id="@+id/post"

3
app/src/main/res/layout/fragment_shoutbox_shout_row.xml

@ -12,7 +12,8 @@
card_view:cardCornerRadius="5dp"
card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true">
card_view:cardUseCompatPadding="true"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:layout_width="match_parent"

Loading…
Cancel
Save