Adds URL when a media is added

This commit is contained in:
tom79 2017-08-14 19:07:07 +02:00
parent 8d2d82b37d
commit 2f321c2f17
1 changed files with 12 additions and 0 deletions

View File

@ -788,6 +788,12 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
imParams.height = (int) Helper.convertDpToPixel(100, getApplicationContext());
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
//Adds the url at the end of the toot
int selectionBefore = toot_content.getSelectionStart();
toot_content.setText(toot_content.getText().toString()+"\n"+attachment.getUrl());
//Moves the cursor
if( selectionBefore >= 0 )
toot_content.setSelection(selectionBefore);
toot_picture_container.addView(imageView, attachments.size(), imParams);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
@ -826,6 +832,12 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
for(Attachment attachment: attachments){
if( Integer.valueOf(attachment.getId()) == viewId){
attachments.remove(attachment);
//Adds the url at the end of the toot
int selectionBefore = toot_content.getSelectionStart();
toot_content.setText(toot_content.getText().toString().replace(attachment.getUrl(),""));
//Moves the cursor
if( selectionBefore >= 0 )
toot_content.setSelection(selectionBefore);
((ViewGroup) namebar.getParent()).removeView(namebar);
break;
}