Skip to content

Commit

Permalink
/issues/5114 - Polls in the timeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Dec 9, 2021
1 parent 96ef44f commit dcaba1b
Show file tree
Hide file tree
Showing 47 changed files with 1,706 additions and 211 deletions.
19 changes: 11 additions & 8 deletions Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,7 @@ final class BuildSettings: NSObject {
static let roomScreenAllowMediaLibraryAction: Bool = true
static let roomScreenAllowStickerAction: Bool = true
static let roomScreenAllowFilesAction: Bool = true
static var roomScreenAllowPollsAction: Bool {
guard #available(iOS 14, *) else {
return false
}

return false
}


/// Allow split view detail view stacking
static let allowSplitViewDetailsScreenStacking: Bool = true

Expand Down Expand Up @@ -349,4 +342,14 @@ final class BuildSettings: NSObject {

// MARK: - Secrets Recovery
static let secretsRecoveryAllowReset = true

// MARK: - Polls

static var pollsEnabled: Bool {
guard #available(iOS 14, *) else {
return false
}

return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "poll_checkbox_default.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "poll_checkbox_default@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "poll_checkbox_default@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "poll_checkbox_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "poll_checkbox_selected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "poll_checkbox_selected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "poll_winner_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "poll_winner_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "poll_winner_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 40 additions & 2 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ Tap the + to start adding people.";
"room_delete_unsent_messages" = "Delete unsent messages";
"room_event_action_copy" = "Copy";
"room_event_action_quote" = "Quote";
"room_event_action_remove_poll" = "Remove poll";
"room_event_action_end_poll" = "End poll";
"room_event_action_redact" = "Remove";
"room_event_action_more" = "More";
"room_event_action_share" = "Share";
Expand Down Expand Up @@ -567,7 +569,7 @@ Tap the + to start adding people.";
"settings_labs_create_conference_with_jitsi" = "Create conference calls with jitsi";
"settings_labs_message_reaction" = "React to messages with emoji";
"settings_labs_enable_ringing_for_group_calls" = "Ring for group calls";
"settings_labs_voice_messages" = "Voice messages";
"settings_labs_enabled_polls" = "Polls";

"settings_version" = "Version %@";
"settings_olm_version" = "Olm Version %@";
Expand Down Expand Up @@ -1793,6 +1795,42 @@ Tap the + to start adding people.";

"poll_edit_form_create_options" = "Create options";

"poll_edit_form_option_number" = "Option %d";
"poll_edit_form_option_number" = "Option %lu";

"poll_edit_form_add_option" = "Add option";

"poll_edit_form_post_failure_title" = "Failed to post poll";

"poll_edit_form_post_failure_subtitle" = "Please try again";

"poll_edit_form_post_failure_action" = "OK";

"poll_timeline_one_vote" = "1 vote";

"poll_timeline_votes_count" = "%lu votes";

"poll_timeline_total_no_votes" = "No votes cast";

"poll_timeline_total_one_vote" = "1 vote cast";

"poll_timeline_total_votes" = "%lu votes cast";

"poll_timeline_total_one_vote_not_voted" = "1 vote cast. Vote to the see the results";

"poll_timeline_total_votes_not_voted" = "%lu votes cast. Vote to the see the results";

"poll_timeline_total_final_results_one_vote" = "Final results based on 1 vote";

"poll_timeline_total_final_results" = "Final results based on %lu votes";

"poll_timeline_vote_not_registered_title" = "Vote not registered";

"poll_timeline_vote_not_registered_subtitle" = "Sorry, your vote was not registered, please try again";

"poll_timeline_vote_not_registered_action" = "OK";

"poll_timeline_not_closed_title" = "Failed to end poll";

"poll_timeline_not_closed_subtitle" = "Please try again";

"poll_timeline_not_closed_action" = "OK";
3 changes: 3 additions & 0 deletions Riot/Generated/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ internal enum Asset {
internal static let videoCall = ImageAsset(name: "video_call")
internal static let voiceCallHangonIcon = ImageAsset(name: "voice_call_hangon_icon")
internal static let voiceCallHangupIcon = ImageAsset(name: "voice_call_hangup_icon")
internal static let pollCheckboxDefault = ImageAsset(name: "poll_checkbox_default")
internal static let pollCheckboxSelected = ImageAsset(name: "poll_checkbox_selected")
internal static let pollDeleteIcon = ImageAsset(name: "poll_delete_icon")
internal static let pollDeleteOptionIcon = ImageAsset(name: "poll_delete_option_icon")
internal static let pollEditIcon = ImageAsset(name: "poll_edit_icon")
internal static let pollEndIcon = ImageAsset(name: "poll_end_icon")
internal static let pollWinnerIcon = ImageAsset(name: "poll_winner_icon")
internal static let urlPreviewClose = ImageAsset(name: "url_preview_close")
internal static let urlPreviewCloseDark = ImageAsset(name: "url_preview_close_dark")
internal static let voiceMessageCancelGradient = ImageAsset(name: "voice_message_cancel_gradient")
Expand Down
90 changes: 85 additions & 5 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2379,18 +2379,90 @@ public class VectorL10n: NSObject {
public static var pollEditFormInputPlaceholder: String {
return VectorL10n.tr("Vector", "poll_edit_form_input_placeholder")
}
/// Option %d
/// Option %lu
public static func pollEditFormOptionNumber(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_edit_form_option_number", p1)
}
/// Poll question or topic
public static var pollEditFormPollQuestionOrTopic: String {
return VectorL10n.tr("Vector", "poll_edit_form_poll_question_or_topic")
}
/// OK
public static var pollEditFormPostFailureAction: String {
return VectorL10n.tr("Vector", "poll_edit_form_post_failure_action")
}
/// Please try again
public static var pollEditFormPostFailureSubtitle: String {
return VectorL10n.tr("Vector", "poll_edit_form_post_failure_subtitle")
}
/// Failed to post poll
public static var pollEditFormPostFailureTitle: String {
return VectorL10n.tr("Vector", "poll_edit_form_post_failure_title")
}
/// Question or topic
public static var pollEditFormQuestionOrTopic: String {
return VectorL10n.tr("Vector", "poll_edit_form_question_or_topic")
}
/// OK
public static var pollTimelineNotClosedAction: String {
return VectorL10n.tr("Vector", "poll_timeline_not_closed_action")
}
/// Please try again
public static var pollTimelineNotClosedSubtitle: String {
return VectorL10n.tr("Vector", "poll_timeline_not_closed_subtitle")
}
/// Failed to end poll
public static var pollTimelineNotClosedTitle: String {
return VectorL10n.tr("Vector", "poll_timeline_not_closed_title")
}
/// 1 vote
public static var pollTimelineOneVote: String {
return VectorL10n.tr("Vector", "poll_timeline_one_vote")
}
/// Final results based on %lu votes
public static func pollTimelineTotalFinalResults(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_timeline_total_final_results", p1)
}
/// Final results based on 1 vote
public static var pollTimelineTotalFinalResultsOneVote: String {
return VectorL10n.tr("Vector", "poll_timeline_total_final_results_one_vote")
}
/// No votes cast
public static var pollTimelineTotalNoVotes: String {
return VectorL10n.tr("Vector", "poll_timeline_total_no_votes")
}
/// 1 vote cast
public static var pollTimelineTotalOneVote: String {
return VectorL10n.tr("Vector", "poll_timeline_total_one_vote")
}
/// 1 vote cast. Vote to the see the results
public static var pollTimelineTotalOneVoteNotVoted: String {
return VectorL10n.tr("Vector", "poll_timeline_total_one_vote_not_voted")
}
/// %lu votes cast
public static func pollTimelineTotalVotes(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_timeline_total_votes", p1)
}
/// %lu votes cast. Vote to the see the results
public static func pollTimelineTotalVotesNotVoted(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_timeline_total_votes_not_voted", p1)
}
/// OK
public static var pollTimelineVoteNotRegisteredAction: String {
return VectorL10n.tr("Vector", "poll_timeline_vote_not_registered_action")
}
/// Sorry, your vote was not registered, please try again
public static var pollTimelineVoteNotRegisteredSubtitle: String {
return VectorL10n.tr("Vector", "poll_timeline_vote_not_registered_subtitle")
}
/// Vote not registered
public static var pollTimelineVoteNotRegisteredTitle: String {
return VectorL10n.tr("Vector", "poll_timeline_vote_not_registered_title")
}
/// %lu votes
public static func pollTimelineVotesCount(_ p1: Int) -> String {
return VectorL10n.tr("Vector", "poll_timeline_votes_count", p1)
}
/// Preview
public static var preview: String {
return VectorL10n.tr("Vector", "preview")
Expand Down Expand Up @@ -2915,6 +2987,10 @@ public class VectorL10n: NSObject {
public static var roomEventActionEdit: String {
return VectorL10n.tr("Vector", "room_event_action_edit")
}
/// End poll
public static var roomEventActionEndPoll: String {
return VectorL10n.tr("Vector", "room_event_action_end_poll")
}
/// Forward
public static var roomEventActionForward: String {
return VectorL10n.tr("Vector", "room_event_action_forward")
Expand Down Expand Up @@ -2951,6 +3027,10 @@ public class VectorL10n: NSObject {
public static var roomEventActionRedact: String {
return VectorL10n.tr("Vector", "room_event_action_redact")
}
/// Remove poll
public static var roomEventActionRemovePoll: String {
return VectorL10n.tr("Vector", "room_event_action_remove_poll")
}
/// Reply
public static var roomEventActionReply: String {
return VectorL10n.tr("Vector", "room_event_action_reply")
Expand Down Expand Up @@ -4535,14 +4615,14 @@ public class VectorL10n: NSObject {
public static var settingsLabsEnableRingingForGroupCalls: String {
return VectorL10n.tr("Vector", "settings_labs_enable_ringing_for_group_calls")
}
/// Polls
public static var settingsLabsEnabledPolls: String {
return VectorL10n.tr("Vector", "settings_labs_enabled_polls")
}
/// React to messages with emoji
public static var settingsLabsMessageReaction: String {
return VectorL10n.tr("Vector", "settings_labs_message_reaction")
}
/// Voice messages
public static var settingsLabsVoiceMessages: String {
return VectorL10n.tr("Vector", "settings_labs_voice_messages")
}
/// LINKS
public static var settingsLinks: String {
return VectorL10n.tr("Vector", "settings_links")
Expand Down
3 changes: 3 additions & 0 deletions Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ final class RiotSettings: NSObject {

@UserDefault(key: "roomScreenAllowFilesAction", defaultValue: BuildSettings.roomScreenAllowFilesAction, storage: defaults)
var roomScreenAllowFilesAction

@UserDefault(key: "roomScreenAllowPollsAction", defaultValue: false, storage: defaults)
var roomScreenAllowPollsAction

@UserDefault(key: "roomScreenShowsURLPreviews", defaultValue: true, storage: defaults)
var roomScreenShowsURLPreviews
Expand Down
12 changes: 9 additions & 3 deletions Riot/Modules/MatrixKit/Models/MXKAppSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ -(instancetype)init
kMXEventTypeStringCallNegotiate,
kMXEventTypeStringSticker,
kMXEventTypeStringKeyVerificationCancel,
kMXEventTypeStringKeyVerificationDone
kMXEventTypeStringKeyVerificationDone,
kMXEventTypeStringPollStart,
kMXEventTypeStringPollStartMSC3381
].mutableCopy;


Expand Down Expand Up @@ -175,7 +177,9 @@ -(instancetype)init
kMXEventTypeStringCallNegotiate,
kMXEventTypeStringSticker,
kMXEventTypeStringKeyVerificationCancel,
kMXEventTypeStringKeyVerificationDone
kMXEventTypeStringKeyVerificationDone,
kMXEventTypeStringPollStart,
kMXEventTypeStringPollStartMSC3381
].mutableCopy;

lastMessageEventTypesAllowList = @[
Expand All @@ -186,7 +190,9 @@ -(instancetype)init
kMXEventTypeStringCallInvite,
kMXEventTypeStringCallAnswer,
kMXEventTypeStringCallHangup,
kMXEventTypeStringSticker
kMXEventTypeStringSticker,
kMXEventTypeStringPollStart,
kMXEventTypeStringPollStartMSC3381
].mutableCopy;

_messageDetailsAllowSharing = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ - (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomS

- (BOOL)addEvent:(MXEvent*)event andRoomState:(MXRoomState*)roomState
{
// Never merge polls
if (self.events.firstObject.eventType == MXEventTypePollStart) {
return NO;
}

// We group together text messages from the same user (attachments are not merged).
if ([event.sender isEqualToString:self.senderId] && (self.attachment == nil) && (self.bubbleComponents.count < self.maxComponentCount))
{
Expand Down Expand Up @@ -85,6 +90,11 @@ - (BOOL)addEvent:(MXEvent*)event andRoomState:(MXRoomState*)roomState

- (BOOL)mergeWithBubbleCellData:(id<MXKRoomBubbleCellDataStoring>)bubbleCellData
{
// Never merge polls
if (self.events.firstObject.eventType == MXEventTypePollStart) {
return NO;
}

if ([self hasSameSenderAsBubbleCellData:bubbleCellData])
{
MXKRoomBubbleCellData *cellData = (MXKRoomBubbleCellData*)bubbleCellData;
Expand Down
Loading

0 comments on commit dcaba1b

Please sign in to comment.