mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Do not load inline images in data-saving mode
This commit is contained in:
parent
6b09f0379c
commit
03ee3899d7
@ -205,7 +205,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
||||
}
|
||||
};
|
||||
Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||
miscPlugin, parentTextColor, parentSpoilerBackgroundColor, null);
|
||||
miscPlugin, parentTextColor, parentSpoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||
binding.commentContentMarkdownView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
|
||||
binding.commentContentMarkdownView.setAdapter(markwonAdapter);
|
||||
|
@ -139,7 +139,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
||||
}
|
||||
};
|
||||
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||
miscPlugin, markdownColor, spoilerBackgroundColor, null);
|
||||
miscPlugin, markdownColor, spoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
|
||||
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
||||
|
@ -149,7 +149,7 @@ public class InstanceInfoActivity extends BaseActivity {
|
||||
};
|
||||
|
||||
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||
miscPlugin, markdownColor, postSpoilerBackgroundColor, null);
|
||||
miscPlugin, markdownColor, postSpoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||
mContentMarkdownView.setAdapter(mMarkwonAdapter);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
|
@ -132,7 +132,7 @@ public class RulesActivity extends BaseActivity {
|
||||
|
||||
mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||
|
||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel);
|
||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
|
@ -5,8 +5,8 @@ import static android.graphics.BitmapFactory.decodeResource;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -271,6 +271,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
|
||||
private boolean showStatistics;
|
||||
|
||||
private boolean disableImagePreview;
|
||||
|
||||
private boolean hideSubredditDescription;
|
||||
|
||||
@Override
|
||||
@ -285,6 +287,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
|
||||
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
|
||||
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
|
||||
disableImagePreview = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false);
|
||||
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
||||
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar),
|
||||
findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar),
|
||||
@ -546,7 +549,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
return true;
|
||||
};
|
||||
|
||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener);
|
||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
|
||||
descriptionTextView.setOnLongClickListener(view -> {
|
||||
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
||||
@ -1731,6 +1734,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
bundle.putString(SidebarFragment.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
bundle.putString(SidebarFragment.EXTRA_COMMUNITY_QUALIFIED_NAME, qualifiedName);
|
||||
bundle.putBoolean(SidebarFragment.EXTRA_SHOW_STATISTICS, !showStatistics);
|
||||
bundle.putBoolean(SidebarFragment.EXTRA_DISABLE_IMAGE_PREVIEW, disableImagePreview);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
urlMenuBottomSheetFragment.show(getSupportFragmentManager(), null);
|
||||
return true;
|
||||
};
|
||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener);
|
||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
|
||||
descriptionTextView.setOnLongClickListener(view -> {
|
||||
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
||||
|
@ -176,7 +176,7 @@ public class WikiActivity extends BaseActivity {
|
||||
return true;
|
||||
};
|
||||
markwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener);
|
||||
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
|
||||
markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
||||
|
@ -170,7 +170,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
return true;
|
||||
};
|
||||
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
||||
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
||||
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
return true;
|
||||
};
|
||||
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
||||
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
||||
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||
mAccessToken = accessToken;
|
||||
mAccountQualifiedName = accountName;
|
||||
|
@ -299,7 +299,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
return true;
|
||||
};
|
||||
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
||||
miscPlugin, markdownColor, postSpoilerBackgroundColor, onLinkLongClickListener);
|
||||
miscPlugin, markdownColor, postSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||
|
||||
mSeparatePostAndComments = separatePostAndComments;
|
||||
|
@ -37,6 +37,7 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
|
||||
private BaseActivity activity;
|
||||
private Markwon markwon;
|
||||
private boolean mDisableImagePreview;
|
||||
@Nullable
|
||||
private final SliderPanel sliderPanel;
|
||||
private ArrayList<Rule> rules;
|
||||
@ -44,10 +45,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
||||
|
||||
public RulesRecyclerViewAdapter(@NonNull BaseActivity activity,
|
||||
@NonNull CustomThemeWrapper customThemeWrapper,
|
||||
@Nullable SliderPanel sliderPanel) {
|
||||
@Nullable SliderPanel sliderPanel, boolean disableImagePreview) {
|
||||
this.activity = activity;
|
||||
this.sliderPanel = sliderPanel;
|
||||
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
mDisableImagePreview = disableImagePreview;
|
||||
int spoilerBackgroundColor = mPrimaryTextColor | 0xFF000000;
|
||||
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
@ -82,7 +84,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
||||
return true;
|
||||
};
|
||||
markwon = MarkdownUtils.createFullRedditMarkwon(activity,
|
||||
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, onLinkLongClickListener);
|
||||
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, onLinkLongClickListener, mDisableImagePreview);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -66,6 +66,7 @@ public class SidebarFragment extends Fragment {
|
||||
public static final String EXTRA_COMMUNITY_QUALIFIED_NAME = "ECQN";
|
||||
|
||||
public static final String EXTRA_SHOW_STATISTICS = "ESS";
|
||||
public static final String EXTRA_DISABLE_IMAGE_PREVIEW = "EDIP";
|
||||
public SubredditViewModel mSubredditViewModel;
|
||||
@BindView(R.id.swipe_refresh_layout_sidebar_fragment)
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
@ -126,6 +127,8 @@ public class SidebarFragment extends Fragment {
|
||||
|
||||
private boolean mShowStatistics;
|
||||
|
||||
private boolean mDisableImagePreview;
|
||||
|
||||
private String communityQualifiedName;
|
||||
private LinearLayoutManagerBugFixed linearLayoutManager;
|
||||
private int markdownColor;
|
||||
@ -153,6 +156,7 @@ public class SidebarFragment extends Fragment {
|
||||
subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
|
||||
communityQualifiedName = getArguments().getString(EXTRA_COMMUNITY_QUALIFIED_NAME);
|
||||
mShowStatistics = getArguments().getBoolean(EXTRA_SHOW_STATISTICS, true);
|
||||
mDisableImagePreview = getArguments().getBoolean(EXTRA_DISABLE_IMAGE_PREVIEW, false);
|
||||
if (communityQualifiedName == null) {
|
||||
Toast.makeText(activity, R.string.error_getting_community_name, Toast.LENGTH_SHORT).show();
|
||||
return rootView;
|
||||
@ -224,7 +228,7 @@ public class SidebarFragment extends Fragment {
|
||||
return true;
|
||||
};
|
||||
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(activity,
|
||||
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener);
|
||||
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener, mDisableImagePreview);
|
||||
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||
|
||||
linearLayoutManager = new LinearLayoutManagerBugFixed(activity);
|
||||
|
@ -38,44 +38,84 @@ public class MarkdownUtils {
|
||||
@NonNull MarkwonPlugin miscPlugin,
|
||||
int markdownColor,
|
||||
int spoilerBackgroundColor,
|
||||
@Nullable BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener) {
|
||||
return Markwon.builder(context)
|
||||
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(miscPlugin)
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
.usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
|
||||
.usePlugin(RedditHeadingPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(ClickableGlideImagesPlugin.create(context))
|
||||
.usePlugin(new MarkwonLemmyLinkPlugin())
|
||||
.build();
|
||||
@Nullable BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener, boolean dataSaverEnabled) {
|
||||
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(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(new MarkwonLemmyLinkPlugin())
|
||||
.build();
|
||||
} else {
|
||||
result = Markwon.builder(context)
|
||||
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(miscPlugin)
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
.usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
|
||||
.usePlugin(RedditHeadingPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(ClickableGlideImagesPlugin.create(context))
|
||||
.usePlugin(new MarkwonLemmyLinkPlugin())
|
||||
.build();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Markwon createDescriptionMarkwon(Activity context, MarkwonPlugin miscPlugin,
|
||||
BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener) {
|
||||
return Markwon.builder(context)
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(miscPlugin)
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
.usePlugin(RedditHeadingPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
|
||||
.usePlugin(new MarkwonLemmyLinkPlugin())
|
||||
.build();
|
||||
BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener, boolean dataSaverEnabled) {
|
||||
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(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.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(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(GlideImagesPlugin.create(context.getApplicationContext()))
|
||||
.usePlugin(new MarkwonLemmyLinkPlugin())
|
||||
.build();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user