mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Fix issue where preferences used the Display name instead of the full account name
Closes #275
This commit is contained in:
parent
336223cc36
commit
c1c8d99de2
@ -865,12 +865,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
} else if (stringId == R.string.enable_nsfw) {
|
} else if (stringId == R.string.enable_nsfw) {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
|
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
|
||||||
sectionsPagerAdapter.changeNSFW(true);
|
sectionsPagerAdapter.changeNSFW(true);
|
||||||
}
|
}
|
||||||
} else if (stringId == R.string.disable_nsfw) {
|
} else if (stringId == R.string.disable_nsfw) {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
|
mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
|
||||||
sectionsPagerAdapter.changeNSFW(false);
|
sectionsPagerAdapter.changeNSFW(false);
|
||||||
}
|
}
|
||||||
} else if (stringId == R.string.settings) {
|
} else if (stringId == R.string.settings) {
|
||||||
@ -928,17 +928,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
|
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
|
||||||
navDrawerRecyclerView.setAdapter(adapter.getConcatAdapter());
|
navDrawerRecyclerView.setAdapter(adapter.getConcatAdapter());
|
||||||
|
|
||||||
int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
|
int tabCount = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3);
|
||||||
mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
|
mShowFavoriteMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false);
|
||||||
mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
|
mShowMultiReddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false);
|
||||||
mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
|
mShowFavoriteSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false);
|
||||||
mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
|
mShowSubscribedSubreddits = mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false);
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
|
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
|
||||||
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
|
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
|
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
|
||||||
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
|
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
|
||||||
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
|
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
|
||||||
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
|
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
|
||||||
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
||||||
} else {
|
} else {
|
||||||
@ -947,13 +947,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
|
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
|
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
|
||||||
break;
|
break;
|
||||||
case 2:
|
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((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
|
if (position >= tabCount && (mShowFavoriteMultiReddits || mShowMultiReddits ||
|
||||||
@ -1001,7 +1001,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
loadSubscriptions();
|
loadSubscriptions();
|
||||||
|
|
||||||
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
|
multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(),
|
||||||
mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
|
mRedditDataRoomDatabase, mAccountQualifiedName == null ? "-" : mAccountQualifiedName))
|
||||||
.get(MultiRedditViewModel.class);
|
.get(MultiRedditViewModel.class);
|
||||||
|
|
||||||
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
|
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
|
||||||
@ -1594,7 +1594,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false);
|
||||||
thingEditText.addTextChangedListener(new TextWatcher() {
|
thingEditText.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
@ -1706,7 +1706,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
private void randomThing() {
|
private void randomThing() {
|
||||||
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
RandomBottomSheetFragment randomBottomSheetFragment = new RandomBottomSheetFragment();
|
||||||
Bundle bundle = new Bundle();
|
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((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.NSFW_BASE, false));
|
||||||
randomBottomSheetFragment.setArguments(bundle);
|
randomBottomSheetFragment.setArguments(bundle);
|
||||||
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
randomBottomSheetFragment.show(getSupportFragmentManager(), randomBottomSheetFragment.getTag());
|
||||||
}
|
}
|
||||||
@ -1767,8 +1767,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
@Override
|
@Override
|
||||||
public Fragment createFragment(int position) {
|
public Fragment createFragment(int position) {
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME);
|
int postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + 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, "");
|
String name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, "");
|
||||||
return generatePostFragment(postType, name);
|
return generatePostFragment(postType, name);
|
||||||
} else {
|
} else {
|
||||||
if (showFavoriteMultiReddits) {
|
if (showFavoriteMultiReddits) {
|
||||||
@ -1810,11 +1810,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
int postType;
|
int postType;
|
||||||
String name;
|
String name;
|
||||||
if (position == 1) {
|
if (position == 1) {
|
||||||
postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR);
|
postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + 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, "");
|
name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, "");
|
||||||
} else {
|
} else {
|
||||||
postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL);
|
postType = mMainActivityTabsSharedPreferences.getInt((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + 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, "");
|
name = mMainActivityTabsSharedPreferences.getString((mAccountQualifiedName == null ? "" : mAccountQualifiedName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, "");
|
||||||
}
|
}
|
||||||
return generatePostFragment(postType, name);
|
return generatePostFragment(postType, name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user