mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-06 06:34:46 +01:00
Compare commits
4 Commits
279820c1be
...
4ce8fd6a63
Author | SHA1 | Date | |
---|---|---|---|
|
4ce8fd6a63 | ||
|
ffc2d669e5 | ||
|
926e1162f0 | ||
|
6cf69ee26d |
@ -8,8 +8,8 @@ android {
|
||||
applicationId "eu.toldi.infinityforlemmy"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 126
|
||||
versionName "0.0.6"
|
||||
versionCode 128
|
||||
versionName "0.0.8"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@ -169,6 +169,7 @@ dependencies {
|
||||
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
||||
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
||||
implementation "io.noties.markwon:inline-parser:$markwonVersion"
|
||||
implementation "io.noties.markwon:image-glide:$markwonVersion"
|
||||
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
||||
implementation 'me.saket:better-link-movement-method:2.2.0'
|
||||
|
||||
|
@ -38,7 +38,7 @@ import eu.toldi.infinityforlemmy.user.UserData;
|
||||
|
||||
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
||||
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
|
||||
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class}, version = 23)
|
||||
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class}, version = 24)
|
||||
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||
|
||||
public static RedditDataRoomDatabase create(final Context context) {
|
||||
@ -49,7 +49,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
|
||||
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
|
||||
MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
|
||||
MIGRATION_21_22, MIGRATION_22_23)
|
||||
MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -383,4 +383,11 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_23_24 = new Migration(23, 24) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE accounts ADD COLUMN can_downvote INTEGER DEFAULT 1 NOT NULL");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ public class Account implements Parcelable {
|
||||
@ColumnInfo(name = "instance_url")
|
||||
private String instance_url;
|
||||
|
||||
@ColumnInfo(name = "can_downvote")
|
||||
private boolean canDownvote = true;
|
||||
|
||||
@Ignore
|
||||
protected Account(Parcel in) {
|
||||
accountName = in.readString();
|
||||
@ -42,6 +45,7 @@ public class Account implements Parcelable {
|
||||
code = in.readString();
|
||||
isCurrentUser = in.readByte() != 0;
|
||||
instance_url = in.readString();
|
||||
canDownvote = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
||||
@ -58,11 +62,11 @@ public class Account implements Parcelable {
|
||||
|
||||
@Ignore
|
||||
public static Account getAnonymousAccount() {
|
||||
return new Account("-",null, null, null, null, null, false,null);
|
||||
return new Account("-",null, null, null, null, null, false,null,true);
|
||||
}
|
||||
|
||||
public Account(@NonNull String accountName, String display_name, String accessToken, String code,
|
||||
String profileImageUrl, String bannerImageUrl, boolean isCurrentUser,String instance_url) {
|
||||
String profileImageUrl, String bannerImageUrl, boolean isCurrentUser,String instance_url, boolean canDownvote) {
|
||||
this.accountName = accountName;
|
||||
this.display_name = display_name;
|
||||
this.accessToken = accessToken;
|
||||
@ -71,6 +75,7 @@ public class Account implements Parcelable {
|
||||
this.bannerImageUrl = bannerImageUrl;
|
||||
this.isCurrentUser = isCurrentUser;
|
||||
this.instance_url = instance_url;
|
||||
this.canDownvote = canDownvote;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -116,6 +121,10 @@ public class Account implements Parcelable {
|
||||
return instance_url;
|
||||
}
|
||||
|
||||
public boolean canDownvote() {
|
||||
return canDownvote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(accountName);
|
||||
@ -126,5 +135,6 @@ public class Account implements Parcelable {
|
||||
dest.writeString(code);
|
||||
dest.writeByte((byte) (isCurrentUser ? 1 : 0));
|
||||
dest.writeString(instance_url);
|
||||
dest.writeByte((byte) (canDownvote ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
@ -513,8 +513,8 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
||||
int start = Math.max(binding.commentCommentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(binding.commentCommentEditText.getSelectionEnd(), 0);
|
||||
binding.commentCommentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
"![" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -345,7 +345,7 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
"![" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
"![" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ import eu.toldi.infinityforlemmy.asynctasks.ParseAndInsertNewAccount;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
||||
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
|
||||
import eu.toldi.infinityforlemmy.site.SiteInfo;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Call;
|
||||
@ -176,17 +178,35 @@ public class LoginActivity extends BaseActivity {
|
||||
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
||||
@Override
|
||||
public void onFetchMyInfoSuccess(String name, String display_name, String profileImageUrl, String bannerImageUrl) {
|
||||
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), accessToken, new FetchSiteInfo.FetchSiteInfoListener() {
|
||||
@Override
|
||||
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||
boolean canDownvote = siteInfo.isEnable_downvotes();
|
||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode,instance,canDownvote, mRedditDataRoomDatabase.accountDao(),
|
||||
() -> {
|
||||
Intent resultIntent = new Intent();
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
finish();
|
||||
});
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSiteInfoFailed() {
|
||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode,instance,true, mRedditDataRoomDatabase.accountDao(),
|
||||
() -> {
|
||||
Intent resultIntent = new Intent();
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
finish();
|
||||
});
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
|
||||
}
|
||||
});
|
||||
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_NAME, display_name)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, name)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,instance)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply();
|
||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode,instance, mRedditDataRoomDatabase.accountDao(),
|
||||
() -> {
|
||||
Intent resultIntent = new Intent();
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -792,7 +792,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
"![" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
"![" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
|
@ -673,8 +673,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
"![" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,7 @@ import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.inlineparser.BangInlineProcessor;
|
||||
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
@ -105,7 +105,6 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
|
||||
mMarkwon = Markwon.builder(mActivity)
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
@ -129,6 +128,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(GlideImagesPlugin.create(mActivity))
|
||||
.build();
|
||||
mAccessToken = accessToken;
|
||||
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||
|
@ -1219,6 +1219,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
this.mSaveButton = mSaveButton;
|
||||
this.mShareButton = mShareButton;
|
||||
|
||||
if(!mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE,true)){
|
||||
mDownvoteButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mIconGifImageView.setOnClickListener(view -> mSubredditTextView.performClick());
|
||||
|
||||
mSubredditTextView.setOnClickListener(view -> {
|
||||
|
@ -2370,6 +2370,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
this.shareButton = shareButton;
|
||||
|
||||
scoreTextView.setOnClickListener(null);
|
||||
if(!mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE,true)){
|
||||
downvoteButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (mVoteButtonsOnTheRight) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
@ -3727,6 +3730,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
|
||||
scoreTextView.setOnClickListener(null);
|
||||
|
||||
if(!mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE,true)){
|
||||
downvoteButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (mVoteButtonsOnTheRight) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
constraintSet.clone(bottomConstraintLayout);
|
||||
|
@ -221,4 +221,9 @@ public interface LemmyAPI {
|
||||
@Query("id") int commentId,
|
||||
@Query("auth") String auth
|
||||
);
|
||||
|
||||
@GET("api/v3/site")
|
||||
Call<String> getSiteInfo(
|
||||
@Query("auth") String auth
|
||||
);
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ public class ParseAndInsertNewAccount {
|
||||
|
||||
public static void parseAndInsertNewAccount(Executor executor, Handler handler, String username,
|
||||
String display_name,String accessToken, String profileImageUrl,
|
||||
String bannerImageUrl, String code,String instance, AccountDao accountDao,
|
||||
String bannerImageUrl, String code,String instance,boolean can_downvote, AccountDao accountDao,
|
||||
ParseAndInsertAccountListener parseAndInsertAccountListener) {
|
||||
executor.execute(() -> {
|
||||
Account account = new Account(username,display_name, accessToken, code, profileImageUrl,
|
||||
bannerImageUrl, true,instance);
|
||||
bannerImageUrl, true,instance,true);
|
||||
accountDao.markAllAccountsNonCurrent();
|
||||
accountDao.insert(account);
|
||||
|
||||
|
@ -8,6 +8,8 @@ import java.util.concurrent.Executor;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
|
||||
import eu.toldi.infinityforlemmy.site.SiteInfo;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
public class SwitchAccount {
|
||||
@ -26,6 +28,18 @@ public class SwitchAccount {
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,account.getInstance_url())
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, account.getProfileImageUrl()).apply();
|
||||
retrofitHolder.setBaseURL(account.getInstance_url());
|
||||
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
|
||||
@Override
|
||||
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||
boolean canDownvote = siteInfo.isEnable_downvotes();
|
||||
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSiteInfoFailed() {
|
||||
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
|
||||
}
|
||||
});
|
||||
handler.post(() -> switchAccountListener.switched(account));
|
||||
});
|
||||
|
||||
|
@ -55,12 +55,8 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
TextView shareTextView;
|
||||
@BindView(R.id.copy_text_view_comment_more_bottom_sheet_fragment)
|
||||
TextView copyTextView;
|
||||
@BindView(R.id.give_award_text_view_comment_more_bottom_sheet_fragment)
|
||||
TextView giveAwardTextView;
|
||||
@BindView(R.id.report_view_comment_more_bottom_sheet_fragment)
|
||||
TextView reportTextView;
|
||||
@BindView(R.id.see_removed_view_comment_more_bottom_sheet_fragment)
|
||||
TextView seeRemovedTextView;
|
||||
private BaseActivity activity;
|
||||
|
||||
public CommentMoreBottomSheetFragment() {
|
||||
@ -93,18 +89,6 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
|
||||
|
||||
if (accessToken != null && !accessToken.equals("")) {
|
||||
giveAwardTextView.setVisibility(View.VISIBLE);
|
||||
giveAwardTextView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(activity, GiveAwardActivity.class);
|
||||
intent.putExtra(GiveAwardActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
||||
intent.putExtra(GiveAwardActivity.EXTRA_ITEM_POSITION, bundle.getInt(EXTRA_POSITION));
|
||||
if (activity instanceof ViewPostDetailActivity) {
|
||||
activity.startActivityForResult(intent, ViewPostDetailActivity.GIVE_AWARD_REQUEST_CODE);
|
||||
} else if (activity instanceof ViewUserDetailActivity) {
|
||||
activity.startActivityForResult(intent, ViewUserDetailActivity.GIVE_AWARD_REQUEST_CODE);
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if (editAndDeleteAvailable) {
|
||||
editTextView.setVisibility(View.VISIBLE);
|
||||
@ -193,27 +177,14 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
});
|
||||
|
||||
reportTextView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(activity, ReportActivity.class);
|
||||
/*Intent intent = new Intent(activity, ReportActivity.class);
|
||||
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getCommunityName());
|
||||
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
||||
activity.startActivity(intent);
|
||||
|
||||
activity.startActivity(intent);*/
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if ("[deleted]".equals(comment.getAuthor()) ||
|
||||
"[deleted]".equals(comment.getCommentRawText()) ||
|
||||
"[removed]".equals(comment.getCommentRawText())
|
||||
) {
|
||||
seeRemovedTextView.setVisibility(View.VISIBLE);
|
||||
|
||||
seeRemovedTextView.setOnClickListener(view -> {
|
||||
dismiss();
|
||||
if (activity instanceof ViewPostDetailActivity) {
|
||||
((ViewPostDetailActivity) activity).showRemovedComment(comment, bundle.getInt(EXTRA_POSITION));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (activity.typeface != null) {
|
||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
||||
|
@ -24,7 +24,6 @@ import java.util.TimeZone;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
|
||||
@ -310,7 +309,7 @@ public class ParseComment {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String content = MarkdownUtils.processImageCaptions(commentObj.getString("content"), "Image");
|
||||
String content = commentObj.getString("content");
|
||||
String commentMarkdown = content;
|
||||
String commentRawText = content;
|
||||
String linkId = postObj.getString("id");
|
||||
|
@ -78,7 +78,6 @@ import eu.toldi.infinityforlemmy.SaveThing;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.EditPostActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.PostFilterPreferenceActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ReportActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.SubmitCrosspostActivity;
|
||||
@ -114,7 +113,6 @@ import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import eu.toldi.infinityforlemmy.videoautoplay.ExoCreator;
|
||||
@ -709,7 +707,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
MenuItem spoilerItem = mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment);
|
||||
spoilerItem.setVisible(true);
|
||||
|
||||
mMenu.findItem(R.id.action_edit_flair_view_post_detail_fragment).setVisible(true);
|
||||
mMenu.findItem(R.id.action_block_user_view_post_detail_fragment).setVisible(false);
|
||||
}
|
||||
|
||||
mMenu.findItem(R.id.action_view_crosspost_parent_view_post_detail_fragment).setVisible(mPost.getCrosspostParentId() != null);
|
||||
@ -1072,35 +1070,18 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
return true;
|
||||
} else if (itemId == R.id.action_spoiler_view_post_detail_fragment) {
|
||||
return true;
|
||||
} else if (itemId == R.id.action_edit_flair_view_post_detail_fragment) {
|
||||
FlairBottomSheetFragment flairBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
|
||||
bundle.putLong(FlairBottomSheetFragment.EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID, viewPostDetailFragmentId);
|
||||
flairBottomSheetFragment.setArguments(bundle);
|
||||
flairBottomSheetFragment.show(activity.getSupportFragmentManager(), flairBottomSheetFragment.getTag());
|
||||
} else if (itemId == R.id.action_block_user_view_post_detail_fragment) {
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_give_award_view_post_detail_fragment) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
Intent giveAwardIntent = new Intent(activity, GiveAwardActivity.class);
|
||||
giveAwardIntent.putExtra(GiveAwardActivity.EXTRA_THING_FULLNAME, mPost.getFullName());
|
||||
giveAwardIntent.putExtra(GiveAwardActivity.EXTRA_ITEM_POSITION, 0);
|
||||
activity.startActivityForResult(giveAwardIntent, ViewPostDetailActivity.GIVE_AWARD_REQUEST_CODE);
|
||||
} else if (itemId == R.id.action_block_community_view_post_detail_fragment) {
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_report_view_post_detail_fragment) {
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
Intent intent = new Intent(activity, ReportActivity.class);
|
||||
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
|
||||
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName());
|
||||
startActivity(intent);
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
} else if (itemId == R.id.action_see_removed_view_post_detail_fragment) {
|
||||
showRemovedPost();
|
||||
@ -1190,7 +1171,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
if (mCommentsRecyclerView != null) {
|
||||
LinearLayoutManager myLayoutManager = (LinearLayoutManager) mCommentsRecyclerView.getLayoutManager();
|
||||
scrollPosition = myLayoutManager != null ? myLayoutManager.findFirstVisibleItemPosition() : 0;
|
||||
|
||||
|
||||
} else {
|
||||
LinearLayoutManager myLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||
scrollPosition = myLayoutManager != null ? myLayoutManager.findFirstVisibleItemPosition() : 0;
|
||||
@ -1250,7 +1231,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
mPostDetailsSharedPreferences, mExoCreator,
|
||||
post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, post.getId(), mSingleCommentId == 0 ? null : mSingleCommentParentId == 0 ? mSingleCommentId : mSingleCommentParentId, sortType, mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, post.getId(), mSingleCommentId == null || mSingleCommentId == 0 ? null : mSingleCommentParentId == 0 ? mSingleCommentId : mSingleCommentParentId, sortType, mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
||||
pages_loaded++;
|
||||
@ -1369,7 +1350,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
|
||||
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, mPost.getId(), commentId, sortType, mExpandChildren, pages_loaded + 1,
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, mPost.getId(), mSingleCommentId == null || mSingleCommentId == 0 ? null : mSingleCommentParentId == 0 ? mSingleCommentId : mSingleCommentParentId, sortType, mExpandChildren, pages_loaded + 1,
|
||||
new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments,
|
||||
@ -1438,8 +1419,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
@Override
|
||||
public void onFetchCommentFailed() {
|
||||
isFetchingComments = false;
|
||||
|
||||
mCommentsAdapter.initiallyLoadCommentsFailed();
|
||||
if(pages_loaded == 0)
|
||||
mCommentsAdapter.initiallyLoadCommentsFailed();
|
||||
if (changeRefreshState) {
|
||||
isRefreshing = false;
|
||||
}
|
||||
@ -1459,7 +1440,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
isLoadingMoreChildren = true;
|
||||
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken,
|
||||
mPost.getId(), null, sortType, mExpandChildren, pages_loaded + 1, new FetchComment.FetchCommentListener() {
|
||||
mPost.getId(), mSingleCommentId == 0 ? null : mSingleCommentParentId == 0 ? mSingleCommentId : mSingleCommentParentId, sortType, mExpandChildren, pages_loaded + 1, new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
||||
pages_loaded++;
|
||||
|
@ -0,0 +1,59 @@
|
||||
package eu.toldi.infinityforlemmy.markdown;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.commonmark.node.Image;
|
||||
|
||||
import eu.toldi.infinityforlemmy.activities.ViewImageOrGifActivity;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.MarkwonSpansFactory;
|
||||
import io.noties.markwon.RenderProps;
|
||||
import io.noties.markwon.image.AsyncDrawableSpan;
|
||||
import io.noties.markwon.image.ImageSpanFactory;
|
||||
|
||||
public class ClickableGlideImagesPlugin extends AbstractMarkwonPlugin {
|
||||
|
||||
public static Context context;
|
||||
|
||||
public ClickableGlideImagesPlugin(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public static ClickableGlideImagesPlugin create(Context context) {
|
||||
return new ClickableGlideImagesPlugin(context);
|
||||
}
|
||||
@Override
|
||||
public void configureSpansFactory(@NonNull MarkwonSpansFactory.Builder builder) {
|
||||
builder.setFactory(Image.class, new ClickableImageFactory());
|
||||
}
|
||||
|
||||
class ClickableImageFactory extends ImageSpanFactory {
|
||||
@Override
|
||||
public Object getSpans(@NonNull MarkwonConfiguration configuration, @NonNull RenderProps props) {
|
||||
AsyncDrawableSpan image = (AsyncDrawableSpan) super.getSpans(configuration, props);
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
Intent intent = new Intent(context, ViewImageOrGifActivity.class);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, image.getDrawable().getDestination());
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, image.getDrawable().getDestination());
|
||||
context.startActivity(intent);
|
||||
}
|
||||
};
|
||||
Object[] objects = new Object[2];
|
||||
objects[0] = image;
|
||||
objects[1] = clickableSpan;
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.commonmark.ext.gfm.tables.TableBlock;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
@ -16,6 +15,7 @@ import eu.toldi.infinityforlemmy.customviews.CustomMarkwonAdapter;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonPlugin;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||
import io.noties.markwon.inlineparser.BangInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
@ -38,9 +38,9 @@ public class MarkdownUtils {
|
||||
int spoilerBackgroundColor,
|
||||
@Nullable BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener) {
|
||||
return Markwon.builder(context)
|
||||
.usePlugin(GlideImagesPlugin.create(context))
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(miscPlugin)
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
@ -51,6 +51,7 @@ public class MarkdownUtils {
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(ClickableGlideImagesPlugin.create(context))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -60,7 +61,6 @@ public class MarkdownUtils {
|
||||
return Markwon.builder(context)
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(miscPlugin)
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
@ -70,6 +70,7 @@ public class MarkdownUtils {
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.usePlugin(GlideImagesPlugin.create(context))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -104,6 +105,15 @@ public class MarkdownUtils {
|
||||
.build();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static MarkwonAdapter createTablesAndImagesAdapter(@NonNull Context context) {
|
||||
return MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
||||
.include(TableBlock.class, TableEntry.create(builder -> builder
|
||||
.tableLayout(R.layout.adapter_table_block, R.id.table_layout)
|
||||
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CustomMarkwonAdapter configured with support for tables.
|
||||
*/
|
||||
@ -119,35 +129,4 @@ public class MarkdownUtils {
|
||||
private static final Pattern emptyPattern = Pattern.compile("!\\[\\]\\((.*?)\\)");
|
||||
private static final Pattern nonEmptyPattern = Pattern.compile("!\\[(.*?)\\]\\((.*?)\\)");
|
||||
|
||||
public static String processImageCaptions(String markdown, String replacementCaption) {
|
||||
// Pattern for Markdown images with empty captions
|
||||
|
||||
// Pattern for Markdown images with non-empty captions
|
||||
|
||||
|
||||
Matcher emptyMatcher = emptyPattern.matcher(markdown);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
while (emptyMatcher.find()) {
|
||||
// Replace the matched pattern with the same URL, but with a caption
|
||||
emptyMatcher.appendReplacement(sb, "[" + replacementCaption + "](" + emptyMatcher.group(1) + ")");
|
||||
}
|
||||
|
||||
// Append the rest of the content
|
||||
emptyMatcher.appendTail(sb);
|
||||
|
||||
// Now process non-empty captions
|
||||
Matcher nonEmptyMatcher = nonEmptyPattern.matcher(sb.toString());
|
||||
StringBuffer finalSb = new StringBuffer();
|
||||
|
||||
while (nonEmptyMatcher.find()) {
|
||||
// Replace the matched pattern with the same URL and caption, but without the "!"
|
||||
nonEmptyMatcher.appendReplacement(finalSb, "[" + nonEmptyMatcher.group(1) + "](" + nonEmptyMatcher.group(2) + ")");
|
||||
}
|
||||
|
||||
// Append the rest of the content
|
||||
nonEmptyMatcher.appendTail(finalSb);
|
||||
|
||||
return finalSb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -214,6 +214,7 @@ public class ParsePost {
|
||||
|
||||
String url = (!data.getJSONObject("post").isNull("url")) ? data.getJSONObject("post").getString("url") : "";
|
||||
String communityURL = (!data.getJSONObject("community").isNull("icon")) ? data.getJSONObject("community").getString("icon") : "";
|
||||
String authorAvatar = (!data.getJSONObject("creator").isNull("avatar")) ? data.getJSONObject("creator").getString("avatar") : null;
|
||||
|
||||
Uri uri = Uri.parse(url);
|
||||
String path = uri.getPath();
|
||||
@ -654,14 +655,14 @@ public class ParsePost {
|
||||
post.setVoteType(data.getInt("my_vote"));
|
||||
post.setScore(post.getScore() - 1);
|
||||
}
|
||||
|
||||
|
||||
if (!data.getJSONObject("post").isNull("body")) {
|
||||
String body = MarkdownUtils.processImageCaptions(data.getJSONObject("post").getString("body"), "Image");
|
||||
String body = data.getJSONObject("post").getString("body");
|
||||
post.setSelfText(body);
|
||||
post.setSelfTextPlain(body);
|
||||
post.setSelfTextPlainTrimmed(body.trim());
|
||||
}
|
||||
|
||||
post.setAuthorIconUrl(authorAvatar);
|
||||
post.setSubredditIconUrl(communityURL);
|
||||
return post;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package eu.toldi.infinityforlemmy.site;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class FetchSiteInfo {
|
||||
|
||||
public static void fetchSiteInfo(Retrofit retrofit, String accesToken, FetchSiteInfoListener fetchSiteInfoListener) {
|
||||
retrofit.create(LemmyAPI.class).getSiteInfo(accesToken).enqueue(
|
||||
new retrofit2.Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(retrofit2.Call<String> call, retrofit2.Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
String siteInfoJson = response.body();
|
||||
SiteInfo siteInfo = SiteInfo.parseSiteInfo(siteInfoJson);
|
||||
fetchSiteInfoListener.onFetchSiteInfoSuccess(siteInfo);
|
||||
} else {
|
||||
fetchSiteInfoListener.onFetchSiteInfoFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(retrofit2.Call<String> call, Throwable t) {
|
||||
fetchSiteInfoListener.onFetchSiteInfoFailed();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public interface FetchSiteInfoListener {
|
||||
void onFetchSiteInfoSuccess(SiteInfo siteInfo);
|
||||
void onFetchSiteInfoFailed();
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package eu.toldi.infinityforlemmy.site;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class SiteInfo {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String sidebar;
|
||||
private String description;
|
||||
private boolean enable_downvotes;
|
||||
private boolean enable_nsfw;
|
||||
private boolean community_creation_admin_only;
|
||||
|
||||
public SiteInfo(int id, String name, String sidebar, String description, boolean enable_downvotes, boolean enable_nsfw, boolean community_creation_admin_only) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.sidebar = sidebar;
|
||||
this.description = description;
|
||||
this.enable_downvotes = enable_downvotes;
|
||||
this.enable_nsfw = enable_nsfw;
|
||||
this.community_creation_admin_only = community_creation_admin_only;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSidebar() {
|
||||
return sidebar;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public boolean isEnable_downvotes() {
|
||||
return enable_downvotes;
|
||||
}
|
||||
|
||||
public boolean isEnable_nsfw() {
|
||||
return enable_nsfw;
|
||||
}
|
||||
|
||||
public boolean isCommunity_creation_admin_only() {
|
||||
return community_creation_admin_only;
|
||||
}
|
||||
|
||||
public static SiteInfo parseSiteInfo(String siteInfoJson) {
|
||||
try {
|
||||
JSONObject siteInfo = new JSONObject(siteInfoJson);
|
||||
JSONObject siteView = siteInfo.getJSONObject("site_view");
|
||||
JSONObject site = siteView.getJSONObject("site");
|
||||
JSONObject localSite = siteView.getJSONObject("local_site");
|
||||
|
||||
int id = site.getInt("id");
|
||||
String name = site.getString("name");
|
||||
String sidebar = null;
|
||||
if (site.has("sidebar"))
|
||||
sidebar = site.getString("sidebar");
|
||||
|
||||
String description = null;
|
||||
if (site.has("description"))
|
||||
description = site.getString("description");
|
||||
|
||||
boolean enable_downvotes = localSite.getBoolean("enable_downvotes");
|
||||
boolean enable_nsfw = localSite.getBoolean("enable_nsfw");
|
||||
boolean community_creation_admin_only = localSite.getBoolean("community_creation_admin_only");
|
||||
|
||||
SiteInfo si = new SiteInfo(id, name, sidebar, description, enable_downvotes, enable_nsfw, community_creation_admin_only);
|
||||
|
||||
return si;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -400,4 +400,5 @@ public class SharedPreferencesUtils {
|
||||
public static final String OPEN_LINK_IN_APP_LEGACY = "open_link_in_app";
|
||||
public static final String ACCOUNT_INSTANCE = "account_instance";
|
||||
public static final String ACCOUNT_QUALIFIED_NAME = "account_qualified_name";
|
||||
public static final String CAN_DOWNVOTE = "can_downvote";
|
||||
}
|
||||
|
@ -382,8 +382,8 @@ public final class Utils {
|
||||
int start = Math.max(editText.getSelectionStart(), 0);
|
||||
int end = Math.max(editText.getSelectionEnd(), 0);
|
||||
editText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + fileName + "](" + imageUrlOrError + ")",
|
||||
0, "[]()".length() + fileName.length() + imageUrlOrError.length());
|
||||
"![" + fileName + "](" + imageUrlOrError + ")",
|
||||
0, "![]()".length() + fileName.length() + imageUrlOrError.length());
|
||||
Snackbar.make(coordinatorLayout, R.string.upload_image_success, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(context, R.string.upload_image_failed, Toast.LENGTH_LONG).show();
|
||||
|
@ -124,25 +124,6 @@
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:drawableStartCompat="@drawable/ic_copy_24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/give_award_text_view_comment_more_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:drawablePadding="48dp"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/action_give_award"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:drawableStartCompat="@drawable/ic_give_award_24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/report_view_comment_more_bottom_sheet_fragment"
|
||||
@ -163,25 +144,6 @@
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:drawableStartCompat="@drawable/ic_report_24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/see_removed_view_comment_more_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:drawablePadding="48dp"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/see_removed_comment"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:drawableStartCompat="@drawable/ic_preview_24dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -76,16 +76,16 @@
|
||||
android:visible="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit_flair_view_post_detail_fragment"
|
||||
android:id="@+id/action_block_user_view_post_detail_fragment"
|
||||
android:orderInCategory="12"
|
||||
android:title="@string/action_edit_flair"
|
||||
android:title="@string/block_user"
|
||||
app:showAsAction="never"
|
||||
android:visible="false" />
|
||||
android:visible="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_give_award_view_post_detail_fragment"
|
||||
android:id="@+id/action_block_community_view_post_detail_fragment"
|
||||
android:orderInCategory="13"
|
||||
android:title="@string/action_give_award"
|
||||
android:title="@string/block_community"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
|
@ -1347,4 +1347,6 @@
|
||||
<string name="mentions">Mentions</string>
|
||||
<string name="replies">Replies</string>
|
||||
<string name="use_circular_fab">Use Circular FAB</string>
|
||||
<string name="block_community">Block Community\n</string>
|
||||
<string name="not_implemented">Feature not implemented yet :(</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user