diff options
author | Thomas <tschneider.ac@gmail.com> | 2023-08-26 17:53:55 +0200 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2023-08-26 17:53:55 +0200 |
commit | 185479287c78996bf3a3c4410d2c81dfd83fdb22 (patch) | |
tree | 92213eb21accc8a15688b724e72ca19f16b4ef9f /app | |
parent | a9da1752b2b557f65262a975de2babb0d99eb37e (diff) |
Change tabs in profiles
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java | 25 | ||||
-rw-r--r-- | app/src/main/res/layouts/mastodon/layout/tab_profile_custom_view.xml | 26 |
2 files changed, 48 insertions, 3 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java index 4a02043ce..ef0e4fc07 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java @@ -81,6 +81,7 @@ import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.ActivityProfileBinding; import app.fedilab.android.databinding.NotificationsRelatedAccountsBinding; +import app.fedilab.android.databinding.TabProfileCustomViewBinding; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.FamiliarFollowers; @@ -291,9 +292,27 @@ public class ProfileActivity extends BaseActivity { binding.accountTabLayout.removeAllTabs(); //Tablayout for timelines/following/followers FedilabProfileTLPageAdapter fedilabProfileTLPageAdapter = new FedilabProfileTLPageAdapter(getSupportFragmentManager(), account, checkRemotely); - binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.status_cnt, Helper.withSuffix(account.statuses_count)))); - binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.following_cnt, Helper.withSuffix(account.following_count)))); - binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.followers_cnt, Helper.withSuffix(account.followers_count)))); + TabProfileCustomViewBinding tabMessagesView = TabProfileCustomViewBinding.inflate(getLayoutInflater()); + TabProfileCustomViewBinding tabFollowingView = TabProfileCustomViewBinding.inflate(getLayoutInflater()); + TabProfileCustomViewBinding tabFollowersView = TabProfileCustomViewBinding.inflate(getLayoutInflater()); + + tabMessagesView.title.setText(getString(R.string.toots)); + tabMessagesView.count.setText(Helper.withSuffix(account.statuses_count)); + tabFollowingView.title.setText(getString(R.string.following)); + tabFollowingView.count.setText(Helper.withSuffix(account.following_count)); + tabFollowersView.title.setText(getString(R.string.followers)); + tabFollowersView.count.setText(Helper.withSuffix(account.followers_count)); + + TabLayout.Tab tabMessages = binding.accountTabLayout.newTab(); + TabLayout.Tab tabFollowing = binding.accountTabLayout.newTab(); + TabLayout.Tab tabFollowers = binding.accountTabLayout.newTab(); + tabMessages.setCustomView(tabMessagesView.getRoot()); + tabFollowing.setCustomView(tabFollowingView.getRoot()); + tabFollowers.setCustomView(tabFollowersView.getRoot()); + + binding.accountTabLayout.addTab(tabMessages); + binding.accountTabLayout.addTab(tabFollowing); + binding.accountTabLayout.addTab(tabFollowers); binding.accountViewpager.setAdapter(fedilabProfileTLPageAdapter); binding.accountViewpager.setOffscreenPageLimit(3); binding.accountViewpager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(binding.accountTabLayout)); diff --git a/app/src/main/res/layouts/mastodon/layout/tab_profile_custom_view.xml b/app/src/main/res/layouts/mastodon/layout/tab_profile_custom_view.xml new file mode 100644 index 000000000..a2a62c745 --- /dev/null +++ b/app/src/main/res/layouts/mastodon/layout/tab_profile_custom_view.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:id="@+id/title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ellipsize="end" + android:gravity="center" + android:maxLines="1" + tools:text="@string/followers" /> + + <TextView + android:id="@+id/count" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:maxLines="1" + tools:text="10" /> +</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file |