Change license to AGPL
This commit:
- Updates the `LICENSE` file
- Start every file with something like:
// Copyright YEAR_FIRST_PUBLISHED Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
---
First, I removed existing license headers with this Ruby 3.1.2 script:
require 'set'
EXTENSIONS_TO_CHECK = Set['.h', '.hpp', '.cpp', '.m', '.mm', '.pch', '.swift']
same = 0
different = 0
all_files = `git ls-files`.lines.map { |line| line.strip }
all_files.each do |relative_path|
if relative_path == 'Pods'
next
end
unless EXTENSIONS_TO_CHECK.include? File.extname(relative_path)
next
end
path = File.expand_path(relative_path)
contents = File.read(path)
new_contents = contents.sub(/\/\/\n\/\/ Copyright .*\n\/\/\n\n/, '')
if contents == new_contents
same += 1
else
different += 1
end
File.write(path, new_contents)
end
puts "updated #{different} file(s), left #{same} untouched"
I'm sure this script could be improved, but it worked well enough.
Then, I created `Scripts/lint/lint-license-headers` and ran it to auto-
fix a lot of files. This changed the mode of some files, but I think
that's actually desirable. For example,
`SignalServiceKit/src/Util/AppContext.m` previously had a mode of
`0755/-rwxr-xr-x`, and it's now `0644/-rw-r--r--`.
Then I fixed some stragglers and updated the precommit script.
See [a similar change in the Desktop app][0].
[0]: 8bfaf598af
168 lines
6.1 KiB
Objective-C
168 lines
6.1 KiB
Objective-C
//
|
|
// Copyright 2018 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
#import "ScreenLockViewController.h"
|
|
#import "UIFont+OWS.h"
|
|
#import "UIView+SignalUI.h"
|
|
#import <SignalUI/SignalUI-Swift.h>
|
|
|
|
NSString *NSStringForScreenLockUIState(ScreenLockUIState value)
|
|
{
|
|
switch (value) {
|
|
case ScreenLockUIStateNone:
|
|
return @"ScreenLockUIStateNone";
|
|
case ScreenLockUIStateScreenProtection:
|
|
return @"ScreenLockUIStateScreenProtection";
|
|
case ScreenLockUIStateScreenLock:
|
|
return @"ScreenLockUIStateScreenLock";
|
|
}
|
|
}
|
|
|
|
@interface ScreenLockViewController ()
|
|
|
|
@property (nonatomic) UIView *screenBlockingImageView;
|
|
@property (nonatomic) UIView *screenBlockingButton;
|
|
@property (nonatomic) NSArray<NSLayoutConstraint *> *screenBlockingConstraints;
|
|
@property (nonatomic) NSString *screenBlockingSignature;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@implementation ScreenLockViewController
|
|
|
|
- (void)loadView
|
|
{
|
|
[super loadView];
|
|
|
|
self.view.backgroundColor = Theme.launchScreenBackgroundColor;
|
|
|
|
UIView *edgesView = [UIView containerView];
|
|
[self.view addSubview:edgesView];
|
|
[edgesView autoPinEdgeToSuperviewEdge:ALEdgeTop];
|
|
[edgesView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
|
|
[edgesView autoPinWidthToSuperview];
|
|
|
|
UIImage *image = [UIImage imageNamed:@"signal-logo-128-launch-screen"];
|
|
UIImageView *imageView = [UIImageView new];
|
|
imageView.image = image;
|
|
[edgesView addSubview:imageView];
|
|
[imageView autoHCenterInSuperview];
|
|
[imageView autoSetDimensionsToSize:CGSizeMake(128, 128)];
|
|
|
|
const CGFloat kButtonHeight = 40.f;
|
|
OWSFlatButton *button =
|
|
[OWSFlatButton buttonWithTitle:OWSLocalizedString(@"SCREEN_LOCK_UNLOCK_SIGNAL",
|
|
@"Label for button on lock screen that lets users unlock Signal.")
|
|
font:[OWSFlatButton fontForHeight:kButtonHeight]
|
|
titleColor:Theme.accentBlueColor
|
|
backgroundColor:[UIColor whiteColor]
|
|
target:self
|
|
selector:@selector(showUnlockUI)];
|
|
[edgesView addSubview:button];
|
|
|
|
[button autoSetDimension:ALDimensionHeight toSize:kButtonHeight];
|
|
[button autoPinLeadingToSuperviewMarginWithInset:50.f];
|
|
[button autoPinTrailingToSuperviewMarginWithInset:50.f];
|
|
const CGFloat kVMargin = 65.f;
|
|
[button autoPinBottomToSuperviewMarginWithInset:kVMargin];
|
|
|
|
self.screenBlockingImageView = imageView;
|
|
self.screenBlockingButton = button;
|
|
|
|
[self updateUIWithState:ScreenLockUIStateScreenProtection isLogoAtTop:NO animated:NO];
|
|
|
|
[NSNotificationCenter.defaultCenter addObserver:self
|
|
selector:@selector(themeDidChange)
|
|
name:ThemeDidChangeNotification
|
|
object:nil];
|
|
}
|
|
|
|
- (void)themeDidChange
|
|
{
|
|
self.view.backgroundColor = Theme.launchScreenBackgroundColor;
|
|
}
|
|
|
|
// The "screen blocking" window has three possible states:
|
|
//
|
|
// * "Just a logo". Used when app is launching and in app switcher. Must match the "Launch Screen"
|
|
// storyboard pixel-for-pixel.
|
|
// * "Screen Lock, local auth UI presented". Move the Signal logo so that it is visible.
|
|
// * "Screen Lock, local auth UI not presented". Move the Signal logo so that it is visible,
|
|
// show "unlock" button.
|
|
- (void)updateUIWithState:(ScreenLockUIState)uiState isLogoAtTop:(BOOL)isLogoAtTop animated:(BOOL)animated
|
|
{
|
|
OWSAssertIsOnMainThread();
|
|
|
|
if (!self.isViewLoaded) {
|
|
return;
|
|
}
|
|
|
|
BOOL shouldShowBlockWindow = uiState != ScreenLockUIStateNone;
|
|
BOOL shouldHaveScreenLock = uiState == ScreenLockUIStateScreenLock;
|
|
|
|
self.screenBlockingImageView.hidden = !shouldShowBlockWindow;
|
|
|
|
NSString *signature = [NSString stringWithFormat:@"%d %d", shouldHaveScreenLock, isLogoAtTop];
|
|
if ([NSObject isNullableObject:self.screenBlockingSignature equalTo:signature]) {
|
|
// Skip redundant work to avoid interfering with ongoing animations.
|
|
return;
|
|
}
|
|
|
|
[NSLayoutConstraint deactivateConstraints:self.screenBlockingConstraints];
|
|
|
|
NSMutableArray<NSLayoutConstraint *> *screenBlockingConstraints = [NSMutableArray new];
|
|
|
|
self.screenBlockingButton.hidden = !shouldHaveScreenLock;
|
|
|
|
if (isLogoAtTop) {
|
|
const CGFloat kVMargin = 60.f;
|
|
[screenBlockingConstraints addObject:[self.screenBlockingImageView autoPinEdge:ALEdgeTop
|
|
toEdge:ALEdgeTop
|
|
ofView:self.view
|
|
withOffset:kVMargin]];
|
|
} else {
|
|
[screenBlockingConstraints addObject:[self.screenBlockingImageView autoVCenterInSuperview]];
|
|
}
|
|
|
|
self.screenBlockingConstraints = screenBlockingConstraints;
|
|
self.screenBlockingSignature = signature;
|
|
|
|
if (animated) {
|
|
[UIView animateWithDuration:0.35f animations:^{ [self.view layoutIfNeeded]; }];
|
|
} else {
|
|
[self.view layoutIfNeeded];
|
|
}
|
|
}
|
|
|
|
- (void)showUnlockUI
|
|
{
|
|
OWSAssertIsOnMainThread();
|
|
|
|
[self.delegate unlockButtonWasTapped];
|
|
}
|
|
|
|
- (void)presentViewController:(UIViewController *)viewControllerToPresent
|
|
animated:(BOOL)flag
|
|
completion:(void (^)(void))completion
|
|
{
|
|
// The "Select Photos" dialog presents on top of the key window. If screen security is enabled,
|
|
// this will end up being the screen lock window which we immediately hide. To work around, we
|
|
// pass the view off to the proper frontmost view controller so it's visible to the user.
|
|
OWSAssertDebug([viewControllerToPresent isKindOfClass:[UIImagePickerController class]]);
|
|
[CurrentAppContext().frontmostViewController presentViewController:viewControllerToPresent
|
|
animated:flag
|
|
completion:completion];
|
|
}
|
|
|
|
#pragma mark - Orientation
|
|
|
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
|
{
|
|
return UIDevice.currentDevice.defaultSupportedOrientations;
|
|
}
|
|
|
|
@end
|