diff --git a/README.md b/README.md index 96b10849..598072af 100644 --- a/README.md +++ b/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) diff --git a/app/build.gradle b/app/build.gradle index 10c07e6e..0c95158c 100644 --- a/app/build.gradle +++ b/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() + "\"" diff --git a/app/src/main/assets/style.css b/app/src/main/assets/style.css index 501e1320..27c7f39f 100644 --- a/app/src/main/assets/style.css +++ b/app/src/main/assets/style.css @@ -107,6 +107,7 @@ body { background: #3C3F41; margin: 0; padding: 0; + word-wrap: break-word; } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java index e42e4095..b052dc32 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java @@ -61,22 +61,24 @@ class LatestPostsAdapter extends RecyclerView.Adapter { @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 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 9d0d4556..0f0b544c 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 @@ -693,13 +693,13 @@ class TopicAdapter extends RecyclerView.Adapter { } 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 { 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 { } } - 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 { @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 diff --git a/app/src/main/java/gr/thmmy/mthmmy/views/CustomRecyclerView.java b/app/src/main/java/gr/thmmy/mthmmy/views/CustomRecyclerView.java index 1b605cdd..964eaa81 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/views/CustomRecyclerView.java +++ b/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); } - } diff --git a/app/src/main/java/gr/thmmy/mthmmy/views/ScrollAwareRecyclerView.java b/app/src/main/java/gr/thmmy/mthmmy/views/ScrollAwareRecyclerView.java new file mode 100644 index 00000000..ee11a673 --- /dev/null +++ b/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; + } + +} diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index 6d27a5a9..01d3fb6d 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/app/src/main/res/layout-v21/activity_topic_post_row.xml @@ -223,7 +223,8 @@ + android:layout_marginBottom="16dp" + android:descendantFocusability="blocksDescendants"> diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index 24793374..69fb3954 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -37,7 +37,7 @@ - + android:layout_marginBottom="16dp" + android:descendantFocusability="blocksDescendants"> diff --git a/app/src/main/res/layout/fragment_profile_latest_posts_row.xml b/app/src/main/res/layout/fragment_profile_latest_posts_row.xml index bf992123..6c1a8d25 100644 --- a/app/src/main/res/layout/fragment_profile_latest_posts_row.xml +++ b/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"> + card_view:cardUseCompatPadding="true" + android:descendantFocusability="blocksDescendants">