Merge branch 'mkirk/hide-all-media-from-settings-gallery'

pull/1/head
Michael Kirk 7 years ago
commit 999b0f0f9c

@ -2033,8 +2033,10 @@ typedef enum : NSUInteger {
} }
TSMessage *mediaMessage = (TSMessage *)viewItem.interaction; TSMessage *mediaMessage = (TSMessage *)viewItem.interaction;
MediaGalleryViewController *vc = [[MediaGalleryViewController alloc] initWithThread:self.thread MediaGalleryViewController *vc = [[MediaGalleryViewController alloc]
uiDatabaseConnection:self.uiDatabaseConnection]; initWithThread:self.thread
uiDatabaseConnection:self.uiDatabaseConnection
options:MediaGalleryOptionSliderEnabled | MediaGalleryOptionShowAllMediaButton];
[vc presentDetailViewFromViewController:self mediaMessage:mediaMessage replacingView:imageView]; [vc presentDetailViewFromViewController:self mediaMessage:mediaMessage replacingView:imageView];
} }
@ -2055,8 +2057,10 @@ typedef enum : NSUInteger {
} }
TSMessage *mediaMessage = (TSMessage *)viewItem.interaction; TSMessage *mediaMessage = (TSMessage *)viewItem.interaction;
MediaGalleryViewController *vc = [[MediaGalleryViewController alloc] initWithThread:self.thread MediaGalleryViewController *vc = [[MediaGalleryViewController alloc]
uiDatabaseConnection:self.uiDatabaseConnection]; initWithThread:self.thread
uiDatabaseConnection:self.uiDatabaseConnection
options:MediaGalleryOptionSliderEnabled | MediaGalleryOptionShowAllMediaButton];
[vc presentDetailViewFromViewController:self mediaMessage:mediaMessage replacingView:imageView]; [vc presentDetailViewFromViewController:self mediaMessage:mediaMessage replacingView:imageView];
} }

@ -10,6 +10,11 @@ NS_ASSUME_NONNULL_BEGIN
@class GalleryItemBox; @class GalleryItemBox;
@class MediaDetailViewController; @class MediaDetailViewController;
typedef NS_OPTIONS(NSInteger, MediaGalleryOption) {
MediaGalleryOptionSliderEnabled = 1 << 0,
MediaGalleryOptionShowAllMediaButton = 1 << 1
};
@protocol MediaDetailViewControllerDelegate <NSObject> @protocol MediaDetailViewControllerDelegate <NSObject>
- (void)dismissSelfAnimated:(BOOL)isAnimated completion:(void (^_Nullable)(void))completionBlock; - (void)dismissSelfAnimated:(BOOL)isAnimated completion:(void (^_Nullable)(void))completionBlock;

