Adding a tab on the tabbar and showing lists. Its still an early alpha though

This commit is contained in:
LucasGGamerM 2022-12-11 11:58:28 -03:00
parent 857bb1e483
commit bfd87cf94e
4 changed files with 41 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import org.joinmastodon.android.R;
import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.discover.DiscoverFragment; import org.joinmastodon.android.fragments.discover.DiscoverFragment;
import org.joinmastodon.android.fragments.ListTimelinesFragment;
import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.ui.AccountSwitcherSheet; import org.joinmastodon.android.ui.AccountSwitcherSheet;
import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.utils.UiUtils;
@ -42,6 +43,7 @@ import me.grishka.appkit.views.FragmentRootLinearLayout;
public class HomeFragment extends AppKitFragment implements OnBackPressedListener{ public class HomeFragment extends AppKitFragment implements OnBackPressedListener{
private FragmentRootLinearLayout content; private FragmentRootLinearLayout content;
private HomeTimelineFragment homeTimelineFragment; private HomeTimelineFragment homeTimelineFragment;
private ListTimelinesFragment listTimelinesFragment;
private NotificationsFragment notificationsFragment; private NotificationsFragment notificationsFragment;
private DiscoverFragment searchFragment; private DiscoverFragment searchFragment;
private ProfileFragment profileFragment; private ProfileFragment profileFragment;
@ -71,6 +73,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
args.putBoolean("noAutoLoad", true); args.putBoolean("noAutoLoad", true);
searchFragment=new DiscoverFragment(); searchFragment=new DiscoverFragment();
searchFragment.setArguments(args); searchFragment.setArguments(args);
listTimelinesFragment =new ListTimelinesFragment();
listTimelinesFragment.setArguments(args);
notificationsFragment=new NotificationsFragment(); notificationsFragment=new NotificationsFragment();
notificationsFragment.setArguments(args); notificationsFragment.setArguments(args);
args=new Bundle(args); args=new Bundle(args);
@ -112,6 +116,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
getChildFragmentManager().beginTransaction() getChildFragmentManager().beginTransaction()
.add(R.id.fragment_wrap, homeTimelineFragment) .add(R.id.fragment_wrap, homeTimelineFragment)
.add(R.id.fragment_wrap, searchFragment).hide(searchFragment) .add(R.id.fragment_wrap, searchFragment).hide(searchFragment)
.add(R.id.fragment_wrap, listTimelinesFragment).hide(listTimelinesFragment)
.add(R.id.fragment_wrap, notificationsFragment).hide(notificationsFragment) .add(R.id.fragment_wrap, notificationsFragment).hide(notificationsFragment)
.add(R.id.fragment_wrap, profileFragment).hide(profileFragment) .add(R.id.fragment_wrap, profileFragment).hide(profileFragment)
.commit(); .commit();
@ -191,6 +196,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
return homeTimelineFragment; return homeTimelineFragment;
}else if(tab==R.id.tab_search){ }else if(tab==R.id.tab_search){
return searchFragment; return searchFragment;
}else if(tab==R.id.tab_lists) {
return listTimelinesFragment;
}else if(tab==R.id.tab_notifications){ }else if(tab==R.id.tab_notifications){
return notificationsFragment; return notificationsFragment;
}else if(tab==R.id.tab_profile){ }else if(tab==R.id.tab_profile){

View File

@ -1,5 +1,6 @@
package org.joinmastodon.android.fragments; package org.joinmastodon.android.fragments;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -8,11 +9,13 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import org.joinmastodon.android.R; import org.joinmastodon.android.R;
import org.joinmastodon.android.api.MastodonAPIRequest; import org.joinmastodon.android.api.MastodonAPIRequest;
@ -20,6 +23,8 @@ import org.joinmastodon.android.api.requests.lists.AddAccountsToList;
import org.joinmastodon.android.api.requests.lists.GetLists; import org.joinmastodon.android.api.requests.lists.GetLists;
import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList; import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList;
import org.joinmastodon.android.model.ListTimeline; import org.joinmastodon.android.model.ListTimeline;
import org.joinmastodon.android.ui.tabs.TabLayout;
import org.joinmastodon.android.ui.tabs.TabLayoutMediator;
import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,6 +42,11 @@ import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.UsableRecyclerView; import me.grishka.appkit.views.UsableRecyclerView;
public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> implements ScrollableToTop { public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> implements ScrollableToTop {
private TabLayout tabLayout;
private ViewPager2 pager;
private FrameLayout[] tabViews;
private TabLayoutMediator tabLayoutMediator;
private String accountId; private String accountId;
private String profileAccountId; private String profileAccountId;
private String profileDisplayUsername; private String profileDisplayUsername;
@ -69,6 +79,13 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
loadData(); loadData();
} }
@Override
public void onAttach(Activity activity){
super.onAttach(activity);
setHasOptionsMenu(true);
setTitle(R.string.sk_list_timelines);
}
// @Override // @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Button saveButton=new Button(getActivity()); // Button saveButton=new Button(getActivity());
@ -94,6 +111,7 @@ public class ListTimelinesFragment extends BaseRecyclerFragment<ListTimeline> im
}).exec(accountId); }).exec(accountId);
} }
@Override @Override
protected void doLoadData(int offset, int count){ protected void doLoadData(int offset, int count){
userInListBefore.clear(); userInListBefore.clear();

View File

@ -44,6 +44,21 @@
android:layout_height="1px" android:layout_height="1px"
android:layout_weight="1"/> android:layout_weight="1"/>
<ImageView
android:id="@+id/tab_lists"
android:layout_width="60dp"
android:layout_height="52dp"
android:scaleType="center"
android:contentDescription="@string/sk_lists_timeline"
android:background="?android:selectableItemBackgroundBorderless"
android:tint="?android:colorPrimary"
android:src="@drawable/ic_fluent_home_28_selector"/>
<Space
android:layout_width="0px"
android:layout_height="1px"
android:layout_weight="1"/>
<ImageView <ImageView
android:id="@+id/tab_notifications" android:id="@+id/tab_notifications"
android:layout_width="60dp" android:layout_width="60dp"

View File

@ -49,4 +49,5 @@
<string name="sk_color_theme_yellow">Yellow</string> <string name="sk_color_theme_yellow">Yellow</string>
<string name="sk_color_theme_material_you">Material You</string> <string name="sk_color_theme_material_you">Material You</string>
<string name="sk_not_supported">Not supported on your device</string> <string name="sk_not_supported">Not supported on your device</string>
<string name="sk_lists_timeline">Lists picker</string>
</resources> </resources>