mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-30 11:34:43 +01:00
Version 5.1.1. Fix anonymous subreddits and multireddits do not show in MainActivity TabLayout. Fix changing tab names not working in anonymous mode.
This commit is contained in:
parent
841fec87dc
commit
1b39925cf8
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "ml.docilealligator.infinityforreddit"
|
applicationId "ml.docilealligator.infinityforreddit"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 84
|
versionCode 85
|
||||||
versionName "5.1.0"
|
versionName "5.1.1"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
|
@ -38,7 +38,6 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
@ -852,19 +851,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
||||||
}
|
}
|
||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||||
if (mAccessToken == null) {
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
tab.setText(R.string.home);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
tab.setText(R.string.popular);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
tab.setText(R.string.all);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
|
tab.setText(mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
|
||||||
@ -898,7 +884,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
- sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());
|
- sectionsPagerAdapter.favoriteSubscribedSubreddits.size()).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).attach();
|
}).attach();
|
||||||
} else {
|
} else {
|
||||||
tabLayout.setVisibility(View.GONE);
|
tabLayout.setVisibility(View.GONE);
|
||||||
@ -922,7 +907,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))
|
mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
|
||||||
.get(MultiRedditViewModel.class);
|
.get(MultiRedditViewModel.class);
|
||||||
|
|
||||||
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
|
multiRedditViewModel.getAllFavoriteMultiReddits().observe(this, multiReddits -> {
|
||||||
@ -931,17 +916,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
multiRedditViewModel.getAllMultiReddits().observe(this, new Observer<List<MultiReddit>>() {
|
multiRedditViewModel.getAllMultiReddits().observe(this, multiReddits -> {
|
||||||
@Override
|
|
||||||
public void onChanged(List<MultiReddit> multiReddits) {
|
|
||||||
if (mShowMultiReddits && sectionsPagerAdapter != null) {
|
if (mShowMultiReddits && sectionsPagerAdapter != null) {
|
||||||
sectionsPagerAdapter.setMultiReddits(multiReddits);
|
sectionsPagerAdapter.setMultiReddits(multiReddits);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
subscribedSubredditViewModel = new ViewModelProvider(this,
|
subscribedSubredditViewModel = new ViewModelProvider(this,
|
||||||
new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
|
new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName == null ? "-" : mAccountName))
|
||||||
.get(SubscribedSubredditViewModel.class);
|
.get(SubscribedSubredditViewModel.class);
|
||||||
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
|
subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this,
|
||||||
subscribedSubredditData -> {
|
subscribedSubredditData -> {
|
||||||
@ -1693,9 +1675,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if (mAccessToken == null) {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
return tabCount + favoriteMultiReddits.size() + multiReddits.size() +
|
return tabCount + favoriteMultiReddits.size() + multiReddits.size() +
|
||||||
favoriteSubscribedSubreddits.size() + subscribedSubreddits.size();
|
favoriteSubscribedSubreddits.size() + subscribedSubreddits.size();
|
||||||
}
|
}
|
||||||
|
@ -492,26 +492,26 @@ public class CustomizeMainPageTabsFragment extends Fragment {
|
|||||||
|
|
||||||
tab3AddImageView.setOnClickListener(view -> selectName(2));
|
tab3AddImageView.setOnClickListener(view -> selectName(2));
|
||||||
|
|
||||||
showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
|
showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false));
|
||||||
showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
|
showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply());
|
||||||
showMultiredditsLinearLayout.setOnClickListener(view -> {
|
showMultiredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showMultiredditsSwitchMaterial.performClick();
|
showMultiredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
|
showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false));
|
||||||
showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
|
showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply());
|
||||||
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
|
showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showFavoriteMultiredditsSwitchMaterial.performClick();
|
showFavoriteMultiredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
|
showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false));
|
||||||
showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
|
showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply());
|
||||||
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
showSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showSubscribedSubredditsSwitchMaterial.performClick();
|
showSubscribedSubredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
|
showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false));
|
||||||
showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
|
showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply());
|
||||||
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> {
|
||||||
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
|
showFavoriteSubscribedSubredditsSwitchMaterial.performClick();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user