@ -178,7 +178,7 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
private var initialDetailItem: MediaGalleryItem? private var initialDetailItem: MediaGalleryItem?
private let thread: TSThread private let thread: TSThread
private let includeGallery: Bool private let options: MediaGalleryOption
// we start with a small range size for quick loading. // we start with a small range size for quick loading.
private let fetchRangeSize: UInt = 10 private let fetchRangeSize: UInt = 10
@ -187,15 +187,11 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
Logger.debug("\(logTag) deinit") Logger.debug("\(logTag) deinit")
} }
convenience init(thread: TSThread, uiDatabaseConnection: YapDatabaseConnection) { init(thread: TSThread, uiDatabaseConnection: YapDatabaseConnection, options: MediaGalleryOption = []) {
self.init(thread: thread, uiDatabaseConnection: uiDatabaseConnection, includeGallery: true)
}
init(thread: TSThread, uiDatabaseConnection: YapDatabaseConnection, includeGallery: Bool) {
self.thread = thread self.thread = thread
assert(uiDatabaseConnection.isInLongLivedReadTransaction()) assert(uiDatabaseConnection.isInLongLivedReadTransaction())
self.uiDatabaseConnection = uiDatabaseConnection self.uiDatabaseConnection = uiDatabaseConnection
self.includeGallery = includeGallery self.options = options
self.mediaGalleryFinder = OWSMediaGalleryFinder(thread: thread) self.mediaGalleryFinder = OWSMediaGalleryFinder(thread: thread)
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
@ -264,7 +260,7 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
ensureGalleryItemsLoaded(.around, item: initialDetailItem, amount: 10) ensureGalleryItemsLoaded(.around, item: initialDetailItem, amount: 10)
self.initialDetailItem = initialDetailItem self.initialDetailItem = initialDetailItem
let pageViewController = MediaPageViewController(initialItem: initialDetailItem, mediaGalleryDataSource: self, uiDatabaseConnection: self.uiDatabaseConnection, includeGallery: self.includeGallery) let pageViewController = MediaPageViewController(initialItem: initialDetailItem, mediaGalleryDataSource: self, uiDatabaseConnection: self.uiDatabaseConnection, options: self.options)
self.pageViewController = pageViewController self.pageViewController = pageViewController
self.setViewControllers([pageViewController], animated: false) self.setViewControllers([pageViewController], animated: false)

@ -58,16 +58,14 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
private let uiDatabaseConnection: YapDatabaseConnection private let uiDatabaseConnection: YapDatabaseConnection
private let includeGallery: Bool private let showAllMediaButton: Bool
private let sliderEnabled: Bool
convenience init(initialItem: MediaGalleryItem, mediaGalleryDataSource: MediaGalleryDataSource, uiDatabaseConnection: YapDatabaseConnection) { init(initialItem: MediaGalleryItem, mediaGalleryDataSource: MediaGalleryDataSource, uiDatabaseConnection: YapDatabaseConnection, options: MediaGalleryOption) {
self.init(initialItem: initialItem, mediaGalleryDataSource: mediaGalleryDataSource, uiDatabaseConnection: uiDatabaseConnection, includeGallery: true)
}
init(initialItem: MediaGalleryItem, mediaGalleryDataSource: MediaGalleryDataSource, uiDatabaseConnection: YapDatabaseConnection, includeGallery: Bool) {
assert(uiDatabaseConnection.isInLongLivedReadTransaction()) assert(uiDatabaseConnection.isInLongLivedReadTransaction())
self.uiDatabaseConnection = uiDatabaseConnection self.uiDatabaseConnection = uiDatabaseConnection
self.includeGallery = includeGallery self.showAllMediaButton = options.contains(.showAllMediaButton)
self.sliderEnabled = options.contains(.sliderEnabled)
self.mediaGalleryDataSource = mediaGalleryDataSource self.mediaGalleryDataSource = mediaGalleryDataSource
let kSpacingBetweenItems: CGFloat = 20 let kSpacingBetweenItems: CGFloat = 20
@ -106,9 +104,12 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
// Navigation // Navigation
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(didPressDismissButton)) // Note: using a custom leftBarButtonItem breaks the interactive pop gesture, but we don't want to be able
// to swipe to go back in the pager view anyway, instead swiping back should show the next page.
let backButton = OWSViewController.createOWSBackButton(withTarget: self, selector: #selector(didPressDismissButton))
self.navigationItem.leftBarButtonItem = backButton
if includeGallery { if showAllMediaButton {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: MediaStrings.allMedia, style: .plain, target: self, action: #selector(didPressAllMediaButton)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: MediaStrings.allMedia, style: .plain, target: self, action: #selector(didPressAllMediaButton))
} }
@ -129,9 +130,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
// Hack to avoid "page" bouncing when not in gallery view. // Hack to avoid "page" bouncing when not in gallery view.
// e.g. when getting to media details via message details screen, there's only // e.g. when getting to media details via message details screen, there's only
// one "Page" so the bounce doesn't make sense. // one "Page" so the bounce doesn't make sense.
if !self.includeGallery { pagerScrollView.isScrollEnabled = sliderEnabled
pagerScrollView.isScrollEnabled = false
}
// FIXME dynamic title with sender/date // FIXME dynamic title with sender/date
self.title = "Attachment" self.title = "Attachment"

@ -762,7 +762,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi
return return
} }
let mediaGalleryViewController = MediaGalleryViewController(thread: self.thread, uiDatabaseConnection: self.uiDatabaseConnection, includeGallery: false) let mediaGalleryViewController = MediaGalleryViewController(thread: self.thread, uiDatabaseConnection: self.uiDatabaseConnection)
mediaGalleryViewController.presentDetailView(fromViewController: self, mediaMessage: self.message, replacingView: fromView) mediaGalleryViewController.presentDetailView(fromViewController: self, mediaMessage: self.message, replacingView: fromView)
} }
} }

@ -1166,7 +1166,9 @@ NS_ASSUME_NONNULL_BEGIN
DDLogDebug(@"%@ in showMediaGallery", self.logTag); DDLogDebug(@"%@ in showMediaGallery", self.logTag);
MediaGalleryViewController *vc = MediaGalleryViewController *vc =
[[MediaGalleryViewController alloc] initWithThread:self.thread uiDatabaseConnection:self.uiDatabaseConnection]; [[MediaGalleryViewController alloc] initWithThread:self.thread
uiDatabaseConnection:self.uiDatabaseConnection
options:MediaGalleryOptionSliderEnabled];
// although we don't present the mediaGalleryViewController directly, we need to maintain a strong // although we don't present the mediaGalleryViewController directly, we need to maintain a strong
// reference to it until we're dismissed. // reference to it until we're dismissed.

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (UIBarButtonItem *)createOWSBackButton; - (UIBarButtonItem *)createOWSBackButton;
+ (UIBarButtonItem *)createOWSBackButtonWithTarget:(id)target selector:(SEL)selector;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "UIView+OWS.h" #import "UIView+OWS.h"
@ -42,6 +42,11 @@ NS_ASSUME_NONNULL_BEGIN
} }
- (UIBarButtonItem *)createOWSBackButtonWithTarget:(id)target selector:(SEL)selector - (UIBarButtonItem *)createOWSBackButtonWithTarget:(id)target selector:(SEL)selector
{
return [[self class] createOWSBackButtonWithTarget:target selector:selector];
}
+ (UIBarButtonItem *)createOWSBackButtonWithTarget:(id)target selector:(SEL)selector
{ {
OWSAssert(target); OWSAssert(target);
OWSAssert(selector); OWSAssert(selector);

Loading…
Cancel
Save