feat(profile): make the new decentralization sheet appear only when holding the instance button

This commit is contained in:
LucasGGamerM 2024-03-17 10:37:02 -03:00
parent 1dd46df540
commit 4a13398801
2 changed files with 35 additions and 23 deletions

View File

@ -398,28 +398,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
followingBtn.setOnClickListener(this::onFollowersOrFollowingClick); followingBtn.setOnClickListener(this::onFollowersOrFollowingClick);
content.findViewById(R.id.username_wrap).setOnClickListener(v->{ content.findViewById(R.id.username_wrap).setOnClickListener(v->{
try { UiUtils.goToInstanceAboutFragment(Uri.parse(account.url).getHost(), accountID, getContext());
new GetInstance()
.setCallback(new Callback<>(){
@Override
public void onSuccess(Instance result){
Bundle args = new Bundle();
args.putParcelable("instance", Parcels.wrap(result));
args.putString("account", accountID);
Nav.go(getActivity(), SettingsServerFragment.class, args);
}
@Override
public void onError(ErrorResponse error){
error.showToast(getContext());
}
})
.wrapProgress((Activity) getContext(), R.string.loading, true)
.execRemote(Uri.parse(account.url).getHost());
} catch (NullPointerException ignored) {
// maybe the url was malformed?
Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show();
}
}); });
content.findViewById(R.id.username_wrap).setOnLongClickListener(v->{ content.findViewById(R.id.username_wrap).setOnLongClickListener(v->{
@ -456,7 +435,15 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
nameEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true)); nameEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true));
bioEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true)); bioEdit.addTextChangedListener(new SimpleTextWatcher(e->editDirty=true));
usernameDomain.setOnClickListener(v->new DecentralizationExplainerSheet(getActivity(), accountID, account).show()); usernameDomain.setOnClickListener(v->{
UiUtils.goToInstanceAboutFragment(Uri.parse(account.url).getHost(), accountID, getContext());
});
usernameDomain.setOnLongClickListener(v->{
new DecentralizationExplainerSheet(getActivity(), accountID, account).show();
return true;
});
// qrCodeButton.setOnClickListener(v->{ // qrCodeButton.setOnClickListener(v->{
// Bundle args=new Bundle(); // Bundle args=new Bundle();
// args.putString("account", accountID); // args.putString("account", accountID);

View File

@ -1798,6 +1798,31 @@ public class UiUtils {
return text; return text;
} }
public static void goToInstanceAboutFragment(String instanceUrl, String accountID ,Context context){
try {
new GetInstance()
.setCallback(new Callback<>(){
@Override
public void onSuccess(Instance result){
Bundle args = new Bundle();
args.putParcelable("instance", Parcels.wrap(result));
args.putString("account", accountID);
Nav.go((Activity) context, SettingsServerFragment.class, args);
}
@Override
public void onError(ErrorResponse error){
error.showToast(context);
}
})
.wrapProgress((Activity) context, R.string.loading, true)
.execRemote(instanceUrl);
} catch (NullPointerException ignored) {
// maybe the url was malformed?
Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
}
}
private static final String[] pronounsUrls= new String[] { private static final String[] pronounsUrls= new String[] {
"pronouns.within.lgbt/", "pronouns.within.lgbt/",
"pronouns.cc/pronouns/", "pronouns.cc/pronouns/",