Skip to content

Commit 617eb49

Browse files
committed
Merge pull request #43 from HackForEquality/Issue40
Resolve #40
2 parents ac06a6c + 17f454a commit 617eb49

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

mobile/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
applicationId "ie.yesequality.yesequality"
99
minSdkVersion 15
1010
targetSdkVersion 22
11-
versionCode 1
11+
versionCode 2
1212
versionName "1.0.0"
1313
}
1414

mobile/src/main/AndroidManifest.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest
3-
package="ie.yesequality.yesequality"
4-
xmlns:android="http://schemas.android.com/apk/res/android">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="ie.yesequality.yesequality">
54

6-
<uses-feature android:name="android.hardware.camera"/>
7-
<uses-feature android:name="android.hardware.camera.front"/>
5+
<uses-feature
6+
android:name="android.hardware.camera"
7+
android:required="false" />
8+
<uses-feature
9+
android:name="android.hardware.camera.front"
10+
android:required="false" />
11+
<uses-feature
12+
android:name="android.hardware.camera.autofocus"
13+
android:required="false" />
814

9-
<uses-permission android:name="android.permission.CAMERA"/>
15+
<uses-permission android:name="android.permission.CAMERA" />
1016

1117
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
1218
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

mobile/src/main/java/ie/yesequality/yesequality/CameraFragment.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public class CameraFragment extends Fragment implements TextureView.SurfaceTextu
4141
private int mCameraId;
4242

4343

44-
4544
/**
4645
* Determine the current display orientation and rotate the mCamera preview
4746
* accordingly.
@@ -133,13 +132,14 @@ public void onResume() {
133132
*/
134133
public void takePicture() {
135134
orientationListener.rememberOrientation();
136-
137-
mCamera.takePicture(null, null, this);
135+
if (mCamera != null) {
136+
mCamera.takePicture(null, null, this);
137+
} else {
138+
Toast.makeText(getActivity(), "Unable to take a picture because the camera is not connected. :(", Toast.LENGTH_LONG).show();
139+
}
138140
}
139141

140142

141-
142-
143143
private Bitmap overlay(Bitmap bmp1, Bitmap bmp2, float left, float top, int parentWidth, int
144144
parentHeight) {
145145
//Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1
@@ -175,10 +175,10 @@ private Bitmap bitmapScaler(Bitmap bitmap, int newWidth, int newHeight) {
175175

176176
Canvas canvas = new Canvas(scaledBitmap);
177177
canvas.setMatrix(scaleMatrix);
178-
Paint paint =new Paint(Paint.FILTER_BITMAP_FLAG);
178+
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
179179
paint.setAntiAlias(true);
180180
canvas.drawBitmap(bitmap, middleX - bitmap.getWidth() / 2, middleY - bitmap.getHeight() /
181-
2,paint );
181+
2, paint);
182182

183183
return scaledBitmap;
184184
}
@@ -306,19 +306,21 @@ public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int hei
306306

307307
@Override
308308
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
309-
// Ignored, Camera does all the work for us
309+
// Ignored, Camera does all the work for us
310310
}
311311

312312
@Override
313313
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
314-
mCamera.stopPreview();
315-
mCamera.release();
314+
if (mCamera != null) {
315+
mCamera.stopPreview();
316+
mCamera.release();
317+
}
316318
return true;
317319
}
318320

319321
@Override
320322
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
321-
// Invoked every time there's a new Camera preview frame
323+
// Invoked every time there's a new Camera preview frame
322324
}
323325

324326

0 commit comments

Comments
 (0)