Merge branch 'dev' into feature/message-requests
# Conflicts: # Session/Conversations/ConversationVC+Interaction.swift
This commit is contained in:
commit
999d4a1082
|
@ -2,6 +2,7 @@ import UIKit
|
||||||
import CoreServices
|
import CoreServices
|
||||||
import Photos
|
import Photos
|
||||||
import PhotosUI
|
import PhotosUI
|
||||||
|
import SessionUtilitiesKit
|
||||||
import SignalUtilitiesKit
|
import SignalUtilitiesKit
|
||||||
|
|
||||||
extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuActionDelegate, ScrollToBottomButtonDelegate,
|
extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuActionDelegate, ScrollToBottomButtonDelegate,
|
||||||
|
@ -516,7 +517,18 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
||||||
let thread = self.thread as? TSContactThread,
|
let thread = self.thread as? TSContactThread,
|
||||||
Storage.shared.getContact(with: thread.contactSessionID())?.isTrusted != true {
|
Storage.shared.getContact(with: thread.contactSessionID())?.isTrusted != true {
|
||||||
confirmDownload()
|
confirmDownload()
|
||||||
} else {
|
}
|
||||||
|
else if (
|
||||||
|
viewItem.attachmentStream?.isText == true ||
|
||||||
|
viewItem.attachmentStream?.isMicrosoftDoc == true ||
|
||||||
|
viewItem.attachmentStream?.contentType == OWSMimeTypeApplicationPdf
|
||||||
|
), let filePathString: String = viewItem.attachmentStream?.originalFilePath {
|
||||||
|
let fileUrl: URL = URL(fileURLWithPath: filePathString)
|
||||||
|
let interactionController: UIDocumentInteractionController = UIDocumentInteractionController(url: fileUrl)
|
||||||
|
interactionController.delegate = self
|
||||||
|
interactionController.presentPreview(animated: true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Open the document if possible
|
// Open the document if possible
|
||||||
guard let url = viewItem.attachmentStream?.originalMediaURL else { return }
|
guard let url = viewItem.attachmentStream?.originalMediaURL else { return }
|
||||||
let shareVC = UIActivityViewController(activityItems: [ url ], applicationActivities: nil)
|
let shareVC = UIActivityViewController(activityItems: [ url ], applicationActivities: nil)
|
||||||
|
@ -1039,6 +1051,14 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - UIDocumentInteractionControllerDelegate
|
||||||
|
|
||||||
|
extension ConversationVC: UIDocumentInteractionControllerDelegate {
|
||||||
|
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Message Request Actions
|
// MARK: - Message Request Actions
|
||||||
|
|
||||||
extension ConversationVC {
|
extension ConversationVC {
|
||||||
|
|
|
@ -194,7 +194,7 @@ static NSTimeInterval launchStartedAt;
|
||||||
mainWindow.rootViewController = [LoadingViewController new];
|
mainWindow.rootViewController = [LoadingViewController new];
|
||||||
[mainWindow makeKeyAndVisible];
|
[mainWindow makeKeyAndVisible];
|
||||||
|
|
||||||
LKAppMode appMode = [self getCurrentAppMode];
|
LKAppMode appMode = [LKAppModeManager getAppModeOrSystemDefault];
|
||||||
[self adaptAppMode:appMode];
|
[self adaptAppMode:appMode];
|
||||||
|
|
||||||
if (@available(iOS 11, *)) {
|
if (@available(iOS 11, *)) {
|
||||||
|
@ -245,7 +245,7 @@ static NSTimeInterval launchStartedAt;
|
||||||
|
|
||||||
[self ensureRootViewController];
|
[self ensureRootViewController];
|
||||||
|
|
||||||
LKAppMode appMode = [self getCurrentAppMode];
|
LKAppMode appMode = [LKAppModeManager getAppModeOrSystemDefault];
|
||||||
[self adaptAppMode:appMode];
|
[self adaptAppMode:appMode];
|
||||||
|
|
||||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||||
|
@ -734,12 +734,6 @@ static NSTimeInterval launchStartedAt;
|
||||||
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.appModeChanged object:nil];
|
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.appModeChanged object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (LKAppMode)getCurrentAppMode
|
|
||||||
{
|
|
||||||
LKAppMode appMode = [self getAppModeOrSystemDefault];
|
|
||||||
return appMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setCurrentAppMode:(LKAppMode)appMode
|
- (void)setCurrentAppMode:(LKAppMode)appMode
|
||||||
{
|
{
|
||||||
[NSUserDefaults.standardUserDefaults setInteger:appMode forKey:@"appMode"];
|
[NSUserDefaults.standardUserDefaults setInteger:appMode forKey:@"appMode"];
|
||||||
|
@ -749,7 +743,7 @@ static NSTimeInterval launchStartedAt;
|
||||||
- (void)setAppModeToSystemDefault
|
- (void)setAppModeToSystemDefault
|
||||||
{
|
{
|
||||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:@"appMode"];
|
[NSUserDefaults.standardUserDefaults removeObjectForKey:@"appMode"];
|
||||||
LKAppMode appMode = [self getCurrentAppMode];
|
LKAppMode appMode = [LKAppModeManager getAppModeOrSystemDefault];
|
||||||
[self adaptAppMode:appMode];
|
[self adaptAppMode:appMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,20 +45,4 @@ extension AppDelegate {
|
||||||
@objc func stopClosedGroupPoller() {
|
@objc func stopClosedGroupPoller() {
|
||||||
ClosedGroupPoller.shared.stop()
|
ClosedGroupPoller.shared.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func getAppModeOrSystemDefault() -> AppMode {
|
|
||||||
let userDefaults = UserDefaults.standard
|
|
||||||
|
|
||||||
guard userDefaults.dictionaryRepresentation().keys.contains("appMode") else {
|
|
||||||
if #available(iOS 13.0, *) {
|
|
||||||
return UITraitCollection.current.userInterfaceStyle == .dark ? .dark : .light
|
|
||||||
} else {
|
|
||||||
return .light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mode = userDefaults.integer(forKey: "appMode")
|
|
||||||
return AppMode(rawValue: mode) ?? .light
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,7 +462,12 @@ public class SignalAttachment: NSObject {
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
public var isText: Bool {
|
public var isText: Bool {
|
||||||
return UTTypeConformsTo(dataUTI as CFString, kUTTypeText) || isOversizeText
|
return (
|
||||||
|
isConvertibleToTextMessage && (
|
||||||
|
UTTypeConformsTo(dataUTI as CFString, kUTTypeText) ||
|
||||||
|
isOversizeText
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
|
|
|
@ -84,6 +84,8 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
|
||||||
@property (nonatomic, readonly) BOOL isAudio;
|
@property (nonatomic, readonly) BOOL isAudio;
|
||||||
@property (nonatomic, readonly) BOOL isVoiceMessage;
|
@property (nonatomic, readonly) BOOL isVoiceMessage;
|
||||||
@property (nonatomic, readonly) BOOL isVisualMedia;
|
@property (nonatomic, readonly) BOOL isVisualMedia;
|
||||||
|
@property (nonatomic, readonly) BOOL isText;
|
||||||
|
@property (nonatomic, readonly) BOOL isMicrosoftDoc;
|
||||||
@property (nonatomic, readonly) BOOL isOversizeText;
|
@property (nonatomic, readonly) BOOL isOversizeText;
|
||||||
|
|
||||||
+ (NSString *)emojiForMimeType:(NSString *)contentType;
|
+ (NSString *)emojiForMimeType:(NSString *)contentType;
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
#import "TSAttachmentPointer.h"
|
#import "TSAttachmentPointer.h"
|
||||||
#import <SignalCoreKit/NSString+OWS.h>
|
#import <SignalCoreKit/NSString+OWS.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
#import <CoreServices/CoreServices.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
NSUInteger const TSAttachmentSchemaVersion = 4;
|
NSUInteger const TSAttachmentSchemaVersion = 4;
|
||||||
|
@ -229,6 +237,14 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
||||||
return [MIMETypeUtil isVisualMedia:self.contentType];
|
return [MIMETypeUtil isVisualMedia:self.contentType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isText {
|
||||||
|
return [MIMETypeUtil isText:self.contentType];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isMicrosoftDoc {
|
||||||
|
return [MIMETypeUtil isMicrosoftDoc:self.contentType];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)isOversizeText
|
- (BOOL)isOversizeText
|
||||||
{
|
{
|
||||||
return [self.contentType isEqualToString:OWSMimeTypeOversizeTextMessage];
|
return [self.contentType isEqualToString:OWSMimeTypeOversizeTextMessage];
|
||||||
|
|
|
@ -162,15 +162,6 @@ final class ShareVC : UINavigationController, ShareViewDelegate, AppModeManagerD
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - App Mode
|
// MARK: - App Mode
|
||||||
|
|
||||||
public func getCurrentAppMode() -> AppMode {
|
|
||||||
guard let window = self.view.window else { return .light }
|
|
||||||
|
|
||||||
let userInterfaceStyle = window.traitCollection.userInterfaceStyle
|
|
||||||
let isLightMode = (userInterfaceStyle == .light || userInterfaceStyle == .unspecified)
|
|
||||||
|
|
||||||
return (isLightMode ? .light : .dark)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func setCurrentAppMode(to appMode: AppMode) {
|
public func setCurrentAppMode(to appMode: AppMode) {
|
||||||
return // Not applicable to share extensions
|
return // Not applicable to share extensions
|
||||||
|
|
|
@ -95,6 +95,11 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
|
view.setGradient(Gradients.defaultBackground)
|
||||||
|
fadeView.setGradient(Gradients.homeVCFade)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Layout
|
// MARK: Layout
|
||||||
|
|
||||||
private func setupLayout() {
|
private func setupLayout() {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import Foundation
|
import UIKit
|
||||||
|
|
||||||
@objc(LKAppModeManager)
|
@objc(LKAppModeManager)
|
||||||
public final class AppModeManager : NSObject {
|
public final class AppModeManager : NSObject {
|
||||||
private let delegate: AppModeManagerDelegate
|
private let delegate: AppModeManagerDelegate
|
||||||
|
|
||||||
public var currentAppMode: AppMode {
|
public var currentAppMode: AppMode {
|
||||||
return delegate.getCurrentAppMode()
|
return AppModeManager.getAppModeOrSystemDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
public static var shared: AppModeManager!
|
public static var shared: AppModeManager!
|
||||||
|
@ -29,19 +29,33 @@ public final class AppModeManager : NSObject {
|
||||||
public func setAppModeToSystemDefault() {
|
public func setAppModeToSystemDefault() {
|
||||||
delegate.setAppModeToSystemDefault()
|
delegate.setAppModeToSystemDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc public static func getAppModeOrSystemDefault() -> AppMode {
|
||||||
|
let userDefaults = UserDefaults.standard
|
||||||
|
|
||||||
|
guard userDefaults.dictionaryRepresentation().keys.contains("appMode") else {
|
||||||
|
if #available(iOS 13.0, *) {
|
||||||
|
return UITraitCollection.current.userInterfaceStyle == .dark ? .dark : .light
|
||||||
|
}
|
||||||
|
|
||||||
|
return .light
|
||||||
|
}
|
||||||
|
|
||||||
|
let mode = userDefaults.integer(forKey: "appMode")
|
||||||
|
return AppMode(rawValue: mode) ?? .light
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc(LKAppModeManagerDelegate)
|
@objc(LKAppModeManagerDelegate)
|
||||||
public protocol AppModeManagerDelegate {
|
public protocol AppModeManagerDelegate {
|
||||||
|
|
||||||
func getCurrentAppMode() -> AppMode
|
|
||||||
@objc(setCurrentAppMode:)
|
@objc(setCurrentAppMode:)
|
||||||
func setCurrentAppMode(to appMode: AppMode)
|
func setCurrentAppMode(to appMode: AppMode)
|
||||||
func setAppModeToSystemDefault()
|
func setAppModeToSystemDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc(LKAppMode)
|
@objc(LKAppMode)
|
||||||
public enum AppMode : Int {
|
public enum AppMode: Int {
|
||||||
case light, dark
|
case light, dark
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
extern NSString *const OWSMimeTypeApplicationOctetStream;
|
extern NSString *const OWSMimeTypeApplicationOctetStream;
|
||||||
extern NSString *const OWSMimeTypeApplicationZip;
|
extern NSString *const OWSMimeTypeApplicationZip;
|
||||||
|
extern NSString *const OWSMimeTypeApplicationPdf;
|
||||||
extern NSString *const OWSMimeTypeImagePng;
|
extern NSString *const OWSMimeTypeImagePng;
|
||||||
extern NSString *const OWSMimeTypeImageJpeg;
|
extern NSString *const OWSMimeTypeImageJpeg;
|
||||||
extern NSString *const OWSMimeTypeImageGif;
|
extern NSString *const OWSMimeTypeImageGif;
|
||||||
|
@ -40,6 +41,8 @@ extern NSString *const kSyncMessageFileExtension;
|
||||||
+ (BOOL)isImage:(NSString *)contentType;
|
+ (BOOL)isImage:(NSString *)contentType;
|
||||||
+ (BOOL)isVideo:(NSString *)contentType;
|
+ (BOOL)isVideo:(NSString *)contentType;
|
||||||
+ (BOOL)isAudio:(NSString *)contentType;
|
+ (BOOL)isAudio:(NSString *)contentType;
|
||||||
|
+ (BOOL)isText:(NSString *)contentType;
|
||||||
|
+ (BOOL)isMicrosoftDoc:(NSString *)contentType;
|
||||||
+ (BOOL)isVisualMedia:(NSString *)contentType;
|
+ (BOOL)isVisualMedia:(NSString *)contentType;
|
||||||
|
|
||||||
// filename is optional and should not be trusted.
|
// filename is optional and should not be trusted.
|
||||||
|
|
|
@ -22,6 +22,7 @@ NSString *const OWSMimeTypeImageBmp2 = @"image/x-windows-bmp";
|
||||||
NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain";
|
NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain";
|
||||||
NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
|
NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
|
||||||
NSString *const OWSMimeTypeApplicationZip = @"application/zip";
|
NSString *const OWSMimeTypeApplicationZip = @"application/zip";
|
||||||
|
NSString *const OWSMimeTypeApplicationPdf = @"application/pdf";
|
||||||
|
|
||||||
NSString *const kOversizeTextAttachmentUTI = @"org.whispersystems.oversize-text-attachment";
|
NSString *const kOversizeTextAttachmentUTI = @"org.whispersystems.oversize-text-attachment";
|
||||||
NSString *const kOversizeTextAttachmentFileExtension = @"txt";
|
NSString *const kOversizeTextAttachmentFileExtension = @"txt";
|
||||||
|
@ -278,6 +279,53 @@ NSString *const kSyncMessageFileExtension = @"bin";
|
||||||
return [MIMETypeUtil isSupportedAudioMIMEType:contentType];
|
return [MIMETypeUtil isSupportedAudioMIMEType:contentType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (BOOL)isText:(NSString *)contentType {
|
||||||
|
return [
|
||||||
|
@[
|
||||||
|
@"text/plain",
|
||||||
|
@"text/csv",
|
||||||
|
@"text/tab-separated-values"
|
||||||
|
]
|
||||||
|
containsObject:contentType
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL)isMicrosoftDoc:(NSString *)contentType {
|
||||||
|
return [
|
||||||
|
@[
|
||||||
|
// Word files
|
||||||
|
@"application/msword",
|
||||||
|
|
||||||
|
@"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
||||||
|
@"application/vnd.ms-word.document.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-word.template.macroEnabled.12",
|
||||||
|
|
||||||
|
// Excel files
|
||||||
|
@"application/vnd.ms-excel",
|
||||||
|
|
||||||
|
@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
||||||
|
@"application/vnd.ms-excel.sheet.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-excel.template.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-excel.addin.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
||||||
|
|
||||||
|
// Powerpoint files
|
||||||
|
@"application/vnd.ms-powerpoint",
|
||||||
|
|
||||||
|
@"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.presentationml.template",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
||||||
|
@"application/vnd.ms-powerpoint.addin.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-powerpoint.presentation.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-powerpoint.template.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-powerpoint.slideshow.macroEnabled.12"
|
||||||
|
]
|
||||||
|
containsObject:contentType
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
+ (BOOL)isVisualMedia:(NSString *)contentType
|
+ (BOOL)isVisualMedia:(NSString *)contentType
|
||||||
{
|
{
|
||||||
if ([self isImage:contentType]) {
|
if ([self isImage:contentType]) {
|
||||||
|
|
Loading…
Reference in New Issue