Merged original_master into PhotonQyv-Baseline

This commit is contained in:
PhotonQyv 2017-10-15 19:30:21 +01:00
commit a14763e60c
5 changed files with 39 additions and 32 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 26
versionCode 62
versionName "1.5.2"
versionCode 63
versionName "1.5.3"
}
buildTypes {
release {

View File

@ -1214,35 +1214,37 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_content.setAdapter(accountsListAdapter);
final String oldContent = toot_content.getText().toString();
String[] searchA = oldContent.substring(0,currentCursorPosition).split("@");
final String search = searchA[searchA.length-1];
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = accounts.get(position);
String deltaSearch = "";
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
else {
if( currentCursorPosition >= oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, oldContent.length());
}
if( searchA.length > 0 ) {
final String search = searchA[searchA.length - 1];
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = accounts.get(position);
String deltaSearch = "";
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
if (currentCursorPosition >= oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
}
if( !search.equals(""))
deltaSearch = deltaSearch.replace("@"+search,"");
String newContent = oldContent.substring(0,currentCursorPosition-searchLength);
newContent += deltaSearch;
newContent += "@" + account.getAcct() + " ";
int newPosition = newContent.length();
if( currentCursorPosition < oldContent.length() - 1)
newContent += oldContent.substring(currentCursorPosition, oldContent.length()-1);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, new ArrayList<Account>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter);
}
});
if (!search.equals(""))
deltaSearch = deltaSearch.replace("@" + search, "");
String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
newContent += deltaSearch;
newContent += "@" + account.getAcct() + " ";
int newPosition = newContent.length();
if (currentCursorPosition < oldContent.length() - 1)
newContent += oldContent.substring(currentCursorPosition, oldContent.length() - 1);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, new ArrayList<Account>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter);
}
});
}
}
}

View File

@ -43,7 +43,7 @@ public class RetrieveSearchAccountsAsyncTask extends AsyncTask<Void, Void, Void>
@Override
protected Void doInBackground(Void... params) {
API api = new API(context);
apiResponse = api.searchAccounts(query, 10);
apiResponse = api.searchAccounts(query, 20);
return null;
}

View File

@ -125,7 +125,7 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
holder.account_un.setText(String.format("@%s", account.getUsername() + "@" + instance));
holder.account_dn.setVisibility(View.GONE);
}else {
holder.account_un.setText(String.format("@%s", account.getUsername()));
holder.account_un.setText(String.format("@%s", account.getAcct()));
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
holder.account_dn.setVisibility(View.VISIBLE);
}

View File

@ -385,6 +385,11 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
retrieveMissingToots(statuses.get(0).getId());
}
}
int index = lv_status.getFirstVisiblePosition();
View v = lv_status.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();
statusListAdapter.notifyDataSetChanged();
lv_status.setSelectionFromTop(index, top);
}
/**