Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文章に草を生やす機能が 1 char 以上で構成される文字を壊す #214

Closed
kb10uy opened this issue Mar 13, 2019 · 1 comment · Fixed by #215
Closed

文章に草を生やす機能が 1 char 以上で構成される文字を壊す #214

kb10uy opened this issue Mar 13, 2019 · 1 comment · Fixed by #215
Labels
bug Something isn't working

Comments

@kb10uy
Copy link

kb10uy commented Mar 13, 2019

https://mstdn.maud.io/@kb10uy/101746027854760988

char 単位で挿入しているせいっぽそうな雰囲気。
例によって Grapheme Cluster 単位の処理を導入する必要がありそうだが、そもそもこれ使ってる人いるのか…?

@shibafu528 shibafu528 added the bug Something isn't working label Mar 14, 2019
@shibafu528
Copy link
Owner

原因はその通りで、かなり古いバージョンから潜在している不具合かと思われます。

しかし使っている人いるんですかね……こんな影の薄いアサインの機能……

// 草ボタン
ImageButton ibGrasses = (ImageButton) findViewById(R.id.ibTweetGrasses);
ibGrasses.setOnClickListener(v -> {
int start = etInput.getSelectionStart();
int end = etInput.getSelectionEnd();
if (start < 0 || end < 0 || start == end) {
appendTextInto("w");
} else {
String text = etInput.getText().toString().substring(Math.min(start, end), Math.max(start, end));
char[] chr = text.toCharArray();
int grass = text.length() - 1;
StringBuilder sb = new StringBuilder();
for (char c : chr) {
sb.append(c);
if (grass > 0) {
sb.append("w");
--grass;
}
}
text = sb.toString();
etInput.getText().replace(Math.min(start, end), Math.max(start, end), text);
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants