mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Merge branch 'master' into gallery-captions-feature
This commit is contained in:
commit
a399200be2
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "ml.docilealligator.infinityforreddit"
|
applicationId "ml.docilealligator.infinityforreddit"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 82
|
versionCode 86
|
||||||
versionName "5.1.0-beta2"
|
versionName "5.1.2"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
@ -154,6 +154,7 @@ dependencies {
|
|||||||
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
||||||
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
||||||
implementation "io.noties.markwon:html:$markwonVersion"
|
implementation "io.noties.markwon:html:$markwonVersion"
|
||||||
|
implementation "io.noties.markwon:inline-parser:$markwonVersion"
|
||||||
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
||||||
implementation 'me.saket:better-link-movement-method:2.2.0'
|
implementation 'me.saket:better-link-movement-method:2.2.0'
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".Infinity"
|
android:name="ml.docilealligator.infinityforreddit.Infinity"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/application_name"
|
android:label="@string/application_name"
|
||||||
@ -34,6 +34,11 @@
|
|||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:replace="android:label">
|
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
|
<activity
|
||||||
android:name=".activities.WikiActivity"
|
android:name=".activities.WikiActivity"
|
||||||
android:label="@string/wiki_activity_label"
|
android:label="@string/wiki_activity_label"
|
||||||
@ -393,11 +398,6 @@
|
|||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
|
android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
|
||||||
|
|
||||||
<activity android:name=".activities.EditProfileActivity"
|
|
||||||
android:parentActivityName=".activities.MainActivity"
|
|
||||||
android:theme="@style/AppTheme.SlidableWithTranslucentWindow"
|
|
||||||
android:windowSoftInputMode="adjustPan" />
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="ml.docilealligator.infinityforreddit.provider"
|
android:authorities="ml.docilealligator.infinityforreddit.provider"
|
||||||
|
@ -43,6 +43,9 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
private boolean canStartLockScreenActivity = false;
|
private boolean canStartLockScreenActivity = false;
|
||||||
private boolean isSecureMode;
|
private boolean isSecureMode;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences mSharedPreferences;
|
||||||
|
@Inject
|
||||||
@Named("security")
|
@Named("security")
|
||||||
SharedPreferences mSecuritySharedPreferences;
|
SharedPreferences mSecuritySharedPreferences;
|
||||||
|
|
||||||
@ -127,7 +130,7 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
|
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
|
||||||
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
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)
|
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -129,10 +129,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean userDefinedChangeSatusBarIconColorInImmersiveInterface =
|
boolean userDefinedChangeStatusBarIconColorInImmersiveInterface =
|
||||||
customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface();
|
customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface();
|
||||||
if (immersiveInterface && isImmersiveInterfaceApplicable) {
|
if (immersiveInterface && isImmersiveInterfaceApplicable) {
|
||||||
changeStatusBarIconColor = userDefinedChangeSatusBarIconColorInImmersiveInterface;
|
changeStatusBarIconColor = userDefinedChangeStatusBarIconColorInImmersiveInterface;
|
||||||
} else {
|
} else {
|
||||||
changeStatusBarIconColor = false;
|
changeStatusBarIconColor = false;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
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.customviews.LinearLayoutManagerBugFixed;
|
||||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -160,8 +165,21 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
|||||||
|
|
||||||
int linkColor = mCustomThemeWrapper.getLinkColor();
|
int linkColor = mCustomThemeWrapper.getLinkColor();
|
||||||
Markwon markwon = Markwon.builder(this)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
@ -201,8 +219,21 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
|||||||
contentMarkdownRecyclerView.setVisibility(View.VISIBLE);
|
contentMarkdownRecyclerView.setVisibility(View.VISIBLE);
|
||||||
contentMarkdownRecyclerView.setNestedScrollingEnabled(false);
|
contentMarkdownRecyclerView.setNestedScrollingEnabled(false);
|
||||||
Markwon postBodyMarkwon = Markwon.builder(this)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
||||||
textView.setTextColor(markdownColor);
|
textView.setTextColor(markdownColor);
|
||||||
|
@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.activities;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -17,7 +18,6 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
@ -26,6 +26,8 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
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.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
import com.r0adkll.slidr.model.SlidrInterface;
|
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.user.UserViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
|
import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class EditProfileActivity extends BaseActivity {
|
public class EditProfileActivity extends BaseActivity {
|
||||||
@ -61,14 +64,16 @@ public class EditProfileActivity extends BaseActivity {
|
|||||||
CoordinatorLayout root;
|
CoordinatorLayout root;
|
||||||
@BindView(R.id.content_view_edit_profile_activity)
|
@BindView(R.id.content_view_edit_profile_activity)
|
||||||
LinearLayout content;
|
LinearLayout content;
|
||||||
|
@BindView(R.id.collapsing_toolbar_layout_edit_profile_activity)
|
||||||
|
CollapsingToolbarLayout collapsingToolbarLayout;
|
||||||
@BindView(R.id.appbar_layout_view_edit_profile_activity)
|
@BindView(R.id.appbar_layout_view_edit_profile_activity)
|
||||||
AppBarLayout appBarLayout;
|
AppBarLayout appBarLayout;
|
||||||
@BindView(R.id.toolbar_view_edit_profile_activity)
|
@BindView(R.id.toolbar_view_edit_profile_activity)
|
||||||
Toolbar toolbar;
|
MaterialToolbar toolbar;
|
||||||
@BindView(R.id.image_view_banner_edit_profile_activity)
|
@BindView(R.id.image_view_banner_edit_profile_activity)
|
||||||
ImageView bannerImageView;
|
GifImageView bannerImageView;
|
||||||
@BindView(R.id.image_view_avatar_edit_profile_activity)
|
@BindView(R.id.image_view_avatar_edit_profile_activity)
|
||||||
ImageView avatarImageView;
|
GifImageView avatarImageView;
|
||||||
@BindView(R.id.image_view_change_banner_edit_profile_activity)
|
@BindView(R.id.image_view_change_banner_edit_profile_activity)
|
||||||
ImageView changeBanner;
|
ImageView changeBanner;
|
||||||
@BindView(R.id.image_view_change_avatar_edit_profile_activity)
|
@BindView(R.id.image_view_change_avatar_edit_profile_activity)
|
||||||
@ -92,20 +97,28 @@ public class EditProfileActivity extends BaseActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
//
|
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
setTransparentStatusBarAfterToolbarCollapsed();
|
|
||||||
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_edit_profile);
|
setContentView(R.layout.activity_edit_profile);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
|
|
||||||
applyCustomTheme();
|
applyCustomTheme();
|
||||||
adjustToolbar(toolbar);
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
|
||||||
|
addOnOffsetChangedListener(appBarLayout);
|
||||||
|
}
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
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);
|
new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class);
|
||||||
|
|
||||||
userViewModel.getUserLiveData().observe(this, userData -> {
|
userViewModel.getUserLiveData().observe(this, userData -> {
|
||||||
if (userData == null) return;//
|
if (userData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// BANNER
|
// BANNER
|
||||||
final String userBanner = userData.getBanner();
|
final String userBanner = userData.getBanner();
|
||||||
LayoutParams cBannerLp = (LayoutParams) changeBanner.getLayoutParams();
|
LayoutParams cBannerLp = (LayoutParams) changeBanner.getLayoutParams();
|
||||||
if (userBanner == null || userBanner.isEmpty()) {
|
if (userBanner == null || userBanner.isEmpty()) {
|
||||||
changeBanner.setLongClickable(false);
|
changeBanner.setLongClickable(false);
|
||||||
changeBanner.setImageResource(R.drawable.ic_add_day_night_24dp);
|
cBannerLp.gravity = Gravity.CENTER;
|
||||||
changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.CENTER));
|
changeBanner.setLayoutParams(cBannerLp);
|
||||||
changeBanner.setOnLongClickListener(v -> false);
|
changeBanner.setOnLongClickListener(v -> false);
|
||||||
} else {
|
} else {
|
||||||
changeBanner.setLongClickable(true);
|
changeBanner.setLongClickable(true);
|
||||||
changeBanner.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp);
|
cBannerLp.gravity = Gravity.END | Gravity.BOTTOM;
|
||||||
changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.END | Gravity.BOTTOM));
|
changeBanner.setLayoutParams(cBannerLp);
|
||||||
glide.load(userBanner).into(bannerImageView);
|
glide.load(userBanner).into(bannerImageView);
|
||||||
changeBanner.setOnLongClickListener(view -> {
|
changeBanner.setOnLongClickListener(view -> {
|
||||||
if (mAccessToken == null) return false;
|
if (mAccessToken == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
.setTitle(R.string.remove_banner)
|
.setTitle(R.string.remove_banner)
|
||||||
.setMessage(R.string.are_you_sure)
|
.setMessage(R.string.are_you_sure)
|
||||||
@ -182,15 +199,13 @@ public class EditProfileActivity extends BaseActivity {
|
|||||||
LayoutParams cAvatarLp = (LayoutParams) changeAvatar.getLayoutParams();
|
LayoutParams cAvatarLp = (LayoutParams) changeAvatar.getLayoutParams();
|
||||||
if (userAvatar.contains("avatar_default_")) {
|
if (userAvatar.contains("avatar_default_")) {
|
||||||
changeAvatar.setLongClickable(false);
|
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);
|
changeAvatar.setOnLongClickListener(v -> false);
|
||||||
} else {
|
} else {
|
||||||
changeAvatar.setLongClickable(true);
|
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 -> {
|
changeAvatar.setOnLongClickListener(view -> {
|
||||||
if (mAccessToken == null) return false;
|
if (mAccessToken == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
.setTitle(R.string.remove_avatar)
|
.setTitle(R.string.remove_avatar)
|
||||||
.setMessage(R.string.are_you_sure)
|
.setMessage(R.string.are_you_sure)
|
||||||
@ -328,8 +343,9 @@ public class EditProfileActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
root.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
root.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
|
|
||||||
changeColorTextView(content, mCustomThemeWrapper.getPrimaryTextColor());
|
changeColorTextView(content, mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import org.commonmark.ext.gfm.tables.TableBlock;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -48,6 +47,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
@ -58,7 +61,11 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|||||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
||||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
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.utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
public class FullMarkdownActivity extends BaseActivity {
|
public class FullMarkdownActivity extends BaseActivity {
|
||||||
|
|
||||||
@ -131,67 +138,19 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
int spoilerBackgroundColor = markdownColor | 0xFF000000;
|
int spoilerBackgroundColor = markdownColor | 0xFF000000;
|
||||||
int linkColor = mCustomThemeWrapper.getLinkColor();
|
int linkColor = mCustomThemeWrapper.getLinkColor();
|
||||||
Markwon markwon = Markwon.builder(this)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
|
||||||
ArrayList<Integer> matched = new ArrayList<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
matched.add(matcher.start());
|
|
||||||
}
|
|
||||||
for (int i = matched.size() - 1; i >= 0; i--) {
|
|
||||||
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -215,6 +174,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
builder.linkColor(linkColor);
|
builder.linkColor(linkColor);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(TableEntryPlugin.create(this))
|
.usePlugin(TableEntryPlugin.create(this))
|
||||||
|
@ -38,7 +38,6 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
drawer.setFitsSystemWindows(false);
|
drawer.setFitsSystemWindows(false);
|
||||||
getWindow().setDecorFitsSystemWindows(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 {
|
} else {
|
||||||
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||||
}
|
}
|
||||||
@ -855,19 +851,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
||||||
}
|
}
|
||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
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) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
|
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
|
||||||
@ -901,7 +884,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
- sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());
|
- sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).attach();
|
}).attach();
|
||||||
} else {
|
} else {
|
||||||
tabLayout.setVisibility(View.GONE);
|
tabLayout.setVisibility(View.GONE);
|
||||||
@ -925,7 +907,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
loadSubscriptions();
|
loadSubscriptions();
|
||||||
|
|
||||||
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
|
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
|
||||||
mRedditDataRoomDatabase, mAccountName))
|
mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
|
||||||
.get(MultiRedditViewModel.class);
|
.get(MultiRedditViewModel.class);
|
||||||
|
|
||||||
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
|
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
|
||||||
@ -934,17 +916,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
multiRedditViewModel.getAllMultiReddits().observe(this, new Observer<List<MultiReddit>>() {
|
multiRedditViewModel.getAllMultiReddits().observe(this, multiReddits -> {
|
||||||
@Override
|
|
||||||
public void onChanged(List<MultiReddit> multiReddits) {
|
|
||||||
if (mShowMultiReddits && sectionsPagerAdapter != null) {
|
if (mShowMultiReddits && sectionsPagerAdapter != null) {
|
||||||
sectionsPagerAdapter.setMultiReddits(multiReddits);
|
sectionsPagerAdapter.setMultiReddits(multiReddits);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
subscribedSubredditViewModel = new ViewModelProvider(this,
|
subscribedSubredditViewModel = new ViewModelProvider(this,
|
||||||
new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
|
new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
|
||||||
.get(SubscribedSubredditViewModel.class);
|
.get(SubscribedSubredditViewModel.class);
|
||||||
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
|
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
|
||||||
subscribedSubredditData -> {
|
subscribedSubredditData -> {
|
||||||
@ -1696,9 +1675,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if (mAccessToken == null) {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
return tabCount + favoriteMultiReddits.size() + multiReddits.size() +
|
return tabCount + favoriteMultiReddits.size() + multiReddits.size() +
|
||||||
favoriteSubscribedSubreddits.size() + subscribedSubreddits.size();
|
favoriteSubscribedSubreddits.size() + subscribedSubreddits.size();
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
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.snackbar.Snackbar;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@ -110,27 +111,23 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
@BindView(R.id.rules_button_post_gallery_activity)
|
@BindView(R.id.rules_button_post_gallery_activity)
|
||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_gallery_activity)
|
@BindView(R.id.divider_1_post_gallery_activity)
|
||||||
View divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_gallery_activity)
|
@BindView(R.id.flair_custom_text_view_post_gallery_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_gallery_activity)
|
@BindView(R.id.spoiler_custom_text_view_post_gallery_activity)
|
||||||
CustomTextView spoilerTextView;
|
CustomTextView spoilerTextView;
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_gallery_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_gallery_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_post_gallery_activity)
|
|
||||||
View divider2;
|
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity)
|
||||||
LinearLayout receivePostReplyNotificationsLinearLayout;
|
LinearLayout receivePostReplyNotificationsLinearLayout;
|
||||||
@BindView(R.id.receive_post_reply_notifications_text_view_post_gallery_activity)
|
@BindView(R.id.receive_post_reply_notifications_text_view_post_gallery_activity)
|
||||||
TextView receivePostReplyNotificationsTextView;
|
TextView receivePostReplyNotificationsTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_switch_material_post_gallery_activity)
|
@BindView(R.id.receive_post_reply_notifications_switch_material_post_gallery_activity)
|
||||||
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
||||||
@BindView(R.id.divider_3_post_gallery_activity)
|
@BindView(R.id.divider_2_post_gallery_activity)
|
||||||
View divider3;
|
MaterialDivider divider2;
|
||||||
@BindView(R.id.post_title_edit_text_post_gallery_activity)
|
@BindView(R.id.post_title_edit_text_post_gallery_activity)
|
||||||
EditText titleEditText;
|
EditText titleEditText;
|
||||||
@BindView(R.id.divider_4_post_gallery_activity)
|
|
||||||
View divider4;
|
|
||||||
@BindView(R.id.images_recycler_view_post_gallery_activity)
|
@BindView(R.id.images_recycler_view_post_gallery_activity)
|
||||||
RecyclerView imagesRecyclerView;
|
RecyclerView imagesRecyclerView;
|
||||||
@Inject
|
@Inject
|
||||||
@ -415,10 +412,8 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
||||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||||
divider1.setBackgroundColor(dividerColor);
|
divider1.setDividerColor(dividerColor);
|
||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setDividerColor(dividerColor);
|
||||||
divider3.setBackgroundColor(dividerColor);
|
|
||||||
divider4.setBackgroundColor(dividerColor);
|
|
||||||
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
||||||
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
||||||
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
||||||
|
@ -32,6 +32,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
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.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
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)
|
@BindView(R.id.rules_button_post_image_activity)
|
||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_image_activity)
|
@BindView(R.id.divider_1_post_image_activity)
|
||||||
View divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_image_activity)
|
@BindView(R.id.flair_custom_text_view_post_image_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_image_activity)
|
@BindView(R.id.spoiler_custom_text_view_post_image_activity)
|
||||||
CustomTextView spoilerTextView;
|
CustomTextView spoilerTextView;
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_post_image_activity)
|
|
||||||
View divider2;
|
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_image_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_image_activity)
|
||||||
LinearLayout receivePostReplyNotificationsLinearLayout;
|
LinearLayout receivePostReplyNotificationsLinearLayout;
|
||||||
@BindView(R.id.receive_post_reply_notifications_text_view_post_image_activity)
|
@BindView(R.id.receive_post_reply_notifications_text_view_post_image_activity)
|
||||||
TextView receivePostReplyNotificationsTextView;
|
TextView receivePostReplyNotificationsTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_switch_material_post_image_activity)
|
@BindView(R.id.receive_post_reply_notifications_switch_material_post_image_activity)
|
||||||
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
||||||
@BindView(R.id.divider_3_post_image_activity)
|
@BindView(R.id.divider_2_post_image_activity)
|
||||||
View divider3;
|
MaterialDivider divider2;
|
||||||
@BindView(R.id.post_title_edit_text_post_image_activity)
|
@BindView(R.id.post_title_edit_text_post_image_activity)
|
||||||
EditText titleEditText;
|
EditText titleEditText;
|
||||||
@BindView(R.id.divider_4_post_image_activity)
|
|
||||||
View divider4;
|
|
||||||
@BindView(R.id.select_image_constraint_layout_post_image_activity)
|
@BindView(R.id.select_image_constraint_layout_post_image_activity)
|
||||||
ConstraintLayout constraintLayout;
|
ConstraintLayout constraintLayout;
|
||||||
@BindView(R.id.capture_fab_post_image_activity)
|
@BindView(R.id.capture_fab_post_image_activity)
|
||||||
@ -396,10 +393,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
||||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||||
divider1.setBackgroundColor(dividerColor);
|
divider1.setDividerColor(dividerColor);
|
||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setDividerColor(dividerColor);
|
||||||
divider3.setBackgroundColor(dividerColor);
|
|
||||||
divider4.setBackgroundColor(dividerColor);
|
|
||||||
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
||||||
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
||||||
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
||||||
|
@ -26,6 +26,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
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.snackbar.Snackbar;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import com.libRG.CustomTextView;
|
import com.libRG.CustomTextView;
|
||||||
@ -91,11 +92,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@BindView(R.id.rules_button_post_link_activity)
|
@BindView(R.id.rules_button_post_link_activity)
|
||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_link_activity)
|
@BindView(R.id.divider_1_post_link_activity)
|
||||||
View divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.divider_2_post_link_activity)
|
@BindView(R.id.divider_2_post_link_activity)
|
||||||
View divider2;
|
MaterialDivider divider2;
|
||||||
@BindView(R.id.divider_4_post_link_activity)
|
|
||||||
View divider4;
|
|
||||||
@BindView(R.id.flair_custom_text_view_post_link_activity)
|
@BindView(R.id.flair_custom_text_view_post_link_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_link_activity)
|
@BindView(R.id.spoiler_custom_text_view_post_link_activity)
|
||||||
@ -108,8 +107,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
TextView receivePostReplyNotificationsTextView;
|
TextView receivePostReplyNotificationsTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_switch_material_post_link_activity)
|
@BindView(R.id.receive_post_reply_notifications_switch_material_post_link_activity)
|
||||||
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
||||||
@BindView(R.id.divider_3_post_link_activity)
|
|
||||||
View divider3;
|
|
||||||
@BindView(R.id.post_title_edit_text_post_link_activity)
|
@BindView(R.id.post_title_edit_text_post_link_activity)
|
||||||
EditText titleEditText;
|
EditText titleEditText;
|
||||||
@BindView(R.id.suggest_title_button_post_link_activity)
|
@BindView(R.id.suggest_title_button_post_link_activity)
|
||||||
@ -370,10 +367,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
||||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||||
divider1.setBackgroundColor(dividerColor);
|
divider1.setDividerColor(dividerColor);
|
||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setDividerColor(dividerColor);
|
||||||
divider3.setBackgroundColor(dividerColor);
|
|
||||||
divider4.setBackgroundColor(dividerColor);
|
|
||||||
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
||||||
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
||||||
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
||||||
|
@ -33,6 +33,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
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.snackbar.Snackbar;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import com.libRG.CustomTextView;
|
import com.libRG.CustomTextView;
|
||||||
@ -107,27 +108,23 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@BindView(R.id.rules_button_post_text_activity)
|
@BindView(R.id.rules_button_post_text_activity)
|
||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_text_activity)
|
@BindView(R.id.divider_1_post_text_activity)
|
||||||
View divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_text_activity)
|
@BindView(R.id.flair_custom_text_view_post_text_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_text_activity)
|
@BindView(R.id.spoiler_custom_text_view_post_text_activity)
|
||||||
CustomTextView spoilerTextView;
|
CustomTextView spoilerTextView;
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_post_text_activity)
|
|
||||||
View divider2;
|
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
|
||||||
LinearLayout receivePostReplyNotificationsLinearLayout;
|
LinearLayout receivePostReplyNotificationsLinearLayout;
|
||||||
@BindView(R.id.receive_post_reply_notifications_text_view_post_text_activity)
|
@BindView(R.id.receive_post_reply_notifications_text_view_post_text_activity)
|
||||||
TextView receivePostReplyNotificationsTextView;
|
TextView receivePostReplyNotificationsTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_switch_material_post_text_activity)
|
@BindView(R.id.receive_post_reply_notifications_switch_material_post_text_activity)
|
||||||
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
||||||
@BindView(R.id.divider_3_post_text_activity)
|
@BindView(R.id.divider_2_post_text_activity)
|
||||||
View divider3;
|
MaterialDivider divider2;
|
||||||
@BindView(R.id.post_title_edit_text_post_text_activity)
|
@BindView(R.id.post_title_edit_text_post_text_activity)
|
||||||
EditText titleEditText;
|
EditText titleEditText;
|
||||||
@BindView(R.id.divider_4_post_text_activity)
|
|
||||||
View divider4;
|
|
||||||
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||||
EditText contentEditText;
|
EditText contentEditText;
|
||||||
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
@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();
|
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
||||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||||
divider1.setBackgroundColor(dividerColor);
|
divider1.setDividerColor(dividerColor);
|
||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setDividerColor(dividerColor);
|
||||||
divider3.setBackgroundColor(dividerColor);
|
|
||||||
divider4.setBackgroundColor(dividerColor);
|
|
||||||
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
||||||
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
||||||
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.activities;
|
package ml.docilealligator.infinityforreddit.activities;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@ -14,6 +15,7 @@ import android.view.View;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
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.appbar.AppBarLayout;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
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.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
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)
|
@BindView(R.id.rules_button_post_video_activity)
|
||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_video_activity)
|
@BindView(R.id.divider_1_post_video_activity)
|
||||||
View divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_video_activity)
|
@BindView(R.id.flair_custom_text_view_post_video_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_video_activity)
|
@BindView(R.id.spoiler_custom_text_view_post_video_activity)
|
||||||
CustomTextView spoilerTextView;
|
CustomTextView spoilerTextView;
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_post_video_activity)
|
|
||||||
View divider2;
|
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
|
||||||
LinearLayout receivePostReplyNotificationsLinearLayout;
|
LinearLayout receivePostReplyNotificationsLinearLayout;
|
||||||
@BindView(R.id.receive_post_reply_notifications_text_view_post_video_activity)
|
@BindView(R.id.receive_post_reply_notifications_text_view_post_video_activity)
|
||||||
TextView receivePostReplyNotificationsTextView;
|
TextView receivePostReplyNotificationsTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_switch_material_post_video_activity)
|
@BindView(R.id.receive_post_reply_notifications_switch_material_post_video_activity)
|
||||||
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
||||||
@BindView(R.id.divider_3_post_video_activity)
|
@BindView(R.id.divider_2_post_video_activity)
|
||||||
View divider3;
|
MaterialDivider divider2;
|
||||||
@BindView(R.id.post_title_edit_text_post_video_activity)
|
@BindView(R.id.post_title_edit_text_post_video_activity)
|
||||||
EditText titleEditText;
|
EditText titleEditText;
|
||||||
@BindView(R.id.divider_4_post_video_activity)
|
|
||||||
View divider4;
|
|
||||||
@BindView(R.id.select_video_constraint_layout_post_video_activity)
|
@BindView(R.id.select_video_constraint_layout_post_video_activity)
|
||||||
ConstraintLayout constraintLayout;
|
ConstraintLayout constraintLayout;
|
||||||
@BindView(R.id.capture_fab_post_video_activity)
|
@BindView(R.id.capture_fab_post_video_activity)
|
||||||
@ -364,8 +363,10 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
|
|
||||||
captureFab.setOnClickListener(view -> {
|
captureFab.setOnClickListener(view -> {
|
||||||
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
|
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
|
||||||
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
|
try {
|
||||||
startActivityForResult(takeVideoIntent, CAPTURE_VIDEO_REQUEST_CODE);
|
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();
|
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
|
||||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||||
divider1.setBackgroundColor(dividerColor);
|
divider1.setDividerColor(dividerColor);
|
||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setDividerColor(dividerColor);
|
||||||
divider3.setBackgroundColor(dividerColor);
|
|
||||||
divider4.setBackgroundColor(dividerColor);
|
|
||||||
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
|
||||||
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
|
||||||
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
|
||||||
|
@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
@ -100,10 +101,10 @@ public class TrendingActivity extends BaseActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
|
||||||
private boolean isRefreshing = false;
|
private boolean isRefreshing = false;
|
||||||
private ArrayList<TrendingSearch> trendingSearches;
|
private ArrayList<TrendingSearch> trendingSearches;
|
||||||
private TrendingSearchRecyclerViewAdapter adapter;
|
private TrendingSearchRecyclerViewAdapter adapter;
|
||||||
|
private RequestManager mGlide;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -151,7 +152,8 @@ public class TrendingActivity extends BaseActivity {
|
|||||||
setToolbarGoToTop(toolbar);
|
setToolbarGoToTop(toolbar);
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
|
||||||
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||||
@ -277,7 +279,7 @@ public class TrendingActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void showErrorView(int stringId) {
|
private void showErrorView(int stringId) {
|
||||||
errorLinearLayout.setVisibility(View.VISIBLE);
|
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);
|
errorTextView.setText(stringId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -71,6 +72,9 @@ import io.noties.markwon.AbstractMarkwonPlugin;
|
|||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -380,6 +384,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
Locale locale = getResources().getConfiguration().locale;
|
Locale locale = getResources().getConfiguration().locale;
|
||||||
|
|
||||||
Markwon markwon = Markwon.builder(this)
|
Markwon markwon = Markwon.builder(this)
|
||||||
|
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||||
|
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||||
|
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||||
|
}))
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
@ -541,10 +549,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
descriptionTextView.setTextColor(primaryTextColor);
|
descriptionTextView.setTextColor(primaryTextColor);
|
||||||
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
|
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
|
||||||
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
|
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
|
||||||
option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option2BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option1BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
option3BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option3BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab);
|
||||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
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();
|
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
return true;
|
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);
|
Intent wikiIntent = new Intent(this, WikiActivity.class);
|
||||||
wikiIntent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
wikiIntent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
wikiIntent.putExtra(WikiActivity.EXTRA_WIKI_PATH, "index");
|
wikiIntent.putExtra(WikiActivity.EXTRA_WIKI_PATH, "index");
|
||||||
startActivity(wikiIntent);
|
startActivity(wikiIntent);
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -73,6 +74,9 @@ import io.noties.markwon.AbstractMarkwonPlugin;
|
|||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -376,6 +380,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
Locale locale = getResources().getConfiguration().locale;
|
Locale locale = getResources().getConfiguration().locale;
|
||||||
|
|
||||||
Markwon markwon = Markwon.builder(this)
|
Markwon markwon = Markwon.builder(this)
|
||||||
|
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||||
|
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||||
|
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||||
|
}))
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
@ -635,10 +643,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
|
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
|
||||||
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
|
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
|
||||||
option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option2BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option1BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
option3BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option3BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab);
|
||||||
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package ml.docilealligator.infinityforreddit.activities;
|
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.Manifest;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
@ -32,6 +38,7 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
@ -79,6 +86,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.apis.VReddIt;
|
import ml.docilealligator.infinityforreddit.apis.VReddIt;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PlaybackSpeedBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PlaybackSpeedBottomSheetFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
|
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
|
||||||
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
|
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
|
||||||
import ml.docilealligator.infinityforreddit.font.FontFamily;
|
import ml.docilealligator.infinityforreddit.font.FontFamily;
|
||||||
@ -150,6 +158,8 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
TextView titleTextView;
|
TextView titleTextView;
|
||||||
@BindView(R.id.download_image_view_exo_playback_control_view)
|
@BindView(R.id.download_image_view_exo_playback_control_view)
|
||||||
ImageView downloadImageView;
|
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)
|
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
|
||||||
LockableNestedScrollView nestedScrollView;
|
LockableNestedScrollView nestedScrollView;
|
||||||
|
|
||||||
@ -194,6 +204,9 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
|
||||||
@ -206,7 +219,37 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
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);
|
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
|
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
|
||||||
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
|
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
|
||||||
@ -250,6 +293,14 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
isDownloading = true;
|
isDownloading = true;
|
||||||
requestPermissionAndDownload();
|
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 {
|
} else {
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
||||||
@ -520,10 +571,13 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
hdButton.setVisibility(View.VISIBLE);
|
hdButton.setVisibility(View.VISIBLE);
|
||||||
hdButton.setOnClickListener(view -> {
|
hdButton.setOnClickListener(view -> {
|
||||||
TrackSelectionDialogBuilder build = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), trackSelector, 0);
|
TrackSelectionDialogBuilder builder = new TrackSelectionDialogBuilder(ViewVideoActivity.this, getString(R.string.select_video_quality), trackSelector, 0);
|
||||||
build.setShowDisableOption(true);
|
builder.setShowDisableOption(true);
|
||||||
build.setAllowAdaptiveSelections(false);
|
builder.setAllowAdaptiveSelections(false);
|
||||||
build.build().show();
|
AlertDialog alertDialog = builder.build();
|
||||||
|
alertDialog.show();
|
||||||
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
|
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
@ -37,7 +38,6 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -52,6 +52,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
@ -63,8 +67,12 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|||||||
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
||||||
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan;
|
||||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -108,6 +116,7 @@ public class WikiActivity extends BaseActivity {
|
|||||||
private Markwon markwon;
|
private Markwon markwon;
|
||||||
private MarkwonAdapter markwonAdapter;
|
private MarkwonAdapter markwonAdapter;
|
||||||
private boolean isRefreshing = false;
|
private boolean isRefreshing = false;
|
||||||
|
private RequestManager mGlide;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -149,6 +158,8 @@ public class WikiActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
|
swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
|
||||||
swipeRefreshLayout.setOnRefreshListener(this::loadWiki);
|
swipeRefreshLayout.setOnRefreshListener(this::loadWiki);
|
||||||
|
|
||||||
@ -156,67 +167,19 @@ public class WikiActivity extends BaseActivity {
|
|||||||
int spoilerBackgroundColor = markdownColor | 0xFF000000;
|
int spoilerBackgroundColor = markdownColor | 0xFF000000;
|
||||||
int linkColor = mCustomThemeWrapper.getLinkColor();
|
int linkColor = mCustomThemeWrapper.getLinkColor();
|
||||||
markwon = Markwon.builder(this)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
|
||||||
ArrayList<Integer> matched = new ArrayList<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
matched.add(matcher.start());
|
|
||||||
}
|
|
||||||
for (int i = matched.size() - 1; i >= 0; i--) {
|
|
||||||
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -239,6 +202,7 @@ public class WikiActivity extends BaseActivity {
|
|||||||
builder.linkColor(linkColor);
|
builder.linkColor(linkColor);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(TableEntryPlugin.create(this))
|
.usePlugin(TableEntryPlugin.create(this))
|
||||||
@ -326,7 +290,7 @@ public class WikiActivity extends BaseActivity {
|
|||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchWikiInfoTextView.setText(stringResId);
|
mFetchWikiInfoTextView.setText(stringResId);
|
||||||
Glide.with(this).load(R.drawable.error_image).into(mFetchWikiInfoImageView);
|
mGlide.load(R.drawable.error_image).into(mFetchWikiInfoImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
@ -30,7 +31,6 @@ import androidx.recyclerview.widget.DiffUtil;
|
|||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -43,6 +43,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
@ -59,8 +63,11 @@ import ml.docilealligator.infinityforreddit.comment.Comment;
|
|||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
|
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
|
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.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -116,72 +123,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
mCommentColor = customThemeWrapper.getCommentColor();
|
mCommentColor = customThemeWrapper.getCommentColor();
|
||||||
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
|
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
|
||||||
mMarkwon = Markwon.builder(mActivity)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
|
||||||
ArrayList<Integer> matched = new ArrayList<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
matched.add(matcher.start());
|
|
||||||
}
|
|
||||||
for (int i = matched.size() - 1; i >= 0; i--) {
|
|
||||||
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
if (textView instanceof SpoilerOnClickTextView) {
|
|
||||||
((SpoilerOnClickTextView) textView).setSpoilerOnClick(true);
|
|
||||||
}
|
|
||||||
isShowing = !isShowing;
|
|
||||||
view.invalidate();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
markdownStringBuilder.setSpan(clickableSpan, matcherStart, matcherEnd - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
||||||
start = matcherEnd - 4;
|
|
||||||
}
|
|
||||||
if (find) {
|
|
||||||
textView.setText(markdownStringBuilder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -200,6 +154,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(mCommentColor, commentSpoilerBackgroundColor))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.build();
|
.build();
|
||||||
@ -282,12 +237,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case Comment.VOTE_TYPE_UPVOTE:
|
case Comment.VOTE_TYPE_UPVOTE:
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
break;
|
break;
|
||||||
case Comment.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -322,8 +277,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).awardsTextView.setText("");
|
((CommentViewHolder) holder).awardsTextView.setText("");
|
||||||
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
((CommentViewHolder) holder).awardsTextView.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).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -470,13 +425,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
||||||
awardsTextView.setTextColor(mSecondaryTextColor);
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
commentMarkdownView.setTextColor(mCommentColor);
|
commentMarkdownView.setTextColor(mCommentColor);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
moreButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
expandButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
expandButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
saveButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
commentDivider.setBackgroundColor(mDividerColor);
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
|
|
||||||
authorTextView.setOnClickListener(view -> {
|
authorTextView.setOnClickListener(view -> {
|
||||||
@ -566,20 +521,20 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = APIUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
upvoteButton
|
upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,19 +548,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
}
|
}
|
||||||
@ -633,19 +588,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = APIUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,19 +614,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,11 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
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.text.util.Linkify;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -37,8 +34,6 @@ import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -48,6 +43,11 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
@ -66,6 +66,8 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|||||||
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
|
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
|
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
|
||||||
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
|
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.post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
@ -160,68 +162,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
int commentSpoilerBackgroundColor = mCommentTextColor | 0xFF000000;
|
int commentSpoilerBackgroundColor = mCommentTextColor | 0xFF000000;
|
||||||
int linkColor = customThemeWrapper.getLinkColor();
|
int linkColor = customThemeWrapper.getLinkColor();
|
||||||
mCommentMarkwon = Markwon.builder(mActivity)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
|
||||||
ArrayList<Integer> matched = new ArrayList<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
matched.add(matcher.start());
|
|
||||||
}
|
|
||||||
for (int i = matched.size() - 1; i >= 0; i--) {
|
|
||||||
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
} else {
|
|
||||||
ds.bgColor = commentSpoilerBackgroundColor;
|
|
||||||
}
|
|
||||||
ds.setColor(mCommentTextColor);
|
|
||||||
ds.setUnderlineText(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(@NonNull View view) {
|
|
||||||
if (textView instanceof SpoilerOnClickTextView) {
|
|
||||||
((SpoilerOnClickTextView) textView).setSpoilerOnClick(true);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -240,6 +193,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
builder.linkColor(linkColor);
|
builder.linkColor(linkColor);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(mCommentTextColor, commentSpoilerBackgroundColor))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.newInstance().setOnLinkLongClickListener((textView, url) -> {
|
.usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.newInstance().setOnLinkLongClickListener((textView, url) -> {
|
||||||
if (!activity.isDestroyed() && !activity.isFinishing()) {
|
if (!activity.isDestroyed() && !activity.isFinishing()) {
|
||||||
@ -486,13 +440,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case Comment.VOTE_TYPE_UPVOTE:
|
case Comment.VOTE_TYPE_UPVOTE:
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
break;
|
break;
|
||||||
case Comment.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
@ -501,19 +455,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
((CommentViewHolder) holder).replyButton
|
((CommentViewHolder) holder).replyButton
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
||||||
android.graphics.PorterDuff.Mode.SRC_IN);
|
PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
||||||
android.graphics.PorterDuff.Mode.SRC_IN);
|
PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
||||||
android.graphics.PorterDuff.Mode.SRC_IN);
|
PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isLocked()) {
|
if (mPost.isLocked()) {
|
||||||
((CommentViewHolder) holder).replyButton
|
((CommentViewHolder) holder).replyButton
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
||||||
android.graphics.PorterDuff.Mode.SRC_IN);
|
PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
@ -1059,10 +1013,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
((CommentViewHolder) holder).awardsTextView.setText("");
|
((CommentViewHolder) holder).awardsTextView.setText("");
|
||||||
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).expandButton.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).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,13 +1125,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
awardsTextView.setTextColor(mSecondaryTextColor);
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
commentDivider.setBackgroundColor(mDividerColor);
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
moreButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
expandButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
expandButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
saveButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
||||||
|
|
||||||
@ -1254,20 +1208,20 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = APIUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
topScoreTextView.setTextColor(mUpvotedColor);
|
topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
@ -1286,21 +1240,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
topScoreTextView.setTextColor(mUpvotedColor);
|
topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||||
@ -1332,20 +1286,20 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = APIUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
topScoreTextView.setTextColor(mDownvotedColor);
|
topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
@ -1364,21 +1318,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
topScoreTextView.setTextColor(mDownvotedColor);
|
topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||||
|
@ -35,6 +35,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
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.ViewPrivateMessagesActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
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.FetchMessage;
|
||||||
import ml.docilealligator.infinityforreddit.message.Message;
|
import ml.docilealligator.infinityforreddit.message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
||||||
@ -99,69 +107,19 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
|
|
||||||
mMarkwon = Markwon.builder(mContext)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
|
||||||
ArrayList<Integer> matched = new ArrayList<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
matched.add(matcher.start());
|
|
||||||
}
|
|
||||||
for (int i = matched.size() - 1; i >= 0; i--) {
|
|
||||||
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -179,6 +137,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
builder.linkColor(customThemeWrapper.getLinkColor());
|
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(mSecondaryTextColor, spoilerBackgroundColor))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.build();
|
.build();
|
||||||
|
@ -74,6 +74,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
@ -83,6 +87,7 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
|
|||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
||||||
|
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
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.LinearLayoutManagerBugFixed;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
||||||
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
|
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.Post;
|
||||||
import ml.docilealligator.infinityforreddit.post.PostPagingSource;
|
import ml.docilealligator.infinityforreddit.post.PostPagingSource;
|
||||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -134,7 +142,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Markwon mPostDetailMarkwon;
|
private Markwon mPostDetailMarkwon;
|
||||||
private int mImageViewWidth;
|
private final MarkwonAdapter mMarkwonAdapter;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private Post mPost;
|
private Post mPost;
|
||||||
@ -204,7 +212,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
Executor executor, CustomThemeWrapper customThemeWrapper,
|
Executor executor, CustomThemeWrapper customThemeWrapper,
|
||||||
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
|
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
|
||||||
Retrofit redgifsRetrofit, RedditDataRoomDatabase redditDataRoomDatabase,
|
Retrofit redgifsRetrofit, RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
RequestManager glide, int imageViewWidth,
|
RequestManager glide,
|
||||||
boolean separatePostAndComments, String accessToken,
|
boolean separatePostAndComments, String accessToken,
|
||||||
String accountName, Post post, Locale locale,
|
String accountName, Post post, Locale locale,
|
||||||
SharedPreferences sharedPreferences,
|
SharedPreferences sharedPreferences,
|
||||||
@ -226,68 +234,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
|
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
|
||||||
int linkColor = customThemeWrapper.getLinkColor();
|
int linkColor = customThemeWrapper.getLinkColor();
|
||||||
mPostDetailMarkwon = Markwon.builder(mActivity)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
|
||||||
ArrayList<Integer> matched = new ArrayList<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
matched.add(matcher.start());
|
|
||||||
}
|
|
||||||
for (int i = matched.size() - 1; i >= 0; i--) {
|
|
||||||
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -322,6 +281,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
builder.linkColor(linkColor);
|
builder.linkColor(linkColor);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(markdownColor, postSpoilerBackgroundColor))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
|
.usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
|
||||||
if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
|
if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
|
||||||
@ -341,7 +301,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
.tableLayout(R.layout.adapter_table_block, R.id.table_layout)
|
.tableLayout(R.layout.adapter_table_block, R.id.table_layout)
|
||||||
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
|
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
|
||||||
.build();
|
.build();
|
||||||
mImageViewWidth = imageViewWidth;
|
|
||||||
mSeparatePostAndComments = separatePostAndComments;
|
mSeparatePostAndComments = separatePostAndComments;
|
||||||
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
|
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
@ -596,16 +555,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
((PostDetailBaseViewHolder) holder).mUpvoteButton
|
((PostDetailBaseViewHolder) holder).mUpvoteButton
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mDownvoteButton
|
((PostDetailBaseViewHolder) holder).mDownvoteButton
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isCrosspost()) {
|
if (mPost.isCrosspost()) {
|
||||||
@ -676,11 +635,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
|
||||||
mGlide.load(preview.getPreviewUrl()).override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(preview.getPreviewUrl()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||||
}
|
}
|
||||||
@ -736,8 +691,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / (float) preview.getPreviewWidth());
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / (float) preview.getPreviewWidth());
|
||||||
}
|
}
|
||||||
@ -873,30 +826,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
previewIndex = 0;
|
previewIndex = 0;
|
||||||
}
|
}
|
||||||
preview = previews.get(previewIndex);
|
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--) {
|
for (int i = previews.size() - 1; i >= 1; i--) {
|
||||||
preview = previews.get(i);
|
preview = previews.get(i);
|
||||||
if (mImageViewWidth >= preview.getPreviewWidth()) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
|
||||||
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;
|
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;
|
return preview;
|
||||||
}
|
}
|
||||||
@ -909,7 +846,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);
|
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();
|
String url = mPost.getPostType() == Post.IMAGE_TYPE || blurImage ? preview.getPreviewUrl() : mPost.getUrl();
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url)
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url)
|
||||||
.listener(new RequestListener<Drawable>() {
|
.listener(new RequestListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
||||||
@ -932,15 +869,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
if (blurImage) {
|
if (blurImage) {
|
||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
|
||||||
} else {
|
|
||||||
imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
|
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||||
.listener(new RequestListener<Drawable>() {
|
.listener(new RequestListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
((PostDetailVideoAndGifPreviewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
||||||
@ -964,15 +897,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
|
||||||
} else {
|
|
||||||
imageRequestBuilder.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostDetailLinkViewHolder) {
|
} else if (holder instanceof PostDetailLinkViewHolder) {
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||||
.listener(new RequestListener<Drawable>() {
|
.listener(new RequestListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
((PostDetailLinkViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
||||||
@ -996,15 +925,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostDetailLinkViewHolder) holder).mImageView);
|
.into(((PostDetailLinkViewHolder) holder).mImageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailLinkViewHolder) holder).mImageView);
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailLinkViewHolder) holder).mImageView);
|
|
||||||
} else {
|
|
||||||
imageRequestBuilder.into(((PostDetailLinkViewHolder) holder).mImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostDetailGalleryViewHolder) {
|
} else if (holder instanceof PostDetailGalleryViewHolder) {
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||||
.listener(new RequestListener<Drawable>() {
|
.listener(new RequestListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
((PostDetailGalleryViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
((PostDetailGalleryViewHolder) holder).mLoadImageProgressBar.setVisibility(View.GONE);
|
||||||
@ -1027,11 +952,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)) {
|
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);
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailGalleryViewHolder) holder).mImageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostDetailGalleryViewHolder) holder).mImageView);
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailGalleryViewHolder) holder).mImageView);
|
|
||||||
} else {
|
|
||||||
imageRequestBuilder.into(((PostDetailGalleryViewHolder) holder).mImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1087,9 +1008,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
if (holder instanceof PostDetailBaseViewHolder) {
|
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).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).mFlairTextView.setVisibility(View.GONE);
|
||||||
((PostDetailBaseViewHolder) holder).mSpoilerTextView.setVisibility(View.GONE);
|
((PostDetailBaseViewHolder) holder).mSpoilerTextView.setVisibility(View.GONE);
|
||||||
((PostDetailBaseViewHolder) holder).mNSFWTextView.setVisibility(View.GONE);
|
((PostDetailBaseViewHolder) holder).mNSFWTextView.setVisibility(View.GONE);
|
||||||
@ -1286,19 +1207,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
int previousVoteType = mPost.getVoteType();
|
int previousVoteType = mPost.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != 1) {
|
if (previousVoteType != 1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
mPost.setVoteType(1);
|
mPost.setVoteType(1);
|
||||||
newVoteType = APIUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mUpvotedColor);
|
mScoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1314,15 +1235,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
public void onVoteThingSuccess() {
|
public void onVoteThingSuccess() {
|
||||||
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
mPost.setVoteType(1);
|
mPost.setVoteType(1);
|
||||||
mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mUpvotedColor);
|
mScoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
mPost.getScore() + mPost.getVoteType()));
|
mPost.getScore() + mPost.getVoteType()));
|
||||||
@ -1366,19 +1287,19 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
int previousVoteType = mPost.getVoteType();
|
int previousVoteType = mPost.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != -1) {
|
if (previousVoteType != -1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
mPost.setVoteType(-1);
|
mPost.setVoteType(-1);
|
||||||
newVoteType = APIUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mDownvotedColor);
|
mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
newVoteType = APIUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1394,15 +1315,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
public void onVoteThingSuccess() {
|
public void onVoteThingSuccess() {
|
||||||
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
mPost.setVoteType(-1);
|
mPost.setVoteType(-1);
|
||||||
mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mDownvotedColor);
|
mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
mPost.getScore() + mPost.getVoteType()));
|
mPost.getScore() + mPost.getVoteType()));
|
||||||
@ -1574,13 +1495,13 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mUpvoteRatioTextView.setCompoundDrawablesWithIntrinsicBounds(
|
mUpvoteRatioTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
upvoteRatioDrawable, null, null, null);
|
upvoteRatioDrawable, null, null, null);
|
||||||
mUpvoteRatioTextView.setTextColor(mSecondaryTextColor);
|
mUpvoteRatioTextView.setTextColor(mSecondaryTextColor);
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
commentsCountTextView.setTextColor(mPostIconAndInfoColor);
|
commentsCountTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null);
|
commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null);
|
||||||
mSaveButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mSaveButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mShareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mShareButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2223,7 +2144,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
|
|
||||||
mLinkTextView.setTextColor(mSecondaryTextColor);
|
mLinkTextView.setTextColor(mSecondaryTextColor);
|
||||||
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
|
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
|
||||||
mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
|
mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
mNoPreviewPostTypeImageView.setOnClickListener(view -> {
|
mNoPreviewPostTypeImageView.setOnClickListener(view -> {
|
||||||
if (mPost != null) {
|
if (mPost != null) {
|
||||||
@ -2374,7 +2295,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
|
mLoadImageProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
|
||||||
mLoadImageErrorTextView.setTextColor(mPrimaryTextColor);
|
mLoadImageErrorTextView.setTextColor(mPrimaryTextColor);
|
||||||
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
|
mNoPreviewPostTypeImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
|
||||||
mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
|
mNoPreviewPostTypeImageView.setColorFilter(mNoPreviewPostTypeIconTint, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
mImageView.setOnClickListener(view -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
|
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
|
||||||
|
@ -69,6 +69,7 @@ import jp.wasabeef.glide.transformations.BlurTransformation;
|
|||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
||||||
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
|
||||||
|
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
@ -128,7 +129,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
private Retrofit mOauthRetrofit;
|
private Retrofit mOauthRetrofit;
|
||||||
private Retrofit mGfycatRetrofit;
|
private Retrofit mGfycatRetrofit;
|
||||||
private Retrofit mRedgifsRetrofit;
|
private Retrofit mRedgifsRetrofit;
|
||||||
private int mImageViewWidth;
|
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@ -208,7 +208,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
|
|
||||||
public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
|
public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
|
||||||
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
|
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
|
||||||
CustomThemeWrapper customThemeWrapper, Locale locale, int imageViewWidth,
|
CustomThemeWrapper customThemeWrapper, Locale locale,
|
||||||
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
|
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
|
||||||
SharedPreferences postHistorySharedPreferences,
|
SharedPreferences postHistorySharedPreferences,
|
||||||
@ -222,7 +222,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
mOauthRetrofit = oauthRetrofit;
|
mOauthRetrofit = oauthRetrofit;
|
||||||
mGfycatRetrofit = gfycatRetrofit;
|
mGfycatRetrofit = gfycatRetrofit;
|
||||||
mRedgifsRetrofit = redgifsRetrofit;
|
mRedgifsRetrofit = redgifsRetrofit;
|
||||||
mImageViewWidth = imageViewWidth;
|
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
mPostType = postType;
|
mPostType = postType;
|
||||||
mDisplaySubredditName = displaySubredditName;
|
mDisplaySubredditName = displaySubredditName;
|
||||||
@ -678,11 +677,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
|
||||||
mGlide.load(preview.getPreviewUrl()).override(Target.SIZE_ORIGINAL).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(preview.getPreviewUrl()).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||||
}
|
}
|
||||||
@ -776,8 +771,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostWithPreviewTypeViewHolder) holder).imageView
|
((PostWithPreviewTypeViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -811,11 +804,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
|
||||||
mGlide.load(preview.getPreviewUrl()).override(Target.SIZE_ORIGINAL).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(preview.getPreviewUrl()).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||||
}
|
}
|
||||||
@ -911,8 +900,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostCard2WithPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostCard2WithPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostCard2WithPreviewViewHolder) holder).imageView
|
((PostCard2WithPreviewViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1293,8 +1280,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostGalleryViewHolder) holder).imageView
|
((PostGalleryViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1329,8 +1314,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostGalleryViewHolder) holder).imageView
|
((PostGalleryViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1355,8 +1338,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostGalleryViewHolder) holder).imageView
|
((PostGalleryViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1381,8 +1362,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostGalleryViewHolder) holder).imageView
|
((PostGalleryViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1417,8 +1396,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
int height = (int) (400 * mScale);
|
int height = (int) (400 * mScale);
|
||||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||||
preview.setPreviewWidth(mImageViewWidth);
|
|
||||||
preview.setPreviewHeight(height);
|
|
||||||
} else {
|
} else {
|
||||||
((PostGalleryViewHolder) holder).imageView
|
((PostGalleryViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1449,29 +1426,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
|
||||||
for (int i = previews.size() - 1; i >= 1; i--) {
|
for (int i = previews.size() - 1; i >= 1; i--) {
|
||||||
preview = previews.get(i);
|
preview = previews.get(i);
|
||||||
if (mImageViewWidth >= preview.getPreviewWidth()) {
|
|
||||||
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
|
||||||
return preview;
|
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) {
|
|
||||||
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;
|
return preview;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1496,7 +1455,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostWithPreviewTypeViewHolder) holder).imageView);
|
.into(((PostWithPreviewTypeViewHolder) holder).imageView);
|
||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).centerInside().into(((PostWithPreviewTypeViewHolder) holder).imageView);
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostWithPreviewTypeViewHolder) holder).imageView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostCompactBaseViewHolder) {
|
} else if (holder instanceof PostCompactBaseViewHolder) {
|
||||||
@ -1536,11 +1495,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostGalleryViewHolder) holder).imageView);
|
.into(((PostGalleryViewHolder) holder).imageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostGalleryViewHolder) holder).imageView);
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostGalleryViewHolder) holder).imageView);
|
|
||||||
} else {
|
|
||||||
imageRequestBuilder.into(((PostGalleryViewHolder) holder).imageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
|
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
|
||||||
@ -1560,11 +1515,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
.into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > preview.getPreviewWidth()) {
|
imageRequestBuilder.centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
||||||
imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
|
||||||
} else {
|
|
||||||
imageRequestBuilder.into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1918,6 +1869,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openViewPostDetailActivity(Post post, int position) {
|
private void openViewPostDetailActivity(Post post, int position) {
|
||||||
|
if (canStartActivity) {
|
||||||
|
canStartActivity = false;
|
||||||
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
|
||||||
@ -1925,6 +1878,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_IS_NSFW_SUBREDDIT, mFragment.getIsNsfwSubreddit());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_IS_NSFW_SUBREDDIT, mFragment.getIsNsfwSubreddit());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void openMedia(Post post) {
|
private void openMedia(Post post) {
|
||||||
if (canStartActivity) {
|
if (canStartActivity) {
|
||||||
@ -2115,7 +2069,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
markPostRead(post, true);
|
markPostRead(post, true);
|
||||||
canStartActivity = false;
|
|
||||||
|
|
||||||
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
||||||
}
|
}
|
||||||
@ -3162,8 +3115,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null && canStartActivity) {
|
if (post != null && canStartActivity) {
|
||||||
markPostRead(post, true);
|
markPostRead(post, true);
|
||||||
canStartActivity = false;
|
|
||||||
|
|
||||||
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3752,7 +3703,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
markPostRead(post, true);
|
markPostRead(post, true);
|
||||||
canStartActivity = false;
|
|
||||||
|
|
||||||
if (post.getPostType() == Post.TEXT_TYPE || !mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
|
if (post.getPostType() == Post.TEXT_TYPE || !mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
|
||||||
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
||||||
@ -3769,7 +3719,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
markPostRead(post, true);
|
markPostRead(post, true);
|
||||||
canStartActivity = false;
|
|
||||||
|
|
||||||
if (post.getPostType() == Post.TEXT_TYPE || mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
|
if (post.getPostType() == Post.TEXT_TYPE || mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
|
||||||
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
||||||
|
@ -28,6 +28,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
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.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.message.Message;
|
import ml.docilealligator.infinityforreddit.message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
@ -66,8 +71,21 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
mAccountName = accountName;
|
mAccountName = accountName;
|
||||||
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
|
@ -23,6 +23,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
@ -31,6 +35,8 @@ import ml.docilealligator.infinityforreddit.Rule;
|
|||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
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> {
|
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
|
||||||
private Markwon markwon;
|
private Markwon markwon;
|
||||||
@ -40,8 +46,21 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
|
|
||||||
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) {
|
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) {
|
||||||
markwon = Markwon.builder(activity)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
|
@ -6,6 +6,7 @@ import android.content.ClipData;
|
|||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -72,7 +73,7 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (markdownText != null) {
|
if (markdownText != null) {
|
||||||
markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
|
//markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
|
||||||
copyMarkdownTextView.setOnClickListener(view -> {
|
copyMarkdownTextView.setOnClickListener(view -> {
|
||||||
showCopyDialog(markdownText);
|
showCopyDialog(markdownText);
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -3,16 +3,25 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
|
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class WallpaperChangeReceiver extends BroadcastReceiver {
|
public class WallpaperChangeReceiver extends BroadcastReceiver {
|
||||||
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
public WallpaperChangeReceiver(SharedPreferences sharedPreferences) {
|
||||||
|
this.sharedPreferences = sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (sharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
|
||||||
Intent materialYouIntent = new Intent(context, MaterialYouService.class);
|
Intent materialYouIntent = new Intent(context, MaterialYouService.class);
|
||||||
ContextCompat.startForegroundService(context, materialYouIntent);
|
ContextCompat.startForegroundService(context, materialYouIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -17,7 +17,6 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
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);
|
mGlide = Glide.with(activity);
|
||||||
|
|
||||||
lazyModeRunnable = new LazyModeRunnable() {
|
lazyModeRunnable = new LazyModeRunnable() {
|
||||||
@ -452,7 +447,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -529,7 +524,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName,
|
accessToken, accountName, postType, postLayout, displaySubredditName,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -600,7 +595,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -665,7 +660,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -726,7 +721,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -786,7 +781,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -840,7 +835,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
mRedgifsRetrofit, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -891,7 +886,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
StaggeredGridLayoutManagerItemOffsetDecoration itemDecoration =
|
StaggeredGridLayoutManagerItemOffsetDecoration itemDecoration =
|
||||||
new StaggeredGridLayoutManagerItemOffsetDecoration(activity, R.dimen.staggeredLayoutManagerItemOffset, nColumns);
|
new StaggeredGridLayoutManagerItemOffsetDecoration(activity, R.dimen.staggeredLayoutManagerItemOffset, nColumns);
|
||||||
mPostRecyclerView.addItemDecoration(itemDecoration);
|
mPostRecyclerView.addItemDecoration(itemDecoration);
|
||||||
windowWidth /= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recyclerViewPosition > 0) {
|
if (recyclerViewPosition > 0) {
|
||||||
|
@ -35,6 +35,10 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.html.HtmlPlugin;
|
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.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
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.FetchSubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
|
||||||
|
import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class SidebarFragment extends Fragment {
|
public class SidebarFragment extends Fragment {
|
||||||
@ -104,8 +110,21 @@ public class SidebarFragment extends Fragment {
|
|||||||
markdownColor = mCustomThemeWrapper.getPrimaryTextColor();
|
markdownColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
|
|
||||||
Markwon markwon = Markwon.builder(activity)
|
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() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
|
return super.processMarkdown(Utils.fixSuperScript(markdown));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
||||||
textView.setTextColor(markdownColor);
|
textView.setTextColor(markdownColor);
|
||||||
|
@ -16,7 +16,6 @@ import android.graphics.drawable.ColorDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -67,6 +66,7 @@ import butterknife.ButterKnife;
|
|||||||
import im.ene.toro.exoplayer.ExoCreator;
|
import im.ene.toro.exoplayer.ExoCreator;
|
||||||
import im.ene.toro.media.PlaybackInfo;
|
import im.ene.toro.media.PlaybackInfo;
|
||||||
import im.ene.toro.media.VolumeInfo;
|
import im.ene.toro.media.VolumeInfo;
|
||||||
|
import im.ene.toro.widget.Container;
|
||||||
import ml.docilealligator.infinityforreddit.DeleteThing;
|
import ml.docilealligator.infinityforreddit.DeleteThing;
|
||||||
import ml.docilealligator.infinityforreddit.Flair;
|
import ml.docilealligator.infinityforreddit.Flair;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
@ -224,7 +224,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
private boolean mExpandChildren;
|
private boolean mExpandChildren;
|
||||||
private boolean mSeparatePostAndComments = false;
|
private boolean mSeparatePostAndComments = false;
|
||||||
private boolean mMarkPostsAsRead;
|
private boolean mMarkPostsAsRead;
|
||||||
private int mWindowWidth;
|
|
||||||
private ConcatAdapter mConcatAdapter;
|
private ConcatAdapter mConcatAdapter;
|
||||||
private PostDetailRecyclerViewAdapter mPostAdapter;
|
private PostDetailRecyclerViewAdapter mPostAdapter;
|
||||||
private CommentsRecyclerViewAdapter mCommentsAdapter;
|
private CommentsRecyclerViewAdapter mCommentsAdapter;
|
||||||
@ -290,10 +289,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
showToast = true;
|
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);
|
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);
|
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);
|
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,
|
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||||
this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
|
this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide,
|
mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide,
|
||||||
mWindowWidth, mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
|
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
||||||
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||||
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
||||||
@ -1195,7 +1190,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||||
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
||||||
mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
||||||
mRedditDataRoomDatabase, mGlide, mWindowWidth, mSeparatePostAndComments,
|
mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
||||||
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
||||||
mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
||||||
mExoCreator,
|
mExoCreator,
|
||||||
@ -1736,28 +1731,32 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToNextParentComment() {
|
public void scrollToNextParentComment() {
|
||||||
int currentPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
RecyclerView chooseYourView = mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView;
|
||||||
if (mCommentsAdapter != null) {
|
if (mCommentsAdapter != null && chooseYourView != null) {
|
||||||
int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
|
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) {
|
if (nextParentPosition < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition);
|
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? nextParentPosition + 1 : nextParentPosition);
|
||||||
mIsSmoothScrolling = true;
|
mIsSmoothScrolling = true;
|
||||||
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller);
|
chooseYourView.getLayoutManager().startSmoothScroll(mSmoothScroller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToPreviousParentComment() {
|
public void scrollToPreviousParentComment() {
|
||||||
int currentPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
RecyclerView chooseYourView = mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView;
|
||||||
if (mCommentsAdapter != null) {
|
if (mCommentsAdapter != null && chooseYourView != null) {
|
||||||
int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
|
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) {
|
if (previousParentPosition < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition);
|
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null && !isSingleCommentThreadMode ? previousParentPosition + 1 : previousParentPosition);
|
||||||
mIsSmoothScrolling = true;
|
mIsSmoothScrolling = true;
|
||||||
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller);
|
chooseYourView.getLayoutManager().startSmoothScroll(mSmoothScroller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.fragments;
|
package ml.docilealligator.infinityforreddit.fragments;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@ -207,11 +208,14 @@ public class ViewRPANBroadcastFragment extends Fragment {
|
|||||||
|
|
||||||
hdButton.setVisibility(View.VISIBLE);
|
hdButton.setVisibility(View.VISIBLE);
|
||||||
hdButton.setOnClickListener(view -> {
|
hdButton.setOnClickListener(view -> {
|
||||||
TrackSelectionDialogBuilder build = new TrackSelectionDialogBuilder(mActivity,
|
TrackSelectionDialogBuilder builder = new TrackSelectionDialogBuilder(mActivity,
|
||||||
getString(R.string.select_video_quality), trackSelector, 0);
|
getString(R.string.select_video_quality), trackSelector, 0);
|
||||||
build.setShowDisableOption(true);
|
builder.setShowDisableOption(true);
|
||||||
build.setAllowAdaptiveSelections(false);
|
builder.setAllowAdaptiveSelections(false);
|
||||||
build.build().show();
|
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++) {
|
for (int i = 0; i < trackGroups.length; i++) {
|
||||||
|
@ -492,7 +492,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
BigImageViewer.imageLoader().cancelAll();
|
imageView.cancel();
|
||||||
SubsamplingScaleImageView subsamplingScaleImageView = imageView.getSSIV();
|
SubsamplingScaleImageView subsamplingScaleImageView = imageView.getSSIV();
|
||||||
if (subsamplingScaleImageView != null) {
|
if (subsamplingScaleImageView != null) {
|
||||||
subsamplingScaleImageView.recycle();
|
subsamplingScaleImageView.recycle();
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -492,26 +492,26 @@ public class CustomizeMainPageTabsFragment extends Fragment {
|
|||||||
|
|
||||||
tab3AddImageView.setOnClickListener(view -> selectName(2));
|
tab3AddImageView.setOnClickListener(view -> selectName(2));
|
||||||
|
|
||||||
showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
|
showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
|
||||||
showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
|
showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
|
||||||
showMultiredditsLinearLayout.setOnClickListener(view -> {
|
showMultiredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showMultiredditsSwitchMaterial.performClick();
|
showMultiredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
|
showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : 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.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
|
||||||
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
|
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showFavoriteMultiredditsSwitchMaterial.performClick();
|
showFavoriteMultiredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
|
showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : 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.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
|
||||||
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showSubscribedSubredditsSwitchMaterial.performClick();
|
showSubscribedSubredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
|
showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : 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.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
|
||||||
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
|
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
@ -1,28 +1,30 @@
|
|||||||
package ml.docilealligator.infinityforreddit.utils;
|
package ml.docilealligator.infinityforreddit.utils;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
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.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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 retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public final class EditProfileUtils {
|
public final class EditProfileUtils {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void updateProfile(Retrofit oauthRetrofit,
|
public static void updateProfile(Retrofit oauthRetrofit,
|
||||||
String accessToken,
|
String accessToken,
|
||||||
String accountName,
|
String accountName,
|
||||||
|
@ -72,10 +72,13 @@ public class Utils {
|
|||||||
.replaceAll("(^|^ *|\\n *)#####(?!($|\\s|#))", "$0 ")
|
.replaceAll("(^|^ *|\\n *)#####(?!($|\\s|#))", "$0 ")
|
||||||
.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;
|
boolean hasBracket = false;
|
||||||
int nCarets = 0;
|
int nCarets = 0;
|
||||||
for (int i = 0; i < regexed.length(); i++) {
|
for (int i = 0; i < regexed.length(); i++) {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:paddingBottom="144dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
|
app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:paddingBottom="144dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
|
app:layoutManager=".customviews.LinearLayoutManagerBugFixed" />
|
||||||
|
|
||||||
|
@ -13,14 +13,23 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:id="@+id/collapsing_toolbar_layout_edit_profile_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
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:id="@+id/toolbar_view_edit_profile_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?attr/actionBarSize"
|
android:minHeight="?attr/actionBarSize"
|
||||||
app:navigationIcon="?attr/homeAsUpIndicator"
|
app:navigationIcon="?attr/homeAsUpIndicator"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
app:title="@string/action_edit_profile" />
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
@ -42,130 +51,121 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/frame_layout_view_banner_edit_profile_activity"
|
android:id="@+id/frame_layout_view_banner_edit_profile_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_margin="8dp">
|
|
||||||
|
|
||||||
<ImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
android:id="@+id/image_view_banner_edit_profile_activity"
|
android:id="@+id/image_view_banner_edit_profile_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="180dp"
|
android:layout_height="180dp"
|
||||||
android:contentDescription="@null"
|
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
tools:src="@tools:sample/backgrounds/scenic" />
|
tools:src="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image_view_change_banner_edit_profile_activity"
|
android:id="@+id/image_view_change_banner_edit_profile_activity"
|
||||||
android:layout_width="32dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="32dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end|bottom"
|
android:layout_gravity="end|bottom"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="8dp"
|
||||||
|
android:padding="8dp"
|
||||||
android:background="@drawable/ic_dot_outline"
|
android:background="@drawable/ic_dot_outline"
|
||||||
android:contentDescription="@null"
|
|
||||||
android:padding="4dp"
|
|
||||||
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
|
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/frame_layout_view_avatar_edit_profile_activity"
|
android:id="@+id/frame_layout_view_avatar_edit_profile_activity"
|
||||||
android:layout_width="74dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="74dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="24dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="143dp"
|
android:layout_marginTop="144dp"
|
||||||
android:elevation="4dp">
|
android:elevation="4dp">
|
||||||
|
|
||||||
<ImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
android:id="@+id/image_view_avatar_edit_profile_activity"
|
android:id="@+id/image_view_avatar_edit_profile_activity"
|
||||||
android:layout_width="74dp"
|
android:layout_width="72dp"
|
||||||
android:layout_height="74dp"
|
android:layout_height="72dp"
|
||||||
android:contentDescription="@null"
|
|
||||||
tools:src="@tools:sample/avatars" />
|
tools:src="@tools:sample/avatars" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image_view_change_avatar_edit_profile_activity"
|
android:id="@+id/image_view_change_avatar_edit_profile_activity"
|
||||||
android:layout_width="32dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="32dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end|bottom"
|
android:layout_gravity="center"
|
||||||
android:layout_margin="4dp"
|
android:padding="8dp"
|
||||||
android:background="@drawable/ic_dot_outline"
|
android:background="@drawable/ic_dot_outline"
|
||||||
android:contentDescription="@null"
|
|
||||||
android:padding="4dp"
|
|
||||||
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
|
app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:background="?dividerVertical" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:orientation="vertical">
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="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:text="@string/display_name_text"
|
||||||
android:textSize="?attr/font_18" />
|
android:textSize="?attr/font_18"
|
||||||
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edit_text_display_name_edit_profile_activity"
|
android:id="@+id/edit_text_display_name_edit_profile_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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:hint="@string/display_name_hint"
|
||||||
android:importantForAutofill="no"
|
android:importantForAutofill="no"
|
||||||
android:inputType="textCapSentences"
|
android:inputType="textCapSentences"
|
||||||
android:lines="1"
|
android:maxLength="30" />
|
||||||
android:maxLength="30"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:paddingBottom="16dp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:orientation="vertical">
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="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:text="@string/about_you_text"
|
||||||
android:textSize="?attr/font_18" />
|
android:textSize="?attr/font_18"
|
||||||
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edit_text_about_you_edit_profile_activity"
|
android:id="@+id/edit_text_about_you_edit_profile_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
android:gravity="top"
|
android:gravity="top"
|
||||||
|
android:background="#00000000"
|
||||||
|
android:textSize="?attr/font_16"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
android:hint="@string/about_you_hint"
|
android:hint="@string/about_you_hint"
|
||||||
android:importantForAutofill="no"
|
android:importantForAutofill="no"
|
||||||
android:inputType="textCapSentences|textMultiLine"
|
android:inputType="textCapSentences|textMultiLine"
|
||||||
android:lines="4"
|
android:maxLength="200" />
|
||||||
android:maxLength="200"
|
|
||||||
android:maxLines="4"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:paddingBottom="16dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_1_post_gallery_activity"
|
android:id="@+id/divider_1_post_gallery_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -127,17 +127,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider_2_post_gallery_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_gallery_activity"
|
android:id="@+id/receive_post_reply_notifications_linear_layout_post_gallery_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -164,10 +157,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_3_post_gallery_activity"
|
android:id="@+id/divider_2_post_gallery_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/post_title_edit_text_post_gallery_activity"
|
android:id="@+id/post_title_edit_text_post_gallery_activity"
|
||||||
@ -182,11 +175,6 @@
|
|||||||
android:textSize="?attr/title_font_18"
|
android:textSize="?attr/title_font_18"
|
||||||
android:fontFamily="?attr/title_font_family" />
|
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
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/images_recycler_view_post_gallery_activity"
|
android:id="@+id/images_recycler_view_post_gallery_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -73,10 +73,10 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_1_post_image_activity"
|
android:id="@+id/divider_1_post_image_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -127,17 +127,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider_2_post_image_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
|
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -164,10 +157,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_3_post_image_activity"
|
android:id="@+id/divider_2_post_image_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/post_title_edit_text_post_image_activity"
|
android:id="@+id/post_title_edit_text_post_image_activity"
|
||||||
@ -182,11 +175,6 @@
|
|||||||
android:textSize="?attr/title_font_18"
|
android:textSize="?attr/title_font_18"
|
||||||
android:fontFamily="?attr/title_font_family" />
|
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
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/select_image_constraint_layout_post_image_activity"
|
android:id="@+id/select_image_constraint_layout_post_image_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -73,10 +73,10 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_1_post_link_activity"
|
android:id="@+id/divider_1_post_link_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -127,17 +127,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider_2_post_link_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
|
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -164,10 +157,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_3_post_link_activity"
|
android:id="@+id/divider_2_post_link_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -201,11 +194,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider_4_post_link_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp" />
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/post_link_edit_text_post_link_activity"
|
android:id="@+id/post_link_edit_text_post_link_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -79,10 +79,10 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_1_post_text_activity"
|
android:id="@+id/divider_1_post_text_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -130,17 +130,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider_2_post_text_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_text_activity"
|
android:id="@+id/receive_post_reply_notifications_linear_layout_post_text_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -167,10 +160,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_3_post_text_activity"
|
android:id="@+id/divider_2_post_text_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/post_title_edit_text_post_text_activity"
|
android:id="@+id/post_title_edit_text_post_text_activity"
|
||||||
@ -184,11 +177,6 @@
|
|||||||
android:textSize="?attr/title_font_18"
|
android:textSize="?attr/title_font_18"
|
||||||
android:fontFamily="?attr/title_font_family" />
|
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
|
<EditText
|
||||||
android:id="@+id/post_text_content_edit_text_post_text_activity"
|
android:id="@+id/post_text_content_edit_text_post_text_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -73,10 +73,10 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_1_post_video_activity"
|
android:id="@+id/divider_1_post_video_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -127,17 +127,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider_2_post_video_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_video_activity"
|
android:id="@+id/receive_post_reply_notifications_linear_layout_post_video_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -164,10 +157,10 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/divider_3_post_video_activity"
|
android:id="@+id/divider_2_post_video_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/post_title_edit_text_post_video_activity"
|
android:id="@+id/post_title_edit_text_post_video_activity"
|
||||||
@ -182,11 +175,6 @@
|
|||||||
android:textSize="?attr/title_font_18"
|
android:textSize="?attr/title_font_18"
|
||||||
android:fontFamily="?attr/title_font_family" />
|
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
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/select_video_constraint_layout_post_video_activity"
|
android:id="@+id/select_video_constraint_layout_post_video_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -197,25 +185,27 @@
|
|||||||
android:id="@+id/capture_fab_post_video_activity"
|
android:id="@+id/capture_fab_post_video_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
android:src="@drawable/ic_outline_add_a_photo_24dp"
|
android:src="@drawable/ic_outline_add_a_photo_24dp"
|
||||||
|
app:useCompatPadding="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
|
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
|
||||||
app:layout_constraintHorizontal_chainStyle="spread"
|
app:layout_constraintHorizontal_chainStyle="spread"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
app:tint="@android:color/white" />
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/select_from_library_fab_post_video_activity"
|
android:id="@+id/select_from_library_fab_post_video_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
android:src="@drawable/ic_outline_select_photo_24dp"
|
android:src="@drawable/ic_outline_select_photo_24dp"
|
||||||
|
app:useCompatPadding="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_chainStyle="spread"
|
app:layout_constraintHorizontal_chainStyle="spread"
|
||||||
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
|
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
app:tint="@android:color/white" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
@ -119,6 +119,14 @@
|
|||||||
android:src="@drawable/ic_file_download_toolbar_white_24dp"
|
android:src="@drawable/ic_file_download_toolbar_white_24dp"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.bottomappbar.BottomAppBar>
|
</com.google.android.material.bottomappbar.BottomAppBar>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_timeout="1500"
|
app:show_timeout="1500"
|
||||||
|
app:auto_show="false"
|
||||||
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
|
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_timeout="1500"
|
app:show_timeout="1500"
|
||||||
|
app:auto_show="false"
|
||||||
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
|
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
@ -214,6 +214,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_timeout="1500"
|
app:show_timeout="1500"
|
||||||
|
app:auto_show="false"
|
||||||
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
|
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
@ -214,6 +214,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_timeout="1500"
|
app:show_timeout="1500"
|
||||||
|
app:auto_show="false"
|
||||||
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
|
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
@ -208,6 +208,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_timeout="1500"
|
app:show_timeout="1500"
|
||||||
|
app:auto_show="false"
|
||||||
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
|
app:controller_layout_id="@layout/exo_autoplay_playback_control_view" />
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
@ -208,6 +208,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:show_timeout="1500"
|
app:show_timeout="1500"
|
||||||
|
app:auto_show="false"
|
||||||
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
|
app:controller_layout_id="@layout/exo_autoplay_playback_control_view_legacy" />
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
@ -216,8 +216,7 @@
|
|||||||
android:id="@+id/image_view_item_post_with_preview"
|
android:id="@+id/image_view_item_post_with_preview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true" />
|
||||||
android:scaleType="fitStart" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/video_or_gif_indicator_image_view_item_post_with_preview"
|
android:id="@+id/video_or_gif_indicator_image_view_item_post_with_preview"
|
||||||
|
@ -6,6 +6,6 @@
|
|||||||
android:id="@+id/action_save_edit_profile_activity"
|
android:id="@+id/action_save_edit_profile_activity"
|
||||||
android:orderInCategory="1"
|
android:orderInCategory="1"
|
||||||
android:title="@string/action_save"
|
android:title="@string/action_save"
|
||||||
android:icon="@drawable/ic_save_to_database_24dp"
|
android:icon="@drawable/ic_check_circle_toolbar_24dp"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
</menu>
|
</menu>
|
@ -54,8 +54,14 @@
|
|||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_go_to_wiki_activity"
|
android:id="@+id/action_go_to_wiki_view_subreddit_detail_activity"
|
||||||
android:orderInCategory="9"
|
android:orderInCategory="9"
|
||||||
android:title="@string/action_go_to_wiki"
|
android:title="@string/action_go_to_wiki"
|
||||||
app:showAsAction="never" />
|
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>
|
</menu>
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
<string name="post_gallery_activity_label">Gallery Post</string>
|
<string name="post_gallery_activity_label">Gallery Post</string>
|
||||||
<string name="trending_activity_label">Trending</string>
|
<string name="trending_activity_label">Trending</string>
|
||||||
<string name="wiki_activity_label">Wiki</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_open">Open navigation drawer</string>
|
||||||
<string name="navigation_drawer_close">Close 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_share_post_link">Share Post Link</string>
|
||||||
<string name="action_go_to_wiki">Go to Wiki</string>
|
<string name="action_go_to_wiki">Go to Wiki</string>
|
||||||
<string name="action_playback_speed">Playback Speed</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="parse_json_response_error">Error occurred when parsing the JSON response</string>
|
||||||
<string name="retrieve_token_error">Error Retrieving the token</string>
|
<string name="retrieve_token_error">Error Retrieving the token</string>
|
||||||
@ -1226,18 +1228,18 @@
|
|||||||
<string name="remove_banner">Remove Banner</string>
|
<string name="remove_banner">Remove Banner</string>
|
||||||
<string name="display_name_text">Display Name</string>
|
<string name="display_name_text">Display Name</string>
|
||||||
<string name="display_name_hint">Show on your profile page</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_text">About You</string>
|
||||||
<string name="about_you_hint">A little description of yourself</string>
|
<string name="about_you_hint">A little description of yourself</string>
|
||||||
<string name="message_remove_avatar_success">Success remove Avatar</string>
|
<string name="message_remove_avatar_success">Remove avatar successfully</string>
|
||||||
<string name="message_remove_avatar_failed_fmt">Failed remove Avatar %s</string>
|
<string name="message_remove_avatar_failed_fmt">Failed to remove avatar %s</string>
|
||||||
<string name="message_remove_banner_success">Success remove Banner</string>
|
<string name="message_remove_banner_success">Remove banner successfully</string>
|
||||||
<string name="message_remove_banner_failed_fmt">Failed remove Banner %s</string>
|
<string name="message_remove_banner_failed_fmt">Failed to remove banner %s</string>
|
||||||
<string name="message_change_avatar_success">Success changing Avatar</string>
|
<string name="message_change_avatar_success">Change avatar successfully</string>
|
||||||
<string name="message_change_avatar_failed_fmt">Failed changing Avatar %s</string>
|
<string name="message_change_avatar_failed_fmt">Failed to change avatar %s</string>
|
||||||
<string name="message_change_banner_success">Success changing Banner</string>
|
<string name="message_change_banner_success">Changing banner successfully</string>
|
||||||
<string name="message_change_banner_failed_fmt">Failed changing Banner %s</string>
|
<string name="message_change_banner_failed_fmt">Failed to change banner %s</string>
|
||||||
<string name="message_save_profile_success">Success save profile</string>
|
<string name="message_save_profile_success">Save profile successfully</string>
|
||||||
<string name="message_save_profile_failed_fmt">Failed save profile %s</string>
|
<string name="message_save_profile_failed_fmt">Failed to save profile %s</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user