add profile tab for pinned toots

This commit is contained in:
sk 2022-05-06 18:09:00 +02:00
parent 88504531d4
commit a3bea6ad24
5 changed files with 19 additions and 7 deletions

View File

@ -21,6 +21,7 @@ public class GetAccountStatuses extends MastodonAPIRequest<List<Status>>{
switch(filter){ switch(filter){
case DEFAULT -> addQueryParameter("exclude_replies", "true"); case DEFAULT -> addQueryParameter("exclude_replies", "true");
case INCLUDE_REPLIES -> {} case INCLUDE_REPLIES -> {}
case PINNED -> addQueryParameter("pinned", "true");
case MEDIA -> addQueryParameter("only_media", "true"); case MEDIA -> addQueryParameter("only_media", "true");
case NO_REBLOGS -> { case NO_REBLOGS -> {
addQueryParameter("exclude_replies", "true"); addQueryParameter("exclude_replies", "true");
@ -32,6 +33,7 @@ public class GetAccountStatuses extends MastodonAPIRequest<List<Status>>{
public enum Filter{ public enum Filter{
DEFAULT, DEFAULT,
INCLUDE_REPLIES, INCLUDE_REPLIES,
PINNED,
MEDIA, MEDIA,
NO_REBLOGS NO_REBLOGS
} }

View File

@ -101,7 +101,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private ProgressBarButton actionButton; private ProgressBarButton actionButton;
private ViewPager2 pager; private ViewPager2 pager;
private NestedRecyclerScrollView scrollView; private NestedRecyclerScrollView scrollView;
private AccountTimelineFragment postsFragment, postsWithRepliesFragment, mediaFragment; private AccountTimelineFragment postsFragment, postsWithRepliesFragment, pinnedPostsFragment, mediaFragment;
private ProfileAboutFragment aboutFragment; private ProfileAboutFragment aboutFragment;
private TabLayout tabbar; private TabLayout tabbar;
private SwipeRefreshLayout refreshLayout; private SwipeRefreshLayout refreshLayout;
@ -215,8 +215,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
tabView.setId(switch(i){ tabView.setId(switch(i){
case 0 -> R.id.profile_posts; case 0 -> R.id.profile_posts;
case 1 -> R.id.profile_posts_with_replies; case 1 -> R.id.profile_posts_with_replies;
case 2 -> R.id.profile_media; case 2 -> R.id.profile_pinned_posts;
case 3 -> R.id.profile_about; case 3 -> R.id.profile_media;
case 4 -> R.id.profile_about;
default -> throw new IllegalStateException("Unexpected value: "+i); default -> throw new IllegalStateException("Unexpected value: "+i);
}); });
tabView.setVisibility(View.GONE); tabView.setVisibility(View.GONE);
@ -240,8 +241,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
tab.setText(switch(position){ tab.setText(switch(position){
case 0 -> R.string.posts; case 0 -> R.string.posts;
case 1 -> R.string.posts_and_replies; case 1 -> R.string.posts_and_replies;
case 2 -> R.string.media; case 2 -> R.string.pinned_posts;
case 3 -> R.string.profile_about; case 3 -> R.string.media;
case 4 -> R.string.profile_about;
default -> throw new IllegalStateException(); default -> throw new IllegalStateException();
}); });
} }
@ -298,6 +300,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
postsFragment.onRefresh(); postsFragment.onRefresh();
if(postsWithRepliesFragment.loaded) if(postsWithRepliesFragment.loaded)
postsWithRepliesFragment.onRefresh(); postsWithRepliesFragment.onRefresh();
if(pinnedPostsFragment.loaded)
pinnedPostsFragment.onRefresh();
if(mediaFragment.loaded) if(mediaFragment.loaded)
mediaFragment.onRefresh(); mediaFragment.onRefresh();
} }
@ -322,6 +326,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(postsFragment==null){ if(postsFragment==null){
postsFragment=AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.DEFAULT, true); postsFragment=AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.DEFAULT, true);
postsWithRepliesFragment=AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.INCLUDE_REPLIES, false); postsWithRepliesFragment=AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.INCLUDE_REPLIES, false);
pinnedPostsFragment =AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.PINNED, false);
mediaFragment=AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.MEDIA, false); mediaFragment=AccountTimelineFragment.newInstance(accountID, account, GetAccountStatuses.Filter.MEDIA, false);
aboutFragment=new ProfileAboutFragment(); aboutFragment=new ProfileAboutFragment();
aboutFragment.setFields(fields); aboutFragment.setFields(fields);
@ -402,6 +407,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(postsFragment!=null && postsFragment.isAdded() && childInsets!=null){ if(postsFragment!=null && postsFragment.isAdded() && childInsets!=null){
postsFragment.onApplyWindowInsets(childInsets); postsFragment.onApplyWindowInsets(childInsets);
postsWithRepliesFragment.onApplyWindowInsets(childInsets); postsWithRepliesFragment.onApplyWindowInsets(childInsets);
pinnedPostsFragment.onApplyWindowInsets(childInsets);
mediaFragment.onApplyWindowInsets(childInsets); mediaFragment.onApplyWindowInsets(childInsets);
} }
} }
@ -637,8 +643,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
return switch(page){ return switch(page){
case 0 -> postsFragment; case 0 -> postsFragment;
case 1 -> postsWithRepliesFragment; case 1 -> postsWithRepliesFragment;
case 2 -> mediaFragment; case 2 -> pinnedPostsFragment;
case 3 -> aboutFragment; case 3 -> mediaFragment;
case 4 -> aboutFragment;
default -> throw new IllegalStateException(); default -> throw new IllegalStateException();
}; };
} }

View File

@ -42,6 +42,7 @@
</plurals> </plurals>
<string name="posts">Beiträge</string> <string name="posts">Beiträge</string>
<string name="posts_and_replies">Beiträge und Antworten</string> <string name="posts_and_replies">Beiträge und Antworten</string>
<string name="pinned_posts">Angepinnt</string>
<string name="media">Medien</string> <string name="media">Medien</string>
<string name="profile_about">Über</string> <string name="profile_about">Über</string>
<string name="button_follow">Folgen</string> <string name="button_follow">Folgen</string>

View File

@ -4,6 +4,7 @@
<item name="profile_posts" type="id"/> <item name="profile_posts" type="id"/>
<item name="profile_posts_with_replies" type="id"/> <item name="profile_posts_with_replies" type="id"/>
<item name="profile_pinned_posts" type="id"/>
<item name="profile_media" type="id"/> <item name="profile_media" type="id"/>
<item name="profile_about" type="id"/> <item name="profile_about" type="id"/>

View File

@ -47,6 +47,7 @@
</plurals> </plurals>
<string name="posts">Posts</string> <string name="posts">Posts</string>
<string name="posts_and_replies">Posts and Replies</string> <string name="posts_and_replies">Posts and Replies</string>
<string name="pinned_posts">Pinned</string>
<string name="media">Media</string> <string name="media">Media</string>
<string name="profile_about">About</string> <string name="profile_about">About</string>
<string name="button_follow">Follow</string> <string name="button_follow">Follow</string>