fix mentions

This commit is contained in:
tom79 2019-07-05 18:34:44 +02:00
parent 8ccfb51c19
commit fe78f7c91d
2 changed files with 26 additions and 4 deletions

View File

@ -228,7 +228,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private Toast mToast;
private RelativeLayout drawer_layout;
private HorizontalScrollView picture_scrollview;
private int searchLength;
private TextView toot_space_left;
private String initialContent;
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 754;
@ -2381,6 +2380,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = accounts.get(position);
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
@ -2455,6 +2458,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String shortcode = emojis.get(position).getShortcode();
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
else {
@ -2605,6 +2612,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
return;
String tag = tags.get(position);
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
else {

View File

@ -303,7 +303,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
public void onRetrieveSearchAccounts(APIResponse apiResponse) {
if( apiResponse.getError() != null)
return;
int searchLength = 15;
final List<Account> accounts = apiResponse.getAccounts();
if( accounts != null && accounts.size() > 0){
int currentCursorPosition = toot_content.getSelectionStart();
@ -320,6 +320,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = accounts.get(position);
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
@ -356,7 +360,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
@Override
public void onRetrieveSearchEmoji(List<Emojis> emojis) {
int currentCursorPosition = toot_content.getSelectionStart();
int searchLength = 15;
if( emojis != null && emojis.size() > 0){
EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(context, emojis);
toot_content.setThreshold(1);
@ -369,6 +373,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String shortcode = emojis.get(position).getShortcode();
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
else {
@ -400,7 +408,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if( apiResponse == null || apiResponse.getResults() == null)
return;
int searchLength = 15;
app.fedilab.android.client.Entities.Results results = apiResponse.getResults();
int currentCursorPosition = toot_content.getSelectionStart();
final List<String> tags = results.getHashtags();
@ -423,6 +430,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
return;
String tag = tags.get(position);
String deltaSearch = "";
int searchLength = 15;
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
}
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
else {