From a6f1d981db5b877591c0034e872560149154c0c7 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 12 Aug 2024 07:09:17 +0200 Subject: [PATCH 1/3] fix(Profile): use global context for note toast Uses the global context for displaying the note saved toast. When using the local context, it was somehow, sometimes null, leading to crashes. --- .../org/joinmastodon/android/fragments/ProfileFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 b25c0e405..7847cb769 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -58,6 +58,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.viewpager2.widget.ViewPager2; import org.joinmastodon.android.GlobalUserPreferences; +import org.joinmastodon.android.MastodonApp; import org.joinmastodon.android.R; import org.joinmastodon.android.api.requests.accounts.GetAccountByID; import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships; @@ -468,7 +469,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList public void onSuccess(Relationship result) { updateRelationship(result); invalidateOptionsMenu(); - Toast.makeText(getContext(), R.string.mo_personal_note_saved, Toast.LENGTH_SHORT).show(); + Toast.makeText(MastodonApp.context, R.string.mo_personal_note_saved, Toast.LENGTH_SHORT).show(); } @Override From 78ec24ff0c9eb9d40249f8debd9085bfcd007e57 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 12 Aug 2024 07:15:22 +0200 Subject: [PATCH 2/3] feat(Profile): only show note saved if note has not been hidden The note text field being hidden is already enough comfirmation that the note has been hidden. --- .../org/joinmastodon/android/fragments/ProfileFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 7847cb769..042e2d46f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -469,7 +469,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList public void onSuccess(Relationship result) { updateRelationship(result); invalidateOptionsMenu(); - Toast.makeText(MastodonApp.context, R.string.mo_personal_note_saved, Toast.LENGTH_SHORT).show(); + if(!TextUtils.isEmpty(result.note)) + Toast.makeText(MastodonApp.context, R.string.mo_personal_note_saved, Toast.LENGTH_SHORT).show(); } @Override From 420233da148b271cb626a3e4c378f733ae268e53 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 12 Aug 2024 07:16:15 +0200 Subject: [PATCH 3/3] fix(Profile): remove note text before hiding NoteTextField Fixes an issue, where if the NoteTextField was focussed and the note was hidden, the note would saved and reshown once the NoteTextField was hidden. --- .../org/joinmastodon/android/fragments/ProfileFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 042e2d46f..43f48482c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -454,8 +454,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList } private void hidePrivateNote(){ - noteWrap.setVisibility(View.GONE); noteEdit.setText(null); + noteWrap.setVisibility(View.GONE); } private void savePrivateNote(String note){