From 3fd252180611ad33bef914a27d45d86bbd9e49c6 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Fri, 22 Dec 2023 21:23:21 +0100 Subject: [PATCH] Revert "feat: make profile note box be visible at all times" This reverts commit d6c05f0850a876401105f3531cf216203c8aa3ac. --- .../android/fragments/ProfileFragment.java | 25 ++++++++++++++++++- .../ui/viewholders/AccountViewHolder.java | 1 + mastodon/src/main/res/menu/profile.xml | 5 +++- 3 files changed, 29 insertions(+), 2 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 e45f7e7a55..7ed8413608 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -865,6 +865,8 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){ }else{ blockDomain.setVisible(false); } + menu.findItem(R.id.edit_note).setTitle(noteWrap.getVisibility()==View.GONE && (relationship.note==null || relationship.note.isEmpty()) + ? R.string.sk_add_note : R.string.sk_delete_note); } @Override @@ -946,6 +948,26 @@ public void onError(ErrorResponse error){ }else if(id==R.id.save){ if(isInEditMode) saveAndExitEditMode(); + }else if(id==R.id.edit_note){ + if(noteWrap.getVisibility()==View.GONE){ + showPrivateNote(); + UiUtils.beginLayoutTransition(scrollableContent); + noteEdit.requestFocus(); + noteEdit.postDelayed(()->{ + InputMethodManager imm=getActivity().getSystemService(InputMethodManager.class); + imm.showSoftInput(noteEdit, 0); + }, 100); + }else if(relationship.note.isEmpty()){ + hidePrivateNote(); + UiUtils.beginLayoutTransition(scrollableContent); + }else{ + new M3AlertDialogBuilder(getActivity()) + .setMessage(getContext().getString(R.string.sk_private_note_confirm_delete, account.getDisplayUsername())) + .setPositiveButton(R.string.delete, (dlg, btn)->savePrivateNote(null)) + .setNegativeButton(R.string.cancel, null) + .show(); + } + invalidateOptionsMenu(); } return true; } @@ -971,7 +993,8 @@ public void onError(ErrorResponse error){ private void updateRelationship(){ if(getActivity()==null) return; - showPrivateNote(); + if(relationship.note!=null && !relationship.note.isEmpty()) showPrivateNote(); + else hidePrivateNote(); invalidateOptionsMenu(); actionButton.setVisibility(View.VISIBLE); notifyButton.setVisibility(relationship.following ? View.VISIBLE : View.GONE); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java index efd2380718..caa89f7973 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java @@ -217,6 +217,7 @@ public boolean onLongClick(float x, float y){ Menu menu=contextMenu.getMenu(); Account account=item.account; + menu.findItem(R.id.edit_note).setVisible(false); menu.findItem(R.id.manage_user_lists).setTitle(fragment.getString(R.string.sk_lists_with_user, account.getShortUsername())); MenuItem mute=menu.findItem(R.id.mute); mute.setTitle(fragment.getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getShortUsername())); diff --git a/mastodon/src/main/res/menu/profile.xml b/mastodon/src/main/res/menu/profile.xml index aaaf7cae8c..6d93f8a606 100644 --- a/mastodon/src/main/res/menu/profile.xml +++ b/mastodon/src/main/res/menu/profile.xml @@ -1,6 +1,9 @@ + + + @@ -9,7 +12,7 @@ - +