Skip to content

Commit

Permalink
[android] Fix invalid casting of quality option in Camera (#2692)
Browse files Browse the repository at this point in the history
* Fixed wrong type casting

* Add CHANGELOG entry
  • Loading branch information
Szymon20000 authored and sjchmiela committed Nov 16, 2018
1 parent a20de51 commit a5cb40a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This is the log of notable changes to the Expo client that are developer-facing.
- decycle objects when sending logs to remote console by [@sjchmiela](https://github.com/sjchmiela) ([#2598](https://github.com/expo/expo/pull/2598))
- unify linear gradient behavior across platforms by [@sjchmiela](https://github.com/sjchmiela) ([#2624](https://github.com/expo/expo/pull/2624))
- use device orientation for recorded videos by [@flippinjoe](https://github.com/flippinjoe) ([expo-camera#2](https://github.com/expo/expo-camera/pull/2))
- handle `quality` option passed to `Camera.takePictureAsync` on Android properly by [@Szymon20000](https://github.com/Szymon20000) ([#2683](https://github.com/expo/expo/pull/2683))

## 31.0.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Bundle>
private static final String URI_KEY = "uri";
private static final String ID_KEY = "id";

private static final int DEFAULT_QUALITY = 1;

private Promise mPromise;
private byte[] mImageData;
private Bitmap mBitmap;
Expand All @@ -66,7 +68,12 @@ public ResolveTakenPictureAsyncTask(Bitmap bitmap, Promise promise, Map<String,
}

private int getQuality() {
return ((Number) mOptions.get(QUALITY_KEY)).intValue() * 100;
if (mOptions.get(QUALITY_KEY) instanceof Number) {
double requestedQuality = ((Number) mOptions.get(QUALITY_KEY)).doubleValue();
return (int)(requestedQuality * 100);
}

return DEFAULT_QUALITY * 100;
}

@Override
Expand Down

0 comments on commit a5cb40a

Please sign in to comment.