From 3d75c4ad84e35c6da2d1096029e00e9cb6890c97 Mon Sep 17 00:00:00 2001 From: Arnfried Griesert Date: Fri, 16 Feb 2024 06:46:48 +0000 Subject: [PATCH] MESSENGER-5610 change profile hint --- Config/BWIBuildSettings.swift | 4 ++ .../BuM-Beta/BWIBuildSettings+BuM-Beta.swift | 1 + Riot/Assets/de.lproj/Bwi.strings | 1 + Riot/Assets/en.lproj/Bwi.strings | 1 + Riot/Modules/MatrixKit/MatrixKit.h | 1 + .../Modules/Settings/SettingsViewController.m | 17 ++++- ...BWITableViewCellWithLabelAndMXKImageView.h | 49 +++++++++++++ ...BWITableViewCellWithLabelAndMXKImageView.m | 44 ++++++++++++ ...ITableViewCellWithLabelAndMXKImageView.xib | 68 +++++++++++++++++++ 9 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.h create mode 100644 bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.m create mode 100644 bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.xib diff --git a/Config/BWIBuildSettings.swift b/Config/BWIBuildSettings.swift index 3d8ce4d43..3f6c90d2a 100644 --- a/Config/BWIBuildSettings.swift +++ b/Config/BWIBuildSettings.swift @@ -719,4 +719,8 @@ class BWIBuildSettings: NSObject { // MARK: Room Participants // activates swipe gesture action to remove participants from room (RoomParticipantsViewController) var bwiCanEditRoomParticipants = false + + // MARK: Profile picture hint + // (only when federation is enabled) + var showChangeProfilePictureHint = false } diff --git a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift index ac974d5d0..37ae265d6 100644 --- a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift +++ b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift @@ -37,6 +37,7 @@ extension BWIBuildSettings { showMaintenanceInfoMessageType = true ignoreBlockingMaintenance = true bwiUseWellKnownPrivacyPolicyLink = true + showChangeProfilePictureHint = true itunesAppLink = "https://apps.apple.com/de/app/bundesmessenger/id1616866351" avoidServerSelectionOnAppConfig = true diff --git a/Riot/Assets/de.lproj/Bwi.strings b/Riot/Assets/de.lproj/Bwi.strings index 0c35a3119..e8a3cd038 100644 --- a/Riot/Assets/de.lproj/Bwi.strings +++ b/Riot/Assets/de.lproj/Bwi.strings @@ -220,6 +220,7 @@ "settings_about" = "Erweitert"; "bwi_settings_ignored_users_text" = "Ignorierte Nutzer"; "settings_imprint" = "Impressum"; +"settings_change_profile_avatar_hint" = "Auch Nutzer aus föderierten Organisationen können dein Profilbild sehen."; // MARK: - Room Details diff --git a/Riot/Assets/en.lproj/Bwi.strings b/Riot/Assets/en.lproj/Bwi.strings index dddc7b134..1f2af2ba1 100644 --- a/Riot/Assets/en.lproj/Bwi.strings +++ b/Riot/Assets/en.lproj/Bwi.strings @@ -176,6 +176,7 @@ "settings_deactivate_my_account" = "Deactivate my account"; "settings_enable_inapp_notifications" = "Enable In-App notifications"; "settings_imprint" = "Imprint"; +"settings_change_profile_avatar_hint" = "Users from federated organizations can also see your profile picture."; // MARK: - Room Details diff --git a/Riot/Modules/MatrixKit/MatrixKit.h b/Riot/Modules/MatrixKit/MatrixKit.h index ce6ea5f1e..ed974483a 100644 --- a/Riot/Modules/MatrixKit/MatrixKit.h +++ b/Riot/Modules/MatrixKit/MatrixKit.h @@ -97,6 +97,7 @@ #import "MXKTableViewCellWithLabelAndButton.h" #import "MXKTableViewCellWithLabelAndImageView.h" #import "MXKTableViewCellWithLabelAndMXKImageView.h" +#import "BWITableViewCellWithLabelAndMXKImageView.h" // bwi: 5610 #import "MXKTableViewCellWithLabelAndSlider.h" #import "MXKTableViewCellWithLabelAndSubLabel.h" #import "MXKTableViewCellWithLabelAndSwitch.h" diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 6c3b97464..86e9458e9 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -878,6 +878,7 @@ SSOAuthenticationPresenterDelegate> [self.tableView registerClass:MXKTableViewCellWithLabelAndTextField.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndTextField defaultReuseIdentifier]]; [self.tableView registerClass:MXKTableViewCellWithLabelAndSwitch.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]]; [self.tableView registerClass:MXKTableViewCellWithLabelAndMXKImageView.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndMXKImageView defaultReuseIdentifier]]; + [self.tableView registerClass:BWITableViewCellWithLabelAndMXKImageView.class forCellReuseIdentifier:[BWITableViewCellWithLabelAndMXKImageView defaultReuseIdentifier]]; // bwi: 5610 [self.tableView registerClass:TableViewCellWithPhoneNumberTextField.class forCellReuseIdentifier:[TableViewCellWithPhoneNumberTextField defaultReuseIdentifier]]; [self.tableView registerNib:MXKTableViewCellWithTextView.nib forCellReuseIdentifier:[MXKTableViewCellWithTextView defaultReuseIdentifier]]; [self.tableView registerNib:SectionFooterView.nib forHeaderFooterViewReuseIdentifier:[SectionFooterView defaultReuseIdentifier]]; @@ -2004,13 +2005,20 @@ SSOAuthenticationPresenterDelegate> if (row == USER_SETTINGS_PROFILE_PICTURE_INDEX) { - MXKTableViewCellWithLabelAndMXKImageView *profileCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithLabelAndMXKImageView defaultReuseIdentifier] forIndexPath:indexPath]; + BWITableViewCellWithLabelAndMXKImageView *profileCell = [tableView dequeueReusableCellWithIdentifier:[BWITableViewCellWithLabelAndMXKImageView defaultReuseIdentifier] forIndexPath:indexPath]; // bwi: keep reference to cell image view bwiProfileImage = profileCell.mxkImageView; profileCell.mxkLabelLeadingConstraint.constant = tableView.vc_separatorInset.left; profileCell.mxkImageViewTrailingConstraint.constant = 10; + + profileCell.bwiHintLeadingConstraint.constant = tableView.vc_separatorInset.left; + if(![BWIBuildSettings.shared showChangeProfilePictureHint] || ![BWIBuildSettings.shared isFederationEnabled]) { + // Change constraints to get the default spacing when no hint is shown + profileCell.bwiHintTopConstraint.constant = 0; + profileCell.bwiHintBottomConstraint.constant = 5.5; + } profileCell.mxkImageViewWidthConstraint.constant = profileCell.mxkImageViewHeightConstraint.constant = 30; profileCell.mxkImageViewDisplayBoxType = MXKTableViewCellDisplayBoxTypeCircle; @@ -2026,6 +2034,13 @@ SSOAuthenticationPresenterDelegate> profileCell.accessibilityIdentifier=@"SettingsVCProfilPictureStaticText"; profileCell.mxkLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + if([BWIBuildSettings.shared showChangeProfilePictureHint] && [BWIBuildSettings.shared isFederationEnabled]) { + profileCell.bwiHint.text = [BWIL10n settingsChangeProfileAvatarHint]; + profileCell.bwiHint.textColor = ThemeService.shared.theme.textSecondaryColor; + } else { + profileCell.bwiHint.text = nil; + } + // if the user defines a new avatar if (newAvatarImage) { diff --git a/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.h b/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.h new file mode 100644 index 000000000..010e4a7e4 --- /dev/null +++ b/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.h @@ -0,0 +1,49 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "MXKTableViewCell.h" + +#import "MXKImageView.h" + +/** + 'MXKTableViewCellWithLabelAndMXKImageView' inherits 'MXKTableViewCell' class. + It constains a 'UILabel' and a 'MXKImageView' vertically centered. + */ +@interface BWITableViewCellWithLabelAndMXKImageView : MXKTableViewCell + +@property (strong, nonatomic) IBOutlet UILabel *mxkLabel; +@property (strong, nonatomic) IBOutlet UILabel *bwiHint; +@property (strong, nonatomic) IBOutlet MXKImageView *mxkImageView; + +/** + Leading/Trailing constraints define here spacing to nearest neighbor (no relative to margin) + */ +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mxkLabelLeadingConstraint; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bwiHintLeadingConstraint; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bwiHintTopConstraint; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bwiHintBottomConstraint; + +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mxkImageViewLeadingConstraint; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mxkImageViewTrailingConstraint; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mxkImageViewWidthConstraint; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mxkImageViewHeightConstraint; + +/** + The MXKImageView display box type ('MXKTableViewCellDisplayBoxTypeDefault' by default) + */ +@property (nonatomic) MXKTableViewCellDisplayBoxType mxkImageViewDisplayBoxType; + +@end diff --git a/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.m b/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.m new file mode 100644 index 000000000..577d32b33 --- /dev/null +++ b/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.m @@ -0,0 +1,44 @@ +/* + Copyright 2015 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "BWITableViewCellWithLabelAndMXKImageView.h" + +@implementation BWITableViewCellWithLabelAndMXKImageView + +- (void)layoutSubviews +{ + [super layoutSubviews]; + + if (self.mxkImageViewDisplayBoxType == MXKTableViewCellDisplayBoxTypeCircle) + { + // Round image view for thumbnail + _mxkImageView.layer.cornerRadius = _mxkImageView.frame.size.width / 2; + _mxkImageView.clipsToBounds = YES; + } + else if (self.mxkImageViewDisplayBoxType == MXKTableViewCellDisplayBoxTypeRoundedCorner) + { + _mxkImageView.layer.cornerRadius = 5; + _mxkImageView.clipsToBounds = YES; + } + else + { + _mxkImageView.layer.cornerRadius = 0; + _mxkImageView.clipsToBounds = NO; + } +} + +@end + diff --git a/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.xib b/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.xib new file mode 100644 index 000000000..bb84ae49e --- /dev/null +++ b/bwi/Settings/BWITableViewCellWithLabelAndMXKImageView.xib @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +