7 Commits

Author SHA1 Message Date
Bazsalanszky
55bbef25c6 Switch pipeline to java 17 2024-08-29 14:20:42 +02:00
Bazsalanszky
32c75ff87c Fix crash when switching to some sort types on the community search page
Closes #283
2024-08-29 14:12:15 +02:00
Bazsalanszky
468bae4019 Fix crash on video autoplay
This commit fixes the issue where the app crashes if autoplay is enabled and the user clicks on a post with a video.

Closes #281
2024-08-29 13:51:30 +02:00
Bazsalanszky
e8b199a74a Fix crash on theme editing
This commit resolves the issue where saving or previewing a theme crashed the app.

Closes #282
2024-08-29 10:52:20 +02:00
Bazsalanszky
0c8e3e3ea5 Fix comment rendering
There were some issues rendering markdown in comments. Now its fixed.
2024-08-12 13:16:18 +02:00
Bazsalanszky
767e75b798 Better markdown handling
This commit fixes some of the issues with markdown rendering:
- Switch to Textview instead of RecyclerView to render Markdown
- Import Spoiler renderer from Jebora
- Import Script renderer from Jebora
- Clean out markwon plugins that were specific to reddit

Closes #130 #172 #217 and #273
2024-08-09 12:45:15 +02:00
Bazsalanszky
c1c8d99de2 Fix issue where preferences used the Display name instead of the full account name
Closes #275
2024-08-09 10:37:23 +02:00
21 changed files with 344 additions and 239 deletions

View File

@@ -6,12 +6,12 @@ clone:
steps:
build:
image: alvrme/alpine-android:android-34-jdk11
image: alvrme/alpine-android:android-34-jdk17
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleNightly
sign:
image: alvrme/alpine-android:android-34-jdk11
image: alvrme/alpine-android:android-34-jdk17
commands:
- ./scripts/apk-sign.sh eu.toldi.infinityforlemmy.nightly.apk app/build/outputs/apk/nightly/eu.toldi.infinityforlemmy.nightly.apk
secrets: [ APK_KS_PASS, APK_KS, APK_KS_ALIAS ]

View File

