Various fixes

This commit is contained in:
Ilya Laktyushin 2020-10-18 04:42:32 +04:00
parent ce911f3f9b
commit fe9610eee9
7 changed files with 88 additions and 10 deletions

View File

@ -67,7 +67,7 @@
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
{
if (intent != TGMediaAssetsControllerSendMediaIntent)
if (intent != TGMediaAssetsControllerSendMediaIntent && intent != TGMediaAssetsControllerSendFileIntent)
allowGrouping = false;
TGMediaAssetsController *assetsController = [[TGMediaAssetsController alloc] initWithContext:context intent:intent saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping selectionLimit:selectionLimit];
@ -735,6 +735,9 @@
dict[@"fileName"] = assetData.fileName;
dict[@"mimeType"] = TGMimeTypeForFileUTI(assetData.fileUTI);
if (groupedId != nil)
dict[@"groupedId"] = groupedId;
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
return generatedItem;
}] catch:^SSignal *(id error)
@ -752,6 +755,9 @@
dict[@"mimeType"] = TGMimeTypeForFileUTI(asset.uniformTypeIdentifier);
dict[@"fileName"] = asset.fileName;
if (groupedId != nil)
dict[@"groupedId"] = groupedId;
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
return generatedItem;
}];
@ -971,6 +977,9 @@
if (adjustments.paintingData.stickers.count > 0)
dict[@"stickers"] = adjustments.paintingData.stickers;
if (groupedId != nil)
dict[@"groupedId"] = groupedId;
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
return generatedItem;
}]];

View File

@ -184,7 +184,7 @@ public func legacyAssetPickerItemGenerator() -> ((Any?, String?, [Any]?, String?
name = customName
}
result["item" as NSString] = LegacyAssetItemWrapper(item: .file(data: .asset(asset.backingAsset), thumbnail: thumbnail, mimeType: mimeType, name: name, caption: caption), timer: nil, groupedId: nil)
result["item" as NSString] = LegacyAssetItemWrapper(item: .file(data: .asset(asset.backingAsset), thumbnail: thumbnail, mimeType: mimeType, name: name, caption: caption), timer: nil, groupedId: (dict["groupedId"] as? NSNumber)?.int64Value)
} else {
result["item" as NSString] = LegacyAssetItemWrapper(item: .image(data: .asset(asset.backingAsset), thumbnail: thumbnail, caption: caption, stickers: []), timer: (dict["timer"] as? NSNumber)?.intValue, groupedId: (dict["groupedId"] as? NSNumber)?.int64Value)
}

View File

@ -545,6 +545,27 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
self.pinDisposable.set(nil)
}
func showAll(animated: Bool = true) {
guard let mapView = self.mapView else {
return
}
var annotations: [MKAnnotation] = []
if let userAnnotation = self.userLocationAnnotation {
annotations.append(userAnnotation)
}
annotations.append(contentsOf: self.annotations)
var zoomRect: MKMapRect = MKMapRect()
for annotation in annotations {
let pointRegionRect = MKMapRect(region: MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 100, longitudinalMeters: 100))
zoomRect = zoomRect.union(pointRegionRect)
}
let insets = UIEdgeInsets()
zoomRect = mapView.mapRectThatFits(zoomRect, edgePadding: insets)
mapView.setVisibleMapRect(zoomRect, animated: animated)
}
func updateLayout(size: CGSize) {
self.proximityDimView.frame = CGRect(origin: CGPoint(), size: size)
self.pickerAnnotationContainerView.frame = CGRect(x: 0.0, y: floorToScreenPixels((size.height - size.width) / 2.0), width: size.width, height: size.width)

View File

@ -29,6 +29,12 @@ public class LocationViewParams {
}
}
enum LocationViewRightBarButton {
case none
case share
case showAll
}
class LocationViewInteraction {
let toggleMapModeSelection: () -> Void
let updateMapMode: (LocationMapMode) -> Void
@ -40,8 +46,9 @@ class LocationViewInteraction {
let updateSendActionHighlight: (Bool) -> Void
let sendLiveLocation: (CLLocationCoordinate2D) -> Void
let stopLiveLocation: () -> Void
let updateRightBarButton: (LocationViewRightBarButton) -> Void
init(toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, goToUserLocation: @escaping () -> Void, goToCoordinate: @escaping (CLLocationCoordinate2D) -> Void, requestDirections: @escaping () -> Void, share: @escaping () -> Void, setupProximityNotification: @escaping (CLLocationCoordinate2D, Bool) -> Void, updateSendActionHighlight: @escaping (Bool) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D) -> Void, stopLiveLocation: @escaping () -> Void) {
init(toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, goToUserLocation: @escaping () -> Void, goToCoordinate: @escaping (CLLocationCoordinate2D) -> Void, requestDirections: @escaping () -> Void, share: @escaping () -> Void, setupProximityNotification: @escaping (CLLocationCoordinate2D, Bool) -> Void, updateSendActionHighlight: @escaping (Bool) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D) -> Void, stopLiveLocation: @escaping () -> Void, updateRightBarButton: @escaping (LocationViewRightBarButton) -> Void) {
self.toggleMapModeSelection = toggleMapModeSelection
self.updateMapMode = updateMapMode
self.goToUserLocation = goToUserLocation
@ -52,6 +59,7 @@ class LocationViewInteraction {
self.updateSendActionHighlight = updateSendActionHighlight
self.sendLiveLocation = sendLiveLocation
self.stopLiveLocation = stopLiveLocation
self.updateRightBarButton = updateRightBarButton
}
}
@ -71,6 +79,8 @@ public final class LocationViewController: ViewController {
private var interaction: LocationViewInteraction?
private var rightBarButtonAction: LocationViewRightBarButton = .none
public init(context: AccountContext, subject: Message, params: LocationViewParams) {
self.context = context
self.subject = subject
@ -83,8 +93,6 @@ public final class LocationViewController: ViewController {
self.title = self.presentationData.strings.Map_LocationTitle
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Close, style: .plain, target: self, action: #selector(self.cancelPressed))
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationShareIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.sharePressed))
self.navigationItem.rightBarButtonItem?.accessibilityLabel = self.presentationData.strings.VoiceOver_MessageContextShare
self.presentationDataDisposable = (context.sharedContext.presentationData
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
@ -95,7 +103,7 @@ public final class LocationViewController: ViewController {
strongSelf.navigationBar?.updatePresentationData(NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: strongSelf.presentationData.theme).withUpdatedSeparatorColor(.clear), strings: NavigationBarStrings(presentationStrings: strongSelf.presentationData.strings)))
strongSelf.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationShareIcon(strongSelf.presentationData.theme), style: .plain, target: strongSelf, action: #selector(strongSelf.sharePressed))
strongSelf.updateRightBarButton()
if strongSelf.isNodeLoaded {
strongSelf.controllerNode.updatePresentationData(presentationData)
@ -247,6 +255,15 @@ public final class LocationViewController: ViewController {
}, stopLiveLocation: { [weak self] in
params.stopLiveLocation()
self?.dismiss()
}, updateRightBarButton: { [weak self] action in
guard let strongSelf = self else {
return
}
if action != strongSelf.rightBarButtonAction {
strongSelf.rightBarButtonAction = action
strongSelf.updateRightBarButton()
}
})
self.scrollToTop = { [weak self] in
@ -280,6 +297,18 @@ public final class LocationViewController: ViewController {
}
}
private func updateRightBarButton() {
switch self.rightBarButtonAction {
case .none:
self.navigationItem.rightBarButtonItem = nil
case .share:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationShareIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.sharePressed))
self.navigationItem.rightBarButtonItem?.accessibilityLabel = self.presentationData.strings.VoiceOver_MessageContextShare
case .showAll:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Map_LiveLocationShowAll, style: .plain, target: self, action: #selector(self.showAllPressed))
}
}
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
super.containerLayoutUpdated(layout, transition: transition)
@ -295,7 +324,7 @@ public final class LocationViewController: ViewController {
}
@objc private func showAllPressed() {
self.dismiss()
self.controllerNode.showAll()
}
}

