aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/AndroidManifest.xml13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SaveMemoryCenterInisdeDownsampleStrategy.java29
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java35
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java54
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java71
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java94
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java74
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java68
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java99
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java147
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java157
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java73
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java187
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java88
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/SpoilerOnClickTextView.java30
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java35
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/BlockQuoteWithExceptionParser.java85
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java202
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerSpan.java64
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptInlineProcessor.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java75
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java7
-rw-r--r--app/src/main/res/layout-land/fragment_view_post_detail.xml1
-rw-r--r--app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml1
-rw-r--r--app/src/main/res/layout/activity_edit_profile.xml120
-rw-r--r--app/src/main/res/layout/activity_post_gallery.xml36
-rw-r--r--app/src/main/res/layout/activity_post_image.xml38
-rw-r--r--app/src/main/res/layout/activity_post_link.xml42
-rw-r--r--app/src/main/res/layout/activity_post_text.xml36
-rw-r--r--app/src/main/res/layout/activity_post_video.xml46
-rw-r--r--app/src/main/res/layout/activity_submit_crosspost.xml6
-rw-r--r--app/src/main/res/layout/activity_view_subreddit_detail.xml3
-rw-r--r--app/src/main/res/layout/activity_view_user_detail.xml3
-rw-r--r--app/src/main/res/layout/exo_playback_control_view.xml8
-rw-r--r--app/src/main/res/layout/fragment_theme_preview_posts.xml10
-rw-r--r--app/src/main/res/layout/item_comment.xml2
-rw-r--r--app/src/main/res/layout/item_post_card_2_text.xml10
-rw-r--r--app/src/main/res/layout/item_post_card_2_video_autoplay.xml11
-rw-r--r--app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml11
-rw-r--r--app/src/main/res/layout/item_post_card_2_with_preview.xml10
-rw-r--r--app/src/main/res/layout/item_post_compact.xml10
-rw-r--r--app/src/main/res/layout/item_post_compact_right_thumbnail.xml10
-rw-r--r--app/src/main/res/layout/item_post_detail_gallery.xml8
-rw-r--r--app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml8
-rw-r--r--app/src/main/res/layout/item_post_detail_link.xml8
-rw-r--r--app/src/main/res/layout/item_post_detail_no_preview.xml8
-rw-r--r--app/src/main/res/layout/item_post_detail_text.xml8
-rw-r--r--app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml8
-rw-r--r--app/src/main/res/layout/item_post_detail_video_autoplay.xml9
-rw-r--r--app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml9
-rw-r--r--app/src/main/res/layout/item_post_text.xml10
-rw-r--r--app/src/main/res/layout/item_post_video_type_autoplay.xml11
-rw-r--r--app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml11
-rw-r--r--app/src/main/res/layout/item_post_with_preview.xml3
-rw-r--r--app/src/main/res/menu/edit_profile_activity.xml2
-rw-r--r--app/src/main/res/menu/view_subreddit_detail_activity.xml8
-rw-r--r--app/src/main/res/values/strings.xml26
81 files changed, 1460 insertions, 1130 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 826dc004..6852e8a5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -25,7 +25,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
- android:name=".Infinity"
+ android:name="ml.docilealligator.infinityforreddit.Infinity"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
@@ -34,6 +34,11 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
+ <activity android:name=".activities.EditProfileActivity"
+ android:label="@string/edit_profile_activity_label"
+ android:parentActivityName=".activities.MainActivity"
+ android:theme="@style/AppTheme.Slidable"
+ android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activities.WikiActivity"
android:label="@string/wiki_activity_label"
@@ -53,7 +58,6 @@
<activity
android:name=".activities.RPANActivity"
android:configChanges="orientation|screenSize|layoutDirection"
- android:label="@string/rpan_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.TranslucentStatusBar"
android:windowSoftInputMode="adjustPan" />
@@ -394,11 +398,6 @@
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
- <activity android:name=".activities.EditProfileActivity"
- android:parentActivityName=".activities.MainActivity"
- android:theme="@style/AppTheme.SlidableWithTranslucentWindow"
- android:windowSoftInputMode="adjustPan" />
-
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="ml.docilealligator.infinityforreddit.provider"
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index e0eb462d..2b990071 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -43,6 +43,9 @@ public class Infinity extends Application implements LifecycleObserver {
private boolean canStartLockScreenActivity = false;
private boolean isSecureMode;
@Inject
+ @Named("default")
+ SharedPreferences mSharedPreferences;
+ @Inject
@Named("security")
SharedPreferences mSecuritySharedPreferences;
@@ -127,7 +130,7 @@ public class Infinity extends Application implements LifecycleObserver {
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
- registerReceiver(new WallpaperChangeReceiver(), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
+ registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SaveMemoryCenterInisdeDownsampleStrategy.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SaveMemoryCenterInisdeDownsampleStrategy.java
new file mode 100644
index 00000000..8516c53e
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SaveMemoryCenterInisdeDownsampleStrategy.java
@@ -0,0 +1,29 @@
+package ml.docilealligator.infinityforreddit;
+
+import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy;
+
+public class SaveMemoryCenterInisdeDownsampleStrategy extends DownsampleStrategy {
+
+ @Override
+ public float getScaleFactor(int sourceWidth, int sourceHeight, int requestedWidth, int requestedHeight) {
+ int originalSourceWidth = sourceWidth;
+ int originalSourceHeight = sourceHeight;
+ if (sourceWidth * sourceHeight > 5_000_000) {
+ int divisor = 2;
+ do {
+ sourceWidth /= divisor;
+ sourceHeight /= divisor;
+ } while (sourceWidth * sourceHeight > 5_000_000);
+ }
+
+ float widthPercentage = (float) requestedWidth / (float) sourceWidth;
+ float heightPercentage = (float) requestedHeight / (float) sourceHeight;
+
+ return Math.min((float) sourceWidth / (float) originalSourceWidth, (float) sourceHeight / (float) originalSourceHeight) * Math.min(1.f, Math.min(widthPercentage, heightPercentage));
+ }
+
+ @Override
+ public SampleSizeRounding getSampleSizeRounding(int sourceWidth, int sourceHeight, int requestedWidth, int requestedHeight) {
+ return SampleSizeRounding.MEMORY;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index 13f40f63..ad840efa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -129,10 +129,10 @@ public abstract class BaseActivity extends AppCompatActivity {
}
}
- boolean userDefinedChangeSatusBarIconColorInImmersiveInterface =
+ boolean userDefinedChangeStatusBarIconColorInImmersiveInterface =
customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface();
if (immersiveInterface && isImmersiveInterfaceApplicable) {
- changeStatusBarIconColor = userDefinedChangeSatusBarIconColorInImmersiveInterface;
+ changeStatusBarIconColor = userDefinedChangeStatusBarIconColorInImmersiveInterface;
} else {
changeStatusBarIconColor = false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index 1f85f362..7680f2fd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -51,6 +51,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.recycler.MarkwonAdapter;
import io.noties.markwon.recycler.table.TableEntry;
@@ -68,6 +72,7 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
@@ -160,8 +165,21 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
int linkColor = mCustomThemeWrapper.getLinkColor();
Markwon markwon = Markwon.builder(this)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
+ @NonNull
+ @Override
+ public String processMarkdown(@NonNull String markdown) {
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
+ }
+
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
@@ -201,8 +219,21 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
contentMarkdownRecyclerView.setVisibility(View.VISIBLE);
contentMarkdownRecyclerView.setNestedScrollingEnabled(false);
Markwon postBodyMarkwon = Markwon.builder(this)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
+ @NonNull
+ @Override
+ public String processMarkdown(@NonNull String markdown) {
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
+ }
+
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
textView.setTextColor(markdownColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
index f267e9f4..d9248652 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.activities;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
@@ -17,7 +18,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
@@ -26,6 +26,8 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrInterface;
@@ -50,6 +52,7 @@ import ml.docilealligator.infinityforreddit.services.EditProfileService;
import ml.docilealligator.infinityforreddit.user.UserViewModel;
import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class EditProfileActivity extends BaseActivity {
@@ -61,14 +64,16 @@ public class EditProfileActivity extends BaseActivity {
CoordinatorLayout root;
@BindView(R.id.content_view_edit_profile_activity)
LinearLayout content;
+ @BindView(R.id.collapsing_toolbar_layout_edit_profile_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_view_edit_profile_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_view_edit_profile_activity)
- Toolbar toolbar;
+ MaterialToolbar toolbar;
@BindView(R.id.image_view_banner_edit_profile_activity)
- ImageView bannerImageView;
+ GifImageView bannerImageView;
@BindView(R.id.image_view_avatar_edit_profile_activity)
- ImageView avatarImageView;
+ GifImageView avatarImageView;
@BindView(R.id.image_view_change_banner_edit_profile_activity)
ImageView changeBanner;
@BindView(R.id.image_view_change_avatar_edit_profile_activity)
@@ -92,20 +97,28 @@ public class EditProfileActivity extends BaseActivity {
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- //
private String mAccountName;
private String mAccessToken;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
- setTransparentStatusBarAfterToolbarCollapsed();
+
+ setImmersiveModeNotApplicable();
+
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile);
+
ButterKnife.bind(this);
+
EventBus.getDefault().register(this);
+
applyCustomTheme();
- adjustToolbar(toolbar);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
+ addOnOffsetChangedListener(appBarLayout);
+ }
+
setSupportActionBar(toolbar);
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
@@ -130,22 +143,26 @@ public class EditProfileActivity extends BaseActivity {
new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class);
userViewModel.getUserLiveData().observe(this, userData -> {
- if (userData == null) return;//
+ if (userData == null) {
+ return;
+ }
// BANNER
final String userBanner = userData.getBanner();
LayoutParams cBannerLp = (LayoutParams) changeBanner.getLayoutParams();
if (userBanner == null || userBanner.isEmpty()) {
changeBanner.setLongClickable(false);
- changeBanner.setImageResource(R.drawable.ic_add_day_night_24dp);
- changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.CENTER));
+ cBannerLp.gravity = Gravity.CENTER;
+ changeBanner.setLayoutParams(cBannerLp);
changeBanner.setOnLongClickListener(v -> false);
} else {
changeBanner.setLongClickable(true);
- changeBanner.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp);
- changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.END | Gravity.BOTTOM));
+ cBannerLp.gravity = Gravity.END | Gravity.BOTTOM;
+ changeBanner.setLayoutParams(cBannerLp);
glide.load(userBanner).into(bannerImageView);
changeBanner.setOnLongClickListener(view -> {
- if (mAccessToken == null) return false;
+ if (mAccessToken == null) {
+ return false;
+ }
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.remove_banner)
.setMessage(R.string.are_you_sure)
@@ -182,15 +199,13 @@ public class EditProfileActivity extends BaseActivity {
LayoutParams cAvatarLp = (LayoutParams) changeAvatar.getLayoutParams();
if (userAvatar.contains("avatar_default_")) {
changeAvatar.setLongClickable(false);
- changeAvatar.setImageResource(R.drawable.ic_add_day_night_24dp);
- changeAvatar.setLayoutParams(new LayoutParams(cAvatarLp.width, cAvatarLp.height, Gravity.CENTER));
changeAvatar.setOnLongClickListener(v -> false);
} else {
changeAvatar.setLongClickable(true);
- changeAvatar.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp);
- changeAvatar.setLayoutParams(new LayoutParams(cAvatarLp.width, cAvatarLp.height, Gravity.END | Gravity.BOTTOM));
changeAvatar.setOnLongClickListener(view -> {
- if (mAccessToken == null) return false;
+ if (mAccessToken == null) {
+ return false;
+ }
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.remove_avatar)
.setMessage(R.string.are_you_sure)
@@ -328,8 +343,9 @@ public class EditProfileActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
- applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
root.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
+
changeColorTextView(content, mCustomThemeWrapper.getPrimaryTextColor());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
index dca5b75b..acd1713c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
@@ -47,6 +47,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.recycler.MarkwonAdapter;
import io.noties.markwon.recycler.table.TableEntry;
@@ -57,7 +61,11 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
+import ml.docilealligator.infinityforreddit.utils.Utils;
public class FullMarkdownActivity extends BaseActivity {
@@ -130,63 +138,19 @@ public class FullMarkdownActivity extends BaseActivity {
int spoilerBackgroundColor = markdownColor | 0xFF000000;
int linkColor = mCustomThemeWrapper.getLinkColor();
Markwon markwon = Markwon.builder(this)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
- }
- return super.processMarkdown(markdownStringBuilder.toString());
- }
-
- @Override
- public void afterSetText(@NonNull TextView textView) {
- textView.setHighlightColor(Color.TRANSPARENT);
- SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- int start = 0;
- boolean find = false;
- while (matcher.find(start)) {
- if (markdownStringBuilder.length() < 4
- || matcher.start() < 0
- || matcher.end() > markdownStringBuilder.length()) {
- break;
- }
- find = true;
- markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
- markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
- ClickableSpan clickableSpan = new ClickableSpan() {
- private boolean isShowing = false;
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- if (isShowing) {
- super.updateDrawState(ds);
- ds.setColor(markdownColor);
- } else {
- ds.bgColor = spoilerBackgroundColor;
- ds.setColor(markdownColor);
- }
- ds.setUnderlineText(false);
- }
-
- @Override
- public void onClick(@NonNull View view) {
- isShowing = !isShowing;
- view.invalidate();
- }
- };
- markdownStringBuilder.setSpan(clickableSpan, matcher.start(), matcher.end() - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- start = matcher.end() - 4;
- }
- if (find) {
- textView.setText(markdownStringBuilder);
- }
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@@ -210,6 +174,7 @@ public class FullMarkdownActivity extends BaseActivity {
builder.linkColor(linkColor);
}
})
+ .usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(this))
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 30d134fe..990fbe83 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -38,7 +38,6 @@ import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
-import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter;
@@ -270,9 +269,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
drawer.setFitsSystemWindows(false);
getWindow().setDecorFitsSystemWindows(false);
- /*drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
@@ -855,51 +851,37 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
tabLayout.setTabMode(TabLayout.MODE_FIXED);
}
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
- if (mAccessToken == null) {
- switch (position) {
- case 0:
- tab.setText(R.string.home);
- break;
- case 1:
- tab.setText(R.string.popular);
- break;
- case 2:
- tab.setText(R.string.all);
- break;
- }
- } else {
- switch (position) {
- case 0:
- tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
- break;
- case 1:
- tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
- break;
- case 2:
- tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
- break;
- }
- if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
- mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits)
- && sectionsPagerAdapter != null) {
- if (position - tabCount < sectionsPagerAdapter.favoriteMultiReddits.size()) {
- tab.setText(sectionsPagerAdapter.favoriteMultiReddits.get(position - tabCount).getName());
- } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size() < sectionsPagerAdapter.multiReddits.size()) {
- tab.setText(sectionsPagerAdapter.multiReddits.get(position - tabCount
- - sectionsPagerAdapter.favoriteMultiReddits.size()).getName());
- } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
- - sectionsPagerAdapter.multiReddits.size() < sectionsPagerAdapter.favoriteSubscribedSubreddits.size()) {
- tab.setText(sectionsPagerAdapter.favoriteSubscribedSubreddits.get(position - tabCount
- - sectionsPagerAdapter.favoriteMultiReddits.size()
- - sectionsPagerAdapter.multiReddits.size()).getName());
- } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
+ switch (position) {
+ case 0:
+ tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
+ break;
+ case 1:
+ tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
+ break;
+ case 2:
+ tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
+ break;
+ }
+ if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
+ mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits)
+ && sectionsPagerAdapter != null) {
+ if (position - tabCount < sectionsPagerAdapter.favoriteMultiReddits.size()) {
+ tab.setText(sectionsPagerAdapter.favoriteMultiReddits.get(position - tabCount).getName());
+ } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size() < sectionsPagerAdapter.multiReddits.size()) {
+ tab.setText(sectionsPagerAdapter.multiReddits.get(position - tabCount
+ - sectionsPagerAdapter.favoriteMultiReddits.size()).getName());
+ } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
+ - sectionsPagerAdapter.multiReddits.size() < sectionsPagerAdapter.favoriteSubscribedSubreddits.size()) {
+ tab.setText(sectionsPagerAdapter.favoriteSubscribedSubreddits.get(position - tabCount
+ - sectionsPagerAdapter.favoriteMultiReddits.size()
+ - sectionsPagerAdapter.multiReddits.size()).getName());
+ } else if (position - tabCount - sectionsPagerAdapter.favoriteMultiReddits.size()
+ - sectionsPagerAdapter.multiReddits.size()
+ - sectionsPagerAdapter.favoriteSubscribedSubreddits.size() < sectionsPagerAdapter.subscribedSubreddits.size()) {
+ tab.setText(sectionsPagerAdapter.subscribedSubreddits.get(position - tabCount
+ - sectionsPagerAdapter.favoriteMultiReddits.size()
- sectionsPagerAdapter.multiReddits.size()
- - sectionsPagerAdapter.favoriteSubscribedSubreddits.size() < sectionsPagerAdapter.subscribedSubreddits.size()) {
- tab.setText(sectionsPagerAdapter.subscribedSubreddits.get(position - tabCount
- - sectionsPagerAdapter.favoriteMultiReddits.size()
- - sectionsPagerAdapter.multiReddits.size()
- - sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());
- }
+ - sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());
}
}
}).attach();
@@ -925,7 +907,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadSubscriptions();
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
- mRedditDataRoomDatabase, mAccountName))
+ mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
.get(MultiRedditViewModel.class);
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
@@ -934,17 +916,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
});
- multiRedditViewModel.getAllMultiReddits().observe(this, new Observer<List<MultiReddit>>() {
- @Override
- public void onChanged(List<MultiReddit> multiReddits) {
- if (mShowMultiReddits && sectionsPagerAdapter != null) {
- sectionsPagerAdapter.setMultiReddits(multiReddits);
- }
+ multiRedditViewModel.getAllMultiReddits().observe(this, multiReddits -> {
+ if (mShowMultiReddits && sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.setMultiReddits(multiReddits);
}
});
subscribedSubredditViewModel = new ViewModelProvider(this,
- new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
+ new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
.get(SubscribedSubredditViewModel.class);
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
subscribedSubredditData -> {
@@ -1696,9 +1675,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public int getItemCount() {
- if (mAccessToken == null) {
- return 3;
- }
return tabCount + favoriteMultiReddits.size() + multiReddits.size() +
favoriteSubscribedSubreddits.size() + subscribedSubreddits.size();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
index 3dcb726e..a3c12c29 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
@@ -35,6 +35,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.switchmaterial.SwitchMaterial;
import com.google.gson.Gson;
@@ -110,27 +111,23 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
@BindView(R.id.rules_button_post_gallery_activity)
MaterialButton rulesButton;
@BindView(R.id.divider_1_post_gallery_activity)
- View divider1;
+ MaterialDivider divider1;
@BindView(R.id.flair_custom_text_view_post_gallery_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_gallery_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_gallery_activity)
CustomTextView nsfwTextView;
- @BindView(R.id.divider_2_post_gallery_activity)
- View divider2;
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity)
LinearLayout receivePostReplyNotificationsLinearLayout;
@BindView(R.id.receive_post_reply_notifications_text_view_post_gallery_activity)
TextView receivePostReplyNotificationsTextView;
@BindView(R.id.receive_post_reply_notifications_switch_material_post_gallery_activity)
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
- @BindView(R.id.divider_3_post_gallery_activity)
- View divider3;
+ @BindView(R.id.divider_2_post_gallery_activity)
+ MaterialDivider divider2;
@BindView(R.id.post_title_edit_text_post_gallery_activity)
EditText titleEditText;
- @BindView(R.id.divider_4_post_gallery_activity)
- View divider4;
@BindView(R.id.images_recycler_view_post_gallery_activity)
RecyclerView imagesRecyclerView;
@Inject
@@ -415,10 +412,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor();
- divider1.setBackgroundColor(dividerColor);
- divider2.setBackgroundColor(dividerColor);
- divider3.setBackgroundColor(dividerColor);
- divider4.setBackgroundColor(dividerColor);
+ divider1.setDividerColor(dividerColor);
+ divider2.setDividerColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
index cf6c7664..759f4911 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
@@ -32,6 +32,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.switchmaterial.SwitchMaterial;
@@ -97,27 +98,23 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
@BindView(R.id.rules_button_post_image_activity)
MaterialButton rulesButton;
@BindView(R.id.divider_1_post_image_activity)
- View divider1;
+ MaterialDivider divider1;
@BindView(R.id.flair_custom_text_view_post_image_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_image_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
CustomTextView nsfwTextView;
- @BindView(R.id.divider_2_post_image_activity)
- View divider2;
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_image_activity)
LinearLayout receivePostReplyNotificationsLinearLayout;
@BindView(R.id.receive_post_reply_notifications_text_view_post_image_activity)
TextView receivePostReplyNotificationsTextView;
@BindView(R.id.receive_post_reply_notifications_switch_material_post_image_activity)
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
- @BindView(R.id.divider_3_post_image_activity)
- View divider3;
+ @BindView(R.id.divider_2_post_image_activity)
+ MaterialDivider divider2;
@BindView(R.id.post_title_edit_text_post_image_activity)
EditText titleEditText;
- @BindView(R.id.divider_4_post_image_activity)
- View divider4;
@BindView(R.id.select_image_constraint_layout_post_image_activity)
ConstraintLayout constraintLayout;
@BindView(R.id.capture_fab_post_image_activity)
@@ -396,10 +393,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor();
- divider1.setBackgroundColor(dividerColor);
- divider2.setBackgroundColor(dividerColor);
- divider3.setBackgroundColor(dividerColor);
- divider4.setBackgroundColor(dividerColor);
+ divider1.setDividerColor(dividerColor);
+ divider2.setDividerColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
index eecefa75..a24ece41 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
@@ -26,6 +26,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.switchmaterial.SwitchMaterial;
import com.libRG.CustomTextView;
@@ -91,11 +92,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
@BindView(R.id.rules_button_post_link_activity)
MaterialButton rulesButton;
@BindView(R.id.divider_1_post_link_activity)
- View divider1;
+ MaterialDivider divider1;
@BindView(R.id.divider_2_post_link_activity)
- View divider2;
- @BindView(R.id.divider_4_post_link_activity)
- View divider4;
+ MaterialDivider divider2;
@BindView(R.id.flair_custom_text_view_post_link_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_link_activity)
@@ -108,8 +107,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
TextView receivePostReplyNotificationsTextView;
@BindView(R.id.receive_post_reply_notifications_switch_material_post_link_activity)
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
- @BindView(R.id.divider_3_post_link_activity)
- View divider3;
@BindView(R.id.post_title_edit_text_post_link_activity)
EditText titleEditText;
@BindView(R.id.suggest_title_button_post_link_activity)
@@ -370,10 +367,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor();
- divider1.setBackgroundColor(dividerColor);
- divider2.setBackgroundColor(dividerColor);
- divider3.setBackgroundColor(dividerColor);
- divider4.setBackgroundColor(dividerColor);
+ divider1.setDividerColor(dividerColor);
+ divider2.setDividerColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
index 5336051c..b54e56af 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
@@ -33,6 +33,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.switchmaterial.SwitchMaterial;
import com.libRG.CustomTextView;
@@ -107,27 +108,23 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
@BindView(R.id.rules_button_post_text_activity)
MaterialButton rulesButton;
@BindView(R.id.divider_1_post_text_activity)
- View divider1;
+ MaterialDivider divider1;
@BindView(R.id.flair_custom_text_view_post_text_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_text_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
CustomTextView nsfwTextView;
- @BindView(R.id.divider_2_post_text_activity)
- View divider2;
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
LinearLayout receivePostReplyNotificationsLinearLayout;
@BindView(R.id.receive_post_reply_notifications_text_view_post_text_activity)
TextView receivePostReplyNotificationsTextView;
@BindView(R.id.receive_post_reply_notifications_switch_material_post_text_activity)
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
- @BindView(R.id.divider_3_post_text_activity)
- View divider3;
+ @BindView(R.id.divider_2_post_text_activity)
+ MaterialDivider divider2;
@BindView(R.id.post_title_edit_text_post_text_activity)
EditText titleEditText;
- @BindView(R.id.divider_4_post_text_activity)
- View divider4;
@BindView(R.id.post_text_content_edit_text_post_text_activity)
EditText contentEditText;
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
@@ -394,10 +391,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor();
- divider1.setBackgroundColor(dividerColor);
- divider2.setBackgroundColor(dividerColor);
- divider3.setBackgroundColor(dividerColor);
- divider4.setBackgroundColor(dividerColor);
+ divider1.setDividerColor(dividerColor);
+ divider2.setDividerColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
index f80b5e94..d1d09ddc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
@@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -14,6 +15,7 @@ import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -36,6 +38,7 @@ import com.google.android.exoplayer2.util.Util;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.divider.MaterialDivider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.switchmaterial.SwitchMaterial;
@@ -98,27 +101,23 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
@BindView(R.id.rules_button_post_video_activity)
MaterialButton rulesButton;
@BindView(R.id.divider_1_post_video_activity)
- View divider1;
+ MaterialDivider divider1;
@BindView(R.id.flair_custom_text_view_post_video_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_video_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
CustomTextView nsfwTextView;
- @BindView(R.id.divider_2_post_video_activity)
- View divider2;
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
LinearLayout receivePostReplyNotificationsLinearLayout;
@BindView(R.id.receive_post_reply_notifications_text_view_post_video_activity)
TextView receivePostReplyNotificationsTextView;
@BindView(R.id.receive_post_reply_notifications_switch_material_post_video_activity)
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
- @BindView(R.id.divider_3_post_video_activity)
- View divider3;
+ @BindView(R.id.divider_2_post_video_activity)
+ MaterialDivider divider2;
@BindView(R.id.post_title_edit_text_post_video_activity)
EditText titleEditText;
- @BindView(R.id.divider_4_post_video_activity)
- View divider4;
@BindView(R.id.select_video_constraint_layout_post_video_activity)
ConstraintLayout constraintLayout;
@BindView(R.id.capture_fab_post_video_activity)
@@ -364,8 +363,10 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
captureFab.setOnClickListener(view -> {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
+ try {
startActivityForResult(takeVideoIntent, CAPTURE_VIDEO_REQUEST_CODE);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
}
});
@@ -407,10 +408,8 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor();
- divider1.setBackgroundColor(dividerColor);
- divider2.setBackgroundColor(dividerColor);
- divider3.setBackgroundColor(dividerColor);
- divider4.setBackgroundColor(dividerColor);
+ divider1.setDividerColor(dividerColor);
+ divider2.setDividerColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java
index d99511ac..a027e738 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java
@@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
+import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -129,6 +130,7 @@ public class RPANActivity extends AppCompatActivity {
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
+ actionBar.setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.rpan_activity_label) + "</font>"));
if (rpanBroadcasts == null) {
loadRPANVideos();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
index 7057b1ad..039688fb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
+import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
@@ -100,10 +101,10 @@ public class TrendingActivity extends BaseActivity {
@Inject
Executor mExecutor;
private String mAccessToken;
- private String mAccountName;
private boolean isRefreshing = false;
private ArrayList<TrendingSearch> trendingSearches;
private TrendingSearchRecyclerViewAdapter adapter;
+ private RequestManager mGlide;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -151,7 +152,8 @@ public class TrendingActivity extends BaseActivity {
setToolbarGoToTop(toolbar);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
+
+ mGlide = Glide.with(this);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
@@ -277,7 +279,7 @@ public class TrendingActivity extends BaseActivity {
private void showErrorView(int stringId) {
errorLinearLayout.setVisibility(View.VISIBLE);
- Glide.with(this).load(R.drawable.error_image).into(errorImageView);
+ mGlide.load(R.drawable.error_image).into(errorImageView);
errorTextView.setText(stringId);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java
index e5d5f72b..a8d13ed7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java
@@ -163,7 +163,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
boolean useBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER, false);
if (postTitle != null) {
- Spanned title = Html.fromHtml(String.format("<small>%s</small>", postTitle));
+ Spanned title = Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", postTitle));
if (useBottomAppBar) {
titleTextView.setText(title);
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
index f56bf406..a9571923 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
@@ -137,14 +137,14 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
private void bindView() {
if (privateMessage != null) {
if (privateMessage.getAuthor().equals(mAccountName)) {
- mToolbar.setTitle(privateMessage.getDestination());
+ setTitle(privateMessage.getDestination());
mToolbar.setOnClickListener(view -> {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination());
startActivity(intent);
});
} else {
- mToolbar.setTitle(privateMessage.getAuthor());
+ setTitle(privateMessage.getAuthor());
mToolbar.setOnClickListener(view -> {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
index 61a5066f..8b477c34 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
@@ -5,6 +5,7 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
+import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
@@ -17,17 +18,20 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
-import app.futured.hauler.DragDirection;
-import app.futured.hauler.HaulerView;
-
import java.util.ArrayList;
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
+import app.futured.hauler.DragDirection;
+import app.futured.hauler.HaulerView;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
+import ml.docilealligator.infinityforreddit.WallpaperSetter;
import ml.docilealligator.infinityforreddit.customviews.ViewPagerBugFixed;
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
@@ -37,12 +41,8 @@ import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryImageOrGifFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
-import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.post.Post;
-import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
-import ml.docilealligator.infinityforreddit.WallpaperSetter;
public class ViewRedditGalleryActivity extends AppCompatActivity implements SetAsWallpaperCallback {
@@ -147,11 +147,11 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
private void setToolbarTitle(int position) {
if (gallery != null && position >= 0 && position < gallery.size()) {
if (gallery.get(position).mediaType == Post.Gallery.TYPE_IMAGE) {
- setTitle(getString(R.string.view_reddit_gallery_activity_image_label, position + 1, gallery.size()));
+ setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_image_label, position + 1, gallery.size()) + "</font>"));
} else if (gallery.get(position).mediaType == Post.Gallery.TYPE_GIF) {
- setTitle(getString(R.string.view_reddit_gallery_activity_gif_label, position + 1, gallery.size()));
+ setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_gif_label, position + 1, gallery.size()) + "</font>"));
} else {
- setTitle(getString(R.string.view_reddit_gallery_activity_video_label, position + 1, gallery.size()));
+ setTitle(Html.fromHtml("<font color=\"#FFFFFF\">" + getString(R.string.view_reddit_gallery_activity_video_label, position + 1, gallery.size()) + "</font>"));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 9ea9f5de..01c7b4d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
+import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -71,6 +72,9 @@ import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
@@ -380,6 +384,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
Locale locale = getResources().getConfiguration().locale;
Markwon markwon = Markwon.builder(this)
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
@@ -396,7 +404,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
builder.linkColor(mCustomThemeWrapper.getLinkColor());
}
})
- .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, this).setOnLinkLongClickListener((textView, url) -> {
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
@@ -519,8 +527,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
- collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
}
});
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, false);
@@ -541,10 +549,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
descriptionTextView.setTextColor(primaryTextColor);
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
- option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- option3BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ option2BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
+ option1BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
+ option3BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
+ option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
applyTabLayoutTheme(tabLayout);
applyFABTheme(fab);
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
@@ -1137,12 +1145,17 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
}
return true;
- } else if (itemId == R.id.action_go_to_wiki_activity ) {
+ } else if (itemId == R.id.action_go_to_wiki_view_subreddit_detail_activity) {
Intent wikiIntent = new Intent(this, WikiActivity.class);
wikiIntent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, subredditName);
wikiIntent.putExtra(WikiActivity.EXTRA_WIKI_PATH, "index");
startActivity(wikiIntent);
return true;
+ } else if (itemId == R.id.action_contact_mods_view_subreddit_detail_activity) {
+ Intent intent = new Intent(this, SendPrivateMessageActivity.class);
+ intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, "r/" + subredditName);
+ startActivity(intent);
+ return true;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index dfc40140..f4b6bee2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Resources;
+import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@@ -12,6 +13,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
+import android.text.util.Linkify;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@@ -68,7 +70,17 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import io.noties.markwon.AbstractMarkwonPlugin;
+import io.noties.markwon.Markwon;
+import io.noties.markwon.MarkwonConfiguration;
+import io.noties.markwon.core.MarkwonTheme;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
+import io.noties.markwon.linkify.LinkifyPlugin;
+import io.noties.markwon.movement.MovementMethodPlugin;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
+import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.DeleteThing;
@@ -84,11 +96,13 @@ import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.asynctasks.AddSubredditOrUserToMultiReddit;
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUser;
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.RandomBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UserThingSortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
@@ -217,6 +231,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String mAccessToken;
private String mAccountName;
private String username;
+ private String description;
private boolean subscriptionReady = false;
private boolean mFetchUserInfoSuccess = false;
private int expandedTabTextColor;
@@ -364,6 +379,48 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
glide = Glide.with(this);
Locale locale = getResources().getConfiguration().locale;
+ Markwon markwon = Markwon.builder(this)
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ }))
+ .usePlugin(new AbstractMarkwonPlugin() {
+ @Override
+ public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
+ builder.linkResolver((view, link) -> {
+ Intent intent = new Intent(ViewUserDetailActivity.this, LinkResolverActivity.class);
+ Uri uri = Uri.parse(link);
+ intent.setData(uri);
+ startActivity(intent);
+ });
+ }
+
+ @Override
+ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
+ builder.linkColor(mCustomThemeWrapper.getLinkColor());
+ }
+ })
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> {
+ UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
+ urlMenuBottomSheetFragment.setArguments(bundle);
+ urlMenuBottomSheetFragment.show(getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
+ return true;
+ })))
+ .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)).build();
+
+ descriptionTextView.setOnLongClickListener(view -> {
+ if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
+ Bundle bundle = new Bundle();
+ bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, description);
+ CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
+ copyTextBottomSheetFragment.setArguments(bundle);
+ copyTextBottomSheetFragment.show(getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
+ }
+ return true;
+ });
+
userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username))
.get(UserViewModel.class);
userViewModel.getUserLiveData().observe(this, userData -> {
@@ -516,7 +573,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
descriptionTextView.setVisibility(View.GONE);
} else {
descriptionTextView.setVisibility(View.VISIBLE);
- descriptionTextView.setText(userData.getDescription());
+ description = userData.getDescription();
+ markwon.setMarkdown(descriptionTextView, description);
}
/*if (userData.isNSFW()) {
@@ -566,8 +624,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
- collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
}
});
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, false);
@@ -585,10 +643,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
- option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- option3BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ option2BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
+ option1BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
+ option3BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
+ option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
applyFABTheme(fab);
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
@@ -1022,11 +1080,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
- if(mAccountName.equals(username)){ // Hide some menus
+ if (username.equals(mAccountName)) {
menu.findItem(R.id.action_send_private_message_view_user_detail_activity).setVisible(false);
menu.findItem(R.id.action_report_view_user_detail_activity).setVisible(false);
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
- }else { // Hide Edit Profile menu
+ } else {
menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false);
}
applyMenuItemTheme(menu);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
index 09d9850b..d70aaa68 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -1,6 +1,12 @@
package ml.docilealligator.infinityforreddit.activities;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
+
import android.Manifest;
+import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
@@ -32,6 +38,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -79,6 +86,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.apis.VReddIt;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PlaybackSpeedBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
import ml.docilealligator.infinityforreddit.font.FontFamily;
@@ -150,6 +158,8 @@ public class ViewVideoActivity extends AppCompatActivity {
TextView titleTextView;
@BindView(R.id.download_image_view_exo_playback_control_view)
ImageView downloadImageView;
+ @BindView(R.id.playback_speed_image_view_exo_playback_control_view)
+ ImageView playbackSpeedImageView;
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
LockableNestedScrollView nestedScrollView;
@@ -195,6 +205,9 @@ public class ViewVideoActivity extends AppCompatActivity {
SharedPreferences mSharedPreferences;
@Inject
+ CustomThemeWrapper mCustomThemeWrapper;
+
+ @Inject
Executor mExecutor;
@Inject
@@ -206,7 +219,37 @@ public class ViewVideoActivity extends AppCompatActivity {
((Infinity) getApplication()).getAppComponent().inject(this);
- getTheme().applyStyle(R.style.Theme_Normal, true);
+ boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+ int systemThemeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
+ switch (systemThemeType) {
+ case 0:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
+ getTheme().applyStyle(R.style.Theme_Normal, true);
+ break;
+ case 1:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
+ if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
+ } else {
+ getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
+ }
+ break;
+ case 2:
+ if (systemDefault) {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
+ } else {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
+ }
+ if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
+ getTheme().applyStyle(R.style.Theme_Normal, true);
+ } else {
+ if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
+ } else {
+ getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
+ }
+ }
+ }
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
@@ -250,6 +293,14 @@ public class ViewVideoActivity extends AppCompatActivity {
isDownloading = true;
requestPermissionAndDownload();
});
+
+ playbackSpeedImageView.setOnClickListener(view -> {
+ PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed);
+ playbackSpeedBottomSheetFragment.setArguments(bundle);
+ playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag());
+ });
} else {
ActionBar actionBar = getSupportActionBar();
Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp);
@@ -324,9 +375,9 @@ public class ViewVideoActivity extends AppCompatActivity {
if (postTitle != null) {
if (useBottomAppBar) {
- titleTextView.setText(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
+ titleTextView.setText(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", postTitle)));
} else {
- setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
+ setTitle(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", postTitle)));
}
} else {
if (!useBottomAppBar) {
@@ -520,10 +571,13 @@ public class ViewVideoActivity extends AppCompatActivity {
hdButton.setVisibility(View.VISIBLE);
hdButton.setOnClickListener(view -> {
- TrackSelectionDialogBuilder build = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), trackSelector, 0);
- build.setShowDisableOption(true);
- build.setAllowAdaptiveSelections(false);
- build.build().show();
+ TrackSelectionDialogBuilder builder = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), trackSelector, 0);
+ builder.setShowDisableOption(true);
+ builder.setAllowAdaptiveSelections(false);
+ AlertDialog alertDialog = builder.build();
+ alertDialog.show();
+ alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
+ alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
});
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index c5e9d35c..755a1c7b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -2,14 +2,10 @@ package ml.docilealligator.infinityforreddit.activities;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
-import android.text.SpannableStringBuilder;
import android.text.Spanned;
-import android.text.TextPaint;
-import android.text.style.ClickableSpan;
import android.text.util.Linkify;
import android.view.MenuItem;
import android.view.View;
@@ -26,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
+import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
@@ -37,9 +34,6 @@ import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import javax.inject.Inject;
import javax.inject.Named;
@@ -51,19 +45,29 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
+import io.noties.markwon.movement.MovementMethodPlugin;
import io.noties.markwon.recycler.MarkwonAdapter;
import io.noties.markwon.recycler.table.TableEntry;
import io.noties.markwon.recycler.table.TableEntryPlugin;
+import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -107,6 +111,7 @@ public class WikiActivity extends BaseActivity {
private Markwon markwon;
private MarkwonAdapter markwonAdapter;
private boolean isRefreshing = false;
+ private RequestManager mGlide;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -148,6 +153,8 @@ public class WikiActivity extends BaseActivity {
}
}
+ mGlide = Glide.with(this);
+
swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
swipeRefreshLayout.setOnRefreshListener(this::loadWiki);
@@ -155,63 +162,19 @@ public class WikiActivity extends BaseActivity {
int spoilerBackgroundColor = markdownColor | 0xFF000000;
int linkColor = mCustomThemeWrapper.getLinkColor();
markwon = Markwon.builder(this)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
- }
- return super.processMarkdown(markdownStringBuilder.toString());
- }
-
- @Override
- public void afterSetText(@NonNull TextView textView) {
- textView.setHighlightColor(Color.TRANSPARENT);
- SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- int start = 0;
- boolean find = false;
- while (matcher.find(start)) {
- if (markdownStringBuilder.length() < 4
- || matcher.start() < 0
- || matcher.end() > markdownStringBuilder.length()) {
- break;
- }
- find = true;
- markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
- markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
- ClickableSpan clickableSpan = new ClickableSpan() {
- private boolean isShowing = false;
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- if (isShowing) {
- super.updateDrawState(ds);
- ds.setColor(markdownColor);
- } else {
- ds.bgColor = spoilerBackgroundColor;
- ds.setColor(markdownColor);
- }
- ds.setUnderlineText(false);
- }
-
- @Override
- public void onClick(@NonNull View view) {
- isShowing = !isShowing;
- view.invalidate();
- }
- };
- markdownStringBuilder.setSpan(clickableSpan, matcher.start(), matcher.end() - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- start = matcher.end() - 4;
- }
- if (find) {
- textView.setText(markdownStringBuilder);
- }
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@@ -234,7 +197,16 @@ public class WikiActivity extends BaseActivity {
builder.linkColor(linkColor);
}
})
+ .usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
.usePlugin(StrikethroughPlugin.create())
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> {
+ UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
+ urlMenuBottomSheetFragment.setArguments(bundle);
+ urlMenuBottomSheetFragment.show(getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
+ return true;
+ })))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(this))
.build();
@@ -290,8 +262,9 @@ public class WikiActivity extends BaseActivity {
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
try {
- markwonAdapter.setMarkdown(markwon, new JSONObject(response.body())
- .getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.CONTENT_MD_KEY));
+ String markdown = new JSONObject(response.body())
+ .getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.CONTENT_MD_KEY);
+ markwonAdapter.setMarkdown(markwon, Utils.modifyMarkdown(markdown));
markwonAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
@@ -321,7 +294,7 @@ public class WikiActivity extends BaseActivity {
swipeRefreshLayout.setRefreshing(false);
mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchWikiInfoTextView.setText(stringResId);
- Glide.with(this).load(R.drawable.error_image).into(mFetchWikiInfoImageView);
+ mGlide.load(R.drawable.error_image).into(mFetchWikiInfoImageView);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index 15dce401..40bce0d6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Color;
+import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
@@ -42,8 +43,11 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
-import io.noties.markwon.movement.MovementMethodPlugin;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
@@ -58,8 +62,12 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSh
import ml.docilealligator.infinityforreddit.comment.Comment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
+import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
@@ -115,65 +123,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mCommentColor = customThemeWrapper.getCommentColor();
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
mMarkwon = Markwon.builder(mActivity)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
- }
- return super.processMarkdown(markdownStringBuilder.toString());
- }
-
- @Override
- public void afterSetText(@NonNull TextView textView) {
- textView.setHighlightColor(Color.TRANSPARENT);
- SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- int start = 0;
- boolean find = false;
- while (matcher.find(start)) {
- if (markdownStringBuilder.length() < 4
- || matcher.start() < 0
- || matcher.end() > markdownStringBuilder.length()) {
- break;
- }
- find = true;
- markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
- markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
- int matcherStart = matcher.start();
- int matcherEnd = matcher.end();
- ClickableSpan clickableSpan = new ClickableSpan() {
- private boolean isShowing = false;
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- if (isShowing) {
- super.updateDrawState(ds);
- ds.setColor(mCommentColor);
- } else {
- ds.bgColor = commentSpoilerBackgroundColor;
- ds.setColor(mCommentColor);
- }
- ds.setUnderlineText(false);
- }
-
- @Override
- public void onClick(@NonNull View view) {
- isShowing = !isShowing;
- view.invalidate();
- }
- };
- markdownStringBuilder.setSpan(clickableSpan, matcherStart, matcherEnd - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- start = matcherEnd - 4;
- }
- if (find) {
- textView.setText(markdownStringBuilder);
- }
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@@ -192,16 +154,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
})
- .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
- if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
- UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
- Bundle bundle = new Bundle();
- bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
- urlMenuBottomSheetFragment.setArguments(bundle);
- urlMenuBottomSheetFragment.show(activity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
- }
- return true;
- })))
+ .usePlugin(SpoilerParserPlugin.create(mCommentColor, commentSpoilerBackgroundColor))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(StrikethroughPlugin.create())
.build();
@@ -284,12 +237,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
switch (comment.getVoteType()) {
case Comment.VOTE_TYPE_UPVOTE:
((CommentViewHolder) holder).upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
break;
case Comment.VOTE_TYPE_DOWNVOTE:
((CommentViewHolder) holder).downvoteButton
- .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
break;
}
@@ -324,8 +277,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
((CommentViewHolder) holder).awardsTextView.setText("");
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
}
}
@@ -412,7 +365,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@BindView(R.id.awards_text_view_item_comment)
TextView awardsTextView;
@BindView(R.id.comment_markdown_view_item_post_comment)
- TextView commentMarkdownView;
+ SpoilerOnClickTextView commentMarkdownView;
@BindView(R.id.bottom_constraint_layout_item_post_comment)
ConstraintLayout bottomConstraintLayout;
@BindView(R.id.up_vote_button_item_post_comment)
@@ -472,13 +425,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
commentTimeTextView.setTextColor(mSecondaryTextColor);
awardsTextView.setTextColor(mSecondaryTextColor);
commentMarkdownView.setTextColor(mCommentColor);
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- moreButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- expandButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ expandButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ saveButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
commentDivider.setBackgroundColor(mDividerColor);
authorTextView.setOnClickListener(view -> {
@@ -536,11 +489,23 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
});
commentMarkdownView.setOnClickListener(view -> {
- if (commentMarkdownView.getSelectionStart() == -1 && commentMarkdownView.getSelectionEnd() == -1) {
- itemView.callOnClick();
+ if (commentMarkdownView.isSpoilerOnClick()) {
+ commentMarkdownView.setSpoilerOnClick(false);
+ return;
}
+ itemView.callOnClick();
});
+ commentMarkdownView.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkLongClickListener((textView, url) -> {
+ if (mActivity != null && !mActivity.isDestroyed() && !mActivity.isFinishing()) {
+ UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
+ urlMenuBottomSheetFragment.setArguments(bundle);
+ urlMenuBottomSheetFragment.show(mActivity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
+ }
+ return true;
+ }));
upvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
@@ -556,20 +521,20 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
int previousVoteType = comment.getVoteType();
String newVoteType;
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
//Not upvoted before
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
newVoteType = APIUtils.DIR_UPVOTE;
upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mUpvotedColor);
} else {
//Upvoted before
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
newVoteType = APIUtils.DIR_UNVOTE;
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
}
@@ -583,19 +548,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
if (currentPosition == position) {
- upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mUpvotedColor);
}
} else {
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
if (currentPosition == position) {
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
}
}
if (currentPosition == position) {
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType()));
}
@@ -623,19 +588,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
int previousVoteType = comment.getVoteType();
String newVoteType;
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
//Not downvoted before
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
newVoteType = APIUtils.DIR_DOWNVOTE;
- downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mDownvotedColor);
} else {
//Downvoted before
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
newVoteType = APIUtils.DIR_UNVOTE;
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
}
@@ -649,19 +614,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
if (currentPosition == position) {
- downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mDownvotedColor);
}
} else {
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
if (currentPosition == position) {
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
}
}
if (currentPosition == position) {
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType()));
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 14f53a2d..6e6d18d5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -4,14 +4,11 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Color;
+import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.TextPaint;
-import android.text.style.ClickableSpan;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
@@ -37,8 +34,6 @@ import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Executor;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -48,6 +43,11 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BackslashInlineProcessor;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
@@ -64,7 +64,10 @@ import ml.docilealligator.infinityforreddit.comment.Comment;
import ml.docilealligator.infinityforreddit.comment.FetchComment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
+import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -159,62 +162,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
int commentSpoilerBackgroundColor = mCommentTextColor | 0xFF000000;
int linkColor = customThemeWrapper.getLinkColor();
mCommentMarkwon = Markwon.builder(mActivity)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
- }
- return super.processMarkdown(markdownStringBuilder.toString());
- }
-
- @Override
- public void afterSetText(@NonNull TextView textView) {
- SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- int start = 0;
- boolean find = false;
- while (matcher.find(start)) {
- if (markdownStringBuilder.length() < 4
- || matcher.start() < 0
- || matcher.end() > markdownStringBuilder.length()) {
- break;
- }
- find = true;
- markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
- markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
- ClickableSpan clickableSpan = new ClickableSpan() {
- private boolean isShowing = false;
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- if (isShowing) {
- super.updateDrawState(ds);
- ds.setColor(mCommentTextColor);
- } else {
- ds.bgColor = commentSpoilerBackgroundColor;
- ds.setColor(mCommentTextColor);
- }
- ds.setUnderlineText(false);
- }
-
- @Override
- public void onClick(@NonNull View view) {
- isShowing = !isShowing;
- view.invalidate();
- }
- };
- markdownStringBuilder.setSpan(clickableSpan, matcher.start(), matcher.end() - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- start = matcher.end() - 4;
- }
- if (find) {
- textView.setText(markdownStringBuilder);
- }
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@@ -233,8 +193,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
builder.linkColor(linkColor);
}
})
+ .usePlugin(SpoilerParserPlugin.create(mCommentTextColor, commentSpoilerBackgroundColor))
.usePlugin(StrikethroughPlugin.create())
- .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.newInstance().setOnLinkLongClickListener((textView, url) -> {
if (!activity.isDestroyed() && !activity.isFinishing()) {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
@@ -479,13 +440,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
switch (comment.getVoteType()) {
case Comment.VOTE_TYPE_UPVOTE:
((CommentViewHolder) holder).upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
break;
case Comment.VOTE_TYPE_DOWNVOTE:
((CommentViewHolder) holder).downvoteButton
- .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
break;
@@ -494,19 +455,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (mPost.isArchived()) {
((CommentViewHolder) holder).replyButton
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
- android.graphics.PorterDuff.Mode.SRC_IN);
+ PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).upvoteButton
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
- android.graphics.PorterDuff.Mode.SRC_IN);
+ PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).downvoteButton
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
- android.graphics.PorterDuff.Mode.SRC_IN);
+ PorterDuff.Mode.SRC_IN);
}
if (mPost.isLocked()) {
((CommentViewHolder) holder).replyButton
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
- android.graphics.PorterDuff.Mode.SRC_IN);
+ PorterDuff.Mode.SRC_IN);
}
if (comment.isSaved()) {
@@ -1052,10 +1013,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
((CommentViewHolder) holder).awardsTextView.setText("");
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
((CommentViewHolder) holder).expandButton.setVisibility(View.GONE);
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ ((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
}
}
@@ -1100,7 +1061,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
@BindView(R.id.awards_text_view_item_comment)
TextView awardsTextView;
@BindView(R.id.comment_markdown_view_item_post_comment)
- TextView commentMarkdownView;
+ SpoilerOnClickTextView commentMarkdownView;
@BindView(R.id.bottom_constraint_layout_item_post_comment)
ConstraintLayout bottomConstraintLayout;
@BindView(R.id.up_vote_button_item_post_comment)
@@ -1164,13 +1125,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
topScoreTextView.setTextColor(mSecondaryTextColor);
awardsTextView.setTextColor(mSecondaryTextColor);
commentDivider.setBackgroundColor(mDividerColor);
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- moreButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- expandButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ expandButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ saveButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
@@ -1247,20 +1208,20 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
int previousVoteType = comment.getVoteType();
String newVoteType;
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
//Not upvoted before
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
newVoteType = APIUtils.DIR_UPVOTE;
- upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mUpvotedColor);
topScoreTextView.setTextColor(mUpvotedColor);
} else {
//Upvoted before
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
newVoteType = APIUtils.DIR_UNVOTE;
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
topScoreTextView.setTextColor(mSecondaryTextColor);
}
@@ -1279,21 +1240,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
if (currentPosition == position) {
- upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mUpvotedColor);
topScoreTextView.setTextColor(mUpvotedColor);
}
} else {
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
if (currentPosition == position) {
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
topScoreTextView.setTextColor(mSecondaryTextColor);
}
}
if (currentPosition == position) {
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType()));
topScoreTextView.setText(mActivity.getString(R.string.top_score,
@@ -1325,20 +1286,20 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
int previousVoteType = comment.getVoteType();
String newVoteType;
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
//Not downvoted before
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
newVoteType = APIUtils.DIR_DOWNVOTE;
- downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mDownvotedColor);
topScoreTextView.setTextColor(mDownvotedColor);
} else {
//Downvoted before
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
newVoteType = APIUtils.DIR_UNVOTE;
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
topScoreTextView.setTextColor(mSecondaryTextColor);
}
@@ -1357,21 +1318,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
if (currentPosition == position) {
- downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mDownvotedColor);
topScoreTextView.setTextColor(mDownvotedColor);
}
} else {
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
if (currentPosition == position) {
- downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mCommentIconAndInfoColor);
topScoreTextView.setTextColor(mSecondaryTextColor);
}
}
if (currentPosition == position) {
- upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
comment.getScore() + comment.getVoteType()));
topScoreTextView.setText(mActivity.getString(R.string.top_score,
@@ -1477,6 +1438,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
});
+ /*commentMarkdownView.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkLongClickListener((textView, url) -> {
+ if (!mActivity.isDestroyed() && !mActivity.isFinishing()) {
+ UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
+ urlMenuBottomSheetFragment.setArguments(bundle);
+ urlMenuBottomSheetFragment.show(mActivity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
+ }
+ return true;
+ }));*/
if (mSwapTapAndLong) {
if (mCommentToolbarHideOnClick) {
View.OnLongClickListener hideToolbarOnLongClickListener = view -> hideToolbar();
@@ -1485,17 +1456,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
commentTimeTextView.setOnLongClickListener(hideToolbarOnLongClickListener);
}
commentMarkdownView.setOnClickListener(view -> {
- if (commentMarkdownView.getSelectionStart() == -1 && commentMarkdownView.getSelectionEnd() == -1) {
- expandComments();
+ if (commentMarkdownView.isSpoilerOnClick()) {
+ commentMarkdownView.setSpoilerOnClick(false);
+ return;
}
+ expandComments();
});
itemView.setOnClickListener(view -> expandComments());
} else {
if (mCommentToolbarHideOnClick) {
commentMarkdownView.setOnClickListener(view -> {
- if (commentMarkdownView.getSelectionStart() == -1 && commentMarkdownView.getSelectionEnd() == -1) {
- hideToolbar();
+ if (commentMarkdownView.isSpoilerOnClick()) {
+ commentMarkdownView.setSpoilerOnClick(false);
+ return;
}
+ hideToolbar();
});
View.OnClickListener hideToolbarOnClickListener = view -> hideToolbar();
itemView.setOnClickListener(hideToolbarOnClickListener);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
index 3925d59c..7560aab4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
@@ -35,6 +35,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
@@ -42,9 +46,13 @@ import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan;
import ml.docilealligator.infinityforreddit.message.FetchMessage;
import ml.docilealligator.infinityforreddit.message.Message;
import ml.docilealligator.infinityforreddit.message.ReadMessage;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
+import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
@@ -99,65 +107,19 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
mButtonTextColor = customThemeWrapper.getButtonTextColor();
mMarkwon = Markwon.builder(mContext)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
- }
- return super.processMarkdown(markdownStringBuilder.toString());
- }
-
- @Override
- public void afterSetText(@NonNull TextView textView) {
- textView.setHighlightColor(Color.TRANSPARENT);
- SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- int start = 0;
- boolean find = false;
- while (matcher.find(start)) {
- if (markdownStringBuilder.length() < 4
- || matcher.start() < 0
- || matcher.end() > markdownStringBuilder.length()) {
- break;
- }
- find = true;
- markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
- markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
- int matcherStart = matcher.start();
- int matcherEnd = matcher.end();
- ClickableSpan clickableSpan = new ClickableSpan() {
- private boolean isShowing = false;
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- if (isShowing) {
- super.updateDrawState(ds);
- ds.setColor(mSecondaryTextColor);
- } else {
- ds.bgColor = spoilerBackgroundColor;
- ds.setColor(mSecondaryTextColor);
- }
- ds.setUnderlineText(false);
- }
-
- @Override
- public void onClick(@NonNull View view) {
- isShowing = !isShowing;
- view.invalidate();
- }
- };
- markdownStringBuilder.setSpan(clickableSpan, matcherStart, matcherEnd - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- start = matcherEnd - 4;
- }
- if (find) {
- textView.setText(markdownStringBuilder);
- }
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@@ -175,6 +137,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
builder.linkColor(customThemeWrapper.getLinkColor());
}
})
+ .usePlugin(SpoilerParserPlugin.create(mSecondaryTextColor, spoilerBackgroundColor))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.build();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index 789ce798..6aa50c65 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -74,6 +74,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.noties.markwon.recycler.MarkwonAdapter;
@@ -83,6 +87,7 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
+import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveThing;
@@ -106,10 +111,13 @@ import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
+import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostPagingSource;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -135,7 +143,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private RequestManager mGlide;
private Markwon mPostDetailMarkwon;
private final MarkwonAdapter mMarkwonAdapter;
- private int mImageViewWidth;
private String mAccessToken;
private String mAccountName;
private Post mPost;
@@ -204,7 +211,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
Retrofit redgifsRetrofit, RedditDataRoomDatabase redditDataRoomDatabase,
- RequestManager glide, int imageViewWidth,
+ RequestManager glide,
boolean separatePostAndComments, String accessToken,
String accountName, Post post, Locale locale,
SharedPreferences sharedPreferences,
@@ -226,63 +233,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
int linkColor = customThemeWrapper.getLinkColor();
mPostDetailMarkwon = Markwon.builder(mActivity)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
- }
- return super.processMarkdown(markdownStringBuilder.toString());
- }
-
- @Override
- public void afterSetText(@NonNull TextView textView) {
- textView.setHighlightColor(Color.TRANSPARENT);
- SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
- Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
- int start = 0;
- boolean find = false;
- while (matcher.find(start)) {
- if (markdownStringBuilder.length() < 4
- || matcher.start() < 0
- || matcher.end() > markdownStringBuilder.length()) {
- break;
- }
- find = true;
- markdownStringBuilder.delete(matcher.end() - 2, matcher.end());
- markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
- ClickableSpan clickableSpan = new ClickableSpan() {
- private boolean isShowing = false;
- @Override
- public void updateDrawState(@NonNull TextPaint ds) {
- if (isShowing) {
- super.updateDrawState(ds);
- ds.setColor(markdownColor);
- } else {
- ds.bgColor = postSpoilerBackgroundColor;
- ds.setColor(markdownColor);
- }
- ds.setUnderlineText(false);
- }
-
- @Override
- public void onClick(@NonNull View view) {
- isShowing = !isShowing;
- view.invalidate();
- }
- };
- markdownStringBuilder.setSpan(clickableSpan, matcher.start(), matcher.end() - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- start = matcher.end() - 4;
- }
- if (find) {
- textView.setText(markdownStringBuilder);
- }
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@@ -317,8 +280,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
builder.linkColor(linkColor);
}
})
+ .usePlugin(SpoilerParserPlugin.create(markdownColor, postSpoilerBackgroundColor))
.usePlugin(StrikethroughPlugin.create())
- .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> {
if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
@@ -336,7 +300,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
.tableLayout(R.layout.adapter_table_block, R.id.table_layout)
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
.build();
- mImageViewWidth = imageViewWidth;
mSeparatePostAndComments = separatePostAndComments;
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
mAccessToken = accessToken;
@@ -590,16 +553,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
break;
case 0:
- ((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ ((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
}
if (mPost.isArchived()) {
((PostDetailBaseViewHolder) holder).mUpvoteButton
- .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, PorterDuff.Mode.SRC_IN);
((PostDetailBaseViewHolder) holder).mDownvoteButton
- .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ .setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, PorterDuff.Mode.SRC_IN);
}
if (mPost.isCrosspost()) {
@@ -670,11 +633,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
if (preview != null) {
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
- if (mImageViewWidth > preview.getPreviewWidth()) {
- mGlide.load(preview.getPreviewUrl()).override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
- } else {
- mGlide.load(preview.getPreviewUrl()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
- }
+ mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
} else {
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
}
@@ -730,8 +689,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
int height = (int) (400 * mScale);
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / (float) preview.getPreviewWidth());
}
@@ -848,31 +805,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
previewIndex = 0;
}
preview = previews.get(previewIndex);
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
for (int i = previews.size() - 1; i >= 1; i--) {
preview = previews.get(i);
- if (mImageViewWidth >= preview.getPreviewWidth()) {
- if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 10_000_000) {
- return preview;
- }
- } else {
- int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
- if (mImageViewWidth * height <= 10_000_000) {
- return preview;
- }
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
+ return preview;
}
}
}
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
- int divisor = 2;
- do {
- preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
- preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
- divisor *= 2;
- } while (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000);
- }
-
return preview;
}
@@ -884,7 +825,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
boolean blurImage = (mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler);
String url = mPost.getPostType() == Post.IMAGE_TYPE || blurImage ? preview.getPreviewUrl() : mPost.getUrl();
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url)
- .listener(new RequestListener<Drawable>() {
+ .listener(new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
@@ -907,15 +848,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
- } else {
- imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
- }
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
}
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
- .listener(new RequestListener<Drawable>() {
+ .listener(new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
@@ -939,15 +876,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
} else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
- } else {
- imageRequestBuilder.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
- }
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
}
} else if (holder instanceof PostDetailLinkViewHolder) {
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
- .listener(new RequestListener<Drawable>() {
+ .listener(new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
@@ -971,15 +904,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostDetailLinkViewHolder) holder).mImageView);
} else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailLinkViewHolder) holder).mImageView);
- } else {
- imageRequestBuilder.into(((PostDetailLinkViewHolder) holder).mImageView);
- }
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailLinkViewHolder) holder).mImageView);
}
} else if (holder instanceof PostDetailGalleryViewHolder) {
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
- .listener(new RequestListener<Drawable>() {
+ .listener(new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostDetailGalleryViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
@@ -1002,11 +931,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailGalleryViewHolder) holder).mImageView);
} else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailGalleryViewHolder) holder).mImageView);
- } else {
- imageRequestBuilder.into(((PostDetailGalleryViewHolder) holder).mImageView);
- }
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailGalleryViewHolder) holder).mImageView);
}
}
}
@@ -1062,9 +987,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof PostDetailBaseViewHolder) {
- ((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
- ((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
((PostDetailBaseViewHolder) holder).mFlairTextView.setVisibility(View.GONE);
((PostDetailBaseViewHolder) holder).mSpoilerTextView.setVisibility(View.GONE);
((PostDetailBaseViewHolder) holder).mNSFWTextView.setVisibility(View.GONE);
@@ -1261,19 +1186,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
int previousVoteType = mPost.getVoteType();
String newVoteType;
- mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (previousVoteType != 1) {
//Not upvoted before
mPost.setVoteType(1);
newVoteType = APIUtils.DIR_UPVOTE;
- mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mUpvotedColor);
} else {
//Upvoted before
mPost.setVoteType(0);
newVoteType = APIUtils.DIR_UNVOTE;
- mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mPostIconAndInfoColor);
}
@@ -1289,15 +1214,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public void onVoteThingSuccess() {
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
mPost.setVoteType(1);
- mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mUpvotedColor);
} else {
mPost.setVoteType(0);
- mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mPostIconAndInfoColor);
}
- mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (!mHideTheNumberOfVotes) {
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
mPost.getScore() + mPost.getVoteType()));
@@ -1341,19 +1266,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
int previousVoteType = mPost.getVoteType();
String newVoteType;
- mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (previousVoteType != -1) {
//Not upvoted before
mPost.setVoteType(-1);
newVoteType = APIUtils.DIR_DOWNVOTE;
- mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mDownvotedColor);
} else {
//Upvoted before
mPost.setVoteType(0);
newVoteType = APIUtils.DIR_UNVOTE;
- mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mPostIconAndInfoColor);
}
@@ -1369,15 +1294,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public void onVoteThingSuccess() {
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
mPost.setVoteType(-1);
- mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mDownvotedColor);
} else {
mPost.setVoteType(0);
- mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mPostIconAndInfoColor);
}
- mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
if (!mHideTheNumberOfVotes) {
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
mPost.getScore() + mPost.getVoteType()));
@@ -1549,13 +1474,13 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mUpvoteRatioTextView.setCompoundDrawablesWithIntrinsicBounds(
upvoteRatioDrawable, null, null, null);
mUpvoteRatioTextView.setTextColor(mSecondaryTextColor);
- mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(mPostIconAndInfoColor);
- mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
commentsCountTextView.setTextColor(mPostIconAndInfoColor);
commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null);
- mSaveButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- mShareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ mSaveButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
+ mShareButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
}
}
@@ -2199,7 +2124,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mLinkTextView.setTextColor(mSecondaryTextColor);
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
- mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
+ mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, PorterDuff.Mode.SRC_IN);
mNoPreviewPostTypeImageView.setOnClickListener(view -> {
if (mPost != null) {
@@ -2344,7 +2269,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
mLoadImageErrorTextView.setTextColor(mPrimaryTextColor);
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
- mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
+ mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, PorterDuff.Mode.SRC_IN);
mImageView.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 464a4ab1..a8cf40d2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -39,7 +39,6 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.DataSource;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
@@ -70,6 +69,7 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
+import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing;
@@ -127,7 +127,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private Retrofit mOauthRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
- private int mImageViewWidth;
private String mAccessToken;
private RequestManager mGlide;
private Locale mLocale;
@@ -207,7 +206,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
- CustomThemeWrapper customThemeWrapper, Locale locale, int imageViewWidth,
+ CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
SharedPreferences postHistorySharedPreferences,
@@ -221,7 +220,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mOauthRetrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
- mImageViewWidth = imageViewWidth;
mAccessToken = accessToken;
mPostType = postType;
mDisplaySubredditName = displaySubredditName;
@@ -677,11 +675,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
if (preview != null) {
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
- if (mImageViewWidth > preview.getPreviewWidth()) {
- mGlide.load(preview.getPreviewUrl()).override(Target.SIZE_ORIGINAL).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
- } else {
- mGlide.load(preview.getPreviewUrl()).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
- }
+ mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
} else {
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
}
@@ -775,8 +769,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostWithPreviewTypeViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -810,11 +802,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
if (preview != null) {
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
- if (mImageViewWidth > preview.getPreviewWidth()) {
- mGlide.load(preview.getPreviewUrl()).override(Target.SIZE_ORIGINAL).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
- } else {
- mGlide.load(preview.getPreviewUrl()).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
- }
+ mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
} else {
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
}
@@ -910,8 +898,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostCard2WithPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostCard2WithPreviewViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1292,8 +1278,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1328,8 +1312,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1354,8 +1336,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1380,8 +1360,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1416,8 +1394,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
} else {
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1448,29 +1424,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
for (int i = previews.size() - 1; i >= 1; i--) {
preview = previews.get(i);
- if (mImageViewWidth >= preview.getPreviewWidth()) {
- if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
- return preview;
- }
- } else {
- int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
- if (mImageViewWidth * height <= 5_000_000) {
- preview.setPreviewWidth(mImageViewWidth);
- preview.setPreviewHeight(height);
- return preview;
- }
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
+ return preview;
}
}
}
-
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
- int divisor = 2;
- do {
- preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
- preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
- divisor *= 2;
- } while (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000);
- }
return preview;
}
@@ -1495,7 +1453,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else {
- imageRequestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE).override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostWithPreviewTypeViewHolder) holder).imageView);
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostWithPreviewTypeViewHolder) holder).imageView);
}
}
} else if (holder instanceof PostCompactBaseViewHolder) {
@@ -1535,11 +1493,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostGalleryViewHolder) holder).imageView);
} else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostGalleryViewHolder) holder).imageView);
- } else {
- imageRequestBuilder.into(((PostGalleryViewHolder) holder).imageView);
- }
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostGalleryViewHolder) holder).imageView);
}
}
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
@@ -1559,11 +1513,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostCard2WithPreviewViewHolder) holder).imageView);
} else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostCard2WithPreviewViewHolder) holder).imageView);
- } else {
- imageRequestBuilder.into(((PostCard2WithPreviewViewHolder) holder).imageView);
- }
+ imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostCard2WithPreviewViewHolder) holder).imageView);
}
}
}
@@ -1917,12 +1867,15 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
private void openViewPostDetailActivity(Post post, int position) {
- Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
- intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
- intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
- intent.putExtra(ViewPostDetailActivity.EXTRA_POST_FRAGMENT_ID, mFragment.getPostFragmentId());
- intent.putExtra(ViewPostDetailActivity.EXTRA_IS_NSFW_SUBREDDIT, mFragment.getIsNsfwSubreddit());
- mActivity.startActivity(intent);
+ if (canStartActivity) {
+ canStartActivity = false;
+ Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
+ intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
+ intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
+ intent.putExtra(ViewPostDetailActivity.EXTRA_POST_FRAGMENT_ID, mFragment.getPostFragmentId());
+ intent.putExtra(ViewPostDetailActivity.EXTRA_IS_NSFW_SUBREDDIT, mFragment.getIsNsfwSubreddit());
+ mActivity.startActivity(intent);
+ }
}
private void openMedia(Post post) {
@@ -2114,7 +2067,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post post = getItem(position);
if (post != null) {
markPostRead(post, true);
- canStartActivity = false;
openViewPostDetailActivity(post, getBindingAdapterPosition());
}
@@ -3161,8 +3113,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post post = getItem(position);
if (post != null && canStartActivity) {
markPostRead(post, true);
- canStartActivity = false;
-
openViewPostDetailActivity(post, getBindingAdapterPosition());
}
});
@@ -3751,7 +3701,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post post = getItem(position);
if (post != null) {
markPostRead(post, true);
- canStartActivity = false;
if (post.getPostType() == Post.TEXT_TYPE || !mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
openViewPostDetailActivity(post, getBindingAdapterPosition());
@@ -3768,7 +3717,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post post = getItem(position);
if (post != null) {
markPostRead(post, true);
- canStartActivity = false;
if (post.getPostType() == Post.TEXT_TYPE || mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
openViewPostDetailActivity(post, getBindingAdapterPosition());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
index 8fe78d79..180b74be 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
@@ -28,6 +28,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R;
@@ -37,6 +41,7 @@ import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.message.Message;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -66,8 +71,21 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
mLocale = locale;
mAccountName = accountName;
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
+ @NonNull
+ @Override
+ public String processMarkdown(@NonNull String markdown) {
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
+ }
+
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
index 454ecdd4..13e5e6a1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
@@ -23,6 +23,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
@@ -31,6 +35,8 @@ import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
+import ml.docilealligator.infinityforreddit.utils.Utils;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private Markwon markwon;
@@ -40,8 +46,21 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) {
markwon = Markwon.builder(activity)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
+ @NonNull
+ @Override
+ public String processMarkdown(@NonNull String markdown) {
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
+ }
+
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
@@ -57,7 +76,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
builder.linkColor(customThemeWrapper.getLinkColor());
}
})
- .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> {
if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
index d8cf1fe9..e30156dc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java
@@ -6,6 +6,7 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
+import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -72,7 +73,7 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
}
if (markdownText != null) {
- markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
+ //markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
copyMarkdownTextView.setOnClickListener(view -> {
showCopyDialog(markdownText);
dismiss();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
index 5a596308..e65b97f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
@@ -3,16 +3,25 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import androidx.core.content.ContextCompat;
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class WallpaperChangeReceiver extends BroadcastReceiver {
+ private SharedPreferences sharedPreferences;
+
+ public WallpaperChangeReceiver(SharedPreferences sharedPreferences) {
+ this.sharedPreferences = sharedPreferences;
+ }
@Override
public void onReceive(Context context, Intent intent) {
- Intent materialYouIntent = new Intent(context, MaterialYouService.class);
- ContextCompat.startForegroundService(context, materialYouIntent);
+ if (sharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
+ Intent materialYouIntent = new Intent(context, MaterialYouService.class);
+ ContextCompat.startForegroundService(context, materialYouIntent);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/SpoilerOnClickTextView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/SpoilerOnClickTextView.java
new file mode 100644
index 00000000..a34f644a
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/SpoilerOnClickTextView.java
@@ -0,0 +1,30 @@
+package ml.docilealligator.infinityforreddit.customviews;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import androidx.annotation.Nullable;
+
+public class SpoilerOnClickTextView extends androidx.appcompat.widget.AppCompatTextView {
+ private boolean isSpoilerOnClick;
+
+ public SpoilerOnClickTextView(Context context) {
+ super(context);
+ }
+
+ public SpoilerOnClickTextView(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SpoilerOnClickTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public boolean isSpoilerOnClick() {
+ return isSpoilerOnClick;
+ }
+
+ public void setSpoilerOnClick(boolean spoilerOnClick) {
+ isSpoilerOnClick = spoilerOnClick;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
index 04cabb7a..34c67ecd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
@@ -307,9 +307,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
if (hasComment) {
mFetchCommentInfoLinearLayout.setVisibility(View.GONE);
} else {
- mFetchCommentInfoLinearLayout.setOnClickListener(view -> {
- //Do nothing
- });
+ mFetchCommentInfoLinearLayout.setOnClickListener(null);
showErrorView(R.string.no_comments);
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index c578c437..257f604e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -17,7 +17,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
-import android.util.DisplayMetrics;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -338,10 +337,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
- DisplayMetrics displayMetrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
- int windowWidth = displayMetrics.widthPixels;
-
mGlide = Glide.with(activity);
lazyModeRunnable = new LazyModeRunnable() {
@@ -452,7 +447,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, true,
+ accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -529,7 +524,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName,
+ accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -600,7 +595,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, true,
+ accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -665,7 +660,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, true,
+ accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -726,7 +721,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, true,
+ accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -786,7 +781,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, true,
+ accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -840,7 +835,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mCustomThemeWrapper, locale,
- windowWidth, accessToken, accountName, postType, postLayout, true,
+ accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -891,7 +886,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
StaggeredGridLayoutManagerItemOffsetDecoration itemDecoration =
new StaggeredGridLayoutManagerItemOffsetDecoration(activity, R.dimen.staggeredLayoutManagerItemOffset, nColumns);
mPostRecyclerView.addItemDecoration(itemDecoration);
- windowWidth /= 2;
}
if (recyclerViewPosition > 0) {
@@ -1704,6 +1698,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
public void markPostAsRead(Post post) {
+ if (readPosts == null) {
+ readPosts = new ArrayList<>();
+ }
readPosts.add(post.getId());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
index d7a77b07..a7116540 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
@@ -35,6 +35,10 @@ import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.html.HtmlPlugin;
+import io.noties.markwon.html.tag.SuperScriptHandler;
+import io.noties.markwon.inlineparser.BangInlineProcessor;
+import io.noties.markwon.inlineparser.HtmlInlineProcessor;
+import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.noties.markwon.recycler.MarkwonAdapter;
@@ -54,6 +58,8 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
+import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
+import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Retrofit;
public class SidebarFragment extends Fragment {
@@ -104,8 +110,21 @@ public class SidebarFragment extends Fragment {
markdownColor = mCustomThemeWrapper.getPrimaryTextColor();
Markwon markwon = Markwon.builder(activity)
- .usePlugin(HtmlPlugin.create())
+ .usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
+ plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
+ plugin.excludeInlineProcessor(BangInlineProcessor.class);
+ plugin.addInlineProcessor(new SuperscriptInlineProcessor());
+ }))
+ .usePlugin(HtmlPlugin.create(plugin -> {
+ plugin.excludeDefaults(true).addHandler(new SuperScriptHandler());
+ }))
.usePlugin(new AbstractMarkwonPlugin() {
+ @NonNull
+ @Override
+ public String processMarkdown(@NonNull String markdown) {
+ return super.processMarkdown(Utils.fixSuperScript(markdown));
+ }
+
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
textView.setTextColor(markdownColor);
@@ -137,7 +156,8 @@ public class SidebarFragment extends Fragment {
}
})
.usePlugin(StrikethroughPlugin.create())
- .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, recyclerView).setOnLinkLongClickListener((textView, url) -> {
+ .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> {
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
@@ -145,7 +165,6 @@ public class SidebarFragment extends Fragment {
urlMenuBottomSheetFragment.show(getChildFragmentManager(), urlMenuBottomSheetFragment.getTag());
return true;
})))
- .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(TableEntryPlugin.create(activity))
.build();
MarkwonAdapter markwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index e912418d..0a2ec296 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -16,7 +16,6 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
-import android.util.DisplayMetrics;
import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -67,6 +66,7 @@ import butterknife.ButterKnife;
import im.ene.toro.exoplayer.ExoCreator;
import im.ene.toro.media.PlaybackInfo;
import im.ene.toro.media.VolumeInfo;
+import im.ene.toro.widget.Container;
import ml.docilealligator.infinityforreddit.DeleteThing;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
@@ -224,7 +224,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
private boolean mExpandChildren;
private boolean mSeparatePostAndComments = false;
private boolean mMarkPostsAsRead;
- private int mWindowWidth;
private ConcatAdapter mConcatAdapter;
private PostDetailRecyclerViewAdapter mPostAdapter;
private CommentsRecyclerViewAdapter mCommentsAdapter;
@@ -290,10 +289,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
showToast = true;
}
- DisplayMetrics displayMetrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
- mWindowWidth = displayMetrics.widthPixels;
-
mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
mSwipeUpToHideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
@@ -550,7 +545,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide,
- mWindowWidth, mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
+ mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
@@ -1195,7 +1190,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
- mRedditDataRoomDatabase, mGlide, mWindowWidth, mSeparatePostAndComments,
+ mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
mExoCreator,
@@ -1736,28 +1731,32 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
public void scrollToNextParentComment() {
- int currentPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
- if (mCommentsAdapter != null) {
- int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
+ RecyclerView chooseYourView = mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView;
+ if (mCommentsAdapter != null && chooseYourView != null) {
+ int currentPosition = ((LinearLayoutManagerBugFixed) chooseYourView.getLayoutManager()).findFirstVisibleItemPosition();
+ //int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
+ int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? currentPosition - 1 : currentPosition);
if (nextParentPosition < 0) {
return;
}
- mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition);
+ mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? nextParentPosition + 1 : nextParentPosition);
mIsSmoothScrolling = true;
- (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller);
+ chooseYourView.getLayoutManager().startSmoothScroll(mSmoothScroller);
}
}
public void scrollToPreviousParentComment() {
- int currentPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
- if (mCommentsAdapter != null) {
- int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
+ RecyclerView chooseYourView = mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView;
+ if (mCommentsAdapter != null && chooseYourView != null) {
+ int currentPosition = ((LinearLayoutManagerBugFixed) chooseYourView.getLayoutManager()).findFirstVisibleItemPosition();
+ //int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
+ int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? currentPosition - 1 : currentPosition);
if (previousParentPosition < 0) {
return;
}
- mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition);
+ mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? previousParentPosition + 1 : previousParentPosition);
mIsSmoothScrolling = true;
- (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller);
+ chooseYourView.getLayoutManager().startSmoothScroll(mSmoothScroller);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java
index 66921637..5b7dcb2c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java
@@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.fragments;
+import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@@ -207,11 +208,14 @@ public class ViewRPANBroadcastFragment extends Fragment {
hdButton.setVisibility(View.VISIBLE);
hdButton.setOnClickListener(view -> {
- TrackSelectionDialogBuilder build = new TrackSelectionDialogBuilder(mActivity,
+ TrackSelectionDialogBuilder builder = new TrackSelectionDialogBuilder(mActivity,
getString(R.string.select_video_quality), trackSelector, 0);
- build.setShowDisableOption(true);
- build.setAllowAdaptiveSelections(false);
- build.build().show();
+ builder.setShowDisableOption(true);
+ builder.setAllowAdaptiveSelections(false);
+ AlertDialog alertDialog = builder.build();
+ alertDialog.show();
+ alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
+ alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
});
for (int i = 0; i < trackGroups.length; i++) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
index 05f0ab7a..494d6b44 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
@@ -427,7 +427,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@Override
public void onDestroyView() {
super.onDestroyView();
- BigImageViewer.imageLoader().cancelAll();
+ imageView.cancel();
SubsamplingScaleImageView subsamplingScaleImageView = imageView.getSSIV();
if (subsamplingScaleImageView != null) {
subsamplingScaleImageView.recycle();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/BlockQuoteWithExceptionParser.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/BlockQuoteWithExceptionParser.java
new file mode 100644
index 00000000..f500bb93
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/BlockQuoteWithExceptionParser.java
@@ -0,0 +1,85 @@
+package ml.docilealligator.infinityforreddit.markdown;
+
+import org.commonmark.internal.util.Parsing;
+import org.commonmark.node.Block;
+import org.commonmark.node.BlockQuote;
+import org.commonmark.parser.block.AbstractBlockParser;
+import org.commonmark.parser.block.AbstractBlockParserFactory;
+import org.commonmark.parser.block.BlockContinue;
+import org.commonmark.parser.block.BlockStart;
+import org.commonmark.parser.block.MatchedBlockParser;
+import org.commonmark.parser.block.ParserState;
+
+// Parse and consume a block quote except when it's a spoiler opening
+public class BlockQuoteWithExceptionParser extends AbstractBlockParser {
+ private final BlockQuote block = new BlockQuote();
+
+ private static boolean isMarker(ParserState state, int index) {
+ CharSequence line = state.getLine();
+ return state.getIndent() < Parsing.CODE_BLOCK_INDENT && index < line.length() && line.charAt(index) == '>';
+ }
+
+ private static boolean isMarkerSpoiler(ParserState state, int index) {
+ CharSequence line = state.getLine();
+ int length = line.length();
+ try {
+ return state.getIndent() < Parsing.CODE_BLOCK_INDENT && index < length && line.charAt(index) == '>' && (index + 1) < length && line.charAt(index + 1) == '!';
+ } catch (IndexOutOfBoundsException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isContainer() {
+ return true;
+ }
+
+ @Override
+ public boolean canContain(Block block) {
+ return true;
+ }
+
+ @Override
+ public BlockQuote getBlock() {
+ return block;
+ }
+
+ @Override
+ public BlockContinue tryContinue(ParserState state) {
+ int nextNonSpace = state.getNextNonSpaceIndex();
+ if (isMarker(state, nextNonSpace)) {
+ int newColumn = state.getColumn() + state.getIndent() + 1;
+ // optional following space or tab
+ if (Parsing.isSpaceOrTab(state.getLine(), nextNonSpace + 1)) {
+ newColumn++;
+ }
+ return BlockContinue.atColumn(newColumn);
+ } else {
+ return BlockContinue.none();
+ }
+ }
+
+ public static class Factory extends AbstractBlockParserFactory {
+ public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) {
+ int nextNonSpace = state.getNextNonSpaceIndex();
+ // Potential for a spoiler opening
+ // We don't check for spoiler closing, neither does Reddit
+ if (isMarkerSpoiler(state, nextNonSpace)) {
+ // It might be a spoiler, don't consume
+ return BlockStart.none();
+ }
+ // Not a spoiler then
+ else if (isMarker(state, nextNonSpace)) {
+ int newColumn = state.getColumn() + state.getIndent() + 1;
+ // optional following space or tab
+ if (Parsing.isSpaceOrTab(state.getLine(), nextNonSpace + 1)) {
+ newColumn++;
+ }
+ return BlockStart.of(new BlockQuoteWithExceptionParser()).atColumn(newColumn);
+ } else {
+ return BlockStart.none();
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java
new file mode 100644
index 00000000..1cca0cfe
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerParserPlugin.java
@@ -0,0 +1,202 @@
+package ml.docilealligator.infinityforreddit.markdown;
+
+import android.graphics.Color;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+import org.commonmark.node.Block;
+import org.commonmark.node.BlockQuote;
+import org.commonmark.node.HtmlBlock;
+import org.commonmark.node.HtmlInline;
+import org.commonmark.parser.Parser;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+
+import io.noties.markwon.AbstractMarkwonPlugin;
+import io.noties.markwon.core.CorePlugin;
+import io.noties.markwon.core.spans.CodeBlockSpan;
+import io.noties.markwon.core.spans.CodeSpan;
+
+public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
+ private final int textColor;
+ private final int backgroundColor;
+
+ SpoilerParserPlugin(int textColor, int backgroundColor) {
+ this.textColor = textColor;
+ this.backgroundColor = backgroundColor;
+ }
+
+ public static SpoilerParserPlugin create(@NonNull int textColor, @NonNull int backgroundColor) {
+ return new SpoilerParserPlugin(textColor, backgroundColor);
+ }
+
+ @Override
+ public void configureParser(@NonNull Parser.Builder builder) {
+ builder.customBlockParserFactory(new BlockQuoteWithExceptionParser.Factory());
+
+ Set<Class<? extends Block>> blocks = CorePlugin.enabledBlockTypes();
+ blocks.remove(HtmlBlock.class);
+ blocks.remove(HtmlInline.class);
+ blocks.remove(BlockQuote.class);
+
+ builder.enabledBlockTypes(blocks);
+ }
+
+ @Override
+ public void afterSetText(@NonNull TextView textView) {
+ textView.setHighlightColor(Color.TRANSPARENT);
+
+ if(textView.getText().length() < 5) {
+ return;
+ }
+
+ SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText());
+
+ LinkedHashMap<Integer, Integer> spoilers = parse(markdownStringBuilder);
+ if(spoilers.size() == 0) {
+ return;
+ }
+ int offset = 2;
+
+ for (Map.Entry<Integer, Integer> entry : spoilers.entrySet()) {
+ int spoilerStart = entry.getKey() - offset;
+ int spoilerEnd = entry.getValue() - offset;
+
+ // Try not to set a spoiler span if it's inside a CodeSpan
+ CodeSpan[] codeSpans = markdownStringBuilder.getSpans(spoilerStart, spoilerEnd, CodeSpan.class);
+ CodeBlockSpan[] codeBlockSpans = markdownStringBuilder.getSpans(spoilerStart, spoilerEnd, CodeBlockSpan.class);
+
+ if (codeSpans.length == 0 && codeBlockSpans.length == 0) {
+ markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
+ markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
+ SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
+ markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ offset += 4;
+ }
+
+ for (CodeSpan codeSpan : codeSpans) {
+ int spanBeginning = markdownStringBuilder.getSpanStart(codeSpan);
+ int spanEnd = markdownStringBuilder.getSpanEnd(codeSpan);
+ if (spoilerStart + 2 <= spanBeginning && spanEnd <= spoilerEnd + 2) {
+ markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
+ markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
+ SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
+ markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ offset += 4;
+ } else {
+ break;
+ }
+ }
+
+ for (CodeBlockSpan codeBlockSpan : codeBlockSpans) {
+ int spanBeginning = markdownStringBuilder.getSpanStart(codeBlockSpan);
+ int spanEnd = markdownStringBuilder.getSpanEnd(codeBlockSpan);
+ if (spoilerStart + 2 <= spanBeginning && spanEnd <= spoilerEnd + 2) {
+ markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
+ markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
+ SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
+ markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ offset += 4;
+ } else {
+ break;
+ }
+ }
+ }
+ if(offset > 2) {
+ textView.setText(markdownStringBuilder);
+ }
+ }
+
+ // Very naive implementation, needs to be improved for efficiency and edge cases
+ // Don't allow more than one new line after every non-blank line
+ // Try not to care about recursing spoilers, we just want the outermost spoiler because
+ // spoiler revealing-hiding breaks with recursing spoilers
+ private LinkedHashMap<Integer, Integer> parse(SpannableStringBuilder markdown) {
+ final int MAX_NEW_LINE = 1;
+ var openSpoilerStack = new Stack<Integer>();
+ var closedSpoilerMap = new LinkedHashMap<Integer, Integer>();
+ int variable_max_depth = calculateBalance(0, markdown) + 1;
+ int new_lines = 0;
+ int depth = 0;
+ for (int i = 0; i < markdown.length(); i++) {
+ if (markdown.charAt(i) == '\u2000' || markdown.charAt(i) == '\t') {
+ continue;
+ } else if (markdown.charAt(i) == '>' && (i + 1) < markdown.length() && markdown.charAt(i + 1) == '!') {
+ openSpoilerStack.push(i + 1);
+ depth++;
+ } else if (openSpoilerStack.size() > 0
+ && markdown.charAt(i) == '!' && (i + 1) < markdown.length()
+ && markdown.charAt(i + 1) == '<') {
+ var pos = i + 1;
+ for (int j = 0; j < depth; j++) {
+ if (!openSpoilerStack.isEmpty()) pos = openSpoilerStack.peek();
+ if (pos + 1 <= i) {
+ if (!openSpoilerStack.isEmpty()) pos = openSpoilerStack.peek();
+ break;
+ } else {
+ if (!openSpoilerStack.isEmpty()) pos = openSpoilerStack.pop();
+ }
+ }
+ if (depth <= variable_max_depth && pos + 1 <= i) //Spoiler content cannot be zero or less length
+ {
+ openSpoilerStack.clear();
+ closedSpoilerMap.put(pos + 1, i);
+ }
+ depth--;
+ } else if (markdown.charAt(i) == '\n') {
+ new_lines++;
+ if (openSpoilerStack.size() >= 1 && new_lines > MAX_NEW_LINE) {
+ openSpoilerStack.clear();
+ new_lines = 0;
+ depth = 0;
+ variable_max_depth = calculateBalance(i, markdown) + 1;
+ }
+ } else {
+ new_lines = 0;
+ }
+
+ if (openSpoilerStack.size() >= 32) // No
+ {
+ openSpoilerStack.clear();
+ closedSpoilerMap.clear();
+ continue;
+ }
+ }
+ return closedSpoilerMap;
+ }
+
+ private int calculateBalance(int index, SpannableStringBuilder line) {
+ final int MAX_NEW_LINE = 1;
+ int new_lines = 0;
+ int opening = 0;
+ int closing = 0;
+ for (int i = index; i < line.length(); i++) {
+ if (line.charAt(i) == '\u0020' || line.charAt(i) == '\t') {
+ continue;
+ } else if (line.charAt(i) == '>'
+ && (i + 1) < line.length()
+ && line.charAt(i + 1) == '!') {
+ opening++;
+ } else if (line.charAt(i) == '!' && (i + 1) < line.length()
+ && line.charAt(i + 1) == '<') {
+ closing++;
+ } else if (line.charAt(i) == '\n') {
+ new_lines++;
+ if (new_lines > MAX_NEW_LINE) {
+ break;
+ }
+ } else {
+ new_lines = 0;
+ continue;
+ }
+ }
+ return Math.abs(opening - closing);
+ }
+
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerSpan.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerSpan.java
new file mode 100644
index 00000000..2264449c
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SpoilerSpan.java
@@ -0,0 +1,64 @@
+package ml.docilealligator.infinityforreddit.markdown;
+
+import android.text.Layout;
+import android.text.Spannable;
+import android.text.TextPaint;
+import android.text.style.ClickableSpan;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.transition.AutoTransition;
+import androidx.transition.TransitionManager;
+
+import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
+
+public class SpoilerSpan extends ClickableSpan {
+ final int textColor;
+ final int backgroundColor;
+ private boolean isShowing = false;
+
+ public SpoilerSpan(@NonNull int textColor, @NonNull int backgroundColor) {
+ this.textColor = textColor;
+ this.backgroundColor = backgroundColor;
+ }
+
+ @Override
+ public void onClick(@NonNull View widget) {
+ if (!(widget instanceof TextView)) {
+ return;
+ }
+
+ final TextView textView = (TextView) widget;
+ final Spannable spannable = (Spannable) textView.getText();
+
+ final int end = spannable.getSpanEnd(this);
+
+ if (end < 0) {
+ return;
+ }
+
+ final Layout layout = textView.getLayout();
+ if (layout == null) {
+ return;
+ }
+
+ if (widget instanceof SpoilerOnClickTextView) {
+ ((SpoilerOnClickTextView) textView).setSpoilerOnClick(true);
+ }
+ isShowing = !isShowing;
+ widget.invalidate();
+ }
+
+ @Override
+ public void updateDrawState(@NonNull TextPaint ds) {
+ if (isShowing) {
+ ds.bgColor = backgroundColor & 0x0D000000; //Slightly darker background color for revealed spoiler
+ super.updateDrawState(ds);
+ } else {
+ ds.bgColor = backgroundColor;
+ }
+ ds.setColor(textColor);
+ ds.setUnderlineText(false);
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptInlineProcessor.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptInlineProcessor.java
new file mode 100644
index 00000000..27f4d1e4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptInlineProcessor.java
@@ -0,0 +1,32 @@
+package ml.docilealligator.infinityforreddit.markdown;
+
+import androidx.annotation.Nullable;
+
+import org.commonmark.node.HtmlInline;
+import org.commonmark.node.Node;
+
+import java.util.regex.Pattern;
+
+import io.noties.markwon.inlineparser.InlineProcessor;
+
+public class SuperscriptInlineProcessor extends InlineProcessor {
+ private static final Pattern HTML_TAG = Pattern.compile("</?sup>", Pattern.CASE_INSENSITIVE);
+
+ @Override
+ public char specialCharacter() {
+ return '<';
+ }
+
+ @Nullable
+ @Override
+ protected Node parse() {
+ String m = match(HTML_TAG);
+ if (m != null) {
+ HtmlInline node = new HtmlInline();
+ node.setLiteral(m);
+ return node;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
index dddbda85..44f45eef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
@@ -492,26 +492,26 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab3AddImageView.setOnClickListener(view -> selectName(2));
- showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
- showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
+ showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
+ showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
showMultiredditsLinearLayout.setOnClickListener(view -> {
showMultiredditsSwitchMaterial.performClick();
});
- showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
- showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
+ showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
+ showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
showFavoriteMultiredditsSwitchMaterial.performClick();
});
- showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
- showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
+ showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
+ showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
showSubscribedSubredditsSwitchMaterial.performClick();
});
- showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
- showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
+ showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
+ showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java
index 5293bc71..f66fe648 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java
@@ -1,28 +1,30 @@
package ml.docilealligator.infinityforreddit.utils;
import android.graphics.Bitmap;
+
import androidx.annotation.NonNull;
+
import com.google.gson.Gson;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.subreddit.SubredditSettingData;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
-import org.json.JSONException;
-import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
-import java.io.ByteArrayOutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
public final class EditProfileUtils {
-
-
public static void updateProfile(Retrofit oauthRetrofit,
String accessToken,
String accountName,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
index 63c3d9f2..9d5f27cb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
@@ -48,72 +48,75 @@ public class MaterialYouUtils {
SharedPreferences amoledThemeSharedPreferences,
@Nullable MaterialYouListener materialYouListener) {
executor.execute(() -> {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) { }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
CustomTheme lightTheme = CustomThemeWrapper.getIndigo(context);
CustomTheme darkTheme = CustomThemeWrapper.getIndigoDark(context);
CustomTheme amoledTheme = CustomThemeWrapper.getIndigoAmoled(context);
-
- lightTheme.colorPrimary = context.getColor(android.R.color.system_accent1_300);
- lightTheme.colorPrimaryDark = context.getColor(android.R.color.system_accent1_500);
+ lightTheme.colorPrimary = context.getColor(android.R.color.system_accent1_100);
+ lightTheme.colorPrimaryDark = lightTheme.colorPrimary;
lightTheme.colorAccent = context.getColor(android.R.color.system_accent3_300);
- lightTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_200);
- lightTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_10);
+ lightTheme.colorPrimaryLightTheme = lightTheme.colorPrimary;
+ lightTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_100);
lightTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
lightTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
- lightTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_100);
- lightTheme.bottomAppBarBackgroundColor = context.getColor(android.R.color.system_accent2_100);
- lightTheme.navBarColor = context.getColor(android.R.color.system_neutral2_100);
+ lightTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
+ lightTheme.bottomAppBarBackgroundColor = lightTheme.colorPrimary;
+ lightTheme.navBarColor = lightTheme.colorPrimary;
lightTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_900);
- lightTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_900);
- lightTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_400);;
+ lightTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_700);
+ lightTheme.buttonTextColor = context.getColor(android.R.color.system_accent1_800);
+ lightTheme.bottomAppBarIconColor = lightTheme.buttonTextColor;
lightTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_400);
- lightTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_10);
- lightTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent1_50);
- lightTheme.toolbarSecondaryTextColor = context.getColor(android.R.color.system_accent3_50);
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_50);
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_50);
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_50);
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_50);
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_50);
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_50);
+ lightTheme.fabIconColor = lightTheme.buttonTextColor;
+ lightTheme.toolbarPrimaryTextAndIconColor = lightTheme.buttonTextColor;
+ lightTheme.toolbarSecondaryTextColor = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = lightTheme.colorPrimary;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = lightTheme.backgroundColor;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = lightTheme.buttonTextColor;
lightTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_10);
- lightTheme.dividerColor = context.getColor(android.R.color.system_neutral1_100);
- lightTheme.isLightStatusBar = false;
+ lightTheme.dividerColor = context.getColor(android.R.color.system_neutral1_400);
+ lightTheme.isLightStatusBar = true;
lightTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
lightTheme.name = "Material You";
- darkTheme.colorPrimary = context.getColor(android.R.color.system_accent1_100);
- darkTheme.colorPrimaryDark = context.getColor(android.R.color.system_accent1_300);
+ darkTheme.colorPrimary = context.getColor(android.R.color.system_accent2_800);
+ darkTheme.colorPrimaryDark = darkTheme.colorPrimary;
darkTheme.colorAccent = context.getColor(android.R.color.system_accent3_100);
- darkTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_100);
+ darkTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_300);
darkTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_900);
darkTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
darkTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
darkTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
darkTheme.bottomAppBarBackgroundColor = context.getColor(android.R.color.system_accent2_800);
- darkTheme.navBarColor = context.getColor(android.R.color.system_neutral2_800);
+ darkTheme.navBarColor = darkTheme.colorPrimary;
darkTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_10);
darkTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_10);
darkTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_100);;
darkTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_100);
darkTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
- darkTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent1_900);
- darkTheme.toolbarSecondaryTextColor = context.getColor(android.R.color.system_accent3_900);
- darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_800);
- darkTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_800);
- darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_800);
- darkTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_800);
- darkTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_800);
- darkTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_800);
+ darkTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent2_100);
+ darkTheme.toolbarSecondaryTextColor = darkTheme.toolbarPrimaryTextAndIconColor;
+ darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = darkTheme.toolbarPrimaryTextAndIconColor;
+ darkTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = darkTheme.toolbarPrimaryTextAndIconColor;
+ darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = darkTheme.colorPrimary;
+ darkTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = darkTheme.backgroundColor;
+ darkTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = darkTheme.bottomAppBarIconColor;
+ darkTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = darkTheme.bottomAppBarIconColor;
darkTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_900);
darkTheme.dividerColor = context.getColor(android.R.color.system_neutral1_600);
- darkTheme.isLightStatusBar = true;
darkTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
darkTheme.name = "Material You Dark";
amoledTheme.colorAccent = context.getColor(android.R.color.system_accent1_100);
- amoledTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent3_100);
+ amoledTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_300);
+ amoledTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
amoledTheme.name = "Material You Amoled";
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
@@ -173,7 +176,7 @@ public class MaterialYouUtils {
lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = colorPrimaryInt;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = colorPrimaryInt;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = backgroundColor;
lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
lightTheme.circularProgressBarBackground = colorPrimaryInt;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
index ad2b7405..f292088d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
@@ -72,10 +72,13 @@ public class Utils {
.replaceAll("(^|^ *|\\n *)#####(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)######(?!($|\\s|#))", "$0 "));
- return fixSuperScript(regexed);
+ //return fixSuperScript(regexed);
+ // We don't want to fix super scripts here because we need the original markdown later for editing posts
+ return regexed.toString();
}
- private static String fixSuperScript(StringBuilder regexed) {
+ public static String fixSuperScript(String regexedMarkdown) {
+ StringBuilder regexed = new StringBuilder(regexedMarkdown);
boolean hasBracket = false;
int nCarets = 0;
for (int i = 0; i < regexed.length(); i++) {
diff --git a/app/src/main/res/layout-land/fragment_view_post_detail.xml b/app/src/main/res/layout-land/fragment_view_post_detail.xml
index 3b35b38b..02bba243 100644
--- a/app/src/main/res/layout-land/fragment_view_post_detail.xml
+++ b/app/src/main/res/layout-land/fragment_view_post_detail.xml
@@ -23,6 +23,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
+ android:paddingBottom="144dp"
android:clipToPadding="false"
app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
diff --git a/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml b/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml
index d1637b0c..dd688bfc 100644
--- a/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml
+++ b/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml
@@ -23,6 +23,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
+ android:paddingBottom="144dp"
android:clipToPadding="false"
app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml
index 453ad5c4..4f3ad007 100644
--- a/app/src/main/res/layout/activity_edit_profile.xml
+++ b/app/src/main/res/layout/activity_edit_profile.xml
@@ -13,14 +13,23 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/toolbar_view_edit_profile_activity"
+ <com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_edit_profile_activity"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?attr/actionBarSize"
- app:navigationIcon="?attr/homeAsUpIndicator"
- app:popupTheme="@style/AppTheme.PopupOverlay"
- app:title="@string/action_edit_profile" />
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:titleEnabled="false"
+ app:toolbarId="@+id/toolbar_post_text_activity">
+
+ <com.google.android.material.appbar.MaterialToolbar
+ android:id="@+id/toolbar_view_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?attr/actionBarSize"
+ app:navigationIcon="?attr/homeAsUpIndicator"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
+
+ </com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
@@ -42,130 +51,121 @@
<FrameLayout
android:id="@+id/frame_layout_view_banner_edit_profile_activity"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="8dp">
+ android:layout_height="wrap_content">
- <ImageView
+ <pl.droidsonroids.gif.GifImageView
android:id="@+id/image_view_banner_edit_profile_activity"
android:layout_width="match_parent"
android:layout_height="180dp"
- android:contentDescription="@null"
android:scaleType="centerCrop"
tools:src="@tools:sample/backgrounds/scenic" />
<ImageView
android:id="@+id/image_view_change_banner_edit_profile_activity"
- android:layout_width="32dp"
- android:layout_height="32dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
- android:layout_margin="4dp"
+ android:layout_margin="8dp"
+ android:padding="8dp"
android:background="@drawable/ic_dot_outline"
- android:contentDescription="@null"
- android:padding="4dp"
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
</FrameLayout>
<FrameLayout
android:id="@+id/frame_layout_view_avatar_edit_profile_activity"
- android:layout_width="74dp"
- android:layout_height="74dp"
- android:layout_marginStart="24dp"
- android:layout_marginTop="143dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="144dp"
android:elevation="4dp">
- <ImageView
+ <pl.droidsonroids.gif.GifImageView
android:id="@+id/image_view_avatar_edit_profile_activity"
- android:layout_width="74dp"
- android:layout_height="74dp"
- android:contentDescription="@null"
+ android:layout_width="72dp"
+ android:layout_height="72dp"
tools:src="@tools:sample/avatars" />
<ImageView
android:id="@+id/image_view_change_avatar_edit_profile_activity"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_gravity="end|bottom"
- android:layout_margin="4dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:padding="8dp"
android:background="@drawable/ic_dot_outline"
- android:contentDescription="@null"
- android:padding="4dp"
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
</FrameLayout>
</FrameLayout>
- <View
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:layout_margin="8dp"
- android:background="?dividerVertical" />
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="8dp"
- android:orientation="vertical"
- android:padding="8dp">
+ android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:fontFamily="?attr/font_family"
+ android:paddingTop="48dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
android:text="@string/display_name_text"
- android:textSize="?attr/font_18" />
+ android:textSize="?attr/font_18"
+ android:fontFamily="?attr/font_family" />
<EditText
android:id="@+id/edit_text_display_name_edit_profile_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:gravity="top"
+ android:padding="16dp"
+ android:background="#00000000"
+ android:textSize="?attr/font_16"
+ android:fontFamily="?attr/font_family"
android:hint="@string/display_name_hint"
android:importantForAutofill="no"
android:inputType="textCapSentences"
- android:lines="1"
- android:maxLength="30"
- android:maxLines="1"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- android:paddingBottom="16dp" />
+ android:maxLength="30" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/display_name_description" />
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:text="@string/display_name_description"
+ android:textSize="?attr/font_12"
+ android:fontFamily="?attr/font_family" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="8dp"
- android:orientation="vertical"
- android:padding="8dp">
+ android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:fontFamily="?attr/font_family"
+ android:paddingTop="48dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
android:text="@string/about_you_text"
- android:textSize="?attr/font_18" />
+ android:textSize="?attr/font_18"
+ android:fontFamily="?attr/font_family" />
<EditText
android:id="@+id/edit_text_about_you_edit_profile_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:padding="16dp"
android:gravity="top"
+ android:background="#00000000"
+ android:textSize="?attr/font_16"
+ android:fontFamily="?attr/font_family"
android:hint="@string/about_you_hint"
android:importantForAutofill="no"
android:inputType="textCapSentences|textMultiLine"
- android:lines="4"
- android:maxLength="200"
- android:maxLines="4"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- android:paddingBottom="16dp" />
+ android:maxLength="200" />
</LinearLayout>
diff --git a/app/src/main/res/layout/activity_post_gallery.xml b/app/src/main/res/layout/activity_post_gallery.xml
index 150870e0..66fd39ac 100644
--- a/app/src/main/res/layout/activity_post_gallery.xml
+++ b/app/src/main/res/layout/activity_post_gallery.xml
@@ -36,9 +36,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="16dp"
android:paddingTop="8dp"
- android:paddingEnd="16dp"
android:paddingBottom="8dp">
<pl.droidsonroids.gif.GifImageView
@@ -46,7 +44,8 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentStart="true"
- android:layout_centerVertical="true" />
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp" />
<TextView
android:id="@+id/subreddit_name_text_view_post_gallery_activity"
@@ -54,7 +53,6 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/rules_button_post_gallery_activity"
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_gallery_activity"
android:text="@string/choose_a_subreddit"
@@ -67,16 +65,18 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
android:text="@string/rules"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</RelativeLayout>
- <View
+ <com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_1_post_gallery_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
@@ -93,7 +93,7 @@
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -107,7 +107,7 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,23 +121,16 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
- <View
- android:id="@+id/divider_2_post_gallery_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<LinearLayout
android:id="@+id/receive_post_reply_notifications_linear_layout_post_gallery_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dp"
- android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
@@ -164,10 +157,10 @@
</LinearLayout>
- <View
- android:id="@+id/divider_3_post_gallery_activity"
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_2_post_gallery_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<EditText
android:id="@+id/post_title_edit_text_post_gallery_activity"
@@ -182,11 +175,6 @@
android:textSize="?attr/title_font_18"
android:fontFamily="?attr/title_font_family" />
- <View
- android:id="@+id/divider_4_post_gallery_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/images_recycler_view_post_gallery_activity"
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/activity_post_image.xml b/app/src/main/res/layout/activity_post_image.xml
index 2e66a7ea..fc4c15cd 100644
--- a/app/src/main/res/layout/activity_post_image.xml
+++ b/app/src/main/res/layout/activity_post_image.xml
@@ -36,9 +36,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="16dp"
android:paddingTop="8dp"
- android:paddingEnd="16dp"
android:paddingBottom="8dp">
<pl.droidsonroids.gif.GifImageView
@@ -46,7 +44,8 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentStart="true"
- android:layout_centerVertical="true" />
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp" />
<TextView
android:id="@+id/subreddit_name_text_view_post_image_activity"
@@ -54,7 +53,6 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/rules_button_post_image_activity"
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_image_activity"
android:text="@string/choose_a_subreddit"
@@ -67,16 +65,18 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
android:text="@string/rules"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</RelativeLayout>
- <View
+ <com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_1_post_image_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
@@ -93,7 +93,7 @@
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -107,7 +107,7 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,23 +121,16 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
- <View
- android:id="@+id/divider_2_post_image_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<LinearLayout
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dp"
- android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
@@ -164,10 +157,10 @@
</LinearLayout>
- <View
- android:id="@+id/divider_3_post_image_activity"
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_2_post_image_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<EditText
android:id="@+id/post_title_edit_text_post_image_activity"
@@ -182,11 +175,6 @@
android:textSize="?attr/title_font_18"
android:fontFamily="?attr/title_font_family" />
- <View
- android:id="@+id/divider_4_post_image_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/select_image_constraint_layout_post_image_activity"
android:layout_width="match_parent"
@@ -197,6 +185,7 @@
android:id="@+id/capture_fab_post_image_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_margin="16dp"
android:src="@drawable/ic_outline_add_a_photo_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
@@ -209,6 +198,7 @@
android:id="@+id/select_from_library_fab_post_image_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_margin="16dp"
android:src="@drawable/ic_outline_select_photo_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
diff --git a/app/src/main/res/layout/activity_post_link.xml b/app/src/main/res/layout/activity_post_link.xml
index 427b8306..29c33d4b 100644
--- a/app/src/main/res/layout/activity_post_link.xml
+++ b/app/src/main/res/layout/activity_post_link.xml
@@ -36,9 +36,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="16dp"
android:paddingTop="8dp"
- android:paddingEnd="16dp"
android:paddingBottom="8dp">
<pl.droidsonroids.gif.GifImageView
@@ -46,7 +44,8 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentStart="true"
- android:layout_centerVertical="true" />
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp" />
<TextView
android:id="@+id/subreddit_name_text_view_post_link_activity"
@@ -54,7 +53,6 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/rules_button_post_link_activity"
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_link_activity"
android:text="@string/choose_a_subreddit"
@@ -67,16 +65,18 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
android:text="@string/rules"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</RelativeLayout>
- <View
+ <com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_1_post_link_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
@@ -93,7 +93,7 @@
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -107,7 +107,7 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,23 +121,16 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
- <View
- android:id="@+id/divider_2_post_link_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<LinearLayout
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dp"
- android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
@@ -164,16 +157,14 @@
</LinearLayout>
- <View
- android:id="@+id/divider_3_post_link_activity"
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_2_post_link_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="0dp"
- android:paddingEnd="16dp">
+ android:layout_height="wrap_content">
<EditText
android:id="@+id/post_title_edit_text_post_link_activity"
@@ -195,17 +186,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
android:text="@string/suggest_title"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout>
- <View
- android:id="@+id/divider_4_post_link_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<EditText
android:id="@+id/post_link_edit_text_post_link_activity"
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/activity_post_text.xml b/app/src/main/res/layout/activity_post_text.xml
index f18bf667..78728545 100644
--- a/app/src/main/res/layout/activity_post_text.xml
+++ b/app/src/main/res/layout/activity_post_text.xml
@@ -42,9 +42,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="16dp"
android:paddingTop="8dp"
- android:paddingEnd="16dp"
android:paddingBottom="8dp">
<pl.droidsonroids.gif.GifImageView
@@ -52,7 +50,8 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentStart="true"
- android:layout_centerVertical="true" />
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp" />
<TextView
android:id="@+id/subreddit_name_text_view_post_text_activity"
@@ -60,7 +59,6 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/rules_button_post_text_activity"
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_text_activity"
android:text="@string/choose_a_subreddit"
@@ -73,16 +71,18 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
android:text="@string/rules"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</RelativeLayout>
- <View
+ <com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_1_post_text_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
@@ -98,7 +98,7 @@
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -111,7 +111,7 @@
android:text="@string/spoiler"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -124,23 +124,16 @@
android:text="@string/nsfw"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
- <View
- android:id="@+id/divider_2_post_text_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<LinearLayout
android:id="@+id/receive_post_reply_notifications_linear_layout_post_text_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dp"
- android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
@@ -167,10 +160,10 @@
</LinearLayout>
- <View
- android:id="@+id/divider_3_post_text_activity"
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_2_post_text_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<EditText
android:id="@+id/post_title_edit_text_post_text_activity"
@@ -184,11 +177,6 @@
android:textSize="?attr/title_font_18"
android:fontFamily="?attr/title_font_family" />
- <View
- android:id="@+id/divider_4_post_text_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<EditText
android:id="@+id/post_text_content_edit_text_post_text_activity"
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/activity_post_video.xml b/app/src/main/res/layout/activity_post_video.xml
index e1c297cb..f9b34698 100644
--- a/app/src/main/res/layout/activity_post_video.xml
+++ b/app/src/main/res/layout/activity_post_video.xml
@@ -36,9 +36,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="16dp"
android:paddingTop="8dp"
- android:paddingEnd="16dp"
android:paddingBottom="8dp">
<pl.droidsonroids.gif.GifImageView
@@ -46,7 +44,8 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentStart="true"
- android:layout_centerVertical="true" />
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp" />
<TextView
android:id="@+id/subreddit_name_text_view_post_video_activity"
@@ -54,7 +53,6 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/rules_button_post_video_activity"
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_video_activity"
android:text="@string/choose_a_subreddit"
@@ -67,16 +65,18 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
android:text="@string/rules"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</RelativeLayout>
- <View
+ <com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_1_post_video_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
@@ -93,7 +93,7 @@
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -107,7 +107,7 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,23 +121,16 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
</LinearLayout>
- <View
- android:id="@+id/divider_2_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<LinearLayout
android:id="@+id/receive_post_reply_notifications_linear_layout_post_video_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dp"
- android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
@@ -164,10 +157,10 @@
</LinearLayout>
- <View
- android:id="@+id/divider_3_post_video_activity"
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_2_post_video_activity"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="wrap_content" />
<EditText
android:id="@+id/post_title_edit_text_post_video_activity"
@@ -182,11 +175,6 @@
android:textSize="?attr/title_font_18"
android:fontFamily="?attr/title_font_family" />
- <View
- android:id="@+id/divider_4_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="1dp" />
-
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/select_video_constraint_layout_post_video_activity"
android:layout_width="match_parent"
@@ -197,25 +185,27 @@
android:id="@+id/capture_fab_post_video_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:padding="16dp"
android:src="@drawable/ic_outline_add_a_photo_24dp"
+ app:useCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:tint="@android:color/white" />
+ app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/select_from_library_fab_post_video_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:padding="16dp"
android:src="@drawable/ic_outline_select_photo_24dp"
+ app:useCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
- app:layout_constraintTop_toTopOf="parent"
- app:tint="@android:color/white" />
+ app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/layout/activity_submit_crosspost.xml b/app/src/main/res/layout/activity_submit_crosspost.xml
index 345de3ae..797f9608 100644
--- a/app/src/main/res/layout/activity_submit_crosspost.xml
+++ b/app/src/main/res/layout/activity_submit_crosspost.xml
@@ -93,7 +93,7 @@
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -107,7 +107,7 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,7 +121,7 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml
index 6709af9f..a347b353 100644
--- a/app/src/main/res/layout/activity_view_subreddit_detail.xml
+++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml
@@ -65,7 +65,8 @@
android:id="@+id/subscribe_subreddit_chip_view_subreddit_detail_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"/>
+ android:layout_gravity="center_horizontal"
+ app:chipStrokeColor="#00000000" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/activity_view_user_detail.xml b/app/src/main/res/layout/activity_view_user_detail.xml
index c312e808..203f53ff 100644
--- a/app/src/main/res/layout/activity_view_user_detail.xml
+++ b/app/src/main/res/layout/activity_view_user_detail.xml
@@ -67,7 +67,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_gravity="center_horizontal"
- android:visibility="gone"/>
+ android:visibility="gone"
+ app:chipStrokeColor="#00000000" />
<RelativeLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml
index b81b5026..28ee2d9a 100644
--- a/app/src/main/res/layout/exo_playback_control_view.xml
+++ b/app/src/main/res/layout/exo_playback_control_view.xml
@@ -119,6 +119,14 @@
android:src="@drawable/ic_file_download_toolbar_white_24dp"
android:background="?attr/selectableItemBackgroundBorderless" />
+ <ImageView
+ android:id="@+id/playback_speed_image_view_exo_playback_control_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:src="@drawable/ic_playback_speed_toolbar_24dp"
+ android:background="?attr/selectableItemBackgroundBorderless" />
+
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
diff --git a/app/src/main/res/layout/fragment_theme_preview_posts.xml b/app/src/main/res/layout/fragment_theme_preview_posts.xml
index 8c0169cf..9ed975e3 100644
--- a/app/src/main/res/layout/fragment_theme_preview_posts.xml
+++ b/app/src/main/res/layout/fragment_theme_preview_posts.xml
@@ -136,7 +136,7 @@
android:text="@string/post_type_preview"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -149,7 +149,7 @@
android:text="@string/spoiler"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -161,7 +161,7 @@
android:text="@string/nsfw"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -174,7 +174,7 @@
android:text="@string/flair_preview"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -186,7 +186,7 @@
android:text="@string/awards_preview"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml
index f72eadc0..e6d3f89d 100644
--- a/app/src/main/res/layout/item_comment.xml
+++ b/app/src/main/res/layout/item_comment.xml
@@ -99,7 +99,7 @@
android:fontFamily="?attr/font_family"
tools:visibility="visible" />
- <TextView
+ <ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView
android:id="@+id/comment_markdown_view_item_post_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/app/src/main/res/layout/item_post_card_2_text.xml b/app/src/main/res/layout/item_post_card_2_text.xml
index a133cd52..c70142c2 100644
--- a/app/src/main/res/layout/item_post_card_2_text.xml
+++ b/app/src/main/res/layout/item_post_card_2_text.xml
@@ -49,7 +49,7 @@
android:text="@string/text"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -63,7 +63,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -76,7 +76,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -89,7 +89,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -101,7 +101,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_card_2_video_autoplay.xml b/app/src/main/res/layout/item_post_card_2_video_autoplay.xml
index ef8794ce..3f3cf37c 100644
--- a/app/src/main/res/layout/item_post_card_2_video_autoplay.xml
+++ b/app/src/main/res/layout/item_post_card_2_video_autoplay.xml
@@ -31,6 +31,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1500"
+ app:auto_show="false"
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
<pl.droidsonroids.gif.GifImageView
@@ -81,7 +82,7 @@
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -95,7 +96,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -108,7 +109,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,7 +122,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -133,7 +134,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml b/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml
index 4f5dc4f2..002afb56 100644
--- a/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml
+++ b/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml
@@ -31,6 +31,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1500"
+ app:auto_show="false"
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
<pl.droidsonroids.gif.GifImageView
@@ -81,7 +82,7 @@
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -95,7 +96,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -108,7 +109,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -121,7 +122,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -133,7 +134,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_card_2_with_preview.xml b/app/src/main/res/layout/item_post_card_2_with_preview.xml
index 298e77ce..7c752ab1 100644
--- a/app/src/main/res/layout/item_post_card_2_with_preview.xml
+++ b/app/src/main/res/layout/item_post_card_2_with_preview.xml
@@ -92,7 +92,7 @@
android:text="@string/gallery"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -106,7 +106,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -119,7 +119,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -132,7 +132,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -144,7 +144,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_compact.xml b/app/src/main/res/layout/item_post_compact.xml
index 0371a939..5bab3835 100644
--- a/app/src/main/res/layout/item_post_compact.xml
+++ b/app/src/main/res/layout/item_post_compact.xml
@@ -112,7 +112,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:textSize="?attr/font_10"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -126,7 +126,7 @@
android:text="@string/spoiler"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -139,7 +139,7 @@
android:text="@string/nsfw"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -152,7 +152,7 @@
android:padding="4dp"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -164,7 +164,7 @@
android:padding="4dp"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_compact_right_thumbnail.xml b/app/src/main/res/layout/item_post_compact_right_thumbnail.xml
index f151c98d..da3305d6 100644
--- a/app/src/main/res/layout/item_post_compact_right_thumbnail.xml
+++ b/app/src/main/res/layout/item_post_compact_right_thumbnail.xml
@@ -174,7 +174,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:textSize="?attr/font_10"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -188,7 +188,7 @@
android:text="@string/spoiler"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -201,7 +201,7 @@
android:text="@string/nsfw"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -214,7 +214,7 @@
android:padding="4dp"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -226,7 +226,7 @@
android:padding="4dp"
android:textSize="?attr/font_10"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_gallery.xml b/app/src/main/res/layout/item_post_detail_gallery.xml
index 5a53410d..6a5d2a51 100644
--- a/app/src/main/res/layout/item_post_detail_gallery.xml
+++ b/app/src/main/res/layout/item_post_detail_gallery.xml
@@ -120,7 +120,7 @@
android:text="@string/gallery"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -134,7 +134,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -147,7 +147,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -160,7 +160,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml b/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml
index 567269d5..fa135603 100644
--- a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml
+++ b/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml
@@ -120,7 +120,7 @@
android:text="@string/image"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -134,7 +134,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -147,7 +147,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -160,7 +160,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_link.xml b/app/src/main/res/layout/item_post_detail_link.xml
index 105b34eb..076766d0 100644
--- a/app/src/main/res/layout/item_post_detail_link.xml
+++ b/app/src/main/res/layout/item_post_detail_link.xml
@@ -120,7 +120,7 @@
android:text="@string/link"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -134,7 +134,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -147,7 +147,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -160,7 +160,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_no_preview.xml b/app/src/main/res/layout/item_post_detail_no_preview.xml
index 63d6e17e..01aabe38 100644
--- a/app/src/main/res/layout/item_post_detail_no_preview.xml
+++ b/app/src/main/res/layout/item_post_detail_no_preview.xml
@@ -129,7 +129,7 @@
android:text="@string/link"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -143,7 +143,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -156,7 +156,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -169,7 +169,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_text.xml b/app/src/main/res/layout/item_post_detail_text.xml
index d71c4670..2043ad98 100644
--- a/app/src/main/res/layout/item_post_detail_text.xml
+++ b/app/src/main/res/layout/item_post_detail_text.xml
@@ -129,7 +129,7 @@
android:text="@string/text"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -143,7 +143,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -156,7 +156,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -169,7 +169,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml
index 9ebfe960..846a2c10 100644
--- a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml
+++ b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml
@@ -119,7 +119,7 @@
android:padding="4dp"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -133,7 +133,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -146,7 +146,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -159,7 +159,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_detail_video_autoplay.xml b/app/src/main/res/layout/item_post_detail_video_autoplay.xml
index 6e6f77b2..aa3a3662 100644
--- a/app/src/main/res/layout/item_post_detail_video_autoplay.xml
+++ b/app/src/main/res/layout/item_post_detail_video_autoplay.xml
@@ -120,7 +120,7 @@
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -134,7 +134,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -147,7 +147,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -160,7 +160,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -214,6 +214,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1500"
+ app:auto_show="false"
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
<pl.droidsonroids.gif.GifImageView
diff --git a/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml b/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml
index 2f77d082..8e1b67ac 100644
--- a/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml
+++ b/app/src/main/res/layout/item_post_detail_video_autoplay_legacy_controller.xml
@@ -120,7 +120,7 @@
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -134,7 +134,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -147,7 +147,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -160,7 +160,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -214,6 +214,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1500"
+ app:auto_show="false"
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
<pl.droidsonroids.gif.GifImageView
diff --git a/app/src/main/res/layout/item_post_text.xml b/app/src/main/res/layout/item_post_text.xml
index b2b979b1..3b2ca0f3 100644
--- a/app/src/main/res/layout/item_post_text.xml
+++ b/app/src/main/res/layout/item_post_text.xml
@@ -130,7 +130,7 @@
android:text="@string/text"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -144,7 +144,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -157,7 +157,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -170,7 +170,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -182,7 +182,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
diff --git a/app/src/main/res/layout/item_post_video_type_autoplay.xml b/app/src/main/res/layout/item_post_video_type_autoplay.xml
index 5afde9c1..b63b608e 100644
--- a/app/src/main/res/layout/item_post_video_type_autoplay.xml
+++ b/app/src/main/res/layout/item_post_video_type_autoplay.xml
@@ -117,7 +117,7 @@
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -131,7 +131,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -144,7 +144,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -157,7 +157,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -169,7 +169,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -208,6 +208,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1500"
+ app:auto_show="false"
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
<pl.droidsonroids.gif.GifImageView
diff --git a/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml b/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml
index b8f4a27c..6dc38374 100644
--- a/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml
+++ b/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml
@@ -117,7 +117,7 @@
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -131,7 +131,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -144,7 +144,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -157,7 +157,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -169,7 +169,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -208,6 +208,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_timeout="1500"
+ app:auto_show="false"
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
<pl.droidsonroids.gif.GifImageView
diff --git a/app/src/main/res/layout/item_post_with_preview.xml b/app/src/main/res/layout/item_post_with_preview.xml
index 91014578..e0162b1c 100644
--- a/app/src/main/res/layout/item_post_with_preview.xml
+++ b/app/src/main/res/layout/item_post_with_preview.xml
@@ -216,8 +216,7 @@
android:id="@+id/image_view_item_post_with_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:adjustViewBounds="true"
- android:scaleType="fitStart" />
+ android:adjustViewBounds="true" />
<ImageView
android:id="@+id/video_or_gif_indicator_image_view_item_post_with_preview"
diff --git a/app/src/main/res/menu/edit_profile_activity.xml b/app/src/main/res/menu/edit_profile_activity.xml
index fe96ba20..4d5ec31d 100644
--- a/app/src/main/res/menu/edit_profile_activity.xml
+++ b/app/src/main/res/menu/edit_profile_activity.xml
@@ -6,6 +6,6 @@
android:id="@+id/action_save_edit_profile_activity"
android:orderInCategory="1"
android:title="@string/action_save"
- android:icon="@drawable/ic_save_to_database_24dp"
+ android:icon="@drawable/ic_check_circle_toolbar_24dp"
app:showAsAction="ifRoom" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml
index b72aa93f..e23d5191 100644
--- a/app/src/main/res/menu/view_subreddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml
@@ -54,8 +54,14 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_go_to_wiki_activity"
+ android:id="@+id/action_go_to_wiki_view_subreddit_detail_activity"
android:orderInCategory="9"
android:title="@string/action_go_to_wiki"
app:showAsAction="never" />
+
+ <item
+ android:id="@+id/action_contact_mods_view_subreddit_detail_activity"
+ android:orderInCategory="10"
+ android:title="@string/action_contact_mods"
+ app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3b8753e8..7c5c5180 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -43,6 +43,7 @@
<string name="post_gallery_activity_label">Gallery Post</string>
<string name="trending_activity_label">Trending</string>
<string name="wiki_activity_label">Wiki</string>
+ <string name="edit_profile_activity_label">Edit Profile</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
@@ -91,6 +92,7 @@
<string name="action_share_post_link">Share Post Link</string>
<string name="action_go_to_wiki">Go to Wiki</string>
<string name="action_playback_speed">Playback Speed</string>
+ <string name="action_contact_mods">Contact Mods</string>
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
<string name="retrieve_token_error">Error Retrieving the token</string>
@@ -1226,18 +1228,18 @@
<string name="remove_banner">Remove Banner</string>
<string name="display_name_text">Display Name</string>
<string name="display_name_hint">Show on your profile page</string>
- <string name="display_name_description">This will be displayed to viewer of your profile page and does not change your username</string>
+ <string name="display_name_description">This will be displayed to viewers of your profile page and does not change your username.</string>
<string name="about_you_text">About You</string>
- <string name="about_you_hint">A little description of your self</string>
- <string name="message_remove_avatar_success">Success remove Avatar</string>
- <string name="message_remove_avatar_failed_fmt">Failed remove Avatar %s</string>
- <string name="message_remove_banner_success">Success remove Banner</string>
- <string name="message_remove_banner_failed_fmt">Failed remove Banner %s</string>
- <string name="message_change_avatar_success">Success changing Avatar</string>
- <string name="message_change_avatar_failed_fmt">Failed changing Avatar %s</string>
- <string name="message_change_banner_success">Success changing Banner</string>
- <string name="message_change_banner_failed_fmt">Failed changing Banner %s</string>
- <string name="message_save_profile_success">Success save profile</string>
- <string name="message_save_profile_failed_fmt">Failed save profile %s</string>
+ <string name="about_you_hint">A little description of yourself</string>
+ <string name="message_remove_avatar_success">Remove avatar successfully</string>
+ <string name="message_remove_avatar_failed_fmt">Failed to remove avatar %s</string>
+ <string name="message_remove_banner_success">Remove banner successfully</string>
+ <string name="message_remove_banner_failed_fmt">Failed to remove banner %s</string>
+ <string name="message_change_avatar_success">Change avatar successfully</string>
+ <string name="message_change_avatar_failed_fmt">Failed to change avatar %s</string>
+ <string name="message_change_banner_success">Changing banner successfully</string>
+ <string name="message_change_banner_failed_fmt">Failed to change banner %s</string>
+ <string name="message_save_profile_success">Save profile successfully</string>
+ <string name="message_save_profile_failed_fmt">Failed to save profile %s</string>
</resources>