Skip to content

Commit

Permalink
Release 1.5.4 (221)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Jan 31, 2024
1 parent 1cd6417 commit 4ad4741
Show file tree
Hide file tree
Showing 32 changed files with 296 additions and 486 deletions.
6 changes: 0 additions & 6 deletions Nicegram/NGUI/Sources/NicegramSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ private enum EasyToggleType {
case showRegDate
case hideReactions
case hideStories
case showDeletedMessages
}


Expand Down Expand Up @@ -509,8 +508,6 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
VarSystemNGSettings.hideReactions = value
case .hideStories:
NGSettings.hideStories = value
case .showDeletedMessages:
NGDeletedMessages.showDeletedMessages = value
}
})
case let .unblockHeader(text):
Expand Down Expand Up @@ -669,9 +666,6 @@ private func nicegramSettingsControllerEntries(presentationData: PresentationDat
entries.append(.easyToggle(toggleIndex, .hideStories, l("NicegramSettings.HideStories"), NGSettings.hideStories))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .showDeletedMessages, l("ShowDeletedMessages"), NGDeletedMessages.showDeletedMessages))
toggleIndex += 1

entries.append(.shareChannelsInfoToggle(l("NicegramSettings.ShareChannelsInfoToggle"), isShareChannelsInfoEnabled()))
entries.append(.shareChannelsInfoNote(l("NicegramSettings.ShareChannelsInfoToggle.Note")))

Expand Down
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"location" : "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git",
"state" : {
"branch" : "develop",
"revision" : "7d2b8a50729adb8666dec011494892cef8bc176d"
"revision" : "f1b83c87b7c0da94adad36a17d36b124e98b86c7"
}
},
{
Expand Down
7 changes: 0 additions & 7 deletions Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,6 @@
/*Confirm Call*/
"ConfirmCall.Desc" = "Are you sure you want to make a call?";

/* Deleted Messages */
"ShowDeletedMessages" = "Show Deleted Messages";

/* Edited Messages */
"ShowOriginalText" = "Show Original Text";
"UndoShowOriginalText" = "Undo Show Original Text";

/*Hidden Chats*/
"ChatContextMenu.Hide" = "Hide";
"ChatContextMenu.Unhide" = "Unhide";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,12 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth

let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
}, displayCancel: displayCancel)
controller.openUrl = { [weak self] url in
guard let self else {
return
}
self.openUrl(url)
}
controller.signUpWithName = { [weak self, weak controller] firstName, lastName, avatarData, avatarAsset, avatarAdjustments in
if let strongSelf = self {
controller?.inProgress = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ProgressNavigationButtonNode
import ImageCompression
import LegacyMediaPickerUI
import Postbox
import TextFormat

final class AuthorizationSequenceSignUpController: ViewController {
private var controllerNode: AuthorizationSequenceSignUpControllerNode {
Expand All @@ -25,6 +26,7 @@ final class AuthorizationSequenceSignUpController: ViewController {
private var termsOfService: UnauthorizedAccountTermsOfService?

var signUpWithName: ((String, String, Data?, Any?, TGVideoEditAdjustments?) -> Void)?
var openUrl: ((String) -> Void)?

var avatarAsset: Any?
var avatarAdjustments: TGVideoEditAdjustments?
Expand Down Expand Up @@ -122,7 +124,32 @@ final class AuthorizationSequenceSignUpController: ViewController {
return
}
strongSelf.view.endEditing(true)
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: strongSelf.presentationData.strings.Login_TermsOfServiceHeader, text: termsOfService.text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))

let presentAlertImpl: () -> Void = {
guard let strongSelf = self else {
return
}
var dismissImpl: (() -> Void)?
let alertTheme = AlertControllerTheme(presentationData: strongSelf.presentationData)
let attributedText = stringWithAppliedEntities(termsOfService.text, entities: termsOfService.entities, baseColor: alertTheme.primaryColor, linkColor: alertTheme.accentColor, baseFont: Font.regular(13.0), linkFont: Font.regular(13.0), boldFont: Font.semibold(13.0), italicFont: Font.italic(13.0), boldItalicFont: Font.semiboldItalic(13.0), fixedFont: Font.regular(13.0), blockQuoteFont: Font.regular(13.0), message: nil)
let contentNode = TextAlertContentNode(theme: alertTheme, title: NSAttributedString(string: strongSelf.presentationData.strings.Login_TermsOfServiceHeader, font: Font.medium(17.0), textColor: alertTheme.primaryColor, paragraphAlignment: .center), text: attributedText, actions: [
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
dismissImpl?()
})
], actionLayout: .vertical, dismissOnOutsideTap: true)
contentNode.textAttributeAction = (NSAttributedString.Key(rawValue: TelegramTextAttributes.URL), { value in
if let value = value as? String {
strongSelf.openUrl?(value)
}
})
let controller = AlertController(theme: alertTheme, contentNode: contentNode)
dismissImpl = { [weak controller] in
controller?.dismissAnimated()
}
strongSelf.view.endEditing(true)
strongSelf.present(controller, in: .window(.root))
}
presentAlertImpl()
}

