Fixed a couple of bugs with the share extension
Fixed a bug where sharing a text file was resulting in the entire contents being put into the message input field Fixed a bug where sharing from within the app where the app was in dark mode but the device was in light mode would result in buggy UI
This commit is contained in:
parent
69e464e8ae
commit
140cc97829
|
@ -194,7 +194,7 @@ static NSTimeInterval launchStartedAt;
|
|||
mainWindow.rootViewController = [LoadingViewController new];
|
||||
[mainWindow makeKeyAndVisible];
|
||||
|
||||
LKAppMode appMode = [self getCurrentAppMode];
|
||||
LKAppMode appMode = [LKAppModeManager getAppModeOrSystemDefault];
|
||||
[self adaptAppMode:appMode];
|
||||
|
||||
if (@available(iOS 11, *)) {
|
||||
|
@ -245,7 +245,7 @@ static NSTimeInterval launchStartedAt;
|
|||
|
||||
[self ensureRootViewController];
|
||||
|
||||
LKAppMode appMode = [self getCurrentAppMode];
|
||||
LKAppMode appMode = [LKAppModeManager getAppModeOrSystemDefault];
|
||||
[self adaptAppMode:appMode];
|
||||
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
|
@ -734,12 +734,6 @@ static NSTimeInterval launchStartedAt;
|
|||
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.appModeChanged object:nil];
|
||||
}
|
||||
|
||||
- (LKAppMode)getCurrentAppMode
|
||||
{
|
||||
LKAppMode appMode = [self getAppModeOrSystemDefault];
|
||||
return appMode;
|
||||
}
|
||||
|
||||
- (void)setCurrentAppMode:(LKAppMode)appMode
|
||||
{
|
||||
[NSUserDefaults.standardUserDefaults setInteger:appMode forKey:@"appMode"];
|
||||
|
@ -749,7 +743,7 @@ static NSTimeInterval launchStartedAt;
|
|||
- (void)setAppModeToSystemDefault
|
||||
{
|
||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:@"appMode"];
|
||||
LKAppMode appMode = [self getCurrentAppMode];
|
||||
LKAppMode appMode = [LKAppModeManager getAppModeOrSystemDefault];
|
||||
[self adaptAppMode:appMode];
|
||||
}
|
||||
|
||||
|
|
|
@ -40,20 +40,4 @@ extension AppDelegate {
|
|||
@objc func stopClosedGroupPoller() {
|
||||
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
|
||||
public var isText: Bool {
|
||||
return UTTypeConformsTo(dataUTI as CFString, kUTTypeText) || isOversizeText
|
||||
return (
|
||||
isConvertibleToTextMessage && (
|
||||
UTTypeConformsTo(dataUTI as CFString, kUTTypeText) ||
|
||||
isOversizeText
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@objc
|
||||
|
|
|
@ -162,15 +162,6 @@ final class ShareVC : UINavigationController, ShareViewDelegate, AppModeManagerD
|
|||
}
|
||||
|
||||
// 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) {
|
||||
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
|
||||
|
||||
private func setupLayout() {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
|
||||
@objc(LKAppModeManager)
|
||||
public final class AppModeManager : NSObject {
|
||||
private let delegate: AppModeManagerDelegate
|
||||
|
||||
public var currentAppMode: AppMode {
|
||||
return delegate.getCurrentAppMode()
|
||||
return AppModeManager.getAppModeOrSystemDefault()
|
||||
}
|
||||
|
||||
public static var shared: AppModeManager!
|
||||
|
@ -29,19 +29,33 @@ public final class AppModeManager : NSObject {
|
|||
public func 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)
|
||||
public protocol AppModeManagerDelegate {
|
||||
|
||||
func getCurrentAppMode() -> AppMode
|
||||
@objc(setCurrentAppMode:)
|
||||
func setCurrentAppMode(to appMode: AppMode)
|
||||
func setAppModeToSystemDefault()
|
||||
}
|
||||
|
||||
@objc(LKAppMode)
|
||||
public enum AppMode : Int {
|
||||
public enum AppMode: Int {
|
||||
case light, dark
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue