diff --git a/package.json b/package.json index f748a1f..95b22fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-mediapicker-dmcsdk", - "version": "2.3.7", + "version": "2.3.8", "description": "android ios mediaPicker support selection of multiple image and video", "cordova": { "id": "cordova-plugin-mediapicker-dmcsdk", diff --git a/plugin.xml b/plugin.xml index 8ef3ba5..f5099ad 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ - + MediaPicker @@ -50,7 +50,9 @@ - + + + $IOS_PHOTO_LIBRARY_USAGE_DESCRIPTION diff --git a/src/ios/DMCMediaPicker/.DS_Store b/src/ios/DMCMediaPicker/.DS_Store new file mode 100644 index 0000000..3bf546f Binary files /dev/null and b/src/ios/DMCMediaPicker/.DS_Store differ diff --git a/src/ios/DMCMediaPicker/CollectionViewCell.m b/src/ios/DMCMediaPicker/CollectionViewCell.m index b1958d2..6cc508e 100644 --- a/src/ios/DMCMediaPicker/CollectionViewCell.m +++ b/src/ios/DMCMediaPicker/CollectionViewCell.m @@ -28,21 +28,20 @@ self.labelR = [[UILabel alloc]initWithFrame:CGRectMake(width/2, width-labelH, width/2, labelH)]; self.labelR.textColor=[UIColor whiteColor]; self.labelR.font=[UIFont systemFontOfSize:13.0]; - self.labelR.textAlignment=NSTextAlignmentRight; + //self.labelR.textAlignment=NSTextAlignmentRight; self.labelR.backgroundColor= [[UIColor blackColor] colorWithAlphaComponent:0.3f]; - + self.labeGIF = [[UILabel alloc] initWithFrame:CGRectMake(width-width/5-5, width-labelH-2, width/5, labelH-5)]; self.labeGIF.backgroundColor = [UIColor clearColor]; self.labeGIF.textColor=[UIColor whiteColor]; - self.labeGIF.text=@"\tGIF\t"; - self.labeGIF.layer.cornerRadius =4; - self.labeGIF.layer.masksToBounds =YES; - self.labeGIF.textAlignment= NSTextAlignmentCenter; - self.labeGIF.baselineAdjustment= UIBaselineAdjustmentAlignCenters; + + NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:@" GIF " attributes:@{ NSParagraphStyleAttributeName : [[NSParagraphStyle defaultParagraphStyle] mutableCopy]}]; + self.labeGIF.attributedText = attrText; + self.labeGIF.layer.cornerRadius = 4; + self.labeGIF.layer.masksToBounds = YES; self.labeGIF.font=[UIFont systemFontOfSize:13.0]; self.labeGIF.adjustsFontSizeToFitWidth = YES; - //self.labeGIF.textAlignment=NSTextAlignmentRight; self.labeGIF.backgroundColor= [[UIColor blackColor] colorWithAlphaComponent:0.4f]; diff --git a/src/ios/DMCMediaPicker/DmcPickerViewController.m b/src/ios/DMCMediaPicker/DmcPickerViewController.m index 80fd8e6..b754b51 100644 --- a/src/ios/DMCMediaPicker/DmcPickerViewController.m +++ b/src/ios/DMCMediaPicker/DmcPickerViewController.m @@ -326,12 +326,12 @@ CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identify forIndexPath:indexPath]; [cell sizeToFit]; PHAsset *asset=fetchResult[indexPath.item]; - [_manager requestImageForAsset:asset - targetSize:CGSizeMake(200 , 200) - contentMode:PHImageContentModeAspectFill - options:nil + [_manager requestImageForAsset:asset targetSize:CGSizeMake(200 , 200) contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { - cell.imgView.image = result; + BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey] && ![[info objectForKey:PHImageResultIsDegradedKey] boolValue]); + if (downloadFinined && result) { + cell.imgView.image = result; + } }]; NSInteger i=[self isSelect:asset]; if(asset.mediaType==PHAssetMediaTypeVideo){ @@ -340,8 +340,14 @@ cell.labeGIF.hidden=YES; NSString *dtime=[NSString stringWithFormat:@"%.0f",asset.duration]; - cell.labelL.text=[@"\t"stringByAppendingString:NSLocalizedString(@"Video",nil)]; - cell.labelR.text=[[self getNewTimeFromDurationSecond:dtime.integerValue]stringByAppendingString:@"\t"]; + cell.labelL.text = [@" "stringByAppendingString:NSLocalizedString(@"Video",nil)]; + //Uilable默认会去除尾部空格所以处理一下 + NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + style.tailIndent = -3.0f; + style.alignment=NSTextAlignmentRight; + NSString *dtimeStr=[self getNewTimeFromDurationSecond:dtime.integerValue]; + NSAttributedString *attrTextR = [[NSAttributedString alloc] initWithString:dtimeStr attributes:@{ NSParagraphStyleAttributeName : style}]; + cell.labelR.attributedText=attrTextR; }else{ NSString *fileName =[asset valueForKey:@"filename"]; NSString * fileExtension = [fileName pathExtension]; diff --git a/src/ios/DMCMediaPicker/PreviewViewController.m b/src/ios/DMCMediaPicker/PreviewViewController.m index 1adcdfe..90aa94b 100644 --- a/src/ios/DMCMediaPicker/PreviewViewController.m +++ b/src/ios/DMCMediaPicker/PreviewViewController.m @@ -148,12 +148,18 @@ if([@"GIF" caseInsensitiveCompare:fileExtension]){ cell.gifView.hidden=YES; [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(SCREEN_WIDTH*3 , SCREENH_HEIGHT*3) contentMode:PHImageContentModeAspectFill options:option resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { - [cell setImg:result]; + BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey] && ![[info objectForKey:PHImageResultIsDegradedKey] boolValue]); + if (downloadFinined && result) { + [cell setImg:result]; + } }]; }else{ cell.imgView.hidden=YES; [[PHImageManager defaultManager] requestImageDataForAsset:asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) { - [cell setGifImg:imageData]; + BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey] && ![[info objectForKey:PHImageResultIsDegradedKey] boolValue]); + if (downloadFinined && imageData) { + [cell setGifImg:imageData]; + } }]; } diff --git a/src/ios/DMCMediaPicker/es.lproj/Localizable.strings b/src/ios/DMCMediaPicker/es.lproj/Localizable.strings new file mode 100644 index 0000000..ccdba9c --- /dev/null +++ b/src/ios/DMCMediaPicker/es.lproj/Localizable.strings @@ -0,0 +1,10 @@ +"Cancel"="Cancelar"; +"Done"="hecho"; +"All"="Todas las fotos"; +"Video"="Video"; +"maxSelectAlert"="Has alcanzado el número maximo de selecciones"; +"ok"="OK"; +"Unable to access album" = "Denegado el acceso al album"; +"Please allow to access your album" = "Por favor permita el acceso a sus albums en \"Configuraciones -> Privacidad -> Album\""; +"Setting" = "Configuraciones"; +"Preview" = "Vista previa"; diff --git a/src/ios/DMCMediaPicker/pt-BR.lproj/Localizable.strings b/src/ios/DMCMediaPicker/pt-BR.lproj/Localizable.strings new file mode 100644 index 0000000..aecf87a --- /dev/null +++ b/src/ios/DMCMediaPicker/pt-BR.lproj/Localizable.strings @@ -0,0 +1,10 @@ +"Cancel"="Cancelar"; +"Done"="Pronto"; +"All"="Todas as fotos"; +"Video"="Vídeo"; +"maxSelectAlert”=“Atingiu o limite máximo de escolhas"; +"ok"="OK"; +"Unable to access album" = "Impossibilitado de acessar o álbum"; +"Please allow to access your album" = "Por favor permita acessar o seu álbum em \“Configurações -> Privacidade -> Álbum\""; +"Setting" = "Configuração"; +"Preview" = "Prévia"; diff --git a/src/ios/DMCMediaPicker/pt-PT.lproj/Localizable.strings b/src/ios/DMCMediaPicker/pt-PT.lproj/Localizable.strings new file mode 100644 index 0000000..aecf87a --- /dev/null +++ b/src/ios/DMCMediaPicker/pt-PT.lproj/Localizable.strings @@ -0,0 +1,10 @@ +"Cancel"="Cancelar"; +"Done"="Pronto"; +"All"="Todas as fotos"; +"Video"="Vídeo"; +"maxSelectAlert”=“Atingiu o limite máximo de escolhas"; +"ok"="OK"; +"Unable to access album" = "Impossibilitado de acessar o álbum"; +"Please allow to access your album" = "Por favor permita acessar o seu álbum em \“Configurações -> Privacidade -> Álbum\""; +"Setting" = "Configuração"; +"Preview" = "Prévia";