From aeb0ded0cdccd661339ba342a39667877e2ef214 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 14 Jan 2020 19:09:40 +0300 Subject: [PATCH] Fixes --- .../PrivacyAndSecurityController.swift | 9 ++++++- .../Sources/SettingsController.swift | 2 +- .../Themes/ThemeAccentColorController.swift | 3 +-- .../Sources/PresentationThemeCodable.swift | 1 - .../Sources/WallpaperResources.swift | 27 ++++++++++--------- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift index 99a2f3dbd2..6e741d6517 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift @@ -482,12 +482,19 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting let updateHasTwoStepAuth: () -> Void = { let signal = twoStepVerificationConfiguration(account: context.account) |> map { value -> TwoStepVerificationAccessConfiguration? in - return TwoStepVerificationAccessConfiguration(configuration: value, password: nil) + return TwoStepVerificationAccessConfiguration(configuration: value, password: nil) } |> deliverOnMainQueue updateTwoStepAuthDisposable.set( signal.start(next: { value in twoStepAuthDataValue.set(.single(value)) + if let value = value { + if case .set = value { + updatedHasTwoStepAuth?(true) + } else { + updatedHasTwoStepAuth?(false) + } + } }) ) } diff --git a/submodules/SettingsUI/Sources/SettingsController.swift b/submodules/SettingsUI/Sources/SettingsController.swift index b7997b90cd..280b6055f8 100644 --- a/submodules/SettingsUI/Sources/SettingsController.swift +++ b/submodules/SettingsUI/Sources/SettingsController.swift @@ -945,7 +945,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM blockedPeers.set(.single(blockedPeersContext)) }, updatedHasTwoStepAuth: { hasTwoStepAuthValue in hasTwoStepAuthPromise.set(.single(hasTwoStepAuthValue)) - }, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, blockedPeersContext: blockedPeersContext)) + }, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, blockedPeersContext: blockedPeersContext, hasTwoStepAuth: hasTwoStepAuth)) }) }) }, openDataAndStorage: { diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index af8fd96d9f..503d9005d3 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -443,8 +443,7 @@ final class ThemeAccentColorController: ViewController { var defaultPatternWallpaper: TelegramWallpaper? for wallpaper in wallpapers { - //JqSUrO0-mFIBAAAAWwTvLzoWGQI, 25 - if case let .file(file) = wallpaper, file.slug == "-Xc-np9y2VMCAAAARKr0yNNPYW0" { + if case let .file(file) = wallpaper, file.slug == "JqSUrO0-mFIBAAAAWwTvLzoWGQI" { defaultPatternWallpaper = wallpaper break } diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index d470ce403f..d1417a3398 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -55,7 +55,6 @@ extension TelegramWallpaper: Codable { } if components.count >= 2 && components.count <= 5 && [6, 8].contains(components[0].count) && !optionKeys.contains(components[0]) && [6, 8].contains(components[1].count) && !optionKeys.contains(components[1]), let topColor = UIColor(hexString: components[0]), let bottomColor = UIColor(hexString: components[1]) { - var rotation: Int32? if components.count > 2, components[2].count <= 3, let value = Int32(components[2]) { if value >= 0 && value < 360 { diff --git a/submodules/WallpaperResources/Sources/WallpaperResources.swift b/submodules/WallpaperResources/Sources/WallpaperResources.swift index fda30d573b..0c39b08129 100644 --- a/submodules/WallpaperResources/Sources/WallpaperResources.swift +++ b/submodules/WallpaperResources/Sources/WallpaperResources.swift @@ -429,17 +429,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da var scale = scale let drawingRect = arguments.drawingRect - var fittedSize = arguments.imageSize - if abs(fittedSize.width - arguments.boundingSize.width).isLessThanOrEqualTo(CGFloat(1.0)) { - fittedSize.width = arguments.boundingSize.width - } - if abs(fittedSize.height - arguments.boundingSize.height).isLessThanOrEqualTo(CGFloat(1.0)) { - fittedSize.height = arguments.boundingSize.height - } - fittedSize = fittedSize.aspectFilled(arguments.drawingRect.size) - - let fittedRect = CGRect(origin: CGPoint(x: drawingRect.origin.x + (drawingRect.size.width - fittedSize.width) / 2.0, y: drawingRect.origin.y + (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize) - + if let customArguments = arguments.custom as? PatternWallpaperArguments, let combinedColor = customArguments.colors.first { if customArguments.preview { scale = max(1.0, UIScreenScale - 1.0) @@ -479,6 +469,17 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da let image = customArguments.preview ? (scaledSizeImage ?? fullSizeImage) : fullSizeImage if let image = image { + var fittedSize = CGSize(width: image.width, height: image.height) + if abs(fittedSize.width - arguments.boundingSize.width).isLessThanOrEqualTo(CGFloat(1.0)) { + fittedSize.width = arguments.boundingSize.width + } + if abs(fittedSize.height - arguments.boundingSize.height).isLessThanOrEqualTo(CGFloat(1.0)) { + fittedSize.height = arguments.boundingSize.height + } + fittedSize = fittedSize.aspectFilled(arguments.drawingRect.size) + + let fittedRect = CGRect(origin: CGPoint(x: drawingRect.origin.x + (drawingRect.size.width - fittedSize.width) / 2.0, y: drawingRect.origin.y + (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize) + c.setBlendMode(.normal) c.interpolationQuality = customArguments.preview ? .low : .medium c.clip(to: fittedRect, mask: image) @@ -538,7 +539,7 @@ public func solidColorImage(_ color: UIColor) -> Signal<(TransformImageArguments let context = DrawingContext(size: arguments.drawingSize, clear: true) context.withFlippedContext { c in - c.setFillColor(color.cgColor) + c.setFillColor(color.withAlphaComponent(1.0).cgColor) c.fill(arguments.drawingRect) } @@ -563,7 +564,7 @@ public func gradientImage(_ colors: [UIColor], rotation: Int32? = nil) -> Signal let context = DrawingContext(size: arguments.drawingSize, clear: !arguments.corners.isEmpty) context.withContext { c in - let gradientColors = colors.map { $0.cgColor } as CFArray + let gradientColors = colors.map { $0.withAlphaComponent(1.0).cgColor } as CFArray let delta: CGFloat = 1.0 / (CGFloat(colors.count) - 1.0) var locations: [CGFloat] = []