From 3aa252f681f02f4dec98a9a22781357321cd3fd6 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 1 Oct 2022 01:12:31 +0300 Subject: [PATCH] Fix editing --- .../joinmastodon/android/fragments/ComposeFragment.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 5504f6a5..2f0f7115 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -180,6 +180,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr private Status editingStatus; private boolean pollChanged; private boolean creatingView; + private boolean ignoreSelectionChanges=false; @Override public void onCreate(Bundle savedInstanceState){ @@ -480,7 +481,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr initialText=mentions.isEmpty() ? "" : TextUtils.join(" ", mentions)+" "; if(savedInstanceState==null){ mainEditText.setText(initialText); + ignoreSelectionChanges=true; mainEditText.setSelection(mainEditText.length()); + ignoreSelectionChanges=false; if(!TextUtils.isEmpty(replyTo.spoilerText) && AccountSessionManager.getInstance().isSelf(accountID, replyTo.account)){ hasSpoiler=true; spoilerEdit.setVisibility(View.VISIBLE); @@ -495,7 +498,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr if(editingStatus!=null){ initialText=getArguments().getString("sourceText", ""); mainEditText.setText(initialText); + ignoreSelectionChanges=true; mainEditText.setSelection(mainEditText.length()); + ignoreSelectionChanges=false; if(!editingStatus.mediaAttachments.isEmpty()){ attachmentsView.setVisibility(View.VISIBLE); for(Attachment att:editingStatus.mediaAttachments){ @@ -512,7 +517,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr String prefilledText=getArguments().getString("prefilledText"); if(!TextUtils.isEmpty(prefilledText)){ mainEditText.setText(prefilledText); + ignoreSelectionChanges=true; mainEditText.setSelection(mainEditText.length()); + ignoreSelectionChanges=false; initialText=prefilledText; } ArrayList mediaUris=getArguments().getParcelableArrayList("mediaAttachments"); @@ -1154,6 +1161,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr @Override public void onSelectionChanged(int start, int end){ + if(ignoreSelectionChanges) + return; if(start==end && mainEditText.length()>0){ ComposeAutocompleteSpan[] spans=mainEditText.getText().getSpans(start, end, ComposeAutocompleteSpan.class); if(spans.length>0){