From 1f51331f67c462b19d0211457342117410c5c507 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Sun, 11 Dec 2022 20:12:27 -0300 Subject: [PATCH] Fixed the lists tab order. This should partially fix #3 --- .../fragments/ListTimelinesFragment.java | 43 +++++++++---------- .../fragments/discover/DiscoverFragment.java | 21 ++++----- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java index df0f536aa2..c4cbf7fb02 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java @@ -63,14 +63,14 @@ public ListTimelinesFragment() { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args=getArguments(); - setTitle(R.string.sk_list_timelines); +// setTitle(R.string.sk_list_timelines); accountId=args.getString("account"); if(args.containsKey("profileAccount")){ profileAccountId=args.getString("profileAccount"); profileDisplayUsername=args.getString("profileDisplayUsername"); setTitle(getString(R.string.sk_lists_with_user, profileDisplayUsername)); -// setHasOptionsMenu(true); + setHasOptionsMenu(true); } // toolbarTitle=new TextView(getActivity()); // toolbarTitle.setText(R.string.sk_list_timelines); @@ -85,27 +85,24 @@ protected void onShown(){ loadData(); } -// @Override -// public void onAttach(Activity activity){ -// super.onAttach(activity); -// setHasOptionsMenu(false); -// setTitle(R.string.sk_list_timelines); -// } - -// @Override -// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { -// Button saveButton=new Button(getActivity()); -// saveButton.setText(R.string.save); -// saveButton.setOnClickListener(this::onSaveClick); -// LinearLayout wrap=new LinearLayout(getActivity()); -// wrap.setOrientation(LinearLayout.HORIZONTAL); -// wrap.addView(saveButton, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); -// wrap.setPadding(V.dp(16), V.dp(4), V.dp(16), V.dp(8)); -// wrap.setClipToPadding(false); -// MenuItem item=menu.add(R.string.save); -// item.setActionView(wrap); -// item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); -// } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + Button saveButton=new Button(getActivity()); + saveButton.setText(R.string.save); + saveButton.setOnClickListener(this::onSaveClick); + LinearLayout wrap=new LinearLayout(getActivity()); + wrap.setOrientation(LinearLayout.HORIZONTAL); + wrap.addView(saveButton, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + wrap.setPadding(V.dp(16), V.dp(4), V.dp(16), V.dp(8)); + wrap.setClipToPadding(false); + MenuItem item=menu.add(R.string.save); + item.setActionView(wrap); + item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + } + + private void onSaveClick(View view) { + System.out.println("Save"); + } private void saveListMembership(String listId, boolean isMember) { userInList.put(listId, isMember); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java index ccd663ca43..a51f9fd90a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java @@ -88,11 +88,11 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, tabView.setId(switch(switchIndex){ case 0 -> R.id.discover_local_timeline; case 1 -> R.id.discover_federated_timeline; - case 2 -> R.id.discover_hashtags; - case 3 -> R.id.discover_posts; - case 4 -> R.id.discover_news; - case 5 -> R.id.discover_users; - case 6 -> R.id.discover_lists; + case 2 -> R.id.discover_lists; + case 3 -> R.id.discover_hashtags; + case 4 -> R.id.discover_posts; + case 5 -> R.id.discover_news; + case 6 -> R.id.discover_users; default -> throw new IllegalStateException("Unexpected value: "+switchIndex); }); tabView.setVisibility(View.GONE); @@ -165,11 +165,12 @@ public void onConfigureTab(@NonNull TabLayout.Tab tab, int position){ tab.setText(switch(position){ case 0 -> R.string.local_timeline; case 1 -> R.string.sk_federated_timeline; - case 2 -> R.string.hashtags; - case 3 -> R.string.posts; - case 4 -> R.string.news; - case 5 -> R.string.for_you; - case 6 -> R.string.sk_list_timelines; + case 2 -> R.string.sk_list_timelines; + case 3 -> R.string.hashtags; + case 4 -> R.string.posts; + case 5 -> R.string.news; + case 6 -> R.string.for_you; + default -> throw new IllegalStateException("Unexpected value: "+position); }); tab.view.textView.setAllCaps(true);