Skip to content

Commit

Permalink
v5.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
张双义 committed Jan 18, 2022
1 parent a48ab2d commit 2e0718e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 7 deletions.
2 changes: 1 addition & 1 deletion UdeskSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'UdeskSDK'
s.version = '5.2.5'
s.version = '5.2.6'
s.license = 'MIT'
s.summary = 'Udesk SDK for iOS'
s.homepage = 'https://github.com/udesk/UdeskSDK-iOS'
Expand Down
Binary file modified UdeskSDK/SDK/libUdesk.a
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ - (void)didUpdateAgentModel:(UdeskAgent *)agent {

//收到客服发送的满意度调查
- (void)didReceiveSurveyWithAgentId:(NSString *)agentId {

[self servicesFeedbackSurveyWithAgentId:agentId];
[self showSurveyViewWithAgentId:agentId];
}

//无消息会话标题
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ - (void)layoutRichTextMessage {

CGFloat spacing = ud_isIOS11 ? 0 : kUDRichMendSpacingOne;

self.attributedString = [self getAttributedStringWithText:self.message.content font:[UdeskSDKConfig customConfig].sdkStyle.messageContentFont];
UIFont *textFont = [self preferredRichTextFont];
self.attributedString = [self getAttributedStringWithText:self.message.content font:textFont];
CGSize richSize = [self getAttributedStringSizeWithAttr:self.attributedString size:CGSizeMake([self textMaxWidth], CGFLOAT_MAX)];
switch (self.message.messageFrom) {
case UDMessageTypeSending:{
Expand Down Expand Up @@ -105,4 +106,56 @@ - (UITableViewCell *)getCellWithReuseIdentifier:(NSString *)cellReuseIdentifer {
return [[UdeskRichCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifer];
}

- (UIFont *)preferredRichTextFont
{
UIFont *messageFont =[UdeskSDKConfig customConfig].sdkStyle.messageContentFont;
if (!messageFont) {
return nil;
}
UIFont *preferredFont = messageFont;

BOOL fontFix = ![self isLocaleChineseLanguage];
static NSString *systemFontFamilyName;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIFont *sysFont = [UIFont systemFontOfSize:1];
systemFontFamilyName = sysFont.familyName;
});

//非中文环境下默认消息字体强制 苹方
if (fontFix && systemFontFamilyName && [systemFontFamilyName isEqualToString:messageFont.familyName]) {
UIFontDescriptor *fontDescriptor = [messageFont fontDescriptor];
NSMutableDictionary<UIFontDescriptorAttributeName, id> *atts = [[fontDescriptor fontAttributes] mutableCopy];
[atts setValue:nil forKey:UIFontDescriptorTextStyleAttribute];
[atts setValue:@"PingFang SC" forKey:UIFontDescriptorFamilyAttribute];
[atts setValue:@"PingFangSC-Regular" forKey:UIFontDescriptorNameAttribute];
UIFontDescriptorSymbolicTraits traits = fontDescriptor.symbolicTraits;
UIFontDescriptor *preferrDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:atts];
preferrDescriptor = [preferrDescriptor fontDescriptorWithSymbolicTraits:traits];

preferredFont = [UIFont fontWithDescriptor:preferrDescriptor size:messageFont.pointSize];
}

return preferredFont;
}

- (BOOL)isLocaleChineseLanguage
{
NSArray *languages = [NSLocale preferredLanguages];
NSString *pfLanguageCode = [languages objectAtIndex:0];
if ([pfLanguageCode isEqualToString:@"zh-Hant"] ||
[pfLanguageCode hasPrefix:@"zh-Hant"] ||
[pfLanguageCode hasPrefix:@"yue-Hant"] ||
[pfLanguageCode isEqualToString:@"zh-HK"] ||
[pfLanguageCode isEqualToString:@"zh-TW"]||
[pfLanguageCode isEqualToString:@"zh-Hans"] ||
[pfLanguageCode hasPrefix:@"yue-Hans"] ||
[pfLanguageCode hasPrefix:@"zh-Hans"]
)
{
return YES;
}
return NO;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ + (NSAttributedString *)attributedStringFromNode:(xmlNodePtr)xmlNode customFont:
//加粗标签
if (strncmp("strong", (const char *)xmlNode->name, strlen((const char *)xmlNode->name)) == 0) {
if (customFont) {
UIFont *boldFont = [UIFont boldSystemFontOfSize:customFont.pointSize];
UIFontDescriptor *fontDescriptor = [customFont fontDescriptor];
UIFontDescriptor *bodlDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:fontDescriptor.symbolicTraits | UIFontDescriptorTraitBold];
UIFont *boldFont = [UIFont fontWithDescriptor:bodlDescriptor size:customFont.pointSize];
[nodeAttributedString addAttribute:NSFontAttributeName value:boldFont range:nodeAttributedStringRange];
}
}
Expand Down Expand Up @@ -353,4 +355,13 @@ + (NSAttributedString *)attributedStringFromNode:(xmlNodePtr)xmlNode customFont:
return nodeAttributedString;
}


- (UIFont *)bodyFont:(UIFont *)baseFont
{
UIFontDescriptor *fontDescriptor = [baseFont fontDescriptor];
UIFontDescriptor *bodlDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:fontDescriptor.symbolicTraits | UIFontDescriptorTraitBold];
UIFont *boldFont = [UIFont fontWithDescriptor:bodlDescriptor size:baseFont.pointSize];
return boldFont;
}

@end
4 changes: 2 additions & 2 deletions UdeskSDKExample/UdeskSDKExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2499,7 +2499,7 @@
"$(inherited)",
"\"$(SRCROOT)/../UdeskSDK/SDK\"",
);
MARKETING_VERSION = 5.2.5;
MARKETING_VERSION = 5.2.6;
OTHER_LDFLAGS = (
"$(inherited)",
"-l\"c++\"",
Expand Down Expand Up @@ -2592,7 +2592,7 @@
"$(inherited)",
"\"$(SRCROOT)/../UdeskSDK/SDK\"",
);
MARKETING_VERSION = 5.2.5;
MARKETING_VERSION = 5.2.6;
OTHER_LDFLAGS = (
"$(inherited)",
"-l\"c++\"",
Expand Down

0 comments on commit 2e0718e

Please sign in to comment.