Various fixes

This commit is contained in:
Ilya Laktyushin 2023-12-04 21:14:12 +04:00
parent 22c67867c6
commit f9cf3761c7
3 changed files with 31 additions and 6 deletions

View File

@ -10609,3 +10609,8 @@ Sorry for the inconvenience.";
"Chat.RemoveWallpaper.Title" = "Remove Wallpaper";
"Chat.RemoveWallpaper.Text" = "Are you sure you want to reset the wallpaper?";
"Chat.RemoveWallpaper.Remove" = "Remove";
"MediaEditor.Shortcut.Image" = "Image";
"MediaEditor.Shortcut.Location" = "Location";
"MediaEditor.Shortcut.Reaction" = "Reaction";
"MediaEditor.Shortcut.Audio" = "Audio";

View File

@ -61,9 +61,24 @@ extension MediaEditorScreen {
}
func requestDeviceAccess() {
DeviceAccess.authorizeAccess(to: .camera(.video), { granted in
guard let controller = self.controller else {
return
}
let context = controller.context
let presentationData = context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: defaultDarkColorPresentationTheme)
DeviceAccess.authorizeAccess(to: .camera(.video), presentationData: presentationData, present: { c, a in
c.presentationArguments = a
context.sharedContext.mainWindow?.present(c, on: .root)
}, openSettings: {
context.sharedContext.applicationBindings.openSettings()
}, { granted in
if granted {
DeviceAccess.authorizeAccess(to: .microphone(.video))
DeviceAccess.authorizeAccess(to: .microphone(.video), presentationData: presentationData, present: { c, a in
c.presentationArguments = a
context.sharedContext.mainWindow?.present(c, on: .root)
}, openSettings: {
context.sharedContext.applicationBindings.openSettings()
})
}
})
}
@ -119,6 +134,11 @@ extension MediaEditorScreen {
self.cameraIsActive = false
} else {
if self.cameraAuthorizationStatus != .allowed || self.microphoneAuthorizationStatus != .allowed {
self.requestDeviceAccess()
return
}
guard self.tooltipController == nil, let sourceView else {
return
}

View File

@ -4418,28 +4418,28 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
var items: [ContextMenuItem] = []
items.append(.action(ContextMenuActionItem(text: "Image", icon: { theme in
items.append(.action(ContextMenuActionItem(text: presentationData.strings.MediaEditor_Shortcut_Image, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Image"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
self?.node.presentGallery()
})))
items.append(.action(ContextMenuActionItem(text: "Location", icon: { theme in
items.append(.action(ContextMenuActionItem(text: presentationData.strings.MediaEditor_Shortcut_Location, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Media Editor/LocationSmall"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
self?.node.presentLocationPicker()
})))
items.append(.action(ContextMenuActionItem(text: "Reaction", icon: { theme in
items.append(.action(ContextMenuActionItem(text: presentationData.strings.MediaEditor_Shortcut_Reaction, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Reactions"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
self?.node.addReaction()
})))
items.append(.action(ContextMenuActionItem(text: "Audio", icon: { theme in
items.append(.action(ContextMenuActionItem(text: presentationData.strings.MediaEditor_Shortcut_Audio, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Media Editor/AudioSmall"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)