diff --git a/LegacyComponents/Resources/LegacyComponentsResources.bundle/TwitchPlayerInject.js b/LegacyComponents/Resources/LegacyComponentsResources.bundle/TwitchPlayerInject.js index c503efd2f8..fc3957b338 100644 --- a/LegacyComponents/Resources/LegacyComponentsResources.bundle/TwitchPlayerInject.js +++ b/LegacyComponents/Resources/LegacyComponentsResources.bundle/TwitchPlayerInject.js @@ -47,6 +47,21 @@ function fixPlayer() { statusOverlay.style.padding = '1.5em 1.5em 5.5em 2.5em'; } + var recommendationOverlay = document.getElementById('js-player-recommendations-overlay'); + if (recommendationOverlay != null) { + recommendationOverlay.style.display = 'none'; + } + + var adOverlay = document.getElementsByClassName('player-ad-overlay')[0]; + if (adOverlay != null) { + adOverlay.style.display = 'none'; + } + + var alertOverlay = document.getElementById('js-player-alert-container'); + if (alertOverlay != null) { + alertOverlay.style.display = 'none'; + } + var video = document.getElementsByTagName('video')[0]; video.setAttribute('webkit-playsinline', ''); video.setAttribute('playsinline', ''); diff --git a/LegacyComponents/TGMediaAssetsController.h b/LegacyComponents/TGMediaAssetsController.h index 0d247844f2..d590326db0 100644 --- a/LegacyComponents/TGMediaAssetsController.h +++ b/LegacyComponents/TGMediaAssetsController.h @@ -33,6 +33,8 @@ typedef enum @property (nonatomic, copy) void (^completionBlock)(NSArray *signals); @property (nonatomic, copy) void (^dismissalBlock)(void); +@property (nonatomic, copy) TGViewController *(^requestSearchController)(void); + @property (nonatomic, readonly) TGMediaAssetsPickerController *pickerController; - (UIBarButtonItem *)rightBarButtonItem; diff --git a/LegacyComponents/TGMediaAssetsController.m b/LegacyComponents/TGMediaAssetsController.m index c719d2e366..da74a1e4ec 100644 --- a/LegacyComponents/TGMediaAssetsController.m +++ b/LegacyComponents/TGMediaAssetsController.m @@ -694,14 +694,13 @@ - (void)searchButtonPressed { - __weak TGMediaAssetsController *weakSelf = self; - if (false) { - + if (self.requestSearchController) { + _searchController = self.requestSearchController(); } /*TGWebSearchController *searchController = [[TGWebSearchController alloc] initWithContext:[TGLegacyComponentsContext shared] forAvatarSelection:(_intent == TGMediaAssetsControllerSetProfilePhotoIntent) embedded:true]; searchController.captionsEnabled = self.captionsEnabled; searchController.suggestionContext = self.suggestionContext; - + __weak TGWebSearchController *weakController = searchController; searchController.avatarCompletionBlock = ^(UIImage *image) { @@ -738,7 +737,7 @@ }; searchController.parentNavigationController = self; [searchController presentEmbeddedInController:self animated:true]; - + _searchController = searchController;*/ } diff --git a/LegacyComponents/TGMediaAvatarMenuMixin.h b/LegacyComponents/TGMediaAvatarMenuMixin.h index ea2394e0b7..d9e90b0cf5 100644 --- a/LegacyComponents/TGMediaAvatarMenuMixin.h +++ b/LegacyComponents/TGMediaAvatarMenuMixin.h @@ -3,12 +3,14 @@ @class TGViewController; @class TGMenuSheetController; +@class TGMediaAssetsController; @interface TGMediaAvatarMenuMixin : NSObject @property (nonatomic, copy) void (^didFinishWithImage)(UIImage *image); @property (nonatomic, copy) void (^didFinishWithDelete)(void); @property (nonatomic, copy) void (^didDismiss)(void); +@property (nonatomic, copy) TGViewController *(^requestSearchController)(TGMediaAssetsController *); - (instancetype)initWithContext:(id)context parentController:(TGViewController *)parentController hasDeleteButton:(bool)hasDeleteButton saveEditedPhotos:(bool)saveEditedPhotos saveCapturedMedia:(bool)saveCapturedMedia; - (instancetype)initWithContext:(id)context parentController:(TGViewController *)parentController hasDeleteButton:(bool)hasDeleteButton personalPhoto:(bool)personalPhoto saveEditedPhotos:(bool)saveEditedPhotos saveCapturedMedia:(bool)saveCapturedMedia; diff --git a/LegacyComponents/TGMediaAvatarMenuMixin.m b/LegacyComponents/TGMediaAvatarMenuMixin.m index 64dc9bd20f..2f18514f05 100644 --- a/LegacyComponents/TGMediaAvatarMenuMixin.m +++ b/LegacyComponents/TGMediaAvatarMenuMixin.m @@ -402,6 +402,15 @@ if (strongController != nil && strongController.dismissalBlock != nil) strongController.dismissalBlock(); }; + controller.requestSearchController = ^TGViewController * + { + __strong TGMediaAvatarMenuMixin *strongSelf = weakSelf; + __strong TGMediaAssetsController *strongController = weakController; + if (strongSelf == nil) + return nil; + + return strongSelf.requestSearchController(strongController); + }; presentBlock(controller); }; diff --git a/LegacyComponents/TGPhotoStickersView.m b/LegacyComponents/TGPhotoStickersView.m index 5539dd1554..d0f3711fa3 100644 --- a/LegacyComponents/TGPhotoStickersView.m +++ b/LegacyComponents/TGPhotoStickersView.m @@ -167,7 +167,7 @@ typedef enum { { __strong TGPhotoStickersView *strongSelf = weakSelf; if (strongSelf != nil) - [strongSelf scrollToSection:index]; + [strongSelf scrollToSection:index == 1 ? 0 : index - 2]; }; [_wrapperView addSubview:_tabPanel]; @@ -404,7 +404,7 @@ typedef enum { [_collectionView reloadData]; - [_tabPanel setStickerPacks:_section == TGPhotoStickersViewSectionMasks ? _maskStickerPacks : _genericStickerPacks showRecent:_section == TGPhotoStickersViewSectionMasks ? (_recentStickers.count != 0) : (_recentMasks.count != 0) showFavorite:false showGroup:false showGroupLast:false showGifs:false showTrendingFirst:false showTrendingLast:false]; + [_tabPanel setStickerPacks:_section == TGPhotoStickersViewSectionMasks ? _maskStickerPacks : _genericStickerPacks showRecent:_section == TGPhotoStickersViewSectionMasks ? (_recentMasks.count != 0) : (_recentStickers.count != 0) showFavorite:false showGroup:false showGroupLast:false showGifs:false showTrendingFirst:false showTrendingLast:false]; } - (void)updateRecentDocuments diff --git a/LegacyComponents/TGStickerKeyboardTabPanel.m b/LegacyComponents/TGStickerKeyboardTabPanel.m index 8d7468a0bd..ea6e658fcc 100644 --- a/LegacyComponents/TGStickerKeyboardTabPanel.m +++ b/LegacyComponents/TGStickerKeyboardTabPanel.m @@ -399,16 +399,35 @@ - (void)setCurrentStickerPackIndex:(NSUInteger)currentStickerPackIndex animated:(bool)animated { - NSInteger section = currentStickerPackIndex + 1; + NSInteger section = 0; NSInteger row = 0; - if (section >= 4) + if (_style != TGStickerKeyboardViewPaintStyle && _style != TGStickerKeyboardViewPaintDarkStyle) { - section = 4; - row = currentStickerPackIndex - 4; + section = currentStickerPackIndex + 1; - if (!_showGroup) - row++; + if (section >= 4 + _stickerPacks.count) + { + section = 5 + currentStickerPackIndex - _stickerPacks.count - 3; + } + else if (section >= 4) + { + section = 4; + row = currentStickerPackIndex - 3; + } + } + else + { + if (currentStickerPackIndex == 0) + { + section = 2; + row = 0; + } + else + { + section = 4; + row = currentStickerPackIndex - 1; + } } NSArray *selectedItems = [_collectionView indexPathsForSelectedItems]; @@ -459,7 +478,11 @@ - (void)scrollToTrendingButton { NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_showGifs ? 1 : 0 inSection:0]; if (_showTrendingLast) { - indexPath = [NSIndexPath indexPathForItem:0 inSection:5]; + NSInteger item = 0; + if ([self collectionView:_collectionView numberOfItemsInSection:5] > 2) + item = 1; + + indexPath = [NSIndexPath indexPathForItem:item inSection:5]; } if (indexPath.section < [self numberOfSectionsInCollectionView:_collectionView] && indexPath.item < [self collectionView:_collectionView numberOfItemsInSection:indexPath.section]) { UICollectionViewLayoutAttributes *attributes = [_collectionLayout layoutAttributesForItemAtIndexPath:indexPath]; diff --git a/LegacyComponents/TGTextField.h b/LegacyComponents/TGTextField.h index ea61efdd80..f34c1687ad 100644 --- a/LegacyComponents/TGTextField.h +++ b/LegacyComponents/TGTextField.h @@ -6,6 +6,7 @@ @property (nonatomic, strong) UIColor *placeholderColor; @property (nonatomic, strong) UIFont *placeholderFont; +@property (nonatomic) CGFloat placeholderOffset; @property (nonatomic) CGFloat leftInset; @property (nonatomic) CGFloat rightInset; diff --git a/LegacyComponents/TGTextField.m b/LegacyComponents/TGTextField.m index 648cd06da3..92c74fc979 100644 --- a/LegacyComponents/TGTextField.m +++ b/LegacyComponents/TGTextField.m @@ -21,7 +21,7 @@ else if (self.textAlignment == NSTextAlignmentRight) placeholderOrigin.x = rect.size.width - placeholderSize.width; - placeholderOrigin.y += TGRetinaPixel; + placeholderOrigin.y += TGScreenPixel + _placeholderOffset; [self.placeholder drawAtPoint:placeholderOrigin withFont:_placeholderFont]; } @@ -38,7 +38,7 @@ - (CGRect)editingRectForBounds:(CGRect)bounds { - return CGRectOffset([self textRectForBounds:bounds], 0.0f, TGRetinaPixel + _editingRectOffset); + return CGRectOffset([self textRectForBounds:bounds], 0.0f, TGScreenPixel + _editingRectOffset); } - (CGRect)placeholderRectForBounds:(CGRect)bounds