diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 2e7345fce9..50efa98325 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -200,7 +200,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr public Instance instance; public Status editingStatus; - private ScheduledStatus scheduledStatus; + public ScheduledStatus scheduledStatus; private boolean redraftStatus; private ContentType contentType; diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/ScheduledStatus.java b/mastodon/src/main/java/org/joinmastodon/android/model/ScheduledStatus.java index 309bb46469..0f2af6cb6c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/ScheduledStatus.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/ScheduledStatus.java @@ -6,6 +6,7 @@ import org.parceler.Parcel; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.stream.Collectors; @@ -27,10 +28,10 @@ public String getID() { @Override public void postprocess() throws ObjectValidationException { super.postprocess(); - if (mediaAttachments == null) mediaAttachments = List.of(); + if(mediaAttachments==null) mediaAttachments=List.of(); for(Attachment a:mediaAttachments) a.postprocess(); - if (params != null) params.postprocess(); + if(params!=null) params.postprocess(); } @Parcel @@ -53,7 +54,7 @@ public static class Params extends BaseModel { @Override public void postprocess() throws ObjectValidationException { super.postprocess(); - if (poll != null) poll.postprocess(); + if(poll!=null) poll.postprocess(); } } @@ -67,25 +68,26 @@ public static class ScheduledPoll extends BaseModel { public boolean hideTotals; public Poll toPoll() { - Poll p = new Poll(); - p.voted = true; - p.emojis = List.of(); - p.ownVotes = List.of(); - p.multiple = multiple; - p.options = options.stream().map(Option::new).collect(Collectors.toList()); + Poll p=new Poll(); + p.voted=true; + p.emojis=List.of(); + p.ownVotes=List.of(); + p.multiple=multiple; + p.options=options.stream().map(Option::new).collect(Collectors.toList()); + p.expiresAt=Instant.now().plus(Integer.parseInt(expiresIn)+1, ChronoUnit.SECONDS); return p; } } public Status toStatus() { - Status s = Status.ofFake(id, params.text, scheduledAt); - s.mediaAttachments = mediaAttachments; - s.inReplyToId = params.inReplyToId > 0 ? "" + params.inReplyToId : null; - s.spoilerText = params.spoilerText; - s.visibility = params.visibility; - s.language = params.language; - s.sensitive = params.sensitive; - if (params.poll != null) s.poll = params.poll.toPoll(); + Status s=Status.ofFake(id, params.text, scheduledAt); + s.mediaAttachments=mediaAttachments; + s.inReplyToId=params.inReplyToId>0 ? ""+params.inReplyToId : null; + s.spoilerText=params.spoilerText; + s.visibility=params.visibility; + s.language=params.language; + s.sensitive=params.sensitive; + if(params.poll!=null) s.poll=params.poll.toPoll(); return s; } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java index 05c61b8d30..aa72ec7240 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java @@ -134,7 +134,10 @@ public void setView(View view, Bundle savedInstanceState){ DraftPollOption opt=createDraftPollOption(false); opt.edit.setText(eopt.title); } - pollDuration=(int)fragment.editingStatus.poll.expiresAt.minus(fragment.editingStatus.createdAt.toEpochMilli(), ChronoUnit.MILLIS).getEpochSecond(); + if(fragment.scheduledStatus!=null && fragment.scheduledStatus.params.poll!=null) + pollDuration=Integer.parseInt(fragment.scheduledStatus.params.poll.expiresIn); + else if(fragment.editingStatus.poll.expiresAt!=null) + pollDuration=(int)fragment.editingStatus.poll.expiresAt.minus(fragment.editingStatus.createdAt.toEpochMilli(), ChronoUnit.MILLIS).getEpochSecond(); updatePollOptionHints(); pollDurationValue.setText(UiUtils.formatDuration(fragment.getContext(), pollDuration)); pollIsMultipleChoice=fragment.editingStatus.poll.multiple;