Skip to content

Commit

Permalink
Add release application
Browse files Browse the repository at this point in the history
  • Loading branch information
monolidth committed Oct 25, 2020
1 parent f69dab9 commit b37db71
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 56 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Android ###
# Built application files
*.apk
#*.apk
*.aar
*.ap_
*.aab
Expand Down Expand Up @@ -278,8 +278,6 @@ modules.xml
# NDK
obj/

# IntelliJ IDEA
/out/

# User-specific configurations
.idea/caches/
Expand Down
105 changes: 52 additions & 53 deletions lib/ui/camera_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,39 +64,6 @@ class TakePictureScreenState extends State<TakePictureScreen> {
super.dispose();
}

Future<File> fixExifRotation(String imagePath) async {
final originalFile = File(imagePath);
List<int> imageBytes = await originalFile.readAsBytes();

final originalImage = img.decodeImage(imageBytes);
final height = originalImage.height;
final width = originalImage.width;

if (height >= width) {
return originalFile;
}

final exifData = await readExifFromBytes(imageBytes);
img.Image fixedImage;

if (height < width) {
if (exifData['Image Orientation'].printable.contains('Horizontal')) {
fixedImage = img.copyRotate(originalImage, 90);
} else if (exifData['Image Orientation'].printable.contains('180')) {
fixedImage = img.copyRotate(originalImage, -90);
} else if (exifData['Image Orientation'].printable.contains('CCW')) {
fixedImage = img.copyRotate(originalImage, 180);
} else {
fixedImage = img.copyRotate(originalImage, 0);
}
}

final fixedFile =
await originalFile.writeAsBytes(img.encodeJpg(fixedImage));

return fixedFile;
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -128,8 +95,6 @@ class TakePictureScreenState extends State<TakePictureScreen> {
// Take an picture with the best resolution
await _controller.takePicture(path);
// await FlutterExifRotation.rotateAndSaveImage(path: path);
await fixExifRotation(path);

Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -155,6 +120,7 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
final GlobalKey<ScaffoldState> key2 = GlobalKey<ScaffoldState>();
Color _acceptButtonColor = Colors.green;
Color _declineButtonColor = Colors.red;
double _progress = 0.0;
ProgressDialog pr;

bool _isButtonDisabled;
Expand All @@ -167,25 +133,59 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
_isButtonDisabled = false;
}

Future<File> fixExifRotation(String imagePath) async {
final originalFile = File(imagePath);
List<int> imageBytes = await originalFile.readAsBytes();

final originalImage = img.decodeImage(imageBytes);
final height = originalImage.height;
final width = originalImage.width;

if (height >= width) {
return originalFile;
}

final exifData = await readExifFromBytes(imageBytes);
img.Image fixedImage;

if (height < width) {
if (exifData['Image Orientation'].printable.contains('Horizontal')) {
fixedImage = img.copyRotate(originalImage, 90);
} else if (exifData['Image Orientation'].printable.contains('180')) {
fixedImage = img.copyRotate(originalImage, -90);
} else if (exifData['Image Orientation'].printable.contains('CCW')) {
fixedImage = img.copyRotate(originalImage, 180);
} else {
fixedImage = img.copyRotate(originalImage, 0);
}
}

final fixedFile =
await originalFile.writeAsBytes(img.encodeJpg(fixedImage));

return fixedFile;
}

@override
Widget build(BuildContext context) {
pr = ProgressDialog(
context,
type: ProgressDialogType.Normal,
textDirection: TextDirection.ltr,
isDismissible: false,
);
pr = ProgressDialog(context,
type: ProgressDialogType.Download,
isDismissible: false,
showLogs: true);

pr.style(
message:
'Parsing image using tesseract. This takes some time.',
borderRadius: 10.0,
backgroundColor: Colors.white,
elevation: 10.0,
insetAnimCurve: Curves.easeInCirc,
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600),
);
message: 'Downloading file...',
borderRadius: 10.0,
backgroundColor: Colors.white,
progressWidget: CircularProgressIndicator(),
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600));

return Scaffold(
appBar: AppBar(title: Text('Display the Picture')),
Expand Down Expand Up @@ -231,11 +231,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen> {
await SharedPreferences.getInstance();
String ip = sharedPrefs.get("ipv4");

pr.show();
await fixExifRotation(imagePath);
await NetworkClient.sendImage(
File(imagePath), ip, context, key2);

pr.hide();
_progress = _progress + 80.0;
})))),
],
)
Expand Down
Binary file added release_apk/receipt-manager.apk
Binary file not shown.

0 comments on commit b37db71

Please sign in to comment.