aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-01 07:04:12 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-01-01 07:04:12 +0000
commit7d656d90ee8c3c44fac51a2cfde4ae60f9937208 (patch)
treed12371b5a95709e6c4234fa05410a437a0163e94 /app/src/main
parent5ec25cb921503bbbcabc207e7d84a51ff5780b3c (diff)
downloadinfinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.tar
infinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.tar.gz
infinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.tar.bz2
infinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.tar.lz
infinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.tar.xz
infinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.tar.zst
infinity-for-reddit-7d656d90ee8c3c44fac51a2cfde4ae60f9937208.zip
Use accountName.equals(Account.ANONYMOUS_ACCOUNT) instead of accountName == null or accountName != null.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java44
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsFollowingUser.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java88
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java87
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java3
30 files changed, 184 insertions, 172 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java
index 4ac78c1b..08f859d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java
@@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubscribedThings;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
@@ -22,10 +23,10 @@ import retrofit2.Retrofit;
public class FavoriteThing {
public static void favoriteSubreddit(Executor executor, Handler handler, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
- @Nullable String accessToken, @Nullable String accountName,
+ @Nullable String accessToken, String accountName,
SubscribedSubredditData subscribedSubredditData,
FavoriteThingListener favoriteThingListener) {
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, subscribedSubredditData,
favoriteThingListener::success);
} else {
@@ -53,10 +54,10 @@ public class FavoriteThing {
public static void unfavoriteSubreddit(Executor executor, Handler handler, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
- @Nullable String accessToken, @Nullable String accountName,
+ @Nullable String accessToken, String accountName,
SubscribedSubredditData subscribedSubredditData,
FavoriteThingListener favoriteThingListener) {
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase,
subscribedSubredditData, favoriteThingListener::success);
} else {
@@ -84,10 +85,10 @@ public class FavoriteThing {
public static void favoriteUser(Executor executor, Handler handler, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
- @Nullable String accessToken, @Nullable String accountName,
+ @Nullable String accessToken, String accountName,
SubscribedUserData subscribedUserData,
FavoriteThingListener favoriteThingListener) {
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase,
subscribedUserData, favoriteThingListener::success);
} else {
@@ -115,10 +116,10 @@ public class FavoriteThing {
public static void unfavoriteUser(Executor executor, Handler handler, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
- @Nullable String accessToken, @Nullable String accountName,
+ @Nullable String accessToken, String accountName,
SubscribedUserData subscribedUserData,
FavoriteThingListener favoriteThingListener) {
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, subscribedUserData,
favoriteThingListener::success);
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java
index 127328d1..1837d6e5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPostFilterReadPostsAndConcatenatedSubredditNames.java
@@ -27,15 +27,15 @@ public class FetchPostFilterReadPostsAndConcatenatedSubredditNames {
executor.execute(() -> {
List<PostFilter> postFilters = redditDataRoomDatabase.postFilterDao().getValidPostFilters(postFilterUsage, nameOfUsage);
PostFilter mergedPostFilter = PostFilter.mergePostFilter(postFilters);
- if (accountName != null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
+ handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, null));
+ } else {
List<ReadPost> readPosts = redditDataRoomDatabase.readPostDao().getAllReadPosts(accountName);
ArrayList<String> readPostStrings = new ArrayList<>();
for (ReadPost readPost : readPosts) {
readPostStrings.add(readPost.getId());
}
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, readPostStrings));
- } else {
- handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, null));
}
});
}
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 f7c984f1..257ad00a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -164,7 +164,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
int filter = getIntent().getIntExtra(EXTRA_FILTER, -1000);
PostFilter postFilter = new PostFilter();
- postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null || mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
switch (filter) {
case Post.NSFW_TYPE:
postFilter.onlyNSFW = true;
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 0a02d0e6..3e019455 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
@@ -46,6 +46,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@@ -232,7 +233,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) {
if (mNewAccountName != null) {
- if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
+ if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
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 29f08f2d..4cf166f6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -387,7 +387,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
WorkManager workManager = WorkManager.getInstance(this);
if (mNewAccountName != null) {
- if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
+ if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -815,12 +815,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
} else if (stringId == R.string.enable_nsfw) {
if (sectionsPagerAdapter != null) {
- mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
+ mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
sectionsPagerAdapter.changeNSFW(true);
}
} else if (stringId == R.string.disable_nsfw) {
if (sectionsPagerAdapter != null) {
- mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
+ mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
sectionsPagerAdapter.changeNSFW(false);
}
} else if (stringId == R.string.settings) {
@@ -871,17 +871,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
navDrawerRecyclerView.setAdapter(adapter.getConcatAdapter());
- int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
- mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
- mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
- mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
- mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
+ 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);
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 == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
+ if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
} else {
@@ -890,13 +890,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 == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
+ Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
break;
case 1:
- Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
+ Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)));
break;
case 2:
- Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
+ Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
break;
}
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
@@ -944,7 +944,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
loadSubscriptions();
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
- mRedditDataRoomDatabase, mAccountName == null ? Account.ANONYMOUS_ACCOUNT : mAccountName))
+ mRedditDataRoomDatabase, mAccountName))
.get(MultiRedditViewModel.class);
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
@@ -960,7 +960,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
subscribedSubredditViewModel = new ViewModelProvider(this,
- new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName == null ? Account.ANONYMOUS_ACCOUNT : mAccountName))
+ new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
.get(SubscribedSubredditViewModel.class);
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
subscribedSubredditData -> {
@@ -1409,7 +1409,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1509,7 +1509,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 == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ 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));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
@@ -1560,8 +1560,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override
public Fragment createFragment(int position) {
if (position == 0) {
- int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
- String name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
+ 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, "");
return generatePostFragment(postType, name);
} else {
if (showFavoriteMultiReddits) {
@@ -1603,11 +1603,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int postType;
String name;
if (position == 1) {
- postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
- name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
+ 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, "");
} else {
- postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
- name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
+ 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, "");
}
return generatePostFragment(postType, name);
}
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 dc3eee4b..40108cd1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -177,7 +177,7 @@ public class SearchActivity extends BaseActivity {
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
subredditAutocompleteRecyclerViewAdapter = new SubredditAutocompleteRecyclerViewAdapter(this,
mCustomThemeWrapper, subredditData -> {
@@ -322,7 +322,7 @@ public class SearchActivity extends BaseActivity {
}
private void bindView() {
- if (mAccountName != null) {
+ if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
adapter = new SearchActivityRecyclerViewAdapter(this, mCustomThemeWrapper, new SearchActivityRecyclerViewAdapter.ItemOnClickListener() {
@Override
public void onClick(String query) {
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 e02c9332..2cd11f5e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
@@ -389,7 +389,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
return true;
});
- if (mAccountName != null && mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
+ if (!mAccountName.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);
}
@@ -606,7 +606,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -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 == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ 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));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
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 801dd5a5..c6f50425 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
@@ -25,6 +25,7 @@ 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;
@@ -81,7 +82,7 @@ public class SettingsActivity extends BaseActivity implements
setSupportActionBar(binding.toolbarSettingsActivity);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
+ mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, Account.ANONYMOUS_ACCOUNT);
if (savedInstanceState == null) {
getSupportFragmentManager()
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 c40496c0..bc22542b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
@@ -499,7 +499,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
MultiRedditListingFragment fragment = new MultiRedditListingFragment();
Bundle bundle = new Bundle();
bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? Account.ANONYMOUS_ACCOUNT : mAccountName);
+ bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
fragment.setArguments(bundle);
return fragment;
}
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 bfeb6135..ce78d3c9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -614,7 +614,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -714,7 +714,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 == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ 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));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
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 3e1d732b..6ba110d7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -350,7 +350,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private void checkNewAccountAndBindView(Bundle savedInstanceState) {
if (mNewAccountName != null) {
- if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
+ if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
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 939b2cd8..3f8c21cc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -479,7 +479,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (subredditData.isNSFW()) {
if (nsfwWarningBuilder == null
- && mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) || !mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false)) {
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) || !mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false)) {
nsfwWarningBuilder = new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.warning)
.setMessage(R.string.this_is_a_nsfw_subreddit)
@@ -558,7 +558,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void checkNewAccountAndBindView() {
if (mNewAccountName != null) {
- if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
+ if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -1434,7 +1434,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -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 == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ 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));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
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 3d11bfbe..f4ab4b87 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -555,7 +555,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
/*if (userData.isNSFW()) {
if (nsfwWarningBuilder == null
- && !mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false)) {
+ && !mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false)) {
nsfwWarningBuilder = new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.warning)
.setMessage(R.string.this_user_has_nsfw_content)
@@ -639,7 +639,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private void checkNewAccountAndInitializeViewPager() {
if (mNewAccountName != null) {
- if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
+ if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT) || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
@@ -1371,7 +1371,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
return false;
});
- boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
thingEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -1471,7 +1471,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 == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false));
+ 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));
randomBottomSheetFragment.setArguments(bundle);
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
}
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 2c502882..e7f645c0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -234,9 +234,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
miscPlugin, mEmoteCloseBracketInlineProcessor, mEmotePlugin, mImageAndGifPlugin, mCommentTextColor,
commentSpoilerBackgroundColor, onLinkLongClickListener);
- boolean needBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
- boolean doNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
- boolean needBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
+ boolean needBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ boolean doNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
+ boolean needBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
boolean blurImage = (post.isNSFW() && needBlurNsfw && !(doNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (post.isSpoiler() && needBlurSpoiler);
mImageAndGifEntry = new ImageAndGifEntry(activity, mGlide, blurImage,
mediaMetadata -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index 6881c46e..ad158f05 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -261,9 +261,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSubredditNamePrefixed = post.getSubredditNamePrefixed();
mLocale = locale;
- mNeedBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
- mDoNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
- mNeedBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
+ mNeedBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ mDoNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
+ mNeedBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java
index 270de60b..be4b158d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java
@@ -28,6 +28,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -60,7 +61,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
resources = baseActivity.getResources();
this.glide = glide;
this.accountName = accountName;
- isLoggedIn = accountName != null;
+ isLoggedIn = !accountName.equals(Account.ANONYMOUS_ACCOUNT);
this.pageToggle = pageToggle;
requireAuthToAccountSection = securitySharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java
index ec67fd1f..3084ffc3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java
@@ -48,11 +48,11 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
}
});
accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
- navigationDrawerSharedPreferences, accountName != null, itemClickListener);
+ navigationDrawerSharedPreferences, !accountName.equals(Account.ANONYMOUS_ACCOUNT), itemClickListener);
redditSectionRecyclerViewAdapter = new RedditSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
navigationDrawerSharedPreferences, itemClickListener);
postSectionRecyclerViewAdapter = new PostSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
- navigationDrawerSharedPreferences, accountName != null, itemClickListener);
+ navigationDrawerSharedPreferences, !accountName.equals(Account.ANONYMOUS_ACCOUNT), itemClickListener);
preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener);
favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter(
@@ -60,7 +60,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
subscribedSubredditsRecyclerViewAdapter = new SubscribedSubredditsRecyclerViewAdapter(baseActivity, glide,
customThemeWrapper, navigationDrawerSharedPreferences, itemClickListener);
accountManagementSectionRecyclerViewAdapter = new AccountManagementSectionRecyclerViewAdapter(baseActivity,
- customThemeWrapper, glide, accountName != null, itemClickListener);
+ customThemeWrapper, glide, !accountName.equals(Account.ANONYMOUS_ACCOUNT), itemClickListener);
mainPageConcatAdapter = new ConcatAdapter(
headerSectionRecyclerViewAdapter,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java
index 32485929..b4a969a6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java
@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -44,7 +45,7 @@ public class PreferenceSectionRecyclerViewAdapter extends RecyclerView.Adapter<R
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
primaryIconColor = customThemeWrapper.getPrimaryIconColor();
- isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
collapsePreferencesSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_PREFERENCES_SECTION, false);
this.itemClickListener = itemClickListener;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsFollowingUser.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsFollowingUser.java
index 12bedc46..f4e34ce3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsFollowingUser.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsFollowingUser.java
@@ -13,7 +13,7 @@ public class CheckIsFollowingUser {
RedditDataRoomDatabase redditDataRoomDatabase, String username,
String accountName, CheckIsFollowingUserListener checkIsFollowingUserListener) {
executor.execute(() -> {
- SubscribedUserData subscribedUserData = redditDataRoomDatabase.subscribedUserDao().getSubscribedUser(username, accountName == null ? Account.ANONYMOUS_ACCOUNT : accountName);
+ SubscribedUserData subscribedUserData = redditDataRoomDatabase.subscribedUserDao().getSubscribedUser(username, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : accountName);
handler.post(() -> {
if (subscribedUserData != null) {
checkIsFollowingUserListener.isSubscribed();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java
index 60700edc..830c6dbc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/CheckIsSubscribedToSubreddit.java
@@ -14,12 +14,12 @@ public class CheckIsSubscribedToSubreddit {
String subredditName, String accountName,
CheckIsSubscribedToSubredditListener checkIsSubscribedToSubredditListener) {
executor.execute(() -> {
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (!redditDataRoomDatabase.accountDao().isAnonymousAccountInserted()) {
redditDataRoomDatabase.accountDao().insert(Account.getAnonymousAccount());
}
}
- SubscribedSubredditData subscribedSubredditData = redditDataRoomDatabase.subscribedSubredditDao().getSubscribedSubreddit(subredditName, accountName == null ? Account.ANONYMOUS_ACCOUNT : accountName);
+ SubscribedSubredditData subscribedSubredditData = redditDataRoomDatabase.subscribedSubredditDao().getSubscribedSubreddit(subredditName, accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : accountName);
handler.post(() -> {
if (subscribedSubredditData != null) {
checkIsSubscribedToSubredditListener.isSubscribed();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java
index a3b90ebd..7959cc68 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/InsertSubscribedThings.java
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.subreddit.SubredditDao;
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditDao;
@@ -26,7 +27,7 @@ public class InsertSubscribedThings {
List<SubredditData> subredditDataList,
InsertSubscribedThingListener insertSubscribedThingListener) {
executor.execute(() -> {
- if (accountName != null && redditDataRoomDatabase.accountDao().getAccountData(accountName) == null) {
+ if (!accountName.equals(Account.ANONYMOUS_ACCOUNT) && redditDataRoomDatabase.accountDao().getAccountData(accountName) == null) {
handler.post(insertSubscribedThingListener::insertSuccess);
return;
}
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 eb192207..712eeb0a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -1468,7 +1468,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 == null ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
+ String accountNameForCache = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
String key = accountNameForCache + SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_FRONT_PAGE_BASE;
String value = currentPost.getFullName();
mPostFeedScrolledPositionSharedPreferences.edit().putString(key, value).apply();
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 8545dcbe..0cf8b4cb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
@@ -39,6 +39,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
@@ -140,7 +141,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
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 == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRetrofit,
mCustomThemeWrapper, accessToken, accountName,
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 824dc93e..a12e5bf3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
@@ -39,6 +39,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.SearchUsersResultActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
@@ -140,7 +141,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
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 == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
+ boolean nsfw = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
mAdapter = new UserListingRecyclerViewAdapter(mActivity, mExecutor, mOauthRetrofit, mRetrofit,
mCustomThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java
index 99c12ff7..a6b14dbb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java
@@ -212,7 +212,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
if (loadParams.getKey() == null) {
boolean savePostFeedScrolledPosition = sortType != null && sortType.getType() == SortType.Type.BEST && sharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
if (savePostFeedScrolledPosition) {
- String accountNameForCache = accountName == null ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
+ String accountNameForCache = accountName.equals(Account.ANONYMOUS_ACCOUNT) ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
afterKey = postFeedScrolledPositionSharedPreferences.getString(accountNameForCache + SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_FRONT_PAGE_BASE, null);
} else {
afterKey = null;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java
index acb13de1..8cf513e9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.SortType;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
@@ -86,7 +87,7 @@ public class PostViewModel extends ViewModel {
post -> !post.isRead() || !currentlyReadPostIdsLiveData.getValue()))), ViewModelKt.getViewModelScope(this));
currentlyReadPostIdsLiveData.setValue(postHistorySharedPreferences != null
- && postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
+ && postHistorySharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
}
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
@@ -126,7 +127,7 @@ public class PostViewModel extends ViewModel {
post -> !post.isRead() || !currentlyReadPostIdsLiveData.getValue()))), ViewModelKt.getViewModelScope(this));
currentlyReadPostIdsLiveData.setValue(postHistorySharedPreferences != null
- && postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
+ && postHistorySharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
}
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
@@ -169,7 +170,7 @@ public class PostViewModel extends ViewModel {
post -> !post.isRead() || !currentlyReadPostIdsLiveData.getValue()))), ViewModelKt.getViewModelScope(this));
currentlyReadPostIdsLiveData.setValue(postHistorySharedPreferences != null
- && postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
+ && postHistorySharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
}
public PostViewModel(Executor executor, Retrofit retrofit, String accessToken, String accountName,
@@ -212,7 +213,7 @@ public class PostViewModel extends ViewModel {
post -> !post.isRead() || !currentlyReadPostIdsLiveData.getValue()))), ViewModelKt.getViewModelScope(this));
currentlyReadPostIdsLiveData.setValue(postHistorySharedPreferences != null
- && postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
+ && postHistorySharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
}
public LiveData<PagingData<Post>> getPosts() {
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 0348f3c1..15531189 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java
@@ -162,12 +162,12 @@ public class CustomizeBottomAppBarFragment extends Fragment {
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 == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- mainActivityOption1 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, 0);
- mainActivityOption2 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, 1);
- mainActivityOption3 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, 2);
- mainActivityOption4 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, 3);
- mainActivityFAB = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, accountName == null ? 7: 0);
+ 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);
mainActivityOption1 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption1);
mainActivityOption2 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption2);
@@ -180,7 +180,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]);
mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]);
- if (accountName == null) {
+ if (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 +200,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 == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, mainActivityOptionCount).apply();
+ sharedPreferences.edit().putInt((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 +210,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 == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> {
mainActivityOption1 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption1;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
+ 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();
mainActivityOption1TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -223,10 +223,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 == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> {
mainActivityOption2 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption2;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
+ 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();
mainActivityOption2TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -236,10 +236,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 == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> {
mainActivityOption3 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption3;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
+ 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();
mainActivityOption3TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -249,10 +249,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 == null ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> {
mainActivityOption4 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption4;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
+ 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();
mainActivityOption4TextView.setText(mainActivityOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -265,7 +265,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
.setSingleChoiceItems(fabOptions, mainActivityFAB, (dialogInterface, i) -> {
mainActivityFAB = i;
int optionToSaveToPreference;
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (i >= 7) {
optionToSaveToPreference = i + 2;
} else {
@@ -274,7 +274,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
} else {
optionToSaveToPreference = i;
}
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply();
+ sharedPreferences.edit().putInt((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 +284,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 == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4);
- otherActivitiesOption1 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, 0);
- otherActivitiesOption2 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, 1);
- otherActivitiesOption3 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, 2);
- otherActivitiesOption4 = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, 3);
- otherActivitiesFAB = sharedPreferences.getInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, accountName == null ? 7: 0);
+ 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);
otherActivitiesOption1 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption1);
otherActivitiesOption2 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption2);
@@ -302,7 +302,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]);
otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]);
- if (accountName == null) {
+ if (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 +318,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 == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, otherActivitiesOptionCount).apply();
+ sharedPreferences.edit().putInt((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 +328,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 == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> {
otherActivitiesOption1 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption1;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply();
+ 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();
otherActivitiesOption1TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -341,10 +341,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 == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> {
otherActivitiesOption2 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption2;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply();
+ 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();
otherActivitiesOption2TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -354,10 +354,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 == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> {
otherActivitiesOption3 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption3;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply();
+ 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();
otherActivitiesOption3TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -367,10 +367,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 == null ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> {
+ .setSingleChoiceItems(accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> {
otherActivitiesOption4 = i;
- int optionToSaveToPreference = accountName == null ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption4;
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply();
+ 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();
otherActivitiesOption4TextView.setText(otherActivitiesOptions[optionToSaveToPreference]);
dialogInterface.dismiss();
})
@@ -383,7 +383,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
.setSingleChoiceItems(fabOptions, otherActivitiesFAB, (dialogInterface, i) -> {
otherActivitiesFAB = i;
int optionToSaveToPreference;
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
if (i >= 7) {
optionToSaveToPreference = i + 2;
} else {
@@ -392,7 +392,7 @@ public class CustomizeBottomAppBarFragment extends Fragment {
} else {
optionToSaveToPreference = i;
}
- sharedPreferences.edit().putInt((accountName == null ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply();
+ sharedPreferences.edit().putInt((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 af471538..083a547d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java
@@ -30,6 +30,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.MultiredditSelectionActivity;
import ml.docilealligator.infinityforreddit.activities.SearchActivity;
import ml.docilealligator.infinityforreddit.activities.SettingsActivity;
@@ -198,37 +199,37 @@ public class CustomizeMainPageTabsFragment extends Fragment {
accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
String[] typeValues;
- if (accountName == null) {
+ if (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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
+ tabCount = mainActivityTabsSharedPreferences.getInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, tabCount).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, tabCount).apply();
tabCountTextView.setText(Integer.toString(tabCount));
dialogInterface.dismiss();
})
.show();
});
- boolean showTabNames = mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true);
+ boolean showTabNames = mainActivityTabsSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true);
showTabNamesSwitch.setChecked(showTabNames);
- showTabNamesSwitch.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, b).apply());
+ showTabNamesSwitch.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, b).apply());
showTabNamesLinearLayout.setOnClickListener(view -> showTabNamesSwitch.performClick());
- tab1CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home));
- tab1CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
- if (accountName != null) {
+ 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)) {
tab1CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab1CurrentPostType, 1);
}
- tab1CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
+ tab1CurrentName = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
tab1TypeSummaryTextView.setText(typeValues[tab1CurrentPostType]);
tab1TitleSummaryTextView.setText(tab1CurrentTitle);
tab1NameSummaryTextView.setText(tab1CurrentName);
@@ -251,7 +252,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab1CurrentTitle = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, tab1CurrentTitle).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, tab1CurrentTitle).apply();
tab1TitleSummaryTextView.setText(tab1CurrentTitle);
Utils.hideKeyboard(activity);
})
@@ -266,7 +267,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setTitle(R.string.settings_tab_title)
.setSingleChoiceItems(typeValues, tab1CurrentPostType, (dialogInterface, i) -> {
tab1CurrentPostType = i;
- mainActivityTabsSharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply();
tab1TypeSummaryTextView.setText(typeValues[i]);
applyTab1NameView(tab1NameConstraintLayout, tab1NameTitleTextView, i);
dialogInterface.dismiss();
@@ -303,7 +304,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab1CurrentName = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
tab1NameSummaryTextView.setText(tab1CurrentName);
Utils.hideKeyboard(activity);
})
@@ -315,12 +316,12 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab1AddImageView.setOnClickListener(view -> selectName(0));
- tab2CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular));
- tab2CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
- if (accountName != null) {
+ 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)) {
tab2CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab2CurrentPostType, 1);
}
- tab2CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
+ tab2CurrentName = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
tab2TypeSummaryTextView.setText(typeValues[tab2CurrentPostType]);
tab2TitleSummaryTextView.setText(tab2CurrentTitle);
tab2NameSummaryTextView.setText(tab2CurrentName);
@@ -340,7 +341,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab2CurrentTitle = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, tab2CurrentTitle).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, tab2CurrentTitle).apply();
tab2TitleSummaryTextView.setText(tab2CurrentTitle);
Utils.hideKeyboard(activity);
})
@@ -355,7 +356,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setTitle(R.string.settings_tab_title)
.setSingleChoiceItems(typeValues, tab2CurrentPostType, (dialogInterface, i) -> {
tab2CurrentPostType = i;
- mainActivityTabsSharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply();
tab2TypeSummaryTextView.setText(typeValues[i]);
applyTab2NameView(tab2NameConstraintLayout, tab2NameTitleTextView, i);
dialogInterface.dismiss();
@@ -392,7 +393,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab2CurrentName = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
tab2NameSummaryTextView.setText(tab2CurrentName);
Utils.hideKeyboard(activity);
})
@@ -404,12 +405,12 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab2AddImageView.setOnClickListener(view -> selectName(1));
- tab3CurrentTitle = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all));
- tab3CurrentPostType = mainActivityTabsSharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
- if (accountName != null) {
+ 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)) {
tab3CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab3CurrentPostType, 1);
}
- tab3CurrentName = mainActivityTabsSharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
+ tab3CurrentName = mainActivityTabsSharedPreferences.getString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
tab3TypeSummaryTextView.setText(typeValues[tab3CurrentPostType]);
tab3TitleSummaryTextView.setText(tab3CurrentTitle);
tab3NameSummaryTextView.setText(tab3CurrentName);
@@ -429,7 +430,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab3CurrentTitle = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, tab3CurrentTitle).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, tab3CurrentTitle).apply();
tab3TitleSummaryTextView.setText(tab3CurrentTitle);
Utils.hideKeyboard(activity);
})
@@ -444,7 +445,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setTitle(R.string.settings_tab_title)
.setSingleChoiceItems(typeValues, tab3CurrentPostType, (dialogInterface, i) -> {
tab3CurrentPostType = i;
- mainActivityTabsSharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply();
+ mainActivityTabsSharedPreferences.edit().putInt((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply();
tab3TypeSummaryTextView.setText(typeValues[i]);
applyTab3NameView(tab3NameConstraintLayout, tab3NameTitleTextView, i);
dialogInterface.dismiss();
@@ -481,7 +482,7 @@ public class CustomizeMainPageTabsFragment extends Fragment {
.setPositiveButton(R.string.ok, (dialogInterface, i)
-> {
tab3CurrentName = editText.getText().toString();
- mainActivityTabsSharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
tab3NameSummaryTextView.setText(tab3CurrentName);
Utils.hideKeyboard(activity);
})
@@ -493,26 +494,26 @@ public class CustomizeMainPageTabsFragment extends Fragment {
tab3AddImageView.setOnClickListener(view -> selectName(2));
- showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
- showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
+ 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());
showMultiredditsLinearLayout.setOnClickListener(view -> {
showMultiredditsSwitchMaterial.performClick();
});
- showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
- showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
+ 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());
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
showFavoriteMultiredditsSwitchMaterial.performClick();
});
- showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
- showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
+ 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());
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
showSubscribedSubredditsSwitchMaterial.performClick();
});
- showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
- showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
+ 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());
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
});
@@ -695,54 +696,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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply();
+ mainActivityTabsSharedPreferences.edit().putString((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 a17649c5..a75cd76d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
@@ -24,6 +24,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.SettingsActivity;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
@@ -104,10 +105,10 @@ public class NsfwAndSpoilerFragment extends Fragment {
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
- boolean enableNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
- blurNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
- doNotBlurNsfwInNsfwSubreddits = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
- boolean blurSpoiler = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
+ 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);
disableNsfwForever = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false);
if (enableNsfw) {
@@ -128,7 +129,7 @@ public class NsfwAndSpoilerFragment extends Fragment {
enableNsfwLinearLayout.setOnClickListener(view -> enableNsfwSwitchMaterial.performClick());
enableNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply();
if (b) {
blurNsfwLinearLayout.setVisibility(View.VISIBLE);
doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.VISIBLE);
@@ -141,7 +142,7 @@ public class NsfwAndSpoilerFragment extends Fragment {
blurNsfwLinearLayout.setOnClickListener(view -> blurNsfwSwitchMaterial.performClick());
blurNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, b).apply();
EventBus.getDefault().post(new ChangeNSFWBlurEvent(b, doNotBlurNsfwInNsfwSubreddits));
});
@@ -149,13 +150,13 @@ public class NsfwAndSpoilerFragment extends Fragment {
doNotBlurNsfwInNsfwSubredditsSwitch.performClick();
});
doNotBlurNsfwInNsfwSubredditsSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
- nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, b).apply();
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : 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 3ac6dcef..f2cd8965 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
@@ -22,6 +22,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.SettingsActivity;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
@@ -83,7 +84,7 @@ public class PostHistoryFragment extends Fragment {
}
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
- if (accountName == null) {
+ if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
infoTextView.setText(R.string.only_for_logged_in_user);
markPostsAsReadLinearLayout.setVisibility(View.GONE);
markPostsAsReadAfterVotingLinearLayout.setVisibility(View.GONE);