Fixes issue #201 - Mentions in replies & cursor position

This commit is contained in:
stom79 2017-12-26 14:54:01 +01:00
parent 3c5965d4e4
commit 7dd364f27d
2 changed files with 18 additions and 16 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 27
versionCode 97
versionName "1.6.9"
versionCode 98
versionName "1.6.9.1"
}
flavorDimensions "default"
buildTypes {

View File

@ -1864,7 +1864,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
//Evaluate the cursor position => mention length + 1 char for carriage return
cursorReply = toot_content.getText().toString().length() + 1;
}
if( tootReply.getMentions() != null && tootReply.getMentions().size() > 0){
if( tootReply.getMentions() != null ){
//Put other accounts mentioned at the bottom
toot_content.setText(String.format("%s", (toot_content.getText().toString() + "\n\n")));
for(Mention mention : tootReply.getMentions()){
@ -1874,21 +1874,23 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
toot_content.setText(String.format("%s ", (toot_content.getText().toString() + tootTemp.trim())));
}
}
toot_content.setText(toot_content.getText().toString().trim());
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.requestFocus();
if( cursorReply > 0 && cursorReply < toot_content.getText().length())
toot_content.setSelection(cursorReply);
else
if( mentionedAccountsAdded.size() == 1){
toot_content.setText(toot_content.getText().toString().trim());
if (toot_content.getText().toString().startsWith("@")) {
toot_content.append("\n");
}
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.requestFocus();
toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end
}else{
toot_content.setText(toot_content.getText().toString().trim());
if (toot_content.getText().toString().startsWith("@")) {
toot_content.append("\n");
}else {
toot_content.setText(toot_content.getText().toString().trim());
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.requestFocus();
if (cursorReply > 0 && cursorReply < toot_content.getText().length())
toot_content.setSelection(cursorReply);
else
toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end
}
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.requestFocus();
toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end
}
}