diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index cb91616c06..389e6eb81f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -42,7 +42,6 @@ public class GlobalUserPreferences{ public static boolean showNewPostsButton; public static boolean toolbarMarquee; public static boolean disableSwipe; - public static boolean voteButtonForSingleChoice; public static boolean enableDeleteNotifications; public static boolean translateButtonOpenedOnly; public static boolean uniformNotificationIcon; @@ -117,7 +116,6 @@ public static void load(){ showNewPostsButton=prefs.getBoolean("showNewPostsButton", true); toolbarMarquee=prefs.getBoolean("toolbarMarquee", true); disableSwipe=prefs.getBoolean("disableSwipe", false); - voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true); enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", false); translateButtonOpenedOnly=prefs.getBoolean("translateButtonOpenedOnly", false); uniformNotificationIcon=prefs.getBoolean("uniformNotificationIcon", false); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 1ece949226..ea5bb55473 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -599,7 +599,8 @@ protected void updatePoll(String itemID, Status status, Poll poll){ public void onPollOptionClick(PollOptionStatusDisplayItem.Holder holder){ Poll poll=holder.getItem().poll; Poll.Option option=holder.getItem().option; - if(poll.multiple || GlobalUserPreferences.voteButtonForSingleChoice){ + // MEGALODON: always show vote button +// if(poll.multiple){ if(poll.selectedOptions==null) poll.selectedOptions=new ArrayList<>(); boolean optionContained=poll.selectedOptions.contains(option); @@ -614,7 +615,7 @@ public void onPollOptionClick(PollOptionStatusDisplayItem.Holder holder){ for(int i=0;i { new TimePickerDialog(getActivity(), (timePicker, hour, minute) -> { - updateScheduledAt(LocalDateTime.of(year, arrayMonth + 1, dayOfMonth, hour, minute) - .toInstant(OffsetDateTime.now().getOffset())); + LocalDateTime at=LocalDateTime.of(year, arrayMonth + 1, dayOfMonth, hour, minute); + updateScheduledAt(at.toInstant(ZoneId.systemDefault().getRules().getOffset(at))); }, soon.getHour(), soon.getMinute(), DateFormat.is24HourFormat(getActivity())).show(); }, soon.getYear(), soon.getMonthValue() - 1, soon.getDayOfMonth()).show(); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java index 0994392715..2443e997db 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java @@ -6,7 +6,6 @@ import android.widget.Button; import android.widget.TextView; -import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Poll; @@ -32,6 +31,7 @@ public Type getType(){ public static class Holder extends StatusDisplayItem.Holder{ private TextView text; private Button voteButton, resultsButton; + private ViewGroup wrapper; public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_poll_footer, parent); @@ -39,28 +39,30 @@ public Holder(Activity activity, ViewGroup parent){ voteButton=findViewById(R.id.vote_btn); voteButton.setOnClickListener(v->item.parentFragment.onPollVoteButtonClick(this)); resultsButton=findViewById(R.id.results_btn); + wrapper=findViewById(R.id.wrapper); resultsButton.setOnClickListener(v-> { item.resultsVisible = !item.resultsVisible; item.parentFragment.onPollViewResultsButtonClick(this, item.resultsVisible); rebind(); + UiUtils.beginLayoutTransition(wrapper); }); } @Override public void onBind(PollFooterStatusDisplayItem item){ String text=item.parentFragment.getResources().getQuantityString(R.plurals.x_votes, item.poll.votesCount, item.poll.votesCount); - String sep=item.parentFragment.getString(R.string.sk_separator); - if(item.poll.expiresAt!=null && !item.poll.isExpired()){ - text+=" "+sep+" "+UiUtils.formatTimeLeft(itemView.getContext(), item.poll.expiresAt); - if(item.poll.multiple) - text+=" "+sep+" "+item.parentFragment.getString(R.string.poll_multiple_choice); - }else if(item.poll.isExpired()){ - text+=" "+sep+" "+item.parentFragment.getString(R.string.poll_closed); - } + String sep=" "+item.parentFragment.getString(R.string.sk_separator)+" "; + if(item.poll.expiresAt!=null && !item.poll.isExpired()) + text+=sep+UiUtils.formatTimeLeft(itemView.getContext(), item.poll.expiresAt).replaceAll(" ", " "); + else if(item.poll.isExpired()) + text+=sep+item.parentFragment.getString(R.string.poll_closed).replaceAll(" ", " "); + if(item.poll.multiple) + text+=sep+item.parentFragment.getString(R.string.sk_poll_multiple_choice).replaceAll(" ", " "); this.text.setText(text); resultsButton.setVisibility(item.poll.isExpired() || item.poll.voted ? View.GONE : View.VISIBLE); - resultsButton.setText(item.resultsVisible ? R.string.sk_poll_view : R.string.sk_poll_results); - voteButton.setVisibility(item.poll.isExpired() || item.poll.voted || (!item.poll.multiple && !GlobalUserPreferences.voteButtonForSingleChoice) ? View.GONE : View.VISIBLE); + resultsButton.setText(item.resultsVisible ? R.string.sk_poll_hide_results : R.string.sk_poll_show_results); + resultsButton.setSelected(item.resultsVisible); + voteButton.setVisibility(item.poll.isExpired() || item.poll.voted ? View.GONE : View.VISIBLE); voteButton.setEnabled(item.poll.selectedOptions!=null && !item.poll.selectedOptions.isEmpty() && !item.resultsVisible); } } diff --git a/mastodon/src/main/res/layout/display_item_poll_footer.xml b/mastodon/src/main/res/layout/display_item_poll_footer.xml index 824f776307..132221bf67 100644 --- a/mastodon/src/main/res/layout/display_item_poll_footer.xml +++ b/mastodon/src/main/res/layout/display_item_poll_footer.xml @@ -6,18 +6,38 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:layout_height="wrap_content"> + + + +