Skip to content

Commit f8485fb

Browse files
committed
2 parents 395c57d + cb2114b commit f8485fb

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

android/messagelist/src/main/java/cn/jiguang/imui/utils/PhotoViewPagerViewUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ public void onClick(View v) {
176176
}
177177

178178
public static void saveImageToAlbum(String imagePath, Context context) {
179+
if(TextUtils.isEmpty(imagePath)){
180+
return;
181+
}
179182
File imageFile = new File(imagePath);
180183
if (imageFile.exists()) {
181184
try {

ios/RCTAuroraIMUI.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@
10711071
DYLIB_CURRENT_VERSION = 1;
10721072
DYLIB_INSTALL_NAME_BASE = "@rpath";
10731073
FRAMEWORK_SEARCH_PATHS = "";
1074-
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/**";
1074+
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/Headers/Public/**";
10751075
INFOPLIST_FILE = RCTAuroraIMUI/Info.plist;
10761076
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10771077
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -1097,7 +1097,7 @@
10971097
DYLIB_CURRENT_VERSION = 1;
10981098
DYLIB_INSTALL_NAME_BASE = "@rpath";
10991099
FRAMEWORK_SEARCH_PATHS = "";
1100-
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/**";
1100+
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/Headers/Public/**";
11011101
INFOPLIST_FILE = RCTAuroraIMUI/Info.plist;
11021102
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
11031103
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";

ios/RCTAuroraIMUI/DWCustomView/DWOrigImageView.m

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#import "DWOrigImageView.h"
1212
#import "UIView+Extend.h"
13+
#import <Photos/Photos.h>
1314
//#import "DWContentScrollView.h"
1415

1516

@@ -93,7 +94,30 @@ - (void)addContentView{
9394

9495

9596
- (void)saveImage{
96-
UIImageWriteToSavedPhotosAlbum(self.imgView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
97+
// 判断授权状态
98+
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
99+
if (status == PHAuthorizationStatusNotDetermined) { // 用户还没有做出选择
100+
// 弹框请求用户授权
101+
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
102+
if (status == PHAuthorizationStatusAuthorized) { // 用户第一次同意了访问相册权限
103+
UIImageWriteToSavedPhotosAlbum(self.imgView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
104+
}
105+
}];
106+
} else if (status == PHAuthorizationStatusAuthorized) { // 用户允许当前应用访问相册
107+
NSLog(@"用户允许当前应用访问相册");
108+
UIImageWriteToSavedPhotosAlbum(self.imgView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
109+
} else if (status == PHAuthorizationStatusDenied) { // 用户拒绝当前应用访问相册
110+
dispatch_async(dispatch_get_main_queue(), ^{
111+
UIAlertView * alart = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请您设置允许APP访问您的照片\n设置>隐私>照片" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
112+
[alart show];
113+
});
114+
115+
} else if (status == PHAuthorizationStatusRestricted) {
116+
dispatch_async(dispatch_get_main_queue(), ^{
117+
UIAlertView * alart = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"由于系统限制, 无法访问相册" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
118+
[alart show];
119+
});
120+
}
97121
}
98122

99123

@@ -163,8 +187,6 @@ - (void)clickPinchView:(UIPinchGestureRecognizer *)gest{
163187
}
164188
}
165189
}];
166-
167-
168190
}else{
169191
if (_contentScrollView.contentSize.width != view.width) {
170192
if (view.height>screenH) {

ios/RCTAuroraIMUI/DWCustomView/DWOrigScorllView.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ - (void)addContentView{
194194
- (void)clickTapGest{
195195
NSMutableDictionary *tmpDict = self.imgArr[showIndex];
196196
NSString *strRect = [tmpDict objectForKey:@"rect"];
197-
if (strRect.length) {
197+
NSNumber *isEditNum = [tmpDict objectForKey:@"isEdit"];
198+
if ((strRect.length)&& (!isEditNum.boolValue)) {
198199
CGRect rect = CGRectFromString(strRect);
199200
CGFloat scale = rect.size.width/screenW;
200201
CGFloat tmpY = rect.origin.y - (screenH * scale - rect.size.height)*0.5;

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIBaseMessageCell.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
223223
}
224224

225225
func tapBubbleView() {
226+
UIApplication.shared.keyWindow?.endEditing(true)
226227
if self.message?.type == .text {
227-
self.delegate?.messageCollectionView?(tapCellView: "")
228+
// self.delegate?.messageCollectionView?(tapCellView: "")
228229
}else if self.message?.type == .image {
229230
let strMsgID = (self.message?.msgId)! as NSString
230231
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShowOrigImageNotification"), object: strMsgID)
231-
232232
// self.delegate?.messageCollectionView?(didTapImageMessageBubbleInCell:rect, model: self.message! )
233233
self.delegate?.messageCollectionView?(didTapMessageBubbleInCell: self, model: self.message!)
234234

@@ -238,7 +238,8 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
238238
}
239239

240240
func tapCellView(){//点击整个cell,隐藏键盘
241-
self.delegate?.messageCollectionView?(tapCellView: "")
241+
// self.delegate?.messageCollectionView?(tapCellView: "")
242+
UIApplication.shared.keyWindow?.endEditing(true)
242243
}
243244

244245

ios/RCTAuroraIMUI/RCTMessageListView.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ - (void)clickShowOrigImgView:(NSNotification *)noti{
373373
NSInteger count = [[UIApplication sharedApplication] keyWindow].subviews.count;
374374
topView = [[UIApplication sharedApplication] keyWindow].subviews[count - 2];
375375
}
376+
BOOL isEdit = (self.height >= screenH*0.7) ? NO : YES;
376377
NSMutableArray *rectArr = [NSMutableArray array];
377378
for (UIView *tmpView in self.messageList.messageCollectionView.subviews) {
378379
if ([tmpView isKindOfClass:[IMUIBaseMessageCell class]] ) {
@@ -401,10 +402,11 @@ - (void)clickShowOrigImgView:(NSNotification *)noti{
401402
for (NSMutableDictionary *tmpDict in rectArr) {
402403
if ([msgID isEqualToString:[tmpDict objectForKey:@"msgId"]]) {
403404
[imgDict setObject:[tmpDict objectForKey:@"rect"] forKey:@"rect"];
405+
NSNumber *number = [NSNumber numberWithBool:isEdit];
406+
[imgDict setObject:number forKey:@"isEdit"];
404407
break;
405408
}
406409
}
407-
408410
}
409411
if (imgIndex > 0) {
410412
UIWindow *win = [UIApplication sharedApplication].keyWindow;

0 commit comments

Comments
 (0)