@@ -245,6 +245,7 @@ dependencies {
implementation "io.noties.markwon:simple-ext:$markwonVersion"
implementation "io.noties.markwon:inline-parser:$markwonVersion"
implementation "io.noties.markwon:image-glide:$markwonVersion"
implementation "io.noties.markwon:html:$markwonVersion"
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
implementation 'me.saket:better-link-movement-method:2.2.0'

View File

@@ -865,12 +865,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
} else if (stringId == R.string.enable_nsfw) {
if (sectionsPagerAdapter != null) {
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
sectionsPagerAdapter.changeNSFW(true);
}
} else if (stringId == R.string.disable_nsfw) {
if (sectionsPagerAdapter != null) {
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
sectionsPagerAdapter.changeNSFW(false);
}
} else if (stringId == R.string.settings) {
@@ -928,17 +928,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
navDrawerRecyclerView.setAdapter(adapter.getConcatAdapter());
int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
viewPager2.setAdapter(sectionsPagerAdapter);
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
} else {
@@ -947,13 +947,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) {
case 0:
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
break;
case 1:
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
break;
case 2:
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
break;
}
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
@@ -1001,7 +1001,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadSubscriptions();
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
mRedditDataRoomDatabase, mAccountQualifiedName == null ? "-" : mAccountQualifiedName))
.get(MultiRedditViewModel.class);
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
@@ -1594,7 +1594,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return false;
});
boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1706,7 +1706,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private void randomThing() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -1767,8 +1767,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public Fragment createFragment(int position) {
if (position == 0) {
int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
String name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
int postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
String name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
return generatePostFragment(postType, name);
} else {
if (showFavoriteMultiReddits) {
@@ -1810,11 +1810,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int postType;
String name;
if (position == 1) {
postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
} else {
postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
}
return generatePostFragment(postType, name);
}

View File

@@ -203,10 +203,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
} else {
((CommentBaseViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
}
((CommentViewHolder) holder).markwonAdapter.setMarkdown(mMarkwon, comment.getCommentMarkdown());
// noinspection NotifyDataSetChanged
((CommentBaseViewHolder) holder).markwonAdapter.notifyDataSetChanged();
mMarkwon.setMarkdown(((CommentBaseViewHolder) holder).commentMarkdownView, comment.getCommentMarkdown());
String commentText = Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType());
@@ -254,8 +251,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (holder instanceof CommentBaseViewHolder) {
((CommentBaseViewHolder) holder).authorFlairTextView.setText("");
((CommentBaseViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).awardsTextView.setText("");
((CommentBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
@@ -327,8 +322,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
TextView authorTextView;
TextView authorFlairTextView;
TextView commentTimeTextView;
TextView awardsTextView;
RecyclerView commentMarkdownView;
TextView commentMarkdownView;
ConstraintLayout bottomConstraintLayout;
MaterialButton upvoteButton;
TextView scoreTextView;
@@ -338,7 +332,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
MaterialButton saveButton;
MaterialButton replyButton;
View commentDivider;
CustomMarkwonAdapter markwonAdapter;
CommentBaseViewHolder(@NonNull View itemView) {
super(itemView);
@@ -348,8 +341,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
TextView authorTextView,
TextView authorFlairTextView,
TextView commentTimeTextView,
TextView awardsTextView,
RecyclerView commentMarkdownView,
TextView commentMarkdownView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
TextView scoreTextView,
@@ -365,7 +357,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
this.authorTextView = authorTextView;
this.authorFlairTextView = authorFlairTextView;
this.commentTimeTextView = commentTimeTextView;
this.awardsTextView = awardsTextView;
this.commentMarkdownView = commentMarkdownView;
this.bottomConstraintLayout = bottomConstraintLayout;
this.upvoteButton = upvoteButton;
@@ -430,14 +421,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
authorTextView.setTypeface(mActivity.typeface);
authorFlairTextView.setTypeface(mActivity.typeface);
commentTimeTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
upvoteButton.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor);
authorTextView.setTextColor(mUsernameColor);
authorFlairTextView.setTextColor(mAuthorFlairColor);
commentTimeTextView.setTextColor(mSecondaryTextColor);
awardsTextView.setTextColor(mSecondaryTextColor);
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
scoreTextView.setTextColor(mCommentIconAndInfoColor);
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
@@ -495,7 +484,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
});
commentMarkdownView.setRecycledViewPool(recycledViewPool);
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
@@ -507,18 +496,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mActivity.unlockSwipeRightToGoBack();
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
markwonAdapter = MarkdownUtils.createCustomTablesAdapter();
markwonAdapter.setOnClickListener(view -> {
if (view instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) view).isSpoilerOnClick()) {
((SpoilerOnClickTextView) view).setSpoilerOnClick(false);
return;
}
}
itemView.callOnClick();
});
commentMarkdownView.setAdapter(markwonAdapter);
upvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
@@ -739,7 +717,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
binding.authorTextViewItemPostComment,
binding.authorFlairTextViewItemPostComment,
binding.commentTimeTextViewItemPostComment,
binding.awardsTextViewItemComment,
binding.commentMarkdownViewItemPostComment,
binding.bottomConstraintLayoutItemPostComment,
binding.upvoteButtonItemPostComment,

View File

@@ -465,10 +465,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
text = "*"+mActivity.getString(R.string.deleted_by_creator)+"*";
}
mCommentMarkwon.setMarkdown(((CommentBaseViewHolder) holder).commentMarkdownView,text);
((CommentBaseViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon,text);
// noinspection NotifyDataSetChanged
((CommentBaseViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
if (mHideDownvotes) {
((CommentBaseViewHolder) holder).downvoteButton.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
@@ -1180,8 +1178,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
mGlide.clear(((CommentBaseViewHolder) holder).authorIconImageView);
((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mSecondaryTextColor);
((CommentBaseViewHolder) holder).awardsTextView.setText("");
((CommentBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).expandButton.setVisibility(View.GONE);
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
@@ -1231,8 +1227,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
TextView authorFlairTextView;
TextView commentTimeTextView;
TextView topScoreTextView;
TextView awardsTextView;
RecyclerView commentMarkdownView;
TextView commentMarkdownView;
TextView editedTextView;
ConstraintLayout bottomConstraintLayout;
MaterialButton upvoteButton;
@@ -1246,7 +1241,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
MaterialButton replyButton;
CommentIndentationView commentIndentationView;
View commentDivider;
CustomMarkwonAdapter mMarkwonAdapter;
CommentBaseViewHolder(@NonNull View itemView) {
super(itemView);
@@ -1258,8 +1252,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
TextView authorFlairTextView,
TextView commentTimeTextView,
TextView topScoreTextView,
TextView awardsTextView,
RecyclerView commentMarkdownView,
TextView commentMarkdownView,
TextView editedTextView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
@@ -1279,7 +1272,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
this.authorFlairTextView = authorFlairTextView;
this.commentTimeTextView = commentTimeTextView;
this.topScoreTextView = topScoreTextView;
this.awardsTextView = awardsTextView;
this.commentMarkdownView = commentMarkdownView;
this.editedTextView = editedTextView;
this.bottomConstraintLayout = bottomConstraintLayout;
@@ -1357,7 +1349,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
authorFlairTextView.setTypeface(mActivity.typeface);
topScoreTextView.setTypeface(mActivity.typeface);
editedTextView.setTypeface(mActivity.typeface);
awardsTextView.setTypeface(mActivity.typeface);
scoreTextView.setTypeface(mActivity.typeface);
downvoteTextView.setTypeface(mActivity.typeface);
expandButton.setTypeface(mActivity.typeface);
@@ -1370,7 +1362,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((ConstraintLayout.LayoutParams) authorFlairTextView.getLayoutParams()).leftMargin = 0;
}
commentMarkdownView.setRecycledViewPool(recycledViewPool);
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
@@ -1382,9 +1374,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((ViewPostDetailActivity) mActivity).unlockSwipeRightToGoBack();
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
mMarkwonAdapter = MarkdownUtils.createCustomTablesAdapter();
commentMarkdownView.setAdapter(mMarkwonAdapter);
itemView.setBackgroundColor(mCommentBackgroundColor);
authorTextView.setTextColor(mUsernameColor);
@@ -1393,7 +1382,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
topScoreTextView.setTextColor(mSecondaryTextColor);
downvoteTextView.setTextColor(mSecondaryTextColor);
editedTextView.setTextColor(mSecondaryTextColor);
awardsTextView.setTextColor(mSecondaryTextColor);
commentDivider.setBackgroundColor(mDividerColor);
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
scoreTextView.setTextColor(mCommentIconAndInfoColor);
@@ -1814,41 +1802,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
View.OnLongClickListener hideToolbarOnLongClickListener = view -> hideToolbar();
itemView.setOnLongClickListener(hideToolbarOnLongClickListener);
commentTimeTextView.setOnLongClickListener(hideToolbarOnLongClickListener);
mMarkwonAdapter.setOnLongClickListener(v -> {
if (v instanceof TextView) {
if (((TextView) v).getSelectionStart() == -1 && ((TextView) v).getSelectionEnd() == -1) {
hideToolbar();
}
}
commentMarkdownView.setOnLongClickListener(v -> {
hideToolbar();
return true;
});
}
mMarkwonAdapter.setOnClickListener(v -> {
if (v instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) v).isSpoilerOnClick()) {
((SpoilerOnClickTextView) v).setSpoilerOnClick(false);
return;
}
}
expandComments();
});
itemView.setOnClickListener(view -> expandComments());
} else {
if (mCommentToolbarHideOnClick) {
mMarkwonAdapter.setOnClickListener(view -> {
if (view instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) view).isSpoilerOnClick()) {
((SpoilerOnClickTextView) view).setSpoilerOnClick(false);
return;
}
}
hideToolbar();
});
View.OnClickListener hideToolbarOnClickListener = view -> hideToolbar();
itemView.setOnClickListener(hideToolbarOnClickListener);
commentTimeTextView.setOnClickListener(hideToolbarOnClickListener);
}
mMarkwonAdapter.setOnLongClickListener(view -> {
commentMarkdownView.setOnLongClickListener(view -> {
if (view instanceof TextView) {
if (((TextView) view).getSelectionStart() == -1 && ((TextView) view).getSelectionEnd() == -1) {
expandComments();
@@ -1896,7 +1862,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
binding.authorFlairTextViewItemPostComment,
binding.commentTimeTextViewItemPostComment,
binding.topScoreTextViewItemPostComment,
binding.awardsTextViewItemComment,
binding.commentMarkdownViewItemPostComment,
binding.editedTextViewItemPostComment,
binding.bottomConstraintLayoutItemPostComment,

View File

@@ -681,10 +681,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.getSelfText() != null && !mPost.getSelfText().equals("")) {
((PostDetailBaseViewHolder) holder).contentMarkdownView.setVisibility(View.VISIBLE);
((PostDetailBaseViewHolder) holder).contentMarkdownView.setAdapter(mMarkwonAdapter);
mMarkwonAdapter.setMarkdown(mPostDetailMarkwon, mPost.getSelfText());
// noinspection NotifyDataSetChanged
mMarkwonAdapter.notifyDataSetChanged();
mPostDetailMarkwon.setMarkdown(((PostDetailBaseViewHolder) holder).contentMarkdownView,mPost.getSelfText());
}
if (holder instanceof PostDetailBaseVideoAutoplayViewHolder) {
@@ -1216,7 +1213,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
CustomTextView flairTextView;
TextView awardsTextView;
TextView upvoteRatioTextView;
RecyclerView contentMarkdownView;
TextView contentMarkdownView;
ConstraintLayout bottomConstraintLayout;
MaterialButton upvoteButton;
TextView scoreTextView;
@@ -1248,7 +1245,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
CustomTextView flairTextView,
TextView awardsTextView,
TextView upvoteRatioTextView,
RecyclerView contentMarkdownView,
TextView contentMarkdownView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
TextView scoreTextView,
@@ -1344,7 +1341,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mActivity.startActivity(intent);
});
contentMarkdownView.setLayoutManager(new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
/*contentMarkdownView.setLayoutManager(new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
((ViewPostDetailActivity) mActivity).lockSwipeRightToGoBack();
@@ -1354,7 +1351,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public void unlockSwipe() {
((ViewPostDetailActivity) mActivity).unlockSwipeRightToGoBack();
}
}));
}));*/
upvoteButton.setOnClickListener(view -> {
if (mPost.isArchived()) {
@@ -1805,7 +1802,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostDetailBaseVideoAutoplayViewHolder(@NonNull View itemView,
AspectRatioGifImageView iconGifImageView,
TextView subredditTextView,
TextView communityInstance,
TextView userTextView,
TextView userInstanceTextView,
TextView authorFlairTextView,
TextView postTimeTextView,
TextView titleTextView,
@@ -1827,10 +1826,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
ImageView pauseButton,
ImageView playButton,
DefaultTimeBar progressBar,
RecyclerView contentMarkdownView,
TextView contentMarkdownView,
ConstraintLayout bottomConstraintLayout,
MaterialButton upvoteButton,
TextView scoreTextView,
TextView downvoteTextView,
MaterialButton downvoteButton,
MaterialButton commentsCountButton,
MaterialButton saveButton,
@@ -1838,9 +1838,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
super(itemView);
setBaseView(iconGifImageView,
subredditTextView,
mCommunityInstanceTextView,
communityInstance,
userTextView,
mUserInstanceTextView,
userInstanceTextView,
authorFlairTextView,
postTimeTextView,
titleTextView,
@@ -1857,7 +1857,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
bottomConstraintLayout,
upvoteButton,
scoreTextView,
mDownvoteTextView,
downvoteTextView,
downvoteButton,
commentsCountButton,
saveButton,
@@ -2078,7 +2078,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
super(binding.getRoot(),
binding.iconGifImageViewItemPostDetailVideoAutoplay,
binding.subredditTextViewItemPostDetailVideoAutoplay,
binding.communityInstanceTextViewItemPostDetailVideoAutoplay,
binding.userTextViewItemPostDetailVideoAutoplay,
binding.userInstanceTextViewItemPostDetailVideoAutoplay,
binding.authorFlairTextViewItemPostDetailVideoAutoplay,
binding.postTimeTextViewItemPostDetailVideoAutoplay,
binding.titleTextViewItemPostDetailVideoAutoplay,
@@ -2104,6 +2106,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
binding.bottomConstraintLayoutItemPostDetailVideoAutoplay,
binding.upvoteButtonItemPostDetailVideoAutoplay,
binding.scoreTextViewItemPostDetailVideoAutoplay,
binding.downvoteTextViewItemPostDetailVideoAutoplay,
binding.downvoteButtonItemPostDetailVideoAutoplay,
binding.commentsCountButtonItemPostDetailVideoAutoplay,
binding.saveButtonItemPostDetailVideoAutoplay,
@@ -2116,7 +2119,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
super(binding.getRoot(),
binding.iconGifImageViewItemPostDetailVideoAutoplay,
binding.subredditTextViewItemPostDetailVideoAutoplay,
binding.communityInstanceTextViewItemPostDetailVideoAutoplay,
binding.userTextViewItemPostDetailVideoAutoplay,
binding.userInstanceTextViewItemPostDetailVideoAutoplay,
binding.authorFlairTextViewItemPostDetailVideoAutoplay,
binding.postTimeTextViewItemPostDetailVideoAutoplay,
binding.titleTextViewItemPostDetailVideoAutoplay,
@@ -2142,6 +2147,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
binding.bottomConstraintLayoutItemPostDetailVideoAutoplay,
binding.upvoteButtonItemPostDetailVideoAutoplay,
binding.scoreTextViewItemPostDetailVideoAutoplay,
binding.downvoteTextViewItemPostDetailVideoAutoplay,
binding.downvoteButtonItemPostDetailVideoAutoplay,
binding.commentsCountButtonItemPostDetailVideoAutoplay,
binding.saveButtonItemPostDetailVideoAutoplay,

View File

@@ -263,69 +263,64 @@ public class CustomTheme {
customTheme.readPostFilledCardViewBackgroundColor = customThemeSettingsItems.get(23).colorValue;
customTheme.commentBackgroundColor = customThemeSettingsItems.get(24).colorValue;
customTheme.fullyCollapsedCommentBackgroundColor = customThemeSettingsItems.get(25).colorValue;
customTheme.awardedCommentBackgroundColor = customThemeSettingsItems.get(26).colorValue;
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(27).colorValue;
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(28).colorValue;
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(29).colorValue;
customTheme.primaryIconColor = customThemeSettingsItems.get(30).colorValue;
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(31).colorValue;
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(32).colorValue;
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(33).colorValue;
customTheme.fabIconColor = customThemeSettingsItems.get(34).colorValue;
customTheme.sendMessageIconColor = customThemeSettingsItems.get(35).colorValue;
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(36).colorValue;
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(37).colorValue;
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(38).colorValue;
customTheme.mediaIndicatorIconColor = customThemeSettingsItems.get(39).colorValue;
customTheme.mediaIndicatorBackgroundColor = customThemeSettingsItems.get(40).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(41).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(42).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(43).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(44).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(45).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(46).colorValue;
customTheme.upvoted = customThemeSettingsItems.get(47).colorValue;
customTheme.downvoted = customThemeSettingsItems.get(48).colorValue;
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(49).colorValue;
customTheme.postTypeTextColor = customThemeSettingsItems.get(50).colorValue;
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(51).colorValue;
customTheme.spoilerTextColor = customThemeSettingsItems.get(52).colorValue;
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(53).colorValue;
customTheme.nsfwTextColor = customThemeSettingsItems.get(54).colorValue;
customTheme.flairBackgroundColor = customThemeSettingsItems.get(55).colorValue;
customTheme.flairTextColor = customThemeSettingsItems.get(56).colorValue;
customTheme.awardsBackgroundColor = customThemeSettingsItems.get(57).colorValue;
customTheme.awardsTextColor = customThemeSettingsItems.get(58).colorValue;
customTheme.archivedTint = customThemeSettingsItems.get(59).colorValue;
customTheme.lockedIconTint = customThemeSettingsItems.get(60).colorValue;
customTheme.crosspostIconTint = customThemeSettingsItems.get(61).colorValue;
customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(62).colorValue;
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(63).colorValue;
customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(64).colorValue;
customTheme.subscribed = customThemeSettingsItems.get(65).colorValue;
customTheme.unsubscribed = customThemeSettingsItems.get(66).colorValue;
customTheme.username = customThemeSettingsItems.get(67).colorValue;
customTheme.subreddit = customThemeSettingsItems.get(68).colorValue;
customTheme.authorFlairTextColor = customThemeSettingsItems.get(69).colorValue;
customTheme.submitter = customThemeSettingsItems.get(70).colorValue;
customTheme.moderator = customThemeSettingsItems.get(71).colorValue;
customTheme.currentUser = customThemeSettingsItems.get(72).colorValue;
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(73).colorValue;
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(74).colorValue;
customTheme.dividerColor = customThemeSettingsItems.get(75).colorValue;
customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(76).colorValue;
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(77).colorValue;
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(78).colorValue;
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(79).colorValue;
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(80).colorValue;
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(81).colorValue;
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(82).colorValue;
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(83).colorValue;
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(84).colorValue;
customTheme.navBarColor = customThemeSettingsItems.get(85).colorValue;
customTheme.isLightStatusBar = customThemeSettingsItems.get(86).isEnabled;
customTheme.isLightNavBar = customThemeSettingsItems.get(87).isEnabled;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(88).isEnabled;
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(26).colorValue;
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(27).colorValue;
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(28).colorValue;
customTheme.primaryIconColor = customThemeSettingsItems.get(29).colorValue;
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(30).colorValue;
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(31).colorValue;
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(32).colorValue;
customTheme.fabIconColor = customThemeSettingsItems.get(33).colorValue;
customTheme.sendMessageIconColor = customThemeSettingsItems.get(34).colorValue;
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(35).colorValue;
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(36).colorValue;
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(37).colorValue;
customTheme.mediaIndicatorIconColor = customThemeSettingsItems.get(38).colorValue;
customTheme.mediaIndicatorBackgroundColor = customThemeSettingsItems.get(39).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(40).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(41).colorValue;
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(42).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(43).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(44).colorValue;
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(45).colorValue;
customTheme.upvoted = customThemeSettingsItems.get(46).colorValue;
customTheme.downvoted = customThemeSettingsItems.get(47).colorValue;
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(48).colorValue;
customTheme.postTypeTextColor = customThemeSettingsItems.get(49).colorValue;
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(50).colorValue;
customTheme.spoilerTextColor = customThemeSettingsItems.get(51).colorValue;
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(52).colorValue;
customTheme.nsfwTextColor = customThemeSettingsItems.get(53).colorValue;
customTheme.archivedTint = customThemeSettingsItems.get(54).colorValue;
customTheme.lockedIconTint = customThemeSettingsItems.get(55).colorValue;
customTheme.crosspostIconTint = customThemeSettingsItems.get(56).colorValue;
customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(57).colorValue;
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(58).colorValue;
customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(59).colorValue;
customTheme.subscribed = customThemeSettingsItems.get(60).colorValue;
customTheme.unsubscribed = customThemeSettingsItems.get(61).colorValue;
customTheme.username = customThemeSettingsItems.get(62).colorValue;
customTheme.subreddit = customThemeSettingsItems.get(63).colorValue;
customTheme.submitter = customThemeSettingsItems.get(64).colorValue;
customTheme.moderator = customThemeSettingsItems.get(65).colorValue;
customTheme.currentUser = customThemeSettingsItems.get(66).colorValue;
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(67).colorValue;
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(68).colorValue;
customTheme.dividerColor = customThemeSettingsItems.get(69).colorValue;
customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(70).colorValue;
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(71).colorValue;
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(72).colorValue;
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(73).colorValue;
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(74).colorValue;
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(75).colorValue;
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(76).colorValue;
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(77).colorValue;
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(78).colorValue;
customTheme.navBarColor = customThemeSettingsItems.get(79).colorValue;
customTheme.isLightStatusBar = customThemeSettingsItems.get(80).isEnabled;
customTheme.isLightNavBar = customThemeSettingsItems.get(81).isEnabled;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(82).isEnabled;
return customTheme;
}

View File

@@ -831,7 +831,7 @@ public class CustomThemeWrapper {
customTheme.colorPrimary = Color.parseColor("#FFFFFF");
customTheme.colorPrimaryDark = Color.parseColor("#FFFFFF");
customTheme.colorAccent = Color.parseColor("#000000");
customTheme.colorPrimaryLightTheme = Color.parseColor("#FFFFFF");
customTheme.colorPrimaryLightTheme = Color.parseColor("#000000");
customTheme.primaryTextColor = Color.parseColor("#000000");
customTheme.secondaryTextColor = Color.parseColor("#8A000000");
customTheme.postTitleColor = Color.parseColor("#000000");
@@ -839,7 +839,7 @@ public class CustomThemeWrapper {
customTheme.readPostTitleColor = Color.parseColor("#9D9D9D");
customTheme.readPostContentColor = Color.parseColor("#9D9D9D");
customTheme.commentColor = Color.parseColor("#000000");
customTheme.buttonTextColor = Color.parseColor("#000000");
customTheme.buttonTextColor = Color.parseColor("#FFFFFF");
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");

View File

@@ -239,7 +239,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
}
public void changeSortType(SortType sortType) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, sortType.getType().value).apply();
mSubredditListingViewModel.changeSortType(sortType);
this.sortType = sortType;
}

View File

@@ -18,6 +18,8 @@ import eu.toldi.infinityforlemmy.customviews.CustomMarkwonAdapter;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.image.glide.GlideImagesPlugin;
import io.noties.markwon.inlineparser.BangInlineProcessor;
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
@@ -44,35 +46,27 @@ public class MarkdownUtils {
Markwon result;
if (dataSaverEnabled) {
result = Markwon.builder(context)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
}))
.usePlugin(miscPlugin)
.usePlugin(SuperscriptPlugin.create())
.usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
.usePlugin(RedditHeadingPlugin.create())
.usePlugin(new ScriptRewriteSupportPlugin())
.usePlugin(new MarkwonSpoilerPlugin(true))
.usePlugin(HtmlPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
.setOnLinkLongClickListener(onLinkLongClickListener)))
.usePlugin(TablePlugin.create(context))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(context))
.usePlugin(new MarkwonLemmyLinkPlugin())
.build();
} else {
result = Markwon.builder(context)
.usePlugin(GlideImagesPlugin.create(new GlideMarkdownLoader(mGlide)))
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
}))
.usePlugin(miscPlugin)
.usePlugin(SuperscriptPlugin.create())
.usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
.usePlugin(RedditHeadingPlugin.create())
.usePlugin(new ScriptRewriteSupportPlugin())
.usePlugin(new MarkwonSpoilerPlugin(true))
.usePlugin(HtmlPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
.setOnLinkLongClickListener(onLinkLongClickListener)))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(context))
.usePlugin(TablePlugin.create(context))
.usePlugin(ClickableGlideImagesPlugin.create(context))
.usePlugin(new MarkwonLemmyLinkPlugin())
.build();
@@ -87,32 +81,27 @@ public class MarkdownUtils {
Markwon result;
if (dataSaverEnabled) {
result = Markwon.builder(context)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
}))
.usePlugin(miscPlugin)
.usePlugin(SuperscriptPlugin.create())
.usePlugin(RedditHeadingPlugin.create())
.usePlugin(new ScriptRewriteSupportPlugin())
.usePlugin(new MarkwonSpoilerPlugin(true))
.usePlugin(HtmlPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
.setOnLinkLongClickListener(onLinkLongClickListener)))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(context))
.usePlugin(TablePlugin.create(context))
.usePlugin(new MarkwonLemmyLinkPlugin())
.build();
} else {
result = Markwon.builder(context)
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
}))
.usePlugin(miscPlugin)
.usePlugin(SuperscriptPlugin.create())
.usePlugin(RedditHeadingPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(new ScriptRewriteSupportPlugin())
.usePlugin(new MarkwonSpoilerPlugin(true))
.usePlugin(HtmlPlugin.create())
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
.setOnLinkLongClickListener(onLinkLongClickListener)))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(context))
.usePlugin(TablePlugin.create(context))
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
.usePlugin(new MarkwonLemmyLinkPlugin())
.build();

