mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Initial support for input language restoration
This commit is contained in:
@@ -140,8 +140,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic) BOOL enablesReturnKeyAutomatically; // default is NO (when YES, will automatically disable return key when text widget has zero-length contents, and will automatically enable when text widget has non-zero-length contents)
|
||||
@property (nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; // default is NO
|
||||
|
||||
- (void)dropAutocorrection;
|
||||
@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage;
|
||||
|
||||
- (void)dropAutocorrection;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
@interface ASPanningOverriddenUITextView : ASTextKitComponentsTextView
|
||||
{
|
||||
BOOL _shouldBlockPanGesture;
|
||||
BOOL _initializedPrimaryInputLanguage;
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) bool (^shouldPaste)();
|
||||
@@ -90,6 +91,8 @@
|
||||
@property (nonatomic, copy) bool (^shouldReturn)();
|
||||
@property (nonatomic, copy) void (^backspaceWhileEmpty)();
|
||||
|
||||
@property (nonatomic, strong) NSString * _Nullable initialPrimaryLanguage;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASPanningOverriddenUITextView
|
||||
@@ -190,6 +193,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (UITextInputMode *)textInputMode {
|
||||
if (!_initializedPrimaryInputLanguage) {
|
||||
_initializedPrimaryInputLanguage = true;
|
||||
/*if (_initialPrimaryLanguage != nil) {
|
||||
for (UITextInputMode *inputMode in [UITextInputMode activeInputModes]) {
|
||||
NSString *primaryLanguage = inputMode.primaryLanguage;
|
||||
if (primaryLanguage != nil && [primaryLanguage isEqualToString:_initialPrimaryLanguage]) {
|
||||
return inputMode;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return [super textInputMode];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
||||
@@ -316,6 +334,7 @@
|
||||
|
||||
// Create and configure our text view.
|
||||
ASPanningOverriddenUITextView *textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
||||
textView.initialPrimaryLanguage = _initialPrimaryLanguage;
|
||||
__weak ASEditableTextNode *weakSelf = self;
|
||||
textView.shouldPaste = ^bool{
|
||||
__strong ASEditableTextNode *strongSelf = weakSelf;
|
||||
|
||||
Reference in New Issue
Block a user