Skip to content

Commit

Permalink
Enable URL Previews by default and remove from Labs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Sep 16, 2021
1 parent e1d5a33 commit 96ef61a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 29 deletions.
1 change: 1 addition & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ Tap the + to start adding people.";

"settings_user_settings" = "USER SETTINGS";
"settings_sending_media" = "SENDING IMAGES AND VIDEOS";
"settings_links" = "LINKS";
"settings_notifications" = "NOTIFICATIONS";
"settings_calls_settings" = "CALLS";
"settings_discovery_settings" = "DISCOVERY";
Expand Down
4 changes: 4 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4426,6 +4426,10 @@ internal enum VectorL10n {
internal static var settingsLabsVoiceMessages: String {
return VectorL10n.tr("Vector", "settings_labs_voice_messages")
}
/// LINKS
internal static var settingsLinks: String {
return VectorL10n.tr("Vector", "settings_links")
}
/// Mark all messages as read
internal static var settingsMarkAllAsRead: String {
return VectorL10n.tr("Vector", "settings_mark_all_as_read")
Expand Down
3 changes: 1 addition & 2 deletions Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ final class RiotSettings: NSObject {
@UserDefault(key: "roomScreenAllowFilesAction", defaultValue: BuildSettings.roomScreenAllowFilesAction, storage: defaults)
var roomScreenAllowFilesAction

// labs prefix added to the key can be dropped when default value becomes true
@UserDefault(key: "labsRoomScreenShowsURLPreviews", defaultValue: false, storage: defaults)
@UserDefault(key: "roomScreenShowsURLPreviews", defaultValue: true, storage: defaults)
var roomScreenShowsURLPreviews

// MARK: - Room Contextual Menu
Expand Down
66 changes: 39 additions & 27 deletions Riot/Modules/Settings/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
SECTION_TAG_SIGN_OUT = 0,
SECTION_TAG_USER_SETTINGS,
SECTION_TAG_SENDING_MEDIA,
SECTION_TAG_LINKS,
SECTION_TAG_SECURITY,
SECTION_TAG_NOTIFICATIONS,
SECTION_TAG_CALLS,
Expand Down Expand Up @@ -93,6 +94,12 @@
SENDING_MEDIA_CONFIRM_SIZE_DESCRIPTION,
};

enum
{
LINKS_SHOW_URL_PREVIEWS_INDEX = 0,
LINKS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX
};

enum
{
NOTIFICATION_SETTINGS_ENABLE_PUSH_INDEX = 0,
Expand Down Expand Up @@ -153,9 +160,7 @@

enum
{
LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX = 0,
LABS_SHOW_URL_PREVIEWS_INDEX,
LABS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX
LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX = 0
};

enum
Expand Down Expand Up @@ -372,6 +377,12 @@ - (void)updateSections
[tmpSections addObject:sectionMedia];
}

Section *sectionLinks = [Section sectionWithTag:SECTION_TAG_LINKS];
[sectionLinks addRowWithTag:LINKS_SHOW_URL_PREVIEWS_INDEX];
[sectionLinks addRowWithTag:LINKS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX];
sectionLinks.headerTitle = NSLocalizedStringFromTable(@"settings_links", @"Vector", nil);
[tmpSections addObject:sectionLinks];

Section *sectionSecurity = [Section sectionWithTag:SECTION_TAG_SECURITY];
[sectionSecurity addRowWithTag:SECURITY_BUTTON_INDEX];
sectionSecurity.headerTitle = NSLocalizedStringFromTable(@"settings_security", @"Vector", nil);
Expand Down Expand Up @@ -532,8 +543,6 @@ - (void)updateSections
{
Section *sectionLabs = [Section sectionWithTag:SECTION_TAG_LABS];
[sectionLabs addRowWithTag:LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX];
[sectionLabs addRowWithTag:LABS_SHOW_URL_PREVIEWS_INDEX];
[sectionLabs addRowWithTag:LABS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX];
sectionLabs.headerTitle = NSLocalizedStringFromTable(@"settings_labs", @"Vector", nil);
if (sectionLabs.hasAnyRows)
{
Expand Down Expand Up @@ -1871,6 +1880,31 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = infoCell;
}
}
else if (section == SECTION_TAG_LINKS)
{
if (row == LINKS_SHOW_URL_PREVIEWS_INDEX)
{
MXKTableViewCellWithLabelAndSwitch *labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];

labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_url_previews", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.roomScreenShowsURLPreviews;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;

[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableURLPreviews:) forControlEvents:UIControlEventValueChanged];

cell = labelAndSwitchCell;
}
else if (row == LINKS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX)
{
MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView];
descriptionCell.textLabel.text = NSLocalizedStringFromTable(@"settings_show_url_previews_description", @"Vector", nil);
descriptionCell.textLabel.numberOfLines = 0;
descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone;

cell = descriptionCell;
}
}
else if (section == SECTION_TAG_NOTIFICATIONS)
{
if (row == NOTIFICATION_SETTINGS_ENABLE_PUSH_INDEX)
Expand Down Expand Up @@ -2396,28 +2430,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

cell = labelAndSwitchCell;
}
else if (row == LABS_SHOW_URL_PREVIEWS_INDEX)
{
MXKTableViewCellWithLabelAndSwitch *labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];

labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_show_url_previews", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.roomScreenShowsURLPreviews;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;

[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableURLPreviews:) forControlEvents:UIControlEventValueChanged];

cell = labelAndSwitchCell;
}
else if (row == LABS_SHOW_URL_PREVIEWS_DESCRIPTION_INDEX)
{
MXKTableViewCell *descriptionCell = [self getDefaultTableViewCell:tableView];
descriptionCell.textLabel.text = NSLocalizedStringFromTable(@"settings_show_url_previews_description", @"Vector", nil);
descriptionCell.textLabel.numberOfLines = 0;
descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone;

cell = descriptionCell;
}
}
else if (section == SECTION_TAG_FLAIR)
{
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4828.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
URL Previews: Enable by default and remove from labs.

0 comments on commit 96ef61a

Please sign in to comment.