View File

@@ -0,0 +1,158 @@
package eu.toldi.infinityforlemmy.markdown
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.util.Log
import android.view.View
import android.widget.TextView
import io.noties.markwon.AbstractMarkwonPlugin
import io.noties.markwon.MarkwonPlugin
import io.noties.markwon.MarkwonVisitor
import io.noties.markwon.core.CorePlugin
import io.noties.markwon.image.AsyncDrawableScheduler
// Source copied from https://github.com/LemmyNet/jerboa/blob/main/app/src/main/java/com/jerboa/util/markwon/MarkwonSpoilerPlugin.kt
data class SpoilerTitleSpan(
val title: CharSequence,
)
class SpoilerCloseSpan
class MarkwonSpoilerPlugin(
val enableInteraction: Boolean,
) : AbstractMarkwonPlugin() {
override fun configure(registry: MarkwonPlugin.Registry) {
registry.require(CorePlugin::class.java) {
it.addOnTextAddedListener(
SpoilerTextAddedListener(),
)
}
}
private class SpoilerTextAddedListener : CorePlugin.OnTextAddedListener {
override fun onTextAdded(
visitor: MarkwonVisitor,
text: String,
start: Int,
) {
val spoilerTitleRegex = Regex("(:::\\s+spoiler\\s+)(.*)")
// Find all spoiler "start" lines
val spoilerTitles = spoilerTitleRegex.findAll(text)
for (match in spoilerTitles) {
val spoilerTitle = match.groups[2]!!.value
visitor.builder().setSpan(
SpoilerTitleSpan(spoilerTitle),
start,
start + match.groups[2]!!.range.last,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE,
)
}
val spoilerCloseRegex = Regex("^(?!.*spoiler).*:::")
// Find all spoiler "end" lines
val spoilerCloses = spoilerCloseRegex.findAll(text)
for (match in spoilerCloses) {
visitor
.builder()
.setSpan(SpoilerCloseSpan(), start, start + 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
}
override fun afterSetText(textView: TextView) {
try {
val spanned = SpannableStringBuilder(textView.text)
val spoilerTitleSpans =
spanned.getSpans(0, spanned.length, SpoilerTitleSpan::class.java)
val spoilerCloseSpans =
spanned.getSpans(0, spanned.length, SpoilerCloseSpan::class.java)
spoilerTitleSpans.sortBy { spanned.getSpanStart(it) }
spoilerCloseSpans.sortBy { spanned.getSpanStart(it) }
spoilerTitleSpans.forEachIndexed { index, spoilerTitleSpan ->
val spoilerStart = spanned.getSpanStart(spoilerTitleSpan)
var spoilerEnd = spanned.length
if (index < spoilerCloseSpans.size) {
val spoilerCloseSpan = spoilerCloseSpans[index]
spoilerEnd = spanned.getSpanEnd(spoilerCloseSpan)
}
var open = false
// The space at the end is necessary for the lengths to be the same
// This reduces complexity as else it would need complex logic to determine the replacement length
val getSpoilerTitle = { openParam: Boolean ->
if (openParam) "${spoilerTitleSpan.title}\n" else "${spoilerTitleSpan.title}\u200B"
}
val spoilerTitle = getSpoilerTitle(false)
val spoilerContent =
spanned.subSequence(
spanned.getSpanEnd(spoilerTitleSpan) + 1,
spoilerEnd - 3,
) as SpannableStringBuilder
// Remove spoiler content from span
spanned.replace(spoilerStart, spoilerEnd, spoilerTitle)
// Set span block title
spanned.setSpan(
spoilerTitle,
spoilerStart,
spoilerStart + spoilerTitle.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE,
)
val wrapper =
object : ClickableSpan() {
override fun onClick(p0: View) {
if (enableInteraction) {
textView.cancelPendingInputEvents()
open = !open
val spoilerStartCurrent = spanned.getSpanStart(spoilerTitle)
spanned.replace(
spoilerStartCurrent,
spoilerStartCurrent + spoilerTitle.length,
getSpoilerTitle(open),
)
if (open) {
spanned.insert(spoilerStartCurrent + spoilerTitle.length, spoilerContent)
} else {
spanned.replace(
spoilerStartCurrent + spoilerTitle.length,
spoilerStartCurrent + spoilerTitle.length + spoilerContent.length,
"",
)
}
textView.text = spanned
AsyncDrawableScheduler.schedule(textView)
}
}
override fun updateDrawState(ds: TextPaint) {
}
}
// Set spoiler block type as ClickableSpan
spanned.setSpan(
wrapper,
spoilerStart,
spoilerStart + spoilerTitle.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE,
)
textView.text = spanned
}
} catch (e: Exception) {
Log.w("jerboa", "Failed to parse spoiler tag. Format incorrect")
}
}
}

View File

@@ -0,0 +1,26 @@
package eu.toldi.infinityforlemmy.markdown
import io.noties.markwon.AbstractMarkwonPlugin
// Source copied from https://github.com/LemmyNet/jerboa/blob/main/app/src/main/java/com/jerboa/util/markwon/ScriptRewriteSupportPlugin.kt
class ScriptRewriteSupportPlugin : AbstractMarkwonPlugin() {
override fun processMarkdown(markdown: String): String =
super.processMarkdown(
if (markdown.contains("^") || markdown.contains("~")) {
rewriteLemmyScriptToMarkwonScript(markdown)
} else { // Fast path: if there are no markdown characters, we don't need to do anything
markdown
},
)
companion object {
val SUPERSCRIPT_RGX = Regex("""\^([^\n^]+)\^""")
val SUBSCRIPT_RGX = Regex("""(?<!~)~([^\n~]+)~""")
fun rewriteLemmyScriptToMarkwonScript(text: String): String =
text
.replace(SUPERSCRIPT_RGX, "<sup>$1</sup>")
.replace(SUBSCRIPT_RGX, "<sub>$1</sub>")
}
}

View File

@@ -125,23 +125,11 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/awards_text_view_item_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:visibility="gone"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/comment_markdown_view_item_post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:nestedScrollingEnabled="false" />

View File

@@ -256,13 +256,13 @@
android:src="@drawable/ic_link"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" />

View File

@@ -262,13 +262,13 @@
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_image_and_gif_autoplay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" />

View File

@@ -271,13 +271,13 @@
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_link"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" />

View File

@@ -106,17 +106,17 @@
android:focusable="true"
android:longClickable="true" />
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_no_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" >
</androidx.recyclerview.widget.RecyclerView>
</TextView>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"

View File

@@ -106,17 +106,17 @@
android:textIsSelectable="true"
android:textSize="?attr/title_font_18" />
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" >
</androidx.recyclerview.widget.RecyclerView>
</TextView>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"

View File

@@ -274,13 +274,13 @@
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_video_and_gif_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" />

View File

@@ -255,13 +255,13 @@
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_video_autoplay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" />

View File

@@ -258,13 +258,13 @@
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
<androidx.recyclerview.widget.RecyclerView
<TextView
android:id="@+id/content_markdown_view_item_post_detail_video_autoplay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:nestedScrollingEnabled="false" />