self.controllerNode.updateData(firstName: self.initialName.0, lastName: self.initialName.1, hasTermsOfService: self.termsOfService != nil)
Expand Down
54 changes: 33 additions & 21 deletions submodules/Camera/Sources/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ final class CameraDeviceContext {

private let exclusive: Bool
private let additional: Bool
private let isRoundVideo: Bool

let device = CameraDevice()
let input = CameraInput()
let output: CameraOutput

init(session: CameraSession, exclusive: Bool, additional: Bool, ciContext: CIContext, use32BGRA: Bool = false) {
init(session: CameraSession, exclusive: Bool, additional: Bool, ciContext: CIContext, colorSpace: CGColorSpace, isRoundVideo: Bool = false) {
self.session = session
self.exclusive = exclusive
self.additional = additional
self.output = CameraOutput(exclusive: exclusive, ciContext: ciContext, use32BGRA: use32BGRA)
self.isRoundVideo = isRoundVideo
self.output = CameraOutput(exclusive: exclusive, ciContext: ciContext, colorSpace: colorSpace, use32BGRA: isRoundVideo)
}

func configure(position: Camera.Position, previewView: CameraSimplePreviewView?, audio: Bool, photo: Bool, metadata: Bool, preferWide: Bool = false, preferLowerFramerate: Bool = false, switchAudio: Bool = true) {
Expand All @@ -63,7 +65,7 @@ final class CameraDeviceContext {
}

self.previewView = previewView

self.device.configure(for: session, position: position, dual: !self.exclusive || self.additional, switchAudio: switchAudio)
self.device.configureDeviceFormat(maxDimensions: self.maxDimensions(additional: self.additional, preferWide: preferWide), maxFramerate: self.preferredMaxFrameRate(useLower: preferLowerFramerate))
self.input.configure(for: session, device: self.device, audio: audio && switchAudio)
Expand All @@ -83,18 +85,19 @@ final class CameraDeviceContext {
}

private func maxDimensions(additional: Bool, preferWide: Bool) -> CMVideoDimensions {
if additional || preferWide {
return CMVideoDimensions(width: 1920, height: 1440)
if self.isRoundVideo && !Camera.isDualCameraSupported {
return CMVideoDimensions(width: 640, height: 480)
} else {
return CMVideoDimensions(width: 1920, height: 1080)
if additional || preferWide {
return CMVideoDimensions(width: 1920, height: 1440)
} else {
return CMVideoDimensions(width: 1920, height: 1080)
}
}
}

private func preferredMaxFrameRate(useLower: Bool) -> Double {
if !self.exclusive {
return 30.0
}
if useLower {
if !self.exclusive || self.isRoundVideo || useLower {
return 30.0
}
switch DeviceModel.current {
Expand All @@ -108,14 +111,13 @@ final class CameraDeviceContext {

private final class CameraContext {
private let queue: Queue

private let session: CameraSession
private let ciContext: CIContext
private let colorSpace: CGColorSpace

private var mainDeviceContext: CameraDeviceContext?
private var additionalDeviceContext: CameraDeviceContext?

private let ciContext = CIContext()

private let initialConfiguration: Camera.Configuration
private var invalidated = false

Expand All @@ -129,7 +131,10 @@ private final class CameraContext {
var secondaryPreviewView: CameraSimplePreviewView?

private var lastSnapshotTimestamp: Double = CACurrentMediaTime()
private var savedSnapshot = false
private var lastAdditionalSnapshotTimestamp: Double = CACurrentMediaTime()
private var savedAdditionalSnapshot = false

private func savePreviewSnapshot(pixelBuffer: CVPixelBuffer, front: Bool) {
Queue.concurrentDefaultQueue().async {
var ciImage = CIImage(cvImageBuffer: pixelBuffer)
Expand All @@ -139,7 +144,7 @@ private final class CameraContext {
transform = CGAffineTransformTranslate(transform, 0.0, -size.height)
ciImage = ciImage.transformed(by: transform)
}
ciImage = ciImage.clampedToExtent().applyingGaussianBlur(sigma: 40.0).cropped(to: CGRect(origin: .zero, size: size))
ciImage = ciImage.clampedToExtent().applyingGaussianBlur(sigma: Camera.isDualCameraSupported ? 100.0 : 40.0).cropped(to: CGRect(origin: .zero, size: size))
if let cgImage = self.ciContext.createCGImage(ciImage, from: ciImage.extent) {
let uiImage = UIImage(cgImage: cgImage, scale: 1.0, orientation: .right)
if front {
Expand All @@ -156,6 +161,10 @@ private final class CameraContext {

self.queue = queue
self.session = session

self.colorSpace = CGColorSpaceCreateDeviceRGB()
self.ciContext = CIContext(options: [.workingColorSpace : self.colorSpace])

self.initialConfiguration = configuration
self.simplePreviewView = previewView
self.secondaryPreviewView = secondaryPreviewView
Expand Down Expand Up @@ -313,38 +322,40 @@ private final class CameraContext {
if enabled {
self.configure {
self.mainDeviceContext?.invalidate()
self.mainDeviceContext = CameraDeviceContext(session: self.session, exclusive: false, additional: false, ciContext: self.ciContext, use32BGRA: self.initialConfiguration.isRoundVideo)
self.mainDeviceContext = CameraDeviceContext(session: self.session, exclusive: false, additional: false, ciContext: self.ciContext, colorSpace: self.colorSpace, isRoundVideo: self.initialConfiguration.isRoundVideo)
self.mainDeviceContext?.configure(position: .back, previewView: self.simplePreviewView, audio: self.initialConfiguration.audio, photo: self.initialConfiguration.photo, metadata: self.initialConfiguration.metadata)

self.additionalDeviceContext = CameraDeviceContext(session: self.session, exclusive: false, additional: true, ciContext: self.ciContext, use32BGRA: self.initialConfiguration.isRoundVideo)
self.additionalDeviceContext = CameraDeviceContext(session: self.session, exclusive: false, additional: true, ciContext: self.ciContext, colorSpace: self.colorSpace, isRoundVideo: self.initialConfiguration.isRoundVideo)
self.additionalDeviceContext?.configure(position: .front, previewView: self.secondaryPreviewView, audio: false, photo: true, metadata: false)
}
self.mainDeviceContext?.output.processSampleBuffer = { [weak self] sampleBuffer, pixelBuffer, connection in
guard let self, let mainDeviceContext = self.mainDeviceContext else {
return
}
let timestamp = CACurrentMediaTime()
if timestamp > self.lastSnapshotTimestamp + 2.5, !mainDeviceContext.output.isRecording {
if timestamp > self.lastSnapshotTimestamp + 2.5, !mainDeviceContext.output.isRecording || !self.savedSnapshot {
var front = false
if #available(iOS 13.0, *) {
front = connection.inputPorts.first?.sourceDevicePosition == .front
}
self.savePreviewSnapshot(pixelBuffer: pixelBuffer, front: front)
self.lastSnapshotTimestamp = timestamp
self.savedSnapshot = true
}
}
self.additionalDeviceContext?.output.processSampleBuffer = { [weak self] sampleBuffer, pixelBuffer, connection in
guard let self, let additionalDeviceContext = self.additionalDeviceContext else {
return
}
let timestamp = CACurrentMediaTime()
if timestamp > self.lastAdditionalSnapshotTimestamp + 2.5, !additionalDeviceContext.output.isRecording {
if timestamp > self.lastAdditionalSnapshotTimestamp + 2.5, !additionalDeviceContext.output.isRecording || !self.savedAdditionalSnapshot {
var front = false
if #available(iOS 13.0, *) {
front = connection.inputPorts.first?.sourceDevicePosition == .front
}
self.savePreviewSnapshot(pixelBuffer: pixelBuffer, front: front)
self.lastAdditionalSnapshotTimestamp = timestamp
self.savedAdditionalSnapshot = true
}
}
} else {
Expand All @@ -356,21 +367,22 @@ private final class CameraContext {
let preferWide = self.initialConfiguration.preferWide || self.initialConfiguration.isRoundVideo
let preferLowerFramerate = self.initialConfiguration.preferLowerFramerate || self.initialConfiguration.isRoundVideo

self.mainDeviceContext = CameraDeviceContext(session: self.session, exclusive: true, additional: false, ciContext: self.ciContext, use32BGRA: self.initialConfiguration.isRoundVideo)
self.mainDeviceContext = CameraDeviceContext(session: self.session, exclusive: true, additional: false, ciContext: self.ciContext, colorSpace: self.colorSpace, isRoundVideo: self.initialConfiguration.isRoundVideo)
self.mainDeviceContext?.configure(position: self.positionValue, previewView: self.simplePreviewView, audio: self.initialConfiguration.audio, photo: self.initialConfiguration.photo, metadata: self.initialConfiguration.metadata, preferWide: preferWide, preferLowerFramerate: preferLowerFramerate)
}
self.mainDeviceContext?.output.processSampleBuffer = { [weak self] sampleBuffer, pixelBuffer, connection in
guard let self, let mainDeviceContext = self.mainDeviceContext else {
return
}
let timestamp = CACurrentMediaTime()
if timestamp > self.lastSnapshotTimestamp + 2.5, !mainDeviceContext.output.isRecording {
if timestamp > self.lastSnapshotTimestamp + 2.5, !mainDeviceContext.output.isRecording || !self.savedSnapshot {
var front = false
if #available(iOS 13.0, *) {
front = connection.inputPorts.first?.sourceDevicePosition == .front
}
self.savePreviewSnapshot(pixelBuffer: pixelBuffer, front: front)
self.lastSnapshotTimestamp = timestamp
self.savedSnapshot = true
}
}
if self.initialConfiguration.reportAudioLevel {
Expand Down Expand Up @@ -551,7 +563,7 @@ private final class CameraContext {

let orientation = self.simplePreviewView?.videoPreviewLayer.connection?.videoOrientation ?? .portrait
if self.initialConfiguration.isRoundVideo {
return mainDeviceContext.output.startRecording(mode: .roundVideo, orientation: .portrait, additionalOutput: self.additionalDeviceContext?.output)
return mainDeviceContext.output.startRecording(mode: .roundVideo, orientation: DeviceModel.current.isIpad ? orientation : .portrait, additionalOutput: self.additionalDeviceContext?.output)
} else {
if let additionalDeviceContext = self.additionalDeviceContext {
return combineLatest(
Expand Down
11 changes: 8 additions & 3 deletions submodules/Camera/Sources/CameraOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public struct CameraCode: Equatable {
final class CameraOutput: NSObject {
let exclusive: Bool
let ciContext: CIContext
let colorSpace: CGColorSpace
let isVideoMessage: Bool

let photoOutput = AVCapturePhotoOutput()
Expand All @@ -99,14 +100,17 @@ final class CameraOutput: NSObject {

private var photoCaptureRequests: [Int64: PhotoCaptureContext] = [:]
private var videoRecorder: VideoRecorder?

private var captureOrientation: AVCaptureVideoOrientation = .portrait

var processSampleBuffer: ((CMSampleBuffer, CVImageBuffer, AVCaptureConnection) -> Void)?
var processAudioBuffer: ((CMSampleBuffer) -> Void)?
var processCodes: (([CameraCode]) -> Void)?

init(exclusive: Bool, ciContext: CIContext, use32BGRA: Bool = false) {
init(exclusive: Bool, ciContext: CIContext, colorSpace: CGColorSpace, use32BGRA: Bool = false) {
self.exclusive = exclusive
self.ciContext = ciContext
self.colorSpace = colorSpace
self.isVideoMessage = use32BGRA

super.init()
Expand Down Expand Up @@ -303,6 +307,7 @@ final class CameraOutput: NSObject {

self.currentMode = mode
self.lastSampleTimestamp = nil
self.captureOrientation = orientation

var orientation = orientation
let dimensions: CGSize
Expand Down Expand Up @@ -530,13 +535,13 @@ final class CameraOutput: NSObject {
if let current = self.roundVideoFilter {
filter = current
} else {
filter = CameraRoundVideoFilter(ciContext: self.ciContext)
filter = CameraRoundVideoFilter(ciContext: self.ciContext, colorSpace: self.colorSpace, simple: self.exclusive)
self.roundVideoFilter = filter
}
if !filter.isPrepared {
filter.prepare(with: newFormatDescription, outputRetainedBufferCountHint: 3)
}
guard let newPixelBuffer = filter.render(pixelBuffer: videoPixelBuffer, additional: additional, transitionFactor: transitionFactor) else {
guard let newPixelBuffer = filter.render(pixelBuffer: videoPixelBuffer, additional: additional, captureOrientation: self.captureOrientation, transitionFactor: transitionFactor) else {
self.semaphore.signal()
return nil
}
Expand Down

0 comments on commit 4ad4741

Please sign in to comment.