mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			68 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			68 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Matlab
		
	
| 
								 
											7 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								//  Copyright (c) 2019 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#import "OWSTextView.h"
							 | 
						||
| 
								 | 
							
								#import "Theme.h"
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								#import <SessionUIKit/SessionUIKit.h>
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_BEGIN
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
							 | 
						||
| 
								 | 
							
								    = UIDataDetectorTypeLink | UIDataDetectorTypeAddress | UIDataDetectorTypeCalendarEvent;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const UIDataDetectorTypes kOWSAllowedDataDetectorTypesExceptLinks
							 | 
						||
| 
								 | 
							
								    = UIDataDetectorTypeAddress | UIDataDetectorTypeCalendarEvent;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								@implementation OWSTextView
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (instancetype)initWithFrame:(CGRect)frame textContainer:(nullable NSTextContainer *)textContainer
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    if (self = [super initWithFrame:frame textContainer:textContainer]) {
							 | 
						||
| 
								 | 
							
								        [self ows_applyTheme];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    // Setting dataDetectorTypes is expensive.  Do it just once.
							 | 
						||
| 
								 | 
							
								    self.dataDetectorTypes = kOWSAllowedDataDetectorTypes;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    return self;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    if (self = [super initWithCoder:aDecoder]) {
							 | 
						||
| 
								 | 
							
								        [self ows_applyTheme];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    self.dataDetectorTypes = kOWSAllowedDataDetectorTypes;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    return self;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)ows_applyTheme
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    self.keyboardAppearance = LKAppModeUtilities.isLightMode ? UIKeyboardAppearanceDefault : UIKeyboardAppearanceDark;
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								// MARK: -
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)ensureShouldLinkifyText:(BOOL)shouldLinkifyText
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    if (shouldLinkifyText) {
							 | 
						||
| 
								 | 
							
								        // Setting dataDetectorTypes can be expensive, so we only update it when it's changed.
							 | 
						||
| 
								 | 
							
								        if (self.dataDetectorTypes != kOWSAllowedDataDetectorTypes) {
							 | 
						||
| 
								 | 
							
								            self.dataDetectorTypes = kOWSAllowedDataDetectorTypes;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        // Setting dataDetectorTypes can be expensive, so we only update it when it's changed.
							 | 
						||
| 
								 | 
							
								        if (self.dataDetectorTypes != kOWSAllowedDataDetectorTypesExceptLinks) {
							 | 
						||
| 
								 | 
							
								            self.dataDetectorTypes = kOWSAllowedDataDetectorTypesExceptLinks;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_END
							 |