diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e833ae41..540611ae 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,7 +17,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
@@ -38,15 +38,15 @@
{
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
- MediaSavedListener listener = mActivity.get();
+ final MediaSavedListener listener = mActivity.get();
if (listener != null) {
listener.mediaSaved();
}
diff --git a/app/src/main/java/com/simplemobiletools/camera/Preview.java b/app/src/main/java/com/simplemobiletools/camera/Preview.java
index a7e0d3e4..f40740a5 100644
--- a/app/src/main/java/com/simplemobiletools/camera/Preview.java
+++ b/app/src/main/java/com/simplemobiletools/camera/Preview.java
@@ -19,6 +19,8 @@ import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
+import com.simplemobiletools.camera.activities.MainActivity;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -31,133 +33,134 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
private static final int PHOTO_PREVIEW_LENGTH = 1000;
private static final float RATIO_TOLERANCE = 0.1f;
- private static SurfaceHolder surfaceHolder;
- private static Camera camera;
- private static List supportedPreviewSizes;
- private static SurfaceView surfaceView;
- private static Camera.Size previewSize;
- private static boolean canTakePicture;
- private static MainActivity activity;
- private static int currCameraId;
- private static boolean isFlashEnabled;
- private static Camera.Parameters parameters;
- private static PreviewListener callback;
- private static MediaRecorder recorder;
- private static boolean isRecording;
- private static boolean isVideoMode;
- private static boolean isSurfaceCreated;
- private static boolean switchToVideoAsap;
- private static boolean isVideoCaptureIntent;
- private static boolean focusBeforeCapture;
- private boolean setupPreviewAfterMeasure;
- private static String curVideoPath;
- private static int lastClickX;
- private static int lastClickY;
- private static int initVideoRotation;
- private static Point screenSize;
- private static Uri targetUri;
+ private static SurfaceHolder mSurfaceHolder;
+ private static Camera mCamera;
+ private static List mSupportedPreviewSizes;
+ private static SurfaceView mSurfaceView;
+ private static Camera.Size mPreviewSize;
+ private static MainActivity mActivity;
+ private static Camera.Parameters mParameters;
+ private static PreviewListener mCallback;
+ private static MediaRecorder mRecorder;
+ private static String mCurVideoPath;
+ private static Point mScreenSize;
+ private static Uri mTargetUri;
+
+ private static boolean mCanTakePicture;
+ private static boolean mIsFlashEnabled;
+ private static boolean mIsRecording;
+ private static boolean mIsVideoMode;
+ private static boolean mIsSurfaceCreated;
+ private static boolean mSwitchToVideoAsap;
+ private static boolean mIsVideoCaptureIntent;
+ private static boolean mFocusBeforeCapture;
+ private static boolean mSetupPreviewAfterMeasure;
+ private static int mLastClickX;
+ private static int mLastClickY;
+ private static int mInitVideoRotation;
+ private static int mCurrCameraId;
public Preview(Context context) {
super(context);
}
- public Preview(MainActivity act, SurfaceView sv, PreviewListener cb) {
- super(act);
+ public Preview(MainActivity activity, SurfaceView surfaceView, PreviewListener previewListener) {
+ super(activity);
- activity = act;
- callback = cb;
- surfaceView = sv;
- surfaceHolder = surfaceView.getHolder();
- surfaceHolder.addCallback(this);
- surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- canTakePicture = false;
- surfaceView.setOnTouchListener(this);
- surfaceView.setOnClickListener(this);
- isFlashEnabled = false;
- isVideoMode = false;
- isSurfaceCreated = false;
- setupPreviewAfterMeasure = false;
- curVideoPath = "";
- screenSize = Utils.getScreenSize(activity);
+ mActivity = activity;
+ mCallback = previewListener;
+ mSurfaceView = surfaceView;
+ mSurfaceHolder = mSurfaceView.getHolder();
+ mSurfaceHolder.addCallback(this);
+ mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+ mCanTakePicture = false;
+ mSurfaceView.setOnTouchListener(this);
+ mSurfaceView.setOnClickListener(this);
+ mIsFlashEnabled = false;
+ mIsVideoMode = false;
+ mIsSurfaceCreated = false;
+ mSetupPreviewAfterMeasure = false;
+ mCurVideoPath = "";
+ mScreenSize = Utils.getScreenSize(mActivity);
}
public void trySwitchToVideo() {
- if (isSurfaceCreated) {
+ if (mIsSurfaceCreated) {
initRecorder();
} else {
- switchToVideoAsap = true;
+ mSwitchToVideoAsap = true;
}
}
public void setIsVideoCaptureIntent() {
- isVideoCaptureIntent = true;
+ mIsVideoCaptureIntent = true;
}
public boolean setCamera(int cameraId) {
- currCameraId = cameraId;
+ mCurrCameraId = cameraId;
Camera newCamera;
try {
newCamera = Camera.open(cameraId);
- callback.setIsCameraAvailable(true);
+ mCallback.setIsCameraAvailable(true);
} catch (Exception e) {
Utils.showToast(getContext(), R.string.camera_open_error);
Log.e(TAG, "setCamera open " + e.getMessage());
- callback.setIsCameraAvailable(false);
+ mCallback.setIsCameraAvailable(false);
return false;
}
- if (camera == newCamera) {
+ if (mCamera == newCamera) {
return false;
}
releaseCamera();
- camera = newCamera;
- if (camera != null) {
- parameters = camera.getParameters();
- supportedPreviewSizes = parameters.getSupportedPreviewSizes();
+ mCamera = newCamera;
+ if (mCamera != null) {
+ mParameters = mCamera.getParameters();
+ mSupportedPreviewSizes = mParameters.getSupportedPreviewSizes();
requestLayout();
invalidate();
- setupPreviewAfterMeasure = true;
+ mSetupPreviewAfterMeasure = true;
- final List focusModes = parameters.getSupportedFocusModes();
+ final List focusModes = mParameters.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
- parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
+ mParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
final int rotation = getPreviewRotation(cameraId);
- camera.setDisplayOrientation(rotation);
- camera.setParameters(parameters);
+ mCamera.setDisplayOrientation(rotation);
+ mCamera.setParameters(mParameters);
- if (canTakePicture) {
+ if (mCanTakePicture) {
try {
- camera.setPreviewDisplay(surfaceHolder);
+ mCamera.setPreviewDisplay(mSurfaceHolder);
} catch (IOException e) {
Log.e(TAG, "setCamera setPreviewDisplay " + e.getMessage());
return false;
}
}
- callback.setFlashAvailable(Utils.hasFlash(camera));
+ mCallback.setFlashAvailable(Utils.hasFlash(mCamera));
}
- if (isVideoMode) {
+ if (mIsVideoMode) {
initRecorder();
}
final boolean isLongTapEnabled = Config.newInstance(getContext()).getLongTapEnabled();
- surfaceView.setOnLongClickListener(isLongTapEnabled ? this : null);
+ mSurfaceView.setOnLongClickListener(isLongTapEnabled ? this : null);
- focusBeforeCapture = Config.newInstance(getContext()).getFocusBeforeCaptureEnabled();
+ mFocusBeforeCapture = Config.newInstance(getContext()).getFocusBeforeCaptureEnabled();
return true;
}
public void setTargetUri(Uri uri) {
- targetUri = uri;
+ mTargetUri = uri;
}
private static int getPreviewRotation(int cameraId) {
final Camera.CameraInfo info = Utils.getCameraInfo(cameraId);
- int degrees = getRotationDegrees();
+ final int degrees = getRotationDegrees();
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
@@ -171,7 +174,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private static int getMediaRotation(int cameraId) {
- int degrees = getRotationDegrees();
+ final int degrees = getRotationDegrees();
final Camera.CameraInfo info = Utils.getCameraInfo(cameraId);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
return (360 + info.orientation + degrees) % 360;
@@ -181,7 +184,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private static int getRotationDegrees() {
- int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
+ int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
switch (rotation) {
case Surface.ROTATION_0:
return 0;
@@ -197,7 +200,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
public void tryTakePicture() {
- if (focusBeforeCapture) {
+ if (mFocusBeforeCapture) {
focusArea(true);
} else {
takePicture();
@@ -205,28 +208,28 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private void takePicture() {
- if (canTakePicture) {
- if (isFlashEnabled) {
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
+ if (mCanTakePicture) {
+ if (mIsFlashEnabled) {
+ mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
} else {
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
+ mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
}
- int rotation = getMediaRotation(currCameraId);
+ int rotation = getMediaRotation(mCurrCameraId);
rotation += compensateDeviceRotation();
final Camera.Size maxSize = getOptimalPictureSize();
- parameters.setPictureSize(maxSize.width, maxSize.height);
- parameters.setRotation(rotation % 360);
+ mParameters.setPictureSize(maxSize.width, maxSize.height);
+ mParameters.setRotation(rotation % 360);
MediaPlayer.create(getContext(), R.raw.camera_shutter).start();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
- camera.enableShutterSound(false);
+ mCamera.enableShutterSound(false);
}
- camera.setParameters(parameters);
- camera.takePicture(null, null, takePictureCallback);
+ mCamera.setParameters(mParameters);
+ mCamera.takePicture(null, null, takePictureCallback);
}
- canTakePicture = false;
+ mCanTakePicture = false;
}
private Camera.PictureCallback takePictureCallback = new Camera.PictureCallback() {
@@ -235,24 +238,24 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
- if (camera != null) {
- camera.startPreview();
+ if (mCamera != null) {
+ mCamera.startPreview();
}
- canTakePicture = true;
+ mCanTakePicture = true;
}
}, PHOTO_PREVIEW_LENGTH);
- new PhotoProcessor(activity, targetUri).execute(data);
- if (isFlashEnabled) {
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
- camera.setParameters(parameters);
+ new PhotoProcessor(mActivity, mTargetUri).execute(data);
+ if (mIsFlashEnabled) {
+ mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
+ mCamera.setParameters(mParameters);
}
}
};
private Camera.Size getOptimalPictureSize() {
- final List sizes = parameters.getSupportedPictureSizes();
+ final List sizes = mParameters.getSupportedPictureSizes();
Camera.Size maxSize = sizes.get(0);
for (Camera.Size size : sizes) {
final boolean isEightMegapixelsMax = isEightMegapixelsMax(size);
@@ -277,7 +280,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private Camera.Size getOptimalVideoSize() {
- final List sizes = parameters.getSupportedVideoSizes();
+ final List sizes = mParameters.getSupportedVideoSizes();
Camera.Size maxSize = sizes.get(0);
for (Camera.Size size : sizes) {
final boolean isSixteenToNine = isSixteenToNine(size);
@@ -291,8 +294,8 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
private int compensateDeviceRotation() {
int degrees = 0;
- boolean isFrontCamera = (currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT);
- int deviceOrientation = callback.getCurrentOrientation();
+ boolean isFrontCamera = (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT);
+ int deviceOrientation = mCallback.getCurrentOrientation();
if (deviceOrientation == Constants.ORIENT_LANDSCAPE_LEFT) {
degrees += isFrontCamera ? 90 : 270;
} else if (deviceOrientation == Constants.ORIENT_LANDSCAPE_RIGHT) {
@@ -302,33 +305,33 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private int getFinalRotation() {
- int rotation = getMediaRotation(currCameraId);
+ int rotation = getMediaRotation(mCurrCameraId);
rotation += compensateDeviceRotation();
return rotation % 360;
}
private void focusArea(final boolean takePictureAfter) {
- if (camera == null)
+ if (mCamera == null)
return;
- camera.cancelAutoFocus();
- final Rect focusRect = calculateFocusArea(lastClickX, lastClickY);
- if (parameters.getMaxNumFocusAreas() > 0) {
+ mCamera.cancelAutoFocus();
+ final Rect focusRect = calculateFocusArea(mLastClickX, mLastClickY);
+ if (mParameters.getMaxNumFocusAreas() > 0) {
final List focusAreas = new ArrayList<>(1);
focusAreas.add(new Camera.Area(focusRect, 1000));
- parameters.setFocusAreas(focusAreas);
+ mParameters.setFocusAreas(focusAreas);
}
- camera.setParameters(parameters);
- camera.autoFocus(new Camera.AutoFocusCallback() {
+ mCamera.setParameters(mParameters);
+ mCamera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
camera.cancelAutoFocus();
- final List focusModes = parameters.getSupportedFocusModes();
+ final List focusModes = mParameters.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
- parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
+ mParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
- camera.setParameters(parameters);
+ camera.setParameters(mParameters);
if (takePictureAfter) {
takePicture();
}
@@ -337,8 +340,8 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private Rect calculateFocusArea(float x, float y) {
- int left = Float.valueOf((x / surfaceView.getWidth()) * 2000 - 1000).intValue();
- int top = Float.valueOf((y / surfaceView.getHeight()) * 2000 - 1000).intValue();
+ int left = Float.valueOf((x / mSurfaceView.getWidth()) * 2000 - 1000).intValue();
+ int top = Float.valueOf((y / mSurfaceView.getHeight()) * 2000 - 1000).intValue();
int tmp = left;
left = top;
@@ -354,10 +357,10 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
public void releaseCamera() {
stopRecording();
- if (camera != null) {
- camera.stopPreview();
- camera.release();
- camera = null;
+ if (mCamera != null) {
+ mCamera.stopPreview();
+ mCamera.release();
+ mCamera = null;
}
cleanupRecorder();
@@ -365,13 +368,13 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
@Override
public void surfaceCreated(SurfaceHolder holder) {
- isSurfaceCreated = true;
+ mIsSurfaceCreated = true;
try {
- if (camera != null) {
- camera.setPreviewDisplay(surfaceHolder);
+ if (mCamera != null) {
+ mCamera.setPreviewDisplay(mSurfaceHolder);
}
- if (switchToVideoAsap)
+ if (mSwitchToVideoAsap)
initRecorder();
} catch (IOException e) {
Log.e(TAG, "surfaceCreated IOException " + e.getMessage());
@@ -380,40 +383,40 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- isSurfaceCreated = true;
+ mIsSurfaceCreated = true;
- if (isVideoMode) {
+ if (mIsVideoMode) {
initRecorder();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
- isSurfaceCreated = false;
- if (camera != null) {
- camera.stopPreview();
+ mIsSurfaceCreated = false;
+ if (mCamera != null) {
+ mCamera.stopPreview();
}
cleanupRecorder();
}
private void setupPreview() {
- canTakePicture = true;
- if (camera != null && previewSize != null) {
- parameters.setPreviewSize(previewSize.width, previewSize.height);
- camera.setParameters(parameters);
- camera.startPreview();
+ mCanTakePicture = true;
+ if (mCamera != null && mPreviewSize != null) {
+ mParameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
+ mCamera.setParameters(mParameters);
+ mCamera.startPreview();
}
}
private void cleanupRecorder() {
- if (recorder != null) {
- if (isRecording) {
+ if (mRecorder != null) {
+ if (mIsRecording) {
stopRecording();
}
- recorder.release();
- recorder = null;
+ mRecorder.release();
+ mRecorder = null;
}
}
@@ -456,23 +459,23 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- setMeasuredDimension(screenSize.x, screenSize.y);
+ setMeasuredDimension(mScreenSize.x, mScreenSize.y);
- if (supportedPreviewSizes != null) {
- previewSize = getOptimalPreviewSize(supportedPreviewSizes, screenSize.x, screenSize.y);
- final LayoutParams lp = surfaceView.getLayoutParams();
+ if (mSupportedPreviewSizes != null) {
+ mPreviewSize = getOptimalPreviewSize(mSupportedPreviewSizes, mScreenSize.x, mScreenSize.y);
+ final LayoutParams lp = mSurfaceView.getLayoutParams();
- if (screenSize.x > previewSize.height) {
- final float ratio = (float) screenSize.x / previewSize.height;
- lp.width = (int) (previewSize.height * ratio);
- lp.height = (int) (previewSize.width * ratio);
+ if (mScreenSize.x > mPreviewSize.height) {
+ final float ratio = (float) mScreenSize.x / mPreviewSize.height;
+ lp.width = (int) (mPreviewSize.height * ratio);
+ lp.height = (int) (mPreviewSize.width * ratio);
} else {
- lp.width = previewSize.height;
- lp.height = previewSize.width;
+ lp.width = mPreviewSize.height;
+ lp.height = mPreviewSize.width;
}
- if (setupPreviewAfterMeasure) {
- setupPreviewAfterMeasure = false;
+ if (mSetupPreviewAfterMeasure) {
+ mSetupPreviewAfterMeasure = false;
setupPreview();
}
}
@@ -480,55 +483,55 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
@Override
public boolean onTouch(View v, MotionEvent event) {
- lastClickX = (int) event.getX();
- lastClickY = (int) event.getY();
+ mLastClickX = (int) event.getX();
+ mLastClickY = (int) event.getY();
return false;
}
public void enableFlash() {
- if (isVideoMode) {
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
- camera.setParameters(parameters);
+ if (mIsVideoMode) {
+ mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
+ mCamera.setParameters(mParameters);
}
- isFlashEnabled = true;
+ mIsFlashEnabled = true;
}
public void disableFlash() {
- isFlashEnabled = false;
- parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
- camera.setParameters(parameters);
+ mIsFlashEnabled = false;
+ mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
+ mCamera.setParameters(mParameters);
}
public void initPhotoMode() {
- isRecording = false;
- isVideoMode = false;
+ mIsRecording = false;
+ mIsVideoMode = false;
stopRecording();
cleanupRecorder();
}
// VIDEO RECORDING
public boolean initRecorder() {
- if (camera == null || recorder != null || !isSurfaceCreated)
+ if (mCamera == null || mRecorder != null || !mIsSurfaceCreated)
return false;
- switchToVideoAsap = false;
- final Camera.Size preferred = parameters.getPreferredPreviewSizeForVideo();
+ mSwitchToVideoAsap = false;
+ final Camera.Size preferred = mParameters.getPreferredPreviewSizeForVideo();
if (preferred == null)
return false;
- parameters.setPreviewSize(preferred.width, preferred.height);
- camera.setParameters(parameters);
+ mParameters.setPreviewSize(preferred.width, preferred.height);
+ mCamera.setParameters(mParameters);
- isRecording = false;
- isVideoMode = true;
- recorder = new MediaRecorder();
- recorder.setCamera(camera);
- recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
- recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
+ mIsRecording = false;
+ mIsVideoMode = true;
+ mRecorder = new MediaRecorder();
+ mRecorder.setCamera(mCamera);
+ mRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
+ mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
- curVideoPath = Utils.getOutputMediaFile(getContext(), false);
- if (curVideoPath.isEmpty()) {
+ mCurVideoPath = Utils.getOutputMediaFile(getContext(), false);
+ if (mCurVideoPath.isEmpty()) {
Utils.showToast(getContext(), R.string.video_creating_error);
return false;
}
@@ -537,16 +540,16 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
final CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
cpHigh.videoFrameWidth = videoSize.width;
cpHigh.videoFrameHeight = videoSize.height;
- recorder.setProfile(cpHigh);
- recorder.setOutputFile(curVideoPath);
- recorder.setPreviewDisplay(surfaceHolder.getSurface());
+ mRecorder.setProfile(cpHigh);
+ mRecorder.setOutputFile(mCurVideoPath);
+ mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
int rotation = getFinalRotation();
- initVideoRotation = rotation;
- recorder.setOrientationHint(rotation);
+ mInitVideoRotation = rotation;
+ mRecorder.setOrientationHint(rotation);
try {
- recorder.prepare();
+ mRecorder.prepare();
} catch (Exception e) {
Utils.showToast(getContext(), R.string.video_setup_error);
Log.e(TAG, "initRecorder " + e.getMessage());
@@ -557,25 +560,25 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
public boolean toggleRecording() {
- if (isRecording) {
+ if (mIsRecording) {
stopRecording();
initRecorder();
} else {
startRecording();
}
- return isRecording;
+ return mIsRecording;
}
private void startRecording() {
- if (initVideoRotation != getFinalRotation()) {
+ if (mInitVideoRotation != getFinalRotation()) {
cleanupRecorder();
initRecorder();
}
try {
- camera.unlock();
- recorder.start();
- isRecording = true;
+ mCamera.unlock();
+ mRecorder.start();
+ mIsRecording = true;
} catch (Exception e) {
Utils.showToast(getContext(), R.string.video_setup_error);
Log.e(TAG, "toggleRecording " + e.getMessage());
@@ -584,23 +587,23 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
private void stopRecording() {
- if (recorder != null && isRecording) {
+ if (mRecorder != null && mIsRecording) {
try {
- recorder.stop();
- final String[] paths = {curVideoPath};
- MediaScannerConnection.scanFile(getContext(), paths, null, isVideoCaptureIntent ? this : null);
+ mRecorder.stop();
+ final String[] paths = {mCurVideoPath};
+ MediaScannerConnection.scanFile(getContext(), paths, null, mIsVideoCaptureIntent ? this : null);
} catch (RuntimeException e) {
- new File(curVideoPath).delete();
+ new File(mCurVideoPath).delete();
Utils.showToast(getContext(), R.string.video_saving_error);
Log.e(TAG, "stopRecording " + e.getMessage());
releaseCamera();
} finally {
- recorder = null;
- isRecording = false;
+ mRecorder = null;
+ mIsRecording = false;
}
}
- final File file = new File(curVideoPath);
+ final File file = new File(mCurVideoPath);
if (file.exists() && file.length() == 0) {
file.delete();
}
@@ -608,7 +611,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
@Override
public boolean onLongClick(View v) {
- callback.activateShutter();
+ mCallback.activateShutter();
return true;
}
@@ -619,7 +622,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
@Override
public void onScanCompleted(String path, Uri uri) {
- callback.videoSaved(uri);
+ mCallback.videoSaved(uri);
}
public interface PreviewListener {
diff --git a/app/src/main/java/com/simplemobiletools/camera/AboutActivity.java b/app/src/main/java/com/simplemobiletools/camera/activities/AboutActivity.java
similarity index 66%
rename from app/src/main/java/com/simplemobiletools/camera/AboutActivity.java
rename to app/src/main/java/com/simplemobiletools/camera/activities/AboutActivity.java
index 4e6b5041..8250ea86 100644
--- a/app/src/main/java/com/simplemobiletools/camera/AboutActivity.java
+++ b/app/src/main/java/com/simplemobiletools/camera/activities/AboutActivity.java
@@ -1,4 +1,4 @@
-package com.simplemobiletools.camera;
+package com.simplemobiletools.camera.activities;
import android.content.Intent;
import android.content.res.Resources;
@@ -7,10 +7,12 @@ import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
-import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
+import com.simplemobiletools.camera.BuildConfig;
+import com.simplemobiletools.camera.R;
+
import java.util.Calendar;
import butterknife.BindView;
@@ -18,17 +20,18 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
public class AboutActivity extends AppCompatActivity {
- @BindView(R.id.about_copyright) TextView copyright;
- @BindView(R.id.about_version) TextView version;
- @BindView(R.id.about_email) TextView emailTV;
- private Resources res;
+ @BindView(R.id.about_copyright) TextView mCopyright;
+ @BindView(R.id.about_version) TextView mVersion;
+ @BindView(R.id.about_email) TextView mEmailTV;
+
+ private Resources mRes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
- res = getResources();
+ mRes = getResources();
setupEmail();
setupVersion();
@@ -37,8 +40,7 @@ public class AboutActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
+ getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
@@ -55,23 +57,23 @@ public class AboutActivity extends AppCompatActivity {
}
private void setupEmail() {
- final String email = res.getString(R.string.email);
- final String appName = res.getString(R.string.app_name);
+ final String email = mRes.getString(R.string.email);
+ final String appName = mRes.getString(R.string.app_name);
final String href = "" + email + "";
- emailTV.setText(Html.fromHtml(href));
- emailTV.setMovementMethod(LinkMovementMethod.getInstance());
+ mEmailTV.setText(Html.fromHtml(href));
+ mEmailTV.setMovementMethod(LinkMovementMethod.getInstance());
}
private void setupVersion() {
final String versionName = BuildConfig.VERSION_NAME;
- final String versionText = String.format(res.getString(R.string.version), versionName);
- version.setText(versionText);
+ final String versionText = String.format(mRes.getString(R.string.version), versionName);
+ mVersion.setText(versionText);
}
private void setupCopyright() {
final int year = Calendar.getInstance().get(Calendar.YEAR);
- final String copyrightText = String.format(res.getString(R.string.copyright), year);
- copyright.setText(copyrightText);
+ final String copyrightText = String.format(mRes.getString(R.string.copyright), year);
+ mCopyright.setText(copyrightText);
}
@OnClick(R.id.about_license)
diff --git a/app/src/main/java/com/simplemobiletools/camera/LicenseActivity.java b/app/src/main/java/com/simplemobiletools/camera/activities/LicenseActivity.java
similarity index 90%
rename from app/src/main/java/com/simplemobiletools/camera/LicenseActivity.java
rename to app/src/main/java/com/simplemobiletools/camera/activities/LicenseActivity.java
index b99780fa..21f97dea 100644
--- a/app/src/main/java/com/simplemobiletools/camera/LicenseActivity.java
+++ b/app/src/main/java/com/simplemobiletools/camera/activities/LicenseActivity.java
@@ -1,14 +1,17 @@
-package com.simplemobiletools.camera;
+package com.simplemobiletools.camera.activities;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
+import com.simplemobiletools.camera.R;
+
import butterknife.ButterKnife;
import butterknife.OnClick;
public class LicenseActivity extends AppCompatActivity {
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/app/src/main/java/com/simplemobiletools/camera/MainActivity.java b/app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java
similarity index 61%
rename from app/src/main/java/com/simplemobiletools/camera/MainActivity.java
rename to app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java
index 93d727af..fe161902 100644
--- a/app/src/main/java/com/simplemobiletools/camera/MainActivity.java
+++ b/app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java
@@ -1,4 +1,4 @@
-package com.simplemobiletools.camera;
+package com.simplemobiletools.camera.activities;
import android.Manifest;
import android.content.Intent;
@@ -26,7 +26,12 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import com.simplemobiletools.camera.Constants;
+import com.simplemobiletools.camera.PhotoProcessor;
+import com.simplemobiletools.camera.Preview;
import com.simplemobiletools.camera.Preview.PreviewListener;
+import com.simplemobiletools.camera.R;
+import com.simplemobiletools.camera.Utils;
import java.util.ArrayList;
import java.util.List;
@@ -36,29 +41,31 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
public class MainActivity extends AppCompatActivity implements SensorEventListener, PreviewListener, PhotoProcessor.MediaSavedListener {
- @BindView(R.id.viewHolder) RelativeLayout viewHolder;
- @BindView(R.id.toggle_camera) ImageView toggleCameraBtn;
- @BindView(R.id.toggle_flash) ImageView toggleFlashBtn;
- @BindView(R.id.toggle_photo_video) ImageView togglePhotoVideoBtn;
- @BindView(R.id.shutter) ImageView shutterBtn;
- @BindView(R.id.video_rec_curr_timer) TextView recCurrTimer;
- @BindView(R.id.about) View aboutBtn;
+ @BindView(R.id.viewHolder) RelativeLayout mViewHolder;
+ @BindView(R.id.toggle_camera) ImageView mToggleCameraBtn;
+ @BindView(R.id.toggle_flash) ImageView mToggleFlashBtn;
+ @BindView(R.id.toggle_photo_video) ImageView mTogglePhotoVideoBtn;
+ @BindView(R.id.shutter) ImageView mShutterBtn;
+ @BindView(R.id.video_rec_curr_timer) TextView mRecCurrTimer;
+ @BindView(R.id.about) View mAboutBtn;
private static final int CAMERA_STORAGE_PERMISSION = 1;
private static final int AUDIO_PERMISSION = 2;
- private static SensorManager sensorManager;
- private Preview preview;
- private boolean isFlashEnabled;
- private boolean isInPhotoMode;
- private boolean isAskingPermissions;
- private boolean isCameraAvailable;
- private boolean isImageCaptureIntent;
- private boolean isVideoCaptureIntent;
- private boolean isHardwareShutterHandled;
- private int currVideoRecTimer;
- private int orientation;
- private int currCamera;
- private Handler timerHandler;
+
+ private static SensorManager mSensorManager;
+ private static Preview mPreview;
+ private static Handler mTimerHandler;
+
+ private static boolean mIsFlashEnabled;
+ private static boolean mIsInPhotoMode;
+ private static boolean mIsAskingPermissions;
+ private static boolean mIsCameraAvailable;
+ private static boolean mIsImageCaptureIntent;
+ private static boolean mIsVideoCaptureIntent;
+ private static boolean mIsHardwareShutterHandled;
+ private static int mCurrVideoRecTimer;
+ private static int mOrientation;
+ private static int mCurrCamera;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -74,8 +81,8 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_CAMERA && !isHardwareShutterHandled) {
- isHardwareShutterHandled = true;
+ if (keyCode == KeyEvent.KEYCODE_CAMERA && !mIsHardwareShutterHandled) {
+ mIsHardwareShutterHandled = true;
shutterPressed();
return true;
} else {
@@ -86,17 +93,17 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_CAMERA) {
- isHardwareShutterHandled = false;
+ mIsHardwareShutterHandled = false;
}
return super.onKeyUp(keyCode, event);
}
private void hideToggleModeAbout() {
- if (togglePhotoVideoBtn != null)
- togglePhotoVideoBtn.setVisibility(View.GONE);
+ if (mTogglePhotoVideoBtn != null)
+ mTogglePhotoVideoBtn.setVisibility(View.GONE);
- if (aboutBtn != null)
- aboutBtn.setVisibility(View.GONE);
+ if (mAboutBtn != null)
+ mAboutBtn.setVisibility(View.GONE);
}
private void tryInitCamera() {
@@ -119,17 +126,17 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
final Intent intent = getIntent();
if (intent != null && intent.getAction() != null) {
if (intent.getExtras() != null && intent.getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) {
- isImageCaptureIntent = true;
+ mIsImageCaptureIntent = true;
hideToggleModeAbout();
final Object output = intent.getExtras().get(MediaStore.EXTRA_OUTPUT);
if (output != null && output instanceof Uri) {
- preview.setTargetUri((Uri) output);
+ mPreview.setTargetUri((Uri) output);
}
} else if (intent.getAction().equals(MediaStore.ACTION_VIDEO_CAPTURE)) {
- isVideoCaptureIntent = true;
+ mIsVideoCaptureIntent = true;
hideToggleModeAbout();
- preview.setIsVideoCaptureIntent();
- shutterBtn.setImageDrawable(getResources().getDrawable(R.mipmap.video_rec));
+ mPreview.setIsVideoCaptureIntent();
+ mShutterBtn.setImageDrawable(getResources().getDrawable(R.mipmap.video_rec));
}
}
}
@@ -138,13 +145,13 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
- currCamera = Camera.CameraInfo.CAMERA_FACING_BACK;
- preview = new Preview(this, (SurfaceView) findViewById(R.id.surfaceView), this);
- preview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- viewHolder.addView(preview);
- sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
- isInPhotoMode = true;
- timerHandler = new Handler();
+ mCurrCamera = Camera.CameraInfo.CAMERA_FACING_BACK;
+ mPreview = new Preview(this, (SurfaceView) findViewById(R.id.surfaceView), this);
+ mPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ mViewHolder.addView(mPreview);
+ mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
+ mIsInPhotoMode = true;
+ mTimerHandler = new Handler();
}
private boolean hasCameraAndStoragePermission() {
@@ -154,7 +161,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- isAskingPermissions = false;
+ mIsAskingPermissions = false;
if (requestCode == CAMERA_STORAGE_PERMISSION) {
if (hasCameraAndStoragePermission()) {
@@ -169,7 +176,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
toggleVideo();
} else {
Utils.showToast(getApplicationContext(), R.string.no_audio_permissions);
- if (isVideoCaptureIntent)
+ if (mIsVideoCaptureIntent)
finish();
}
}
@@ -181,19 +188,19 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
return;
}
- if (currCamera == Camera.CameraInfo.CAMERA_FACING_BACK) {
- currCamera = Camera.CameraInfo.CAMERA_FACING_FRONT;
+ if (mCurrCamera == Camera.CameraInfo.CAMERA_FACING_BACK) {
+ mCurrCamera = Camera.CameraInfo.CAMERA_FACING_FRONT;
} else {
- currCamera = Camera.CameraInfo.CAMERA_FACING_BACK;
+ mCurrCamera = Camera.CameraInfo.CAMERA_FACING_BACK;
}
int newIconId = R.mipmap.camera_front;
- preview.releaseCamera();
- if (preview.setCamera(currCamera)) {
- if (currCamera == Camera.CameraInfo.CAMERA_FACING_BACK) {
+ mPreview.releaseCamera();
+ if (mPreview.setCamera(mCurrCamera)) {
+ if (mCurrCamera == Camera.CameraInfo.CAMERA_FACING_BACK) {
newIconId = R.mipmap.camera_rear;
}
- toggleCameraBtn.setImageResource(newIconId);
+ mToggleCameraBtn.setImageResource(newIconId);
disableFlash();
hideTimer();
} else {
@@ -207,7 +214,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
return;
}
- if (isFlashEnabled) {
+ if (mIsFlashEnabled) {
disableFlash();
} else {
enableFlash();
@@ -215,15 +222,15 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
}
private void disableFlash() {
- preview.disableFlash();
- isFlashEnabled = false;
- toggleFlashBtn.setImageResource(R.mipmap.flash_off);
+ mPreview.disableFlash();
+ mIsFlashEnabled = false;
+ mToggleFlashBtn.setImageResource(R.mipmap.flash_off);
}
private void enableFlash() {
- preview.enableFlash();
- isFlashEnabled = true;
- toggleFlashBtn.setImageResource(R.mipmap.flash_on);
+ mPreview.enableFlash();
+ mIsFlashEnabled = true;
+ mToggleFlashBtn.setImageResource(R.mipmap.flash_on);
}
@OnClick(R.id.shutter)
@@ -240,18 +247,18 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
}
private void handleShutter() {
- if (isInPhotoMode) {
- preview.tryTakePicture();
+ if (mIsInPhotoMode) {
+ mPreview.tryTakePicture();
} else {
final Resources res = getResources();
- final boolean isRecording = preview.toggleRecording();
+ final boolean isRecording = mPreview.toggleRecording();
if (isRecording) {
- shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_stop));
- toggleCameraBtn.setVisibility(View.INVISIBLE);
+ mShutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_stop));
+ mToggleCameraBtn.setVisibility(View.INVISIBLE);
showTimer();
} else {
- shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_rec));
- toggleCameraBtn.setVisibility(View.VISIBLE);
+ mShutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_rec));
+ mToggleCameraBtn.setVisibility(View.VISIBLE);
hideTimer();
}
}
@@ -276,21 +283,21 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
if (!Utils.hasAudioPermission(getApplicationContext())) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, AUDIO_PERMISSION);
- isAskingPermissions = true;
+ mIsAskingPermissions = true;
return;
}
- if (isVideoCaptureIntent)
- preview.trySwitchToVideo();
+ if (mIsVideoCaptureIntent)
+ mPreview.trySwitchToVideo();
disableFlash();
hideTimer();
- isInPhotoMode = !isInPhotoMode;
- toggleCameraBtn.setVisibility(View.VISIBLE);
+ mIsInPhotoMode = !mIsInPhotoMode;
+ mToggleCameraBtn.setVisibility(View.VISIBLE);
}
private void checkButtons() {
- if (isInPhotoMode) {
+ if (mIsInPhotoMode) {
initPhotoButtons();
} else {
initVideoButtons(true);
@@ -299,19 +306,19 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
private void initPhotoButtons() {
final Resources res = getResources();
- togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.videocam));
- shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.camera));
- preview.initPhotoMode();
+ mTogglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.videocam));
+ mShutterBtn.setImageDrawable(res.getDrawable(R.mipmap.camera));
+ mPreview.initPhotoMode();
}
private void initVideoButtons(boolean warnOnError) {
- if (preview.initRecorder()) {
+ if (mPreview.initRecorder()) {
final Resources res = getResources();
- togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.photo));
- shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_rec));
- toggleCameraBtn.setVisibility(View.VISIBLE);
+ mTogglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.photo));
+ mShutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_rec));
+ mToggleCameraBtn.setVisibility(View.VISIBLE);
} else {
- if (!isVideoCaptureIntent && warnOnError) {
+ if (!mIsVideoCaptureIntent && warnOnError) {
Utils.showToast(getApplicationContext(), R.string.video_mode_error);
}
}
@@ -322,14 +329,14 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
}
private void hideTimer() {
- recCurrTimer.setText(Utils.formatSeconds(0));
- recCurrTimer.setVisibility(View.GONE);
- currVideoRecTimer = 0;
- timerHandler.removeCallbacksAndMessages(null);
+ mRecCurrTimer.setText(Utils.formatSeconds(0));
+ mRecCurrTimer.setVisibility(View.GONE);
+ mCurrVideoRecTimer = 0;
+ mTimerHandler.removeCallbacksAndMessages(null);
}
private void showTimer() {
- recCurrTimer.setVisibility(View.VISIBLE);
+ mRecCurrTimer.setVisibility(View.VISIBLE);
setupTimer();
}
@@ -337,8 +344,8 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
runOnUiThread(new Runnable() {
@Override
public void run() {
- recCurrTimer.setText(Utils.formatSeconds(currVideoRecTimer++));
- timerHandler.postDelayed(this, 1000);
+ mRecCurrTimer.setText(Utils.formatSeconds(mCurrVideoRecTimer++));
+ mTimerHandler.postDelayed(this, 1000);
}
});
}
@@ -349,7 +356,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
if (hasCameraAndStoragePermission()) {
resumeCameraItems();
- if (isVideoCaptureIntent && isInPhotoMode) {
+ if (mIsVideoCaptureIntent && mIsInPhotoMode) {
toggleVideo();
checkButtons();
}
@@ -359,18 +366,18 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
private void resumeCameraItems() {
final int cnt = Camera.getNumberOfCameras();
if (cnt == 1) {
- toggleCameraBtn.setVisibility(View.INVISIBLE);
+ mToggleCameraBtn.setVisibility(View.INVISIBLE);
}
- if (preview.setCamera(currCamera)) {
+ if (mPreview.setCamera(mCurrCamera)) {
hideNavigationBarIcons();
- if (sensorManager != null) {
- final Sensor accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
- sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
+ if (mSensorManager != null) {
+ final Sensor accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+ mSensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
}
- if (!isInPhotoMode) {
+ if (!mIsInPhotoMode) {
initVideoButtons(false);
}
} else {
@@ -381,27 +388,27 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
protected void onPause() {
super.onPause();
- if (!hasCameraAndStoragePermission() || isAskingPermissions)
+ if (!hasCameraAndStoragePermission() || mIsAskingPermissions)
return;
hideTimer();
- if (preview != null) {
- preview.releaseCamera();
+ if (mPreview != null) {
+ mPreview.releaseCamera();
}
- if (sensorManager != null)
- sensorManager.unregisterListener(this);
+ if (mSensorManager != null)
+ mSensorManager.unregisterListener(this);
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.values[0] < 6.5 && event.values[0] > -6.5) {
- orientation = Constants.ORIENT_PORTRAIT;
+ mOrientation = Constants.ORIENT_PORTRAIT;
} else {
if (event.values[0] > 0) {
- orientation = Constants.ORIENT_LANDSCAPE_LEFT;
+ mOrientation = Constants.ORIENT_LANDSCAPE_LEFT;
} else {
- orientation = Constants.ORIENT_LANDSCAPE_RIGHT;
+ mOrientation = Constants.ORIENT_LANDSCAPE_RIGHT;
}
}
}
@@ -412,25 +419,25 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
}
private boolean checkCameraAvailable() {
- if (!isCameraAvailable) {
+ if (!mIsCameraAvailable) {
Utils.showToast(getApplicationContext(), R.string.camera_unavailable);
}
- return isCameraAvailable;
+ return mIsCameraAvailable;
}
@Override
public void setFlashAvailable(boolean available) {
if (available) {
- toggleFlashBtn.setVisibility(View.VISIBLE);
+ mToggleFlashBtn.setVisibility(View.VISIBLE);
} else {
- toggleFlashBtn.setVisibility(View.INVISIBLE);
+ mToggleFlashBtn.setVisibility(View.INVISIBLE);
disableFlash();
}
}
@Override
public void setIsCameraAvailable(boolean available) {
- isCameraAvailable = available;
+ mIsCameraAvailable = available;
}
@Override
@@ -440,12 +447,12 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
public int getCurrentOrientation() {
- return orientation;
+ return mOrientation;
}
@Override
public void videoSaved(Uri uri) {
- if (isVideoCaptureIntent) {
+ if (mIsVideoCaptureIntent) {
final Intent intent = new Intent();
intent.setData(uri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -456,7 +463,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
public void mediaSaved() {
- if (isImageCaptureIntent) {
+ if (mIsImageCaptureIntent) {
setResult(RESULT_OK);
finish();
}
@@ -465,7 +472,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
@Override
protected void onDestroy() {
super.onDestroy();
- if (preview != null)
- preview.releaseCamera();
+ if (mPreview != null)
+ mPreview.releaseCamera();
}
}
diff --git a/app/src/main/java/com/simplemobiletools/camera/SettingsActivity.java b/app/src/main/java/com/simplemobiletools/camera/activities/SettingsActivity.java
similarity index 55%
rename from app/src/main/java/com/simplemobiletools/camera/SettingsActivity.java
rename to app/src/main/java/com/simplemobiletools/camera/activities/SettingsActivity.java
index b30bcade..b67dae62 100644
--- a/app/src/main/java/com/simplemobiletools/camera/SettingsActivity.java
+++ b/app/src/main/java/com/simplemobiletools/camera/activities/SettingsActivity.java
@@ -1,16 +1,19 @@
-package com.simplemobiletools.camera;
+package com.simplemobiletools.camera.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SwitchCompat;
+import com.simplemobiletools.camera.Config;
+import com.simplemobiletools.camera.R;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class SettingsActivity extends AppCompatActivity {
- @BindView(R.id.settings_long_tap) SwitchCompat longTapSwitch;
- @BindView(R.id.settings_focus_before_capture) SwitchCompat focusBeforeCaptureSwitch;
+ @BindView(R.id.settings_long_tap) SwitchCompat mLongTapSwitch;
+ @BindView(R.id.settings_focus_before_capture) SwitchCompat mFocusBeforeCaptureSwitch;
private static Config mConfig;
@@ -26,22 +29,22 @@ public class SettingsActivity extends AppCompatActivity {
}
private void setupLongTap() {
- longTapSwitch.setChecked(mConfig.getLongTapEnabled());
+ mLongTapSwitch.setChecked(mConfig.getLongTapEnabled());
}
private void setupFocusBeforeCapture() {
- focusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
+ mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
}
@OnClick(R.id.settings_long_tap_holder)
public void handleLongTapToTrigger() {
- longTapSwitch.setChecked(!longTapSwitch.isChecked());
- mConfig.setLongTapEnabled(longTapSwitch.isChecked());
+ mLongTapSwitch.setChecked(!mLongTapSwitch.isChecked());
+ mConfig.setLongTapEnabled(mLongTapSwitch.isChecked());
}
@OnClick(R.id.settings_focus_before_capture_holder)
public void handleFocusBeforeCapture() {
- focusBeforeCaptureSwitch.setChecked(!focusBeforeCaptureSwitch.isChecked());
- mConfig.setFocusBeforeCaptureEnabled(focusBeforeCaptureSwitch.isChecked());
+ mFocusBeforeCaptureSwitch.setChecked(!mFocusBeforeCaptureSwitch.isChecked());
+ mConfig.setFocusBeforeCaptureEnabled(mFocusBeforeCaptureSwitch.isChecked());
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0943fb69..705a36b5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -15,7 +15,7 @@
Settings
Long tap to capture
- Focus before capture
+ Refocus before capture
About