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

View File

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

View File

@ -44,6 +44,21 @@
android:layout_height="1px"
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
android:id="@+id/tab_notifications"
android:layout_width="60dp"

View File

@ -49,4 +49,5 @@
<string name="sk_color_theme_yellow">Yellow</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_lists_timeline">Lists picker</string>
</resources>