kopia lustrzana https://github.com/ryukoposting/Signal-Android
Do not show :query completion for possible time entries.
rodzic
eac9f78dfa
commit
9f5b822e33
|
@ -46,6 +46,8 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.thoughtcrime.securesms.database.MentionUtil.MENTION_STARTER;
|
import static org.thoughtcrime.securesms.database.MentionUtil.MENTION_STARTER;
|
||||||
|
|
||||||
|
@ -54,6 +56,8 @@ public class ComposeText extends EmojiEditText {
|
||||||
private static final char EMOJI_STARTER = ':';
|
private static final char EMOJI_STARTER = ':';
|
||||||
private static final long EMOJI_KEYWORD_DELAY = 1500;
|
private static final long EMOJI_KEYWORD_DELAY = 1500;
|
||||||
|
|
||||||
|
private static final Pattern TIME_PATTERN = Pattern.compile("^[0-9]{1,2}:[0-9]{1,2}$");
|
||||||
|
|
||||||
private CharSequence hint;
|
private CharSequence hint;
|
||||||
private SpannableString subHint;
|
private SpannableString subHint;
|
||||||
private MentionRendererDelegate mentionRendererDelegate;
|
private MentionRendererDelegate mentionRendererDelegate;
|
||||||
|
@ -427,11 +431,37 @@ public class ComposeText extends EmojiEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delimiterSearchIndex >= 0 && text.charAt(delimiterSearchIndex) == starter) {
|
if (delimiterSearchIndex >= 0 && text.charAt(delimiterSearchIndex) == starter) {
|
||||||
|
if (couldBeTimeEntry(text, delimiterSearchIndex)) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
return delimiterSearchIndex + 1;
|
return delimiterSearchIndex + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if we think the user may be inputting a time.
|
||||||
|
*/
|
||||||
|
private static boolean couldBeTimeEntry(@NonNull CharSequence text, int startIndex) {
|
||||||
|
if (startIndex <= 0 || startIndex + 1 >= text.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int startOfToken = startIndex;
|
||||||
|
while (startOfToken > 0 && !Character.isWhitespace(text.charAt(startOfToken))) {
|
||||||
|
startOfToken--;
|
||||||
|
}
|
||||||
|
startOfToken++;
|
||||||
|
|
||||||
|
int endOfToken = startIndex;
|
||||||
|
while (endOfToken < text.length() && !Character.isWhitespace(text.charAt(endOfToken))) {
|
||||||
|
endOfToken++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TIME_PATTERN.matcher(text.subSequence(startOfToken, endOfToken)).find();
|
||||||
|
}
|
||||||
|
|
||||||
private static class CommitContentListener implements InputConnectionCompat.OnCommitContentListener {
|
private static class CommitContentListener implements InputConnectionCompat.OnCommitContentListener {
|
||||||
|
|
||||||
private static final String TAG = Log.tag(CommitContentListener.class);
|
private static final String TAG = Log.tag(CommitContentListener.class);
|
||||||
|
|
Ładowanie…
Reference in New Issue