diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 3ceaf30f4..5679e75a8 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -9,7 +9,7 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 31 - versionCode 28 + versionCode 29 versionName "1.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } 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 bd2df7365..5b727ee01 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -76,9 +76,9 @@ import org.joinmastodon.android.ui.text.ComposeHashtagOrMentionSpan; import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.utils.SimpleTextWatcher; import org.joinmastodon.android.ui.utils.UiUtils; +import org.joinmastodon.android.ui.views.ComposeEditText; import org.joinmastodon.android.ui.views.ComposeMediaLayout; import org.joinmastodon.android.ui.views.ReorderableLinearLayout; -import org.joinmastodon.android.ui.views.ComposeEditText; import org.joinmastodon.android.ui.views.SizeListenerLinearLayout; import org.parceler.Parcel; import org.parceler.Parcels; @@ -91,12 +91,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import androidx.annotation.DrawableRes; import me.grishka.appkit.Nav; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.fragments.OnBackPressedListener; -import me.grishka.appkit.fragments.ToolbarFragment; import me.grishka.appkit.imageloader.ViewImageLoader; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; import me.grishka.appkit.utils.V; @@ -416,14 +414,17 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr } char firstChar=editable.charAt(spanStart); String spanText=s.subSequence(spanStart, spanEnd).toString(); - if(firstChar=='@' || firstChar=='#'){ - Matcher matcher=HIGHLIGHT_PATTERN.matcher(spanText); - if(!matcher.find()){ // invalid mention, remove + if(firstChar=='@' || firstChar=='#' || firstChar==':'){ + Matcher matcher=AUTO_COMPLETE_PATTERN.matcher(spanText); + char prevChar=spanStart>0 ? editable.charAt(spanStart-1) : ' '; + if(!matcher.find() || !Character.isWhitespace(prevChar)){ // invalid mention, remove editable.removeSpan(span); continue; }else if(matcher.end()+spanStart