mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Add link preview & open group metadata warnings
This commit is contained in:
parent
cbda28a9a0
commit
442c1b9996
3 changed files with 34 additions and 10 deletions
|
@ -186,14 +186,22 @@ private final class EnterChatURLVC : UIViewController {
|
|||
override func viewDidLoad() {
|
||||
// Remove background color
|
||||
view.backgroundColor = .clear
|
||||
// Set up explanation label
|
||||
let explanationLabel = UILabel()
|
||||
explanationLabel.textColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
||||
explanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
explanationLabel.text = NSLocalizedString("Enter an open group URL", comment: "")
|
||||
explanationLabel.numberOfLines = 0
|
||||
explanationLabel.textAlignment = .center
|
||||
explanationLabel.lineBreakMode = .byWordWrapping
|
||||
// Set up top explanation label
|
||||
let topExplanationLabel = UILabel()
|
||||
topExplanationLabel.textColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
||||
topExplanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
topExplanationLabel.text = NSLocalizedString("Enter an open group URL", comment: "")
|
||||
topExplanationLabel.numberOfLines = 0
|
||||
topExplanationLabel.textAlignment = .center
|
||||
topExplanationLabel.lineBreakMode = .byWordWrapping
|
||||
// Set up bottom explanation label
|
||||
let bottomExplanationLabel = UILabel()
|
||||
bottomExplanationLabel.textColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
||||
bottomExplanationLabel.font = .systemFont(ofSize: Values.verySmallFontSize)
|
||||
bottomExplanationLabel.text = NSLocalizedString("Open groups can be joined by anyone and do not provide full metadata protection", comment: "")
|
||||
bottomExplanationLabel.numberOfLines = 0
|
||||
bottomExplanationLabel.textAlignment = .center
|
||||
bottomExplanationLabel.lineBreakMode = .byWordWrapping
|
||||
// Next button
|
||||
let nextButton = Button(style: .prominentOutline, size: .large)
|
||||
nextButton.setTitle(NSLocalizedString("Next", comment: ""), for: UIControl.State.normal)
|
||||
|
@ -205,10 +213,11 @@ private final class EnterChatURLVC : UIViewController {
|
|||
nextButtonContainer.pin(.trailing, to: .trailing, of: nextButton, withInset: 80)
|
||||
nextButtonContainer.pin(.bottom, to: .bottom, of: nextButton)
|
||||
// Set up stack view
|
||||
let stackView = UIStackView(arrangedSubviews: [ chatURLTextField, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, UIView.vStretchingSpacer(), nextButtonContainer ])
|
||||
let stackView = UIStackView(arrangedSubviews: [ chatURLTextField, UIView.spacer(withHeight: Values.smallSpacing), topExplanationLabel, UIView.vStretchingSpacer(), nextButtonContainer, UIView.spacer(withHeight: Values.smallSpacing), bottomExplanationLabel ])
|
||||
stackView.axis = .vertical
|
||||
stackView.alignment = .fill
|
||||
stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing)
|
||||
let bottomSpacing = isSmallScreen ? Values.smallSpacing : Values.largeSpacing
|
||||
stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: bottomSpacing, right: Values.largeSpacing)
|
||||
stackView.isLayoutMarginsRelativeArrangement = true
|
||||
view.addSubview(stackView)
|
||||
stackView.pin(.leading, to: .leading, of: view)
|
||||
|
|
|
@ -537,6 +537,18 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
|
|||
|
||||
- (void)didToggleLinkPreviewsEnabled:(UISwitch *)sender
|
||||
{
|
||||
BOOL isOn = sender.isOn;
|
||||
if (isOn) {
|
||||
NSString *title = NSLocalizedString(@"Enable Link Previews?", @"");
|
||||
NSString *message = NSLocalizedString(@"You will not have full metadata protection when sending or receiving link previews.", @"");
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:nil]];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||
[sender setOn:NO animated:YES];
|
||||
SSKPreferences.areLinkPreviewsEnabled = NO;
|
||||
}]];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
|
||||
SSKPreferences.areLinkPreviewsEnabled = sender.isOn;
|
||||
}
|
||||
|
|
|
@ -2796,3 +2796,6 @@
|
|||
"Please enter a group name" = "Please enter a group name";
|
||||
"Please enter a shorter group name" = "Please enter a shorter group name";
|
||||
"Please pick at least 2 group members" = "Please pick at least 2 group members";
|
||||
"Enable Link Previews?" = "Enable Link Previews?";
|
||||
"You will not have full metadata protection when sending or receiving link previews." = "You will not have full metadata protection when sending or receiving link previews.";
|
||||
"Open groups can be joined by anyone and do not provide full metadata protection" = "Open groups can be joined by anyone and do not provide full metadata protection";
|
||||
|
|
Loading…
Reference in a new issue