forked from mirrors/Fedilab
Add support to edit media
This commit is contained in:
parent
25d3803e69
commit
33b8dd36e4
3 changed files with 21 additions and 5 deletions
|
@ -91,10 +91,12 @@ public interface MastodonStatusesService {
|
||||||
@Field("sensitive") Boolean sensitive,
|
@Field("sensitive") Boolean sensitive,
|
||||||
@Field("spoiler_text") String spoiler_text,
|
@Field("spoiler_text") String spoiler_text,
|
||||||
@Field("visibility") String visibility,
|
@Field("visibility") String visibility,
|
||||||
@Field("language") String language
|
@Field("language") String language,
|
||||||
|
@Field("media_attributes[id][]") List<String> media_id,
|
||||||
|
@Field("media_attributes[description][]") List<String> media_description,
|
||||||
|
@Field("media_attributes[focus][]") List<String> focus
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//Post a scheduled status
|
//Post a scheduled status
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST("statuses")
|
@POST("statuses")
|
||||||
|
|
|
@ -158,6 +158,9 @@ public class ComposeWorker extends Worker {
|
||||||
}
|
}
|
||||||
dataPost.messageToSend = statuses.size() - startingPosition;
|
dataPost.messageToSend = statuses.size() - startingPosition;
|
||||||
dataPost.messageSent = 0;
|
dataPost.messageSent = 0;
|
||||||
|
List<String> media_edit_id = null;
|
||||||
|
List<String> media_edit_description = null;
|
||||||
|
List<String> media_edit_focus = null;
|
||||||
for (int i = startingPosition; i < statuses.size(); i++) {
|
for (int i = startingPosition; i < statuses.size(); i++) {
|
||||||
if (dataPost.notificationBuilder != null) {
|
if (dataPost.notificationBuilder != null) {
|
||||||
dataPost.notificationBuilder.setProgress(100, dataPost.messageSent * 100 / dataPost.messageToSend, true);
|
dataPost.notificationBuilder.setProgress(100, dataPost.messageSent * 100 / dataPost.messageToSend, true);
|
||||||
|
@ -170,7 +173,15 @@ public class ComposeWorker extends Worker {
|
||||||
attachmentIds = new ArrayList<>();
|
attachmentIds = new ArrayList<>();
|
||||||
for (Attachment attachment : statuses.get(i).media_attachments) {
|
for (Attachment attachment : statuses.get(i).media_attachments) {
|
||||||
if (attachment.id != null) {
|
if (attachment.id != null) {
|
||||||
|
if (media_edit_id == null) {
|
||||||
|
media_edit_id = new ArrayList<>();
|
||||||
|
media_edit_description = new ArrayList<>();
|
||||||
|
media_edit_focus = new ArrayList<>();
|
||||||
|
}
|
||||||
attachmentIds.add(attachment.id);
|
attachmentIds.add(attachment.id);
|
||||||
|
media_edit_id.add(attachment.id);
|
||||||
|
media_edit_description.add(attachment.description);
|
||||||
|
media_edit_focus.add(attachment.focus);
|
||||||
} else {
|
} else {
|
||||||
MultipartBody.Part fileMultipartBody;
|
MultipartBody.Part fileMultipartBody;
|
||||||
if (watermark && attachment.mimeType != null && attachment.mimeType.contains("image")) {
|
if (watermark && attachment.mimeType != null && attachment.mimeType.contains("image")) {
|
||||||
|
@ -221,13 +232,16 @@ public class ComposeWorker extends Worker {
|
||||||
if (statuses.get(i).local_only) {
|
if (statuses.get(i).local_only) {
|
||||||
statuses.get(i).text += " \uD83D\uDC41";
|
statuses.get(i).text += " \uD83D\uDC41";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataPost.scheduledDate == null) {
|
if (dataPost.scheduledDate == null) {
|
||||||
if (dataPost.statusEditId == null) {
|
if (dataPost.statusEditId == null) {
|
||||||
statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
|
statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
|
||||||
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language, statuses.get(i).quote_id, statuses.get(i).content_type);
|
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language, statuses.get(i).quote_id, statuses.get(i).content_type);
|
||||||
} else { //Status is edited
|
} else { //Status is edited
|
||||||
statusCall = mastodonStatusesService.updateStatus(null, dataPost.token, dataPost.statusEditId, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
|
statusCall = mastodonStatusesService.updateStatus(null, dataPost.token, dataPost.statusEditId, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in,
|
||||||
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive, statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language);
|
poll_multiple, poll_hide_totals, statuses.get(i).quote_id == null ? in_reply_to_status : null, statuses.get(i).sensitive,
|
||||||
|
statuses.get(i).spoilerChecked ? statuses.get(i).spoiler_text : null, statuses.get(i).visibility.toLowerCase(), language,
|
||||||
|
media_edit_id, media_edit_description, media_edit_focus);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Response<Status> statusResponse = statusCall.execute();
|
Response<Status> statusResponse = statusCall.execute();
|
||||||
|
|
|
@ -1046,12 +1046,12 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
for (Attachment attachment : attachmentList) {
|
for (Attachment attachment : attachmentList) {
|
||||||
ComposeAttachmentItemBinding composeAttachmentItemBinding = ComposeAttachmentItemBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
ComposeAttachmentItemBinding composeAttachmentItemBinding = ComposeAttachmentItemBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
||||||
composeAttachmentItemBinding.buttonPlay.setVisibility(View.GONE);
|
composeAttachmentItemBinding.buttonPlay.setVisibility(View.GONE);
|
||||||
if (editMessageId != null && attachment.url != null) {
|
/* if (editMessageId != null && attachment.url != null) {
|
||||||
composeAttachmentItemBinding.editPreview.setVisibility(View.GONE);
|
composeAttachmentItemBinding.editPreview.setVisibility(View.GONE);
|
||||||
composeAttachmentItemBinding.buttonDescription.setVisibility(View.INVISIBLE);
|
composeAttachmentItemBinding.buttonDescription.setVisibility(View.INVISIBLE);
|
||||||
composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.INVISIBLE);
|
composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.INVISIBLE);
|
||||||
composeAttachmentItemBinding.buttonOrderUp.setVisibility(View.INVISIBLE);
|
composeAttachmentItemBinding.buttonOrderUp.setVisibility(View.INVISIBLE);
|
||||||
}
|
}*/
|
||||||
String attachmentPath = attachment.local_path != null && !attachment.local_path.trim().isEmpty() ? attachment.local_path : attachment.preview_url;
|
String attachmentPath = attachment.local_path != null && !attachment.local_path.trim().isEmpty() ? attachment.local_path : attachment.preview_url;
|
||||||
if (attachment.type != null || attachment.mimeType != null) {
|
if (attachment.type != null || attachment.mimeType != null) {
|
||||||
if ((attachment.type != null && attachment.type.toLowerCase().startsWith("image")) || (attachment.mimeType != null && attachment.mimeType.toLowerCase().startsWith("image"))) {
|
if ((attachment.type != null && attachment.type.toLowerCase().startsWith("image")) || (attachment.mimeType != null && attachment.mimeType.toLowerCase().startsWith("image"))) {
|
||||||
|
|
Loading…
Reference in a new issue