mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-11-01 09:28:12 +01:00
Compare commits
38 Commits
alpha_vers
...
v0.0.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
907f6e92c3 | ||
|
|
426c3e6979 | ||
|
|
92292be472 | ||
|
|
3e10186c7c | ||
|
|
1974322013 | ||
|
|
a2e22bc525 | ||
|
|
7e433954c5 | ||
|
|
d47e2dac92 | ||
|
|
de3bea0729 | ||
|
|
3c91007d93 | ||
|
|
debb3e04df | ||
|
|
8c758460bc | ||
|
|
2bb1189e15 | ||
|
|
233fc38c23 | ||
|
|
215d31f8ea | ||
|
|
8ae681c753 | ||
|
|
554eb3c2fe | ||
|
|
c1f8f5a681 | ||
|
|
bb5c82aa60 | ||
|
|
72ba41c940 | ||
|
|
40b6722e66 | ||
|
|
dd3b72bc1f | ||
|
|
e9ecae117d | ||
|
|
5e4793bdaf | ||
|
|
fe351a8466 | ||
|
|
b1b12aba31 | ||
|
|
d2b95e1db6 | ||
|
|
20c317b63f | ||
|
|
f2d14a975d | ||
|
|
442310cad3 | ||
|
|
b8da5c6acb | ||
|
|
2ed15f3d5c | ||
|
|
d926fabe09 | ||
|
|
e815a1444d | ||
|
|
df81866821 | ||
|
|
497f6c79d2 | ||
|
|
6eb585800f | ||
|
|
df842d33e1 |
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "eu.toldi.infinityforlemmy"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 122
|
||||
versionName "0.0.2"
|
||||
versionCode 126
|
||||
versionName "0.0.6"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@@ -52,6 +52,10 @@ android {
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
doNotStrip '**/*.so'
|
||||
}
|
||||
namespace 'eu.toldi.infinityforlemmy'
|
||||
}
|
||||
|
||||
|
||||
@@ -291,18 +291,70 @@
|
||||
|
||||
<data android:scheme="https" />
|
||||
<data android:scheme="http" />
|
||||
<data android:host="www.reddit.com" />
|
||||
<data android:host="reddit.com" />
|
||||
<data android:host="v.redd.it" />
|
||||
<data android:host="amp.reddit.com" />
|
||||
<data android:host="m.reddit.com" />
|
||||
<data android:host="old.reddit.com" />
|
||||
<data android:host="new.reddit.com" />
|
||||
<data android:host="np.reddit.com" />
|
||||
<data android:host="reddit.app.link" />
|
||||
<data android:host="redd.it" />
|
||||
<data android:host="s.reddit.com" />
|
||||
<data android:host="click.redditmail.com" />
|
||||
<data android:host="lemmy.world" />
|
||||
<data android:host="lemmy.ml" />
|
||||
<data android:host="beehaw.org" />
|
||||
<data android:host="lemm.ee" />
|
||||
<data android:host="sh.itjust.works" />
|
||||
<data android:host="feddit.de" />
|
||||
<data android:host="lemmy.fmhy.ml" />
|
||||
<data android:host="lemmy.ca" />
|
||||
<data android:host="www.hexbear.net" />
|
||||
<data android:host="programming.dev" />
|
||||
<data android:host="lemmy.dbzer0.com" />
|
||||
<data android:host="lemmy.blahaj.zone" />
|
||||
<data android:host="lemmy.one" />
|
||||
<data android:host="vlemmy.net" />
|
||||
<data android:host="lemmy.sdf.org" />
|
||||
<data android:host="discuss.tchncs.de" />
|
||||
<data android:host="lemmygrad.ml" />
|
||||
<data android:host="sopuli.xyz" />
|
||||
<data android:host="reddthat.com" />
|
||||
<data android:host="aussie.zone" />
|
||||
<data android:host="feddit.uk" />
|
||||
<data android:host="feddit.nl" />
|
||||
<data android:host="midwest.social" />
|
||||
<data android:host="infosec.pub" />
|
||||
<data android:host="feddit.it" />
|
||||
<data android:host="ttrpg.network" />
|
||||
<data android:host="pawb.social" />
|
||||
<data android:host="lemmy.zip" />
|
||||
<data android:host="startrek.website" />
|
||||
<data android:host="burggit.moe" />
|
||||
<data android:host="slrpnk.net" />
|
||||
<data android:host="mander.xyz" />
|
||||
<data android:host="lemmy.eco.br" />
|
||||
<data android:host="lemmy.nz" />
|
||||
<data android:host="dormi.zone" />
|
||||
<data android:host="exploding-heads.com" />
|
||||
<data android:host="delraymisfitsboard.com" />
|
||||
<data android:host="monyet.cc" />
|
||||
<data android:host="feddit.dk" />
|
||||
<data android:host="lemmy.pt" />
|
||||
<data android:host="szmer.info" />
|
||||
<data android:host="yiffit.net" />
|
||||
<data android:host="geddit.social" />
|
||||
<data android:host="waveform.social" />
|
||||
<data android:host="discuss.online" />
|
||||
<data android:host="monero.town" />
|
||||
<data android:host="feddit.cl" />
|
||||
<data android:host="iusearchlinux.fyi" />
|
||||
<data android:host="dataterm.digital" />
|
||||
<data android:host="lemmy.whynotdrs.org" />
|
||||
<data android:host="feddit.ch" />
|
||||
<data android:host="enterprise.lemmy.ml" />
|
||||
<data android:host="lemmy.run" />
|
||||
<data android:host="jlai.lu" />
|
||||
<data android:host="pornlemmy.com" />
|
||||
<data android:host="lemdro.id" />
|
||||
<data android:host="lemmyrs.org" />
|
||||
<data android:host="latte.isnot.coffee" />
|
||||
<data android:host="feddit.nu" />
|
||||
<data android:host="lemmy.film" />
|
||||
<data android:host="bakchodi.org" />
|
||||
<data android:host="mujico.org" />
|
||||
<data android:host="lemmy.studio" />
|
||||
<data android:host="lemmy.toldi.eu" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
@@ -307,6 +307,7 @@ public interface AppComponent {
|
||||
|
||||
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
||||
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
AppComponent create(@BindsInstance Application application);
|
||||
|
||||
@@ -22,6 +22,8 @@ import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LoopAvailableExoCreator;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.videoautoplay.Config;
|
||||
@@ -192,8 +194,8 @@ abstract class AppModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
static ExoCreator provideExoCreator(Config config,
|
||||
ToroExo toroExo,
|
||||
@Named("default") SharedPreferences sharedPreferences) {
|
||||
ToroExo toroExo,
|
||||
@Named("default") SharedPreferences sharedPreferences) {
|
||||
return new LoopAvailableExoCreator(toroExo, config, sharedPreferences);
|
||||
}
|
||||
|
||||
@@ -202,4 +204,16 @@ abstract class AppModule {
|
||||
static Executor provideExecutor() {
|
||||
return Executors.newFixedThreadPool(4);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ObjectResolver provideObjectResolver(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new ObjectResolver(retrofitHolder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static MarkPostAsRead provideMarkPostAsRead(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new MarkPostAsRead(retrofitHolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -40,6 +41,7 @@ import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -64,10 +66,15 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
||||
private ActivityAccountSavedThingBinding binding;
|
||||
|
||||
@@ -116,6 +123,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
initializeViewPager();
|
||||
}
|
||||
@@ -249,7 +257,17 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(AccountSavedThingActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
@@ -13,7 +13,6 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -81,7 +80,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
@BindView(R.id.toolbar_edit_post_activity)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.post_title_text_view_edit_post_activity)
|
||||
TextView titleTextView;
|
||||
EditText titleEditText;
|
||||
@BindView(R.id.divider_edit_post_activity)
|
||||
View divider;
|
||||
@BindView(R.id.post_text_content_edit_text_edit_post_activity)
|
||||
@@ -140,7 +139,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
|
||||
mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
|
||||
titleEditText.setText(getIntent().getStringExtra(EXTRA_TITLE));
|
||||
mPostContent = getIntent().getStringExtra(EXTRA_CONTENT);
|
||||
contentEditText.setText(mPostContent);
|
||||
|
||||
@@ -190,12 +189,12 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||
titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor());
|
||||
titleEditText.setTextColor(mCustomThemeWrapper.getPostTitleColor());
|
||||
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
|
||||
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
|
||||
|
||||
if (titleTypeface != null) {
|
||||
titleTextView.setTypeface(titleTypeface);
|
||||
titleEditText.setTypeface(titleTypeface);
|
||||
}
|
||||
if (contentTypeface != null) {
|
||||
contentEditText.setTypeface(contentTypeface);
|
||||
|
||||
@@ -103,6 +103,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
public SubredditViewModel mSubredditViewModel;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private String name;
|
||||
private String userWhere;
|
||||
private int postType;
|
||||
@@ -158,6 +160,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
name = getIntent().getStringExtra(EXTRA_NAME);
|
||||
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
|
||||
|
||||
@@ -470,7 +473,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,7 +64,6 @@ import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class InboxActivity extends BaseActivity implements ActivityToolbarInterface, RecyclerViewContentScrollingInterface {
|
||||
|
||||
@@ -93,9 +92,6 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
@Named("base")
|
||||
RetrofitHolder mRetrofit;
|
||||
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
@@ -307,7 +303,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
} else if (item.getItemId() == R.id.action_read_all_messages_inbox_activity) {
|
||||
if (mAccessToken != null) {
|
||||
Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show();
|
||||
mOauthRetrofit.create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(mAccessToken))
|
||||
mRetrofit.getRetrofit().create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(mAccessToken))
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
|
||||
@@ -25,7 +25,12 @@ import javax.inject.Named;
|
||||
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
@@ -35,10 +40,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||
public static final String EXTRA_IS_NSFW = "EIN";
|
||||
|
||||
private static final String POST_PATTERN = "/r/[\\w-]+/comments/\\w+/?\\w+/?";
|
||||
private static final String POST_PATTERN_2 = "/(u|U|user)/[\\w-]+/comments/\\w+/?\\w+/?";
|
||||
private static final String POST_PATTERN = "https?:\\/\\/\\S+\\/post\\/\\d+";
|
||||
private static final String POST_PATTERN_3 = "/[\\w-]+$";
|
||||
private static final String COMMENT_PATTERN = "/(r|u|U|user)/[\\w-]+/comments/\\w+/?[\\w-]+/\\w+/?";
|
||||
private static final String COMMENT_PATTERN = "https?:\\/\\/\\S+\\/comment\\/\\d+";
|
||||
private static final String SUBREDDIT_PATTERN = "(?:https?://[\\w.-]+)?/c/[\\w-]+(@[\\w.-]+)?";
|
||||
private static final String USER_PATTERN = "(?:https?://[\\w.-]+)?/u(sers)?/[\\w-]+(@[\\w.-]+)?";
|
||||
private static final String SIDEBAR_PATTERN = "/[rR]/[\\w-]+/about/sidebar";
|
||||
@@ -60,6 +64,19 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
|
||||
@Inject
|
||||
ObjectResolver mObjectResolver;
|
||||
|
||||
@Inject
|
||||
@Named("current_account")
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
|
||||
private String mAccessToken;
|
||||
|
||||
private Uri getRedditUriByPath(String path) {
|
||||
if (path.charAt(0) != '/') {
|
||||
return Uri.parse("https://www.reddit.com/" + path);
|
||||
@@ -73,6 +90,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
Uri uri = getIntent().getData();
|
||||
if (uri == null) {
|
||||
@@ -169,6 +187,75 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (uri.toString().matches(POST_PATTERN)) {
|
||||
if (mAccessToken == null) {
|
||||
// switch retrofit to use the current instance for anonymous requests
|
||||
mRetrofit.setBaseURL(uri.getScheme() + "://" + uri.getHost() + "/");
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, Integer.parseInt(segments.get(segments.size() - 1)));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
|
||||
@Override
|
||||
public void onResolveObjectSuccess(Object p) {
|
||||
Post post = (Post) p;
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResolveObjectFailed() {
|
||||
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (uri.toString().matches(COMMENT_PATTERN)) {
|
||||
if (mAccessToken == null) {
|
||||
mRetrofit.setBaseURL(uri.getScheme() + "://" + uri.getHost() + "/");
|
||||
FetchComment.fetchSingleComment(mRetrofit.getRetrofit(), null, Integer.parseInt(segments.get(segments.size() - 1)), new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> comments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
Comment comment = comments.get(0);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchCommentFailed() {
|
||||
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
|
||||
@Override
|
||||
public void onResolveObjectSuccess(Object c) {
|
||||
Comment comment = (Comment) c;
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResolveObjectFailed() {
|
||||
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (authority.equals("v.redd.it")) {
|
||||
Intent intent = new Intent(this, ViewVideoActivity.class);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
||||
@@ -187,35 +274,12 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
} else if (path.equals("/report")) {
|
||||
openInWebView(uri);
|
||||
} else if (path.matches(POST_PATTERN) || path.matches(POST_PATTERN_2)) {
|
||||
int commentsIndex = segments.lastIndexOf("comments");
|
||||
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
|
||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
deepLinkError(uri);
|
||||
}
|
||||
} else if (path.matches(POST_PATTERN_3)) {
|
||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (path.matches(COMMENT_PATTERN)) {
|
||||
int commentsIndex = segments.lastIndexOf("comments");
|
||||
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
|
||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, segments.get(segments.size() - 1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
deepLinkError(uri);
|
||||
}
|
||||
} else if (path.matches(WIKI_PATTERN)) {
|
||||
String[] pathSegments = path.split("/");
|
||||
String wikiPage;
|
||||
|
||||
@@ -21,11 +21,11 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -139,9 +139,9 @@ public class LoginActivity extends BaseActivity {
|
||||
Log.i("LoginActivity", "Login button clicked");
|
||||
loginButton.setEnabled(false);
|
||||
progressBar.setVisibility(ProgressBar.VISIBLE);
|
||||
String username = username_input.getText().toString();
|
||||
String instance = correctURL(instance_input.getText().toString());
|
||||
if(!Patterns.WEB_URL.matcher(instance).matches()){
|
||||
String username = username_input.getText().toString().trim();
|
||||
String instance = correctURL(instance_input.getText().toString().trim());
|
||||
if (!Patterns.WEB_URL.matcher(instance).matches()) {
|
||||
instance_input.setError("Invalid instance URL");
|
||||
Toast.makeText(LoginActivity.this, "Invalid instance URL", Toast.LENGTH_SHORT).show();
|
||||
loginButton.setEnabled(true);
|
||||
@@ -149,7 +149,7 @@ public class LoginActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
Log.i("LoginActivity", "Instance: " + instance);
|
||||
AccountLoginDTO accountLoginDTO = new AccountLoginDTO(username,password_input.getText().toString(),token_2fa_input.getText().toString());
|
||||
AccountLoginDTO accountLoginDTO = new AccountLoginDTO(username, password_input.getText().toString(), token_2fa_input.getText().toString());
|
||||
mRetrofit.setBaseURL(instance);
|
||||
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
|
||||
Call<String> accessTokenCall = api.userLogin(accountLoginDTO);
|
||||
@@ -158,14 +158,16 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
progressBar.setVisibility(ProgressBar.GONE);
|
||||
loginButton.setEnabled(true);
|
||||
String accountResponse = response.body();
|
||||
if (accountResponse == null) {
|
||||
Log.e("LoginActivity", "Account response is null");
|
||||
Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show();
|
||||
//Handle error
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
String accountResponse = response.body();
|
||||
if (accountResponse == null) {
|
||||
Log.e("LoginActivity", "Account response is null");
|
||||
Toast.makeText(LoginActivity.this, R.string.invalid_response, Toast.LENGTH_SHORT).show();
|
||||
//Handle error
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject responseJSON = new JSONObject(accountResponse);
|
||||
String accessToken = responseJSON.getString("jwt");
|
||||
@@ -173,7 +175,7 @@ public class LoginActivity extends BaseActivity {
|
||||
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
|
||||
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
||||
@Override
|
||||
public void onFetchMyInfoSuccess(String name,String display_name, String profileImageUrl, String bannerImageUrl) {
|
||||
public void onFetchMyInfoSuccess(String name, String display_name, String profileImageUrl, String bannerImageUrl) {
|
||||
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_NAME, display_name)
|
||||
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, name)
|
||||
@@ -206,18 +208,25 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject responseObject = new JSONObject(accountResponse);
|
||||
if(responseObject.has("error")) {
|
||||
Toast.makeText(LoginActivity.this, "Error:"+responseObject.getString("error"), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
String errorBody = response.errorBody().string();
|
||||
Log.e("LoginActivity", "Error body: " + errorBody.trim());
|
||||
JSONObject responseObject = new JSONObject(errorBody.trim());
|
||||
if (responseObject.has("error")) {
|
||||
if (responseObject.getString("error").equals("incorrect_login")) {
|
||||
Toast.makeText(LoginActivity.this, R.string.invalid_username_or_password, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(LoginActivity.this, "Error:" + responseObject.getString("error"), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show();
|
||||
} catch (IOException e) {
|
||||
Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
Log.e("LoginActivity", "Failed to get access token: " + response.code() + " " + response.message() + " " + response.errorBody());
|
||||
Log.e("LoginActivity", "Failed to get access token: " + response.code() + " " + response.message());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -111,6 +113,7 @@ import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiRedditViewModel;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -211,6 +214,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private NavigationDrawerRecyclerViewMergedAdapter adapter;
|
||||
@@ -325,9 +332,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
||||
String instance = (mAccessToken == null) ? mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI) : mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
||||
if(instance != null) {
|
||||
mRetrofit.setBaseURL(instance);
|
||||
}
|
||||
@@ -348,6 +356,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
initializeNotificationAndBindView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mAccessToken == null) {
|
||||
String instancePreference = mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI);
|
||||
if (!mRetrofit.getBaseURL().equalsIgnoreCase(instancePreference)) {
|
||||
this.recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
@@ -858,6 +877,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
startActivity(logOutIntent);
|
||||
finish();
|
||||
});
|
||||
} else if (stringId == R.string.anonymous_account_instance) {
|
||||
changeAnonymousAccountInstance();
|
||||
}
|
||||
if (intent != null) {
|
||||
startActivity(intent);
|
||||
@@ -1385,6 +1406,72 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
}
|
||||
}
|
||||
|
||||
private void changeAnonymousAccountInstance() {
|
||||
View rootView = getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, coordinatorLayout, false);
|
||||
TextInputEditText thingEditText = rootView.findViewById(R.id.text_input_edit_text_go_to_thing_edit_text);
|
||||
|
||||
thingEditText.requestFocus();
|
||||
thingEditText.setText(mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI));
|
||||
Utils.showKeyboard(this, new Handler(), thingEditText);
|
||||
thingEditText.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
Utils.hideKeyboard(this);
|
||||
String url = thingEditText.getText().toString();
|
||||
if (url.isEmpty()) {
|
||||
thingEditText.setError("Instance URL cannot be empty");
|
||||
return false;
|
||||
}
|
||||
if (!url.startsWith("http://") || !url.startsWith("https://")) {
|
||||
url = "https://" + url;
|
||||
}
|
||||
try {
|
||||
URL urlObj = new URL(url);
|
||||
url = urlObj.getProtocol() + "://" + urlObj.getHost() + "/";
|
||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, url).apply();
|
||||
mRetrofit.setBaseURL(url);
|
||||
sectionsPagerAdapter.getCurrentFragment().refresh();
|
||||
} catch (MalformedURLException e) {
|
||||
thingEditText.setError("Invalid URL");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.anonymous_account_instance)
|
||||
.setView(rootView)
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
||||
-> {
|
||||
Utils.hideKeyboard(this);
|
||||
String url = thingEditText.getText().toString();
|
||||
if (url.isEmpty()) {
|
||||
thingEditText.setError("Instance URL cannot be empty");
|
||||
return;
|
||||
}
|
||||
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||
url = "https://" + url;
|
||||
}
|
||||
try {
|
||||
URL urlObj = new URL(url);
|
||||
url = urlObj.getProtocol() + "://" + urlObj.getHost() + "/";
|
||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, url).apply();
|
||||
mRetrofit.setBaseURL(url);
|
||||
sectionsPagerAdapter.getCurrentFragment().refresh();
|
||||
} catch (MalformedURLException e) {
|
||||
thingEditText.setError("Invalid URL");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
Utils.hideKeyboard(this);
|
||||
})
|
||||
.setOnDismissListener(dialogInterface -> {
|
||||
Utils.hideKeyboard(this);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void goToSubreddit() {
|
||||
View rootView = getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, coordinatorLayout, false);
|
||||
TextInputEditText thingEditText = rootView.findViewById(R.id.text_input_edit_text_go_to_thing_edit_text);
|
||||
@@ -1526,7 +1613,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(MainActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void doNotShowRedditAPIInfoAgain() {
|
||||
@@ -1648,7 +1745,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL) {
|
||||
PostFragment fragment = new PostFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccessToken == null ? PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE : PostPagingSource.TYPE_FRONT_PAGE);
|
||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
|
||||
bundle.putString(PostFragment.EXTRA_NAME, "all");
|
||||
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
@@ -1712,7 +1809,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
} else {
|
||||
PostFragment fragment = new PostFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccessToken == null ? PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE : PostPagingSource.TYPE_FRONT_PAGE);
|
||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
|
||||
bundle.putString(PostFragment.EXTRA_NAME, "local");
|
||||
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
|
||||
@@ -74,6 +74,9 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitGalleryPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
|
||||
@@ -102,6 +105,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_gallery_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -123,10 +127,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
MaterialButton rulesButton;
|
||||
@BindView(R.id.divider_1_post_gallery_activity)
|
||||
MaterialDivider divider1;
|
||||
@BindView(R.id.flair_custom_text_view_post_gallery_activity)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_post_gallery_activity)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.nsfw_custom_text_view_post_gallery_activity)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity)
|
||||
@@ -168,6 +168,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
private String mAccountName;
|
||||
private String iconUrl;
|
||||
private String subredditName;
|
||||
private SubscribedSubredditData communityData;
|
||||
private boolean subredditSelected = false;
|
||||
private boolean subredditIsUser;
|
||||
private boolean loadSubredditIconSuccessful = true;
|
||||
@@ -245,6 +246,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||
@@ -279,7 +281,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
if (subredditName != null) {
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
if (!loadSubredditIconSuccessful) {
|
||||
loadSubredditIcon();
|
||||
}
|
||||
@@ -290,17 +291,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
mPostingSnackbar.show();
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
if (isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
}
|
||||
if (isNSFW) {
|
||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||
@@ -314,11 +304,25 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||
loadSubredditIconSuccessful = false;
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
loadSubredditIcon();
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
{
|
||||
communityData = new SubscribedSubredditData(subredditData);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
loadSubredditIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
@@ -347,40 +351,12 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
if (subredditIsUser) {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
if (flair == null) {
|
||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
||||
} else {
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
});
|
||||
|
||||
spoilerTextView.setOnClickListener(view -> {
|
||||
if (!isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
isSpoiler = true;
|
||||
} else {
|
||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
isSpoiler = false;
|
||||
}
|
||||
});
|
||||
|
||||
nsfwTextView.setOnClickListener(view -> {
|
||||
if (!isNSFW) {
|
||||
@@ -449,8 +425,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
@@ -458,8 +433,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
rulesButton.setTypeface(typeface);
|
||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||
flairTextView.setTypeface(typeface);
|
||||
spoilerTextView.setTypeface(typeface);
|
||||
nsfwTextView.setTypeface(typeface);
|
||||
titleEditText.setTypeface(typeface);
|
||||
}
|
||||
@@ -612,7 +585,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_GALLERY);
|
||||
ArrayList<RedditGalleryPayload.Item> items = new ArrayList<>();
|
||||
for (RedditGallerySubmissionRecyclerViewAdapter.RedditGalleryImageInfo i : redditGalleryImageInfoList) {
|
||||
@@ -648,6 +621,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||
@@ -666,19 +640,16 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
||||
subredditIsUser = false;
|
||||
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
displaySubredditIcon();
|
||||
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||
@@ -709,10 +680,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
||||
@Override
|
||||
public void flairSelected(Flair flair) {
|
||||
this.flair = flair;
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -25,6 +26,8 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@@ -43,6 +46,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -55,22 +59,31 @@ import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitImagePostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class PostImageActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||
AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
|
||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
|
||||
@@ -90,6 +103,10 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
||||
|
||||
private static final int PICK_IMAGE_REQUEST_CODE_2 = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE_2 = 200;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_image_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@BindView(R.id.appbar_layout_post_image_activity)
|
||||
@@ -110,10 +127,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
MaterialButton rulesButton;
|
||||
@BindView(R.id.divider_1_post_image_activity)
|
||||
MaterialDivider divider1;
|
||||
@BindView(R.id.flair_custom_text_view_post_image_activity)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_post_image_activity)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_image_activity)
|
||||
@@ -153,6 +166,11 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
@Inject
|
||||
@Named("current_account")
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
|
||||
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||
EditText contentEditText;
|
||||
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||
RecyclerView markdownBottomBarRecyclerView;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
@@ -162,6 +180,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private String mAccountName;
|
||||
private String iconUrl;
|
||||
private String subredditName;
|
||||
private SubscribedSubredditData communityData;
|
||||
private boolean subredditSelected = false;
|
||||
private boolean subredditIsUser;
|
||||
private boolean loadSubredditIconSuccessful = true;
|
||||
@@ -183,6 +202,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||
private Snackbar mPostingSnackbar;
|
||||
|
||||
private Uri capturedImageUri;
|
||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
@@ -217,6 +239,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||
@@ -247,7 +270,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (subredditName != null) {
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
if (!loadSubredditIconSuccessful) {
|
||||
loadSubredditIcon();
|
||||
}
|
||||
@@ -258,17 +280,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
mPostingSnackbar.show();
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
if (isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
}
|
||||
if (isNSFW) {
|
||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||
@@ -282,11 +293,25 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||
loadSubredditIconSuccessful = false;
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
loadSubredditIcon();
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
{
|
||||
communityData = new SubscribedSubredditData(subredditData);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
loadSubredditIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
@@ -320,40 +345,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (subredditIsUser) {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
if (flair == null) {
|
||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
||||
} else {
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
});
|
||||
|
||||
spoilerTextView.setOnClickListener(view -> {
|
||||
if (!isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
isSpoiler = true;
|
||||
} else {
|
||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
isSpoiler = false;
|
||||
}
|
||||
});
|
||||
|
||||
nsfwTextView.setOnClickListener(view -> {
|
||||
if (!isNSFW) {
|
||||
@@ -400,6 +397,30 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
imageView.setVisibility(View.GONE);
|
||||
constraintLayout.setVisibility(View.VISIBLE);
|
||||
});
|
||||
|
||||
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onClick(int item) {
|
||||
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||
PostImageActivity.this, contentEditText, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadImage() {
|
||||
Utils.hideKeyboard(PostImageActivity.this);
|
||||
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||
uploadedImages);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||
LinearLayoutManager.HORIZONTAL, false));
|
||||
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void loadCurrentAccount() {
|
||||
@@ -451,8 +472,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
@@ -463,8 +482,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
rulesButton.setTypeface(typeface);
|
||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||
flairTextView.setTypeface(typeface);
|
||||
spoilerTextView.setTypeface(typeface);
|
||||
nsfwTextView.setTypeface(typeface);
|
||||
titleEditText.setTypeface(typeface);
|
||||
selectAgainTextView.setTypeface(typeface);
|
||||
@@ -570,8 +587,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.setData(imageUri);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||
@@ -608,6 +626,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
@@ -628,19 +647,15 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
communityData = data.getExtras().getParcelable(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
||||
|
||||
subredditIsUser = false;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
displaySubredditIcon();
|
||||
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||
@@ -657,6 +672,16 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (resultCode == RESULT_OK) {
|
||||
loadImage();
|
||||
}
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE_2) {
|
||||
if (data == null) {
|
||||
Toast.makeText(PostImageActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE_2) {
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,10 +694,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
@Override
|
||||
public void flairSelected(Flair flair) {
|
||||
this.flair = flair;
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -700,8 +721,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
isPosting = false;
|
||||
mPostingSnackbar.dismiss();
|
||||
if (submitImagePostEvent.postSuccess) {
|
||||
Intent intent = new Intent(PostImageActivity.this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
Intent intent = new Intent(PostImageActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, submitImagePostEvent.post);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
@@ -740,4 +761,37 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadImage() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureImage() {
|
||||
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
try {
|
||||
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE_2);
|
||||
} catch (IOException ex) {
|
||||
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package eu.toldi.infinityforlemmy.activities;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -20,6 +23,9 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@@ -35,6 +41,9 @@ import com.libRG.CustomTextView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -47,17 +56,26 @@ import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.apis.TitleSuggestion;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Call;
|
||||
@@ -67,12 +85,13 @@ import retrofit2.Retrofit;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
|
||||
public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||
AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
|
||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
static final String EXTRA_LINK = "EL";
|
||||
|
||||
private static final String SELECTED_ACCOUNT_STATE = "SAS";
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
||||
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
||||
@@ -84,6 +103,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private static final String IS_NSFW_STATE = "INS";
|
||||
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_link_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -107,10 +129,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
MaterialDivider divider1;
|
||||
@BindView(R.id.divider_2_post_link_activity)
|
||||
MaterialDivider divider2;
|
||||
@BindView(R.id.flair_custom_text_view_post_link_activity)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_post_link_activity)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.nsfw_custom_text_view_post_link_activity)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_link_activity)
|
||||
@@ -125,6 +143,11 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
MaterialButton suggestTitleButton;
|
||||
@BindView(R.id.post_link_edit_text_post_link_activity)
|
||||
EditText linkEditText;
|
||||
|
||||
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||
EditText contentEditText;
|
||||
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||
RecyclerView markdownBottomBarRecyclerView;
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@@ -147,6 +170,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private String mAccessToken;
|
||||
private String iconUrl;
|
||||
private String subredditName;
|
||||
private SubscribedSubredditData communityData;
|
||||
private boolean subredditSelected = false;
|
||||
private boolean subredditIsUser;
|
||||
private boolean loadSubredditIconSuccessful = true;
|
||||
@@ -167,6 +191,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||
private Snackbar mPostingSnackbar;
|
||||
|
||||
private Uri capturedImageUri;
|
||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
@@ -200,6 +227,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||
@@ -225,7 +253,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (subredditName != null) {
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
if (!loadSubredditIconSuccessful) {
|
||||
loadSubredditIcon();
|
||||
}
|
||||
@@ -236,17 +263,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
mPostingSnackbar.show();
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
if (isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
}
|
||||
if (isNSFW) {
|
||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||
@@ -260,11 +276,25 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||
loadSubredditIconSuccessful = false;
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
loadSubredditIcon();
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
{
|
||||
communityData = new SubscribedSubredditData(subredditData);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
loadSubredditIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
@@ -298,40 +328,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (subredditIsUser) {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
if (flair == null) {
|
||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
||||
} else {
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
});
|
||||
|
||||
spoilerTextView.setOnClickListener(view -> {
|
||||
if (!isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
isSpoiler = true;
|
||||
} else {
|
||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
isSpoiler = false;
|
||||
}
|
||||
});
|
||||
|
||||
nsfwTextView.setOnClickListener(view -> {
|
||||
if (!isNSFW) {
|
||||
@@ -360,21 +362,46 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
.baseUrl("http://localhost/")
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.build().create(TitleSuggestion.class).getHtml(url).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
|
||||
} else {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
|
||||
} else {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onClick(int item) {
|
||||
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||
PostLinkActivity.this, contentEditText, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadImage() {
|
||||
Utils.hideKeyboard(PostLinkActivity.this);
|
||||
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||
uploadedImages);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||
LinearLayoutManager.HORIZONTAL, false));
|
||||
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void loadCurrentAccount() {
|
||||
@@ -426,8 +453,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
@@ -439,8 +464,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
rulesButton.setTypeface(typeface);
|
||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||
flairTextView.setTypeface(typeface);
|
||||
spoilerTextView.setTypeface(typeface);
|
||||
nsfwTextView.setTypeface(typeface);
|
||||
titleEditText.setTypeface(typeface);
|
||||
suggestTitleButton.setTypeface(typeface);
|
||||
@@ -467,10 +490,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private void loadSubredditIcon() {
|
||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
|
||||
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
});
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void promptAlertDialog(int titleResId, int messageResId) {
|
||||
@@ -541,9 +564,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, linkEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_URL, linkEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_LINK);
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
@@ -575,6 +599,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||
@@ -589,22 +614,29 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
communityData = data.getExtras().getParcelable(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
||||
subredditIsUser = false;
|
||||
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
displaySubredditIcon();
|
||||
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||
if (data == null) {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,10 +650,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Override
|
||||
public void flairSelected(Flair flair) {
|
||||
this.flair = flair;
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -664,4 +692,37 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadImage() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureImage() {
|
||||
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
try {
|
||||
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
|
||||
} catch (IOException ex) {
|
||||
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -64,6 +63,9 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitPollPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
@@ -87,6 +89,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private static final String IS_NSFW_STATE = "INS";
|
||||
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_poll_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -108,10 +111,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
MaterialButton rulesButton;
|
||||
@BindView(R.id.divider_1_post_poll_activity)
|
||||
MaterialDivider divider1;
|
||||
@BindView(R.id.flair_custom_text_view_post_poll_activity)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_post_poll_activity)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.nsfw_custom_text_view_post_poll_activity)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_poll_activity)
|
||||
@@ -173,6 +172,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private Account selectedAccount;
|
||||
private SubscribedSubredditData communityData;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String iconUrl;
|
||||
@@ -232,6 +232,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||
@@ -257,7 +258,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (subredditName != null) {
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
if (!loadSubredditIconSuccessful) {
|
||||
loadSubredditIcon();
|
||||
}
|
||||
@@ -268,17 +268,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
mPostingSnackbar.show();
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
if (isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
}
|
||||
if (isNSFW) {
|
||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||
@@ -292,11 +281,25 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||
loadSubredditIconSuccessful = false;
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
loadSubredditIcon();
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
{
|
||||
communityData = new SubscribedSubredditData(subredditData);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
loadSubredditIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
@@ -325,40 +328,12 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (subredditIsUser) {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
if (flair == null) {
|
||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
||||
} else {
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
});
|
||||
|
||||
spoilerTextView.setOnClickListener(view -> {
|
||||
if (!isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
isSpoiler = true;
|
||||
} else {
|
||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
isSpoiler = false;
|
||||
}
|
||||
});
|
||||
|
||||
nsfwTextView.setOnClickListener(view -> {
|
||||
if (!isNSFW) {
|
||||
@@ -431,8 +406,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
@@ -481,8 +454,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
rulesButton.setTypeface(typeface);
|
||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||
flairTextView.setTypeface(typeface);
|
||||
spoilerTextView.setTypeface(typeface);
|
||||
nsfwTextView.setTypeface(typeface);
|
||||
titleEditText.setTypeface(typeface);
|
||||
option1TextInputEditText.setTypeface(typeface);
|
||||
@@ -631,7 +602,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_POLL);
|
||||
PollPayload payload = new PollPayload(subredditName, titleEditText.getText().toString(),
|
||||
optionList.toArray(new String[0]), (int) votingLengthSlider.getValue(), isNSFW, isSpoiler, flair, receivePostReplyNotificationsSwitchMaterial.isChecked(),
|
||||
@@ -669,6 +640,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||
@@ -685,19 +657,16 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
||||
subredditIsUser = false;
|
||||
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
displaySubredditIcon();
|
||||
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
}
|
||||
@@ -706,10 +675,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Override
|
||||
public void flairSelected(Flair flair) {
|
||||
this.flair = flair;
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -69,6 +68,9 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
@@ -78,7 +80,6 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class PostTextActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
|
||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
static final String EXTRA_CONTENT = "EC";
|
||||
|
||||
@@ -98,6 +99,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_text_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -119,10 +121,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
MaterialButton rulesButton;
|
||||
@BindView(R.id.divider_1_post_text_activity)
|
||||
MaterialDivider divider1;
|
||||
@BindView(R.id.flair_custom_text_view_post_text_activity)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_post_text_activity)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
|
||||
@@ -164,6 +162,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private String mAccessToken;
|
||||
private String iconUrl;
|
||||
private String subredditName;
|
||||
private SubscribedSubredditData communityData;
|
||||
private boolean subredditSelected = false;
|
||||
private boolean subredditIsUser;
|
||||
private boolean loadSubredditIconSuccessful = true;
|
||||
@@ -219,6 +218,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||
@@ -245,7 +245,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (subredditName != null) {
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
if (!loadSubredditIconSuccessful) {
|
||||
loadSubredditIcon();
|
||||
}
|
||||
@@ -256,17 +255,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
mPostingSnackbar.show();
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
if (isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
}
|
||||
if (isNSFW) {
|
||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||
@@ -280,11 +268,25 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||
loadSubredditIconSuccessful = false;
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
loadSubredditIcon();
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
{
|
||||
communityData = new SubscribedSubredditData(subredditData);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
loadSubredditIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
@@ -318,44 +320,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
if (subredditIsUser) {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
if (flair == null) {
|
||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
if (subredditIsUser) {
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
}
|
||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
||||
} else {
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
});
|
||||
|
||||
spoilerTextView.setOnClickListener(view -> {
|
||||
if (!isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
isSpoiler = true;
|
||||
} else {
|
||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
isSpoiler = false;
|
||||
}
|
||||
});
|
||||
|
||||
nsfwTextView.setOnClickListener(view -> {
|
||||
if (!isNSFW) {
|
||||
@@ -448,8 +418,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
@@ -459,8 +427,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
rulesButton.setTypeface(typeface);
|
||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||
flairTextView.setTypeface(typeface);
|
||||
spoilerTextView.setTypeface(typeface);
|
||||
nsfwTextView.setTypeface(typeface);
|
||||
titleEditText.setTypeface(typeface);
|
||||
}
|
||||
@@ -562,18 +528,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
|
||||
mPostingSnackbar.show();
|
||||
|
||||
String subredditName;
|
||||
if (subredditIsUser) {
|
||||
subredditName = "u_" + subredditNameTextView.getText().toString();
|
||||
} else {
|
||||
subredditName = subredditNameTextView.getText().toString();
|
||||
}
|
||||
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
@@ -599,6 +559,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
@@ -617,19 +578,16 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
||||
subredditIsUser = false;
|
||||
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
displaySubredditIcon();
|
||||
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||
@@ -658,10 +616,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Override
|
||||
public void flairSelected(Flair flair) {
|
||||
this.flair = flair;
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -67,6 +67,9 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
@@ -92,6 +95,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final int PICK_VIDEO_REQUEST_CODE = 1;
|
||||
private static final int CAPTURE_VIDEO_REQUEST_CODE = 2;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_video_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -113,10 +117,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
MaterialButton rulesButton;
|
||||
@BindView(R.id.divider_1_post_video_activity)
|
||||
MaterialDivider divider1;
|
||||
@BindView(R.id.flair_custom_text_view_post_video_activity)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_post_video_activity)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
|
||||
@@ -168,6 +168,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private String mAccountName;
|
||||
private String iconUrl;
|
||||
private String subredditName;
|
||||
private SubscribedSubredditData communityData;
|
||||
private boolean subredditSelected = false;
|
||||
private boolean subredditIsUser;
|
||||
private Uri videoUri;
|
||||
@@ -235,6 +236,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
@@ -266,7 +268,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (subredditName != null) {
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
if (!loadSubredditIconSuccessful) {
|
||||
loadSubredditIcon();
|
||||
}
|
||||
@@ -277,17 +278,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
mPostingSnackbar.show();
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
if (isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
}
|
||||
if (isNSFW) {
|
||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||
@@ -301,11 +291,25 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||
loadSubredditIconSuccessful = false;
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
loadSubredditIcon();
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
{
|
||||
communityData = new SubscribedSubredditData(subredditData);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
subredditSelected = true;
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
loadSubredditIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
@@ -341,40 +345,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (subredditIsUser) {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||
} else {
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
if (flair == null) {
|
||||
mFlairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
mFlairSelectionBottomSheetFragment.setArguments(bundle);
|
||||
mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag());
|
||||
} else {
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
});
|
||||
|
||||
spoilerTextView.setOnClickListener(view -> {
|
||||
if (!isSpoiler) {
|
||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
||||
spoilerTextView.setTextColor(spoilerTextColor);
|
||||
isSpoiler = true;
|
||||
} else {
|
||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
isSpoiler = false;
|
||||
}
|
||||
});
|
||||
|
||||
nsfwTextView.setOnClickListener(view -> {
|
||||
if (!isNSFW) {
|
||||
@@ -468,8 +444,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
spoilerTextView.setTextColor(primaryTextColor);
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
@@ -480,8 +454,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
rulesButton.setTypeface(typeface);
|
||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||
flairTextView.setTypeface(typeface);
|
||||
spoilerTextView.setTypeface(typeface);
|
||||
nsfwTextView.setTypeface(typeface);
|
||||
titleEditText.setTypeface(typeface);
|
||||
selectAgainTextView.setTypeface(typeface);
|
||||
@@ -589,7 +561,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.setData(videoUri);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
@@ -637,6 +609,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||
@@ -657,19 +630,16 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
||||
subredditIsUser = false;
|
||||
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
displaySubredditIcon();
|
||||
|
||||
flairTextView.setVisibility(View.VISIBLE);
|
||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
||||
flairTextView.setTextColor(primaryTextColor);
|
||||
flairTextView.setText(getString(R.string.flair));
|
||||
flair = null;
|
||||
}
|
||||
}
|
||||
@@ -707,10 +677,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
@Override
|
||||
public void flairSelected(Flair flair) {
|
||||
this.flair = flair;
|
||||
flairTextView.setText(flair.getText());
|
||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
||||
flairTextView.setBorderColor(flairBackgroundColor);
|
||||
flairTextView.setTextColor(flairTextColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@@ -31,7 +30,6 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.FetchRules;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
@@ -41,6 +39,8 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.widget.SliderPanel;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@@ -134,26 +134,27 @@ public class RulesActivity extends BaseActivity {
|
||||
|
||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel);
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
FetchRules.fetchRules(mExecutor, new Handler(), mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mAccessToken, mSubredditName, new FetchRules.FetchRulesListener() {
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void success(ArrayList<Rule> rules) {
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
if (rules == null || rules.size() == 0) {
|
||||
String description = subredditData.getDescription();
|
||||
if (description == null || description.isEmpty()) {
|
||||
errorTextView.setVisibility(View.VISIBLE);
|
||||
errorTextView.setText(R.string.no_rule);
|
||||
errorTextView.setOnClickListener(view -> {
|
||||
});
|
||||
}
|
||||
ArrayList<Rule> rules = new ArrayList<>();
|
||||
rules.add(new Rule("Rules", description));
|
||||
mAdapter.changeDataset(rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
displayError();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,21 +185,24 @@ public class RulesActivity extends BaseActivity {
|
||||
errorTextView.setOnClickListener(view -> {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
errorTextView.setVisibility(View.GONE);
|
||||
FetchRules.fetchRules(mExecutor, new Handler(), mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mAccessToken, mSubredditName, new FetchRules.FetchRulesListener() {
|
||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void success(ArrayList<Rule> rules) {
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
if (rules == null || rules.size() == 0) {
|
||||
String description = subredditData.getDescription();
|
||||
if (description == null || description.isEmpty()) {
|
||||
errorTextView.setVisibility(View.VISIBLE);
|
||||
errorTextView.setText(R.string.no_rule);
|
||||
errorTextView.setOnClickListener(view -> {
|
||||
});
|
||||
}
|
||||
ArrayList<Rule> rules = new ArrayList<>();
|
||||
rules.add(new Rule("Rules", description));
|
||||
mAdapter.changeDataset(rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed() {
|
||||
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||
displayError();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@ import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQuery;
|
||||
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQueryViewModel;
|
||||
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
@@ -128,6 +129,8 @@ public class SearchActivity extends BaseActivity {
|
||||
private String query;
|
||||
private String subredditName;
|
||||
|
||||
private SubscribedSubredditData communityData;
|
||||
|
||||
private String communityQualifiedName;
|
||||
private boolean subredditIsUser;
|
||||
private boolean searchOnlySubreddits;
|
||||
@@ -183,7 +186,7 @@ public class SearchActivity extends BaseActivity {
|
||||
subredditNameList.add(subredditData.getName());
|
||||
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
|
||||
} else {
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, subredditData.getName());
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, new SubscribedSubredditData(subredditData));
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
|
||||
}
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
@@ -429,8 +432,9 @@ public class SearchActivity extends BaseActivity {
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
||||
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
subredditIsUser = false;
|
||||
|
||||
if (subredditName == null) {
|
||||
subredditNameTextView.setText(R.string.all_communities);
|
||||
@@ -442,9 +446,9 @@ public class SearchActivity extends BaseActivity {
|
||||
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
|
||||
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, data.getStringArrayListExtra(SearchSubredditsResultActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES));
|
||||
} else {
|
||||
String name = data.getStringExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
SubscribedSubredditData communityData = data.getParcelableExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
String iconUrl = data.getStringExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, communityData);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||
}
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
|
||||
@@ -34,6 +34,8 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
@@ -144,10 +146,10 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||
}
|
||||
|
||||
public void getSelectedSubreddit(String name, String iconUrl) {
|
||||
public void getSelectedSubreddit(SubredditData subredditData) {
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, new SubscribedSubredditData(subredditData));
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ import eu.toldi.infinityforlemmy.events.SubmitCrosspostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
@@ -87,6 +88,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
private static final String IS_NSFW_STATE = "INS";
|
||||
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_submit_crosspost_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -159,6 +161,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
private Post post;
|
||||
private String iconUrl;
|
||||
private String subredditName;
|
||||
private SubscribedSubredditData communityData;
|
||||
private boolean subredditSelected = false;
|
||||
private boolean subredditIsUser;
|
||||
private boolean loadSubredditIconSuccessful = true;
|
||||
@@ -212,6 +215,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||
@@ -566,12 +570,12 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
|
||||
Intent intent = new Intent(this, SubmitPostService.class);
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
if (post.isCrosspost()) {
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, "t3_" + post.getCrosspostParentId());
|
||||
} else {
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, post.getFullName());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, post.getFullName());
|
||||
}
|
||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
@@ -604,6 +608,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||
@@ -620,10 +625,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
subredditSelected = true;
|
||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
||||
subredditIsUser = false;
|
||||
|
||||
subredditNameTextView.setTextColor(primaryTextColor);
|
||||
subredditNameTextView.setText(subredditName);
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@@ -33,7 +32,6 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
||||
import eu.toldi.infinityforlemmy.AnyAccountAccessTokenAuthenticator;
|
||||
import eu.toldi.infinityforlemmy.FetchSubscribedThing;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
@@ -49,17 +47,12 @@ import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribeduser.SubscribedUserData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_SPECIFIED_ACCOUNT = "ESA";
|
||||
public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
|
||||
public static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
||||
public static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
||||
public static final String EXTRA_RETURN_SUBREDDIT_IS_USER = "ERSIU";
|
||||
public static final String EXTRA_RETURN_COMMUNITY_DATA = "ERCD";
|
||||
|
||||
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 0;
|
||||
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
|
||||
@@ -77,9 +70,6 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
@Named("default")
|
||||
@@ -142,21 +132,14 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
mAccountName = specifiedAccount.getAccountName();
|
||||
mAccountProfileImageUrl = specifiedAccount.getProfileImageUrl();
|
||||
|
||||
mOauthRetrofit = mOauthRetrofit.newBuilder().client(new OkHttpClient.Builder().authenticator(new AnyAccountAccessTokenAuthenticator(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, specifiedAccount, mCurrentAccountSharedPreferences))
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
|
||||
.build())
|
||||
.build();
|
||||
} else {
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
|
||||
}
|
||||
} else {
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
|
||||
}
|
||||
|
||||
@@ -198,6 +181,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
mFragment = new SubscribedSubredditsListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountName);
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, mAccountProfileImageUrl);
|
||||
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
|
||||
@@ -262,11 +246,9 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
return false;
|
||||
}
|
||||
|
||||
public void getSelectedSubreddit(String name, String iconUrl, boolean subredditIsUser) {
|
||||
public void getSelectedSubreddit(SubscribedSubredditData communityData) {
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_IS_USER, subredditIsUser);
|
||||
returnIntent.putExtra(EXTRA_RETURN_COMMUNITY_DATA, communityData);
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
finish();
|
||||
}
|
||||
@@ -275,13 +257,13 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
String name = data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
String iconUrl = data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||
|
||||
SubscribedSubredditData communityData = data.getParcelableExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
String iconUrl = communityData.getIconUrl();
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
||||
returnIntent.putExtra(EXTRA_RETURN_COMMUNITY_DATA, communityData);
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -131,8 +132,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private String multiPath;
|
||||
private Fragment mFragment;
|
||||
private int fabOption;
|
||||
@@ -221,6 +225,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
@@ -868,7 +873,17 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(ViewMultiRedditDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -468,7 +468,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
});
|
||||
} else {
|
||||
comment.setSaved(true);
|
||||
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
saveComment.saveThing(mRetrofit.getRetrofit(), mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
|
||||
@@ -869,7 +869,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
if (postListPosition == position && post != null) {
|
||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, position);
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
|
||||
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_ID, 0));
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
||||
} else {
|
||||
@@ -885,12 +885,12 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
}
|
||||
} else {
|
||||
if (post == null) {
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getStringExtra(EXTRA_POST_ID));
|
||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getIntExtra(EXTRA_POST_ID, 0));
|
||||
} else {
|
||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, postListPosition);
|
||||
}
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
|
||||
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_ID, 0));
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
||||
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ import eu.toldi.infinityforlemmy.fragments.SidebarFragment;
|
||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -196,6 +197,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private NavigationWrapper navigationWrapper;
|
||||
@@ -582,7 +586,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
subscriptionReady = false;
|
||||
if (getResources().getString(R.string.subscribe).contentEquals(subscribeSubredditChip.getText())) {
|
||||
CommunitySubscription.anonymousSubscribeToSubreddit(mExecutor, new Handler(),
|
||||
mRetrofit.getRetrofit(), mRedditDataRoomDatabase, communityName,
|
||||
mRetrofit.getRetrofit(), mRedditDataRoomDatabase, qualifiedName,
|
||||
new CommunitySubscription.SubredditSubscriptionListener() {
|
||||
@Override
|
||||
public void onSubredditSubscriptionSuccess() {
|
||||
@@ -600,7 +604,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
});
|
||||
} else {
|
||||
CommunitySubscription.anonymousUnsubscribeToSubreddit(mExecutor, new Handler(),
|
||||
mRedditDataRoomDatabase, communityName,
|
||||
mRedditDataRoomDatabase, qualifiedName,
|
||||
new CommunitySubscription.SubredditSubscriptionListener() {
|
||||
@Override
|
||||
public void onSubredditSubscriptionSuccess() {
|
||||
@@ -1174,7 +1178,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
} else if (itemId == R.id.action_share_view_subreddit_detail_activity) {
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, qualifiedName);
|
||||
String baseURL = mRetrofit.getBaseURL().endsWith("/") ? mRetrofit.getBaseURL() : mRetrofit.getBaseURL() + "/";
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + "/" + qualifiedName);
|
||||
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||
} else {
|
||||
@@ -1278,7 +1283,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
switch (postType) {
|
||||
case PostTypeBottomSheetFragment.TYPE_TEXT:
|
||||
intent = new Intent(this, PostTextActivity.class);
|
||||
intent.putExtra(PostTextActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||
intent.putExtra(PostTextActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case PostTypeBottomSheetFragment.TYPE_LINK:
|
||||
@@ -1561,7 +1566,18 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(ViewSubredditDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,6 +95,7 @@ import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -202,6 +203,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
public UserViewModel userViewModel;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
@@ -210,6 +214,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private Call<String> subredditAutocompleteCall;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private String username;
|
||||
private String qualifiedName;
|
||||
private String description;
|
||||
@@ -272,6 +277,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
|
||||
|
||||
@@ -1154,7 +1160,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
} else if (itemId == R.id.action_share_view_user_detail_activity) {
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, "https://www.reddit.com/user/" + username);
|
||||
String baseURL = mRetrofit.getBaseURL().endsWith("/") ? mRetrofit.getBaseURL() : mRetrofit.getBaseURL() + "/";
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + qualifiedName);
|
||||
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||
} else {
|
||||
@@ -1549,7 +1556,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(ViewUserDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
}
|
||||
};
|
||||
private BaseActivity mActivity;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private Retrofit retrofit;
|
||||
private Locale mLocale;
|
||||
private Markwon mMarkwon;
|
||||
private RecyclerView.RecycledViewPool recycledViewPool;
|
||||
@@ -110,7 +110,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
super(DIFF_CALLBACK);
|
||||
mActivity = activity;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
retrofit = oauthRetrofit;
|
||||
mCommentColor = customThemeWrapper.getCommentColor();
|
||||
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
|
||||
mLocale = locale;
|
||||
@@ -190,7 +190,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
if (holder instanceof CommentViewHolder) {
|
||||
Comment comment = getItem(holder.getBindingAdapterPosition());
|
||||
if (comment != null) {
|
||||
String name = "r/" + comment.getCommunityName();
|
||||
String name = comment.getCommunityQualifiedName();
|
||||
((CommentViewHolder) holder).authorTextView.setText(name);
|
||||
((CommentViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
||||
|
||||
@@ -437,6 +437,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
if (comment != null) {
|
||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getCommunityName());
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, comment.getCommunityQualifiedName());
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
@@ -469,7 +470,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
Comment comment = getItem(getBindingAdapterPosition());
|
||||
if (comment != null) {
|
||||
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getLinkId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
@@ -537,7 +538,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -607,7 +608,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
comment.getScore() + comment.getVoteType()));
|
||||
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -650,7 +651,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
SaveComment saveComment = new SaveComment();
|
||||
if (comment.isSaved()) {
|
||||
comment.setSaved(false);
|
||||
saveComment.unsaveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
saveComment.unsaveThing(retrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
comment.setSaved(false);
|
||||
@@ -671,7 +672,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
});
|
||||
} else {
|
||||
comment.setSaved(true);
|
||||
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
saveComment.saveThing(retrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
comment.setSaved(true);
|
||||
|
||||
@@ -1570,7 +1570,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
});
|
||||
} else {
|
||||
comment.setSaved(true);
|
||||
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
saveComment.saveThing(mRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
comment.setSaved(true);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
private SharedPreferences mSharedPreferences;
|
||||
private SharedPreferences mCurrentAccountSharedPreferences;
|
||||
private Executor mExecutor;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private Retrofit retrofit;
|
||||
private Retrofit mGfycatRetrofit;
|
||||
private Retrofit mRedgifsRetrofit;
|
||||
private Provider<StreamableAPI> mStreamableApiProvider;
|
||||
@@ -237,7 +237,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
mSharedPreferences = sharedPreferences;
|
||||
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
|
||||
mExecutor = executor;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
retrofit = oauthRetrofit;
|
||||
mGfycatRetrofit = gfycatRetrofit;
|
||||
mRedgifsRetrofit = redgifsRetrofit;
|
||||
mStreamableApiProvider = streambleApiProvider;
|
||||
@@ -2327,7 +2327,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -2419,7 +2419,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -2480,7 +2480,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
SavePost savePost = new SavePost();
|
||||
if (post.isSaved()) {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||
savePost.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -2504,7 +2504,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
});
|
||||
} else {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
savePost.saveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
savePost.saveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -3653,7 +3653,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -3745,7 +3745,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -3808,7 +3808,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
SavePost savePost = new SavePost();
|
||||
if (post.isSaved()) {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||
savePost.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -3832,7 +3832,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
||||
});
|
||||
} else {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
savePost.saveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
savePost.saveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
|
||||
@@ -508,7 +508,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
} else {
|
||||
if (mPost.getSubredditIconUrl() == null) {
|
||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(),
|
||||
mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed().substring(2),
|
||||
mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed(),
|
||||
mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> {
|
||||
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
||||
mGlide.load(R.drawable.subreddit_default_icon)
|
||||
@@ -1374,7 +1374,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
});
|
||||
} else {
|
||||
mSaveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
savePost.saveThing(mOauthRetrofit, mAccessToken, mPost.getId(),
|
||||
savePost.saveThing(mRetrofit, mAccessToken, mPost.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
|
||||
@@ -146,7 +146,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
private SharedPreferences mSharedPreferences;
|
||||
private SharedPreferences mCurrentAccountSharedPreferences;
|
||||
private Executor mExecutor;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private Retrofit retrofit;
|
||||
private Retrofit mGfycatRetrofit;
|
||||
private Retrofit mRedgifsRetrofit;
|
||||
private Provider<StreamableAPI> mStreamableApiProvider;
|
||||
@@ -250,7 +250,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
mSharedPreferences = sharedPreferences;
|
||||
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
|
||||
mExecutor = executor;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
retrofit = oauthRetrofit;
|
||||
mGfycatRetrofit = gfycatRetrofit;
|
||||
mRedgifsRetrofit = redgifsRetrofit;
|
||||
mStreamableApiProvider = streamableApiProvider;
|
||||
@@ -1155,7 +1155,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
if (mHideSubredditAndUserPrefix) {
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getSubredditName());
|
||||
} else {
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setText("r/" + post.getSubredditName());
|
||||
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getSubredditNamePrefixed());
|
||||
}
|
||||
} else {
|
||||
if (post.getAuthorIconUrl() == null) {
|
||||
@@ -2434,7 +2434,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -2530,7 +2530,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -2591,7 +2591,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
SavePost savePost = new SavePost();
|
||||
if (post.isSaved()) {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||
savePost.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -2615,7 +2615,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
});
|
||||
} else {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
savePost.saveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
savePost.saveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -3793,7 +3793,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -3889,7 +3889,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
|
||||
}
|
||||
|
||||
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||
@Override
|
||||
public void onVoteThingSuccess(int position1) {
|
||||
int currentPosition = getBindingAdapterPosition();
|
||||
@@ -3952,7 +3952,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
SavePost postSave = new SavePost();
|
||||
if (post.isSaved()) {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||
postSave.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
postSave.unsaveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -3976,7 +3976,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
});
|
||||
} else {
|
||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
postSave.saveThing(mOauthRetrofit, mAccessToken, post.getId(),
|
||||
postSave.saveThing(retrofit, mAccessToken, post.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
||||
if (isMultiSelection) {
|
||||
((DataViewHolder) holder).checkBox.performClick();
|
||||
} else {
|
||||
callback.subredditSelected(subredditData.getName(), LemmyUtils.actorID2FullName(subredditData.getActorId()), subredditData.getIconUrl());
|
||||
callback.subredditSelected(subredditData);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -252,7 +252,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
||||
public interface Callback {
|
||||
void retryLoadingMore();
|
||||
|
||||
void subredditSelected(String subredditName, String communityFullName,String iconUrl);
|
||||
void subredditSelected(SubredditData communityData);
|
||||
}
|
||||
|
||||
class DataViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -149,39 +149,17 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
|
||||
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_communities);
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null, null, false));
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
|
||||
return;
|
||||
} else if (itemClickListener != null && !hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||
name = username;
|
||||
iconUrl = userIconUrl;
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true));
|
||||
} else if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 1) {
|
||||
name = username;
|
||||
iconUrl = userIconUrl;
|
||||
if (itemClickListener != null) {
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true));
|
||||
}
|
||||
} else {
|
||||
int offset;
|
||||
if (itemClickListener != null) {
|
||||
if (hasClearSelectionRow) {
|
||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||
mFavoriteSubscribedSubredditData.size() + 4 : 2;
|
||||
} else {
|
||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||
mFavoriteSubscribedSubredditData.size() + 3 : 1;
|
||||
}
|
||||
} else {
|
||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||
mFavoriteSubscribedSubredditData.size() + 2 : 0;
|
||||
}
|
||||
|
||||
int offset = hasClearSelectionRow ? 1 : 0;
|
||||
SubscribedSubredditData communityData = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||
name = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||
fullname = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
|
||||
iconUrl = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||
|
||||
if (itemClickListener != null) {
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false));
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,11 +197,12 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
} else {
|
||||
offset = 1;
|
||||
}
|
||||
SubscribedSubredditData communityData = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||
|
||||
if (itemClickListener != null) {
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false));
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||
} else {
|
||||
viewHolder.itemView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||
@@ -250,26 +229,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mSubscribedSubredditData != null) {
|
||||
if(mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) {
|
||||
if (itemClickListener != null) {
|
||||
if (hasClearSelectionRow) {
|
||||
return mSubscribedSubredditData.size() > 0 ?
|
||||
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 4 : 0;
|
||||
} else {
|
||||
return mSubscribedSubredditData.size() > 0 ?
|
||||
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 3 : 0;
|
||||
}
|
||||
}
|
||||
return mSubscribedSubredditData.size() > 0 ?
|
||||
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 2 : 0;
|
||||
}
|
||||
|
||||
if (itemClickListener != null) {
|
||||
if (hasClearSelectionRow) {
|
||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 2 : 0;
|
||||
} else {
|
||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 1 : 0;
|
||||
}
|
||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
|
||||
}
|
||||
|
||||
return mSubscribedSubredditData.size();
|
||||
@@ -347,7 +309,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
}
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onClick(String name, String iconUrl, boolean subredditIsUser);
|
||||
void onClick(SubscribedSubredditData subredditData);
|
||||
}
|
||||
|
||||
class SubredditViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
||||
redditSectionRecyclerViewAdapter = new RedditSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, itemClickListener);
|
||||
navigationDrawerSharedPreferences, itemClickListener, accountName != null);
|
||||
postSectionRecyclerViewAdapter = new PostSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
||||
preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
|
||||
@@ -24,6 +24,9 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||
private static final int REDDIT_SECTION_ITEMS = 1;
|
||||
|
||||
private static final int REDDIT_SECTION_ANONYMOUS_ITEMS = 2;
|
||||
private final boolean isLoggedIn;
|
||||
|
||||
private BaseActivity baseActivity;
|
||||
private int primaryTextColor;
|
||||
private int secondaryTextColor;
|
||||
@@ -33,13 +36,14 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
|
||||
public RedditSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
||||
SharedPreferences navigationDrawerSharedPreferences,
|
||||
NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener) {
|
||||
NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener, boolean isLoggedIn) {
|
||||
this.baseActivity = baseActivity;
|
||||
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||
primaryIconColor = customThemeWrapper.getPrimaryIconColor();
|
||||
collapseRedditSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_REDDIT_SECTION, false);
|
||||
this.itemClickListener = itemClickListener;
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,6 +92,9 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
stringId = R.string.trending;
|
||||
drawableId = R.drawable.ic_trending_24dp;
|
||||
break;
|
||||
case 2:
|
||||
stringId = R.string.anonymous_account_instance;
|
||||
drawableId = R.drawable.ic_account_circle_24dp;
|
||||
}
|
||||
|
||||
((MenuItemViewHolder) holder).menuTextView.setText(stringId);
|
||||
@@ -99,7 +106,7 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return collapseRedditSection ? 1 : REDDIT_SECTION_ITEMS + 1;
|
||||
return !collapseRedditSection ? (isLoggedIn ? REDDIT_SECTION_ITEMS + 1 : REDDIT_SECTION_ANONYMOUS_ITEMS + 1) : 1;
|
||||
}
|
||||
|
||||
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -6,10 +6,13 @@ import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.CommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
@@ -37,6 +40,14 @@ public interface LemmyAPI {
|
||||
@GET("api/v3/post")
|
||||
Call<String> postInfo(@Query("id") Integer postID, @Query("comment_id") Integer comment_id, @Query("auth") String access_token);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/post")
|
||||
Call<String> postCreate(@Body SubmitPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/post")
|
||||
Call<String> postUpdate(@Body EditPostDTO params);
|
||||
|
||||
@GET("api/v3/user")
|
||||
ListenableFuture<Response<String>> getUserPosts(
|
||||
@Query("username") String username,
|
||||
@@ -46,6 +57,16 @@ public interface LemmyAPI {
|
||||
@Query("saved_only") Boolean saved_only,
|
||||
@Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/user")
|
||||
Call<String> getUserComments(
|
||||
@Query("username") String username,
|
||||
@Query("sort") String sort,
|
||||
@Query("page") Integer page,
|
||||
@Query("limit") Integer limit,
|
||||
@Query("saved_only") Boolean saved_only,
|
||||
@Query("auth") String access_token);
|
||||
|
||||
|
||||
@GET("api/v3/community/list")
|
||||
Call<String> listCommunities(
|
||||
@Query("type_") String type_,
|
||||
@@ -83,6 +104,10 @@ public interface LemmyAPI {
|
||||
@PUT("api/v3/post/save")
|
||||
Call<String> postSave(@Body SavePostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/post/mark_as_read")
|
||||
Call<String> postRead(@Body ReadPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/comment/save")
|
||||
Call<String> commentSave(@Body SaveCommentDTO params);
|
||||
@@ -144,4 +169,16 @@ public interface LemmyAPI {
|
||||
@Header("Cookie") String token,
|
||||
@Part MultipartBody.Part filePart
|
||||
);
|
||||
|
||||
@GET("api/v3/resolve_object")
|
||||
Call<String> resolveObject(
|
||||
@Query("q") String query,
|
||||
@Query("auth") String auth
|
||||
);
|
||||
|
||||
@GET("api/v3/comment")
|
||||
Call<String> getComment(
|
||||
@Query("id") int commentId,
|
||||
@Query("auth") String auth
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,12 +38,6 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
||||
TextView linkTypeTextView;
|
||||
@BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment)
|
||||
TextView imageTypeTextView;
|
||||
@BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment)
|
||||
TextView videoTypeTextView;
|
||||
@BindView(R.id.gallery_type_linear_layout_post_type_bottom_sheet_fragment)
|
||||
TextView galleryTypeTextView;
|
||||
@BindView(R.id.poll_type_linear_layout_post_type_bottom_sheet_fragment)
|
||||
TextView pollTypeTextView;
|
||||
private BaseActivity activity;
|
||||
|
||||
public PostTypeBottomSheetFragment() {
|
||||
@@ -76,20 +70,6 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
||||
dismiss();
|
||||
});
|
||||
|
||||
videoTypeTextView.setOnClickListener(view -> {
|
||||
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
galleryTypeTextView.setOnClickListener(view -> {
|
||||
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_GALLERY);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
pollTypeTextView.setOnClickListener(view -> {
|
||||
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_POLL);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if (activity.typeface != null) {
|
||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
||||
|
||||
@@ -16,16 +16,13 @@ import java.util.Locale;
|
||||
|
||||
import eu.toldi.infinityforlemmy.NetworkState;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
public class CommentDataSource extends PageKeyedDataSource<Integer, Comment> {
|
||||
|
||||
private Retrofit retrofit;
|
||||
private Locale locale;
|
||||
@@ -39,8 +36,8 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
private MutableLiveData<NetworkState> initialLoadStateLiveData;
|
||||
private MutableLiveData<Boolean> hasPostLiveData;
|
||||
|
||||
private LoadParams<String> params;
|
||||
private LoadCallback<String, Comment> callback;
|
||||
private LoadParams<Integer> params;
|
||||
private LoadCallback<Integer, Comment> callback;
|
||||
|
||||
CommentDataSource(Retrofit retrofit, Locale locale, @Nullable String accessToken, String username, SortType sortType,
|
||||
boolean areSavedComments) {
|
||||
@@ -72,42 +69,27 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull LoadInitialCallback<String, Comment> callback) {
|
||||
public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull LoadInitialCallback<Integer, Comment> callback) {
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADING);
|
||||
|
||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||
Call<String> commentsCall;
|
||||
if (areSavedComments) {
|
||||
commentsCall = api.getUserSavedCommentsOauth(username, PostPagingSource.USER_WHERE_SAVED,
|
||||
null, sortType.getType(), sortType.getTime(),
|
||||
APIUtils.getOAuthHeader(accessToken));
|
||||
} else {
|
||||
if (accessToken == null) {
|
||||
commentsCall = api.getUserComments(username, null, sortType.getType(),
|
||||
sortType.getTime());
|
||||
} else {
|
||||
commentsCall = api.getUserCommentsOauth(APIUtils.getOAuthHeader(accessToken), username,
|
||||
null, sortType.getType(), sortType.getTime());
|
||||
}
|
||||
}
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
Call<String> commentsCall = api.getUserComments(username, sortType.getType().value, 1, 25, areSavedComments, accessToken);
|
||||
|
||||
commentsCall.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
|
||||
@Override
|
||||
public void parseSuccessful(ArrayList<Comment> comments, String after) {
|
||||
if (comments.size() == 0) {
|
||||
public void parseSuccessful(ArrayList<Comment> comments, Integer after) {
|
||||
if (comments.isEmpty()) {
|
||||
callback.onResult(comments, null, null);
|
||||
hasPostLiveData.postValue(false);
|
||||
} else {
|
||||
hasPostLiveData.postValue(true);
|
||||
callback.onResult(comments, null, 2);
|
||||
}
|
||||
|
||||
if (after == null || after.equals("") || after.equals("null")) {
|
||||
callback.onResult(comments, null, null);
|
||||
} else {
|
||||
callback.onResult(comments, null, after);
|
||||
}
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
@@ -129,39 +111,27 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadBefore(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, Comment> callback) {
|
||||
public void loadBefore(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Comment> callback) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAfter(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, Comment> callback) {
|
||||
public void loadAfter(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Comment> callback) {
|
||||
this.params = params;
|
||||
this.callback = callback;
|
||||
|
||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADING);
|
||||
|
||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||
Call<String> commentsCall;
|
||||
if (areSavedComments) {
|
||||
commentsCall = api.getUserSavedCommentsOauth(username, PostPagingSource.USER_WHERE_SAVED, params.key,
|
||||
sortType.getType(), sortType.getTime(), APIUtils.getOAuthHeader(accessToken));
|
||||
} else {
|
||||
if (accessToken == null) {
|
||||
commentsCall = api.getUserComments(username, params.key, sortType.getType(),
|
||||
sortType.getTime());
|
||||
} else {
|
||||
commentsCall = api.getUserCommentsOauth(APIUtils.getOAuthHeader(accessToken),
|
||||
username, params.key, sortType.getType(), sortType.getTime());
|
||||
}
|
||||
}
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
Call<String> commentsCall = api.getUserComments(username, sortType.getType().value, params.key, 25, areSavedComments, accessToken);
|
||||
commentsCall.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
new ParseCommentAsyncTask(response.body(), locale, new ParseCommentAsyncTask.ParseCommentAsyncTaskListener() {
|
||||
@Override
|
||||
public void parseSuccessful(ArrayList<Comment> comments, String after) {
|
||||
if (after == null || after.equals("") || after.equals("null")) {
|
||||
public void parseSuccessful(ArrayList<Comment> comments, Integer after) {
|
||||
if (comments.isEmpty()) {
|
||||
callback.onResult(comments, null);
|
||||
} else {
|
||||
callback.onResult(comments, after);
|
||||
@@ -187,7 +157,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
}
|
||||
|
||||
private static class ParseCommentAsyncTask extends AsyncTask<Void, ArrayList<Comment>, ArrayList<Comment>> {
|
||||
private String after;
|
||||
private Integer after;
|
||||
private Locale locale;
|
||||
private JSONArray commentsJSONArray;
|
||||
private boolean parseFailed;
|
||||
@@ -197,9 +167,8 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
this.locale = locale;
|
||||
this.parseCommentAsyncTaskListener = parseCommentAsyncTaskListener;
|
||||
try {
|
||||
JSONObject data = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY);
|
||||
commentsJSONArray = data.getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||
after = data.getString(JSONUtils.AFTER_KEY);
|
||||
JSONObject data = new JSONObject(response);
|
||||
commentsJSONArray = data.getJSONArray("comments");
|
||||
parseFailed = false;
|
||||
} catch (JSONException e) {
|
||||
parseFailed = true;
|
||||
@@ -216,7 +185,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
ArrayList<Comment> comments = new ArrayList<>();
|
||||
for (int i = 0; i < commentsJSONArray.length(); i++) {
|
||||
try {
|
||||
JSONObject commentJSON = commentsJSONArray.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||
JSONObject commentJSON = commentsJSONArray.getJSONObject(i);
|
||||
comments.add(ParseComment.parseSingleComment(commentJSON));
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
@@ -235,7 +204,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
|
||||
}
|
||||
|
||||
interface ParseCommentAsyncTaskListener {
|
||||
void parseSuccessful(ArrayList<Comment> comments, String after);
|
||||
void parseSuccessful(ArrayList<Comment> comments, Integer page);
|
||||
|
||||
void parseFailed();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@@ -98,6 +101,32 @@ public class FetchComment {
|
||||
});
|
||||
}
|
||||
|
||||
public static void fetchSingleComment(Retrofit retrofit, @Nullable String accessToken, int commentId,
|
||||
FetchCommentListener fetchCommentListener) {
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
Call<String> comment = api.getComment(commentId, accessToken);
|
||||
comment.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
try {
|
||||
Comment c = ParseComment.parseSingleComment(new JSONObject(response.body()).getJSONObject("comment_view"));
|
||||
ArrayList<Comment> comments = new ArrayList<>();
|
||||
comments.add(c);
|
||||
fetchCommentListener.onFetchCommentSuccess(comments, null, null);
|
||||
} catch (JSONException e) {
|
||||
fetchCommentListener.onFetchCommentFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
fetchCommentListener.onFetchCommentFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface FetchCommentListener {
|
||||
void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children);
|
||||
|
||||
|
||||
@@ -9,16 +9,22 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
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;
|
||||
|
||||
@@ -34,7 +40,6 @@ public class ParseComment {
|
||||
|
||||
ArrayList<Comment> expandedNewComments = new ArrayList<>();
|
||||
ArrayList<Integer> moreChildrenIds = new ArrayList<>();
|
||||
ArrayList<Comment> newComments = new ArrayList<>();
|
||||
|
||||
|
||||
Map<Integer, Comment> parsedComments = new HashMap<>();
|
||||
@@ -49,8 +54,13 @@ public class ParseComment {
|
||||
}
|
||||
}
|
||||
Comment parentComment = (commentId != null) ? parsedComments.get(commentId) : null;
|
||||
if (parentComment != null && parentComment.getDepth() == 0)
|
||||
parentComment = null;
|
||||
if (parentComment != null) {
|
||||
if (parentComment.getDepth() == 0) {
|
||||
parentComment = null;
|
||||
} else {
|
||||
expandedNewComments.add(parentComment);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = orderedComments.size() - 1; i >= 0; i--) {
|
||||
Comment c = orderedComments.get(i);
|
||||
@@ -64,9 +74,7 @@ public class ParseComment {
|
||||
}
|
||||
|
||||
//Add all comments to newComments
|
||||
for (int i = 0; i < topLevelComments.size(); i++) {
|
||||
newComments.add(topLevelComments.get(i));
|
||||
}
|
||||
ArrayList<Comment> newComments = new ArrayList<>(topLevelComments);
|
||||
|
||||
expandChildren(newComments, expandedNewComments, expandChildren);
|
||||
|
||||
@@ -281,12 +289,27 @@ public class ParseComment {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
commentTimeMillis = ZonedDateTime.parse(commentObj.getString("published"),
|
||||
DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.of("Z"))).toInstant().toEpochMilli();
|
||||
} else {
|
||||
String dateStr = commentObj.getString("published");
|
||||
|
||||
dateStr = dateStr.substring(0, dateStr.lastIndexOf(".") + 4) + 'Z';
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
try {
|
||||
Date date = sdf.parse(dateStr);
|
||||
if (date != null) {
|
||||
commentTimeMillis = date.getTime();
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String commentMarkdown = commentObj.getString("content");
|
||||
String commentRawText = commentObj.getString("content");
|
||||
String content = MarkdownUtils.processImageCaptions(commentObj.getString("content"), "Image");
|
||||
String commentMarkdown = content;
|
||||
String commentRawText = content;
|
||||
String linkId = postObj.getString("id");
|
||||
String communityName = communityObj.getString("name");
|
||||
String communityQualifiedName = communityObj.getString("actor_id");
|
||||
String communityQualifiedName = LemmyUtils.actorID2FullName(communityObj.getString("actor_id"));
|
||||
|
||||
int score = countsObj.getInt("score");
|
||||
int voteType = (jsonObject.isNull("my_vote")) ? 0 : jsonObject.getInt("my_vote");
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class EditPostDTO {
|
||||
|
||||
private int post_id;
|
||||
private String name;
|
||||
private String url;
|
||||
private String body;
|
||||
private boolean nsfw;
|
||||
private Integer language_id;
|
||||
private String auth;
|
||||
|
||||
public EditPostDTO(int post_id, String name, String url, String body, boolean nsfw, Integer language_id, String auth) {
|
||||
this.post_id = post_id;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.body = body;
|
||||
this.nsfw = nsfw;
|
||||
this.language_id = language_id;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPost_id() {
|
||||
return post_id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public boolean isNsfw() {
|
||||
return nsfw;
|
||||
}
|
||||
|
||||
public Integer getLanguage_id() {
|
||||
return language_id;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class ReadPostDTO {
|
||||
|
||||
private int post_id;
|
||||
private boolean read;
|
||||
private String auth;
|
||||
|
||||
public ReadPostDTO(int post_id, boolean read, String auth) {
|
||||
this.post_id = post_id;
|
||||
this.read = read;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPost_id() {
|
||||
return post_id;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class SubmitPostDTO {
|
||||
|
||||
private String name;
|
||||
private int community_id;
|
||||
private String url;
|
||||
private String body;
|
||||
private String honeypot;
|
||||
private boolean nsfw;
|
||||
private Integer language_id;
|
||||
private String auth;
|
||||
|
||||
public SubmitPostDTO(String name, int community_id, String url, String body, String honeypot, boolean nsfw, Integer language_id, String auth) {
|
||||
this.name = name;
|
||||
this.community_id = community_id;
|
||||
this.url = url;
|
||||
this.body = body;
|
||||
this.honeypot = honeypot;
|
||||
this.nsfw = nsfw;
|
||||
this.language_id = language_id;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getCommunity_id() {
|
||||
return community_id;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public String getHoneypot() {
|
||||
return honeypot;
|
||||
}
|
||||
|
||||
public boolean isNsfw() {
|
||||
return nsfw;
|
||||
}
|
||||
|
||||
public Integer getLanguage_id() {
|
||||
return language_id;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package eu.toldi.infinityforlemmy.events;
|
||||
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
|
||||
public class SubmitImagePostEvent {
|
||||
public boolean postSuccess;
|
||||
public String errorMessage;
|
||||
public Post post;
|
||||
|
||||
public SubmitImagePostEvent(boolean postSuccess, String errorMessage) {
|
||||
public SubmitImagePostEvent(boolean postSuccess, String errorMessage, Post post) {
|
||||
this.postSuccess = postSuccess;
|
||||
this.errorMessage = errorMessage;
|
||||
this.post = post;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,9 +81,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
@Named("default")
|
||||
@@ -253,6 +249,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
|
||||
new Handler().postDelayed(() -> bindView(resources), 0);
|
||||
|
||||
return rootView;
|
||||
@@ -263,7 +260,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||
mCommentRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
|
||||
mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper,
|
||||
mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mRetrofit.getRetrofit(), customThemeWrapper,
|
||||
getResources().getConfiguration().locale, mSharedPreferences,
|
||||
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
|
||||
() -> mCommentViewModel.retryLoadingMore());
|
||||
@@ -294,15 +291,11 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
|
||||
CommentViewModel.Factory factory;
|
||||
|
||||
if (mAccessToken == null) {
|
||||
factory = new CommentViewModel.Factory(mRetrofit.getRetrofit(),
|
||||
resources.getConfiguration().locale, null, username, sortType,
|
||||
getArguments().getBoolean(EXTRA_ARE_SAVED_COMMENTS));
|
||||
} else {
|
||||
factory = new CommentViewModel.Factory(mOauthRetrofit,
|
||||
resources.getConfiguration().locale, mAccessToken, username, sortType,
|
||||
getArguments().getBoolean(EXTRA_ARE_SAVED_COMMENTS));
|
||||
}
|
||||
|
||||
factory = new CommentViewModel.Factory(mRetrofit.getRetrofit(),
|
||||
resources.getConfiguration().locale, mAccessToken, username, sortType,
|
||||
getArguments().getBoolean(EXTRA_ARE_SAVED_COMMENTS));
|
||||
|
||||
|
||||
mCommentViewModel = new ViewModelProvider(this, factory).get(CommentViewModel.class);
|
||||
mCommentViewModel.getComments().observe(getViewLifecycleOwner(), comments -> mAdapter.submitList(comments));
|
||||
|
||||
@@ -380,7 +380,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
|
||||
if (historyType == HISTORY_TYPE_READ_POSTS) {
|
||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, defaultPostLayout);
|
||||
|
||||
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit,
|
||||
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
|
||||
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
|
||||
accessToken, accountName, postType, postLayout, true,
|
||||
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
|
||||
|
||||
@@ -398,8 +398,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
};
|
||||
|
||||
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
|
||||
|
||||
int recyclerViewPosition = 0;
|
||||
if (savedInstanceState != null) {
|
||||
@@ -437,6 +435,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
postType = getArguments().getInt(EXTRA_POST_TYPE);
|
||||
|
||||
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true) && postType != PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE);
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
|
||||
|
||||
accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||
accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
||||
@@ -725,6 +726,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
});
|
||||
} else if (postType == PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE) {
|
||||
subredditName = getArguments().getString(EXTRA_NAME);
|
||||
usage = PostFilterUsage.HOME_TYPE;
|
||||
nameOfUsage = PostFilterUsage.NO_USAGE;
|
||||
subredditName = getArguments().getString(EXTRA_NAME);
|
||||
@@ -971,11 +973,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
this.postFilter = postFilter;
|
||||
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false);
|
||||
this.concatenatedSubredditNames = concatenatedSubredditNames;
|
||||
if (concatenatedSubredditNames == null) {
|
||||
showErrorView(R.string.anonymous_front_page_no_subscriptions);
|
||||
} else {
|
||||
initializeAndBindPostViewModelForAnonymous(concatenatedSubredditNames);
|
||||
}
|
||||
showErrorView(R.string.anonymous_homepage_not_implemented);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -1017,11 +1015,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
|
||||
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false);
|
||||
this.concatenatedSubredditNames = concatenatedSubredditNames;
|
||||
if (concatenatedSubredditNames == null) {
|
||||
showErrorView(R.string.anonymous_front_page_no_subscriptions);
|
||||
} else {
|
||||
initializeAndBindPostViewModelForAnonymous(concatenatedSubredditNames);
|
||||
}
|
||||
showErrorView(R.string.anonymous_homepage_not_implemented);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -1209,33 +1203,33 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
private void initializeAndBindPostViewModel(String accessToken) {
|
||||
if (postType == PostPagingSource.TYPE_SEARCH) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit() , accessToken,
|
||||
mRetrofit, accessToken,
|
||||
accountName, mSharedPreferences,
|
||||
mPostFeedScrolledPositionSharedPreferences, mPostHistorySharedPreferences, subredditName,
|
||||
query, trendingSource, postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
||||
} else if (postType == PostPagingSource.TYPE_SUBREDDIT) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit() , accessToken,
|
||||
mRetrofit, accessToken,
|
||||
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
|
||||
mPostHistorySharedPreferences, subredditName, postType, sortType, postFilter, readPosts))
|
||||
.get(PostViewModel.class);
|
||||
} else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), accessToken,
|
||||
mRetrofit, accessToken,
|
||||
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
|
||||
mPostHistorySharedPreferences, multiRedditPath, postType, sortType, postFilter, readPosts))
|
||||
.get(PostViewModel.class);
|
||||
} else if (postType == PostPagingSource.TYPE_USER) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), accessToken,
|
||||
mRetrofit, accessToken,
|
||||
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
|
||||
mPostHistorySharedPreferences, username, postType, sortType, postFilter, where, readPosts))
|
||||
.get(PostViewModel.class);
|
||||
} else {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), accessToken,
|
||||
mRetrofit, accessToken,
|
||||
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
|
||||
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts,subredditName)).get(PostViewModel.class);
|
||||
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts, subredditName)).get(PostViewModel.class);
|
||||
}
|
||||
|
||||
bindPostViewModel();
|
||||
@@ -1245,28 +1239,28 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
//For anonymous user
|
||||
if (postType == PostPagingSource.TYPE_SEARCH) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), null, accountName, mSharedPreferences,
|
||||
mRetrofit, null, accountName, mSharedPreferences,
|
||||
mPostFeedScrolledPositionSharedPreferences, null, subredditName, query, trendingSource,
|
||||
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
||||
} else if (postType == PostPagingSource.TYPE_SUBREDDIT) {
|
||||
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), null, accountName, mSharedPreferences,
|
||||
mRetrofit, null, accountName, mSharedPreferences,
|
||||
mPostFeedScrolledPositionSharedPreferences, null, subredditName, postType, sortType,
|
||||
postFilter, readPosts)).get(PostViewModel.class);
|
||||
} else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), null, accountName, mSharedPreferences,
|
||||
mRetrofit, null, accountName, mSharedPreferences,
|
||||
mPostFeedScrolledPositionSharedPreferences, null, multiRedditPath,
|
||||
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
||||
} else if (postType == PostPagingSource.TYPE_USER) {
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), null, accountName, mSharedPreferences,
|
||||
mRetrofit, null, accountName, mSharedPreferences,
|
||||
mPostFeedScrolledPositionSharedPreferences, null, username, postType, sortType, postFilter,
|
||||
where, readPosts)).get(PostViewModel.class);
|
||||
} else {
|
||||
//Anonymous Front Page
|
||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
|
||||
mRetrofit.getRetrofit(), mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter,subredditName))
|
||||
mRetrofit, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter, subredditName))
|
||||
.get(PostViewModel.class);
|
||||
}
|
||||
|
||||
@@ -1357,7 +1351,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
|
||||
mFetchPostInfoLinearLayout.setOnClickListener(null);
|
||||
showErrorView(R.string.no_posts);
|
||||
if (accessToken != null) {
|
||||
showErrorView(R.string.no_posts);
|
||||
} else {
|
||||
showErrorView(R.string.anonymous_homepage_not_implemented);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void changeSortType(SortType sortType) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditListingViewModel;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
|
||||
@@ -149,13 +150,13 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subredditSelected(String subredditName, String communityFullName, String iconUrl) {
|
||||
public void subredditSelected(SubredditData communityData) {
|
||||
if (isGettingSubredditInfo) {
|
||||
((SearchSubredditsResultActivity) mActivity).getSelectedSubreddit(subredditName, iconUrl);
|
||||
((SearchSubredditsResultActivity) mActivity).getSelectedSubreddit(communityData);
|
||||
} else {
|
||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityFullName);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, communityData.getName());
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, LemmyUtils.actorID2FullName(communityData.getActorId()));
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
if (getArguments().getBoolean(EXTRA_IS_SUBREDDIT_SELECTION)) {
|
||||
adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRedditDataRoomDatabase,
|
||||
mCustomThemeWrapper, accessToken, getArguments().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION),
|
||||
(name, iconUrl, subredditIsUser) -> ((SubredditSelectionActivity) mActivity).getSelectedSubreddit(name, iconUrl, subredditIsUser));
|
||||
(communityData) -> ((SubredditSelectionActivity) mActivity).getSelectedSubreddit(communityData));
|
||||
} else {
|
||||
adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRedditDataRoomDatabase,
|
||||
mCustomThemeWrapper, accessToken);
|
||||
|
||||
@@ -85,7 +85,6 @@ import eu.toldi.infinityforlemmy.activities.SubmitCrosspostActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.adapters.CommentsRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.adapters.PostDetailRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.LoadUserData;
|
||||
@@ -95,7 +94,6 @@ import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
||||
import eu.toldi.infinityforlemmy.comment.FetchRemovedComment;
|
||||
import eu.toldi.infinityforlemmy.comment.FetchRemovedCommentReveddit;
|
||||
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.CustomToroContainer;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
@@ -109,7 +107,7 @@ import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.post.FetchPost;
|
||||
import eu.toldi.infinityforlemmy.post.FetchRemovedPost;
|
||||
import eu.toldi.infinityforlemmy.post.HidePost;
|
||||
import eu.toldi.infinityforlemmy.post.ParsePost;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
@@ -193,6 +191,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
ExoCreator mExoCreator;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
@State
|
||||
Post mPost;
|
||||
@State
|
||||
@@ -228,6 +228,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
private Menu mMenu;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private int postListPosition = -1;
|
||||
private Integer mSingleCommentId;
|
||||
private String mContextNumber;
|
||||
@@ -280,6 +281,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
mSavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_toolbar_24dp);
|
||||
mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp);
|
||||
@@ -310,7 +312,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
|
||||
mSwipeUpToHideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
|
||||
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
|
||||
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
|
||||
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountQualifiedName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
|
||||
if (savedInstanceState == null) {
|
||||
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
|
||||
viewPostDetailFragmentId = System.currentTimeMillis();
|
||||
@@ -546,11 +548,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
};
|
||||
|
||||
mSingleCommentId = (getArguments().getString(EXTRA_SINGLE_COMMENT_ID) == null) ? null : Integer.valueOf(getArguments().getString(EXTRA_SINGLE_COMMENT_ID));
|
||||
mSingleCommentId = getArguments().getInt(EXTRA_SINGLE_COMMENT_ID, 0);
|
||||
mContextNumber = getArguments().getString(EXTRA_CONTEXT_NUMBER, "8");
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
if (mSingleCommentId != null) {
|
||||
if (mSingleCommentId != 0) {
|
||||
isSingleCommentThreadMode = true;
|
||||
}
|
||||
mMessageFullname = getArguments().getString(EXTRA_MESSAGE_FULLNAME);
|
||||
@@ -594,7 +596,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
|
||||
if (mPost == null) {
|
||||
fetchPostAndCommentsById(getArguments().getString(EXTRA_POST_ID));
|
||||
fetchPostAndCommentsById(getArguments().getInt(EXTRA_POST_ID));
|
||||
} else {
|
||||
setupMenu();
|
||||
|
||||
@@ -1169,8 +1171,18 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
private void tryMarkingPostAsRead() {
|
||||
if (mMarkPostsAsRead && mPost != null && !mPost.isRead()) {
|
||||
mPost.markAsRead();
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, mPost.getId());
|
||||
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
|
||||
markPostAsRead.markPostAsRead(mPost.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, mPost.getId());
|
||||
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(activity, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1240,153 +1252,91 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fetchPostAndCommentsById(String subredditId) {
|
||||
private void fetchPostAndCommentsById(int subredditId) {
|
||||
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
mGlide.clear(mFetchPostInfoImageView);
|
||||
|
||||
Call<String> postAndComments = mRetrofit.getRetrofit().create(LemmyAPI.class).getComments("All", sortType.value, 5, 1, 25, null, null, Integer.valueOf(subredditId), mSingleCommentId, false, mAccessToken);
|
||||
postAndComments.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (!isAdded()) {
|
||||
return;
|
||||
}
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
ParsePost.parsePost(mExecutor, new Handler(), response.body(), new ParsePost.ParsePostListener() {
|
||||
@Override
|
||||
public void onParsePostSuccess(Post post) {
|
||||
mPost = post;
|
||||
tryMarkingPostAsRead();
|
||||
|
||||
setupMenu();
|
||||
|
||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
||||
mRetrofit.getRetrofit(), mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
||||
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
||||
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
||||
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
|
||||
mPostDetailsSharedPreferences, mExoCreator,
|
||||
post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||
|
||||
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
||||
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
|
||||
mRetrofit.getRetrofit(), mOauthRetrofit, mAccessToken, mAccountName, mPost, mLocale,
|
||||
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
|
||||
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
|
||||
@Override
|
||||
public void retryFetchingComments() {
|
||||
fetchCommentsRespectRecommendedSort(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void retryFetchingMoreComments() {
|
||||
isLoadingMoreChildren = false;
|
||||
loadMoreChildrenSuccess = true;
|
||||
|
||||
fetchMoreComments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortType.Type getSortType() {
|
||||
return sortType;
|
||||
}
|
||||
});
|
||||
if (mCommentsRecyclerView != null) {
|
||||
mRecyclerView.setAdapter(mPostAdapter);
|
||||
mCommentsRecyclerView.setAdapter(mCommentsAdapter);
|
||||
} else {
|
||||
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentsAdapter);
|
||||
mRecyclerView.setAdapter(mConcatAdapter);
|
||||
}
|
||||
|
||||
if (mRespectSubredditRecommendedSortType) {
|
||||
fetchCommentsRespectRecommendedSort(false);
|
||||
} else {
|
||||
ParseComment.parseComments(mExecutor, new Handler(), response.body(), null,
|
||||
mExpandChildren, new ParseComment.ParseCommentListener() {
|
||||
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), String.valueOf(subredditId), mAccessToken,
|
||||
new FetchPost.FetchPostListener() {
|
||||
@Override
|
||||
public void fetchPostSuccess(Post post) {
|
||||
if (!isAdded()) {
|
||||
return;
|
||||
}
|
||||
mPost = post;
|
||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
||||
mRetrofit.getRetrofit(), mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
||||
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
||||
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
||||
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
|
||||
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 : mSingleCommentId, sortType, mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
||||
pages_loaded++;
|
||||
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
||||
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
|
||||
mRetrofit.getRetrofit(), mOauthRetrofit, mAccessToken, mAccountName, mPost, mLocale,
|
||||
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
|
||||
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
|
||||
@Override
|
||||
public void onParseCommentSuccess(ArrayList<Comment> topLevelComments, ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
|
||||
ViewPostDetailFragment.this.children = moreChildrenIds;
|
||||
|
||||
hasMoreChildren = children.size() != 0;
|
||||
mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
|
||||
|
||||
if (children.size() > 0) {
|
||||
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).clearOnScrollListeners();
|
||||
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
if (!mIsSmoothScrolling && !mLockFab) {
|
||||
if (!recyclerView.canScrollVertically(1)) {
|
||||
activity.hideFab();
|
||||
} else {
|
||||
if (dy > 0) {
|
||||
if (mSwipeUpToHideFab) {
|
||||
activity.showFab();
|
||||
} else {
|
||||
activity.hideFab();
|
||||
}
|
||||
} else {
|
||||
if (mSwipeUpToHideFab) {
|
||||
activity.hideFab();
|
||||
} else {
|
||||
activity.showFab();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
||||
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
|
||||
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
|
||||
int firstVisibleItemPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
||||
|
||||
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
||||
fetchMoreComments();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
mIsSmoothScrolling = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public void retryFetchingComments() {
|
||||
fetchCommentsRespectRecommendedSort(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseCommentFailed() {
|
||||
mCommentsAdapter.initiallyLoadCommentsFailed();
|
||||
public void retryFetchingMoreComments() {
|
||||
isLoadingMoreChildren = false;
|
||||
loadMoreChildrenSuccess = true;
|
||||
|
||||
fetchMoreComments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortType.Type getSortType() {
|
||||
return sortType;
|
||||
}
|
||||
});
|
||||
if (mCommentsRecyclerView != null) {
|
||||
mRecyclerView.setAdapter(mPostAdapter);
|
||||
mCommentsRecyclerView.setAdapter(mCommentsAdapter);
|
||||
} else {
|
||||
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentsAdapter);
|
||||
mRecyclerView.setAdapter(mConcatAdapter);
|
||||
}
|
||||
|
||||
if (mRespectSubredditRecommendedSortType) {
|
||||
fetchCommentsRespectRecommendedSort(false);
|
||||
}
|
||||
ViewPostDetailFragment.this.children = children;
|
||||
|
||||
hasMoreChildren = false;
|
||||
mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParsePostFail() {
|
||||
showErrorView(subredditId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showErrorView(subredditId);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFetchCommentFailed() {
|
||||
if (isAdded()) {
|
||||
showErrorView(subredditId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchPostFailed() {
|
||||
if (isAdded()) {
|
||||
showMessage(R.string.refresh_post_failed);
|
||||
isRefreshing = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
if (isAdded()) {
|
||||
showErrorView(subredditId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState, SortType.Type sortType) {
|
||||
@@ -1598,7 +1548,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
}
|
||||
|
||||
private void showErrorView(String subredditId) {
|
||||
private void showErrorView(int subredditId) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||
mFetchPostInfoLinearLayout.setOnClickListener(view -> fetchPostAndCommentsById(subredditId));
|
||||
|
||||
@@ -8,6 +8,11 @@ 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;
|
||||
import eu.toldi.infinityforlemmy.customviews.CustomMarkwonAdapter;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonPlugin;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
@@ -20,8 +25,6 @@ import io.noties.markwon.recycler.MarkwonAdapter;
|
||||
import io.noties.markwon.recycler.table.TableEntry;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.customviews.CustomMarkwonAdapter;
|
||||
|
||||
public class MarkdownUtils {
|
||||
/**
|
||||
@@ -112,4 +115,39 @@ public class MarkdownUtils {
|
||||
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
|
||||
.build();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package eu.toldi.infinityforlemmy.post;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class MarkPostAsRead {
|
||||
RetrofitHolder retrofitHolder;
|
||||
|
||||
public MarkPostAsRead(RetrofitHolder retrofitHolder) {
|
||||
this.retrofitHolder = retrofitHolder;
|
||||
}
|
||||
|
||||
private void setPostAsRead(int post_id, boolean markAsRead, String auth, MarkPostAsReadListener markPostAsReadListener) {
|
||||
LemmyAPI lemmyAPI = retrofitHolder.getRetrofit().create(LemmyAPI.class);
|
||||
|
||||
lemmyAPI.postRead(new ReadPostDTO(post_id, markAsRead, auth)).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null) {
|
||||
markPostAsReadListener.onMarkPostAsReadSuccess();
|
||||
} else {
|
||||
markPostAsReadListener.onMarkPostAsReadFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
markPostAsReadListener.onMarkPostAsReadFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void markPostAsRead(int post_id, String auth, MarkPostAsReadListener markPostAsReadListener) {
|
||||
setPostAsRead(post_id, true, auth, markPostAsReadListener);
|
||||
}
|
||||
|
||||
public void markPostAsUnread(int post_id, String auth, MarkPostAsReadListener markPostAsReadListener) {
|
||||
setPostAsRead(post_id, false, auth, markPostAsReadListener);
|
||||
}
|
||||
|
||||
public interface MarkPostAsReadListener {
|
||||
void onMarkPostAsReadSuccess();
|
||||
|
||||
void onMarkPostAsReadFailed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package eu.toldi.infinityforlemmy.post;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class ObjectResolver {
|
||||
|
||||
RetrofitHolder retrofitHolder;
|
||||
|
||||
public ObjectResolver(RetrofitHolder retrofitHolder) {
|
||||
this.retrofitHolder = retrofitHolder;
|
||||
}
|
||||
|
||||
public void resolvePost(String query, String auth, ObjectResolverListener objectResolverListener) {
|
||||
LemmyAPI lemmyAPI = retrofitHolder.getRetrofit().create(LemmyAPI.class);
|
||||
|
||||
Call<String> response = lemmyAPI.resolveObject(query, auth);
|
||||
response.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(response.body())).getJSONObject("post");
|
||||
Post p = ParsePost.parseBasicData(jsonObject);
|
||||
objectResolverListener.onResolveObjectSuccess(p);
|
||||
} catch (JSONException e) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
|
||||
} else {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void resolveComment(String query, String auth, ObjectResolverListener objectResolverListener) {
|
||||
LemmyAPI lemmyAPI = retrofitHolder.getRetrofit().create(LemmyAPI.class);
|
||||
|
||||
Call<String> response = lemmyAPI.resolveObject(query, auth);
|
||||
response.enqueue(
|
||||
new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(response.body())).getJSONObject("comment");
|
||||
Comment c = ParseComment.parseSingleComment(jsonObject);
|
||||
objectResolverListener.onResolveObjectSuccess(c);
|
||||
} catch (JSONException e) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
|
||||
} else {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public interface ObjectResolverListener {
|
||||
void onResolveObjectSuccess(Object resolvedObject);
|
||||
|
||||
void onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,23 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
@@ -152,15 +158,30 @@ public class ParsePost {
|
||||
String authorFull = LemmyUtils.actorID2FullName(creator.getString("actor_id"));
|
||||
long postTimeMillis = 0;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
postTimeMillis = ZonedDateTime.parse(post.getString("published"),
|
||||
postTimeMillis = ZonedDateTime.parse(post.getString("published"),
|
||||
DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.of("Z"))).toInstant().toEpochMilli();
|
||||
} else {
|
||||
String dateStr = post.getString("published");
|
||||
|
||||
dateStr = dateStr.substring(0, dateStr.lastIndexOf(".") + 4) + 'Z';
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
try {
|
||||
Date date = sdf.parse(dateStr);
|
||||
if (date != null) {
|
||||
postTimeMillis = date.getTime();
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String title = post.getString("name");
|
||||
String permalink = post.getString("ap_id");
|
||||
int score = counts.getInt("score");
|
||||
int voteType = 0;
|
||||
int nComments = counts.getInt("comments");
|
||||
int upvoteRatio = 100 * counts.getInt("upvotes") / max(counts.getInt("upvotes") + counts.getInt("downvotes"),1);
|
||||
int upvoteRatio = 100 * counts.getInt("upvotes") / max(counts.getInt("upvotes") + counts.getInt("downvotes"), 1);
|
||||
boolean hidden = community.getBoolean("hidden");
|
||||
boolean nsfw = post.getBoolean("nsfw");
|
||||
boolean locked = post.getBoolean("locked");
|
||||
@@ -501,8 +522,23 @@ public class ParsePost {
|
||||
post.setStreamableShortCode(shortCode);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException ignore) { }
|
||||
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
}
|
||||
} else if (post.getPostType() == Post.TEXT_TYPE) {
|
||||
List<ImageInfo> images = extractImages(post.getSelfText());
|
||||
if (images.size() == 1) {
|
||||
post.setPostType(Post.IMAGE_TYPE);
|
||||
post.setUrl(images.get(0).imageUrl);
|
||||
} else if (images.size() > 1) {
|
||||
post.setPostType(Post.GALLERY_TYPE);
|
||||
ArrayList<Post.Gallery> gallery = new ArrayList<>();
|
||||
for (ImageInfo image : images) {
|
||||
String[] imagePath = image.getImageUrl().split(Pattern.quote("/"));
|
||||
gallery.add(new Post.Gallery("image/jpg", image.getImageUrl(), "", imagePath[imagePath.length - 1], image.caption, ""));
|
||||
}
|
||||
post.setGallery(gallery);
|
||||
}
|
||||
|
||||
if (!data.isNull(JSONUtils.GALLERY_DATA_KEY)) {
|
||||
JSONArray galleryIdsArray = data.getJSONObject(JSONUtils.GALLERY_DATA_KEY).getJSONArray(JSONUtils.ITEMS_KEY);
|
||||
JSONObject galleryObject = data.getJSONObject(JSONUtils.MEDIA_METADATA_KEY);
|
||||
@@ -612,17 +648,17 @@ public class ParsePost {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(data.getBoolean("read")){
|
||||
if (data.getBoolean("read")) {
|
||||
post.markAsRead();
|
||||
}
|
||||
if(!data.isNull("my_vote")){
|
||||
if (!data.isNull("my_vote")) {
|
||||
post.setVoteType(data.getInt("my_vote"));
|
||||
post.setScore(post.getScore()-1);
|
||||
post.setScore(post.getScore() - 1);
|
||||
}
|
||||
|
||||
|
||||
if (!data.getJSONObject("post").isNull("body")) {
|
||||
String body = data.getJSONObject("post").getString("body");
|
||||
String body = MarkdownUtils.processImageCaptions(data.getJSONObject("post").getString("body"), "Image");
|
||||
post.setSelfText(body);
|
||||
post.setSelfTextPlain(body);
|
||||
post.setSelfTextPlainTrimmed(body.trim());
|
||||
@@ -674,4 +710,40 @@ public class ParsePost {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class ImageInfo {
|
||||
private String caption;
|
||||
private String imageUrl;
|
||||
|
||||
public ImageInfo(String caption, String imageUrl) {
|
||||
this.caption = caption;
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<ImageInfo> extractImages(String markdown) {
|
||||
List<ImageInfo> images = new ArrayList<>();
|
||||
|
||||
// Regular expression to match markdown image syntax 
|
||||
Pattern pattern = Pattern.compile("!\\[(.*?)\\]\\((.*?)\\)");
|
||||
Matcher matcher = pattern.matcher(markdown);
|
||||
|
||||
// Find all matches and extract image URLs and captions
|
||||
while (matcher.find()) {
|
||||
String caption = matcher.group(1);
|
||||
String imageUrl = matcher.group(2);
|
||||
images.add(new ImageInfo(caption, imageUrl));
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import retrofit2.HttpException;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post> {
|
||||
public static final int TYPE_FRONT_PAGE = 0;
|
||||
@@ -43,7 +43,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
public static final String USER_WHERE_GILDED = "gilded";
|
||||
|
||||
private Executor executor;
|
||||
private Retrofit retrofit;
|
||||
private RetrofitHolder retrofit;
|
||||
private String accessToken;
|
||||
private String accountName;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -61,10 +61,10 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
|
||||
private int page = 1;
|
||||
|
||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences,
|
||||
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
|
||||
SortType sortType, PostFilter postFilter, List<String> readPostList,String option) {
|
||||
SortType sortType, PostFilter postFilter, List<String> readPostList, String option) {
|
||||
this.executor = executor;
|
||||
this.retrofit = retrofit;
|
||||
this.accessToken = accessToken;
|
||||
@@ -79,7 +79,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
postLinkedHashSet = new LinkedHashSet<>();
|
||||
}
|
||||
|
||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
String path, int postType, SortType sortType, PostFilter postFilter,
|
||||
List<String> readPostList) {
|
||||
@@ -117,7 +117,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
postLinkedHashSet = new LinkedHashSet<>();
|
||||
}
|
||||
|
||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter,
|
||||
String where, List<String> readPostList) {
|
||||
@@ -136,7 +136,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
postLinkedHashSet = new LinkedHashSet<>();
|
||||
}
|
||||
|
||||
PostPagingSource(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
String subredditOrUserName, String query, String trendingSource, int postType,
|
||||
SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||
@@ -165,17 +165,21 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
@NonNull
|
||||
@Override
|
||||
public ListenableFuture<LoadResult<Integer, Post>> loadFuture(@NonNull LoadParams<Integer> loadParams) {
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
LemmyAPI api = retrofit.getRetrofit().create(LemmyAPI.class);
|
||||
switch (postType) {
|
||||
default:
|
||||
|
||||
case TYPE_FRONT_PAGE:
|
||||
return loadHomePosts(loadParams, api);
|
||||
case TYPE_SUBREDDIT:
|
||||
return loadSubredditPosts(loadParams, api);
|
||||
case TYPE_USER:
|
||||
return loadUserPosts(loadParams, api);
|
||||
case TYPE_SEARCH:
|
||||
return loadSearchPosts(loadParams, api);
|
||||
case TYPE_SUBREDDIT:
|
||||
return loadSubredditPosts(loadParams, api);
|
||||
default:
|
||||
case TYPE_ANONYMOUS_FRONT_PAGE:
|
||||
// Return a dummy result
|
||||
return Futures.immediateFuture(new LoadResult.Page<>(new ArrayList<>(), null, null));
|
||||
/* case TYPE_MULTI_REDDIT:
|
||||
return loadMultiRedditPosts(loadParams, api);
|
||||
default:
|
||||
|
||||
@@ -21,14 +21,14 @@ import androidx.paging.PagingLiveData;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class PostViewModel extends ViewModel {
|
||||
private Executor executor;
|
||||
private Retrofit retrofit;
|
||||
private RetrofitHolder retrofit;
|
||||
private String accessToken;
|
||||
private String accountName;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -50,10 +50,10 @@ public class PostViewModel extends ViewModel {
|
||||
private MutableLiveData<PostFilter> postFilterLiveData;
|
||||
private SortTypeAndPostFilterLiveData sortTypeAndPostFilterLiveData;
|
||||
|
||||
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
@Nullable SharedPreferences postHistorySharedPreferences, int postType,
|
||||
SortType sortType, PostFilter postFilter, List<String> readPostList,String option) {
|
||||
SortType sortType, PostFilter postFilter, List<String> readPostList, String option) {
|
||||
this.executor = executor;
|
||||
this.retrofit = retrofit;
|
||||
this.accessToken = accessToken;
|
||||
@@ -92,7 +92,7 @@ public class PostViewModel extends ViewModel {
|
||||
&& postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
|
||||
}
|
||||
|
||||
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, int postType,
|
||||
SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||
@@ -134,7 +134,7 @@ public class PostViewModel extends ViewModel {
|
||||
&& postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
|
||||
}
|
||||
|
||||
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences,
|
||||
SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
@Nullable SharedPreferences postHistorySharedPreferences, String username,
|
||||
@@ -179,7 +179,7 @@ public class PostViewModel extends ViewModel {
|
||||
&& postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
|
||||
}
|
||||
|
||||
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, String query,
|
||||
String trendingSource, int postType, SortType sortType, PostFilter postFilter,
|
||||
@@ -277,7 +277,7 @@ public class PostViewModel extends ViewModel {
|
||||
|
||||
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||
private Executor executor;
|
||||
private Retrofit retrofit;
|
||||
private RetrofitHolder retrofit;
|
||||
private String accessToken;
|
||||
private String accountName;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -292,7 +292,7 @@ public class PostViewModel extends ViewModel {
|
||||
private String userWhere;
|
||||
private List<String> readPostList;
|
||||
|
||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
SharedPreferences postHistorySharedPreferences, int postType, SortType sortType,
|
||||
PostFilter postFilter, List<String> readPostList, String option) {
|
||||
@@ -310,7 +310,7 @@ public class PostViewModel extends ViewModel {
|
||||
this.name = option;
|
||||
}
|
||||
|
||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
SharedPreferences postHistorySharedPreferences, String name, int postType, SortType sortType,
|
||||
PostFilter postFilter, List<String> readPostList) {
|
||||
@@ -329,7 +329,7 @@ public class PostViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
//User posts
|
||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
SharedPreferences postHistorySharedPreferences, String username, int postType,
|
||||
SortType sortType, PostFilter postFilter, String where, List<String> readPostList) {
|
||||
@@ -348,7 +348,7 @@ public class PostViewModel extends ViewModel {
|
||||
this.readPostList = readPostList;
|
||||
}
|
||||
|
||||
public Factory(Executor executor, Retrofit retrofit, String accessToken, String accountName,
|
||||
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
|
||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||
SharedPreferences postHistorySharedPreferences, String name, String query, String trendingSource,
|
||||
int postType, SortType sortType, PostFilter postFilter, List<String> readPostList) {
|
||||
@@ -369,7 +369,7 @@ public class PostViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
//Anonymous Front Page
|
||||
public Factory(Executor executor, Retrofit retrofit, SharedPreferences sharedPreferences,
|
||||
public Factory(Executor executor, RetrofitHolder retrofit, SharedPreferences sharedPreferences,
|
||||
String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter, String opt) {
|
||||
this.executor = executor;
|
||||
this.retrofit = retrofit;
|
||||
|
||||
@@ -5,21 +5,17 @@ import android.os.Handler;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import eu.toldi.infinityforlemmy.Flair;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
@@ -27,24 +23,24 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class SubmitPost {
|
||||
public static void submitTextOrLinkPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||
String subredditName, String title, String content,
|
||||
int communityId, String title, String body, String url,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, String kind,
|
||||
SubmitPostListener submitPostListener) {
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, subredditName, title, content,
|
||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, body,
|
||||
isNSFW, receivePostReplyNotifications, kind, url, submitPostListener);
|
||||
}
|
||||
|
||||
public static void submitImagePost(Executor executor, Handler handler, RetrofitHolder mRetrofit,
|
||||
String accessToken, String subredditName, String title, Bitmap image,
|
||||
String accessToken, int communityId, String title, String body, Bitmap image,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
|
||||
try {
|
||||
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, accessToken, image);
|
||||
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
|
||||
submitPost(executor, handler, mRetrofit.getRetrofit(), accessToken,
|
||||
subredditName, title, imageUrlOrError, flair, isSpoiler, isNSFW,
|
||||
receivePostReplyNotifications, APIUtils.KIND_IMAGE, null, submitPostListener);
|
||||
communityId, title, body, isNSFW,
|
||||
receivePostReplyNotifications, APIUtils.KIND_IMAGE, imageUrlOrError, submitPostListener);
|
||||
} else {
|
||||
submitPostListener.submitFailed(imageUrlOrError);
|
||||
}
|
||||
@@ -55,57 +51,23 @@ public class SubmitPost {
|
||||
}
|
||||
|
||||
public static void submitCrosspost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||
String subredditName, String title, String crosspostFullname,
|
||||
int communityId, String title, String crosspostFullname,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, String kind,
|
||||
SubmitPostListener submitPostListener) {
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, subredditName, title, crosspostFullname,
|
||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, crosspostFullname,
|
||||
isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||
}
|
||||
|
||||
private static void submitPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||
String subredditName, String title, String content,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
int communityId, String title, String content,
|
||||
boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, String kind,
|
||||
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
|
||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||
LemmyAPI api = oauthRetrofit.create(LemmyAPI.class);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON);
|
||||
params.put(APIUtils.SR_KEY, subredditName);
|
||||
params.put(APIUtils.TITLE_KEY, title);
|
||||
params.put(APIUtils.KIND_KEY, kind);
|
||||
switch (kind) {
|
||||
case APIUtils.KIND_SELF:
|
||||
params.put(APIUtils.TEXT_KEY, content);
|
||||
break;
|
||||
case APIUtils.KIND_LINK:
|
||||
case APIUtils.KIND_IMAGE:
|
||||
params.put(APIUtils.URL_KEY, content);
|
||||
break;
|
||||
case APIUtils.KIND_VIDEOGIF:
|
||||
params.put(APIUtils.KIND_KEY, APIUtils.KIND_IMAGE);
|
||||
params.put(APIUtils.URL_KEY, content);
|
||||
params.put(APIUtils.VIDEO_POSTER_URL_KEY, posterUrl);
|
||||
break;
|
||||
case APIUtils.KIND_VIDEO:
|
||||
params.put(APIUtils.URL_KEY, content);
|
||||
params.put(APIUtils.VIDEO_POSTER_URL_KEY, posterUrl);
|
||||
break;
|
||||
case APIUtils.KIND_CROSSPOST:
|
||||
params.put(APIUtils.CROSSPOST_FULLNAME_KEY, content);
|
||||
break;
|
||||
}
|
||||
|
||||
if (flair != null) {
|
||||
params.put(APIUtils.FLAIR_TEXT_KEY, flair.getText());
|
||||
params.put(APIUtils.FLAIR_ID_KEY, flair.getId());
|
||||
}
|
||||
params.put(APIUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
|
||||
params.put(APIUtils.NSFW_KEY, Boolean.toString(isNSFW));
|
||||
params.put(APIUtils.SEND_REPLIES_KEY, Boolean.toString(receivePostReplyNotifications));
|
||||
|
||||
Call<String> submitPostCall = api.submit(APIUtils.getOAuthHeader(accessToken), params);
|
||||
Call<String> submitPostCall = api.postCreate(new SubmitPostDTO(title, communityId, posterUrl, content, null, isNSFW, null, accessToken));
|
||||
|
||||
try {
|
||||
Response<String> response = submitPostCall.execute();
|
||||
@@ -124,50 +86,18 @@ public class SubmitPost {
|
||||
private static void getSubmittedPost(Executor executor, Handler handler, String response, String kind,
|
||||
Retrofit oauthRetrofit, String accessToken,
|
||||
SubmitPostListener submitPostListener) throws JSONException, IOException {
|
||||
JSONObject responseObject = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY);
|
||||
if (responseObject.getJSONArray(JSONUtils.ERRORS_KEY).length() != 0) {
|
||||
JSONArray error = responseObject.getJSONArray(JSONUtils.ERRORS_KEY)
|
||||
.getJSONArray(responseObject.getJSONArray(JSONUtils.ERRORS_KEY).length() - 1);
|
||||
if (error.length() != 0) {
|
||||
String errorString;
|
||||
if (error.length() >= 2) {
|
||||
errorString = error.getString(1);
|
||||
} else {
|
||||
errorString = error.getString(0);
|
||||
}
|
||||
submitPostListener.submitFailed(errorString);
|
||||
} else {
|
||||
|
||||
ParsePost.parsePost(executor, handler, response, new ParsePost.ParsePostListener() {
|
||||
@Override
|
||||
public void onParsePostSuccess(Post post) {
|
||||
submitPostListener.submitSuccessful(post);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParsePostFail() {
|
||||
submitPostListener.submitFailed(null);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!kind.equals(APIUtils.KIND_IMAGE) && !kind.equals(APIUtils.KIND_VIDEO) && !kind.equals(APIUtils.KIND_VIDEOGIF)) {
|
||||
String postId = responseObject.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.ID_KEY);
|
||||
|
||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||
|
||||
Call<String> getPostCall = api.getPostOauth(postId, APIUtils.getOAuthHeader(accessToken));
|
||||
Response<String> getPostCallResponse = getPostCall.execute();
|
||||
if (getPostCallResponse.isSuccessful()) {
|
||||
ParsePost.parsePost(executor, handler, getPostCallResponse.body(), new ParsePost.ParsePostListener() {
|
||||
@Override
|
||||
public void onParsePostSuccess(Post post) {
|
||||
submitPostListener.submitSuccessful(post);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParsePostFail() {
|
||||
submitPostListener.submitFailed(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
submitPostListener.submitFailed(getPostCallResponse.message());
|
||||
}
|
||||
} else {
|
||||
submitPostListener.submitSuccessful(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface SubmitPostListener {
|
||||
|
||||
@@ -35,12 +35,10 @@ import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import eu.toldi.infinityforlemmy.AnyAccountAccessTokenAuthenticator;
|
||||
import eu.toldi.infinityforlemmy.Flair;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
@@ -59,8 +57,6 @@ import eu.toldi.infinityforlemmy.post.SubmitPost;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.NotificationUtils;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@@ -68,7 +64,9 @@ public class SubmitPostService extends Service {
|
||||
public static final String EXTRA_ACCOUNT = "EA";
|
||||
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
public static final String EXTRA_TITLE = "ET";
|
||||
public static final String EXTRA_CONTENT = "EC";
|
||||
public static final String EXTRA_BODY = "EC";
|
||||
|
||||
public static final String EXTRA_URL = "EU";
|
||||
public static final String EXTRA_REDDIT_GALLERY_PAYLOAD = "ERGP";
|
||||
public static final String EXTRA_POLL_PAYLOAD = "EPP";
|
||||
public static final String EXTRA_KIND = "EK";
|
||||
@@ -88,9 +86,7 @@ public class SubmitPostService extends Service {
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
|
||||
@Inject
|
||||
@Named("upload_media")
|
||||
Retrofit mUploadMediaRetrofit;
|
||||
@@ -128,39 +124,32 @@ public class SubmitPostService extends Service {
|
||||
super.handleMessage(msg);
|
||||
Bundle bundle = msg.getData();
|
||||
Account account = bundle.getParcelable(EXTRA_ACCOUNT);
|
||||
String subredditName = bundle.getString(EXTRA_SUBREDDIT_NAME);
|
||||
int subredditName = bundle.getInt(EXTRA_SUBREDDIT_NAME);
|
||||
String title = bundle.getString(EXTRA_TITLE);
|
||||
Flair flair = bundle.getParcelable(EXTRA_FLAIR);
|
||||
boolean isSpoiler = bundle.getBoolean(EXTRA_IS_SPOILER, false);
|
||||
boolean isNSFW = bundle.getBoolean(EXTRA_IS_NSFW, false);
|
||||
boolean receivePostReplyNotifications = bundle.getBoolean(EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, true);
|
||||
int postType = bundle.getInt(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK);
|
||||
|
||||
Retrofit newAuthenticatorOauthRetrofit = mOauthRetrofit.newBuilder().client(new OkHttpClient.Builder().authenticator(new AnyAccountAccessTokenAuthenticator(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, account, mCurrentAccountSharedPreferences))
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
|
||||
.build())
|
||||
.build();
|
||||
String body = bundle.getString(EXTRA_BODY);
|
||||
String url = bundle.getString(EXTRA_URL);
|
||||
|
||||
if (postType == EXTRA_POST_TEXT_OR_LINK) {
|
||||
String content = bundle.getString(EXTRA_CONTENT);
|
||||
|
||||
String kind = bundle.getString(EXTRA_KIND);
|
||||
submitTextOrLinkPost(newAuthenticatorOauthRetrofit, account, subredditName, title, content, flair, isSpoiler, isNSFW,
|
||||
submitTextOrLinkPost(mRetrofit.getRetrofit(), account, subredditName, title, body, url, flair, isSpoiler, isNSFW,
|
||||
receivePostReplyNotifications, kind);
|
||||
} else if (postType == EXTRA_POST_TYPE_CROSSPOST) {
|
||||
String content = bundle.getString(EXTRA_CONTENT);
|
||||
submitCrosspost(mExecutor, handler, newAuthenticatorOauthRetrofit, account, subredditName, title, content,
|
||||
submitCrosspost(mExecutor, handler, mRetrofit.getRetrofit(), account, subredditName, title, body,
|
||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications);
|
||||
} else if (postType == EXTRA_POST_TYPE_IMAGE) {
|
||||
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
|
||||
submitImagePost(mRetrofit, account, mediaUri, subredditName, title, flair, isSpoiler, isNSFW,
|
||||
submitImagePost(mRetrofit, account, mediaUri, subredditName, title, body, flair, isSpoiler, isNSFW,
|
||||
receivePostReplyNotifications);
|
||||
} else if (postType == EXTRA_POST_TYPE_GALLERY) {
|
||||
submitGalleryPost(newAuthenticatorOauthRetrofit, account, bundle.getString(EXTRA_REDDIT_GALLERY_PAYLOAD));
|
||||
submitGalleryPost(mRetrofit.getRetrofit(), account, bundle.getString(EXTRA_REDDIT_GALLERY_PAYLOAD));
|
||||
} else {
|
||||
submitPollPost(newAuthenticatorOauthRetrofit, account, bundle.getString(EXTRA_POLL_PAYLOAD));
|
||||
submitPollPost(mRetrofit.getRetrofit(), account, bundle.getString(EXTRA_POLL_PAYLOAD));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,11 +216,11 @@ public class SubmitPostService extends Service {
|
||||
.build();
|
||||
}
|
||||
|
||||
private void submitTextOrLinkPost(Retrofit newAuthenticatorOauthRetrofit, Account selectedAccount, String subredditName, String title, String content,
|
||||
private void submitTextOrLinkPost(Retrofit newAuthenticatorOauthRetrofit, Account selectedAccount, int communityId, String title, String body, String url,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications,
|
||||
String kind) {
|
||||
SubmitPost.submitTextOrLinkPost(mExecutor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(),
|
||||
subredditName, title, content, flair, isSpoiler,
|
||||
communityId, title, body, url, flair, isSpoiler,
|
||||
isNSFW, receivePostReplyNotifications, kind, new SubmitPost.SubmitPostListener() {
|
||||
@Override
|
||||
public void submitSuccessful(Post post) {
|
||||
@@ -250,10 +239,10 @@ public class SubmitPostService extends Service {
|
||||
}
|
||||
|
||||
private void submitCrosspost(Executor executor, Handler handler, Retrofit newAuthenticatorOauthRetrofit,
|
||||
Account selectedAccount, String subredditName,
|
||||
Account selectedAccount, int communityId,
|
||||
String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean receivePostReplyNotifications) {
|
||||
SubmitPost.submitCrosspost(executor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(), subredditName, title,
|
||||
SubmitPost.submitCrosspost(executor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(), communityId, title,
|
||||
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST,
|
||||
new SubmitPost.SubmitPostListener() {
|
||||
@Override
|
||||
@@ -272,17 +261,17 @@ public class SubmitPostService extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
private void submitImagePost(RetrofitHolder newAuthenticatorOauthRetrofit, Account selectedAccount, Uri mediaUri, String subredditName, String title,
|
||||
private void submitImagePost(RetrofitHolder newAuthenticatorOauthRetrofit, Account selectedAccount, Uri mediaUri, int communityId, String title, String body,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications) {
|
||||
try {
|
||||
Bitmap resource = Glide.with(this).asBitmap().load(mediaUri).submit().get();
|
||||
SubmitPost.submitImagePost(mExecutor, handler, newAuthenticatorOauthRetrofit,
|
||||
selectedAccount.getAccessToken(), subredditName, title, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
|
||||
selectedAccount.getAccessToken(), communityId, title, body, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
|
||||
new SubmitPost.SubmitPostListener() {
|
||||
@Override
|
||||
public void submitSuccessful(Post post) {
|
||||
handler.post(() -> {
|
||||
EventBus.getDefault().post(new SubmitImagePostEvent(true, null));
|
||||
EventBus.getDefault().post(new SubmitImagePostEvent(true, null, post));
|
||||
Toast.makeText(SubmitPostService.this, R.string.image_is_processing, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
@@ -291,14 +280,14 @@ public class SubmitPostService extends Service {
|
||||
|
||||
@Override
|
||||
public void submitFailed(@Nullable String errorMessage) {
|
||||
handler.post(() -> EventBus.getDefault().post(new SubmitImagePostEvent(false, errorMessage)));
|
||||
handler.post(() -> EventBus.getDefault().post(new SubmitImagePostEvent(false, errorMessage, null)));
|
||||
|
||||
stopService();
|
||||
}
|
||||
});
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
handler.post(() -> EventBus.getDefault().post(new SubmitImagePostEvent(false, getString(R.string.error_processing_image))));
|
||||
handler.post(() -> EventBus.getDefault().post(new SubmitImagePostEvent(false, getString(R.string.error_processing_image), null)));
|
||||
stopService();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,26 +36,12 @@ public class AboutPreferenceFragment extends CustomFontPreferenceFragmentCompat
|
||||
if (openSourcePreference != null) {
|
||||
openSourcePreference.setOnPreferenceClickListener(preference -> {
|
||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||
intent.setData(Uri.parse("https://github.com/Docile-Alligator/Infinity-For-Reddit"));
|
||||
intent.setData(Uri.parse("https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy"));
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (ratePreference != null) {
|
||||
ratePreference.setOnPreferenceClickListener(preference -> {
|
||||
Intent playStoreIntent = new Intent(Intent.ACTION_VIEW);
|
||||
playStoreIntent.setData(Uri.parse("market://details?id=eu.toldi.infinityforlemmy"));
|
||||
if (playStoreIntent.resolveActivity(activity.getPackageManager()) != null) {
|
||||
activity.startActivity(playStoreIntent);
|
||||
} else {
|
||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||
intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy"));
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (emailPreference != null) {
|
||||
emailPreference.setOnPreferenceClickListener(preference -> {
|
||||
@@ -82,7 +68,7 @@ public class AboutPreferenceFragment extends CustomFontPreferenceFragmentCompat
|
||||
if (subredditPreference != null) {
|
||||
subredditPreference.setOnPreferenceClickListener(preference -> {
|
||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||
intent.setData(Uri.parse("https://www.reddit.com/r/Infinity_For_Reddit"));
|
||||
intent.setData(Uri.parse("https://lemdro.id/c/infinityforlemmy"));
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@ import eu.toldi.infinityforlemmy.activities.SearchActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.SettingsActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.SubredditSelectionActivity;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
|
||||
@@ -683,8 +684,8 @@ public class CustomizeMainPageTabsFragment extends Fragment {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
switch (requestCode) {
|
||||
case 0:
|
||||
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) {
|
||||
tab1CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA)) {
|
||||
tab1CurrentName = ((SubscribedSubredditData) data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA)).getName();
|
||||
tab1NameSummaryTextView.setText(tab1CurrentName);
|
||||
mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
|
||||
} else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) {
|
||||
@@ -701,8 +702,8 @@ public class CustomizeMainPageTabsFragment extends Fragment {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) {
|
||||
tab2CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA)) {
|
||||
tab2CurrentName = ((SubscribedSubredditData) data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA)).getName();
|
||||
tab2NameSummaryTextView.setText(tab2CurrentName);
|
||||
mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
|
||||
} else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) {
|
||||
@@ -719,8 +720,8 @@ public class CustomizeMainPageTabsFragment extends Fragment {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) {
|
||||
tab3CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA)) {
|
||||
tab3CurrentName = ((SubscribedSubredditData) data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA)).getName();
|
||||
tab3NameSummaryTextView.setText(tab3CurrentName);
|
||||
mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
|
||||
} else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.biometric.BiometricManager;
|
||||
@@ -17,7 +16,6 @@ import javax.inject.Named;
|
||||
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.PostFilterPreferenceActivity;
|
||||
import eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceFragmentCompat;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
@@ -52,26 +50,5 @@ public class MainPreferenceFragment extends CustomFontPreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (privacyPolicyPreference != null) {
|
||||
privacyPolicyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||
intent.setData(Uri.parse("https://docile-alligator.github.io/"));
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (redditUserAgreementPreference != null) {
|
||||
redditUserAgreementPreference.setOnPreferenceClickListener(preference -> {
|
||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||
intent.setData(Uri.parse("https://www.redditinc.com/policies/user-agreement-september-12-2021"));
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class MiscellaneousPreferenceFragment extends CustomFontPreferenceFragmen
|
||||
ListPreference mainPageBackButtonActionListPreference = findPreference(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION);
|
||||
SwitchPreference savePostFeedScrolledPositionSwitch = findPreference(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION);
|
||||
ListPreference languageListPreference = findPreference(SharedPreferencesUtils.LANGUAGE);
|
||||
EditTextPreference anonymousAccountInstance = findPreference(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE);
|
||||
EditTextPreference postFeedMaxResolution = findPreference(SharedPreferencesUtils.POST_FEED_MAX_RESOLUTION);
|
||||
|
||||
if (mainPageBackButtonActionListPreference != null) {
|
||||
@@ -66,6 +67,25 @@ public class MiscellaneousPreferenceFragment extends CustomFontPreferenceFragmen
|
||||
});
|
||||
}
|
||||
|
||||
if (anonymousAccountInstance != null) {
|
||||
anonymousAccountInstance.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String url = (String) newValue;
|
||||
if (url == null || url.equals("")) {
|
||||
Toast.makeText(activity, R.string.url_cannot_be_null_or_empty, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||
Toast.makeText(activity, "The url has to start with https:// or http://", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (postFeedMaxResolution != null) {
|
||||
postFeedMaxResolution.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
try {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CommunitySubscription {
|
||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
String subredditName,
|
||||
SubredditSubscriptionListener subredditSubscriptionListener) {
|
||||
FetchSubredditData.fetchSubredditData(retrofit, subredditName, "", new FetchSubredditData.FetchSubredditDataListener() {
|
||||
FetchSubredditData.fetchSubredditData(retrofit, subredditName, null, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
insertSubscription(executor, handler, redditDataRoomDatabase,
|
||||
@@ -111,7 +111,7 @@ public class CommunitySubscription {
|
||||
SubredditData subredditData, String accountName,
|
||||
SubredditSubscriptionListener subredditSubscriptionListener) {
|
||||
executor.execute(() -> {
|
||||
SubscribedSubredditData subscribedSubredditData = new SubscribedSubredditData(subredditData.getId(), LemmyUtils.actorID2FullName(subredditData.getActorId()), subredditData.getName(),
|
||||
SubscribedSubredditData subscribedSubredditData = new SubscribedSubredditData(subredditData.getId(), subredditData.getName(), LemmyUtils.actorID2FullName(subredditData.getActorId()),
|
||||
subredditData.getIconUrl(), accountName);
|
||||
if (accountName.equals("-")) {
|
||||
if (!redditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) {
|
||||
|
||||
@@ -41,10 +41,18 @@ public class ParseSubredditData {
|
||||
}
|
||||
int id = community.getInt("id");
|
||||
String name = community.getString("name");
|
||||
String description = community.getString("description");
|
||||
String description = "";
|
||||
if (!community.isNull("description")) {
|
||||
description = community.getString("description");
|
||||
}
|
||||
|
||||
boolean removed = community.getBoolean("removed");
|
||||
String published = community.getString("published");
|
||||
String updated = community.getString("updated");
|
||||
String updated = "";
|
||||
if (!community.isNull("updated")) {
|
||||
updated = community.getString("updated");
|
||||
}
|
||||
|
||||
boolean deleted = community.getBoolean("deleted");
|
||||
|
||||
String actorId = community.getString("actor_id");
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package eu.toldi.infinityforlemmy.subscribedsubreddit;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
|
||||
@Entity(tableName = "subscribed_subreddits", primaryKeys = {"id", "username"},
|
||||
foreignKeys = @ForeignKey(entity = Account.class, parentColumns = "username",
|
||||
childColumns = "username", onDelete = ForeignKey.CASCADE))
|
||||
public class SubscribedSubredditData {
|
||||
childColumns = "username", onDelete = ForeignKey.CASCADE))
|
||||
public class SubscribedSubredditData implements Parcelable {
|
||||
@NonNull
|
||||
@ColumnInfo(name = "id")
|
||||
private int id;
|
||||
@@ -25,12 +30,20 @@ public class SubscribedSubredditData {
|
||||
@ColumnInfo(name = "username")
|
||||
private String username;
|
||||
|
||||
public SubscribedSubredditData(@NonNull int id, String name,@NonNull String qualified_name, String iconUrl, @NonNull String username) {
|
||||
public SubscribedSubredditData(@NonNull int id, String name, @NonNull String qualified_name, String iconUrl, @NonNull String username) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.iconUrl = iconUrl;
|
||||
this.username = username;
|
||||
this.qualified_name =qualified_name;
|
||||
this.qualified_name = qualified_name;
|
||||
}
|
||||
|
||||
public SubscribedSubredditData(@NonNull SubredditData communityData) {
|
||||
this.id = communityData.getId();
|
||||
this.name = communityData.getName();
|
||||
this.iconUrl = communityData.getIconUrl();
|
||||
this.username = "-";
|
||||
this.qualified_name = LemmyUtils.actorID2FullName(communityData.getActorId());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -63,4 +76,38 @@ public class SubscribedSubredditData {
|
||||
public void setUsername(@NonNull String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel parcel, int i) {
|
||||
parcel.writeInt(id);
|
||||
parcel.writeString(name);
|
||||
parcel.writeString(iconUrl);
|
||||
parcel.writeString(username);
|
||||
parcel.writeString(qualified_name);
|
||||
}
|
||||
|
||||
public SubscribedSubredditData(Parcel in) {
|
||||
id = in.readInt();
|
||||
name = in.readString();
|
||||
iconUrl = in.readString();
|
||||
username = in.readString();
|
||||
qualified_name = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<SubscribedSubredditData> CREATOR = new Creator<>() {
|
||||
@Override
|
||||
public SubscribedSubredditData createFromParcel(Parcel in) {
|
||||
return new SubscribedSubredditData(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubscribedSubredditData[] newArray(int size) {
|
||||
return new SubscribedSubredditData[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import okhttp3.RequestBody;
|
||||
public class APIUtils {
|
||||
public static final String OAUTH_URL = "https://www.reddit.com/api/v1/authorize.compact";
|
||||
public static final String OAUTH_API_BASE_URI = "https://oauth.reddit.com";
|
||||
public static final String API_BASE_URI = "https://lemmy.toldi.eu";
|
||||
public static final String API_BASE_URI = "https://lemmy.world";
|
||||
public static final String API_UPLOAD_MEDIA_URI = "https://reddit-uploaded-media.s3-accelerate.amazonaws.com";
|
||||
public static final String API_UPLOAD_VIDEO_URI = "https://reddit-uploaded-video.s3-accelerate.amazonaws.com";
|
||||
public static final String GFYCAT_API_BASE_URI = "https://api.gfycat.com/v1/gfycats/";
|
||||
|
||||
@@ -167,6 +167,8 @@ public class SharedPreferencesUtils {
|
||||
public static final int SWIPE_ACITON_DOWNVOTE = 1;
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LANGUAGE_DEFAULT_VALUE = "auto";
|
||||
|
||||
public static final String ANONYMOUS_ACCOUNT_INSTANCE = "anonymous_account_instance";
|
||||
public static final String ENABLE_SEARCH_HISTORY = "enable_search_history";
|
||||
public static final String POST_FILTER = "post_filter";
|
||||
public static final String ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS = "only_disable_preview_in_video_and_gif_posts";
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<EditText
|
||||
android:id="@+id/post_title_text_view_edit_post_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:hint="@string/instance_url"
|
||||
android:inputType="textUri"
|
||||
android:maxLines="1" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@@ -90,6 +91,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/user_password"
|
||||
android:maxLength="60"
|
||||
android:maxLines="1"
|
||||
android:password="true" />
|
||||
|
||||
|
||||
@@ -109,35 +109,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_post_gallery_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/flair"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_post_gallery_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_gallery_activity"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -23,240 +23,237 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_image_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/flair"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_image_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_image_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/title_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
android:textSize="?attr/title_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/select_image_constraint_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="32dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/capture_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_add_a_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/select_from_library_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_select_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_image_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_image_activity"
|
||||
android:id="@+id/select_again_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="16dp"
|
||||
android:text="@string/select_again"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textSize="?attr/font_default"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart"
|
||||
android:visibility="gone" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_text_content_edit_text_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_text_content_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textSize="?attr/content_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00000000"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/title_font_18"
|
||||
android:fontFamily="?attr/title_font_family" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/select_image_constraint_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="32dp">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/capture_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_add_a_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/select_from_library_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_select_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_again_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:text="@string/select_again"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/markdown_bottom_bar_recycler_view_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:scrollbars="horizontal" />
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -23,219 +23,216 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
android:orientation="vertical">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
</LinearLayout>
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_link_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_link_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</LinearLayout>
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/flair"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/title_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/title_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/suggest_title_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/suggest_title"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/post_link_edit_text_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:hint="@string/post_link_hint"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/title_font_18"
|
||||
android:fontFamily="?attr/title_font_family" />
|
||||
android:textSize="?attr/content_font_18" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/suggest_title_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/suggest_title"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
<EditText
|
||||
android:id="@+id/post_text_content_edit_text_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_text_content_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textSize="?attr/content_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_link_edit_text_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_link_hint"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/content_font_18"
|
||||
android:fontFamily="?attr/content_font_family" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/markdown_bottom_bar_recycler_view_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:scrollbars="horizontal" />
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -109,35 +109,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_post_poll_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/flair"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_post_poll_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_poll_activity"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -115,33 +115,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_post_text_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/flair"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_post_text_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_text_activity"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -109,35 +109,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_post_video_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/flair"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_post_video_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/spoiler"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_video_activity"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -48,25 +48,6 @@
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_type_linear_layout_post_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/bottom_sheet_post_video"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:drawableStart="@drawable/ic_outline_video_24dp"
|
||||
android:drawablePadding="48dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/image_type_linear_layout_post_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
@@ -86,44 +67,6 @@
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gallery_type_linear_layout_post_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/bottom_sheet_post_gallery"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:drawableStart="@drawable/ic_gallery_24dp"
|
||||
android:drawablePadding="48dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/poll_type_linear_layout_post_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/bottom_sheet_post_poll"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:drawableStart="@drawable/ic_poll_24dp"
|
||||
android:drawablePadding="48dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -116,6 +116,7 @@
|
||||
<string name="no_users">No users found</string>
|
||||
<string name="no_multi_reddits">No Multireddits found</string>
|
||||
<string name="no_storage_permission">No storage permission to save this file</string>
|
||||
<string name="anonymous_homepage_not_implemented">Anonymous homepage is not implemented yet</string>
|
||||
|
||||
<string name="load_comments_failed">Error loading comments.\nTap to retry.</string>
|
||||
<string name="retry">Retry</string>
|
||||
@@ -149,6 +150,8 @@
|
||||
<string name="online_subscribers_number_detail">Online: %1$,d</string>
|
||||
<string name="cannot_fetch_community_info">Cannot fetch community info</string>
|
||||
<string name="cannot_fetch_user_info">Cannot fetch user info</string>
|
||||
<string name="invalid_response">Invalid response from the server</string>
|
||||
<string name="invalid_username_or_password">Invalid username or password</string>
|
||||
<string name="cannot_fetch_sidebar">Cannot fetch sidebar</string>
|
||||
<string name="cannot_fetch_multireddit">Cannot fetch multireddit info</string>
|
||||
|
||||
@@ -465,7 +468,7 @@
|
||||
<string name="settings_credits_best_rocket_icon_summary">Icon made by Freepik from www.flaticon.com</string>
|
||||
<string name="settings_credits_material_icons_title">Material Icons</string>
|
||||
<string name="settings_open_source_title">Open Source</string>
|
||||
<string name="settings_open_source_summary">Star it on Github if you like this app</string>
|
||||
<string name="settings_open_source_summary">Star it on Codeberg if you like this app</string>
|
||||
<string name="settings_rate_title">Rate on Google Play</string>
|
||||
<string name="settings_rate_summary">Give me a 5-star rating and I will be really happy</string>
|
||||
<string name="settings_email_title">Mastodon</string>
|
||||
@@ -473,7 +476,7 @@
|
||||
<string name="settings_reddit_account_title">Lemmy Account</string>
|
||||
<string name="settings_reddit_account_summary">\@bazsalanszky@lemmy.toldi.eu</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">r/Infinity_For_Reddit</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">Share</string>
|
||||
<string name="settings_share_summary">Share this app to other people if you enjoy it</string>
|
||||
<string name="settings_privacy_policy_title">Privacy Policy</string>
|
||||
@@ -1336,4 +1339,8 @@
|
||||
<string name="sort_time_3months">3 Months</string>
|
||||
<string name="sort_time_6months">6 Months</string>
|
||||
<string name="sort_time_9months">9 Months</string>
|
||||
<string name="anonymous_account_instance">Anonymous Account Instance</string>
|
||||
<string name="url_cannot_be_null_or_empty">URL cannot be null or empty</string>
|
||||
<string name="could_not_resolve_link">Could not resolve URL :(</string>
|
||||
<string name="mark_post_as_read_failed">Failed to mark post as read</string>
|
||||
</resources>
|
||||
|
||||
@@ -21,11 +21,6 @@
|
||||
app:title="@string/settings_open_source_title"
|
||||
app:summary="@string/settings_open_source_summary" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference
|
||||
android:key="rate"
|
||||
app:title="@string/settings_rate_title"
|
||||
app:summary="@string/settings_rate_summary" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference
|
||||
android:key="email"
|
||||
app:title="@string/settings_email_title"
|
||||
|
||||
@@ -87,14 +87,4 @@
|
||||
app:title="@string/settings_about_master_title"
|
||||
app:fragment="eu.toldi.infinityforlemmy.settings.AboutPreferenceFragment" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference
|
||||
android:key="privacy_policy"
|
||||
app:icon="@drawable/ic_outline_privacy_policy_24dp"
|
||||
app:title="@string/settings_privacy_policy_title" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference
|
||||
android:key="reddit_user_agreement"
|
||||
app:icon="@drawable/ic_outline_user_agreement_24dp"
|
||||
app:title="@string/settings_reddit_user_agreement_title" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
@@ -40,8 +40,13 @@
|
||||
app:title="@string/settings_language_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceCategory
|
||||
app:title="@string/settings_miscellaneous_dangerous_group_title" />
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontEditTextPreference
|
||||
app:defaultValue="https://lemmy.world"
|
||||
app:key="anonymous_account_instance"
|
||||
app:title="@string/anonymous_account_instance"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceCategory app:title="@string/settings_miscellaneous_dangerous_group_title" />
|
||||
|
||||
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference
|
||||
app:icon="@drawable/ic_info_preference_24dp"
|
||||
@@ -54,4 +59,5 @@
|
||||
app:title="@string/settings_post_feed_max_resolution_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user