From 1dd46df5402bf7e52f79e98d8eac69fdfa0e4266 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Sun, 17 Mar 2024 10:11:40 -0300 Subject: [PATCH] feat(profile): add the upstream handle thingys --- .../android/fragments/ProfileFragment.java | 29 +++++++++++++++---- .../src/main/res/layout/fragment_profile.xml | 14 +++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 854cc32df..c5bb750c4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -85,6 +85,7 @@ import org.joinmastodon.android.ui.OutlineProviders; import org.joinmastodon.android.ui.SimpleViewHolder; import org.joinmastodon.android.ui.SingleImagePhotoViewerListener; import org.joinmastodon.android.ui.photoviewer.PhotoViewer; +import org.joinmastodon.android.ui.sheets.DecentralizationExplainerSheet; import org.joinmastodon.android.ui.tabs.TabLayout; import org.joinmastodon.android.ui.tabs.TabLayoutMediator; import org.joinmastodon.android.ui.text.CustomEmojiSpan; @@ -138,7 +139,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList private ImageView avatar; private CoverImageView cover; private View avatarBorder; - private TextView name, username, bio, followersCount, followersLabel, followingCount, followingLabel; + private TextView name, username, usernameDomain, bio, followersCount, followersLabel, followingCount, followingLabel; private ImageView lockIcon, botIcon; private ProgressBarButton actionButton, notifyButton; private ViewPager2 pager; @@ -244,6 +245,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList name=content.findViewById(R.id.name); usernameWrap=content.findViewById(R.id.username_wrap); username=content.findViewById(R.id.username); + usernameDomain=content.findViewById(R.id.username_domain); lockIcon=content.findViewById(R.id.lock_icon); botIcon=content.findViewById(R.id.bot_icon); bio=content.findViewById(R.id.bio); @@ -454,6 +456,16 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList nameEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true)); bioEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true)); + usernameDomain.setOnClickListener(v->new DecentralizationExplainerSheet(getActivity(), accountID, account).show()); +// qrCodeButton.setOnClickListener(v->{ +// Bundle args=new Bundle(); +// args.putString("account", accountID); +// args.putParcelable("targetAccount", Parcels.wrap(account)); +// ProfileQrCodeFragment qf=new ProfileQrCodeFragment(); +// qf.setArguments(args); +// qf.show(getChildFragmentManager(), "qrDialog"); +// }); + return sizeWrapper; } @@ -714,13 +726,18 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList } } - boolean isSelf=AccountSessionManager.getInstance().isSelf(accountID, account); +// boolean isSelf=AccountSessionManager.getInstance().isSelf(accountID, account); - String acct = ((isSelf || account.isRemote) - ? account.getFullyQualifiedName() - : account.acct); +// String acct = ((isSelf || account.isRemote) +// ? account.getFullyQualifiedName() +// : account.acct); - username.setText('@'+acct); + username.setText("@"+account.username); + + String domain=account.getDomain(); + if(TextUtils.isEmpty(domain)) + domain=AccountSessionManager.get(accountID).domain; + usernameDomain.setText(domain); lockIcon.setVisibility(account.locked ? View.VISIBLE : View.GONE); lockIcon.setImageTintList(ColorStateList.valueOf(username.getCurrentTextColor())); diff --git a/mastodon/src/main/res/layout/fragment_profile.xml b/mastodon/src/main/res/layout/fragment_profile.xml index cb73986bf..ae40f0fe4 100644 --- a/mastodon/src/main/res/layout/fragment_profile.xml +++ b/mastodon/src/main/res/layout/fragment_profile.xml @@ -215,6 +215,20 @@ android:contentDescription="@string/sk_icon_bot" android:src="@drawable/ic_fluent_bot_20_filled" /> + +