Skip to content

Commit

Permalink
TW-1844: fix distorted images when using camera in android phone
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Aug 29, 2024
1 parent ff02b03 commit 81ea931
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 55 deletions.
52 changes: 0 additions & 52 deletions lib/domain/usecase/send_images_interactor.dart

This file was deleted.

7 changes: 5 additions & 2 deletions lib/presentation/extensions/send_file_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ extension SendFileExtension on Room {
txid,
uploadStreamController: uploadStreamController,
);
if (fileInfo.width == null || fileInfo.height == null) {
if (fileInfo.width == null ||
fileInfo.height == null ||
fileInfo.width == 0 ||
fileInfo.height == 0) {
fileInfo = VideoFileInfo(
fileInfo.fileName,
fileInfo.filePath,
Expand Down Expand Up @@ -619,7 +622,7 @@ extension SendFileExtension on Room {
final size = await result.length();
var width = originalFile.width;
var height = originalFile.height;
if (width == null || height == null) {
if (width == null || height == null || width == 0 || height == 0) {
final imageDimension = await runBenchmarked(
'_calculateImageDimension',
() => _calculateImageDimension(result.path),
Expand Down
11 changes: 10 additions & 1 deletion lib/presentation/mixins/media_picker_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,21 @@ mixin MediaPickerMixin on CommonMediaPickerMixin {
OnCameraPicked? onCameraPicked,
bool onlyImage = false,
}) async {
final assetEntity =
var assetEntity =
await pickMediaFromCameraAction(context: context, onlyImage: onlyImage);
Logs().d(
"MediaPickerMixin::_pickFromCameraAction(): assetEntity - $assetEntity",
);
if (assetEntity != null) {
// TODO: TW-1844: Remove this when the issue https://github.com/fluttercandies/flutter_wechat_camera_picker/issues/266
if (PlatformInfos.isAndroid) {
assetEntity = AssetEntity(
id: assetEntity.id,
width: 0,
height: 0,
typeInt: assetEntity.typeInt,
);
}
imagePickerGridController.pickAssetFromCamera(assetEntity);

if (onCameraPicked != null) {
Expand Down

0 comments on commit 81ea931

Please sign in to comment.