View File

@ -113,7 +113,7 @@ private enum LocationViewEntry: Comparable, Identifiable {
func item(account: Account, presentationData: PresentationData, interaction: LocationViewInteraction?) -> ListViewItem {
switch self {
case let .info(theme, location, address, distance, time):
case let .info(_, location, address, distance, time):
let addressString: String?
if let address = address {
addressString = address
@ -132,7 +132,7 @@ private enum LocationViewEntry: Comparable, Identifiable {
}, getDirections: {
interaction?.requestDirections()
})
case let .toggleLiveLocation(theme, title, subtitle, coordinate, beginTimstamp, timeout):
case let .toggleLiveLocation(_, title, subtitle, coordinate, beginTimstamp, timeout):
let beginTimeAndTimeout: (Double, Double)?
if let beginTimstamp = beginTimstamp, let timeout = timeout {
beginTimeAndTimeout = (beginTimstamp, timeout)
@ -403,6 +403,18 @@ final class LocationViewControllerNode: ViewControllerTracingNode {
strongSelf.headerNode.mapNode.activeProximityRadius = state.proximityRadius
let rightBarButtonAction: LocationViewRightBarButton
if location.liveBroadcastingTimeout != nil {
if liveLocations.count > 1 {
rightBarButtonAction = .showAll
} else {
rightBarButtonAction = .none
}
} else {
rightBarButtonAction = .share
}
strongSelf.interaction.updateRightBarButton(rightBarButtonAction)
if let (layout, navigationBarHeight) = strongSelf.validLayout {
var updateLayout = false
let transition: ContainedViewLayoutTransition = .animated(duration: 0.45, curve: .spring)
@ -534,6 +546,10 @@ final class LocationViewControllerNode: ViewControllerTracingNode {
}
}
func showAll() {
self.headerNode.mapNode.showAll()
}
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) {
let isFirstLayout = self.validLayout == nil
self.validLayout = (layout, navigationHeight)

View File

@ -7171,6 +7171,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let message: EnqueueMessage = .message(text: "", attributes: [], mediaReference: .standalone(media: file), replyToMessageId: replyMessageId, localGroupingKey: groupingKey)
messages.append(message)
}
if let _ = groupingKey, results.count % 10 == 0 {
groupingKey = arc4random64()
}
}
if !messages.isEmpty {

View File

@ -104,7 +104,7 @@ class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
if case let .linear(_, bottom) = position {
if case .Neighbour(_, _, .condensed) = bottom {
if selectedFile?.isMusic ?? false {
bottomInset -= 14.0
// bottomInset -= 14.0
} else {
bottomInset -= 10.0
}