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" applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 27 targetSdkVersion 27
versionCode 97 versionCode 98
versionName "1.6.9" versionName "1.6.9.1"
} }
flavorDimensions "default" flavorDimensions "default"
buildTypes { 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 //Evaluate the cursor position => mention length + 1 char for carriage return
cursorReply = toot_content.getText().toString().length() + 1; 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 //Put other accounts mentioned at the bottom
toot_content.setText(String.format("%s", (toot_content.getText().toString() + "\n\n"))); toot_content.setText(String.format("%s", (toot_content.getText().toString() + "\n\n")));
for(Mention mention : tootReply.getMentions()){ 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(String.format("%s ", (toot_content.getText().toString() + tootTemp.trim())));
} }
} }
toot_content.setText(toot_content.getText().toString().trim()); if( mentionedAccountsAdded.size() == 1){
toot_space_left.setText(String.valueOf(toot_content.length())); toot_content.setText(toot_content.getText().toString().trim());
toot_content.requestFocus(); if (toot_content.getText().toString().startsWith("@")) {
if( cursorReply > 0 && cursorReply < toot_content.getText().length()) toot_content.append("\n");
toot_content.setSelection(cursorReply); }
else toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.requestFocus();
toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end
}else{ }else {
toot_content.setText(toot_content.getText().toString().trim()); toot_content.setText(toot_content.getText().toString().trim());
if (toot_content.getText().toString().startsWith("@")) { toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.append("\n"); 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
} }
} }