9 Commits

Author SHA1 Message Date
Balazs Toldi
442310cad3 Fix URLs for sharing communities/users 2023-07-28 21:30:32 +02:00
Balazs Toldi
b8da5c6acb Change version name 2023-07-28 21:27:09 +02:00
Balazs Toldi
2ed15f3d5c Minor code fixes 2023-07-28 21:26:56 +02:00
Balazs Toldi
d926fabe09 Update supported links
Updated the "supported links" list in the AndroidManifest.xml to match lemmy instances instead of reddit links.

Reference: https://github.com/dessalines/jerboa/blob/main/app/src/main/AndroidManifest.xml
2023-07-28 21:26:39 +02:00
Balazs Toldi
e815a1444d Anonymous browsing
This commit adds the Anonymous browsing functionality. Unfortunately, the anonymous home page is disabled as of now.
2023-07-28 17:05:53 +02:00
Balazs Toldi
df81866821 Improved login error messages 2023-07-28 07:59:41 +02:00
Balazs Toldi
497f6c79d2 Use the proper retrofit object to save comments
This commit fixes the issue with saving comments. It used the old, oauth Retrofit object, instead of our retrofit holder objects. Closes issue #14
2023-07-28 07:45:12 +02:00
Balazs Toldi
6eb585800f Fix CommentsListingFragment
This allows us to list comments by users
2023-07-28 07:31:48 +02:00
Balazs Toldi
df842d33e1 Bump version 2023-07-28 07:08:01 +02:00
29 changed files with 358 additions and 198 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "eu.toldi.infinityforlemmy"
minSdk 21
targetSdk 33
versionCode 122
versionName "0.0.2"
versionCode 123
versionName "0.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {

View File

@@ -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" />

View File

@@ -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) {

View File

@@ -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;
@@ -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());
}

View File

@@ -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;
@@ -325,9 +327,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 +351,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 +872,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 +1401,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);
@@ -1648,7 +1730,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 +1794,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);

View File

@@ -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();

View File

@@ -582,7 +582,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 +600,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 +1174,7 @@ 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);
shareIntent.putExtra(Intent.EXTRA_TEXT, mRetrofit.getBaseURL() + qualifiedName);
if (shareIntent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
} else {

View File

@@ -1154,7 +1154,7 @@ 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);
shareIntent.putExtra(Intent.EXTRA_TEXT, mRetrofit.getBaseURL() + qualifiedName);
if (shareIntent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
} else {

View File

@@ -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;
@@ -537,7 +537,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 +607,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 +650,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 +671,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);

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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;
@@ -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() {

View File

@@ -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,

View File

@@ -22,7 +22,8 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
private static final int VIEW_TYPE_MENU_ITEM = 2;
private static final int REDDIT_SECTION_ITEMS = 1;
private static final int REDDIT_SECTION_ITEMS = 2;
private final boolean isLoggedIn;
private BaseActivity baseActivity;
private int primaryTextColor;
@@ -33,13 +34,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 +90,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 +104,7 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override
public int getItemCount() {
return collapseRedditSection ? 1 : REDDIT_SECTION_ITEMS + 1;
return isLoggedIn ? (REDDIT_SECTION_ITEMS + 1) - 1 : collapseRedditSection ? 1 : REDDIT_SECTION_ITEMS + 1;
}
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {

View File

@@ -46,6 +46,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_,

View File

@@ -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();
}

View File

@@ -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));

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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:

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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()) {

View File

@@ -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");

View File

@@ -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/";

View File

@@ -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";

View File

@@ -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>
@@ -1336,4 +1339,6 @@
<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>
</resources>

View File

@@ -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>