Fix position

This commit is contained in:
tom79 2019-09-29 16:55:59 +02:00
parent afecf51bfa
commit d0e3549278
2 changed files with 37 additions and 3 deletions

View File

@ -3600,6 +3600,36 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
}
public static String manageMentions(Context context, String userIdReply, Status tootReply) {
String contentView = "";
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
ArrayList<String> mentionedAccountsAdded = new ArrayList<>();
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
if (tootReply.getAccount() != null && tootReply.getAccount().getAcct() != null && !tootReply.getAccount().getId().equals(userIdReply)) {
contentView = String.format("@%s", tootReply.getAccount().getAcct());
mentionedAccountsAdded.add(tootReply.getAccount().getAcct());
//Evaluate the cursor position => mention length + 1 char for carriage return
}
if (tootReply.getMentions() != null) {
//Put other accounts mentioned at the bottom
contentView = String.format("%s", (contentView + " "));
for (Mention mention : tootReply.getMentions()) {
if (mention.getAcct() != null && !mention.getId().equals(userIdReply) && !mentionedAccountsAdded.contains(mention.getAcct())) {
mentionedAccountsAdded.add(mention.getAcct());
String tootTemp = String.format("@%s ", mention.getAcct());
contentView = String.format("%s ", (contentView + tootTemp.trim()));
}
}
contentView = contentView.trim();
if (contentView.startsWith("@")) {
contentView += " ";
}
}
return contentView;
}
private void displayPollPopup() {
AlertDialog.Builder alertPoll = new AlertDialog.Builder(TootActivity.this, style);
alertPoll.setTitle(R.string.create_poll);

View File

@ -446,22 +446,26 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
mLayoutManager = new LinearLayoutManager(context);
holder.lv_comments.setLayoutManager(mLayoutManager);
holder.lv_comments.setAdapter(statusListAdapter);
mLayoutManager.scrollToPositionWithOffset(i, 0);
}else{
status.setCommentsFetched(true);
new RetrieveContextAsyncTask(context, false, false, status.getId(),PixelfedListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
holder.quick_reply_text.requestFocus();
EditText content_cw = new EditText(context);
content_cw.setText(status.getReblog() != null ? status.getReblog().getSpoiler_text() : status.getSpoiler_text());
TootActivity.manageMentions(context, social, userId,
holder.quick_reply_text, content_cw, holder.toot_space_left, status.getReblog() != null ? status.getReblog() : status);
String content = TootActivity.manageMentions(context, userId,status.getReblog() != null ? status.getReblog() : status);
TextWatcher textWatcher = TootActivity.initializeTextWatcher(context, social, holder.quick_reply_text, content_cw, holder.toot_space_left, null, null, PixelfedListAdapter.this, PixelfedListAdapter.this, PixelfedListAdapter.this);
holder.quick_reply_text.setText(content);
comment_content = holder.quick_reply_text;
holder.quick_reply_text.setFocusable(true);
holder.quick_reply_text.requestFocus();
holder.quick_reply_text.setSelection(content.length()); //Put cursor at the end
int newInputType = comment_content.getInputType() & (comment_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
comment_content.setInputType(newInputType);
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
tootReply = status;
if (theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK) {
changeDrawableColor(context, R.drawable.emoji_one_category_smileysandpeople, R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_public_toot, R.color.dark_text);