aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-28 17:31:32 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-28 17:31:32 +0000
commitddb1fb6b421776a7ac88c7cddb8f66910b67fb6b (patch)
tree10427486572dbb5a378f247eca4ad18daad97397 /app
parent0af03d952b866c758b41fa6d0b62fdcfaeabd67b (diff)
downloadinfinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.tar
infinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.tar.gz
infinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.tar.bz2
infinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.tar.lz
infinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.tar.xz
infinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.tar.zst
infinity-for-reddit-ddb1fb6b421776a7ac88c7cddb8f66910b67fb6b.zip
Move accessToken and accountName to BaseActivity.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java35
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java122
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java36
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java45
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java48
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java68
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java79
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/InboxFragment.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java76
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java76
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java92
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java91
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java21
74 files changed, 780 insertions, 813 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
index b1106935..21288314 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
@@ -24,7 +24,6 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
@@ -53,8 +52,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private String mAccessToken;
- private String mAccountName;
private String mUserWhere;
private Fragment mFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@@ -109,9 +106,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction()
@@ -137,6 +131,11 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -153,10 +152,8 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
mFragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
- bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
+ bundle.putString(PostFragment.EXTRA_USER_NAME, accountName);
bundle.putString(PostFragment.EXTRA_USER_WHERE, mUserWhere);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true);
mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction()
@@ -226,7 +223,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
@Override
public void postLayoutSelected(int postLayout) {
if (mFragment != null) {
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + accountName, postLayout).apply();
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
index 554c1ad1..c38641c1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
@@ -32,7 +32,6 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
@@ -71,8 +70,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
Executor mExecutor;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
- private String mAccessToken;
- private String mAccountName;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
private ActivityAccountSavedThingBinding binding;
@@ -119,9 +116,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
initializeViewPager();
}
@@ -140,6 +134,11 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -246,14 +245,14 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
@Override
public void postLayoutSelected(int postLayout) {
if (sectionsPagerAdapter != null) {
- mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
+ mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + accountName, postLayout).apply();
sectionsPagerAdapter.changePostLayout(postLayout);
}
}
@Override
public void markPostAsRead(Post post) {
- InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
+ InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, accountName, post.getId());
}
private class SectionsPagerAdapter extends FragmentStateAdapter {
@@ -269,19 +268,15 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
- bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
+ bundle.putString(PostFragment.EXTRA_USER_NAME, accountName);
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true);
fragment.setArguments(bundle);
return fragment;
}
CommentsListingFragment fragment = new CommentsListingFragment();
Bundle bundle = new Bundle();
- bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountName);
- bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ bundle.putString(CommentsListingFragment.EXTRA_USERNAME, accountName);
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);
fragment.setArguments(bundle);
return fragment;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index a9b49c95..fde2926e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -26,6 +26,7 @@ import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
@@ -47,6 +48,7 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.CustomFontReceiver;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
@@ -75,6 +77,10 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
public SliderPanel mSliderPanel;
@Nullable
public ViewPager2 mViewPager2;
+ @Nullable
+ public String accessToken;
+ @NonNull
+ public String accountName = Account.ANONYMOUS_ACCOUNT;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -223,10 +229,15 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
}
+
+ accessToken = getCurrentAccountSharedPreferences().getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
+ accountName = getCurrentAccountSharedPreferences().getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
}
public abstract SharedPreferences getDefaultSharedPreferences();
+ public abstract SharedPreferences getCurrentAccountSharedPreferences();
+
public abstract CustomThemeWrapper getCustomThemeWrapper();
protected abstract void applyCustomTheme();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index 9a00a343..55195475 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -118,7 +118,6 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
Executor mExecutor;
private RequestManager mGlide;
private Account selectedAccount;
- private String mAccessToken;
private String parentFullname;
private int parentDepth;
private int parentPosition;
@@ -161,8 +160,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
mGlide = Glide.with(this);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- if (mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT).equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
finish();
return;
}
@@ -348,6 +346,11 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -493,10 +496,10 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
return;
}
Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit,
- mAccessToken, binding.commentCommentEditText, binding.commentCoordinatorLayout, data.getData(), uploadedImages);
+ accessToken, binding.commentCommentEditText, binding.commentCoordinatorLayout, data.getData(), uploadedImages);
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit,
- mAccessToken, binding.commentCommentEditText, binding.commentCoordinatorLayout, capturedImageUri, uploadedImages);
+ accessToken, binding.commentCommentEditText, binding.commentCoordinatorLayout, capturedImageUri, uploadedImages);
} else if (requestCode == MARKDOWN_PREVIEW_REQUEST_CODE) {
sendComment(mMenu == null ? null : mMenu.findItem(R.id.action_send_comment_activity));
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java
index 27c3d462..8c58c323 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java
@@ -38,6 +38,9 @@ public class CommentFilterPreferenceActivity extends BaseActivity {
@Named("default")
SharedPreferences sharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
RedditDataRoomDatabase redditDataRoomDatabase;
@Inject
CustomThemeWrapper customThemeWrapper;
@@ -141,6 +144,11 @@ public class CommentFilterPreferenceActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return customThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
index 38c0ac59..e60cccd7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
@@ -42,6 +42,9 @@ public class CommentFilterUsageListingActivity extends BaseActivity {
@Named("default")
SharedPreferences sharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
RedditDataRoomDatabase redditDataRoomDatabase;
@Inject
CustomThemeWrapper customThemeWrapper;
@@ -161,6 +164,11 @@ public class CommentFilterUsageListingActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return customThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
index d91f1d07..6e398871 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
@@ -54,8 +54,6 @@ public class CreateMultiRedditActivity extends BaseActivity {
@Inject
Executor mExecutor;
private ActivityCreateMultiRedditBinding binding;
- private String mAccessToken;
- private String mAccountName;
private ArrayList<String> mSubreddits;
@Override
@@ -81,10 +79,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
setSupportActionBar(binding.toolbarCreateMultiRedditActivity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
binding.visibilityWrapperLinearLayoutCreateMultiRedditActivity.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
binding.multiRedditNameEditTextCreateMultiRedditActivity.setImeOptions(binding.multiRedditNameEditTextCreateMultiRedditActivity.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
@@ -127,11 +122,11 @@ public class CreateMultiRedditActivity extends BaseActivity {
return true;
}
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
String jsonModel = new MultiRedditJSONModel(binding.multiRedditNameEditTextCreateMultiRedditActivity.getText().toString(), binding.descriptionEditTextCreateMultiRedditActivity.getText().toString(),
binding.visibilitySwitchCreateMultiRedditActivity.isChecked(), mSubreddits).createJSONModel();
- CreateMultiReddit.createMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken,
- "/user/" + mAccountName + "/m/" + binding.multiRedditNameEditTextCreateMultiRedditActivity.getText().toString(),
+ CreateMultiReddit.createMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
+ "/user/" + accountName + "/m/" + binding.multiRedditNameEditTextCreateMultiRedditActivity.getText().toString(),
jsonModel, new CreateMultiReddit.CreateMultiRedditListener() {
@Override
public void success() {
@@ -190,6 +185,11 @@ public class CreateMultiRedditActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java
index 4a87a47b..3fa37778 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java
@@ -73,6 +73,9 @@ public class CustomThemeListingActivity extends BaseActivity implements
@Named("default")
SharedPreferences sharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
RedditDataRoomDatabase redditDataRoomDatabase;
@Inject
CustomThemeWrapper customThemeWrapper;
@@ -147,6 +150,11 @@ public class CustomThemeListingActivity extends BaseActivity implements
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return customThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java
index 77534e7c..95ebd9a2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java
@@ -53,6 +53,9 @@ public class CustomizeCommentFilterActivity extends BaseActivity {
SharedPreferences mSharedPreferences;
@Inject
@Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
+ @Named("current_account")
SharedPreferences currentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@@ -157,6 +160,11 @@ public class CustomizeCommentFilterActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
index 1e173b5f..fdeeb22f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
@@ -13,23 +13,13 @@ import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
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;
-import androidx.appcompat.widget.Toolbar;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import com.google.android.material.appbar.AppBarLayout;
-import com.google.android.material.appbar.CollapsingToolbarLayout;
-import com.google.android.material.checkbox.MaterialCheckBox;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import com.google.android.material.materialswitch.MaterialSwitch;
-import com.google.android.material.textfield.TextInputEditText;
-import com.google.android.material.textfield.TextInputLayout;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -40,8 +30,6 @@ import java.util.regex.PatternSyntaxException;
import javax.inject.Inject;
import javax.inject.Named;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@@ -50,7 +38,6 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.databinding.ActivityCustomizePostFilterBinding;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.postfilter.SavePostFilter;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class CustomizePostFilterActivity extends BaseActivity {
@@ -78,6 +65,9 @@ public class CustomizePostFilterActivity extends BaseActivity {
SharedPreferences mSharedPreferences;
@Inject
@Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
+ @Named("current_account")
SharedPreferences currentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@@ -143,7 +133,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
});
binding.addSubredditsImageViewCustomizePostFilterActivity.setOnClickListener(view -> {
- if (currentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT).equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Intent intent = new Intent(this, SearchActivity.class);
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, true);
intent.putExtra(SearchActivity.EXTRA_IS_MULTI_SELECTION, true);
@@ -257,6 +247,11 @@ public class CustomizePostFilterActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
index 22f66c27..58e024bd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
@@ -67,6 +67,9 @@ public class CustomizeThemeActivity extends BaseActivity {
@Named("default")
SharedPreferences sharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
@Named("light_theme")
SharedPreferences lightThemeSharedPreferences;
@Inject
@@ -250,6 +253,11 @@ public class CustomizeThemeActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return customThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
index caa8fcac..3369da0a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
@@ -172,6 +172,11 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java
index 14c881c5..679f5fb7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java
@@ -94,8 +94,6 @@ public class EditMultiRedditActivity extends BaseActivity {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private MultiReddit multiReddit;
private String multipath;
@@ -123,10 +121,7 @@ public class EditMultiRedditActivity extends BaseActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
- if (mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT).equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
visibilityLinearLayout.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
@@ -146,7 +141,7 @@ public class EditMultiRedditActivity extends BaseActivity {
private void bindView() {
if (multiReddit == null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
FetchMultiRedditInfo.anonymousFetchMultiRedditInfo(mExecutor, new Handler(),
mRedditDataRoomDatabase, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
@Override
@@ -164,7 +159,7 @@ public class EditMultiRedditActivity extends BaseActivity {
}
});
} else {
- FetchMultiRedditInfo.fetchMultiRedditInfo(mRetrofit, mAccessToken, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
+ FetchMultiRedditInfo.fetchMultiRedditInfo(mRetrofit, accessToken, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
@Override
public void success(MultiReddit multiReddit) {
EditMultiRedditActivity.this.multiReddit = multiReddit;
@@ -217,7 +212,7 @@ public class EditMultiRedditActivity extends BaseActivity {
return true;
}
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
String name = nameEditText.getText().toString();
multiReddit.setDisplayName(name);
multiReddit.setName(name);
@@ -237,7 +232,7 @@ public class EditMultiRedditActivity extends BaseActivity {
} else {
String jsonModel = new MultiRedditJSONModel(nameEditText.getText().toString(), descriptionEditText.getText().toString(),
visibilitySwitch.isChecked(), multiReddit.getSubreddits()).createJSONModel();
- EditMultiReddit.editMultiReddit(mRetrofit, mAccessToken, multiReddit.getPath(),
+ EditMultiReddit.editMultiReddit(mRetrofit, accessToken, multiReddit.getPath(),
jsonModel, new EditMultiReddit.EditMultiRedditListener() {
@Override
public void success() {
@@ -279,6 +274,11 @@ public class EditMultiRedditActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
index 13a6434d..9ef56da0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
@@ -181,6 +181,11 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
index aff03608..230c0b90 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
@@ -98,9 +98,6 @@ public class EditProfileActivity extends BaseActivity {
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private String mAccountName;
- private String mAccessToken;
-
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
@@ -126,9 +123,6 @@ public class EditProfileActivity extends BaseActivity {
Slidr.attach(this);
}
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
changeBanner.setOnClickListener(view -> {
startPickImage(PICK_IMAGE_BANNER_REQUEST_CODE);
});
@@ -138,7 +132,7 @@ public class EditProfileActivity extends BaseActivity {
final RequestManager glide = Glide.with(this);
final UserViewModel.Factory userViewModelFactory =
- new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName);
+ new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName);
final UserViewModel userViewModel =
new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class);
@@ -160,7 +154,7 @@ public class EditProfileActivity extends BaseActivity {
changeBanner.setLayoutParams(cBannerLp);
glide.load(userBanner).into(bannerImageView);
changeBanner.setOnLongClickListener(view -> {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
return false;
}
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
@@ -168,8 +162,8 @@ public class EditProfileActivity extends BaseActivity {
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes, (dialogInterface, i)
-> EditProfileUtils.deleteBanner(mOauthRetrofit,
- mAccessToken,
- mAccountName,
+ accessToken,
+ accountName,
new EditProfileUtils.EditProfileUtilsListener() {
@Override
public void success() {
@@ -203,7 +197,7 @@ public class EditProfileActivity extends BaseActivity {
} else {
changeAvatar.setLongClickable(true);
changeAvatar.setOnLongClickListener(view -> {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
return false;
}
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
@@ -211,8 +205,8 @@ public class EditProfileActivity extends BaseActivity {
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes, (dialogInterface, i)
-> EditProfileUtils.deleteAvatar(mOauthRetrofit,
- mAccessToken,
- mAccountName,
+ accessToken,
+ accountName,
new EditProfileUtils.EditProfileUtilsListener() {
@Override
public void success() {
@@ -242,13 +236,13 @@ public class EditProfileActivity extends BaseActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if (resultCode != RESULT_OK || data == null || mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (resultCode != RESULT_OK || data == null || accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
return;
}
Intent intent = new Intent(this, EditProfileService.class);
intent.setData(data.getData());
- intent.putExtra(EditProfileService.EXTRA_ACCOUNT_NAME, mAccountName);
- intent.putExtra(EditProfileService.EXTRA_ACCESS_TOKEN, mAccessToken);
+ intent.putExtra(EditProfileService.EXTRA_ACCOUNT_NAME, accountName);
+ intent.putExtra(EditProfileService.EXTRA_ACCESS_TOKEN, accessToken);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
switch (requestCode) {
case PICK_IMAGE_BANNER_REQUEST_CODE:
@@ -289,8 +283,8 @@ public class EditProfileActivity extends BaseActivity {
if (aboutYou == null || displayName == null) return false; //
Intent intent = new Intent(this, EditProfileService.class);
- intent.putExtra(EditProfileService.EXTRA_ACCOUNT_NAME, mAccountName);
- intent.putExtra(EditProfileService.EXTRA_ACCESS_TOKEN, mAccessToken);
+ intent.putExtra(EditProfileService.EXTRA_ACCOUNT_NAME, accountName);
+ intent.putExtra(EditProfileService.EXTRA_ACCESS_TOKEN, accessToken);
intent.putExtra(EditProfileService.EXTRA_DISPLAY_NAME, displayName); //
intent.putExtra(EditProfileService.EXTRA_ABOUT_YOU, aboutYou); //
intent.putExtra(EditProfileService.EXTRA_POST_TYPE, EditProfileService.EXTRA_POST_TYPE_SAVE_EDIT_PROFILE);
@@ -338,6 +332,11 @@ public class EditProfileActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java
index 1587d83f..1e27c968 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java
@@ -34,6 +34,9 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
@@ -95,6 +98,11 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index 3df23f15..c55962c7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -103,8 +103,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
@Inject
Executor mExecutor;
public SubredditViewModel mSubredditViewModel;
- private String mAccessToken;
- private String mAccountName;
private String name;
private String userWhere;
private int postType;
@@ -158,8 +156,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
name = getIntent().getStringExtra(EXTRA_NAME);
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
@@ -226,7 +222,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
postFilter.containFlairs = flair;
}
}
- postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
if (postType == PostPagingSource.TYPE_USER) {
userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE);
@@ -259,6 +255,11 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -318,8 +319,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, postType);
bundle.putParcelable(PostFragment.EXTRA_FILTER, postFilter);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
if (postType == PostPagingSource.TYPE_USER) {
bundle.putString(PostFragment.EXTRA_USER_NAME, name);
bundle.putString(PostFragment.EXTRA_USER_WHERE, userWhere);
@@ -343,7 +342,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
startActivityForResult(intent, CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE);
});
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
fab.setOnLongClickListener(view -> {
FilteredThingFABMoreOptionsBottomSheetFragment filteredThingFABMoreOptionsBottomSheetFragment
= new FilteredThingFABMoreOptionsBottomSheetFragment();
@@ -475,7 +474,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, accountName, post.getId());
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
index 270771cb..8ec7258d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
@@ -73,6 +73,9 @@ public class FullMarkdownActivity extends BaseActivity {
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
private EmotePlugin emotePlugin;
private ImageAndGifEntry imageAndGifEntry;
@@ -227,6 +230,11 @@ public class FullMarkdownActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java
index 221eb92b..0190b9f5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java
@@ -35,7 +35,6 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
@@ -74,8 +73,6 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
CustomThemeWrapper mCustomThemeWrapper;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
- private String mAccessToken;
- private String mAccountName;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -120,9 +117,6 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
initializeViewPager();
}
@@ -141,6 +135,11 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -263,16 +262,12 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte
HistoryPostFragment fragment = new HistoryPostFragment();
Bundle bundle = new Bundle();
bundle.putInt(HistoryPostFragment.EXTRA_HISTORY_TYPE, HistoryPostFragment.HISTORY_TYPE_READ_POSTS);
- bundle.putString(HistoryPostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(HistoryPostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
} else {
HistoryPostFragment fragment = new HistoryPostFragment();
Bundle bundle = new Bundle();
bundle.putInt(HistoryPostFragment.EXTRA_HISTORY_TYPE, HistoryPostFragment.HISTORY_TYPE_READ_POSTS);
- bundle.putString(HistoryPostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(HistoryPostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
index 4fa36e39..8461698f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
@@ -105,8 +105,6 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
Executor mExecutor;
private SectionsPagerAdapter sectionsPagerAdapter;
private FragmentManager fragmentManager;
- private String mAccessToken;
- private String mAccountName;
private String mNewAccountName;
@Override
@@ -157,9 +155,6 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
} else {
@@ -219,6 +214,11 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -233,7 +233,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) {
if (mNewAccountName != null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) || !accountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -241,7 +241,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
mNewAccountName = null;
if (newAccount != null) {
- mAccessToken = newAccount.getAccessToken();
+ accessToken = newAccount.getAccessToken();
}
bindView(savedInstanceState);
@@ -300,9 +300,9 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
}
return true;
} else if (item.getItemId() == R.id.action_read_all_messages_inbox_activity) {
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show();
- mOauthRetrofit.create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(mAccessToken))
+ mOauthRetrofit.create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(accessToken))
.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
@@ -454,14 +454,12 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
if (position == 0) {
InboxFragment fragment = new InboxFragment();
Bundle bundle = new Bundle();
- bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
fragment.setArguments(bundle);
return fragment;
} else {
InboxFragment fragment = new InboxFragment();
Bundle bundle = new Bundle();
- bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MESSAGES);
fragment.setArguments(bundle);
return fragment;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
index d4e44233..8d0129c7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java
@@ -35,6 +35,9 @@ public class LockScreenActivity extends BaseActivity {
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
@Override
@@ -89,6 +92,11 @@ public class LockScreenActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
index fb39c4e2..81b1002c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
@@ -308,6 +308,11 @@ public class LoginActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index a657d12c..73d7f0be 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -213,8 +213,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private NavigationDrawerRecyclerViewMergedAdapter adapter;
private NavigationWrapper navigationWrapper;
private Call<String> subredditAutocompleteCall;
- private String mAccessToken;
- private String mAccountName;
private boolean mFetchUserInfoSuccess = false;
private boolean mFetchSubscriptionsSuccess = false;
private boolean mDrawerOnAccountSwitch = false;
@@ -321,9 +319,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
@@ -351,6 +346,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -384,7 +384,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
WorkManager workManager = WorkManager.getInstance(this);
if (mNewAccountName != null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) || !accountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -392,8 +392,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mNewAccountName = null;
if (newAccount != null) {
- mAccessToken = newAccount.getAccessToken();
- mAccountName = newAccount.getAccountName();
+ accessToken = newAccount.getAccessToken();
+ accountName = newAccount.getAccountName();
}
setNotification(workManager, notificationInterval, timeUnit, enableNotification);
@@ -452,7 +452,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_PROFILE: {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, accountName);
startActivity(intent);
break;
}
@@ -581,9 +581,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
- int option2 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS);
+ int optionCount = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ int option2 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS);
if (optionCount == 2) {
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
@@ -610,8 +610,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
}
} else {
- int option3 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE : SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_PROFILE);
+ int option3 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE : SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_PROFILE);
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1),
getBottomAppBarOptionDrawableResource(option2), getBottomAppBarOptionDrawableResource(option3),
@@ -660,7 +660,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navigationWrapper.floatingActionButton.setLayoutParams(lp);
}
- fabOption = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB,
+ fabOption = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB,
SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) {
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_REFRESH:
@@ -685,7 +685,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_random_24dp);
break;
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -699,7 +699,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
break;
default:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -762,7 +762,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navigationWrapper.floatingActionButton.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment= new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT));
+ bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, accountName.equals(Account.ANONYMOUS_ACCOUNT));
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true;
@@ -771,13 +771,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
adapter = new NavigationDrawerRecyclerViewMergedAdapter(this, mSharedPreferences,
mNsfwAndSpoilerSharedPreferences, mNavigationDrawerSharedPreferences, mSecuritySharedPreferences,
- mCustomThemeWrapper, mAccountName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
+ mCustomThemeWrapper, accountName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
@Override
public void onMenuClick(int stringId) {
Intent intent = null;
if (stringId == R.string.profile) {
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, accountName);
} else if (stringId == R.string.subscriptions) {
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
} else if (stringId == R.string.multi_reddit) {
@@ -812,12 +812,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
} else if (stringId == R.string.enable_nsfw) {
if (sectionsPagerAdapter != null) {
- mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
+ mNsfwAndSpoilerSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
sectionsPagerAdapter.changeNSFW(true);
}
} else if (stringId == R.string.disable_nsfw) {
if (sectionsPagerAdapter != null) {
- mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
+ mNsfwAndSpoilerSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
sectionsPagerAdapter.changeNSFW(false);
}
} else if (stringId == R.string.settings) {
@@ -868,17 +868,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
navDrawerRecyclerView.setAdapter(adapter.getConcatAdapter());
- int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
- mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
- mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
- mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
- mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
+ int tabCount = mMainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
+ mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
+ mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
+ mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
+ mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
viewPager2.setAdapter(sectionsPagerAdapter);
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
- if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
+ if (mMainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
} else {
@@ -887,13 +887,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
switch (position) {
case 0:
- Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
+ Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
break;
case 1:
- Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
+ Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
break;
case 2:
- Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
+ Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
break;
}
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
@@ -941,7 +941,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadSubscriptions();
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
- mRedditDataRoomDatabase, mAccountName))
+ mRedditDataRoomDatabase, accountName))
.get(MultiRedditViewModel.class);
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
@@ -957,7 +957,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
subscribedSubredditViewModel = new ViewModelProvider(this,
- new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
+ new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName))
.get(SubscribedSubredditViewModel.class);
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
subscribedSubredditData -> {
@@ -985,9 +985,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadUserData();
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mMessageFullname != null) {
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
+ ReadMessage.readMessage(mOauthRetrofit, accessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
@Override
public void readSuccess() {
mMessageFullname = null;
@@ -1007,8 +1007,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return;
}
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !mFetchSubscriptionsSuccess) {
- FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT) && !mFetchSubscriptionsSuccess) {
+ FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, accessToken, accountName, null,
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(),
new FetchSubscribedThing.FetchSubscribedThingListener() {
@@ -1021,7 +1021,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mExecutor,
new Handler(),
mRedditDataRoomDatabase,
- mAccountName,
+ accountName,
subscribedSubredditData,
subscribedUserData,
subredditData,
@@ -1038,12 +1038,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private void loadUserData() {
if (!mFetchUserInfoSuccess) {
- FetchUserData.fetchUserData(mRedditDataRoomDatabase, mOauthRetrofit, mAccessToken,
- mAccountName, new FetchUserData.FetchUserDataListener() {
+ FetchUserData.fetchUserData(mRedditDataRoomDatabase, mOauthRetrofit, accessToken,
+ accountName, new FetchUserData.FetchUserDataListener() {
@Override
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
MainActivity.this.inboxCount = inboxCount;
- mAccountName = userData.getName();
+ accountName = userData.getName();
mFetchUserInfoSuccess = true;
if (adapter != null) {
adapter.setInboxCount(inboxCount);
@@ -1411,7 +1411,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1428,7 +1428,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (subredditAutocompleteCall != null) {
subredditAutocompleteCall.cancel();
}
- subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
+ subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(accessToken),
editable.toString(), nsfw);
subredditAutocompleteCall.enqueue(new Callback<>() {
@Override
@@ -1511,7 +1511,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private void randomThing() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -1525,7 +1525,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public void markPostAsRead(Post post) {
- InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
+ InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, accountName, post.getId());
}
public void doNotShowRedditAPIInfoAgain() {
@@ -1562,8 +1562,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public Fragment createFragment(int position) {
if (position == 0) {
- int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
- String name = mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
+ int postType = mMainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
+ String name = mMainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
return generatePostFragment(postType, name);
} else {
if (showFavoriteMultiReddits) {
@@ -1605,11 +1605,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int postType;
String name;
if (position == 1) {
- postType = mMainActivityTabsSharedPreferences.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
- name = mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
+ postType = mMainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
+ name = mMainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
} else {
- postType = mMainActivityTabsSharedPreferences.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
- name = mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
+ postType = mMainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
+ name = mMainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
}
return generatePostFragment(postType, name);
}
@@ -1639,9 +1639,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME) {
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
- bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE : PostPagingSource.TYPE_FRONT_PAGE);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE : PostPagingSource.TYPE_FRONT_PAGE);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL) {
@@ -1649,8 +1647,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_NAME, "all");
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT) {
@@ -1658,17 +1654,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_NAME, name);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT) {
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putString(PostFragment.EXTRA_NAME, name);
- bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT : PostPagingSource.TYPE_MULTI_REDDIT);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT : PostPagingSource.TYPE_MULTI_REDDIT);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER) {
@@ -1677,8 +1669,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
bundle.putString(PostFragment.EXTRA_USER_NAME, name);
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SUBMITTED);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
} else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED
@@ -1688,9 +1678,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
- bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ bundle.putString(PostFragment.EXTRA_USER_NAME, accountName);
bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true);
if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_UPVOTED) {
@@ -1710,8 +1698,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_NAME, "popular");
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
index d84a2646..ca77561b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
@@ -75,8 +75,6 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private boolean mInsertSuccess = false;
private Fragment mFragment;
@@ -117,9 +115,6 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState == null) {
bindView(true);
} else {
@@ -136,6 +131,11 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -151,15 +151,13 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
return;
}
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
loadMultiReddits();
}
if (initializeFragment) {
mFragment = new MultiRedditListingFragment();
Bundle bundle = new Bundle();
- bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putBoolean(MultiRedditListingFragment.EXTRA_IS_GETTING_MULTIREDDIT_INFO, true);
mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_multireddit_selection_activity, mFragment).commit();
@@ -168,11 +166,11 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
private void loadMultiReddits() {
if (!mInsertSuccess) {
- FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
+ FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, accessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
@Override
public void success(ArrayList<MultiReddit> multiReddits) {
InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase,
- multiReddits, mAccountName, () -> {
+ multiReddits, accountName, () -> {
mInsertSuccess = true;
((MultiRedditListingFragment) mFragment).stopRefreshProgressbar();
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
index 92108ae3..d070812a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
@@ -60,6 +60,9 @@ public class PostFilterPreferenceActivity extends BaseActivity {
@Named("default")
SharedPreferences sharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
RedditDataRoomDatabase redditDataRoomDatabase;
@Inject
CustomThemeWrapper customThemeWrapper;
@@ -213,6 +216,11 @@ public class PostFilterPreferenceActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return customThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
index 80f317dc..c8df22b2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
@@ -60,6 +60,9 @@ public class PostFilterUsageListingActivity extends BaseActivity {
@Named("default")
SharedPreferences sharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
RedditDataRoomDatabase redditDataRoomDatabase;
@Inject
CustomThemeWrapper customThemeWrapper;
@@ -199,6 +202,11 @@ public class PostFilterUsageListingActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return customThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
index 4ff943fc..e5497355 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
@@ -75,7 +75,6 @@ import ml.docilealligator.infinityforreddit.events.SubmitGalleryPostEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.UploadImageUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import pl.droidsonroids.gif.GifImageView;
@@ -163,8 +162,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
Executor mExecutor;
private Account selectedAccount;
private ArrayList<RedditGallerySubmissionRecyclerViewAdapter.RedditGalleryImageInfo> redditGalleryImageInfoList;
- private String mAccessToken;
- private String mAccountName;
private String iconUrl;
private String subredditName;
private boolean subredditSelected = false;
@@ -218,9 +215,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
resources = getResources();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
adapter = new RedditGallerySubmissionRecyclerViewAdapter(this, mCustomThemeWrapper, () -> {
if (!isUploading) {
SelectOrCaptureImageBottomSheetFragment fragment = new SelectOrCaptureImageBottomSheetFragment();
@@ -356,7 +350,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
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());
@@ -424,6 +417,11 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -491,7 +489,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
mExecutor.execute(() -> {
try {
Bitmap resource = Glide.with(PostGalleryActivity.this).asBitmap().load(imageUri).submit().get();
- String response = UploadImageUtils.uploadImage(mOauthRetrofit, mUploadMediaRetrofit, mAccessToken, resource, true);
+ String response = UploadImageUtils.uploadImage(mOauthRetrofit, mUploadMediaRetrofit, accessToken, resource, true);
String mediaId = new JSONObject(response).getJSONObject(JSONUtils.ASSET_KEY).getString(JSONUtils.ASSET_ID_KEY);
handler.post(() -> {
adapter.setImageAsUploaded(mediaId);
@@ -531,7 +529,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
index 56629d96..8d4b0edb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
@@ -64,7 +64,6 @@ import ml.docilealligator.infinityforreddit.events.SubmitImagePostEvent;
import ml.docilealligator.infinityforreddit.events.SubmitVideoOrGifPostEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -157,8 +156,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
@Inject
Executor mExecutor;
private Account selectedAccount;
- private String mAccessToken;
- private String mAccountName;
private String iconUrl;
private String subredditName;
private boolean subredditSelected = false;
@@ -211,9 +208,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
resources = getResources();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
@@ -329,7 +323,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
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());
@@ -426,6 +419,11 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -493,7 +491,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
@@ -701,7 +699,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
mPostingSnackbar.dismiss();
if (submitImagePostEvent.postSuccess) {
Intent intent = new Intent(PostImageActivity.this, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, accountName);
startActivity(intent);
finish();
} else {
@@ -726,7 +724,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
if (submitVideoOrGifPostEvent.postSuccess) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
- mAccountName);
+ accountName);
startActivity(intent);
finish();
} else if (submitVideoOrGifPostEvent.errorProcessingVideoOrGif) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
index effadc26..4d4f1d6a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
@@ -57,7 +57,6 @@ import ml.docilealligator.infinityforreddit.events.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Call;
import retrofit2.Callback;
@@ -143,8 +142,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
@Inject
Executor mExecutor;
private Account selectedAccount;
- private String mAccessToken;
- private String mAccountName;
private String iconUrl;
private String subredditName;
private boolean subredditSelected = false;
@@ -196,9 +193,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
resources = getResources();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
@@ -309,7 +303,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
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());
@@ -415,6 +408,11 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -479,7 +477,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java
index 2f98c7de..b03723d9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java
@@ -64,7 +64,6 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.SubmitPollPostEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -172,8 +171,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
@Inject
Executor mExecutor;
private Account selectedAccount;
- private String mAccessToken;
- private String mAccountName;
private String iconUrl;
private String subredditName;
private boolean subredditSelected = false;
@@ -224,9 +221,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
resources = getResources();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
Resources resources = getResources();
if (savedInstanceState != null) {
@@ -334,7 +328,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
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());
@@ -405,6 +398,11 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -529,7 +527,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
index 300a34f0..c36b8ed9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
@@ -70,7 +70,6 @@ import ml.docilealligator.infinityforreddit.events.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -160,8 +159,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
@Inject
Executor mExecutor;
private Account selectedAccount;
- private String mAccessToken;
- private String mAccountName;
private String iconUrl;
private String subredditName;
private boolean subredditSelected = false;
@@ -215,9 +212,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
resources = getResources();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
@@ -329,7 +323,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
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 {
@@ -425,6 +418,11 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -486,7 +484,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
@@ -639,10 +637,10 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
return;
}
Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit,
- mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
+ accessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit,
- mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
+ accessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
} else if (requestCode == MARKDOWN_PREVIEW_REQUEST_CODE) {
submitPost(mMenu.findItem(R.id.action_send_post_text_activity));
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
index 012b9d36..61e78787 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
@@ -163,8 +163,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
@Inject
Executor mExecutor;
private Account selectedAccount;
- private String mAccessToken;
- private String mAccountName;
private String iconUrl;
private String subredditName;
private boolean subredditSelected = false;
@@ -230,9 +228,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
resources = getResources();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
@@ -350,7 +345,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
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());
@@ -443,6 +437,11 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -512,7 +511,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
@@ -742,7 +741,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
if (submitVideoOrGifPostEvent.postSuccess) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
- mAccountName);
+ accountName);
startActivity(intent);
finish();
} else if (submitVideoOrGifPostEvent.errorProcessingVideoOrGif) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java
index 7ecc927c..90265e54 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java
@@ -71,8 +71,6 @@ public class ReportActivity extends BaseActivity {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private String mFullname;
private String mSubredditName;
private ArrayList<ReportReason> generalReasons;
@@ -106,9 +104,6 @@ public class ReportActivity extends BaseActivity {
mFullname = getIntent().getStringExtra(EXTRA_THING_FULLNAME);
mSubredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
generalReasons = savedInstanceState.getParcelableArrayList(GENERAL_REASONS_STATE);
rulesReasons = savedInstanceState.getParcelableArrayList(RULES_REASON_STATE);
@@ -123,8 +118,8 @@ public class ReportActivity extends BaseActivity {
if (rulesReasons == null) {
FetchRules.fetchRules(mExecutor, new Handler(),
- mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit,
- mAccessToken, mAccountName, mSubredditName, new FetchRules.FetchRulesListener() {
+ accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit,
+ accessToken, accountName, mSubredditName, new FetchRules.FetchRulesListener() {
@Override
public void success(ArrayList<Rule> rules) {
mAdapter.setRules(ReportReason.convertRulesToReasons(rules));
@@ -157,7 +152,7 @@ public class ReportActivity extends BaseActivity {
ReportReason reportReason = mAdapter.getSelectedReason();
if (reportReason != null) {
Toast.makeText(ReportActivity.this, R.string.reporting, Toast.LENGTH_SHORT).show();
- ReportThing.reportThing(mOauthRetrofit, mAccessToken, mFullname, mSubredditName,
+ ReportThing.reportThing(mOauthRetrofit, accessToken, mFullname, mSubredditName,
reportReason.getReasonType(), reportReason.getReportReason(), new ReportThing.ReportThingListener() {
@Override
public void success() {
@@ -194,6 +189,11 @@ public class ReportActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java
index 081af098..f57c48c1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java
@@ -80,8 +80,6 @@ public class RulesActivity extends BaseActivity {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private String mSubredditName;
private RulesRecyclerViewAdapter mAdapter;
@@ -125,8 +123,6 @@ public class RulesActivity extends BaseActivity {
}
}
}
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
appBarLayout.setBackgroundColor(mCustomThemeWrapper.getColorPrimary());
setSupportActionBar(toolbar);
@@ -138,8 +134,8 @@ public class RulesActivity extends BaseActivity {
recyclerView.setAdapter(mAdapter);
FetchRules.fetchRules(mExecutor, new Handler(),
- mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit,
- mAccessToken, mAccountName, mSubredditName, new FetchRules.FetchRulesListener() {
+ accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit,
+ accessToken, accountName, mSubredditName, new FetchRules.FetchRulesListener() {
@Override
public void success(ArrayList<Rule> rules) {
progressBar.setVisibility(View.GONE);
@@ -165,6 +161,11 @@ public class RulesActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -188,8 +189,8 @@ public class RulesActivity extends BaseActivity {
progressBar.setVisibility(View.VISIBLE);
errorTextView.setVisibility(View.GONE);
FetchRules.fetchRules(mExecutor, new Handler(),
- mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit,
- mAccessToken, mAccountName, mSubredditName, new FetchRules.FetchRulesListener() {
+ accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit,
+ accessToken, accountName, mSubredditName, new FetchRules.FetchRulesListener() {
@Override
public void success(ArrayList<Rule> rules) {
progressBar.setVisibility(View.GONE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
index 40108cd1..8498bc3c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -129,8 +129,6 @@ public class SearchActivity extends BaseActivity {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor executor;
- private String mAccountName;
- private String mAccessToken;
private String query;
private String subredditName;
private boolean subredditIsUser;
@@ -175,9 +173,7 @@ public class SearchActivity extends BaseActivity {
searchEditText.setHint(getText(R.string.search_only_users_hint));
}
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
subredditAutocompleteRecyclerViewAdapter = new SubredditAutocompleteRecyclerViewAdapter(this,
mCustomThemeWrapper, subredditData -> {
@@ -200,7 +196,7 @@ public class SearchActivity extends BaseActivity {
finish();
});
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
}
@@ -222,7 +218,7 @@ public class SearchActivity extends BaseActivity {
subredditAutocompleteCall.cancel();
}
- subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
+ subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(accessToken),
s.toString(), nsfw);
subredditAutocompleteCall.enqueue(new Callback<>() {
@Override
@@ -283,7 +279,7 @@ public class SearchActivity extends BaseActivity {
.setTitle(R.string.confirm)
.setMessage(R.string.confirm_delete_all_recent_searches)
.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
- executor.execute(() -> mRedditDataRoomDatabase.recentSearchQueryDao().deleteAllRecentSearchQueries(mAccountName));
+ executor.execute(() -> mRedditDataRoomDatabase.recentSearchQueryDao().deleteAllRecentSearchQueries(accountName));
})
.setNegativeButton(R.string.no, null)
.show();
@@ -322,7 +318,7 @@ public class SearchActivity extends BaseActivity {
}
private void bindView() {
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
adapter = new SearchActivityRecyclerViewAdapter(this, mCustomThemeWrapper, new SearchActivityRecyclerViewAdapter.ItemOnClickListener() {
@Override
public void onClick(String query) {
@@ -340,7 +336,7 @@ public class SearchActivity extends BaseActivity {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true)) {
mRecentSearchQueryViewModel = new ViewModelProvider(this,
- new RecentSearchQueryViewModel.Factory(mRedditDataRoomDatabase, mAccountName))
+ new RecentSearchQueryViewModel.Factory(mRedditDataRoomDatabase, accountName))
.get(RecentSearchQueryViewModel.class);
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
@@ -399,6 +395,11 @@ public class SearchActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
index 2cd11f5e..f89fa33f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
@@ -134,8 +134,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Inject
Executor executor;
private Call<String> subredditAutocompleteCall;
- private String mAccessToken;
- private String mAccountName;
private String mQuery;
private String mSubredditName;
private boolean mInsertSearchQuerySuccess;
@@ -204,9 +202,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mInsertSearchQuerySuccess = savedInstanceState.getBoolean(INSERT_SEARCH_QUERY_SUCCESS_STATE);
}
@@ -227,6 +222,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -299,7 +299,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
fab.setImageResource(R.drawable.ic_random_24dp);
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -313,7 +313,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
fab.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
break;
default:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
fab.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -383,15 +383,15 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
fab.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT));
+ bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, accountName.equals(Account.ANONYMOUS_ACCOUNT));
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true;
});
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)&& mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)&& mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
InsertRecentSearchQuery.insertRecentSearchQueryListener(executor, new Handler(getMainLooper()),
- mRedditDataRoomDatabase, mAccountName, mQuery, () -> mInsertSearchQuerySuccess = true);
+ mRedditDataRoomDatabase, accountName, mQuery, () -> mInsertSearchQuerySuccess = true);
}
}
@@ -606,7 +606,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -623,7 +623,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
if (subredditAutocompleteCall != null) {
subredditAutocompleteCall.cancel();
}
- subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
+ subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(accessToken),
editable.toString(), nsfw);
subredditAutocompleteCall.enqueue(new Callback<String>() {
@Override
@@ -706,7 +706,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private void random() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -775,8 +775,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
bundle.putString(PostFragment.EXTRA_NAME, mSubredditName);
bundle.putString(PostFragment.EXTRA_QUERY, mQuery);
bundle.putString(PostFragment.EXTRA_TRENDING_SOURCE, getIntent().getStringExtra(EXTRA_TRENDING_SOURCE));
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
mFragment.setArguments(bundle);
return mFragment;
}
@@ -785,8 +783,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
Bundle bundle = new Bundle();
bundle.putString(SubredditListingFragment.EXTRA_QUERY, mQuery);
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, false);
- bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
mFragment.setArguments(bundle);
return mFragment;
}
@@ -795,8 +791,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
Bundle bundle = new Bundle();
bundle.putString(UserListingFragment.EXTRA_QUERY, mQuery);
bundle.putBoolean(UserListingFragment.EXTRA_IS_GETTING_USER_INFO, false);
- bundle.putString(UserListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(UserListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
mFragment.setArguments(bundle);
return mFragment;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java
index bb1a5b00..f6f60af0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java
@@ -62,8 +62,6 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private String mAccessToken;
- private String mAccountName;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -106,16 +104,11 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
String query = getIntent().getExtras().getString(EXTRA_QUERY);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState == null) {
mFragment = new SubredditListingFragment();
Bundle bundle = new Bundle();
bundle.putString(SubredditListingFragment.EXTRA_QUERY, query);
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, true);
- bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
mFragment.setArguments(bundle);
} else {
@@ -132,6 +125,11 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java
index 7ee846fb..684e676c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java
@@ -62,8 +62,6 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private String mAccessToken;
- private String mAccountName;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -105,16 +103,11 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT
String query = getIntent().getExtras().getString(EXTRA_QUERY);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState == null) {
mFragment = new UserListingFragment();
Bundle bundle = new Bundle();
bundle.putString(UserListingFragment.EXTRA_QUERY, query);
bundle.putBoolean(UserListingFragment.EXTRA_IS_GETTING_USER_INFO, true);
- bundle.putString(UserListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(UserListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(UserListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
mFragment.setArguments(bundle);
} else {
@@ -131,6 +124,11 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java
index 15c775ab..ff2d24f7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java
@@ -32,7 +32,6 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SelectUserFlair;
import ml.docilealligator.infinityforreddit.UserFlair;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.adapters.UserFlairRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
@@ -66,8 +65,6 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
@Inject
CustomThemeWrapper mCustomThemeWrapper;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
- private String mAccessToken;
- private String mAccountName;
private ArrayList<UserFlair> mUserFlairs;
private String mSubredditName;
private UserFlairRecyclerViewAdapter mAdapter;
@@ -100,9 +97,6 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
mSubredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
setTitle(mSubredditName);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mUserFlairs = savedInstanceState.getParcelableArrayList(USER_FLAIRS_STATE);
}
@@ -111,7 +105,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
private void bindView() {
if (mUserFlairs == null) {
- FetchUserFlairs.fetchUserFlairsInSubreddit(mOauthRetrofit, mAccessToken, mSubredditName,
+ FetchUserFlairs.fetchUserFlairsInSubreddit(mOauthRetrofit, accessToken, mSubredditName,
new FetchUserFlairs.FetchUserFlairsInSubredditListener() {
@Override
public void fetchSuccessful(ArrayList<UserFlair> userFlairs) {
@@ -176,7 +170,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
}
private void selectUserFlair(@Nullable UserFlair userFlair) {
- SelectUserFlair.selectUserFlair(mOauthRetrofit, mAccessToken, userFlair, mSubredditName, mAccountName,
+ SelectUserFlair.selectUserFlair(mOauthRetrofit, accessToken, userFlair, mSubredditName, accountName,
new SelectUserFlair.SelectUserFlairListener() {
@Override
public void success() {
@@ -224,6 +218,11 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java
index aa782922..6eeb7363 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java
@@ -59,6 +59,9 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
private LinearLayoutManagerBugFixed linearLayoutManager;
private SelectedSubredditsRecyclerViewAdapter adapter;
@@ -186,6 +189,11 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java
index 9bc8b422..a47bcb15 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java
@@ -167,6 +167,11 @@ public class SendPrivateMessageActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
index c6f50425..cd5da5c9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
@@ -25,22 +25,16 @@ import javax.inject.Named;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.databinding.ActivitySettingsBinding;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.AdvancedPreferenceFragment;
-import ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment;
-import ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment;
import ml.docilealligator.infinityforreddit.settings.FontPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.GesturesAndButtonsPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.InterfacePreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.MainPreferenceFragment;
-import ml.docilealligator.infinityforreddit.settings.NsfwAndSpoilerFragment;
-import ml.docilealligator.infinityforreddit.settings.PostHistoryFragment;
import ml.docilealligator.infinityforreddit.settings.PostPreferenceFragment;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class SettingsActivity extends BaseActivity implements
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
@@ -48,7 +42,6 @@ public class SettingsActivity extends BaseActivity implements
private static final String TITLE_STATE = "TS";
private ActivitySettingsBinding binding;
- private String mAccountName;
@Inject
@Named("default")
@@ -82,8 +75,6 @@ public class SettingsActivity extends BaseActivity implements
setSupportActionBar(binding.toolbarSettingsActivity);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
@@ -121,6 +112,11 @@ public class SettingsActivity extends BaseActivity implements
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -161,15 +157,6 @@ public class SettingsActivity extends BaseActivity implements
final Fragment fragment = getSupportFragmentManager().getFragmentFactory().instantiate(
getClassLoader(),
pref.getFragment());
- if (fragment instanceof CustomizeMainPageTabsFragment) {
- args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- } else if (fragment instanceof NsfwAndSpoilerFragment) {
- args.putString(NsfwAndSpoilerFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- } else if (fragment instanceof CustomizeBottomAppBarFragment) {
- args.putString(CustomizeBottomAppBarFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- } else if (fragment instanceof PostHistoryFragment) {
- args.putString(PostHistoryFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- }
fragment.setArguments(args);
fragment.setTargetFragment(caller, 0);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
index 6c5bcea7..267d6fc4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
@@ -65,7 +65,6 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
@@ -154,8 +153,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
@Inject
Executor mExecutor;
private Account selectedAccount;
- private String mAccessToken;
- private String mAccountName;
private Post post;
private String iconUrl;
private String subredditName;
@@ -209,9 +206,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
post = getIntent().getParcelableExtra(EXTRA_POST);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
@@ -354,7 +348,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
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 {
@@ -436,6 +429,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -501,7 +499,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
- mAccessToken, mAccountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
+ accessToken, accountName, mOauthRetrofit, mRetrofit, iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java
index 6826f4c7..dda07d4f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java
@@ -37,7 +37,6 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.adapters.SubredditMultiselectionRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
@@ -84,7 +83,6 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
@Inject
CustomThemeWrapper mCustomThemeWrapper;
public SubscribedSubredditViewModel mSubscribedSubredditViewModel;
- private String mAccountName;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
private SubredditMultiselectionRecyclerViewAdapter mAdapter;
private RequestManager mGlide;
@@ -132,8 +130,6 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
mSwipeRefreshLayout.setEnabled(false);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
bindView();
}
@@ -144,7 +140,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
mRecyclerView.setAdapter(mAdapter);
mSubscribedSubredditViewModel = new ViewModelProvider(this,
- new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
+ new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName))
.get(SubscribedSubredditViewModel.class);
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, subscribedSubredditData -> {
mSwipeRefreshLayout.setRefreshing(false);
@@ -221,6 +217,11 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java
index ecfffa08..fdd69a5c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java
@@ -90,8 +90,6 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private String mAccountProfileImageUrl;
private boolean mInsertSuccess = false;
private Fragment mFragment;
@@ -137,8 +135,8 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
if (getIntent().hasExtra(EXTRA_SPECIFIED_ACCOUNT)) {
Account specifiedAccount = getIntent().getParcelableExtra(EXTRA_SPECIFIED_ACCOUNT);
if (specifiedAccount != null) {
- mAccessToken = specifiedAccount.getAccessToken();
- mAccountName = specifiedAccount.getAccountName();
+ accessToken = specifiedAccount.getAccessToken();
+ accountName = specifiedAccount.getAccountName();
mAccountProfileImageUrl = specifiedAccount.getProfileImageUrl();
mOauthRetrofit = mOauthRetrofit.newBuilder().client(new OkHttpClient.Builder().authenticator(new AnyAccountAccessTokenAuthenticator(mRetrofit, mRedditDataRoomDatabase, specifiedAccount, mCurrentAccountSharedPreferences))
@@ -149,13 +147,9 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
.build())
.build();
} else {
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
}
} else {
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
}
@@ -176,6 +170,11 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -196,8 +195,6 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
if (initializeFragment) {
mFragment = new SubscribedSubredditsListingFragment();
Bundle bundle = new Bundle();
- bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_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);
if (getIntent().hasExtra(EXTRA_EXTRA_CLEAR_SELECTION)) {
@@ -211,7 +208,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
private void loadSubscriptions() {
if (!mInsertSuccess) {
- FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
+ FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, accessToken, accountName, null,
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(),
new FetchSubscribedThing.FetchSubscribedThingListener() {
@@ -223,7 +220,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
mExecutor,
new Handler(),
mRedditDataRoomDatabase,
- mAccountName,
+ accountName,
subscribedSubredditData,
subscribedUserData,
subredditData,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
index d3eca700..c995bd59 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
@@ -110,8 +110,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private boolean mInsertSuccess = false;
private boolean mInsertMultiredditSuccess = false;
private boolean showMultiReddits = false;
@@ -164,9 +162,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
mInsertMultiredditSuccess = savedInstanceState.getBoolean(INSERT_MULTIREDDIT_STATE);
@@ -174,7 +169,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
showMultiReddits = getIntent().getBooleanExtra(EXTRA_SHOW_MULTIREDDITS, false);
}
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
}
@@ -203,6 +198,11 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -319,8 +319,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
return;
}
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !(!forceLoad && mInsertSuccess)) {
- FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null,
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT) && !(!forceLoad && mInsertSuccess)) {
+ FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, accessToken, accountName, null,
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(),
new FetchSubscribedThing.FetchSubscribedThingListener() {
@@ -333,7 +333,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
mExecutor,
new Handler(),
mRedditDataRoomDatabase,
- mAccountName,
+ accountName,
subscribedSubredditData,
subscribedUserData,
subredditData,
@@ -371,11 +371,11 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
}
private void loadMultiReddits() {
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, accessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
@Override
public void success(ArrayList<MultiReddit> multiReddits) {
- InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> {
+ InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, accountName, () -> {
mInsertMultiredditSuccess = true;
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
});
@@ -397,13 +397,13 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
.setMessage(R.string.delete_multi_reddit_dialog_message)
.setPositiveButton(R.string.delete, (dialogInterface, i)
-> {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiReddit.getPath(),
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, accountName, multiReddit.getPath(),
() -> Toast.makeText(SubscribedThingListingActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show());
} else {
DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
- mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
+ accessToken, accountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(SubscribedThingListingActivity.this,
@@ -477,24 +477,18 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, false);
- bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
fragment.setArguments(bundle);
return fragment;
}
case 1: {
FollowedUsersListingFragment fragment = new FollowedUsersListingFragment();
Bundle bundle = new Bundle();
- bundle.putString(FollowedUsersListingFragment.EXTRA_ACCOUNT_NAME, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : mAccountName);
- bundle.putString(FollowedUsersListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
fragment.setArguments(bundle);
return fragment;
}
default: {
MultiRedditListingFragment fragment = new MultiRedditListingFragment();
Bundle bundle = new Bundle();
- bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java
index 4be5bdd2..b192a6c6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java
@@ -40,6 +40,9 @@ public class SuicidePreventionActivity extends BaseActivity {
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -73,6 +76,11 @@ public class SuicidePreventionActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
index a0b568b5..5ca5f0d6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
@@ -101,8 +101,6 @@ public class TrendingActivity extends BaseActivity {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private boolean isRefreshing = false;
private ArrayList<TrendingSearch> trendingSearches;
private TrendingSearchRecyclerViewAdapter adapter;
@@ -151,9 +149,6 @@ public class TrendingActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
mGlide = Glide.with(this);
DisplayMetrics displayMetrics = new DisplayMetrics();
@@ -209,10 +204,10 @@ public class TrendingActivity extends BaseActivity {
adapter.setTrendingSearches(null);
Handler handler = new Handler();
Call<String> trendingCall;
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
trendingCall = mRetrofit.create(RedditAPI.class).getTrendingSearches();
} else {
- trendingCall = mOauthRetrofit.create(RedditAPI.class).getTrendingSearchesOauth(APIUtils.getOAuthHeader(mAccessToken));
+ trendingCall = mOauthRetrofit.create(RedditAPI.class).getTrendingSearchesOauth(APIUtils.getOAuthHeader(accessToken));
}
trendingCall.enqueue(new Callback<>() {
@Override
@@ -322,6 +317,11 @@ public class TrendingActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
index b55da858..a8c900be 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -128,8 +128,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private String multiPath;
private Fragment mFragment;
private int fabOption;
@@ -216,8 +214,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
if (savedInstanceState != null) {
@@ -230,9 +226,9 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE);
if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
- int option2 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ int optionCount = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
+ int option2 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
if (optionCount == 2) {
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
@@ -259,8 +255,8 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
});
}
} else {
- int option3 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
+ int option3 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1),
getBottomAppBarOptionDrawableResource(option2), getBottomAppBarOptionDrawableResource(option3),
@@ -333,7 +329,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_random_24dp);
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -347,7 +343,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
break;
default:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -409,7 +405,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
navigationWrapper.floatingActionButton.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT));
+ bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, accountName.equals(Account.ANONYMOUS_ACCOUNT));
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true;
@@ -420,9 +416,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
mFragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putString(PostFragment.EXTRA_NAME, multiPath);
- bundle.putInt(PostFragment.EXTRA_POST_TYPE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT : PostPagingSource.TYPE_MULTI_REDDIT);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT : PostPagingSource.TYPE_MULTI_REDDIT);
mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit();
}
@@ -445,7 +439,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, accountName);
startActivity(intent);
break;
}
@@ -611,7 +605,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -628,7 +622,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
if (subredditAutocompleteCall != null) {
subredditAutocompleteCall.cancel();
}
- subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
+ subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(accessToken),
editable.toString(), nsfw);
subredditAutocompleteCall.enqueue(new Callback<String>() {
@Override
@@ -711,7 +705,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private void random() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -755,15 +749,15 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
.setMessage(R.string.delete_multi_reddit_dialog_message)
.setPositiveButton(R.string.delete, (dialogInterface, i)
-> {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiPath,
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, accountName, multiPath,
() -> {
Toast.makeText(this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
finish();
});
} else {
DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
- mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() {
+ accessToken, accountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
@@ -828,6 +822,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -857,7 +856,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
@Override
public void markPostAsRead(Post post) {
- InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
+ InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, accountName, post.getId());
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index 85751042..4547e342 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -176,8 +176,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
public Map<String, String> authorIcons = new HashMap<>();
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
- private String mAccessToken;
- private String mAccountName;
private long postFragmentId;
private int postListPosition;
private int orientation;
@@ -264,9 +262,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
}
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
mVolumeKeysNavigateComments = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOLUME_KEYS_NAVIGATE_COMMENTS, false);
fab.setOnClickListener(view -> {
@@ -289,7 +284,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
return false;
});
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
searchTextInputEditText.setImeOptions(searchTextInputEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
}
@@ -325,6 +320,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -350,7 +350,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private void checkNewAccountAndBindView(Bundle savedInstanceState) {
if (mNewAccountName != null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) || !accountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -434,7 +434,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
public void saveComment(@NonNull Comment comment, int position) {
if (comment.isSaved()) {
comment.setSaved(false);
- SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
+ SaveThing.unsaveThing(mOauthRetrofit, accessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
@Override
public void success() {
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
@@ -455,7 +455,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
});
} else {
comment.setSaved(true);
- SaveThing.saveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
+ SaveThing.saveThing(mOauthRetrofit, accessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
@Override
public void success() {
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
@@ -510,52 +510,52 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) {
mExecutor.execute(() -> {
- RedditAPI api = (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit).create(RedditAPI.class);
+ RedditAPI api = (accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit).create(RedditAPI.class);
Call<String> call;
String afterKey = posts.isEmpty() ? null : posts.get(posts.size() - 1).getFullName();
switch (postType) {
case PostPagingSource.TYPE_SUBREDDIT:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
} else {
call = api.getSubredditBestPostsOauth(subredditName, sortType,
- sortTime, afterKey, APIUtils.getOAuthHeader(mAccessToken));
+ sortTime, afterKey, APIUtils.getOAuthHeader(accessToken));
}
break;
case PostPagingSource.TYPE_USER:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
call = api.getUserPosts(username, afterKey, sortType, sortTime);
} else {
call = api.getUserPostsOauth(username, userWhere, afterKey, sortType,
- sortTime, APIUtils.getOAuthHeader(mAccessToken));
+ sortTime, APIUtils.getOAuthHeader(accessToken));
}
break;
case PostPagingSource.TYPE_SEARCH:
if (subredditName == null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
call = api.searchPosts(query, afterKey, sortType, sortTime,
trendingSource);
} else {
call = api.searchPostsOauth(query, afterKey, sortType,
- sortTime, trendingSource, APIUtils.getOAuthHeader(mAccessToken));
+ sortTime, trendingSource, APIUtils.getOAuthHeader(accessToken));
}
} else {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
call = api.searchPostsInSpecificSubreddit(subredditName, query,
sortType, sortTime, afterKey);
} else {
call = api.searchPostsInSpecificSubredditOauth(subredditName, query,
sortType, sortTime, afterKey,
- APIUtils.getOAuthHeader(mAccessToken));
+ APIUtils.getOAuthHeader(accessToken));
}
}
break;
case PostPagingSource.TYPE_MULTI_REDDIT:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
call = api.getMultiRedditPosts(multiPath, afterKey, sortTime);
} else {
call = api.getMultiRedditPostsOauth(multiPath, afterKey,
- sortTime, APIUtils.getOAuthHeader(mAccessToken));
+ sortTime, APIUtils.getOAuthHeader(accessToken));
}
break;
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
@@ -564,7 +564,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
break;
default:
call = api.getBestPosts(sortType, sortTime, afterKey,
- APIUtils.getOAuthHeader(mAccessToken));
+ APIUtils.getOAuthHeader(accessToken));
}
try {
@@ -633,7 +633,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
if (!posts.isEmpty()) {
lastItem = mRedditDataRoomDatabase.readPostDao().getReadPost(posts.get(posts.size() - 1).getId()).getTime();
}
- List<ReadPost> readPosts = mRedditDataRoomDatabase.readPostDao().getAllReadPosts(mAccountName, lastItem);
+ List<ReadPost> readPosts = mRedditDataRoomDatabase.readPostDao().getAllReadPosts(accountName, lastItem);
StringBuilder ids = new StringBuilder();
for (ReadPost readPost : readPosts) {
ids.append("t3_").append(readPost.getId()).append(",");
@@ -643,8 +643,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
Call<String> historyPosts;
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- historyPosts = mOauthRetrofit.create(RedditAPI.class).getInfoOauth(ids.toString(), APIUtils.getOAuthHeader(mAccessToken));
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ historyPosts = mOauthRetrofit.create(RedditAPI.class).getInfoOauth(ids.toString(), APIUtils.getOAuthHeader(accessToken));
} else {
historyPosts = mRetrofit.create(RedditAPI.class).getInfo(ids.toString());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
index 3b338d08..4bacdc30 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
@@ -38,7 +38,6 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.adapters.PrivateMessagesDetailRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.asynctasks.LoadUserData;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@@ -49,7 +48,6 @@ import ml.docilealligator.infinityforreddit.events.RepliedToPrivateMessageEvent;
import ml.docilealligator.infinityforreddit.message.Message;
import ml.docilealligator.infinityforreddit.message.ReadMessage;
import ml.docilealligator.infinityforreddit.message.ReplyMessage;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class ViewPrivateMessagesActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -97,8 +95,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
Message privateMessage;
@State
Message replyTo;
- private String mAccessToken;
- private String mAccountName;
private String mUserAvatar;
private ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
private boolean isLoadingUserAvatar = false;
@@ -133,9 +129,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
mProvideUserAvatarCallbacks = new ArrayList<>();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState != null) {
mUserAvatar = savedInstanceState.getString(USER_AVATAR_STATE);
if (privateMessage == null) {
@@ -150,7 +143,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
private void bindView() {
if (privateMessage != null) {
- if (privateMessage.getAuthor().equals(mAccountName)) {
+ if (privateMessage.getAuthor().equals(accountName)) {
setTitle(privateMessage.getDestination());
mToolbar.setOnClickListener(view -> {
if (privateMessage.isDestinationDeleted()) {
@@ -173,7 +166,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
}
}
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
- getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
+ getResources().getConfiguration().locale, privateMessage, accountName, mCustomThemeWrapper);
mLinearLayoutManager = new LinearLayoutManagerBugFixed(this);
mLinearLayoutManager.setStackFromEnd(true);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
@@ -191,7 +184,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
isSendingMessage = true;
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
- getResources().getConfiguration().locale, mOauthRetrofit, mAccessToken,
+ getResources().getConfiguration().locale, mOauthRetrofit, accessToken,
new ReplyMessage.ReplyMessageListener() {
@Override
public void replyMessageSuccess(Message message) {
@@ -229,7 +222,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
}
if (fullnames.length() > 0) {
fullnames.deleteCharAt(fullnames.length() - 1);
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, fullnames.toString(),
+ ReadMessage.readMessage(mOauthRetrofit, accessToken, fullnames.toString(),
new ReadMessage.ReadMessageListener() {
@Override
public void readSuccess() {}
@@ -303,6 +296,11 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -334,10 +332,10 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
public void onPassPrivateMessageEvent(PassPrivateMessageEvent passPrivateMessageEvent) {
privateMessage = passPrivateMessageEvent.message;
if (privateMessage != null) {
- if (privateMessage.getAuthor().equals(mAccountName)) {
+ if (privateMessage.getAuthor().equals(accountName)) {
if (privateMessage.getReplies() != null) {
for (int i = privateMessage.getReplies().size() - 1; i >= 0; i--) {
- if (!privateMessage.getReplies().get(i).getAuthor().equals(mAccountName)) {
+ if (!privateMessage.getReplies().get(i).getAuthor().equals(accountName)) {
replyTo = privateMessage.getReplies().get(i);
break;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 3a6f2f41..2dbb5440 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -207,8 +207,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private SectionsPagerAdapter sectionsPagerAdapter;
private NavigationWrapper navigationWrapper;
private Call<String> subredditAutocompleteCall;
- private String mAccessToken;
- private String mAccountName;
private String subredditName;
private String description;
private boolean mFetchSubredditInfoSuccess = false;
@@ -343,9 +341,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
if (savedInstanceState == null) {
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
@@ -479,7 +474,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (subredditData.isNSFW()) {
if (nsfwWarningBuilder == null
- && mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) || !mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false)) {
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) || !mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false)) {
nsfwWarningBuilder = new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.warning)
.setMessage(R.string.this_is_a_nsfw_subreddit)
@@ -510,6 +505,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -558,7 +558,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void checkNewAccountAndBindView() {
if (mNewAccountName != null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) || !accountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -566,8 +566,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
mNewAccountName = null;
if (newAccount != null) {
- mAccessToken = newAccount.getAccessToken();
- mAccountName = newAccount.getAccountName();
+ accessToken = newAccount.getAccessToken();
+ accountName = newAccount.getAccountName();
}
bindView();
@@ -582,7 +582,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void fetchSubredditData() {
if (!mFetchSubredditInfoSuccess) {
- FetchSubredditData.fetchSubredditData(mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
+ FetchSubredditData.fetchSubredditData(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
@@ -618,7 +618,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, accountName);
startActivity(intent);
break;
}
@@ -751,7 +751,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void bindView() {
if (mMessageFullname != null) {
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
+ ReadMessage.readMessage(mOauthRetrofit, accessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
@Override
public void readSuccess() {
mMessageFullname = null;
@@ -765,9 +765,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
- int option2 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ int optionCount = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
+ int option2 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
if (optionCount == 2) {
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
@@ -794,8 +794,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
});
}
} else {
- int option3 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
+ int option3 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1),
getBottomAppBarOptionDrawableResource(option2), getBottomAppBarOptionDrawableResource(option3),
@@ -844,7 +844,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
navigationWrapper.floatingActionButton.setLayoutParams(lp);
}
- fabOption = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
+ fabOption = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) {
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH:
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_refresh_24dp);
@@ -868,7 +868,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_random_24dp);
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -882,7 +882,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
break;
default:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -946,7 +946,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
navigationWrapper.floatingActionButton.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT));
+ bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, accountName.equals(Account.ANONYMOUS_ACCOUNT));
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true;
@@ -954,7 +954,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE);
subscribeSubredditChip.setOnClickListener(view -> {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (subscriptionReady) {
subscriptionReady = false;
if (getResources().getString(R.string.subscribe).contentEquals(subscribeSubredditChip.getText())) {
@@ -1000,7 +1000,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
subscriptionReady = false;
if (getResources().getString(R.string.subscribe).contentEquals(subscribeSubredditChip.getText())) {
SubredditSubscription.subscribeToSubreddit(mExecutor, new Handler(), mOauthRetrofit,
- mRetrofit, mAccessToken, subredditName, mAccountName, mRedditDataRoomDatabase,
+ mRetrofit, accessToken, subredditName, accountName, mRedditDataRoomDatabase,
new SubredditSubscription.SubredditSubscriptionListener() {
@Override
public void onSubredditSubscriptionSuccess() {
@@ -1018,7 +1018,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
});
} else {
SubredditSubscription.unsubscribeToSubreddit(mExecutor, new Handler(), mOauthRetrofit,
- mAccessToken, subredditName, mAccountName, mRedditDataRoomDatabase,
+ accessToken, subredditName, accountName, mRedditDataRoomDatabase,
new SubredditSubscription.SubredditSubscriptionListener() {
@Override
public void onSubredditSubscriptionSuccess() {
@@ -1040,7 +1040,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
});
CheckIsSubscribedToSubreddit.checkIsSubscribedToSubreddit(mExecutor, new Handler(),
- mRedditDataRoomDatabase, subredditName, mAccountName,
+ mRedditDataRoomDatabase, subredditName, accountName,
new CheckIsSubscribedToSubreddit.CheckIsSubscribedToSubredditListener() {
@Override
public void isSubscribed() {
@@ -1135,7 +1135,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
} else if (itemId == R.id.action_select_user_flair_view_subreddit_detail_activity) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
@@ -1144,7 +1144,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
startActivity(selectUserFlairIntent);
return true;
} else if (itemId == R.id.action_add_to_multireddit_view_subreddit_detail_activity) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
@@ -1191,7 +1191,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
MultiReddit multiReddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT);
if (multiReddit != null) {
AddSubredditOrUserToMultiReddit.addSubredditOrUserToMultiReddit(mOauthRetrofit,
- mAccessToken, multiReddit.getPath(), subredditName,
+ accessToken, multiReddit.getPath(), subredditName,
new AddSubredditOrUserToMultiReddit.AddSubredditOrUserToMultiRedditListener() {
@Override
public void success() {
@@ -1434,7 +1434,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1451,7 +1451,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (subredditAutocompleteCall != null) {
subredditAutocompleteCall.cancel();
}
- subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
+ subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(accessToken),
editable.toString(), nsfw);
subredditAutocompleteCall.enqueue(new Callback<String>() {
@Override
@@ -1534,7 +1534,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void random() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -1548,7 +1548,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override
public void markPostAsRead(Post post) {
- InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
+ InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, accountName, post.getId());
}
@Override
@@ -1579,15 +1579,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
Bundle bundle = new Bundle();
bundle.putString(PostFragment.EXTRA_NAME, subredditName);
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
}
SidebarFragment fragment = new SidebarFragment();
Bundle bundle = new Bundle();
- bundle.putString(SidebarFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(SidebarFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putString(SidebarFragment.EXTRA_SUBREDDIT_NAME, subredditName);
fragment.setArguments(bundle);
return fragment;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index e57881f1..6fd6a882 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -203,8 +203,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private RequestManager glide;
private NavigationWrapper navigationWrapper;
private Call<String> subredditAutocompleteCall;
- private String mAccessToken;
- private String mAccountName;
private String username;
private String description;
private boolean subscriptionReady = false;
@@ -260,12 +258,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fragmentManager = getSupportFragmentManager();
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
if (username.equalsIgnoreCase("me")) {
- username = mAccountName;
+ username = accountName;
}
if (savedInstanceState == null) {
@@ -441,7 +437,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (subscriptionReady) {
subscriptionReady = false;
if (resources.getString(R.string.follow).contentEquals(subscribeUserChip.getText())) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
UserFollowing.anonymousFollowUser(mExecutor, new Handler(), mRetrofit,
username, mRedditDataRoomDatabase, new UserFollowing.UserFollowingListener() {
@Override
@@ -459,8 +455,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
});
} else {
- UserFollowing.followUser(mOauthRetrofit, mRetrofit, mAccessToken,
- username, mAccountName, mRedditDataRoomDatabase, new UserFollowing.UserFollowingListener() {
+ UserFollowing.followUser(mOauthRetrofit, mRetrofit, accessToken,
+ username, accountName, mRedditDataRoomDatabase, new UserFollowing.UserFollowingListener() {
@Override
public void onUserFollowingSuccess() {
subscribeUserChip.setText(R.string.unfollow);
@@ -477,7 +473,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
});
}
} else {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
UserFollowing.anonymousUnfollowUser(mExecutor, new Handler(), username,
mRedditDataRoomDatabase, new UserFollowing.UserFollowingListener() {
@Override
@@ -494,8 +490,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
});
} else {
- UserFollowing.unfollowUser(mOauthRetrofit, mRetrofit, mAccessToken,
- username, mAccountName, mRedditDataRoomDatabase, new UserFollowing.UserFollowingListener() {
+ UserFollowing.unfollowUser(mOauthRetrofit, mRetrofit, accessToken,
+ username, accountName, mRedditDataRoomDatabase, new UserFollowing.UserFollowingListener() {
@Override
public void onUserFollowingSuccess() {
subscribeUserChip.setText(R.string.follow);
@@ -516,7 +512,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
});
CheckIsFollowingUser.checkIsFollowingUser(mExecutor, new Handler(), mRedditDataRoomDatabase,
- username, mAccountName, new CheckIsFollowingUser.CheckIsFollowingUserListener() {
+ username, accountName, new CheckIsFollowingUser.CheckIsFollowingUserListener() {
@Override
public void isSubscribed() {
subscribeUserChip.setText(R.string.unfollow);
@@ -596,6 +592,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@@ -639,7 +640,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private void checkNewAccountAndInitializeViewPager() {
if (mNewAccountName != null) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT) || !accountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -647,8 +648,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mNewAccountName = null;
if (newAccount != null) {
- mAccessToken = newAccount.getAccessToken();
- mAccountName = newAccount.getAccountName();
+ accessToken = newAccount.getAccessToken();
+ accountName = newAccount.getAccountName();
}
initializeViewPager();
@@ -700,7 +701,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fixViewPager2Sensitivity(viewPager2);
if (mMessageFullname != null) {
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
+ ReadMessage.readMessage(mOauthRetrofit, accessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
@Override
public void readSuccess() {
mMessageFullname = null;
@@ -716,9 +717,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE);
if (showBottomAppBar) {
- int optionCount = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- int option1 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
- int option2 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
+ int optionCount = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ int option1 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME);
+ int option2 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS);
if (optionCount == 2) {
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
@@ -745,8 +746,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
});
}
} else {
- int option3 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
- int option4 = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
+ int option3 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_MULTIREDDITS : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX);
+ int option4 = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_REFRESH : SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE);
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1),
getBottomAppBarOptionDrawableResource(option2), getBottomAppBarOptionDrawableResource(option3),
@@ -795,7 +796,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
navigationWrapper.floatingActionButton.setLayoutParams(lp);
}
- fabOption = mBottomAppBarSharedPreference.getInt((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
+ fabOption = mBottomAppBarSharedPreference.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS);
switch (fabOption) {
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH:
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_refresh_24dp);
@@ -819,7 +820,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_random_24dp);
break;
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -833,7 +834,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
break;
default:
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
@@ -896,7 +897,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
navigationWrapper.floatingActionButton.setOnLongClickListener(view -> {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment = new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, mAccountName.equals(Account.ANONYMOUS_ACCOUNT));
+ bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, accountName.equals(Account.ANONYMOUS_ACCOUNT));
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true;
@@ -921,7 +922,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, accountName);
startActivity(intent);
break;
}
@@ -1085,7 +1086,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
.setTitle(R.string.delete_this_comment)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.delete, (dialogInterface, i)
- -> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() {
+ -> DeleteThing.delete(mOauthRetrofit, fullName, accessToken, new DeleteThing.DeleteThingListener() {
@Override
public void deleteSuccess() {
Toast.makeText(ViewUserDetailActivity.this, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
@@ -1103,7 +1104,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
- if (username.equals(mAccountName)) {
+ if (username.equals(accountName)) {
menu.findItem(R.id.action_send_private_message_view_user_detail_activity).setVisible(false);
menu.findItem(R.id.action_report_view_user_detail_activity).setVisible(false);
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
@@ -1149,7 +1150,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
return true;
} else if (itemId == R.id.action_send_private_message_view_user_detail_activity) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
@@ -1159,7 +1160,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
startActivity(pmIntent);
return true;
} else if (itemId == R.id.action_add_to_multireddit_view_user_detail_activity) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
@@ -1176,7 +1177,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
startActivity(reportIntent);
return true;
} else if (itemId == R.id.action_block_user_view_user_detail_activity) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
@@ -1185,7 +1186,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
.setTitle(R.string.block_user)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes, (dialogInterface, i)
- -> BlockUser.blockUser(mOauthRetrofit, mAccessToken, username, new BlockUser.BlockUserListener() {
+ -> BlockUser.blockUser(mOauthRetrofit, accessToken, username, new BlockUser.BlockUserListener() {
@Override
public void success() {
Toast.makeText(ViewUserDetailActivity.this, R.string.block_user_success, Toast.LENGTH_SHORT).show();
@@ -1223,7 +1224,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
MultiReddit multiReddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT);
if (multiReddit != null) {
AddSubredditOrUserToMultiReddit.addSubredditOrUserToMultiReddit(mOauthRetrofit,
- mAccessToken, multiReddit.getPath(), "u_" + username,
+ accessToken, multiReddit.getPath(), "u_" + username,
new AddSubredditOrUserToMultiReddit.AddSubredditOrUserToMultiRedditListener() {
@Override
public void success() {
@@ -1371,7 +1372,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1388,7 +1389,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (subredditAutocompleteCall != null) {
subredditAutocompleteCall.cancel();
}
- subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
+ subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(accessToken),
editable.toString(), nsfw);
subredditAutocompleteCall.enqueue(new Callback<String>() {
@Override
@@ -1471,7 +1472,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private void random() {
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ bundle.putBoolean(RandomBottomSheetFragment.EXTRA_IS_NSFW, !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -1536,7 +1537,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
public void markPostAsRead(Post post) {
- InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
+ InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, accountName, post.getId());
}
@Override
@@ -1612,16 +1613,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
bundle.putString(PostFragment.EXTRA_USER_NAME, username);
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SUBMITTED);
- bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
}
CommentsListingFragment fragment = new CommentsListingFragment();
Bundle bundle = new Bundle();
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, username);
- bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, false);
fragment.setArguments(bundle);
return fragment;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java
index 87d66393..a7dd857f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java
@@ -115,6 +115,11 @@ public class WebViewActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index bd8c804d..11053c09 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -98,6 +98,9 @@ public class WikiActivity extends BaseActivity {
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
CustomThemeWrapper mCustomThemeWrapper;
private String wikiMarkdown;
private String mSubredditName;
@@ -325,6 +328,11 @@ public class WikiActivity extends BaseActivity {
}
@Override
+ public SharedPreferences getCurrentAccountSharedPreferences() {
+ return mCurrentAccountSharedPreferences;
+ }
+
+ @Override
public CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index b66b5cd3..bc764aa4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -527,8 +527,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (comment.getAuthor().equals(mAccountName)) {
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
}
- bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getBindingAdapterPosition());
CommentMoreBottomSheetFragment commentMoreBottomSheetFragment = new CommentMoreBottomSheetFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 8695d14b..4dd77296 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -1377,8 +1377,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
}
- bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCOUNT_NAME, mAccountName);
bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
if (mIsSingleCommentThreadMode) {
bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getBindingAdapterPosition() - 1);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
index bd8b992f..3026029a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentMoreBottomSheetFragment.java
@@ -37,8 +37,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_COMMENT = "ECF";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_EDIT_AND_DELETE_AVAILABLE = "EEADA";
public static final String EXTRA_POSITION = "EP";
public static final String EXTRA_SHOW_REPLY_AND_SAVE_OPTION = "ESSARO";
@@ -71,12 +69,10 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
dismiss();
return binding.getRoot();
}
- String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN);
- String accountName = bundle.getString(EXTRA_ACCOUNT_NAME);
boolean editAndDeleteAvailable = bundle.getBoolean(EXTRA_EDIT_AND_DELETE_AVAILABLE, false);
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
- if (!accountName.equals(Account.ANONYMOUS_ACCOUNT) && !accessToken.equals("")) {
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) && !"".equals(activity.accessToken)) {
if (editAndDeleteAvailable) {
binding.editTextViewCommentMoreBottomSheetFragment.setVisibility(View.VISIBLE);
binding.deleteTextViewCommentMoreBottomSheetFragment.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java
index f3b5d1d1..0e258550 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java
@@ -42,7 +42,6 @@ import retrofit2.Retrofit;
*/
public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialogFragment {
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
public static final String EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID = "EPFI";
@BindView(R.id.progress_bar_flair_bottom_sheet_fragment)
@@ -56,7 +55,6 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog
Retrofit mOauthRetrofit;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private String mAccessToken;
private String mSubredditName;
private BaseActivity mActivity;
private FlairBottomSheetRecyclerViewAdapter mAdapter;
@@ -91,7 +89,6 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog
recyclerView.setAdapter(mAdapter);
- mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
mSubredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
fetchFlairs();
@@ -100,7 +97,7 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog
}
private void fetchFlairs() {
- FetchFlairs.fetchFlairsInSubreddit(mOauthRetrofit, mAccessToken,
+ FetchFlairs.fetchFlairsInSubreddit(mOauthRetrofit, mActivity.accessToken,
mSubredditName, new FetchFlairs.FetchFlairsInSubredditListener() {
@Override
public void fetchSuccessful(ArrayList<Flair> flairs) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
index 4c3a2f85..ba6d55f0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
@@ -53,8 +53,6 @@ import ml.docilealligator.infinityforreddit.adapters.CommentsListingRecyclerView
import ml.docilealligator.infinityforreddit.comment.CommentViewModel;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
-import ml.docilealligator.infinityforreddit.events.ChangeDataSavingModeEvent;
-import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNetworkStatusEvent;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
@@ -67,8 +65,6 @@ import retrofit2.Retrofit;
public class CommentsListingFragment extends Fragment implements FragmentCommunicator {
public static final String EXTRA_USERNAME = "EN";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_ARE_SAVED_COMMENTS = "EISC";
@BindView(R.id.coordinator_layout_comments_listing_fragment)
@@ -108,8 +104,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
CustomThemeWrapper customThemeWrapper;
@Inject
Executor mExecutor;
- private String mAccessToken;
- private String mAccountName;
private RequestManager mGlide;
private BaseActivity mActivity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
@@ -260,9 +254,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
touchHelper.attachToRecyclerView(mCommentRecyclerView);
}
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
new Handler().postDelayed(() -> bindView(resources), 0);
return rootView;
@@ -284,7 +275,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper,
getResources().getConfiguration().locale, mSharedPreferences,
- getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
+ mActivity.accessToken, mActivity.accountName,
username, () -> mCommentViewModel.retryLoadingMore());
mCommentRecyclerView.setAdapter(mAdapter);
@@ -304,12 +295,12 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
CommentViewModel.Factory factory;
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- factory = new CommentViewModel.Factory(mRetrofit, null, mAccountName, username, sortType,
+ if (mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ factory = new CommentViewModel.Factory(mRetrofit, null, mActivity.accountName, username, sortType,
getArguments().getBoolean(EXTRA_ARE_SAVED_COMMENTS));
} else {
factory = new CommentViewModel.Factory(mOauthRetrofit,
- mAccessToken, mAccountName, username, sortType,
+ mActivity.accessToken, mActivity.accountName, username, sortType,
getArguments().getBoolean(EXTRA_ARE_SAVED_COMMENTS));
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java
index 78929e32..c6aecc88 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java
@@ -50,9 +50,6 @@ import retrofit2.Retrofit;
*/
public class FollowedUsersListingFragment extends Fragment implements FragmentCommunicator {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
-
@BindView(R.id.swipe_refresh_layout_followed_users_listing_fragment)
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view_followed_users_listing_fragment)
@@ -109,20 +106,18 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
mGlide = Glide.with(this);
- String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
mSwipeRefreshLayout.setEnabled(false);
}
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity,
- mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken, accountName);
+ mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, mActivity.accessToken, mActivity.accountName);
mRecyclerView.setAdapter(adapter);
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
mSubscribedUserViewModel = new ViewModelProvider(this,
- new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountName))
+ new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, mActivity.accountName))
.get(SubscribedUserViewModel.class);
mSubscribedUserViewModel.getAllSubscribedUsers().observe(getViewLifecycleOwner(), subscribedUserData -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
index df26b5d6..616b1759 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
@@ -134,8 +134,6 @@ import retrofit2.Retrofit;
public class HistoryPostFragment extends Fragment implements FragmentCommunicator {
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_HISTORY_TYPE = "EHT";
public static final String EXTRA_FILTER = "EF";
public static final int HISTORY_TYPE_READ_POSTS = 1;
@@ -214,7 +212,6 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
private LazyModeRunnable lazyModeRunnable;
private CountDownTimer resumeLazyModeCountDownTimer;
private float lazyModeInterval;
- private String accountName;
private int maxPosition = -1;
private int postLayout;
private PostFilter postFilter;
@@ -230,7 +227,6 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
private ArrayList<String> readPosts;
private Unbinder unbinder;
private final Map<String, String> subredditOrUserIcons = new HashMap<>();
- private String accessToken;
private int historyType;
public HistoryPostFragment() {
@@ -366,8 +362,6 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
});
}
- accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
historyType = getArguments().getInt(EXTRA_HISTORY_TYPE, HISTORY_TYPE_READ_POSTS);
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
rememberMutingOptionInPostFeed = mSharedPreferences.getBoolean(SharedPreferencesUtils.REMEMBER_MUTING_OPTION_IN_POST_FEED, false);
@@ -378,7 +372,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mExoCreator, new HistoryPostRecyclerViewAdapter.Callback() {
@Override
@@ -443,15 +437,15 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
if (postFilter == null) {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), accountName, PostFilterUsage.HISTORY_TYPE, PostFilterUsage.HISTORY_TYPE_USAGE_READ_POSTS, (postFilter, readPostList) -> {
+ new Handler(), activity.accountName, PostFilterUsage.HISTORY_TYPE, PostFilterUsage.HISTORY_TYPE_USAGE_READ_POSTS, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
- postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
- initializeAndBindPostViewModel(accessToken);
+ postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(activity.accountName + SharedPreferencesUtils.NSFW_BASE, false);
+ initializeAndBindPostViewModel();
}
});
} else {
- initializeAndBindPostViewModel(accessToken);
+ initializeAndBindPostViewModel();
}
vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true);
@@ -649,15 +643,15 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
}
}
- private void initializeAndBindPostViewModel(String accessToken) {
+ private void initializeAndBindPostViewModel() {
if (postType == HistoryPostPagingSource.TYPE_READ_POSTS) {
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
- accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
- accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
+ activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, mRedditDataRoomDatabase, activity.accessToken,
+ activity.accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
} else {
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
- accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
- accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
+ activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, mRedditDataRoomDatabase, activity.accessToken,
+ activity.accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
}
bindPostViewModel();
@@ -929,7 +923,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
} else {
if (isSubreddit) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase,
- subredditOrUserName, accessToken, accountName, mOauthRetrofit, mRetrofit,
+ subredditOrUserName, activity.accessToken, activity.accountName, mOauthRetrofit, mRetrofit,
iconImageUrl -> {
subredditOrUserIcons.put(subredditOrUserName, iconImageUrl);
loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/InboxFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/InboxFragment.java
index cc1ef512..25e4263e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/InboxFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/InboxFragment.java
@@ -47,7 +47,6 @@ import retrofit2.Retrofit;
public class InboxFragment extends Fragment implements FragmentCommunicator {
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_MESSAGE_WHERE = "EMT";
@BindView(R.id.swipe_refresh_layout_inbox_fragment)
SwipeRefreshLayout mSwipeRefreshLayout;
@@ -70,7 +69,6 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
SharedPreferences mSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private String mAccessToken;
private String mWhere;
private MessageRecyclerViewAdapter mAdapter;
private RequestManager mGlide;
@@ -98,7 +96,6 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
if (arguments == null) {
return rootView;
}
- mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
mGlide = Glide.with(this);
if (mActivity.isImmersiveInterface()) {
@@ -107,7 +104,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
mWhere = arguments.getString(EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
mAdapter = new MessageRecyclerViewAdapter(mActivity, mOauthRetrofit, mCustomThemeWrapper,
- mAccessToken, mWhere, () -> mMessageViewModel.retryLoadingMore());
+ mActivity.accessToken, mWhere, () -> mMessageViewModel.retryLoadingMore());
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
mRecyclerView.setAdapter(mAdapter);
@@ -128,7 +125,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
}
MessageViewModel.Factory factory = new MessageViewModel.Factory(mOauthRetrofit,
- getResources().getConfiguration().locale, mAccessToken, mWhere);
+ getResources().getConfiguration().locale, mActivity.accessToken, mWhere);
mMessageViewModel = new ViewModelProvider(this, factory).get(MessageViewModel.class);
mMessageViewModel.getMessages().observe(getViewLifecycleOwner(), messages -> mAdapter.submitList(messages));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java
index 88457354..c58f1c50 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java
@@ -50,8 +50,6 @@ import retrofit2.Retrofit;
public class MultiRedditListingFragment extends Fragment implements FragmentCommunicator {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_IS_GETTING_MULTIREDDIT_INFO = "EIGMI";
@BindView(R.id.swipe_refresh_layout_multi_reddit_listing_fragment)
@@ -108,11 +106,9 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
}
}
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
- String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false);
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
mSwipeRefreshLayout.setEnabled(false);
}
@@ -121,8 +117,8 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
MultiRedditListingRecyclerViewAdapter adapter = new MultiRedditListingRecyclerViewAdapter(mActivity,
- mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken,
- accountName, new MultiRedditListingRecyclerViewAdapter.OnItemClickListener() {
+ mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, mActivity.accessToken,
+ mActivity.accountName, new MultiRedditListingRecyclerViewAdapter.OnItemClickListener() {
@Override
public void onClick(MultiReddit multiReddit) {
if (mActivity instanceof MultiredditSelectionActivity) {
@@ -158,7 +154,7 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
mMultiRedditViewModel = new ViewModelProvider(this,
- new MultiRedditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountName))
+ new MultiRedditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, mActivity.accountName))
.get(MultiRedditViewModel.class);
mMultiRedditViewModel.getAllMultiReddits().observe(getViewLifecycleOwner(), subscribedUserData -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 3d9ac681..3dfd5828 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -157,8 +157,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
public static final String EXTRA_TRENDING_SOURCE = "ETS";
public static final String EXTRA_POST_TYPE = "EPT";
public static final String EXTRA_FILTER = "EF";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_DISABLE_READ_POSTS = "EDRP";
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
@@ -240,7 +238,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private LazyModeRunnable lazyModeRunnable;
private CountDownTimer resumeLazyModeCountDownTimer;
private float lazyModeInterval;
- private String accountName;
private String subredditName;
private String username;
private String query;
@@ -264,7 +261,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private ArrayList<String> readPosts;
private Unbinder unbinder;
private final Map<String, String> subredditOrUserIcons = new HashMap<>();
- private String accessToken;
public PostFragment() {
// Required empty public constructor
@@ -434,8 +430,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postType = getArguments().getInt(EXTRA_POST_TYPE);
- accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
rememberMutingOptionInPostFeed = mSharedPreferences.getBoolean(SharedPreferencesUtils.REMEMBER_MUTING_OPTION_IN_POST_FEED, false);
@@ -462,7 +456,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -539,7 +533,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, displaySubredditName,
+ activity.accessToken, activity.accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -610,7 +604,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -675,7 +669,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -736,7 +730,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -796,7 +790,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -853,7 +847,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
- accessToken, accountName, postType, postLayout, true,
+ activity.accessToken, activity.accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
mExoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
@@ -914,46 +908,46 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
((ActivityToolbarInterface) activity).displaySortType();
}
- if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- if (mPostHistorySharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false) && readPosts == null) {
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (mPostHistorySharedPreferences.getBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false) && readPosts == null) {
if (getArguments().getBoolean(EXTRA_DISABLE_READ_POSTS, false)) {
if (postFilter == null) {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), activity.accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
- postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
- initializeAndBindPostViewModel(accessToken);
+ postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(activity.accountName + SharedPreferencesUtils.NSFW_BASE, false);
+ initializeAndBindPostViewModel();
}
});
} else {
- initializeAndBindPostViewModel(accessToken);
+ initializeAndBindPostViewModel();
}
} else {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), activity.accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
if (this.postFilter == null) {
this.postFilter = postFilter;
- postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
+ postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(activity.accountName + SharedPreferencesUtils.NSFW_BASE, false);
}
this.readPosts = readPostList;
- initializeAndBindPostViewModel(accessToken);
+ initializeAndBindPostViewModel();
}
});
}
} else {
if (postFilter == null) {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), activity.accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
- postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false);
- initializeAndBindPostViewModel(accessToken);
+ postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(activity.accountName + SharedPreferencesUtils.NSFW_BASE, false);
+ initializeAndBindPostViewModel();
}
});
} else {
- initializeAndBindPostViewModel(accessToken);
+ initializeAndBindPostViewModel();
}
}
} else {
@@ -996,7 +990,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
} else {
FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
- new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
+ new Handler(), activity.accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) {
this.postFilter = postFilter;
postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false);
@@ -1201,31 +1195,31 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
- private void initializeAndBindPostViewModel(String accessToken) {
+ private void initializeAndBindPostViewModel() {
if (postType == PostPagingSource.TYPE_SEARCH) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
- accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, accessToken, accountName, mSharedPreferences,
+ activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, activity.accessToken, activity.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,
- accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
+ activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, activity.accessToken, activity.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,
- accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
+ activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, activity.accessToken, activity.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,
- accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, accessToken, accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
+ activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit, activity.accessToken, activity.accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, username, postType, sortType, postFilter, where, readPosts))
.get(PostViewModel.class);
} else {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
- mOauthRetrofit, accessToken,
- accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
+ mOauthRetrofit, activity.accessToken,
+ activity.accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
}
@@ -1236,22 +1230,22 @@ 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, null, accountName, mSharedPreferences,
+ mRetrofit, null, activity.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, null, accountName, mSharedPreferences,
+ mRetrofit, null, activity.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, null, accountName, mSharedPreferences,
+ mRetrofit, null, activity.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, null, accountName, mSharedPreferences,
+ mRetrofit, null, activity.accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, username, postType, sortType, postFilter,
where, readPosts)).get(PostViewModel.class);
} else {
@@ -1333,7 +1327,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} else if (item.getItemId() == R.id.action_more_options_post_fragment) {
FABMoreOptionsBottomSheetFragment fabMoreOptionsBottomSheetFragment= new FABMoreOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, accountName.equals(Account.ANONYMOUS_ACCOUNT));
+ bundle.putBoolean(FABMoreOptionsBottomSheetFragment.EXTRA_ANONYMOUS_MODE, activity.accountName.equals(Account.ANONYMOUS_ACCOUNT));
fabMoreOptionsBottomSheetFragment.setArguments(bundle);
fabMoreOptionsBottomSheetFragment.show(activity.getSupportFragmentManager(), fabMoreOptionsBottomSheetFragment.getTag());
return true;
@@ -1465,7 +1459,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (savePostFeedScrolledPosition && postType == PostPagingSource.TYPE_FRONT_PAGE && sortType != null && sortType.getType() == SortType.Type.BEST && mAdapter != null) {
Post currentPost = mAdapter.getItemByPosition(maxPosition);
if (currentPost != null) {
- String accountNameForCache = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
+ String accountNameForCache = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : activity.accountName;
String key = accountNameForCache + SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_FRONT_PAGE_BASE;
String value = currentPost.getFullName();
mPostFeedScrolledPositionSharedPreferences.edit().putString(key, value).apply();
@@ -1745,7 +1739,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} else {
if (isSubreddit) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase,
- subredditOrUserName, accessToken, accountName, mOauthRetrofit, mRetrofit,
+ subredditOrUserName, activity.accessToken, activity.accountName, mOauthRetrofit, mRetrofit,
iconImageUrl -> {
subredditOrUserIcons.put(subredditOrUserName, iconImageUrl);
loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
index 6e8bfb14..419ace1b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
@@ -65,8 +65,6 @@ import retrofit2.Retrofit;
public class SidebarFragment extends Fragment {
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
public SubredditViewModel mSubredditViewModel;
@BindView(R.id.swipe_refresh_layout_sidebar_fragment)
SwipeRefreshLayout swipeRefreshLayout;
@@ -85,8 +83,6 @@ public class SidebarFragment extends Fragment {
@Inject
Executor mExecutor;
private ViewSubredditDetailActivity activity;
- private String mAccessToken;
- private String mAccountName;
private String subredditName;
private LinearLayoutManagerBugFixed linearLayoutManager;
private int markdownColor;
@@ -110,8 +106,6 @@ public class SidebarFragment extends Fragment {
EventBus.getDefault().register(this);
- mAccessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- mAccountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME);
if (subredditName == null) {
Toast.makeText(activity, R.string.error_getting_subreddit_name, Toast.LENGTH_SHORT).show();
@@ -250,7 +244,7 @@ public class SidebarFragment extends Fragment {
public void fetchSubredditData() {
swipeRefreshLayout.setRefreshing(true);
- FetchSubredditData.fetchSubredditData(mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
+ FetchSubredditData.fetchSubredditData(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, subredditName, activity.accessToken, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
swipeRefreshLayout.setRefreshing(false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
index df44a605..f3ade357 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
@@ -59,8 +59,6 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
public static final String EXTRA_QUERY = "EQ";
public static final String EXTRA_IS_GETTING_SUBREDDIT_INFO = "EIGSI";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
public static final String EXTRA_IS_MULTI_SELECTION = "EIMS";
@BindView(R.id.coordinator_layout_subreddit_listing_fragment)
@@ -136,15 +134,13 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
String query = getArguments().getString(EXTRA_QUERY);
boolean isGettingSubredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_SUBREDDIT_INFO);
- String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, SortType.Type.RELEVANCE.value);
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
- boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mActivity.accountName) + SharedPreferencesUtils.NSFW_BASE, false);
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRetrofit,
- mCustomThemeWrapper, accessToken, accountName,
+ mCustomThemeWrapper, mActivity.accessToken, mActivity.accountName,
mRedditDataRoomDatabase, getArguments().getBoolean(EXTRA_IS_MULTI_SELECTION, false),
new SubredditListingRecyclerViewAdapter.Callback() {
@Override
@@ -180,7 +176,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
}
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(
- mOauthRetrofit, query, sortType, accessToken, accountName, nsfw);
+ mOauthRetrofit, query, sortType, mActivity.accessToken, mActivity.accountName, nsfw);
mSubredditListingViewModel = new ViewModelProvider(this, factory).get(SubredditListingViewModel.class);
mSubredditListingViewModel.getSubreddits().observe(getViewLifecycleOwner(), subredditData -> mAdapter.submitList(subredditData));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java
index cda55e3b..a8925ddb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java
@@ -51,8 +51,6 @@ import retrofit2.Retrofit;
*/
public class SubscribedSubredditsListingFragment extends Fragment implements FragmentCommunicator {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_ACCOUNT_PROFILE_IMAGE_URL = "EAPIU";
public static final String EXTRA_IS_SUBREDDIT_SELECTION = "EISS";
public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
@@ -110,10 +108,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
}
}
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
- String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
-
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
mSwipeRefreshLayout.setEnabled(false);
}
@@ -125,18 +120,18 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
SubscribedSubredditsRecyclerViewAdapter adapter;
if (getArguments().getBoolean(EXTRA_IS_SUBREDDIT_SELECTION)) {
adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRedditDataRoomDatabase,
- mCustomThemeWrapper, accessToken, accountName, getArguments().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION),
+ mCustomThemeWrapper, mActivity.accessToken, mActivity.accountName, getArguments().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION),
(name, iconUrl, subredditIsUser) -> ((SubredditSelectionActivity) mActivity).getSelectedSubreddit(name, iconUrl, subredditIsUser));
} else {
adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRedditDataRoomDatabase,
- mCustomThemeWrapper, accessToken, accountName);
+ mCustomThemeWrapper, mActivity.accessToken, mActivity.accountName);
}
mRecyclerView.setAdapter(adapter);
new FastScrollerBuilder(mRecyclerView).useMd2Style().build();
mSubscribedSubredditViewModel = new ViewModelProvider(this,
- new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountName))
+ new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, mActivity.accountName))
.get(SubscribedSubredditViewModel.class);
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(getViewLifecycleOwner(), subscribedSubredditData -> {
mSwipeRefreshLayout.setRefreshing(false);
@@ -150,8 +145,8 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
mGlide.clear(mImageView);
}
- if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
- adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
+ if (!mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ adapter.addUser(mActivity.accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
}
adapter.setSubscribedSubreddits(subscribedSubredditData);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
index e0122c63..69136dd1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
@@ -60,8 +60,6 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
public static final String EXTRA_QUERY = "EQ";
public static final String EXTRA_IS_GETTING_USER_INFO = "EIGUI";
public static final String EXTRA_IS_MULTI_SELECTION = "EIMS";
- public static final String EXTRA_ACCESS_TOKEN = "EAT";
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
@BindView(R.id.coordinator_layout_user_listing_fragment)
CoordinatorLayout mCoordinatorLayout;
@@ -137,14 +135,12 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
mQuery = getArguments().getString(EXTRA_QUERY);
boolean isGettingUserInfo = getArguments().getBoolean(EXTRA_IS_GETTING_USER_INFO);
- String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, SortType.Type.RELEVANCE.value);
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
- boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mActivity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mActivity.accountName) + SharedPreferencesUtils.NSFW_BASE, false);
mAdapter = new UserListingRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRetrofit,
- mCustomThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase,
+ mCustomThemeWrapper, mActivity.accessToken, mActivity.accountName, mRedditDataRoomDatabase,
getArguments().getBoolean(EXTRA_IS_MULTI_SELECTION, false),
new UserListingRecyclerViewAdapter.Callback() {
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index 548f7e2f..615f411c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -221,8 +221,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
private RequestManager mGlide;
private Locale mLocale;
private Menu mMenu;
- private String mAccessToken;
- private String mAccountName;
private int postListPosition = -1;
private String mSingleCommentId;
private String mContextNumber;
@@ -273,9 +271,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mRecyclerView.addOnWindowFocusChangedListener(this::onWindowFocusChanged);
- mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
-
mSavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_toolbar_24dp);
mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp);
@@ -305,7 +300,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(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
if (savedInstanceState == null) {
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
viewPostDetailFragmentId = System.currentTimeMillis();
@@ -570,8 +565,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
private void bindView() {
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && mMessageFullname != null) {
- ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) && mMessageFullname != null) {
+ ReadMessage.readMessage(mOauthRetrofit, activity.accessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
@Override
public void readSuccess() {
mMessageFullname = null;
@@ -596,12 +591,12 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
this, mExecutor, mCustomThemeWrapper, mOauthRetrofit, mRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide,
- mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
+ mSeparatePostAndComments, activity.accessToken, activity.accountName, mPost, mLocale,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
this, mCustomThemeWrapper, mExecutor, mRetrofit, mOauthRetrofit,
- mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
+ activity.accessToken, activity.accountName, mPost, mLocale, mSingleCommentId,
isSingleCommentThreadMode, mSharedPreferences, mNsfwAndSpoilerSharedPreferences,
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
@@ -676,7 +671,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mMenu.findItem(R.id.action_comment_view_post_detail_fragment).setVisible(true);
mMenu.findItem(R.id.action_sort_view_post_detail_fragment).setVisible(true);
- if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPost.isSaved()) {
saveItem.setVisible(true);
saveItem.setIcon(mSavedIcon);
@@ -697,7 +692,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
hideItem.setVisible(false);
}
- if (mPost.getAuthor().equals(mAccountName)) {
+ if (mPost.getAuthor().equals(activity.accountName)) {
if (mPost.getPostType() == Post.TEXT_TYPE) {
mMenu.findItem(R.id.action_edit_view_post_detail_fragment).setVisible(true);
}
@@ -789,7 +784,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
params.put(APIUtils.TEXT_KEY, flair.getText());
mOauthRetrofit.create(RedditAPI.class).selectFlair(mPost.getSubredditNamePrefixed(),
- APIUtils.getOAuthHeader(mAccessToken), params).enqueue(new Callback<String>() {
+ APIUtils.getOAuthHeader(activity.accessToken), params).enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
@@ -943,7 +938,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
return true;
}
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
showMessage(R.string.login_first);
return true;
}
@@ -960,10 +955,10 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
return true;
} else if (itemId == R.id.action_save_view_post_detail_fragment) {
- if (mPost != null && !mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (mPost != null && !activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPost.isSaved()) {
item.setIcon(mUnsavedIcon);
- SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
+ SaveThing.unsaveThing(mOauthRetrofit, activity.accessToken, mPost.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -987,7 +982,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
});
} else {
item.setIcon(mSavedIcon);
- SaveThing.saveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
+ SaveThing.saveThing(mOauthRetrofit, activity.accessToken, mPost.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -1024,11 +1019,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
startActivity(crosspostIntent);
return true;
} else if (itemId == R.id.action_hide_view_post_detail_fragment) {
- if (mPost != null && !mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (mPost != null && !activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (mPost.isHidden()) {
Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_hide_post));
- HidePost.unhidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() {
+ HidePost.unhidePost(mOauthRetrofit, activity.accessToken, mPost.getFullName(), new HidePost.HidePostListener() {
@Override
public void success() {
mPost.setHidden(false);
@@ -1048,7 +1043,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} else {
Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_unhide_post));
- HidePost.hidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() {
+ HidePost.hidePost(mOauthRetrofit, activity.accessToken, mPost.getFullName(), new HidePost.HidePostListener() {
@Override
public void success() {
mPost.setHidden(true);
@@ -1080,7 +1075,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
.setTitle(R.string.delete_this_post)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.delete, (dialogInterface, i)
- -> DeleteThing.delete(mOauthRetrofit, mPost.getFullName(), mAccessToken, new DeleteThing.DeleteThingListener() {
+ -> DeleteThing.delete(mOauthRetrofit, mPost.getFullName(), activity.accessToken, new DeleteThing.DeleteThingListener() {
@Override
public void deleteSuccess() {
Toast.makeText(activity, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
@@ -1112,14 +1107,13 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} else if (itemId == R.id.action_edit_flair_view_post_detail_fragment) {
FlairBottomSheetFragment flairBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
- bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
bundle.putLong(FlairBottomSheetFragment.EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID, viewPostDetailFragmentId);
flairBottomSheetFragment.setArguments(bundle);
flairBottomSheetFragment.show(activity.getSupportFragmentManager(), flairBottomSheetFragment.getTag());
return true;
} else if (itemId == R.id.action_report_view_post_detail_fragment) {
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
@@ -1171,7 +1165,7 @@ 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());
+ InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, activity.accountName, mPost.getId());
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
}
@@ -1251,7 +1245,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mGlide.clear(mFetchPostInfoImageView);
Call<String> postAndComments;
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (isSingleCommentThreadMode && mSingleCommentId != null) {
postAndComments = mRetrofit.create(RedditAPI.class).getPostAndCommentsSingleThreadById(
subredditId, mSingleCommentId, sortType, mContextNumber);
@@ -1262,10 +1256,10 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} else {
if (isSingleCommentThreadMode && mSingleCommentId != null) {
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsSingleThreadByIdOauth(subredditId,
- mSingleCommentId, sortType, mContextNumber, APIUtils.getOAuthHeader(mAccessToken));
+ mSingleCommentId, sortType, mContextNumber, APIUtils.getOAuthHeader(activity.accessToken));
} else {
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsByIdOauth(subredditId,
- sortType, APIUtils.getOAuthHeader(mAccessToken));
+ sortType, APIUtils.getOAuthHeader(activity.accessToken));
}
}
postAndComments.enqueue(new Callback<>() {
@@ -1289,14 +1283,14 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
mOauthRetrofit, mRetrofit, mRedgifsRetrofit,
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
- mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
+ activity.accessToken, activity.accountName, mPost, mLocale, mSharedPreferences,
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mPostDetailsSharedPreferences, mExoCreator,
post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
- mRetrofit, mOauthRetrofit, mAccessToken, mAccountName, mPost, mLocale,
+ mRetrofit, mOauthRetrofit, activity.accessToken, activity.accountName, mPost, mLocale,
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
mNsfwAndSpoilerSharedPreferences,
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@@ -1434,7 +1428,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
e.printStackTrace();
}
}
- FetchSubredditData.fetchSubredditData(mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, mPost.getSubredditName(), mAccessToken,
+ FetchSubredditData.fetchSubredditData(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? null : mOauthRetrofit, mRetrofit, mPost.getSubredditName(), activity.accessToken,
new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
@@ -1478,8 +1472,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
commentId = mSingleCommentId;
}
- Retrofit retrofit = mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit;
- FetchComment.fetchComments(mExecutor, new Handler(), retrofit, mAccessToken, mAccountName, mPost.getId(), commentId, sortType,
+ Retrofit retrofit = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit;
+ FetchComment.fetchComments(mExecutor, new Handler(), retrofit, activity.accessToken, activity.accountName, mPost.getId(), commentId, sortType,
mContextNumber, mExpandChildren, mCommentFilter, new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments,
@@ -1565,8 +1559,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
isLoadingMoreChildren = true;
- Retrofit retrofit = mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit;
- FetchComment.fetchMoreComment(mExecutor, new Handler(), retrofit, mAccessToken, mAccountName,
+ Retrofit retrofit = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit;
+ FetchComment.fetchMoreComment(mExecutor, new Handler(), retrofit, activity.accessToken, activity.accountName,
children, mExpandChildren, mPost.getFullName(), sortType, new FetchComment.FetchMoreCommentListener() {
@Override
public void onFetchMoreCommentSuccess(ArrayList<Comment> topLevelComments,
@@ -1601,12 +1595,12 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (fetchPost) {
Retrofit retrofit;
- if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
retrofit = mRetrofit;
} else {
retrofit = mOauthRetrofit;
}
- FetchPost.fetchPost(mExecutor, new Handler(), retrofit, mPost.getId(), mAccessToken, mAccountName,
+ FetchPost.fetchPost(mExecutor, new Handler(), retrofit, mPost.getId(), activity.accessToken, activity.accountName,
new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
@@ -1660,7 +1654,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
Map<String, String> params = new HashMap<>();
params.put(APIUtils.ID_KEY, mPost.getFullName());
- mOauthRetrofit.create(RedditAPI.class).markNSFW(APIUtils.getOAuthHeader(mAccessToken), params)
+ mOauthRetrofit.create(RedditAPI.class).markNSFW(APIUtils.getOAuthHeader(activity.accessToken), params)
.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
@@ -1698,7 +1692,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
Map<String, String> params = new HashMap<>();
params.put(APIUtils.ID_KEY, mPost.getFullName());
- mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(APIUtils.getOAuthHeader(mAccessToken), params)
+ mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(APIUtils.getOAuthHeader(activity.accessToken), params)
.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
@@ -1736,7 +1730,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
Map<String, String> params = new HashMap<>();
params.put(APIUtils.ID_KEY, mPost.getFullName());
- mOauthRetrofit.create(RedditAPI.class).markSpoiler(APIUtils.getOAuthHeader(mAccessToken), params)
+ mOauthRetrofit.create(RedditAPI.class).markSpoiler(APIUtils.getOAuthHeader(activity.accessToken), params)
.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
@@ -1774,7 +1768,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
Map<String, String> params = new HashMap<>();
params.put(APIUtils.ID_KEY, mPost.getFullName());
- mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(APIUtils.getOAuthHeader(mAccessToken), params)
+ mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(APIUtils.getOAuthHeader(activity.accessToken), params)
.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
@@ -1810,7 +1804,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
.setTitle(R.string.delete_this_comment)
.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.delete, (dialogInterface, i)
- -> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() {
+ -> DeleteThing.delete(mOauthRetrofit, fullName, activity.accessToken, new DeleteThing.DeleteThingListener() {
@Override
public void deleteSuccess() {
Toast.makeText(activity, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
index 15531189..8bcabd05 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
@@ -33,8 +33,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class CustomizeBottomAppBarFragment extends Fragment {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
-
@BindView(R.id.info_text_view_customize_bottom_app_bar_fragment)
TextView infoTextView;
@BindView(R.id.main_activity_group_summary_customize_bottom_app_bar_fragment)
@@ -155,19 +153,17 @@ public class CustomizeBottomAppBarFragment extends Fragment {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
-
Resources resources = activity.getResources();
String[] mainActivityOptions = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options);
String[] mainActivityOptionAnonymous = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options_anonymous);
String[] mainActivityOptionAnonymousValues = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options_anonymous_values);
String[] fabOptions;
- mainActivityOptionCount = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- mainActivityOption1 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, 0);
- mainActivityOption2 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, 1);
- mainActivityOption3 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, 2);
- mainActivityOption4 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, 3);
- mainActivityFAB = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? 7: 0);
+ mainActivityOptionCount = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ mainActivityOption1 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, 0);
+ mainActivityOption2 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, 1);
+ mainActivityOption3 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, 2);
+ mainActivityOption4 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, 3);
+ mainActivityFAB = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? 7: 0);
mainActivityOption1 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption1);
mainActivityOption2 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption2);
@@ -180,7 +176,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]);
mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]);
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options_anonymous);
ArrayList<String> mainActivityOptionAnonymousValuesList = new ArrayList<>(Arrays.asList(mainActivityOptionAnonymousValues));
mainActivityOption1 = mainActivityOptionAnonymousValuesList.indexOf(Integer.toString(mainActivityOption1));
@@ -200,7 +196,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
.setTitle(R.string.settings_tab_count)
.setSingleChoiceItems(R.array.settings_bottom_app_bar_option_count_options, mainActivityOptionCount / 2 - 1, (dialogInterface, i) -> {
mainActivityOptionCount = (i + 1) * 2;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, mainActivityOptionCount).apply();
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, mainActivityOptionCount).apply();
mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount));
dialogInterface.dismiss();
})
@@ -210,10 +206,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption1LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_1)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> {
mainActivityOption1 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption1;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption1;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
mainActivityOption1TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -223,10 +219,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption2LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_2)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> {
mainActivityOption2 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption2;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption2;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
mainActivityOption2TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -236,10 +232,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption3LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_3)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> {
mainActivityOption3 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption3;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption3;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
mainActivityOption3TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -249,10 +245,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption4LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_4)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> {
mainActivityOption4 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption4;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption4;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
mainActivityOption4TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -265,7 +261,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
.setSingleChoiceItems(fabOptions, mainActivityFAB, (dialogInterface, i) -> {
mainActivityFAB = i;
int optionToSaveToPreference;
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (i >= 7) {
optionToSaveToPreference = i + 2;
} else {
@@ -274,7 +270,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
} else {
optionToSaveToPreference = i;
}
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply();
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply();
mainActivityFABTextView.setText(fabOptions[mainActivityFAB]);
dialogInterface.dismiss();
})
@@ -284,12 +280,12 @@ public class CustomizeBottomAppBarFragment extends Fragment {
String[] otherActivitiesOptions = resources.getStringArray(R.array.settings_other_activities_bottom_app_bar_options);
String[] otherActivitiesOptionAnonymous = resources.getStringArray(R.array.settings_other_activities_bottom_app_bar_options_anonymous);
String[] otherActivitiesOptionAnonymousValues = resources.getStringArray(R.array.settings_other_activities_bottom_app_bar_options_anonymous_values);
- otherActivitiesOptionCount = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- otherActivitiesOption1 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, 0);
- otherActivitiesOption2 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, 1);
- otherActivitiesOption3 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, 2);
- otherActivitiesOption4 = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, 3);
- otherActivitiesFAB = sharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? 7: 0);
+ otherActivitiesOptionCount = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
+ otherActivitiesOption1 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, 0);
+ otherActivitiesOption2 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, 1);
+ otherActivitiesOption3 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, 2);
+ otherActivitiesOption4 = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, 3);
+ otherActivitiesFAB = sharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? 7: 0);
otherActivitiesOption1 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption1);
otherActivitiesOption2 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption2);
@@ -302,7 +298,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]);
otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]);
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
ArrayList<String> otherActivitiesOptionAnonymousValuesList = new ArrayList<>(Arrays.asList(otherActivitiesOptionAnonymousValues));
otherActivitiesOption1 = otherActivitiesOptionAnonymousValuesList.indexOf(Integer.toString(otherActivitiesOption1));
otherActivitiesOption2 = otherActivitiesOptionAnonymousValuesList.indexOf(Integer.toString(otherActivitiesOption2));
@@ -318,7 +314,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
.setTitle(R.string.settings_tab_count)
.setSingleChoiceItems(R.array.settings_bottom_app_bar_option_count_options, otherActivitiesOptionCount / 2 - 1, (dialogInterface, i) -> {
otherActivitiesOptionCount = (i + 1) * 2;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, otherActivitiesOptionCount).apply();
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, otherActivitiesOptionCount).apply();
otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount));
dialogInterface.dismiss();
})
@@ -328,10 +324,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption1LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_1)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> {
otherActivitiesOption1 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption1;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption1;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
otherActivitiesOption1TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -341,10 +337,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption2LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_2)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> {
otherActivitiesOption2 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption2;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption2;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
otherActivitiesOption2TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -354,10 +350,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption3LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_3)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> {
otherActivitiesOption3 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption3;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption3;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
otherActivitiesOption3TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -367,10 +363,10 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption4LinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_bottom_app_bar_option_4)
- .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> {
+ .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> {
otherActivitiesOption4 = i;
- int optionToSaveToPreference = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption4;
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
+ int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption4;
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
otherActivitiesOption4TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -383,7 +379,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
.setSingleChoiceItems(fabOptions, otherActivitiesFAB, (dialogInterface, i) -> {
otherActivitiesFAB = i;
int optionToSaveToPreference;
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (i >= 7) {
optionToSaveToPreference = i + 2;
} else {
@@ -392,7 +388,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
} else {
optionToSaveToPreference = i;
}
- sharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply();
+ sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply();
otherActivitiesFABTextView.setText(fabOptions[otherActivitiesFAB]);
dialogInterface.dismiss();
})
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
index 083a547d..44d07901 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
@@ -41,8 +41,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class CustomizeMainPageTabsFragment extends Fragment {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
-
@BindView(R.id.info_text_view_customize_main_page_tabs_fragment)
TextView infoTextView;
@BindView(R.id.tab_count_linear_layout_customize_main_page_tabs_fragment)
@@ -163,7 +161,6 @@ public class CustomizeMainPageTabsFragment extends Fragment {
@Named("main_activity_tabs")
SharedPreferences mainActivityTabsSharedPreferences;
private SettingsActivity activity;
- private String accountName;
private int tabCount;
private String tab1CurrentTitle;
private int tab1CurrentPostType;
@@ -196,40 +193,38 @@ public class CustomizeMainPageTabsFragment extends Fragment {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
- accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
-
String[] typeValues;
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
typeValues = activity.getResources().getStringArray(R.array.settings_tab_post_type_anonymous);
} else {
typeValues = activity.getResources().getStringArray(R.array.settings_tab_post_type);
}
- tabCount = mainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
+ tabCount = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
tabCountTextView.setText(Integer.toString(tabCount));
tabCountLinearLayout.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.settings_tab_count)
.setSingleChoiceItems(R.array.settings_main_page_tab_count, tabCount - 1, (dialogInterface, i) -> {
tabCount = i + 1;
- mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, tabCount).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, tabCount).apply();
tabCountTextView.setText(Integer.toString(tabCount));
dialogInterface.dismiss();
})
.show();
});
- boolean showTabNames = mainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true);
+ boolean showTabNames = mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true);
showTabNamesSwitch.setChecked(showTabNames);
- showTabNamesSwitch.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, b).apply());
+ showTabNamesSwitch.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, b).apply());
showTabNamesLinearLayout.setOnClickListener(view -> showTabNamesSwitch.performClick());
- tab1CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home));
- tab1CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
- if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ tab1CurrentTitle = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home));
+ tab1CurrentPostType = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
tab1CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab1CurrentPostType, 1);
}
- tab1CurrentName = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
+ tab1CurrentName = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
tab1TypeSummaryTextView.setText(typeValues[tab1CurrentPostType]);
tab1TitleSummaryTextView.setText(tab1CurrentTitle);
tab1NameSummaryTextView.setText(tab1CurrentName);
@@ -252,7 +247,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab1CurrentTitle = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, tab1CurrentTitle).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, tab1CurrentTitle).apply();
tab1TitleSummaryTextView.setText(tab1CurrentTitle);
Utils.hideKeyboard(activity);
})
@@ -267,7 +262,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setTitle(R.string.settings_tab_title)
.setSingleChoiceItems(typeValues, tab1CurrentPostType, (dialogInterface, i) -> {
tab1CurrentPostType = i;
- mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply();
tab1TypeSummaryTextView.setText(typeValues[i]);
applyTab1NameView(tab1NameConstraintLayout, tab1NameTitleTextView, i);
dialogInterface.dismiss();
@@ -304,7 +299,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab1CurrentName = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
tab1NameSummaryTextView.setText(tab1CurrentName);
Utils.hideKeyboard(activity);
})
@@ -316,12 +311,12 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab1AddImageView.setOnClickListener(view -> selectName(0));
- tab2CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular));
- tab2CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
- if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ tab2CurrentTitle = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular));
+ tab2CurrentPostType = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
tab2CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab2CurrentPostType, 1);
}
- tab2CurrentName = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
+ tab2CurrentName = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
tab2TypeSummaryTextView.setText(typeValues[tab2CurrentPostType]);
tab2TitleSummaryTextView.setText(tab2CurrentTitle);
tab2NameSummaryTextView.setText(tab2CurrentName);
@@ -341,7 +336,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab2CurrentTitle = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, tab2CurrentTitle).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, tab2CurrentTitle).apply();
tab2TitleSummaryTextView.setText(tab2CurrentTitle);
Utils.hideKeyboard(activity);
})
@@ -356,7 +351,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setTitle(R.string.settings_tab_title)
.setSingleChoiceItems(typeValues, tab2CurrentPostType, (dialogInterface, i) -> {
tab2CurrentPostType = i;
- mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply();
tab2TypeSummaryTextView.setText(typeValues[i]);
applyTab2NameView(tab2NameConstraintLayout, tab2NameTitleTextView, i);
dialogInterface.dismiss();
@@ -393,7 +388,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab2CurrentName = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
tab2NameSummaryTextView.setText(tab2CurrentName);
Utils.hideKeyboard(activity);
})
@@ -405,12 +400,12 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab2AddImageView.setOnClickListener(view -> selectName(1));
- tab3CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all));
- tab3CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
- if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ tab3CurrentTitle = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all));
+ tab3CurrentPostType = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
+ if (!activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
tab3CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab3CurrentPostType, 1);
}
- tab3CurrentName = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
+ tab3CurrentName = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
tab3TypeSummaryTextView.setText(typeValues[tab3CurrentPostType]);
tab3TitleSummaryTextView.setText(tab3CurrentTitle);
tab3NameSummaryTextView.setText(tab3CurrentName);
@@ -430,7 +425,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab3CurrentTitle = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, tab3CurrentTitle).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, tab3CurrentTitle).apply();
tab3TitleSummaryTextView.setText(tab3CurrentTitle);
Utils.hideKeyboard(activity);
})
@@ -445,7 +440,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setTitle(R.string.settings_tab_title)
.setSingleChoiceItems(typeValues, tab3CurrentPostType, (dialogInterface, i) -> {
tab3CurrentPostType = i;
- mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply();
tab3TypeSummaryTextView.setText(typeValues[i]);
applyTab3NameView(tab3NameConstraintLayout, tab3NameTitleTextView, i);
dialogInterface.dismiss();
@@ -482,7 +477,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab3CurrentName = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
tab3NameSummaryTextView.setText(tab3CurrentName);
Utils.hideKeyboard(activity);
})
@@ -494,26 +489,26 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab3AddImageView.setOnClickListener(view -> selectName(2));
- showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
- showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
+ showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
+ showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
showMultiredditsLinearLayout.setOnClickListener(view -> {
showMultiredditsSwitchMaterial.performClick();
});
- showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
- showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
+ showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
+ showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
showFavoriteMultiredditsSwitchMaterial.performClick();
});
- showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
- showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
+ showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
+ showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
showSubscribedSubredditsSwitchMaterial.performClick();
});
- showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
- showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
+ showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
+ showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
});
@@ -696,54 +691,54 @@ public class CustomizeMainPageTabsFragment extends Fragment {
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) {
tab1CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
tab1NameSummaryTextView.setText(tab1CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
} else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) {
MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT);
if (multireddit != null) {
tab1CurrentName = multireddit.getPath();
tab1NameSummaryTextView.setText(tab1CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
}
} else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) {
tab1CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME);
tab1NameSummaryTextView.setText(tab1CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
}
break;
case 1:
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) {
tab2CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
tab2NameSummaryTextView.setText(tab2CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
} else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) {
MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT);
if (multireddit != null) {
tab2CurrentName = multireddit.getPath();
tab2NameSummaryTextView.setText(tab2CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
}
} else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) {
tab2CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME);
tab2NameSummaryTextView.setText(tab2CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
}
break;
case 2:
if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) {
tab3CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
tab3NameSummaryTextView.setText(tab3CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
} else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) {
MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT);
if (multireddit != null) {
tab3CurrentName = multireddit.getPath();
tab3NameSummaryTextView.setText(tab3CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
}
} else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) {
tab3CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME);
tab3NameSummaryTextView.setText(tab3CurrentName);
- mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
}
break;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
index a75cd76d..e003df8f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
@@ -34,8 +34,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class NsfwAndSpoilerFragment extends Fragment {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
-
@BindView(R.id.enable_nsfw_linear_layout_nsfw_and_spoiler_fragment)
LinearLayout enableNsfwLinearLayout;
@BindView(R.id.enable_nsfw_text_view_nsfw_and_spoiler_fragment)
@@ -103,12 +101,10 @@ public class NsfwAndSpoilerFragment extends Fragment {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
-
- boolean enableNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
- blurNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
- doNotBlurNsfwInNsfwSubreddits = nsfwAndBlurringSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
- boolean blurSpoiler = nsfwAndBlurringSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
+ boolean enableNsfw = nsfwAndBlurringSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ blurNsfw = nsfwAndBlurringSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ doNotBlurNsfwInNsfwSubreddits = nsfwAndBlurringSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
+ boolean blurSpoiler = nsfwAndBlurringSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
disableNsfwForever = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false);
if (enableNsfw) {
@@ -129,7 +125,7 @@ public class NsfwAndSpoilerFragment extends Fragment {
enableNsfwLinearLayout.setOnClickListener(view -> enableNsfwSwitchMaterial.performClick());
enableNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply();
if (b) {
blurNsfwLinearLayout.setVisibility(View.VISIBLE);
doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.VISIBLE);
@@ -142,7 +138,7 @@ public class NsfwAndSpoilerFragment extends Fragment {
blurNsfwLinearLayout.setOnClickListener(view -> blurNsfwSwitchMaterial.performClick());
blurNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, b).apply();
EventBus.getDefault().post(new ChangeNSFWBlurEvent(b, doNotBlurNsfwInNsfwSubreddits));
});
@@ -150,13 +146,13 @@ public class NsfwAndSpoilerFragment extends Fragment {
doNotBlurNsfwInNsfwSubredditsSwitch.performClick();
});
doNotBlurNsfwInNsfwSubredditsSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, b).apply();
EventBus.getDefault().post(new ChangeNSFWBlurEvent(blurNsfw, b));
});
blurSpoilerLinearLayout.setOnClickListener(view -> blurSpoilerSwitchMaterial.performClick());
blurSpoilerSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, b).apply();
EventBus.getDefault().post(new ChangeSpoilerBlurEvent(b));
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
index f2cd8965..8c446ceb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
@@ -29,8 +29,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class PostHistoryFragment extends Fragment {
- public static final String EXTRA_ACCOUNT_NAME = "EAN";
-
@BindView(R.id.info_text_view_post_history_fragment)
TextView infoTextView;
@BindView(R.id.mark_posts_as_read_linear_layout_post_history_fragment)
@@ -83,8 +81,7 @@ public class PostHistoryFragment extends Fragment {
Utils.setFontToAllTextViews(rootView, activity.typeface);
}
- String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
- if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
infoTextView.setText(R.string.only_for_logged_in_user);
markPostsAsReadLinearLayout.setVisibility(View.GONE);
markPostsAsReadAfterVotingLinearLayout.setVisibility(View.GONE);
@@ -94,33 +91,33 @@ public class PostHistoryFragment extends Fragment {
}
markPostsAsReadSwitch.setChecked(postHistorySharedPreferences.getBoolean(
- accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false));
+ activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false));
markPostsAsReadAfterVotingSwitch.setChecked(postHistorySharedPreferences.getBoolean(
- accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false));
+ activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false));
markPostsAsReadOnScrollSwitch.setChecked(postHistorySharedPreferences.getBoolean(
- accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, false));
+ activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, false));
hideReadPostsAutomaticallySwitch.setChecked(postHistorySharedPreferences.getBoolean(
- accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
+ activity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
markPostsAsReadLinearLayout.setOnClickListener(view -> {
markPostsAsReadSwitch.performClick();
});
markPostsAsReadSwitch.setOnCheckedChangeListener((compoundButton, b) ->
- postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, b).apply());
+ postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, b).apply());
markPostsAsReadAfterVotingLinearLayout.setOnClickListener(view -> markPostsAsReadAfterVotingSwitch.performClick());
markPostsAsReadAfterVotingSwitch.setOnCheckedChangeListener((compoundButton, b) ->
- postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, b).apply());
+ postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, b).apply());
markPostsAsReadOnScrollLinearLayout.setOnClickListener(view -> markPostsAsReadOnScrollSwitch.performClick());
- markPostsAsReadOnScrollSwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, b).apply());
+ markPostsAsReadOnScrollSwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, b).apply());
hideReadPostsAutomaticallyLinearLayout.setOnClickListener(view -> hideReadPostsAutomaticallySwitch.performClick());
- hideReadPostsAutomaticallySwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply());
+ hideReadPostsAutomaticallySwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply());
return rootView;
}