summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/callcomposer/camera
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2017-12-27 17:02:37 -0800
committerCopybara-Service <copybara-piper@google.com>2017-12-27 17:03:47 -0800
commit183cb71663320f16149d83eeebaff7795a4b55f2 (patch)
treebc8bfcce809257b3ddbb423a9808082292b9f6a3 /java/com/android/dialer/callcomposer/camera
parentfc81a030a7b4f6d4a497f71aed593d398795e7da (diff)
Remove field prefixes.
Test: Existing tests PiperOrigin-RevId: 180230450 Change-Id: I0b2589cfeeaef81e42a04efa48af24b4e4d0e95f
Diffstat (limited to 'java/com/android/dialer/callcomposer/camera')
-rw-r--r--java/com/android/dialer/callcomposer/camera/CameraManager.java328
-rw-r--r--java/com/android/dialer/callcomposer/camera/CameraPreview.java48
-rw-r--r--java/com/android/dialer/callcomposer/camera/HardwareCameraPreview.java26
-rw-r--r--java/com/android/dialer/callcomposer/camera/ImagePersistWorker.java52
-rw-r--r--java/com/android/dialer/callcomposer/camera/SoftwareCameraPreview.java24
-rw-r--r--java/com/android/dialer/callcomposer/camera/camerafocus/FocusOverlayManager.java230
-rw-r--r--java/com/android/dialer/callcomposer/camera/camerafocus/OverlayRenderer.java40
-rw-r--r--java/com/android/dialer/callcomposer/camera/camerafocus/PieItem.java66
-rw-r--r--java/com/android/dialer/callcomposer/camera/camerafocus/PieRenderer.java539
-rw-r--r--java/com/android/dialer/callcomposer/camera/camerafocus/RenderOverlay.java42
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/CountedDataInputStream.java34
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/ExifData.java12
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/ExifInterface.java48
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/ExifParser.java210
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/ExifTag.java200
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/IfdData.java30
-rw-r--r--java/com/android/dialer/callcomposer/camera/exif/Rational.java18
17 files changed, 968 insertions, 979 deletions
diff --git a/java/com/android/dialer/callcomposer/camera/CameraManager.java b/java/com/android/dialer/callcomposer/camera/CameraManager.java
index b850a193f..c61f57050 100644
--- a/java/com/android/dialer/callcomposer/camera/CameraManager.java
+++ b/java/com/android/dialer/callcomposer/camera/CameraManager.java
@@ -93,28 +93,28 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
};
- private static CameraManager sInstance;
+ private static CameraManager instance;
/** The CameraInfo for the currently selected camera */
- private final CameraInfo mCameraInfo;
+ private final CameraInfo cameraInfo;
/** The index of the selected camera or NO_CAMERA_SELECTED if a camera hasn't been selected yet */
- private int mCameraIndex;
+ private int cameraIndex;
/** True if the device has front and back cameras */
- private final boolean mHasFrontAndBackCamera;
+ private final boolean hasFrontAndBackCamera;
/** True if the camera should be open (may not yet be actually open) */
- private boolean mOpenRequested;
+ private boolean openRequested;
/** The preview view to show the preview on */
- private CameraPreview mCameraPreview;
+ private CameraPreview cameraPreview;
/** The helper classs to handle orientation changes */
- private OrientationHandler mOrientationHandler;
+ private OrientationHandler orientationHandler;
/** Tracks whether the preview has hardware acceleration */
- private boolean mIsHardwareAccelerationSupported;
+ private boolean isHardwareAccelerationSupported;
/**
* The task for opening the camera, so it doesn't block the UI thread Using AsyncTask rather than
@@ -122,32 +122,32 @@ public class CameraManager implements FocusOverlayManager.Listener {
* TODO(blemmon): If we have other AyncTasks (not SafeAsyncTasks) this may contend and we may need
* to create a dedicated thread, or synchronize the threads in the thread pool
*/
- private AsyncTask<Integer, Void, Camera> mOpenCameraTask;
+ private AsyncTask<Integer, Void, Camera> openCameraTask;
/**
* The camera index that is queued to be opened, but not completed yet, or NO_CAMERA_SELECTED if
* no open task is pending
*/
- private int mPendingOpenCameraIndex = NO_CAMERA_SELECTED;
+ private int pendingOpenCameraIndex = NO_CAMERA_SELECTED;
/** The instance of the currently opened camera */
- private Camera mCamera;
+ private Camera camera;
/** The rotation of the screen relative to the camera's natural orientation */
- private int mRotation;
+ private int rotation;
/** The callback to notify when errors or other events occur */
- private CameraManagerListener mListener;
+ private CameraManagerListener listener;
/** True if the camera is currently in the process of taking an image */
- private boolean mTakingPicture;
+ private boolean takingPicture;
/** Manages auto focus visual and behavior */
- private final FocusOverlayManager mFocusOverlayManager;
+ private final FocusOverlayManager focusOverlayManager;
private CameraManager() {
- mCameraInfo = new CameraInfo();
- mCameraIndex = NO_CAMERA_SELECTED;
+ this.cameraInfo = new CameraInfo();
+ cameraIndex = NO_CAMERA_SELECTED;
// Check to see if a front and back camera exist
boolean hasFrontCamera = false;
@@ -169,19 +169,19 @@ public class CameraManager implements FocusOverlayManager.Listener {
} catch (final RuntimeException e) {
LogUtil.e("CameraManager.CameraManager", "Unable to load camera info", e);
}
- mHasFrontAndBackCamera = hasFrontCamera && hasBackCamera;
- mFocusOverlayManager = new FocusOverlayManager(this, Looper.getMainLooper());
+ hasFrontAndBackCamera = hasFrontCamera && hasBackCamera;
+ focusOverlayManager = new FocusOverlayManager(this, Looper.getMainLooper());
// Assume the best until we are proven otherwise
- mIsHardwareAccelerationSupported = true;
+ isHardwareAccelerationSupported = true;
}
/** Gets the singleton instance */
public static CameraManager get() {
- if (sInstance == null) {
- sInstance = new CameraManager();
+ if (instance == null) {
+ instance = new CameraManager();
}
- return sInstance;
+ return instance;
}
/**
@@ -191,7 +191,7 @@ public class CameraManager implements FocusOverlayManager.Listener {
* @param preview The preview surface view
*/
void setSurface(final CameraPreview preview) {
- if (preview == mCameraPreview) {
+ if (preview == cameraPreview) {
return;
}
@@ -203,8 +203,8 @@ public class CameraManager implements FocusOverlayManager.Listener {
public boolean onTouch(final View view, final MotionEvent motionEvent) {
if ((motionEvent.getActionMasked() & MotionEvent.ACTION_UP)
== MotionEvent.ACTION_UP) {
- mFocusOverlayManager.setPreviewSize(view.getWidth(), view.getHeight());
- mFocusOverlayManager.onSingleTapUp(
+ focusOverlayManager.setPreviewSize(view.getWidth(), view.getHeight());
+ focusOverlayManager.onSingleTapUp(
(int) motionEvent.getX() + view.getLeft(),
(int) motionEvent.getY() + view.getTop());
}
@@ -213,20 +213,20 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
});
}
- mCameraPreview = preview;
+ cameraPreview = preview;
tryShowPreview();
}
public void setRenderOverlay(final RenderOverlay renderOverlay) {
- mFocusOverlayManager.setFocusRenderer(
+ focusOverlayManager.setFocusRenderer(
renderOverlay != null ? renderOverlay.getPieRenderer() : null);
}
/** Convenience function to swap between front and back facing cameras */
public void swapCamera() {
- Assert.checkState(mCameraIndex >= 0);
+ Assert.checkState(cameraIndex >= 0);
selectCamera(
- mCameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT
+ cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT
? CameraInfo.CAMERA_FACING_BACK
: CameraInfo.CAMERA_FACING_FRONT);
}
@@ -241,59 +241,59 @@ public class CameraManager implements FocusOverlayManager.Listener {
public boolean selectCamera(final int desiredFacing) {
try {
// We already selected a camera facing that direction
- if (mCameraIndex >= 0 && mCameraInfo.facing == desiredFacing) {
+ if (cameraIndex >= 0 && this.cameraInfo.facing == desiredFacing) {
return true;
}
final int cameraCount = Camera.getNumberOfCameras();
Assert.checkState(cameraCount > 0);
- mCameraIndex = NO_CAMERA_SELECTED;
+ cameraIndex = NO_CAMERA_SELECTED;
setCamera(null);
final CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == desiredFacing) {
- mCameraIndex = i;
- Camera.getCameraInfo(i, mCameraInfo);
+ cameraIndex = i;
+ Camera.getCameraInfo(i, this.cameraInfo);
break;
}
}
// There's no camera in the desired facing direction, just select the first camera
// regardless of direction
- if (mCameraIndex < 0) {
- mCameraIndex = 0;
- Camera.getCameraInfo(0, mCameraInfo);
+ if (cameraIndex < 0) {
+ cameraIndex = 0;
+ Camera.getCameraInfo(0, this.cameraInfo);
}
- if (mOpenRequested) {
+ if (openRequested) {
// The camera is open, so reopen with the newly selected camera
openCamera();
}
return true;
} catch (final RuntimeException e) {
LogUtil.e("CameraManager.selectCamera", "RuntimeException in CameraManager.selectCamera", e);
- if (mListener != null) {
- mListener.onCameraError(ERROR_OPENING_CAMERA, e);
+ if (listener != null) {
+ listener.onCameraError(ERROR_OPENING_CAMERA, e);
}
return false;
}
}
public int getCameraIndex() {
- return mCameraIndex;
+ return cameraIndex;
}
public void selectCameraByIndex(final int cameraIndex) {
- if (mCameraIndex == cameraIndex) {
+ if (this.cameraIndex == cameraIndex) {
return;
}
try {
- mCameraIndex = cameraIndex;
- Camera.getCameraInfo(mCameraIndex, mCameraInfo);
- if (mOpenRequested) {
+ this.cameraIndex = cameraIndex;
+ Camera.getCameraInfo(this.cameraIndex, cameraInfo);
+ if (openRequested) {
openCamera();
}
} catch (final RuntimeException e) {
@@ -301,8 +301,8 @@ public class CameraManager implements FocusOverlayManager.Listener {
"CameraManager.selectCameraByIndex",
"RuntimeException in CameraManager.selectCameraByIndex",
e);
- if (mListener != null) {
- mListener.onCameraError(ERROR_OPENING_CAMERA, e);
+ if (listener != null) {
+ listener.onCameraError(ERROR_OPENING_CAMERA, e);
}
}
}
@@ -310,27 +310,27 @@ public class CameraManager implements FocusOverlayManager.Listener {
@Nullable
@VisibleForTesting
public CameraInfo getCameraInfo() {
- if (mCameraIndex == NO_CAMERA_SELECTED) {
+ if (cameraIndex == NO_CAMERA_SELECTED) {
return null;
}
- return mCameraInfo;
+ return cameraInfo;
}
/** @return True if the device has both a front and back camera */
public boolean hasFrontAndBackCamera() {
- return mHasFrontAndBackCamera;
+ return hasFrontAndBackCamera;
}
/** Opens the camera on a separate thread and initiates the preview if one is available */
void openCamera() {
- if (mCameraIndex == NO_CAMERA_SELECTED) {
+ if (this.cameraIndex == NO_CAMERA_SELECTED) {
// Ensure a selected camera if none is currently selected. This may happen if the
// camera chooser is not the default media chooser.
selectCamera(CameraInfo.CAMERA_FACING_BACK);
}
- mOpenRequested = true;
+ openRequested = true;
// We're already opening the camera or already have the camera handle, nothing more to do
- if (mPendingOpenCameraIndex == mCameraIndex || mCamera != null) {
+ if (pendingOpenCameraIndex == this.cameraIndex || this.camera != null) {
return;
}
@@ -338,25 +338,27 @@ public class CameraManager implements FocusOverlayManager.Listener {
boolean delayTask = false;
// Cancel any previous open camera tasks
- if (mOpenCameraTask != null) {
- mPendingOpenCameraIndex = NO_CAMERA_SELECTED;
+ if (openCameraTask != null) {
+ pendingOpenCameraIndex = NO_CAMERA_SELECTED;
delayTask = true;
}
- mPendingOpenCameraIndex = mCameraIndex;
- mOpenCameraTask =
+ pendingOpenCameraIndex = this.cameraIndex;
+ openCameraTask =
new AsyncTask<Integer, Void, Camera>() {
- private Exception mException;
+ private Exception exception;
@Override
protected Camera doInBackground(final Integer... params) {
try {
final int cameraIndex = params[0];
- LogUtil.v("CameraManager.doInBackground", "Opening camera " + mCameraIndex);
+ LogUtil.v(
+ "CameraManager.doInBackground",
+ "Opening camera " + CameraManager.this.cameraIndex);
return Camera.open(cameraIndex);
} catch (final Exception e) {
LogUtil.e("CameraManager.doInBackground", "Exception while opening camera", e);
- mException = e;
+ exception = e;
return null;
}
}
@@ -364,7 +366,7 @@ public class CameraManager implements FocusOverlayManager.Listener {
@Override
protected void onPostExecute(final Camera camera) {
// If we completed, but no longer want this camera, then release the camera
- if (mOpenCameraTask != this || !mOpenRequested) {
+ if (openCameraTask != this || !openRequested) {
releaseCamera(camera);
cleanup();
return;
@@ -374,11 +376,11 @@ public class CameraManager implements FocusOverlayManager.Listener {
LogUtil.v(
"CameraManager.onPostExecute",
- "Opened camera " + mCameraIndex + " " + (camera != null));
+ "Opened camera " + CameraManager.this.cameraIndex + " " + (camera != null));
setCamera(camera);
if (camera == null) {
- if (mListener != null) {
- mListener.onCameraError(ERROR_OPENING_CAMERA, mException);
+ if (listener != null) {
+ listener.onCameraError(ERROR_OPENING_CAMERA, exception);
}
LogUtil.e("CameraManager.onPostExecute", "Error opening camera");
}
@@ -391,24 +393,24 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
private void cleanup() {
- mPendingOpenCameraIndex = NO_CAMERA_SELECTED;
- if (mOpenCameraTask != null && mOpenCameraTask.getStatus() == Status.PENDING) {
+ pendingOpenCameraIndex = NO_CAMERA_SELECTED;
+ if (openCameraTask != null && openCameraTask.getStatus() == Status.PENDING) {
// If there's another task waiting on this one to complete, start it now
- mOpenCameraTask.execute(mCameraIndex);
+ openCameraTask.execute(CameraManager.this.cameraIndex);
} else {
- mOpenCameraTask = null;
+ openCameraTask = null;
}
}
};
- LogUtil.v("CameraManager.openCamera", "Start opening camera " + mCameraIndex);
+ LogUtil.v("CameraManager.openCamera", "Start opening camera " + this.cameraIndex);
if (!delayTask) {
- mOpenCameraTask.execute(mCameraIndex);
+ openCameraTask.execute(this.cameraIndex);
}
}
/** Closes the camera releasing the resources it uses */
void closeCamera() {
- mOpenRequested = false;
+ openRequested = false;
setCamera(null);
}
@@ -419,18 +421,18 @@ public class CameraManager implements FocusOverlayManager.Listener {
*/
public void setListener(final CameraManagerListener listener) {
Assert.isMainThread();
- mListener = listener;
- if (!mIsHardwareAccelerationSupported && mListener != null) {
- mListener.onCameraError(ERROR_HARDWARE_ACCELERATION_DISABLED, null);
+ this.listener = listener;
+ if (!isHardwareAccelerationSupported && this.listener != null) {
+ this.listener.onCameraError(ERROR_HARDWARE_ACCELERATION_DISABLED, null);
}
}
public void takePicture(final float heightPercent, @NonNull final MediaCallback callback) {
- Assert.checkState(!mTakingPicture);
+ Assert.checkState(!takingPicture);
Assert.isNotNull(callback);
- mCameraPreview.setFocusable(false);
- mFocusOverlayManager.cancelAutoFocus();
- if (mCamera == null) {
+ cameraPreview.setFocusable(false);
+ focusOverlayManager.cancelAutoFocus();
+ if (this.camera == null) {
// The caller should have checked isCameraAvailable first, but just in case, protect
// against a null camera by notifying the callback that taking the picture didn't work
callback.onMediaFailed(null);
@@ -440,8 +442,8 @@ public class CameraManager implements FocusOverlayManager.Listener {
new Camera.PictureCallback() {
@Override
public void onPictureTaken(final byte[] bytes, final Camera camera) {
- mTakingPicture = false;
- if (mCamera != camera) {
+ takingPicture = false;
+ if (CameraManager.this.camera != camera) {
// This may happen if the camera was changed between front/back while the
// picture is being taken.
callback.onMediaInfo(MediaCallback.MEDIA_CAMERA_CHANGED);
@@ -456,7 +458,7 @@ public class CameraManager implements FocusOverlayManager.Listener {
final Camera.Size size = camera.getParameters().getPictureSize();
int width;
int height;
- if (mRotation == 90 || mRotation == 270) {
+ if (rotation == 90 || rotation == 270) {
// Is rotated, so swapping dimensions is desired
// noinspection SuspiciousNameCombination
width = size.height;
@@ -468,11 +470,11 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
LogUtil.i(
"CameraManager.onPictureTaken", "taken picture size: " + bytes.length + " bytes");
- DialerExecutorComponent.get(mCameraPreview.getContext())
+ DialerExecutorComponent.get(cameraPreview.getContext())
.dialerExecutorFactory()
.createNonUiTaskBuilder(
new ImagePersistWorker(
- width, height, heightPercent, bytes, mCameraPreview.getContext()))
+ width, height, heightPercent, bytes, cameraPreview.getContext()))
.onSuccess(
(result) -> {
callback.onMediaReady(
@@ -487,16 +489,16 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
};
- mTakingPicture = true;
+ takingPicture = true;
try {
- mCamera.takePicture(
+ this.camera.takePicture(
// A shutter callback is required to enable shutter sound
DUMMY_SHUTTER_CALLBACK, null /* raw */, null /* postView */, jpegCallback);
} catch (final RuntimeException e) {
LogUtil.e("CameraManager.takePicture", "RuntimeException in CameraManager.takePicture", e);
- mTakingPicture = false;
- if (mListener != null) {
- mListener.onCameraError(ERROR_TAKING_PICTURE, e);
+ takingPicture = false;
+ if (listener != null) {
+ listener.onCameraError(ERROR_TAKING_PICTURE, e);
}
}
}
@@ -511,12 +513,12 @@ public class CameraManager implements FocusOverlayManager.Listener {
return;
}
- mFocusOverlayManager.onCameraReleased();
+ focusOverlayManager.onCameraReleased();
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... params) {
- LogUtil.v("CameraManager.doInBackground", "Releasing camera " + mCameraIndex);
+ LogUtil.v("CameraManager.doInBackground", "Releasing camera " + cameraIndex);
camera.release();
return null;
}
@@ -583,47 +585,47 @@ public class CameraManager implements FocusOverlayManager.Listener {
/** Sets the current camera, releasing any previously opened camera */
private void setCamera(final Camera camera) {
- if (mCamera == camera) {
+ if (this.camera == camera) {
return;
}
- releaseCamera(mCamera);
- mCamera = camera;
+ releaseCamera(this.camera);
+ this.camera = camera;
tryShowPreview();
- if (mListener != null) {
- mListener.onCameraChanged();
+ if (listener != null) {
+ listener.onCameraChanged();
}
}
/** Shows the preview if the camera is open and the preview is loaded */
private void tryShowPreview() {
- if (mCameraPreview == null || mCamera == null) {
- if (mOrientationHandler != null) {
- mOrientationHandler.disable();
- mOrientationHandler = null;
+ if (cameraPreview == null || this.camera == null) {
+ if (orientationHandler != null) {
+ orientationHandler.disable();
+ orientationHandler = null;
}
- mFocusOverlayManager.onPreviewStopped();
+ focusOverlayManager.onPreviewStopped();
return;
}
try {
- mCamera.stopPreview();
- if (!mTakingPicture) {
- mRotation =
+ this.camera.stopPreview();
+ if (!takingPicture) {
+ rotation =
updateCameraRotation(
- mCamera,
+ this.camera,
getScreenRotation(),
- mCameraInfo.orientation,
- mCameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT);
+ cameraInfo.orientation,
+ cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT);
}
- final Camera.Parameters params = mCamera.getParameters();
+ final Camera.Parameters params = this.camera.getParameters();
final Camera.Size pictureSize = chooseBestPictureSize();
final Camera.Size previewSize = chooseBestPreviewSize(pictureSize);
params.setPreviewSize(previewSize.width, previewSize.height);
params.setPictureSize(pictureSize.width, pictureSize.height);
logCameraSize("Setting preview size: ", previewSize);
logCameraSize("Setting picture size: ", pictureSize);
- mCameraPreview.setSize(previewSize, mCameraInfo.orientation);
+ cameraPreview.setSize(previewSize, cameraInfo.orientation);
for (final String focusMode : params.getSupportedFocusModes()) {
if (TextUtils.equals(focusMode, Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
// Use continuous focus if available
@@ -632,39 +634,39 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
}
- mCamera.setParameters(params);
- mCameraPreview.startPreview(mCamera);
- mCamera.startPreview();
- mCamera.setAutoFocusMoveCallback(
+ this.camera.setParameters(params);
+ cameraPreview.startPreview(this.camera);
+ this.camera.startPreview();
+ this.camera.setAutoFocusMoveCallback(
new Camera.AutoFocusMoveCallback() {
@Override
public void onAutoFocusMoving(final boolean start, final Camera camera) {
- mFocusOverlayManager.onAutoFocusMoving(start);
+ focusOverlayManager.onAutoFocusMoving(start);
}
});
- mFocusOverlayManager.setParameters(mCamera.getParameters());
- mFocusOverlayManager.setMirror(mCameraInfo.facing == CameraInfo.CAMERA_FACING_BACK);
- mFocusOverlayManager.onPreviewStarted();
- if (mOrientationHandler == null) {
- mOrientationHandler = new OrientationHandler(mCameraPreview.getContext());
- mOrientationHandler.enable();
+ focusOverlayManager.setParameters(this.camera.getParameters());
+ focusOverlayManager.setMirror(cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK);
+ focusOverlayManager.onPreviewStarted();
+ if (orientationHandler == null) {
+ orientationHandler = new OrientationHandler(cameraPreview.getContext());
+ orientationHandler.enable();
}
} catch (final IOException e) {
LogUtil.e("CameraManager.tryShowPreview", "IOException in CameraManager.tryShowPreview", e);
- if (mListener != null) {
- mListener.onCameraError(ERROR_SHOWING_PREVIEW, e);
+ if (listener != null) {
+ listener.onCameraError(ERROR_SHOWING_PREVIEW, e);
}
} catch (final RuntimeException e) {
LogUtil.e(
"CameraManager.tryShowPreview", "RuntimeException in CameraManager.tryShowPreview", e);
- if (mListener != null) {
- mListener.onCameraError(ERROR_SHOWING_PREVIEW, e);
+ if (listener != null) {
+ listener.onCameraError(ERROR_SHOWING_PREVIEW, e);
}
}
}
private int getScreenRotation() {
- return mCameraPreview
+ return cameraPreview
.getContext()
.getSystemService(WindowManager.class)
.getDefaultDisplay()
@@ -672,7 +674,7 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
public boolean isCameraAvailable() {
- return mCamera != null && !mTakingPicture && mIsHardwareAccelerationSupported;
+ return camera != null && !takingPicture && isHardwareAccelerationSupported;
}
/**
@@ -680,7 +682,7 @@ public class CameraManager implements FocusOverlayManager.Listener {
* is closest to the screen aspect ratio. In case of RCS conversation returns default size.
*/
private Camera.Size chooseBestPictureSize() {
- return mCamera.getParameters().getPictureSize();
+ return camera.getParameters().getPictureSize();
}
/**
@@ -689,7 +691,7 @@ public class CameraManager implements FocusOverlayManager.Listener {
*/
private Camera.Size chooseBestPreviewSize(final Camera.Size pictureSize) {
final List<Camera.Size> sizes =
- new ArrayList<Camera.Size>(mCamera.getParameters().getSupportedPreviewSizes());
+ new ArrayList<Camera.Size>(camera.getParameters().getSupportedPreviewSizes());
final float aspectRatio = pictureSize.width / (float) pictureSize.height;
final int capturePixels = pictureSize.width * pictureSize.height;
@@ -708,13 +710,13 @@ public class CameraManager implements FocusOverlayManager.Listener {
@Override
public void onOrientationChanged(final int orientation) {
- if (!mTakingPicture) {
- mRotation =
+ if (!takingPicture) {
+ rotation =
updateCameraRotation(
- mCamera,
+ camera,
getScreenRotation(),
- mCameraInfo.orientation,
- mCameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT);
+ cameraInfo.orientation,
+ cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT);
}
}
}
@@ -724,24 +726,24 @@ public class CameraManager implements FocusOverlayManager.Listener {
private static final int PREFER_RIGHT = 1;
// The max width/height for the preferred size. Integer.MAX_VALUE if no size limit
- private final int mMaxWidth;
- private final int mMaxHeight;
+ private final int maxWidth;
+ private final int maxHeight;
// The desired aspect ratio
- private final float mTargetAspectRatio;
+ private final float targetAspectRatio;
// The desired size (width x height) to try to match
- private final int mTargetPixels;
+ private final int targetPixels;
public SizeComparator(
final int maxWidth,
final int maxHeight,
final float targetAspectRatio,
final int targetPixels) {
- mMaxWidth = maxWidth;
- mMaxHeight = maxHeight;
- mTargetAspectRatio = targetAspectRatio;
- mTargetPixels = targetPixels;
+ this.maxWidth = maxWidth;
+ this.maxHeight = maxHeight;
+ this.targetAspectRatio = targetAspectRatio;
+ this.targetPixels = targetPixels;
}
/**
@@ -751,16 +753,16 @@ public class CameraManager implements FocusOverlayManager.Listener {
@Override
public int compare(final Camera.Size left, final Camera.Size right) {
// If one size is less than the max size prefer it over the other
- if ((left.width <= mMaxWidth && left.height <= mMaxHeight)
- != (right.width <= mMaxWidth && right.height <= mMaxHeight)) {
- return left.width <= mMaxWidth ? PREFER_LEFT : PREFER_RIGHT;
+ if ((left.width <= maxWidth && left.height <= maxHeight)
+ != (right.width <= maxWidth && right.height <= maxHeight)) {
+ return left.width <= maxWidth ? PREFER_LEFT : PREFER_RIGHT;
}
// If one is closer to the target aspect ratio, prefer it.
final float leftAspectRatio = left.width / (float) left.height;
final float rightAspectRatio = right.width / (float) right.height;
- final float leftAspectRatioDiff = Math.abs(leftAspectRatio - mTargetAspectRatio);
- final float rightAspectRatioDiff = Math.abs(rightAspectRatio - mTargetAspectRatio);
+ final float leftAspectRatioDiff = Math.abs(leftAspectRatio - targetAspectRatio);
+ final float rightAspectRatioDiff = Math.abs(rightAspectRatio - targetAspectRatio);
if (leftAspectRatioDiff != rightAspectRatioDiff) {
return (leftAspectRatioDiff - rightAspectRatioDiff) < 0 ? PREFER_LEFT : PREFER_RIGHT;
}
@@ -768,41 +770,41 @@ public class CameraManager implements FocusOverlayManager.Listener {
// At this point they have the same aspect ratio diff and are either both bigger
// than the max size or both smaller than the max size, so prefer the one closest
// to target size
- final int leftDiff = Math.abs((left.width * left.height) - mTargetPixels);
- final int rightDiff = Math.abs((right.width * right.height) - mTargetPixels);
+ final int leftDiff = Math.abs((left.width * left.height) - targetPixels);
+ final int rightDiff = Math.abs((right.width * right.height) - targetPixels);
return leftDiff - rightDiff;
}
}
@Override // From FocusOverlayManager.Listener
public void autoFocus() {
- if (mCamera == null) {
+ if (this.camera == null) {
return;
}
try {
- mCamera.autoFocus(
+ this.camera.autoFocus(
new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(final boolean success, final Camera camera) {
- mFocusOverlayManager.onAutoFocus(success, false /* shutterDown */);
+ focusOverlayManager.onAutoFocus(success, false /* shutterDown */);
}
});
} catch (final RuntimeException e) {
LogUtil.e("CameraManager.autoFocus", "RuntimeException in CameraManager.autoFocus", e);
// If autofocus fails, the camera should have called the callback with success=false,
// but some throw an exception here
- mFocusOverlayManager.onAutoFocus(false /*success*/, false /*shutterDown*/);
+ focusOverlayManager.onAutoFocus(false /*success*/, false /*shutterDown*/);
}
}
@Override // From FocusOverlayManager.Listener
public void cancelAutoFocus() {
- if (mCamera == null) {
+ if (camera == null) {
return;
}
try {
- mCamera.cancelAutoFocus();
+ camera.cancelAutoFocus();
} catch (final RuntimeException e) {
// Ignore
LogUtil.e(
@@ -817,19 +819,19 @@ public class CameraManager implements FocusOverlayManager.Listener {
@Override // From FocusOverlayManager.Listener
public void setFocusParameters() {
- if (mCamera == null) {
+ if (camera == null) {
return;
}
try {
- final Camera.Parameters parameters = mCamera.getParameters();
- parameters.setFocusMode(mFocusOverlayManager.getFocusMode());
+ final Camera.Parameters parameters = camera.getParameters();
+ parameters.setFocusMode(focusOverlayManager.getFocusMode());
if (parameters.getMaxNumFocusAreas() > 0) {
// Don't set focus areas (even to null) if focus areas aren't supported, camera may
// crash
- parameters.setFocusAreas(mFocusOverlayManager.getFocusAreas());
+ parameters.setFocusAreas(focusOverlayManager.getFocusAreas());
}
- parameters.setMeteringAreas(mFocusOverlayManager.getMeteringAreas());
- mCamera.setParameters(parameters);
+ parameters.setMeteringAreas(focusOverlayManager.getMeteringAreas());
+ camera.setParameters(parameters);
} catch (final RuntimeException e) {
// This occurs when the device is out of space or when the camera is locked
LogUtil.e(
@@ -839,9 +841,9 @@ public class CameraManager implements FocusOverlayManager.Listener {
}
public void resetPreview() {
- mCamera.startPreview();
- if (mCameraPreview != null) {
- mCameraPreview.setFocusable(true);
+ camera.startPreview();
+ if (cameraPreview != null) {
+ cameraPreview.setFocusable(true);
}
}
@@ -855,6 +857,6 @@ public class CameraManager implements FocusOverlayManager.Listener {
@VisibleForTesting
public void resetCameraManager() {
- sInstance = null;
+ instance = null;
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/CameraPreview.java b/java/com/android/dialer/callcomposer/camera/CameraPreview.java
index eaea78961..901833b95 100644
--- a/java/com/android/dialer/callcomposer/camera/CameraPreview.java
+++ b/java/com/android/dialer/callcomposer/camera/CameraPreview.java
@@ -45,30 +45,30 @@ public class CameraPreview {
void setShown();
}
- private int mCameraWidth = -1;
- private int mCameraHeight = -1;
- private boolean mTabHasBeenShown = false;
- private OnTouchListener mListener;
+ private int cameraWidth = -1;
+ private int cameraHeight = -1;
+ private boolean tabHasBeenShown = false;
+ private OnTouchListener listener;
- private final CameraPreviewHost mHost;
+ private final CameraPreviewHost host;
public CameraPreview(final CameraPreviewHost host) {
Assert.isNotNull(host);
Assert.isNotNull(host.getView());
- mHost = host;
+ this.host = host;
}
// This is set when the tab is actually selected.
public void setShown() {
- mTabHasBeenShown = true;
+ tabHasBeenShown = true;
maybeOpenCamera();
}
// Opening camera is very expensive. Most of the ANR reports seem to be related to the camera.
// So we delay until the camera is actually needed. See a bug
private void maybeOpenCamera() {
- boolean visible = mHost.getView().getVisibility() == View.VISIBLE;
- if (mTabHasBeenShown && visible && PermissionsUtil.hasCameraPermissions(getContext())) {
+ boolean visible = host.getView().getVisibility() == View.VISIBLE;
+ if (tabHasBeenShown && visible && PermissionsUtil.hasCameraPermissions(getContext())) {
CameraManager.get().openCamera();
}
}
@@ -77,20 +77,20 @@ public class CameraPreview {
switch (orientation) {
case 0:
case 180:
- mCameraWidth = size.width;
- mCameraHeight = size.height;
+ cameraWidth = size.width;
+ cameraHeight = size.height;
break;
case 90:
case 270:
default:
- mCameraWidth = size.height;
- mCameraHeight = size.width;
+ cameraWidth = size.height;
+ cameraHeight = size.width;
}
- mHost.getView().requestLayout();
+ host.getView().requestLayout();
}
public int getWidthMeasureSpec(final int widthMeasureSpec, final int heightMeasureSpec) {
- if (mCameraHeight >= 0) {
+ if (cameraHeight >= 0) {
final int width = View.MeasureSpec.getSize(widthMeasureSpec);
return MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
} else {
@@ -99,10 +99,10 @@ public class CameraPreview {
}
public int getHeightMeasureSpec(final int widthMeasureSpec, final int heightMeasureSpec) {
- if (mCameraHeight >= 0) {
+ if (cameraHeight >= 0) {
final int orientation = getContext().getResources().getConfiguration().orientation;
final int width = View.MeasureSpec.getSize(widthMeasureSpec);
- final float aspectRatio = (float) mCameraWidth / (float) mCameraHeight;
+ final float aspectRatio = (float) cameraWidth / (float) cameraHeight;
int height;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
height = (int) (width * aspectRatio);
@@ -128,20 +128,20 @@ public class CameraPreview {
}
public Context getContext() {
- return mHost.getView().getContext();
+ return host.getView().getContext();
}
public void setOnTouchListener(final View.OnTouchListener listener) {
- mListener = listener;
- mHost.getView().setOnTouchListener(listener);
+ this.listener = listener;
+ host.getView().setOnTouchListener(listener);
}
public void setFocusable(boolean focusable) {
- mHost.getView().setOnTouchListener(focusable ? mListener : null);
+ host.getView().setOnTouchListener(focusable ? listener : null);
}
public int getHeight() {
- return mHost.getView().getHeight();
+ return host.getView().getHeight();
}
public void onAttachedToWindow() {
@@ -162,7 +162,7 @@ public class CameraPreview {
/** @return True if the view is valid and prepared for the camera to start showing the preview */
public boolean isValid() {
- return mHost.isValid();
+ return host.isValid();
}
/**
@@ -172,6 +172,6 @@ public class CameraPreview {
* @throws IOException Which is caught by the CameraManager to display an error
*/
public void startPreview(final Camera camera) throws IOException {
- mHost.startPreview(camera);
+ host.startPreview(camera);
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/HardwareCameraPreview.java b/java/com/android/dialer/callcomposer/camera/HardwareCameraPreview.java
index c0d61f3f8..3373f1a8d 100644
--- a/java/com/android/dialer/callcomposer/camera/HardwareCameraPreview.java
+++ b/java/com/android/dialer/callcomposer/camera/HardwareCameraPreview.java
@@ -35,23 +35,23 @@ import java.io.IOException;
* implementations of the shared methods are delegated to CameraPreview
*/
public class HardwareCameraPreview extends TextureView implements CameraPreview.CameraPreviewHost {
- private CameraPreview mPreview;
+ private CameraPreview preview;
public HardwareCameraPreview(final Context context, final AttributeSet attrs) {
super(context, attrs);
- mPreview = new CameraPreview(this);
+ preview = new CameraPreview(this);
setSurfaceTextureListener(
new SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(
final SurfaceTexture surfaceTexture, final int i, final int i2) {
- CameraManager.get().setSurface(mPreview);
+ CameraManager.get().setSurface(preview);
}
@Override
public void onSurfaceTextureSizeChanged(
final SurfaceTexture surfaceTexture, final int i, final int i2) {
- CameraManager.get().setSurface(mPreview);
+ CameraManager.get().setSurface(preview);
}
@Override
@@ -62,44 +62,44 @@ public class HardwareCameraPreview extends TextureView implements CameraPreview.
@Override
public void onSurfaceTextureUpdated(final SurfaceTexture surfaceTexture) {
- CameraManager.get().setSurface(mPreview);
+ CameraManager.get().setSurface(preview);
}
});
}
@Override
public void setShown() {
- mPreview.setShown();
+ preview.setShown();
}
@Override
protected void onVisibilityChanged(final View changedView, final int visibility) {
super.onVisibilityChanged(changedView, visibility);
- mPreview.onVisibilityChanged(visibility);
+ preview.onVisibilityChanged(visibility);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- mPreview.onDetachedFromWindow();
+ preview.onDetachedFromWindow();
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mPreview.onAttachedToWindow();
+ preview.onAttachedToWindow();
}
@Override
protected void onRestoreInstanceState(final Parcelable state) {
super.onRestoreInstanceState(state);
- mPreview.onRestoreInstanceState();
+ preview.onRestoreInstanceState();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- widthMeasureSpec = mPreview.getWidthMeasureSpec(widthMeasureSpec, heightMeasureSpec);
- heightMeasureSpec = mPreview.getHeightMeasureSpec(widthMeasureSpec, heightMeasureSpec);
+ widthMeasureSpec = preview.getWidthMeasureSpec(widthMeasureSpec, heightMeasureSpec);
+ heightMeasureSpec = preview.getHeightMeasureSpec(widthMeasureSpec, heightMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@@ -120,6 +120,6 @@ public class HardwareCameraPreview extends TextureView implements CameraPreview.
@Override
public void onCameraPermissionGranted() {
- mPreview.onCameraPermissionGranted();
+ preview.onCameraPermissionGranted();
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/ImagePersistWorker.java b/java/com/android/dialer/callcomposer/camera/ImagePersistWorker.java
index 26b0bde00..69f546929 100644
--- a/java/com/android/dialer/callcomposer/camera/ImagePersistWorker.java
+++ b/java/com/android/dialer/callcomposer/camera/ImagePersistWorker.java
@@ -40,11 +40,11 @@ import java.io.OutputStream;
/** Persisting image routine. */
@TargetApi(VERSION_CODES.M)
public class ImagePersistWorker implements Worker<Void, Result> {
- private int mWidth;
- private int mHeight;
- private final float mHeightPercent;
- private final byte[] mBytes;
- private final Context mContext;
+ private int width;
+ private int height;
+ private final float heightPercent;
+ private final byte[] bytes;
+ private final Context context;
@AutoValue
abstract static class Result {
@@ -81,16 +81,16 @@ public class ImagePersistWorker implements Worker<Void, Result> {
Assert.checkArgument(heightPercent >= 0 && heightPercent <= 1);
Assert.isNotNull(bytes);
Assert.isNotNull(context);
- mWidth = width;
- mHeight = height;
- mHeightPercent = heightPercent;
- mBytes = bytes;
- mContext = context;
+ this.width = width;
+ this.height = height;
+ this.heightPercent = heightPercent;
+ this.bytes = bytes;
+ this.context = context;
}
@Override
public Result doInBackground(Void unused) throws Exception {
- File outputFile = DialerUtils.createShareableFile(mContext);
+ File outputFile = DialerUtils.createShareableFile(context);
try (OutputStream outputStream = new FileOutputStream(outputFile)) {
writeClippedBitmap(outputStream);
@@ -99,9 +99,9 @@ public class ImagePersistWorker implements Worker<Void, Result> {
return Result.builder()
.setUri(
FileProvider.getUriForFile(
- mContext, Constants.get().getFileProviderAuthority(), outputFile))
- .setWidth(mWidth)
- .setHeight(mHeight)
+ context, Constants.get().getFileProviderAuthority(), outputFile))
+ .setWidth(width)
+ .setHeight(height)
.build();
}
@@ -109,7 +109,7 @@ public class ImagePersistWorker implements Worker<Void, Result> {
int orientation = android.media.ExifInterface.ORIENTATION_UNDEFINED;
final ExifInterface exifInterface = new ExifInterface();
try {
- exifInterface.readExif(mBytes);
+ exifInterface.readExif(bytes);
final Integer orientationValue = exifInterface.getTagIntValue(ExifInterface.TAG_ORIENTATION);
if (orientationValue != null) {
orientation = orientationValue.intValue();
@@ -119,25 +119,25 @@ public class ImagePersistWorker implements Worker<Void, Result> {
}
ExifInterface.OrientationParams params = ExifInterface.getOrientationParams(orientation);
- Bitmap bitmap = BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length);
+ Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
final int clippedWidth;
final int clippedHeight;
if (params.invertDimensions) {
- Assert.checkState(mWidth == bitmap.getHeight());
- Assert.checkState(mHeight == bitmap.getWidth());
- clippedWidth = (int) (mHeight * mHeightPercent);
- clippedHeight = mWidth;
+ Assert.checkState(width == bitmap.getHeight());
+ Assert.checkState(height == bitmap.getWidth());
+ clippedWidth = (int) (height * heightPercent);
+ clippedHeight = width;
} else {
- Assert.checkState(mWidth == bitmap.getWidth());
- Assert.checkState(mHeight == bitmap.getHeight());
- clippedWidth = mWidth;
- clippedHeight = (int) (mHeight * mHeightPercent);
+ Assert.checkState(width == bitmap.getWidth());
+ Assert.checkState(height == bitmap.getHeight());
+ clippedWidth = width;
+ clippedHeight = (int) (height * heightPercent);
}
int offsetTop = (bitmap.getHeight() - clippedHeight) / 2;
int offsetLeft = (bitmap.getWidth() - clippedWidth) / 2;
- mWidth = clippedWidth;
- mHeight = clippedHeight;
+ width = clippedWidth;
+ height = clippedHeight;
Bitmap clippedBitmap =
Bitmap.createBitmap(bitmap, offsetLeft, offsetTop, clippedWidth, clippedHeight);
diff --git a/java/com/android/dialer/callcomposer/camera/SoftwareCameraPreview.java b/java/com/android/dialer/callcomposer/camera/SoftwareCameraPreview.java
index fe2c600df..58458a894 100644
--- a/java/com/android/dialer/callcomposer/camera/SoftwareCameraPreview.java
+++ b/java/com/android/dialer/callcomposer/camera/SoftwareCameraPreview.java
@@ -33,17 +33,17 @@ import java.io.IOException;
* implementations of the shared methods are delegated to CameraPreview
*/
public class SoftwareCameraPreview extends SurfaceView implements CameraPreview.CameraPreviewHost {
- private final CameraPreview mPreview;
+ private final CameraPreview preview;
public SoftwareCameraPreview(final Context context) {
super(context);
- mPreview = new CameraPreview(this);
+ preview = new CameraPreview(this);
getHolder()
.addCallback(
new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(final SurfaceHolder surfaceHolder) {
- CameraManager.get().setSurface(mPreview);
+ CameraManager.get().setSurface(preview);
}
@Override
@@ -52,7 +52,7 @@ public class SoftwareCameraPreview extends SurfaceView implements CameraPreview.
final int format,
final int width,
final int height) {
- CameraManager.get().setSurface(mPreview);
+ CameraManager.get().setSurface(preview);
}
@Override
@@ -64,37 +64,37 @@ public class SoftwareCameraPreview extends SurfaceView implements CameraPreview.
@Override
public void setShown() {
- mPreview.setShown();
+ preview.setShown();
}
@Override
protected void onVisibilityChanged(final View changedView, final int visibility) {
super.onVisibilityChanged(changedView, visibility);
- mPreview.onVisibilityChanged(visibility);
+ preview.onVisibilityChanged(visibility);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- mPreview.onDetachedFromWindow();
+ preview.onDetachedFromWindow();
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mPreview.onAttachedToWindow();
+ preview.onAttachedToWindow();
}
@Override
protected void onRestoreInstanceState(final Parcelable state) {
super.onRestoreInstanceState(state);
- mPreview.onRestoreInstanceState();
+ preview.onRestoreInstanceState();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- widthMeasureSpec = mPreview.getWidthMeasureSpec(widthMeasureSpec, heightMeasureSpec);
- heightMeasureSpec = mPreview.getHeightMeasureSpec(widthMeasureSpec, heightMeasureSpec);
+ widthMeasureSpec = preview.getWidthMeasureSpec(widthMeasureSpec, heightMeasureSpec);
+ heightMeasureSpec = preview.getHeightMeasureSpec(widthMeasureSpec, heightMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@@ -115,6 +115,6 @@ public class SoftwareCameraPreview extends SurfaceView implements CameraPreview.
@Override
public void onCameraPermissionGranted() {
- mPreview.onCameraPermissionGranted();
+ preview.onCameraPermissionGranted();
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/camerafocus/FocusOverlayManager.java b/java/com/android/dialer/callcomposer/camera/camerafocus/FocusOverlayManager.java
index a5edf3309..c3f1a5ddd 100644
--- a/java/com/android/dialer/callcomposer/camera/camerafocus/FocusOverlayManager.java
+++ b/java/com/android/dialer/callcomposer/camera/camerafocus/FocusOverlayManager.java
@@ -54,7 +54,7 @@ public class FocusOverlayManager {
private static final int RESET_TOUCH_FOCUS = 0;
private static final int RESET_TOUCH_FOCUS_DELAY = 3000;
- private int mState = STATE_IDLE;
+ private int state = STATE_IDLE;
private static final int STATE_IDLE = 0; // Focus is not active.
private static final int STATE_FOCUSING = 1; // Focus is in progress.
// Focus is in progress and the camera should take a picture after focus finishes.
@@ -62,24 +62,24 @@ public class FocusOverlayManager {
private static final int STATE_SUCCESS = 3; // Focus finishes and succeeds.
private static final int STATE_FAIL = 4; // Focus finishes and fails.
- private boolean mInitialized;
- private boolean mFocusAreaSupported;
- private boolean mMeteringAreaSupported;
- private boolean mLockAeAwbNeeded;
- private boolean mAeAwbLock;
- private Matrix mMatrix;
-
- private PieRenderer mPieRenderer;
-
- private int mPreviewWidth; // The width of the preview frame layout.
- private int mPreviewHeight; // The height of the preview frame layout.
- private boolean mMirror; // true if the camera is front-facing.
- private List<Area> mFocusArea; // focus area in driver format
- private List<Area> mMeteringArea; // metering area in driver format
- private String mFocusMode;
- private Parameters mParameters;
- private Handler mHandler;
- private Listener mListener;
+ private boolean initialized;
+ private boolean focusAreaSupported;
+ private boolean meteringAreaSupported;
+ private boolean lockAeAwbNeeded;
+ private boolean aeAwbLock;
+ private Matrix matrix;
+
+ private PieRenderer pieRenderer;
+
+ private int previewWidth; // The width of the preview frame layout.
+ private int previewHeight; // The height of the preview frame layout.
+ private boolean mirror; // true if the camera is front-facing.
+ private List<Area> focusArea; // focus area in driver format
+ private List<Area> meteringArea; // metering area in driver format
+ private String focusMode;
+ private Parameters parameters;
+ private Handler handler;
+ private Listener listener;
/** Listener used for the focus indicator to communicate back to the camera. */
public interface Listener {
@@ -110,14 +110,14 @@ public class FocusOverlayManager {
}
public FocusOverlayManager(Listener listener, Looper looper) {
- mHandler = new MainHandler(looper);
- mMatrix = new Matrix();
- mListener = listener;
+ handler = new MainHandler(looper);
+ matrix = new Matrix();
+ this.listener = listener;
}
public void setFocusRenderer(PieRenderer renderer) {
- mPieRenderer = renderer;
- mInitialized = (mMatrix != null);
+ pieRenderer = renderer;
+ initialized = (matrix != null);
}
public void setParameters(Parameters parameters) {
@@ -128,182 +128,176 @@ public class FocusOverlayManager {
if (parameters == null) {
return;
}
- mParameters = parameters;
- mFocusAreaSupported = isFocusAreaSupported(parameters);
- mMeteringAreaSupported = isMeteringAreaSupported(parameters);
- mLockAeAwbNeeded =
- (isAutoExposureLockSupported(mParameters) || isAutoWhiteBalanceLockSupported(mParameters));
+ this.parameters = parameters;
+ focusAreaSupported = isFocusAreaSupported(parameters);
+ meteringAreaSupported = isMeteringAreaSupported(parameters);
+ lockAeAwbNeeded =
+ (isAutoExposureLockSupported(this.parameters)
+ || isAutoWhiteBalanceLockSupported(this.parameters));
}
public void setPreviewSize(int previewWidth, int previewHeight) {
- if (mPreviewWidth != previewWidth || mPreviewHeight != previewHeight) {
- mPreviewWidth = previewWidth;
- mPreviewHeight = previewHeight;
+ if (this.previewWidth != previewWidth || this.previewHeight != previewHeight) {
+ this.previewWidth = previewWidth;
+ this.previewHeight = previewHeight;
setMatrix();
}
}
public void setMirror(boolean mirror) {
- mMirror = mirror;
+ this.mirror = mirror;
setMatrix();
}
private void setMatrix() {
- if (mPreviewWidth != 0 && mPreviewHeight != 0) {
+ if (previewWidth != 0 && previewHeight != 0) {
Matrix matrix = new Matrix();
- prepareMatrix(matrix, mMirror, mPreviewWidth, mPreviewHeight);
+ prepareMatrix(matrix, mirror, previewWidth, previewHeight);
// In face detection, the matrix converts the driver coordinates to UI
// coordinates. In tap focus, the inverted matrix converts the UI
// coordinates to driver coordinates.
- matrix.invert(mMatrix);
- mInitialized = (mPieRenderer != null);
+ matrix.invert(this.matrix);
+ initialized = (pieRenderer != null);
}
}
private void lockAeAwbIfNeeded() {
- if (mLockAeAwbNeeded && !mAeAwbLock) {
- mAeAwbLock = true;
- mListener.setFocusParameters();
+ if (lockAeAwbNeeded && !aeAwbLock) {
+ aeAwbLock = true;
+ listener.setFocusParameters();
}
}
public void onAutoFocus(boolean focused, boolean shutterButtonPressed) {
- if (mState == STATE_FOCUSING_SNAP_ON_FINISH) {
+ if (state == STATE_FOCUSING_SNAP_ON_FINISH) {
// Take the picture no matter focus succeeds or fails. No need
// to play the AF sound if we're about to play the shutter
// sound.
if (focused) {
- mState = STATE_SUCCESS;
+ state = STATE_SUCCESS;
} else {
- mState = STATE_FAIL;
+ state = STATE_FAIL;
}
updateFocusUI();
capture();
- } else if (mState == STATE_FOCUSING) {
+ } else if (state == STATE_FOCUSING) {
// This happens when (1) user is half-pressing the focus key or
// (2) touch focus is triggered. Play the focus tone. Do not
// take the picture now.
if (focused) {
- mState = STATE_SUCCESS;
+ state = STATE_SUCCESS;
} else {
- mState = STATE_FAIL;
+ state = STATE_FAIL;
}
updateFocusUI();
// If this is triggered by touch focus, cancel focus after a
// while.
- if (mFocusArea != null) {
- mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
+ if (focusArea != null) {
+ handler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
}
if (shutterButtonPressed) {
// Lock AE & AWB so users can half-press shutter and recompose.
lockAeAwbIfNeeded();
}
- } else if (mState == STATE_IDLE) {
+ } else if (state == STATE_IDLE) {
// User has released the focus key before focus completes.
// Do nothing.
}
}
public void onAutoFocusMoving(boolean moving) {
- if (!mInitialized) {
+ if (!initialized) {
return;
}
// Ignore if we have requested autofocus. This method only handles
// continuous autofocus.
- if (mState != STATE_IDLE) {
+ if (state != STATE_IDLE) {
return;
}
if (moving) {
- mPieRenderer.showStart();
+ pieRenderer.showStart();
} else {
- mPieRenderer.showSuccess(true);
+ pieRenderer.showSuccess(true);
}
}
private void initializeFocusAreas(
int focusWidth, int focusHeight, int x, int y, int previewWidth, int previewHeight) {
- if (mFocusArea == null) {
- mFocusArea = new ArrayList<>();
- mFocusArea.add(new Area(new Rect(), 1));
+ if (focusArea == null) {
+ focusArea = new ArrayList<>();
+ focusArea.add(new Area(new Rect(), 1));
}
// Convert the coordinates to driver format.
calculateTapArea(
- focusWidth, focusHeight, 1f, x, y, previewWidth, previewHeight, mFocusArea.get(0).rect);
+ focusWidth, focusHeight, 1f, x, y, previewWidth, previewHeight, focusArea.get(0).rect);
}
private void initializeMeteringAreas(
int focusWidth, int focusHeight, int x, int y, int previewWidth, int previewHeight) {
- if (mMeteringArea == null) {
- mMeteringArea = new ArrayList<>();
- mMeteringArea.add(new Area(new Rect(), 1));
+ if (meteringArea == null) {
+ meteringArea = new ArrayList<>();
+ meteringArea.add(new Area(new Rect(), 1));
}
// Convert the coordinates to driver format.
// AE area is bigger because exposure is sensitive and
// easy to over- or underexposure if area is too small.
calculateTapArea(
- focusWidth,
- focusHeight,
- 1.5f,
- x,
- y,
- previewWidth,
- previewHeight,
- mMeteringArea.get(0).rect);
+ focusWidth, focusHeight, 1.5f, x, y, previewWidth, previewHeight, meteringArea.get(0).rect);
}
public void onSingleTapUp(int x, int y) {
- if (!mInitialized || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
+ if (!initialized || state == STATE_FOCUSING_SNAP_ON_FINISH) {
return;
}
// Let users be able to cancel previous touch focus.
- if ((mFocusArea != null)
- && (mState == STATE_FOCUSING || mState == STATE_SUCCESS || mState == STATE_FAIL)) {
+ if ((focusArea != null)
+ && (state == STATE_FOCUSING || state == STATE_SUCCESS || state == STATE_FAIL)) {
cancelAutoFocus();
}
// Initialize variables.
- int focusWidth = mPieRenderer.getSize();
- int focusHeight = mPieRenderer.getSize();
- if (focusWidth == 0 || mPieRenderer.getWidth() == 0 || mPieRenderer.getHeight() == 0) {
+ int focusWidth = pieRenderer.getSize();
+ int focusHeight = pieRenderer.getSize();
+ if (focusWidth == 0 || pieRenderer.getWidth() == 0 || pieRenderer.getHeight() == 0) {
return;
}
- int previewWidth = mPreviewWidth;
- int previewHeight = mPreviewHeight;
+ int previewWidth = this.previewWidth;
+ int previewHeight = this.previewHeight;
// Initialize mFocusArea.
- if (mFocusAreaSupported) {
+ if (focusAreaSupported) {
initializeFocusAreas(focusWidth, focusHeight, x, y, previewWidth, previewHeight);
}
// Initialize mMeteringArea.
- if (mMeteringAreaSupported) {
+ if (meteringAreaSupported) {
initializeMeteringAreas(focusWidth, focusHeight, x, y, previewWidth, previewHeight);
}
// Use margin to set the focus indicator to the touched area.
- mPieRenderer.setFocus(x, y);
+ pieRenderer.setFocus(x, y);
// Set the focus area and metering area.
- mListener.setFocusParameters();
- if (mFocusAreaSupported) {
+ listener.setFocusParameters();
+ if (focusAreaSupported) {
autoFocus();
} else { // Just show the indicator in all other cases.
updateFocusUI();
// Reset the metering area in 3 seconds.
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
- mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
+ handler.removeMessages(RESET_TOUCH_FOCUS);
+ handler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
}
}
public void onPreviewStarted() {
- mState = STATE_IDLE;
+ state = STATE_IDLE;
}
public void onPreviewStopped() {
// If auto focus was in progress, it would have been stopped.
- mState = STATE_IDLE;
+ state = STATE_IDLE;
resetTouchFocus();
updateFocusUI();
}
@@ -314,10 +308,10 @@ public class FocusOverlayManager {
private void autoFocus() {
LogUtil.v("FocusOverlayManager.autoFocus", "Start autofocus.");
- mListener.autoFocus();
- mState = STATE_FOCUSING;
+ listener.autoFocus();
+ state = STATE_FOCUSING;
updateFocusUI();
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
+ handler.removeMessages(RESET_TOUCH_FOCUS);
}
public void cancelAutoFocus() {
@@ -327,57 +321,57 @@ public class FocusOverlayManager {
// Otherwise, focus mode stays at auto and the tap area passed to the
// driver is not reset.
resetTouchFocus();
- mListener.cancelAutoFocus();
- mState = STATE_IDLE;
+ listener.cancelAutoFocus();
+ state = STATE_IDLE;
updateFocusUI();
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
+ handler.removeMessages(RESET_TOUCH_FOCUS);
}
private void capture() {
- if (mListener.capture()) {
- mState = STATE_IDLE;
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
+ if (listener.capture()) {
+ state = STATE_IDLE;
+ handler.removeMessages(RESET_TOUCH_FOCUS);
}
}
public String getFocusMode() {
- List<String> supportedFocusModes = mParameters.getSupportedFocusModes();
+ List<String> supportedFocusModes = parameters.getSupportedFocusModes();
- if (mFocusAreaSupported && mFocusArea != null) {
+ if (focusAreaSupported && focusArea != null) {
// Always use autofocus in tap-to-focus.
- mFocusMode = Parameters.FOCUS_MODE_AUTO;
+ focusMode = Parameters.FOCUS_MODE_AUTO;
} else {
- mFocusMode = Parameters.FOCUS_MODE_CONTINUOUS_PICTURE;
+ focusMode = Parameters.FOCUS_MODE_CONTINUOUS_PICTURE;
}
- if (!isSupported(mFocusMode, supportedFocusModes)) {
+ if (!isSupported(focusMode, supportedFocusModes)) {
// For some reasons, the driver does not support the current
// focus mode. Fall back to auto.
- if (isSupported(Parameters.FOCUS_MODE_AUTO, mParameters.getSupportedFocusModes())) {
- mFocusMode = Parameters.FOCUS_MODE_AUTO;
+ if (isSupported(Parameters.FOCUS_MODE_AUTO, parameters.getSupportedFocusModes())) {
+ focusMode = Parameters.FOCUS_MODE_AUTO;
} else {
- mFocusMode = mParameters.getFocusMode();
+ focusMode = parameters.getFocusMode();
}
}
- return mFocusMode;
+ return focusMode;
}
public List<Area> getFocusAreas() {
- return mFocusArea;
+ return focusArea;
}
public List<Area> getMeteringAreas() {
- return mMeteringArea;
+ return meteringArea;
}
private void updateFocusUI() {
- if (!mInitialized) {
+ if (!initialized) {
return;
}
- FocusIndicator focusIndicator = mPieRenderer;
+ FocusIndicator focusIndicator = pieRenderer;
- if (mState == STATE_IDLE) {
- if (mFocusArea == null) {
+ if (state == STATE_IDLE) {
+ if (focusArea == null) {
focusIndicator.clear();
} else {
// Users touch on the preview and the indicator represents the
@@ -385,30 +379,30 @@ public class FocusOverlayManager {
// autoFocus call is not required.
focusIndicator.showStart();
}
- } else if (mState == STATE_FOCUSING || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
+ } else if (state == STATE_FOCUSING || state == STATE_FOCUSING_SNAP_ON_FINISH) {
focusIndicator.showStart();
} else {
- if (Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)) {
+ if (Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(focusMode)) {
// TODO(blemmon): check HAL behavior and decide if this can be removed.
focusIndicator.showSuccess(false);
- } else if (mState == STATE_SUCCESS) {
+ } else if (state == STATE_SUCCESS) {
focusIndicator.showSuccess(false);
- } else if (mState == STATE_FAIL) {
+ } else if (state == STATE_FAIL) {
focusIndicator.showFail(false);
}
}
}
private void resetTouchFocus() {
- if (!mInitialized) {
+ if (!initialized) {
return;
}
// Put focus indicator to the center. clear reset position
- mPieRenderer.clear();
+ pieRenderer.clear();
- mFocusArea = null;
- mMeteringArea = null;
+ focusArea = null;
+ meteringArea = null;
}
private void calculateTapArea(
@@ -428,7 +422,7 @@ public class FocusOverlayManager {
int top = maxH > 0 ? clamp(y - areaHeight / 2, 0, maxH) : 0;
RectF rectF = new RectF(left, top, left + areaWidth, top + areaHeight);
- mMatrix.mapRect(rectF);
+ matrix.mapRect(rectF);
rectFToRect(rectF, rect);
}
diff --git a/java/com/android/dialer/callcomposer/camera/camerafocus/OverlayRenderer.java b/java/com/android/dialer/callcomposer/camera/camerafocus/OverlayRenderer.java
index 4a3b522bb..ac9512ed7 100644
--- a/java/com/android/dialer/callcomposer/camera/camerafocus/OverlayRenderer.java
+++ b/java/com/android/dialer/callcomposer/camera/camerafocus/OverlayRenderer.java
@@ -23,21 +23,21 @@ import android.view.MotionEvent;
/** Abstract class that all Camera overlays should implement. */
public abstract class OverlayRenderer implements RenderOverlay.Renderer {
- protected RenderOverlay mOverlay;
+ protected RenderOverlay overlay;
- private int mLeft;
- private int mTop;
- private int mRight;
- private int mBottom;
- private boolean mVisible;
+ private int left;
+ private int top;
+ private int right;
+ private int bottom;
+ private boolean visible;
public void setVisible(boolean vis) {
- mVisible = vis;
+ visible = vis;
update();
}
public boolean isVisible() {
- return mVisible;
+ return visible;
}
// default does not handle touch
@@ -55,43 +55,43 @@ public abstract class OverlayRenderer implements RenderOverlay.Renderer {
@Override
public void draw(Canvas canvas) {
- if (mVisible) {
+ if (visible) {
onDraw(canvas);
}
}
@Override
public void setOverlay(RenderOverlay overlay) {
- mOverlay = overlay;
+ this.overlay = overlay;
}
@Override
public void layout(int left, int top, int right, int bottom) {
- mLeft = left;
- mRight = right;
- mTop = top;
- mBottom = bottom;
+ this.left = left;
+ this.right = right;
+ this.top = top;
+ this.bottom = bottom;
}
protected Context getContext() {
- if (mOverlay != null) {
- return mOverlay.getContext();
+ if (overlay != null) {
+ return overlay.getContext();
} else {
return null;
}
}
public int getWidth() {
- return mRight - mLeft;
+ return right - left;
}
public int getHeight() {
- return mBottom - mTop;
+ return bottom - top;
}
protected void update() {
- if (mOverlay != null) {
- mOverlay.update();
+ if (overlay != null) {
+ overlay.update();
}
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/camerafocus/PieItem.java b/java/com/android/dialer/callcomposer/camera/camerafocus/PieItem.java
index 86f69c0ae..1c442958e 100644
--- a/java/com/android/dialer/callcomposer/camera/camerafocus/PieItem.java
+++ b/java/com/android/dialer/callcomposer/camera/camerafocus/PieItem.java
@@ -30,54 +30,54 @@ public class PieItem {
void onClick(PieItem item);
}
- private Drawable mDrawable;
+ private Drawable drawable;
private int level;
- private float mCenter;
+ private float center;
private float start;
private float sweep;
private float animate;
private int inner;
private int outer;
- private boolean mSelected;
- private boolean mEnabled;
- private List<PieItem> mItems;
- private Path mPath;
- private OnClickListener mOnClickListener;
- private float mAlpha;
+ private boolean selected;
+ private boolean enabled;
+ private List<PieItem> items;
+ private Path path;
+ private OnClickListener onClickListener;
+ private float alpha;
// Gray out the view when disabled
private static final float ENABLED_ALPHA = 1;
private static final float DISABLED_ALPHA = (float) 0.3;
public PieItem(Drawable drawable, int level) {
- mDrawable = drawable;
+ this.drawable = drawable;
this.level = level;
setAlpha(1f);
- mEnabled = true;
+ enabled = true;
setAnimationAngle(getAnimationAngle());
start = -1;
- mCenter = -1;
+ center = -1;
}
public boolean hasItems() {
- return mItems != null;
+ return items != null;
}
public List<PieItem> getItems() {
- return mItems;
+ return items;
}
public void setPath(Path p) {
- mPath = p;
+ path = p;
}
public Path getPath() {
- return mPath;
+ return path;
}
public void setAlpha(float alpha) {
- mAlpha = alpha;
- mDrawable.setAlpha((int) (255 * alpha));
+ this.alpha = alpha;
+ drawable.setAlpha((int) (255 * alpha));
}
public void setAnimationAngle(float a) {
@@ -89,8 +89,8 @@ public class PieItem {
}
public void setEnabled(boolean enabled) {
- mEnabled = enabled;
- if (mEnabled) {
+ this.enabled = enabled;
+ if (this.enabled) {
setAlpha(ENABLED_ALPHA);
} else {
setAlpha(DISABLED_ALPHA);
@@ -98,15 +98,15 @@ public class PieItem {
}
public boolean isEnabled() {
- return mEnabled;
+ return enabled;
}
public void setSelected(boolean s) {
- mSelected = s;
+ selected = s;
}
public boolean isSelected() {
- return mSelected;
+ return selected;
}
public int getLevel() {
@@ -121,7 +121,7 @@ public class PieItem {
}
public float getCenter() {
- return mCenter;
+ return center;
}
public float getStart() {
@@ -145,35 +145,35 @@ public class PieItem {
}
public void setOnClickListener(OnClickListener listener) {
- mOnClickListener = listener;
+ onClickListener = listener;
}
public void performClick() {
- if (mOnClickListener != null) {
- mOnClickListener.onClick(this);
+ if (onClickListener != null) {
+ onClickListener.onClick(this);
}
}
public int getIntrinsicWidth() {
- return mDrawable.getIntrinsicWidth();
+ return drawable.getIntrinsicWidth();
}
public int getIntrinsicHeight() {
- return mDrawable.getIntrinsicHeight();
+ return drawable.getIntrinsicHeight();
}
public void setBounds(int left, int top, int right, int bottom) {
- mDrawable.setBounds(left, top, right, bottom);
+ drawable.setBounds(left, top, right, bottom);
}
public void draw(Canvas canvas) {
- mDrawable.draw(canvas);
+ drawable.draw(canvas);
}
public void setImageResource(Context context, int resId) {
Drawable d = context.getResources().getDrawable(resId).mutate();
- d.setBounds(mDrawable.getBounds());
- mDrawable = d;
- setAlpha(mAlpha);
+ d.setBounds(drawable.getBounds());
+ drawable = d;
+ setAlpha(alpha);
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/camerafocus/PieRenderer.java b/java/com/android/dialer/callcomposer/camera/camerafocus/PieRenderer.java
index 59b57b002..7629252e5 100644
--- a/java/com/android/dialer/callcomposer/camera/camerafocus/PieRenderer.java
+++ b/java/com/android/dialer/callcomposer/camera/camerafocus/PieRenderer.java
@@ -43,15 +43,15 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
// Sometimes continuous autofocus starts and stops several times quickly.
// These states are used to make sure the animation is run for at least some
// time.
- private volatile int mState;
- private ScaleAnimation mAnimation = new ScaleAnimation();
+ private volatile int state;
+ private ScaleAnimation animation = new ScaleAnimation();
private static final int STATE_IDLE = 0;
private static final int STATE_FOCUSING = 1;
private static final int STATE_FINISHING = 2;
private static final int STATE_PIE = 8;
- private Runnable mDisappear = new Disappear();
- private Animation.AnimationListener mEndAction = new EndAction();
+ private Runnable disappear = new Disappear();
+ private Animation.AnimationListener endAction = new EndAction();
private static final int SCALING_UP_TIME = 600;
private static final int SCALING_DOWN_TIME = 100;
private static final int DISAPPEAR_TIMEOUT = 200;
@@ -65,73 +65,73 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
private static final int MSG_CLOSE = 1;
private static final float PIE_SWEEP = (float) (Math.PI * 2 / 3);
// geometry
- private Point mCenter;
- private int mRadius;
- private int mRadiusInc;
+ private Point center;
+ private int radius;
+ private int radiusInc;
// the detection if touch is inside a slice is offset
// inbounds by this amount to allow the selection to show before the
// finger covers it
- private int mTouchOffset;
+ private int touchOffset;
- private List<PieItem> mItems;
+ private List<PieItem> items;
- private PieItem mOpenItem;
+ private PieItem openItem;
- private Paint mSelectedPaint;
- private Paint mSubPaint;
+ private Paint selectedPaint;
+ private Paint subPaint;
// touch handling
- private PieItem mCurrentItem;
-
- private Paint mFocusPaint;
- private int mSuccessColor;
- private int mFailColor;
- private int mCircleSize;
- private int mFocusX;
- private int mFocusY;
- private int mCenterX;
- private int mCenterY;
-
- private int mDialAngle;
- private RectF mCircle;
- private RectF mDial;
- private Point mPoint1;
- private Point mPoint2;
- private int mStartAnimationAngle;
- private boolean mFocused;
- private int mInnerOffset;
- private int mOuterStroke;
- private int mInnerStroke;
- private boolean mTapMode;
- private boolean mBlockFocus;
- private int mTouchSlopSquared;
- private Point mDown;
- private boolean mOpening;
- private LinearAnimation mXFade;
- private LinearAnimation mFadeIn;
- private volatile boolean mFocusCancelled;
-
- private Handler mHandler =
+ private PieItem currentItem;
+
+ private Paint focusPaint;
+ private int successColor;
+ private int failColor;
+ private int circleSize;
+ private int focusX;
+ private int focusY;
+ private int centerX;
+ private int centerY;
+
+ private int dialAngle;
+ private RectF circle;
+ private RectF dial;
+ private Point point1;
+ private Point point2;
+ private int startAnimationAngle;
+ private boolean focused;
+ private int innerOffset;
+ private int outerStroke;
+ private int innerStroke;
+ private boolean tapMode;
+ private boolean blockFocus;
+ private int touchSlopSquared;
+ private Point down;
+ private boolean opening;
+ private LinearAnimation xFade;
+ private LinearAnimation fadeIn;
+ private volatile boolean focusCancelled;
+
+ private Handler handler =
new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_OPEN:
- if (mListener != null) {
- mListener.onPieOpened(mCenter.x, mCenter.y);
+ if (listener != null) {
+ listener.onPieOpened(center.x, center.y);
}
break;
case MSG_CLOSE:
- if (mListener != null) {
- mListener.onPieClosed();
+ if (listener != null) {
+ listener.onPieClosed();
}
break;
}
}
};
- private PieListener mListener;
+ private PieListener listener;
/** Listener for the pie item to communicate back to the renderer. */
public interface PieListener {
@@ -141,7 +141,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
}
public void setPieListener(PieListener pl) {
- mListener = pl;
+ listener = pl;
}
public PieRenderer(Context context) {
@@ -150,67 +150,67 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
private void init(Context ctx) {
setVisible(false);
- mItems = new ArrayList<PieItem>();
+ items = new ArrayList<PieItem>();
Resources res = ctx.getResources();
- mRadius = res.getDimensionPixelSize(R.dimen.pie_radius_start);
- mCircleSize = mRadius - res.getDimensionPixelSize(R.dimen.focus_radius_offset);
- mRadiusInc = res.getDimensionPixelSize(R.dimen.pie_radius_increment);
- mTouchOffset = res.getDimensionPixelSize(R.dimen.pie_touch_offset);
- mCenter = new Point(0, 0);
- mSelectedPaint = new Paint();
- mSelectedPaint.setColor(Color.argb(255, 51, 181, 229));
- mSelectedPaint.setAntiAlias(true);
- mSubPaint = new Paint();
- mSubPaint.setAntiAlias(true);
- mSubPaint.setColor(Color.argb(200, 250, 230, 128));
- mFocusPaint = new Paint();
- mFocusPaint.setAntiAlias(true);
- mFocusPaint.setColor(Color.WHITE);
- mFocusPaint.setStyle(Paint.Style.STROKE);
- mSuccessColor = Color.GREEN;
- mFailColor = Color.RED;
- mCircle = new RectF();
- mDial = new RectF();
- mPoint1 = new Point();
- mPoint2 = new Point();
- mInnerOffset = res.getDimensionPixelSize(R.dimen.focus_inner_offset);
- mOuterStroke = res.getDimensionPixelSize(R.dimen.focus_outer_stroke);
- mInnerStroke = res.getDimensionPixelSize(R.dimen.focus_inner_stroke);
- mState = STATE_IDLE;
- mBlockFocus = false;
- mTouchSlopSquared = ViewConfiguration.get(ctx).getScaledTouchSlop();
- mTouchSlopSquared = mTouchSlopSquared * mTouchSlopSquared;
- mDown = new Point();
+ radius = res.getDimensionPixelSize(R.dimen.pie_radius_start);
+ circleSize = radius - res.getDimensionPixelSize(R.dimen.focus_radius_offset);
+ radiusInc = res.getDimensionPixelSize(R.dimen.pie_radius_increment);
+ touchOffset = res.getDimensionPixelSize(R.dimen.pie_touch_offset);
+ center = new Point(0, 0);
+ selectedPaint = new Paint();
+ selectedPaint.setColor(Color.argb(255, 51, 181, 229));
+ selectedPaint.setAntiAlias(true);
+ subPaint = new Paint();
+ subPaint.setAntiAlias(true);
+ subPaint.setColor(Color.argb(200, 250, 230, 128));
+ focusPaint = new Paint();
+ focusPaint.setAntiAlias(true);
+ focusPaint.setColor(Color.WHITE);
+ focusPaint.setStyle(Paint.Style.STROKE);
+ successColor = Color.GREEN;
+ failColor = Color.RED;
+ circle = new RectF();
+ dial = new RectF();
+ point1 = new Point();
+ point2 = new Point();
+ innerOffset = res.getDimensionPixelSize(R.dimen.focus_inner_offset);
+ outerStroke = res.getDimensionPixelSize(R.dimen.focus_outer_stroke);
+ innerStroke = res.getDimensionPixelSize(R.dimen.focus_inner_stroke);
+ state = STATE_IDLE;
+ blockFocus = false;
+ touchSlopSquared = ViewConfiguration.get(ctx).getScaledTouchSlop();
+ touchSlopSquared = touchSlopSquared * touchSlopSquared;
+ down = new Point();
}
public boolean showsItems() {
- return mTapMode;
+ return tapMode;
}
public void addItem(PieItem item) {
// add the item to the pie itself
- mItems.add(item);
+ items.add(item);
}
public void removeItem(PieItem item) {
- mItems.remove(item);
+ items.remove(item);
}
public void clearItems() {
- mItems.clear();
+ items.clear();
}
public void showInCenter() {
- if ((mState == STATE_PIE) && isVisible()) {
- mTapMode = false;
+ if ((state == STATE_PIE) && isVisible()) {
+ tapMode = false;
show(false);
} else {
- if (mState != STATE_IDLE) {
+ if (state != STATE_IDLE) {
cancelFocus();
}
- mState = STATE_PIE;
- setCenter(mCenterX, mCenterY);
- mTapMode = true;
+ state = STATE_PIE;
+ setCenter(centerX, centerY);
+ tapMode = true;
show(true);
}
}
@@ -226,59 +226,59 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
*/
private void show(boolean show) {
if (show) {
- mState = STATE_PIE;
+ state = STATE_PIE;
// ensure clean state
- mCurrentItem = null;
- mOpenItem = null;
- for (PieItem item : mItems) {
+ currentItem = null;
+ openItem = null;
+ for (PieItem item : items) {
item.setSelected(false);
}
layoutPie();
fadeIn();
} else {
- mState = STATE_IDLE;
- mTapMode = false;
- if (mXFade != null) {
- mXFade.cancel();
+ state = STATE_IDLE;
+ tapMode = false;
+ if (xFade != null) {
+ xFade.cancel();
}
}
setVisible(show);
- mHandler.sendEmptyMessage(show ? MSG_OPEN : MSG_CLOSE);
+ handler.sendEmptyMessage(show ? MSG_OPEN : MSG_CLOSE);
}
private void fadeIn() {
- mFadeIn = new LinearAnimation(0, 1);
- mFadeIn.setDuration(PIE_FADE_IN_DURATION);
- mFadeIn.setAnimationListener(
+ fadeIn = new LinearAnimation(0, 1);
+ fadeIn.setDuration(PIE_FADE_IN_DURATION);
+ fadeIn.setAnimationListener(
new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
- mFadeIn = null;
+ fadeIn = null;
}
@Override
public void onAnimationRepeat(Animation animation) {}
});
- mFadeIn.startNow();
- mOverlay.startAnimation(mFadeIn);
+ fadeIn.startNow();
+ overlay.startAnimation(fadeIn);
}
public void setCenter(int x, int y) {
- mCenter.x = x;
- mCenter.y = y;
+ center.x = x;
+ center.y = y;
// when using the pie menu, align the focus ring
alignFocus(x, y);
}
private void layoutPie() {
int rgap = 2;
- int inner = mRadius + rgap;
- int outer = mRadius + mRadiusInc - rgap;
+ int inner = radius + rgap;
+ int outer = radius + radiusInc - rgap;
int gap = 1;
- layoutItems(mItems, (float) (Math.PI / 2), inner, outer, gap);
+ layoutItems(items, (float) (Math.PI / 2), inner, outer, gap);
}
private void layoutItems(List<PieItem> items, float centerAngle, int inner, int outer, int gap) {
@@ -294,7 +294,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
break;
}
}
- Path path = makeSlice(getDegrees(0) - gap, getDegrees(sweep) + gap, outer, inner, mCenter);
+ Path path = makeSlice(getDegrees(0) - gap, getDegrees(sweep) + gap, outer, inner, center);
for (PieItem item : items) {
// shared between items
item.setPath(path);
@@ -306,13 +306,13 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
// move views to outer border
int r = inner + (outer - inner) * 2 / 3;
int x = (int) (r * Math.cos(angle));
- int y = mCenter.y - (int) (r * Math.sin(angle)) - h / 2;
- x = mCenter.x + x - w / 2;
+ int y = center.y - (int) (r * Math.sin(angle)) - h / 2;
+ x = center.x + x - w / 2;
item.setBounds(x, y, x + w, y + h);
float itemstart = angle - sweep / 2;
item.setGeometry(itemstart, sweep, inner, outer);
if (item.hasItems()) {
- layoutItems(item.getItems(), angle, inner, outer + mRadiusInc / 2, gap);
+ layoutItems(item.getItems(), angle, inner, outer + radiusInc / 2, gap);
}
angle += sweep;
}
@@ -339,7 +339,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
}
private void startFadeOut() {
- mOverlay
+ overlay
.animate()
.alpha(0)
.setListener(
@@ -348,7 +348,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
public void onAnimationEnd(Animator animation) {
deselect();
show(false);
- mOverlay.setAlpha(1);
+ overlay.setAlpha(1);
super.onAnimationEnd(animation);
}
})
@@ -358,43 +358,43 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
@Override
public void onDraw(Canvas canvas) {
float alpha = 1;
- if (mXFade != null) {
- alpha = mXFade.getValue();
- } else if (mFadeIn != null) {
- alpha = mFadeIn.getValue();
+ if (xFade != null) {
+ alpha = xFade.getValue();
+ } else if (fadeIn != null) {
+ alpha = fadeIn.getValue();
}
int state = canvas.save();
- if (mFadeIn != null) {
+ if (fadeIn != null) {
float sf = 0.9f + alpha * 0.1f;
- canvas.scale(sf, sf, mCenter.x, mCenter.y);
+ canvas.scale(sf, sf, center.x, center.y);
}
drawFocus(canvas);
- if (mState == STATE_FINISHING) {
+ if (this.state == STATE_FINISHING) {
canvas.restoreToCount(state);
return;
}
- if ((mOpenItem == null) || (mXFade != null)) {
+ if ((openItem == null) || (xFade != null)) {
// draw base menu
- for (PieItem item : mItems) {
+ for (PieItem item : items) {
drawItem(canvas, item, alpha);
}
}
- if (mOpenItem != null) {
- for (PieItem inner : mOpenItem.getItems()) {
- drawItem(canvas, inner, (mXFade != null) ? (1 - 0.5f * alpha) : 1);
+ if (openItem != null) {
+ for (PieItem inner : openItem.getItems()) {
+ drawItem(canvas, inner, (xFade != null) ? (1 - 0.5f * alpha) : 1);
}
}
canvas.restoreToCount(state);
}
private void drawItem(Canvas canvas, PieItem item, float alpha) {
- if (mState == STATE_PIE) {
+ if (this.state == STATE_PIE) {
if (item.getPath() != null) {
if (item.isSelected()) {
- Paint p = mSelectedPaint;
+ Paint p = selectedPaint;
int state = canvas.save();
float r = getDegrees(item.getStartAngle());
- canvas.rotate(r, mCenter.x, mCenter.y);
+ canvas.rotate(r, center.x, center.y);
canvas.drawPath(item.getPath(), p);
canvas.restoreToCount(state);
}
@@ -411,15 +411,15 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
float x = evt.getX();
float y = evt.getY();
int action = evt.getActionMasked();
- PointF polar = getPolar(x, y, !(mTapMode));
+ PointF polar = getPolar(x, y, !(tapMode));
if (MotionEvent.ACTION_DOWN == action) {
- mDown.x = (int) evt.getX();
- mDown.y = (int) evt.getY();
- mOpening = false;
- if (mTapMode) {
+ down.x = (int) evt.getX();
+ down.y = (int) evt.getY();
+ opening = false;
+ if (tapMode) {
PieItem item = findItem(polar);
- if ((item != null) && (mCurrentItem != item)) {
- mState = STATE_PIE;
+ if ((item != null) && (currentItem != item)) {
+ state = STATE_PIE;
onEnter(item);
}
} else {
@@ -429,34 +429,34 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
return true;
} else if (MotionEvent.ACTION_UP == action) {
if (isVisible()) {
- PieItem item = mCurrentItem;
- if (mTapMode) {
+ PieItem item = currentItem;
+ if (tapMode) {
item = findItem(polar);
- if (item != null && mOpening) {
- mOpening = false;
+ if (item != null && opening) {
+ opening = false;
return true;
}
}
if (item == null) {
- mTapMode = false;
+ tapMode = false;
show(false);
- } else if (!mOpening && !item.hasItems()) {
+ } else if (!opening && !item.hasItems()) {
item.performClick();
startFadeOut();
- mTapMode = false;
+ tapMode = false;
}
return true;
}
} else if (MotionEvent.ACTION_CANCEL == action) {
- if (isVisible() || mTapMode) {
+ if (isVisible() || tapMode) {
show(false);
}
deselect();
return false;
} else if (MotionEvent.ACTION_MOVE == action) {
- if (polar.y < mRadius) {
- if (mOpenItem != null) {
- mOpenItem = null;
+ if (polar.y < radius) {
+ if (openItem != null) {
+ openItem = null;
} else {
deselect();
}
@@ -464,12 +464,12 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
}
PieItem item = findItem(polar);
boolean moved = hasMoved(evt);
- if ((item != null) && (mCurrentItem != item) && (!mOpening || moved)) {
+ if ((item != null) && (currentItem != item) && (!opening || moved)) {
// only select if we didn't just open or have moved past slop
- mOpening = false;
+ opening = false;
if (moved) {
// switch back to swipe mode
- mTapMode = false;
+ tapMode = false;
}
onEnter(item);
}
@@ -478,8 +478,8 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
}
private boolean hasMoved(MotionEvent e) {
- return mTouchSlopSquared
- < (e.getX() - mDown.x) * (e.getX() - mDown.x) + (e.getY() - mDown.y) * (e.getY() - mDown.y);
+ return touchSlopSquared
+ < (e.getX() - down.x) * (e.getX() - down.x) + (e.getY() - down.y) * (e.getY() - down.y);
}
/**
@@ -488,52 +488,52 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
* @param item
*/
private void onEnter(PieItem item) {
- if (mCurrentItem != null) {
- mCurrentItem.setSelected(false);
+ if (currentItem != null) {
+ currentItem.setSelected(false);
}
if (item != null && item.isEnabled()) {
item.setSelected(true);
- mCurrentItem = item;
- if ((mCurrentItem != mOpenItem) && mCurrentItem.hasItems()) {
+ currentItem = item;
+ if ((currentItem != openItem) && currentItem.hasItems()) {
openCurrentItem();
}
} else {
- mCurrentItem = null;
+ currentItem = null;
}
}
private void deselect() {
- if (mCurrentItem != null) {
- mCurrentItem.setSelected(false);
+ if (currentItem != null) {
+ currentItem.setSelected(false);
}
- if (mOpenItem != null) {
- mOpenItem = null;
+ if (openItem != null) {
+ openItem = null;
}
- mCurrentItem = null;
+ currentItem = null;
}
private void openCurrentItem() {
- if ((mCurrentItem != null) && mCurrentItem.hasItems()) {
- mCurrentItem.setSelected(false);
- mOpenItem = mCurrentItem;
- mOpening = true;
- mXFade = new LinearAnimation(1, 0);
- mXFade.setDuration(PIE_XFADE_DURATION);
- mXFade.setAnimationListener(
+ if ((currentItem != null) && currentItem.hasItems()) {
+ currentItem.setSelected(false);
+ openItem = currentItem;
+ opening = true;
+ xFade = new LinearAnimation(1, 0);
+ xFade.setDuration(PIE_XFADE_DURATION);
+ xFade.setAnimationListener(
new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
- mXFade = null;
+ xFade = null;
}
@Override
public void onAnimationRepeat(Animation animation) {}
});
- mXFade.startNow();
- mOverlay.startAnimation(mXFade);
+ xFade.startNow();
+ overlay.startAnimation(xFade);
}
}
@@ -541,8 +541,8 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
PointF res = new PointF();
// get angle and radius from x/y
res.x = (float) Math.PI / 2;
- x = x - mCenter.x;
- y = mCenter.y - y;
+ x = x - center.x;
+ y = center.y - y;
res.y = (float) Math.sqrt(x * x + y * y);
if (x != 0) {
res.x = (float) Math.atan2(y, x);
@@ -550,7 +550,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
res.x = (float) (2 * Math.PI + res.x);
}
}
- res.y = res.y + (useOffset ? mTouchOffset : 0);
+ res.y = res.y + (useOffset ? touchOffset : 0);
return res;
}
@@ -560,7 +560,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
*/
private PieItem findItem(PointF polar) {
// find the matching item:
- List<PieItem> items = (mOpenItem != null) ? mOpenItem.getItems() : mItems;
+ List<PieItem> items = (openItem != null) ? openItem.getItems() : this.items;
for (PieItem item : items) {
if (inside(polar, item)) {
return item;
@@ -573,7 +573,7 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
return (item.getInnerRadius() < polar.y)
&& (item.getStartAngle() < polar.x)
&& (item.getStartAngle() + item.getSweep() > polar.x)
- && (!mTapMode || (item.getOuterRadius() > polar.y));
+ && (!tapMode || (item.getOuterRadius() > polar.y));
}
@Override
@@ -584,31 +584,31 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
// focus specific code
public void setBlockFocus(boolean blocked) {
- mBlockFocus = blocked;
+ blockFocus = blocked;
if (blocked) {
clear();
}
}
public void setFocus(int x, int y) {
- mFocusX = x;
- mFocusY = y;
- setCircle(mFocusX, mFocusY);
+ focusX = x;
+ focusY = y;
+ setCircle(focusX, focusY);
}
public void alignFocus(int x, int y) {
- mOverlay.removeCallbacks(mDisappear);
- mAnimation.cancel();
- mAnimation.reset();
- mFocusX = x;
- mFocusY = y;
- mDialAngle = DIAL_HORIZONTAL;
+ overlay.removeCallbacks(disappear);
+ animation.cancel();
+ animation.reset();
+ focusX = x;
+ focusY = y;
+ dialAngle = DIAL_HORIZONTAL;
setCircle(x, y);
- mFocused = false;
+ focused = false;
}
public int getSize() {
- return 2 * mCircleSize;
+ return 2 * circleSize;
}
private int getRandomRange() {
@@ -618,58 +618,57 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
@Override
public void layout(int l, int t, int r, int b) {
super.layout(l, t, r, b);
- mCenterX = (r - l) / 2;
- mCenterY = (b - t) / 2;
- mFocusX = mCenterX;
- mFocusY = mCenterY;
- setCircle(mFocusX, mFocusY);
- if (isVisible() && mState == STATE_PIE) {
- setCenter(mCenterX, mCenterY);
+ centerX = (r - l) / 2;
+ centerY = (b - t) / 2;
+ focusX = centerX;
+ focusY = centerY;
+ setCircle(focusX, focusY);
+ if (isVisible() && state == STATE_PIE) {
+ setCenter(centerX, centerY);
layoutPie();
}
}
private void setCircle(int cx, int cy) {
- mCircle.set(cx - mCircleSize, cy - mCircleSize, cx + mCircleSize, cy + mCircleSize);
- mDial.set(
- cx - mCircleSize + mInnerOffset,
- cy - mCircleSize + mInnerOffset,
- cx + mCircleSize - mInnerOffset,
- cy + mCircleSize - mInnerOffset);
+ circle.set(cx - circleSize, cy - circleSize, cx + circleSize, cy + circleSize);
+ dial.set(
+ cx - circleSize + innerOffset,
+ cy - circleSize + innerOffset,
+ cx + circleSize - innerOffset,
+ cy + circleSize - innerOffset);
}
public void drawFocus(Canvas canvas) {
- if (mBlockFocus) {
+ if (blockFocus) {
return;
}
- mFocusPaint.setStrokeWidth(mOuterStroke);
- canvas.drawCircle((float) mFocusX, (float) mFocusY, (float) mCircleSize, mFocusPaint);
- if (mState == STATE_PIE) {
+ focusPaint.setStrokeWidth(outerStroke);
+ canvas.drawCircle((float) focusX, (float) focusY, (float) circleSize, focusPaint);
+ if (state == STATE_PIE) {
return;
}
- int color = mFocusPaint.getColor();
- if (mState == STATE_FINISHING) {
- mFocusPaint.setColor(mFocused ? mSuccessColor : mFailColor);
+ int color = focusPaint.getColor();
+ if (state == STATE_FINISHING) {
+ focusPaint.setColor(focused ? successColor : failColor);
}
- mFocusPaint.setStrokeWidth(mInnerStroke);
- drawLine(canvas, mDialAngle, mFocusPaint);
- drawLine(canvas, mDialAngle + 45, mFocusPaint);
- drawLine(canvas, mDialAngle + 180, mFocusPaint);
- drawLine(canvas, mDialAngle + 225, mFocusPaint);
+ focusPaint.setStrokeWidth(innerStroke);
+ drawLine(canvas, dialAngle, focusPaint);
+ drawLine(canvas, dialAngle + 45, focusPaint);
+ drawLine(canvas, dialAngle + 180, focusPaint);
+ drawLine(canvas, dialAngle + 225, focusPaint);
canvas.save();
// rotate the arc instead of its offset to better use framework's shape caching
- canvas.rotate(mDialAngle, mFocusX, mFocusY);
- canvas.drawArc(mDial, 0, 45, false, mFocusPaint);
- canvas.drawArc(mDial, 180, 45, false, mFocusPaint);
+ canvas.rotate(dialAngle, focusX, focusY);
+ canvas.drawArc(dial, 0, 45, false, focusPaint);
+ canvas.drawArc(dial, 180, 45, false, focusPaint);
canvas.restore();
- mFocusPaint.setColor(color);
+ focusPaint.setColor(color);
}
private void drawLine(Canvas canvas, int angle, Paint p) {
- convertCart(angle, mCircleSize - mInnerOffset, mPoint1);
- convertCart(angle, mCircleSize - mInnerOffset + mInnerOffset / 3, mPoint2);
- canvas.drawLine(
- mPoint1.x + mFocusX, mPoint1.y + mFocusY, mPoint2.x + mFocusX, mPoint2.y + mFocusY, p);
+ convertCart(angle, circleSize - innerOffset, point1);
+ convertCart(angle, circleSize - innerOffset + innerOffset / 3, point2);
+ canvas.drawLine(point1.x + focusX, point1.y + focusY, point2.x + focusX, point2.y + focusY, p);
}
private static void convertCart(int angle, int radius, Point out) {
@@ -680,65 +679,65 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
@Override
public void showStart() {
- if (mState == STATE_PIE) {
+ if (state == STATE_PIE) {
return;
}
cancelFocus();
- mStartAnimationAngle = 67;
+ startAnimationAngle = 67;
int range = getRandomRange();
- startAnimation(SCALING_UP_TIME, false, mStartAnimationAngle, mStartAnimationAngle + range);
- mState = STATE_FOCUSING;
+ startAnimation(SCALING_UP_TIME, false, startAnimationAngle, startAnimationAngle + range);
+ state = STATE_FOCUSING;
}
@Override
public void showSuccess(boolean timeout) {
- if (mState == STATE_FOCUSING) {
- startAnimation(SCALING_DOWN_TIME, timeout, mStartAnimationAngle);
- mState = STATE_FINISHING;
- mFocused = true;
+ if (state == STATE_FOCUSING) {
+ startAnimation(SCALING_DOWN_TIME, timeout, startAnimationAngle);
+ state = STATE_FINISHING;
+ focused = true;
}
}
@Override
public void showFail(boolean timeout) {
- if (mState == STATE_FOCUSING) {
- startAnimation(SCALING_DOWN_TIME, timeout, mStartAnimationAngle);
- mState = STATE_FINISHING;
- mFocused = false;
+ if (state == STATE_FOCUSING) {
+ startAnimation(SCALING_DOWN_TIME, timeout, startAnimationAngle);
+ state = STATE_FINISHING;
+ focused = false;
}
}
private void cancelFocus() {
- mFocusCancelled = true;
- mOverlay.removeCallbacks(mDisappear);
- if (mAnimation != null) {
- mAnimation.cancel();
+ focusCancelled = true;
+ overlay.removeCallbacks(disappear);
+ if (animation != null) {
+ animation.cancel();
}
- mFocusCancelled = false;
- mFocused = false;
- mState = STATE_IDLE;
+ focusCancelled = false;
+ focused = false;
+ state = STATE_IDLE;
}
@Override
public void clear() {
- if (mState == STATE_PIE) {
+ if (state == STATE_PIE) {
return;
}
cancelFocus();
- mOverlay.post(mDisappear);
+ overlay.post(disappear);
}
private void startAnimation(long duration, boolean timeout, float toScale) {
- startAnimation(duration, timeout, mDialAngle, toScale);
+ startAnimation(duration, timeout, dialAngle, toScale);
}
private void startAnimation(long duration, boolean timeout, float fromScale, float toScale) {
setVisible(true);
- mAnimation.reset();
- mAnimation.setDuration(duration);
- mAnimation.setScale(fromScale, toScale);
- mAnimation.setAnimationListener(timeout ? mEndAction : null);
- mOverlay.startAnimation(mAnimation);
+ animation.reset();
+ animation.setDuration(duration);
+ animation.setScale(fromScale, toScale);
+ animation.setAnimationListener(timeout ? endAction : null);
+ overlay.startAnimation(animation);
update();
}
@@ -746,8 +745,8 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
@Override
public void onAnimationEnd(Animation animation) {
// Keep the focus indicator for some time.
- if (!mFocusCancelled) {
- mOverlay.postDelayed(mDisappear, DISAPPEAR_TIMEOUT);
+ if (!focusCancelled) {
+ overlay.postDelayed(disappear, DISAPPEAR_TIMEOUT);
}
}
@@ -761,56 +760,56 @@ public class PieRenderer extends OverlayRenderer implements FocusIndicator {
private class Disappear implements Runnable {
@Override
public void run() {
- if (mState == STATE_PIE) {
+ if (state == STATE_PIE) {
return;
}
setVisible(false);
- mFocusX = mCenterX;
- mFocusY = mCenterY;
- mState = STATE_IDLE;
- setCircle(mFocusX, mFocusY);
- mFocused = false;
+ focusX = centerX;
+ focusY = centerY;
+ state = STATE_IDLE;
+ setCircle(focusX, focusY);
+ focused = false;
}
}
private class ScaleAnimation extends Animation {
- private float mFrom = 1f;
- private float mTo = 1f;
+ private float from = 1f;
+ private float to = 1f;
public ScaleAnimation() {
setFillAfter(true);
}
public void setScale(float from, float to) {
- mFrom = from;
- mTo = to;
+ this.from = from;
+ this.to = to;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
- mDialAngle = (int) (mFrom + (mTo - mFrom) * interpolatedTime);
+ dialAngle = (int) (from + (to - from) * interpolatedTime);
}
}
private static class LinearAnimation extends Animation {
- private float mFrom;
- private float mTo;
- private float mValue;
+ private float from;
+ private float to;
+ private float value;
public LinearAnimation(float from, float to) {
setFillAfter(true);
setInterpolator(new LinearInterpolator());
- mFrom = from;
- mTo = to;
+ this.from = from;
+ this.to = to;
}
public float getValue() {
- return mValue;
+ return value;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
- mValue = (mFrom + (mTo - mFrom) * interpolatedTime);
+ value = (from + (to - from) * interpolatedTime);
}
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/camerafocus/RenderOverlay.java b/java/com/android/dialer/callcomposer/camera/camerafocus/RenderOverlay.java
index c38ae6c81..458e852fa 100644
--- a/java/com/android/dialer/callcomposer/camera/camerafocus/RenderOverlay.java
+++ b/java/com/android/dialer/callcomposer/camera/camerafocus/RenderOverlay.java
@@ -42,26 +42,26 @@ public class RenderOverlay extends FrameLayout {
void draw(Canvas canvas);
}
- private RenderView mRenderView;
- private List<Renderer> mClients;
+ private RenderView renderView;
+ private List<Renderer> clients;
// reverse list of touch clients
- private List<Renderer> mTouchClients;
- private int[] mPosition = new int[2];
+ private List<Renderer> touchClients;
+ private int[] position = new int[2];
public RenderOverlay(Context context, AttributeSet attrs) {
super(context, attrs);
- mRenderView = new RenderView(context);
- addView(mRenderView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- mClients = new ArrayList<>(10);
- mTouchClients = new ArrayList<>(10);
+ renderView = new RenderView(context);
+ addView(renderView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+ clients = new ArrayList<>(10);
+ touchClients = new ArrayList<>(10);
setWillNotDraw(false);
addRenderer(new PieRenderer(context));
}
public PieRenderer getPieRenderer() {
- for (Renderer renderer : mClients) {
+ for (Renderer renderer : clients) {
if (renderer instanceof PieRenderer) {
return (PieRenderer) renderer;
}
@@ -70,22 +70,22 @@ public class RenderOverlay extends FrameLayout {
}
public void addRenderer(Renderer renderer) {
- mClients.add(renderer);
+ clients.add(renderer);
renderer.setOverlay(this);
if (renderer.handlesTouch()) {
- mTouchClients.add(0, renderer);
+ touchClients.add(0, renderer);
}
renderer.layout(getLeft(), getTop(), getRight(), getBottom());
}
public void addRenderer(int pos, Renderer renderer) {
- mClients.add(pos, renderer);
+ clients.add(pos, renderer);
renderer.setOverlay(this);
renderer.layout(getLeft(), getTop(), getRight(), getBottom());
}
public void remove(Renderer renderer) {
- mClients.remove(renderer);
+ clients.remove(renderer);
renderer.setOverlay(null);
}
@@ -95,11 +95,11 @@ public class RenderOverlay extends FrameLayout {
}
private void adjustPosition() {
- getLocationInWindow(mPosition);
+ getLocationInWindow(position);
}
public void update() {
- mRenderView.invalidate();
+ renderView.invalidate();
}
@SuppressLint("ClickableViewAccessibility")
@@ -112,9 +112,9 @@ public class RenderOverlay extends FrameLayout {
@Override
public boolean onTouchEvent(MotionEvent evt) {
- if (mTouchClients != null) {
+ if (touchClients != null) {
boolean res = false;
- for (Renderer client : mTouchClients) {
+ for (Renderer client : touchClients) {
res |= client.onTouchEvent(evt);
}
return res;
@@ -126,10 +126,10 @@ public class RenderOverlay extends FrameLayout {
public void onLayout(boolean changed, int left, int top, int right, int bottom) {
adjustPosition();
super.onLayout(changed, left, top, right, bottom);
- if (mClients == null) {
+ if (clients == null) {
return;
}
- for (Renderer renderer : mClients) {
+ for (Renderer renderer : clients) {
renderer.layout(left, top, right, bottom);
}
}
@@ -137,11 +137,11 @@ public class RenderOverlay extends FrameLayout {
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
- if (mClients == null) {
+ if (clients == null) {
return;
}
boolean redraw = false;
- for (Renderer renderer : mClients) {
+ for (Renderer renderer : clients) {
renderer.draw(canvas);
redraw = redraw || ((OverlayRenderer) renderer).isVisible();
}
diff --git a/java/com/android/dialer/callcomposer/camera/exif/CountedDataInputStream.java b/java/com/android/dialer/callcomposer/camera/exif/CountedDataInputStream.java
index e2c8185da..cb5143a92 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/CountedDataInputStream.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/CountedDataInputStream.java
@@ -27,45 +27,45 @@ import java.nio.charset.Charset;
class CountedDataInputStream extends FilterInputStream {
- private int mCount = 0;
+ private int count = 0;
// allocate a byte buffer for a long value;
- private final byte[] mByteArray = new byte[8];
- private final ByteBuffer mByteBuffer = ByteBuffer.wrap(mByteArray);
+ private final byte[] byteArray = new byte[8];
+ private final ByteBuffer byteBuffer = ByteBuffer.wrap(byteArray);
CountedDataInputStream(InputStream in) {
super(in);
}
int getReadByteCount() {
- return mCount;
+ return count;
}
@Override
public int read(byte[] b) throws IOException {
int r = in.read(b);
- mCount += (r >= 0) ? r : 0;
+ count += (r >= 0) ? r : 0;
return r;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int r = in.read(b, off, len);
- mCount += (r >= 0) ? r : 0;
+ count += (r >= 0) ? r : 0;
return r;
}
@Override
public int read() throws IOException {
int r = in.read();
- mCount += (r >= 0) ? 1 : 0;
+ count += (r >= 0) ? 1 : 0;
return r;
}
@Override
public long skip(long length) throws IOException {
long skip = in.skip(length);
- mCount += skip;
+ count += skip;
return skip;
}
@@ -76,7 +76,7 @@ class CountedDataInputStream extends FilterInputStream {
}
void skipTo(long target) throws IOException {
- long cur = mCount;
+ long cur = count;
long diff = target - cur;
Assert.checkArgument(diff >= 0);
skipOrThrow(diff);
@@ -94,17 +94,17 @@ class CountedDataInputStream extends FilterInputStream {
}
void setByteOrder(ByteOrder order) {
- mByteBuffer.order(order);
+ byteBuffer.order(order);
}
ByteOrder getByteOrder() {
- return mByteBuffer.order();
+ return byteBuffer.order();
}
short readShort() throws IOException {
- readOrThrow(mByteArray, 0, 2);
- mByteBuffer.rewind();
- return mByteBuffer.getShort();
+ readOrThrow(byteArray, 0, 2);
+ byteBuffer.rewind();
+ return byteBuffer.getShort();
}
int readUnsignedShort() throws IOException {
@@ -112,9 +112,9 @@ class CountedDataInputStream extends FilterInputStream {
}
int readInt() throws IOException {
- readOrThrow(mByteArray, 0, 4);
- mByteBuffer.rewind();
- return mByteBuffer.getInt();
+ readOrThrow(byteArray, 0, 4);
+ byteBuffer.rewind();
+ return byteBuffer.getInt();
}
long readUnsignedInt() throws IOException {
diff --git a/java/com/android/dialer/callcomposer/camera/exif/ExifData.java b/java/com/android/dialer/callcomposer/camera/exif/ExifData.java
index 27936ae2f..fef9d870c 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/ExifData.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/ExifData.java
@@ -25,20 +25,20 @@ package com.android.dialer.callcomposer.camera.exif;
*/
public class ExifData {
- private final IfdData[] mIfdDatas = new IfdData[IfdId.TYPE_IFD_COUNT];
+ private final IfdData[] ifdDatas = new IfdData[IfdId.TYPE_IFD_COUNT];
/**
* Adds IFD data. If IFD data of the same type already exists, it will be replaced by the new
* data.
*/
void addIfdData(IfdData data) {
- mIfdDatas[data.getId()] = data;
+ ifdDatas[data.getId()] = data;
}
/** Returns the {@link IfdData} object corresponding to a given IFD if it exists or null. */
IfdData getIfdData(int ifdId) {
if (ExifTag.isValidIfd(ifdId)) {
- return mIfdDatas[ifdId];
+ return ifdDatas[ifdId];
}
return null;
}
@@ -47,7 +47,7 @@ public class ExifData {
* Returns the tag with a given TID in the given IFD if the tag exists. Otherwise returns null.
*/
protected ExifTag getTag(short tag, int ifd) {
- IfdData ifdData = mIfdDatas[ifd];
+ IfdData ifdData = ifdDatas[ifd];
return (ifdData == null) ? null : ifdData.getTag(tag);
}
@@ -79,10 +79,10 @@ public class ExifData {
* Returns the {@link IfdData} object corresponding to a given IFD or generates one if none exist.
*/
private IfdData getOrCreateIfdData(int ifdId) {
- IfdData ifdData = mIfdDatas[ifdId];
+ IfdData ifdData = ifdDatas[ifdId];
if (ifdData == null) {
ifdData = new IfdData(ifdId);
- mIfdDatas[ifdId] = ifdData;
+ ifdDatas[ifdId] = ifdData;
}
return ifdData;
}
diff --git a/java/com/android/dialer/callcomposer/camera/exif/ExifInterface.java b/java/com/android/dialer/callcomposer/camera/exif/ExifInterface.java
index 1bf9519ad..737401f64 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/ExifInterface.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/ExifInterface.java
@@ -61,21 +61,21 @@ public class ExifInterface {
static final int TAG_INTEROPERABILITY_IFD = defineTag(IfdId.TYPE_IFD_EXIF, (short) 0xA005);
/** Tags that contain offset markers. These are included in the banned defines. */
- private static HashSet<Short> sOffsetTags = new HashSet<>();
+ private static HashSet<Short> offsetTags = new HashSet<>();
static {
- sOffsetTags.add(getTrueTagKey(TAG_GPS_IFD));
- sOffsetTags.add(getTrueTagKey(TAG_EXIF_IFD));
- sOffsetTags.add(getTrueTagKey(TAG_JPEG_INTERCHANGE_FORMAT));
- sOffsetTags.add(getTrueTagKey(TAG_INTEROPERABILITY_IFD));
- sOffsetTags.add(getTrueTagKey(TAG_STRIP_OFFSETS));
+ offsetTags.add(getTrueTagKey(TAG_GPS_IFD));
+ offsetTags.add(getTrueTagKey(TAG_EXIF_IFD));
+ offsetTags.add(getTrueTagKey(TAG_JPEG_INTERCHANGE_FORMAT));
+ offsetTags.add(getTrueTagKey(TAG_INTEROPERABILITY_IFD));
+ offsetTags.add(getTrueTagKey(TAG_STRIP_OFFSETS));
}
private static final String NULL_ARGUMENT_STRING = "Argument is null";
private static final String GPS_DATE_FORMAT_STR = "yyyy:MM:dd";
- private ExifData mData = new ExifData();
+ private ExifData data = new ExifData();
@SuppressLint("SimpleDateFormat")
public ExifInterface() {
@@ -110,7 +110,7 @@ public class ExifInterface {
} catch (ExifInvalidFormatException e) {
throw new IOException("Invalid exif format : " + e);
}
- mData = d;
+ data = d;
}
/** Returns the TID for a tag constant. */
@@ -151,17 +151,17 @@ public class ExifInterface {
* @return true if the TID is that of an offset tag.
*/
static boolean isOffsetTag(short tag) {
- return sOffsetTags.contains(tag);
+ return offsetTags.contains(tag);
}
- private SparseIntArray mTagInfo = null;
+ private SparseIntArray tagInfo = null;
SparseIntArray getTagInfo() {
- if (mTagInfo == null) {
- mTagInfo = new SparseIntArray();
+ if (tagInfo == null) {
+ tagInfo = new SparseIntArray();
initTagInfo();
}
- return mTagInfo;
+ return tagInfo;
}
private void initTagInfo() {
@@ -173,24 +173,24 @@ public class ExifInterface {
// IFD0 tags
int[] ifdAllowedIfds = {IfdId.TYPE_IFD_0, IfdId.TYPE_IFD_1};
int ifdFlags = getFlagsFromAllowedIfds(ifdAllowedIfds) << 24;
- mTagInfo.put(ExifInterface.TAG_STRIP_OFFSETS, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16);
- mTagInfo.put(ExifInterface.TAG_EXIF_IFD, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
- mTagInfo.put(ExifInterface.TAG_GPS_IFD, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
- mTagInfo.put(ExifInterface.TAG_ORIENTATION, ifdFlags | ExifTag.TYPE_UNSIGNED_SHORT << 16 | 1);
- mTagInfo.put(ExifInterface.TAG_STRIP_BYTE_COUNTS, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16);
+ tagInfo.put(ExifInterface.TAG_STRIP_OFFSETS, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16);
+ tagInfo.put(ExifInterface.TAG_EXIF_IFD, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
+ tagInfo.put(ExifInterface.TAG_GPS_IFD, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
+ tagInfo.put(ExifInterface.TAG_ORIENTATION, ifdFlags | ExifTag.TYPE_UNSIGNED_SHORT << 16 | 1);
+ tagInfo.put(ExifInterface.TAG_STRIP_BYTE_COUNTS, ifdFlags | ExifTag.TYPE_UNSIGNED_LONG << 16);
// IFD1 tags
int[] ifd1AllowedIfds = {IfdId.TYPE_IFD_1};
int ifdFlags1 = getFlagsFromAllowedIfds(ifd1AllowedIfds) << 24;
- mTagInfo.put(
+ tagInfo.put(
ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT,
ifdFlags1 | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
- mTagInfo.put(
+ tagInfo.put(
ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH,
ifdFlags1 | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
// Exif tags
int[] exifAllowedIfds = {IfdId.TYPE_IFD_EXIF};
int exifFlags = getFlagsFromAllowedIfds(exifAllowedIfds) << 24;
- mTagInfo.put(
+ tagInfo.put(
ExifInterface.TAG_INTEROPERABILITY_IFD, exifFlags | ExifTag.TYPE_UNSIGNED_LONG << 16 | 1);
}
@@ -232,7 +232,7 @@ public class ExifInterface {
if (!ExifTag.isValidIfd(ifdId)) {
return null;
}
- return mData.getTag(getTrueTagKey(tagId), ifdId);
+ return data.getTag(getTrueTagKey(tagId), ifdId);
}
public Integer getTagIntValue(int tagId) {
@@ -328,7 +328,7 @@ public class ExifInterface {
/** Clears this ExifInterface object's existing exif tags. */
public void clearExif() {
- mData = new ExifData();
+ data = new ExifData();
}
/**
@@ -340,7 +340,7 @@ public class ExifInterface {
* @return the previous ExifTag with the same TID and IFD or null if none exists.
*/
public ExifTag setTag(ExifTag tag) {
- return mData.addTag(tag);
+ return data.addTag(tag);
}
/**
diff --git a/java/com/android/dialer/callcomposer/camera/exif/ExifParser.java b/java/com/android/dialer/callcomposer/camera/exif/ExifParser.java
index c728845a1..1aec4ab12 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/ExifParser.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/ExifParser.java
@@ -119,20 +119,20 @@ public class ExifParser {
private static final int DEFAULT_IFD0_OFFSET = 8;
- private final CountedDataInputStream mTiffStream;
- private final int mOptions;
- private int mIfdStartOffset = 0;
- private int mNumOfTagInIfd = 0;
- private int mIfdType;
- private ExifTag mTag;
- private ImageEvent mImageEvent;
- private ExifTag mStripSizeTag;
- private ExifTag mJpegSizeTag;
- private boolean mNeedToParseOffsetsInCurrentIfd;
- private boolean mContainExifData = false;
- private int mApp1End;
- private byte[] mDataAboveIfd0;
- private int mIfd0Position;
+ private final CountedDataInputStream tiffStream;
+ private final int options;
+ private int ifdStartOffset = 0;
+ private int numOfTagInIfd = 0;
+ private int ifdType;
+ private ExifTag tag;
+ private ImageEvent imageEvent;
+ private ExifTag stripSizeTag;
+ private ExifTag jpegSizeTag;
+ private boolean needToParseOffsetsInCurrentIfd;
+ private boolean containExifData = false;
+ private int app1End;
+ private byte[] dataAboveIfd0;
+ private int ifd0Position;
private final ExifInterface mInterface;
private static final short TAG_EXIF_IFD = ExifInterface.getTrueTagKey(ExifInterface.TAG_EXIF_IFD);
@@ -148,26 +148,26 @@ public class ExifParser {
private static final short TAG_STRIP_BYTE_COUNTS =
ExifInterface.getTrueTagKey(ExifInterface.TAG_STRIP_BYTE_COUNTS);
- private final TreeMap<Integer, Object> mCorrespondingEvent = new TreeMap<>();
+ private final TreeMap<Integer, Object> correspondingEvent = new TreeMap<>();
private boolean isIfdRequested(int ifdType) {
switch (ifdType) {
case IfdId.TYPE_IFD_0:
- return (mOptions & OPTION_IFD_0) != 0;
+ return (options & OPTION_IFD_0) != 0;
case IfdId.TYPE_IFD_1:
- return (mOptions & OPTION_IFD_1) != 0;
+ return (options & OPTION_IFD_1) != 0;
case IfdId.TYPE_IFD_EXIF:
- return (mOptions & OPTION_IFD_EXIF) != 0;
+ return (options & OPTION_IFD_EXIF) != 0;
case IfdId.TYPE_IFD_GPS:
- return (mOptions & OPTION_IFD_GPS) != 0;
+ return (options & OPTION_IFD_GPS) != 0;
case IfdId.TYPE_IFD_INTEROPERABILITY:
- return (mOptions & OPTION_IFD_INTEROPERABILITY) != 0;
+ return (options & OPTION_IFD_INTEROPERABILITY) != 0;
}
return false;
}
private boolean isThumbnailRequested() {
- return (mOptions & OPTION_THUMBNAIL) != 0;
+ return (options & OPTION_THUMBNAIL) != 0;
}
private ExifParser(InputStream inputStream, int options, ExifInterface iRef)
@@ -179,25 +179,25 @@ public class ExifParser {
LogUtil.v("ExifParser.ExifParser", "Reading exif...");
}
mInterface = iRef;
- mContainExifData = seekTiffData(inputStream);
- mTiffStream = new CountedDataInputStream(inputStream);
- mOptions = options;
- if (!mContainExifData) {
+ containExifData = seekTiffData(inputStream);
+ tiffStream = new CountedDataInputStream(inputStream);
+ this.options = options;
+ if (!containExifData) {
return;
}
parseTiffHeader();
- long offset = mTiffStream.readUnsignedInt();
+ long offset = tiffStream.readUnsignedInt();
if (offset > Integer.MAX_VALUE) {
throw new ExifInvalidFormatException("Invalid offset " + offset);
}
- mIfd0Position = (int) offset;
- mIfdType = IfdId.TYPE_IFD_0;
+ ifd0Position = (int) offset;
+ ifdType = IfdId.TYPE_IFD_0;
if (isIfdRequested(IfdId.TYPE_IFD_0) || needToParseOffsetsInCurrentIfd()) {
registerIfd(IfdId.TYPE_IFD_0, offset);
if (offset != DEFAULT_IFD0_OFFSET) {
- mDataAboveIfd0 = new byte[(int) offset - DEFAULT_IFD0_OFFSET];
- read(mDataAboveIfd0);
+ dataAboveIfd0 = new byte[(int) offset - DEFAULT_IFD0_OFFSET];
+ read(dataAboveIfd0);
}
}
}
@@ -247,23 +247,23 @@ public class ExifParser {
* @see #EVENT_END
*/
protected int next() throws IOException, ExifInvalidFormatException {
- if (!mContainExifData) {
+ if (!containExifData) {
return EVENT_END;
}
- int offset = mTiffStream.getReadByteCount();
- int endOfTags = mIfdStartOffset + OFFSET_SIZE + TAG_SIZE * mNumOfTagInIfd;
+ int offset = tiffStream.getReadByteCount();
+ int endOfTags = ifdStartOffset + OFFSET_SIZE + TAG_SIZE * numOfTagInIfd;
if (offset < endOfTags) {
- mTag = readTag();
- if (mTag == null) {
+ tag = readTag();
+ if (tag == null) {
return next();
}
- if (mNeedToParseOffsetsInCurrentIfd) {
- checkOffsetOrImageTag(mTag);
+ if (needToParseOffsetsInCurrentIfd) {
+ checkOffsetOrImageTag(tag);
}
return EVENT_NEW_TAG;
} else if (offset == endOfTags) {
// There is a link to ifd1 at the end of ifd0
- if (mIfdType == IfdId.TYPE_IFD_0) {
+ if (ifdType == IfdId.TYPE_IFD_0) {
long ifdOffset = readUnsignedLong();
if (isIfdRequested(IfdId.TYPE_IFD_1) || isThumbnailRequested()) {
if (ifdOffset != 0) {
@@ -273,8 +273,8 @@ public class ExifParser {
} else {
int offsetSize = 4;
// Some camera models use invalid length of the offset
- if (mCorrespondingEvent.size() > 0) {
- offsetSize = mCorrespondingEvent.firstEntry().getKey() - mTiffStream.getReadByteCount();
+ if (correspondingEvent.size() > 0) {
+ offsetSize = correspondingEvent.firstEntry().getKey() - tiffStream.getReadByteCount();
}
if (offsetSize < 4) {
LogUtil.i("ExifParser.next", "Invalid size of link to next IFD: " + offsetSize);
@@ -286,8 +286,8 @@ public class ExifParser {
}
}
}
- while (mCorrespondingEvent.size() != 0) {
- Entry<Integer, Object> entry = mCorrespondingEvent.pollFirstEntry();
+ while (correspondingEvent.size() != 0) {
+ Entry<Integer, Object> entry = correspondingEvent.pollFirstEntry();
Object event = entry.getValue();
try {
skipTo(entry.getKey());
@@ -302,30 +302,30 @@ public class ExifParser {
continue;
}
if (event instanceof IfdEvent) {
- mIfdType = ((IfdEvent) event).ifd;
- mNumOfTagInIfd = mTiffStream.readUnsignedShort();
- mIfdStartOffset = entry.getKey();
+ ifdType = ((IfdEvent) event).ifd;
+ numOfTagInIfd = tiffStream.readUnsignedShort();
+ ifdStartOffset = entry.getKey();
- if (mNumOfTagInIfd * TAG_SIZE + mIfdStartOffset + OFFSET_SIZE > mApp1End) {
- LogUtil.i("ExifParser.next", "Invalid size of IFD " + mIfdType);
+ if (numOfTagInIfd * TAG_SIZE + ifdStartOffset + OFFSET_SIZE > app1End) {
+ LogUtil.i("ExifParser.next", "Invalid size of IFD " + ifdType);
return EVENT_END;
}
- mNeedToParseOffsetsInCurrentIfd = needToParseOffsetsInCurrentIfd();
+ needToParseOffsetsInCurrentIfd = needToParseOffsetsInCurrentIfd();
if (((IfdEvent) event).isRequested) {
return EVENT_START_OF_IFD;
} else {
skipRemainingTagsInCurrentIfd();
}
} else if (event instanceof ImageEvent) {
- mImageEvent = (ImageEvent) event;
- return mImageEvent.type;
+ imageEvent = (ImageEvent) event;
+ return imageEvent.type;
} else {
ExifTagEvent tagEvent = (ExifTagEvent) event;
- mTag = tagEvent.tag;
- if (mTag.getDataType() != ExifTag.TYPE_UNDEFINED) {
- readFullTagValue(mTag);
- checkOffsetOrImageTag(mTag);
+ tag = tagEvent.tag;
+ if (tag.getDataType() != ExifTag.TYPE_UNDEFINED) {
+ readFullTagValue(tag);
+ checkOffsetOrImageTag(tag);
}
if (tagEvent.isRequested) {
return EVENT_VALUE_OF_REGISTERED_TAG;
@@ -342,26 +342,26 @@ public class ExifParser {
* @throws ExifInvalidFormatException
*/
private void skipRemainingTagsInCurrentIfd() throws IOException, ExifInvalidFormatException {
- int endOfTags = mIfdStartOffset + OFFSET_SIZE + TAG_SIZE * mNumOfTagInIfd;
- int offset = mTiffStream.getReadByteCount();
+ int endOfTags = ifdStartOffset + OFFSET_SIZE + TAG_SIZE * numOfTagInIfd;
+ int offset = tiffStream.getReadByteCount();
if (offset > endOfTags) {
return;
}
- if (mNeedToParseOffsetsInCurrentIfd) {
+ if (needToParseOffsetsInCurrentIfd) {
while (offset < endOfTags) {
- mTag = readTag();
+ tag = readTag();
offset += TAG_SIZE;
- if (mTag == null) {
+ if (tag == null) {
continue;
}
- checkOffsetOrImageTag(mTag);
+ checkOffsetOrImageTag(tag);
}
} else {
skipTo(endOfTags);
}
long ifdOffset = readUnsignedLong();
// For ifd0, there is a link to ifd1 in the end of all tags
- if (mIfdType == IfdId.TYPE_IFD_0
+ if (ifdType == IfdId.TYPE_IFD_0
&& (isIfdRequested(IfdId.TYPE_IFD_1) || isThumbnailRequested())) {
if (ifdOffset > 0) {
registerIfd(IfdId.TYPE_IFD_1, ifdOffset);
@@ -370,7 +370,7 @@ public class ExifParser {
}
private boolean needToParseOffsetsInCurrentIfd() {
- switch (mIfdType) {
+ switch (ifdType) {
case IfdId.TYPE_IFD_0:
return isIfdRequested(IfdId.TYPE_IFD_EXIF)
|| isIfdRequested(IfdId.TYPE_IFD_GPS)
@@ -408,7 +408,7 @@ public class ExifParser {
* @see #readString(int, java.nio.charset.Charset)
*/
protected ExifTag getTag() {
- return mTag;
+ return tag;
}
/**
@@ -421,7 +421,7 @@ public class ExifParser {
* @see IfdId#TYPE_IFD_EXIF
*/
int getCurrentIfd() {
- return mIfdType;
+ return ifdType;
}
/**
@@ -429,31 +429,31 @@ public class ExifParser {
* strip.
*/
int getStripIndex() {
- return mImageEvent.stripIndex;
+ return imageEvent.stripIndex;
}
/** When receiving {@link #EVENT_UNCOMPRESSED_STRIP}, call this function to get the strip size. */
int getStripSize() {
- if (mStripSizeTag == null) {
+ if (stripSizeTag == null) {
return 0;
}
- return (int) mStripSizeTag.getValueAt(0);
+ return (int) stripSizeTag.getValueAt(0);
}
/**
* When receiving {@link #EVENT_COMPRESSED_IMAGE}, call this function to get the image data size.
*/
int getCompressedImageSize() {
- if (mJpegSizeTag == null) {
+ if (jpegSizeTag == null) {
return 0;
}
- return (int) mJpegSizeTag.getValueAt(0);
+ return (int) jpegSizeTag.getValueAt(0);
}
private void skipTo(int offset) throws IOException {
- mTiffStream.skipTo(offset);
- while (!mCorrespondingEvent.isEmpty() && mCorrespondingEvent.firstKey() < offset) {
- mCorrespondingEvent.pollFirstEntry();
+ tiffStream.skipTo(offset);
+ while (!correspondingEvent.isEmpty() && correspondingEvent.firstKey() < offset) {
+ correspondingEvent.pollFirstEntry();
}
}
@@ -466,37 +466,37 @@ public class ExifParser {
* @see #EVENT_VALUE_OF_REGISTERED_TAG
*/
void registerForTagValue(ExifTag tag) {
- if (tag.getOffset() >= mTiffStream.getReadByteCount()) {
- mCorrespondingEvent.put(tag.getOffset(), new ExifTagEvent(tag, true));
+ if (tag.getOffset() >= tiffStream.getReadByteCount()) {
+ correspondingEvent.put(tag.getOffset(), new ExifTagEvent(tag, true));
}
}
private void registerIfd(int ifdType, long offset) {
// Cast unsigned int to int since the offset is always smaller
// than the size of APP1 (65536)
- mCorrespondingEvent.put((int) offset, new IfdEvent(ifdType, isIfdRequested(ifdType)));
+ correspondingEvent.put((int) offset, new IfdEvent(ifdType, isIfdRequested(ifdType)));
}
private void registerCompressedImage(long offset) {
- mCorrespondingEvent.put((int) offset, new ImageEvent(EVENT_COMPRESSED_IMAGE));
+ correspondingEvent.put((int) offset, new ImageEvent(EVENT_COMPRESSED_IMAGE));
}
private void registerUncompressedStrip(int stripIndex, long offset) {
- mCorrespondingEvent.put((int) offset, new ImageEvent(EVENT_UNCOMPRESSED_STRIP, stripIndex));
+ correspondingEvent.put((int) offset, new ImageEvent(EVENT_UNCOMPRESSED_STRIP, stripIndex));
}
@SuppressLint("DefaultLocale")
private ExifTag readTag() throws IOException, ExifInvalidFormatException {
- short tagId = mTiffStream.readShort();
- short dataFormat = mTiffStream.readShort();
- long numOfComp = mTiffStream.readUnsignedInt();
+ short tagId = tiffStream.readShort();
+ short dataFormat = tiffStream.readShort();
+ long numOfComp = tiffStream.readUnsignedInt();
if (numOfComp > Integer.MAX_VALUE) {
throw new ExifInvalidFormatException("Number of component is larger then Integer.MAX_VALUE");
}
// Some invalid image file contains invalid data type. Ignore those tags
if (!ExifTag.isValidType(dataFormat)) {
LogUtil.i("ExifParser.readTag", "Tag %04x: Invalid data type %d", tagId, dataFormat);
- mTiffStream.skip(4);
+ tiffStream.skip(4);
return null;
}
// TODO(blemmon): handle numOfComp overflow
@@ -505,20 +505,20 @@ public class ExifParser {
tagId,
dataFormat,
(int) numOfComp,
- mIfdType,
+ ifdType,
((int) numOfComp) != ExifTag.SIZE_UNDEFINED);
int dataSize = tag.getDataSize();
if (dataSize > 4) {
- long offset = mTiffStream.readUnsignedInt();
+ long offset = tiffStream.readUnsignedInt();
if (offset > Integer.MAX_VALUE) {
throw new ExifInvalidFormatException("offset is larger then Integer.MAX_VALUE");
}
// Some invalid images put some undefined data before IFD0.
// Read the data here.
- if ((offset < mIfd0Position) && (dataFormat == ExifTag.TYPE_UNDEFINED)) {
+ if ((offset < ifd0Position) && (dataFormat == ExifTag.TYPE_UNDEFINED)) {
byte[] buf = new byte[(int) numOfComp];
System.arraycopy(
- mDataAboveIfd0, (int) offset - DEFAULT_IFD0_OFFSET, buf, 0, (int) numOfComp);
+ dataAboveIfd0, (int) offset - DEFAULT_IFD0_OFFSET, buf, 0, (int) numOfComp);
tag.setValue(buf);
} else {
tag.setOffset((int) offset);
@@ -530,9 +530,9 @@ public class ExifParser {
// Read value
readFullTagValue(tag);
tag.setHasDefinedCount(defCount);
- mTiffStream.skip(4 - dataSize);
+ tiffStream.skip(4 - dataSize);
// Set the offset to the position of value.
- tag.setOffset(mTiffStream.getReadByteCount() - 4);
+ tag.setOffset(tiffStream.getReadByteCount() - 4);
}
return tag;
}
@@ -569,7 +569,7 @@ public class ExifParser {
} else if (tid == TAG_JPEG_INTERCHANGE_FORMAT_LENGTH
&& checkAllowed(ifd, ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH)) {
if (isThumbnailRequested()) {
- mJpegSizeTag = tag;
+ jpegSizeTag = tag;
}
} else if (tid == TAG_STRIP_OFFSETS && checkAllowed(ifd, ExifInterface.TAG_STRIP_OFFSETS)) {
if (isThumbnailRequested()) {
@@ -582,14 +582,14 @@ public class ExifParser {
}
}
} else {
- mCorrespondingEvent.put(tag.getOffset(), new ExifTagEvent(tag, false));
+ correspondingEvent.put(tag.getOffset(), new ExifTagEvent(tag, false));
}
}
} else if (tid == TAG_STRIP_BYTE_COUNTS
&& checkAllowed(ifd, ExifInterface.TAG_STRIP_BYTE_COUNTS)
&& isThumbnailRequested()
&& tag.hasValue()) {
- mStripSizeTag = tag;
+ stripSizeTag = tag;
}
}
@@ -605,15 +605,15 @@ public class ExifParser {
|| type == ExifTag.TYPE_UNDEFINED
|| type == ExifTag.TYPE_UNSIGNED_BYTE) {
int size = tag.getComponentCount();
- if (mCorrespondingEvent.size() > 0) {
- if (mCorrespondingEvent.firstEntry().getKey() < mTiffStream.getReadByteCount() + size) {
- Object event = mCorrespondingEvent.firstEntry().getValue();
+ if (correspondingEvent.size() > 0) {
+ if (correspondingEvent.firstEntry().getKey() < tiffStream.getReadByteCount() + size) {
+ Object event = correspondingEvent.firstEntry().getValue();
if (event instanceof ImageEvent) {
// Tag value overlaps thumbnail, ignore thumbnail.
LogUtil.i(
"ExifParser.readFullTagValue",
"Thumbnail overlaps value for tag: \n" + tag.toString());
- Entry<Integer, Object> entry = mCorrespondingEvent.pollFirstEntry();
+ Entry<Integer, Object> entry = correspondingEvent.pollFirstEntry();
LogUtil.i("ExifParser.readFullTagValue", "Invalid thumbnail offset: " + entry.getKey());
} else {
// Tag value overlaps another shorten count
@@ -629,7 +629,7 @@ public class ExifParser {
+ " overlaps value for tag: \n"
+ tag.toString());
}
- size = mCorrespondingEvent.firstEntry().getKey() - mTiffStream.getReadByteCount();
+ size = correspondingEvent.firstEntry().getKey() - tiffStream.getReadByteCount();
LogUtil.i(
"ExifParser.readFullTagValue",
"Invalid size of tag: \n" + tag.toString() + " setting count to: " + size);
@@ -702,16 +702,16 @@ public class ExifParser {
}
private void parseTiffHeader() throws IOException, ExifInvalidFormatException {
- short byteOrder = mTiffStream.readShort();
+ short byteOrder = tiffStream.readShort();
if (LITTLE_ENDIAN_TAG == byteOrder) {
- mTiffStream.setByteOrder(ByteOrder.LITTLE_ENDIAN);
+ tiffStream.setByteOrder(ByteOrder.LITTLE_ENDIAN);
} else if (BIG_ENDIAN_TAG == byteOrder) {
- mTiffStream.setByteOrder(ByteOrder.BIG_ENDIAN);
+ tiffStream.setByteOrder(ByteOrder.BIG_ENDIAN);
} else {
throw new ExifInvalidFormatException("Invalid TIFF header");
}
- if (mTiffStream.readShort() != TIFF_HEADER_TAIL) {
+ if (tiffStream.readShort() != TIFF_HEADER_TAIL) {
throw new ExifInvalidFormatException("Invalid TIFF header");
}
}
@@ -736,7 +736,7 @@ public class ExifParser {
headerTail = dataStream.readShort();
length -= 6;
if (header == EXIF_HEADER && headerTail == EXIF_HEADER_TAIL) {
- mApp1End = length;
+ app1End = length;
return true;
}
}
@@ -752,12 +752,12 @@ public class ExifParser {
/** Reads bytes from the InputStream. */
protected int read(byte[] buffer, int offset, int length) throws IOException {
- return mTiffStream.read(buffer, offset, length);
+ return tiffStream.read(buffer, offset, length);
}
/** Equivalent to read(buffer, 0, buffer.length). */
protected int read(byte[] buffer) throws IOException {
- return mTiffStream.read(buffer);
+ return tiffStream.read(buffer);
}
/**
@@ -774,7 +774,7 @@ public class ExifParser {
*/
private String readString(int n, Charset charset) throws IOException {
if (n > 0) {
- return mTiffStream.readString(n, charset);
+ return tiffStream.readString(n, charset);
} else {
return "";
}
@@ -782,7 +782,7 @@ public class ExifParser {
/** Reads value of type {@link ExifTag#TYPE_UNSIGNED_SHORT} from the InputStream. */
private int readUnsignedShort() throws IOException {
- return mTiffStream.readShort() & 0xffff;
+ return tiffStream.readShort() & 0xffff;
}
/** Reads value of type {@link ExifTag#TYPE_UNSIGNED_LONG} from the InputStream. */
@@ -799,7 +799,7 @@ public class ExifParser {
/** Reads value of type {@link ExifTag#TYPE_LONG} from the InputStream. */
private int readLong() throws IOException {
- return mTiffStream.readInt();
+ return tiffStream.readInt();
}
/** Reads value of type {@link ExifTag#TYPE_RATIONAL} from the InputStream. */
diff --git a/java/com/android/dialer/callcomposer/camera/exif/ExifTag.java b/java/com/android/dialer/callcomposer/camera/exif/ExifTag.java
index 9a03c103c..23948ed62 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/ExifTag.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/ExifTag.java
@@ -81,19 +81,19 @@ public class ExifTag {
static final int SIZE_UNDEFINED = 0;
// Exif TagId
- private final short mTagId;
+ private final short tagId;
// Exif Tag Type
- private final short mDataType;
+ private final short dataType;
// If tag has defined count
- private boolean mHasDefinedDefaultComponentCount;
+ private boolean hasDefinedDefaultComponentCount;
// Actual data count in tag (should be number of elements in value array)
- private int mComponentCountActual;
+ private int componentCountActual;
// The ifd that this tag should be put in
- private int mIfd;
+ private int ifd;
// The value (array of elements of type Tag Type)
- private Object mValue;
+ private Object value;
// Value offset in exif header.
- private int mOffset;
+ private int offset;
/** Returns true if the given IFD is a valid IFD. */
static boolean isValidIfd(int ifdId) {
@@ -118,12 +118,12 @@ public class ExifTag {
// Use builtTag in ExifInterface instead of constructor.
ExifTag(short tagId, short type, int componentCount, int ifd, boolean hasDefinedComponentCount) {
- mTagId = tagId;
- mDataType = type;
- mComponentCountActual = componentCount;
- mHasDefinedDefaultComponentCount = hasDefinedComponentCount;
- mIfd = ifd;
- mValue = null;
+ this.tagId = tagId;
+ dataType = type;
+ componentCountActual = componentCount;
+ hasDefinedDefaultComponentCount = hasDefinedComponentCount;
+ this.ifd = ifd;
+ value = null;
}
/**
@@ -152,16 +152,16 @@ public class ExifTag {
* @see IfdId#TYPE_IFD_INTEROPERABILITY
*/
int getIfd() {
- return mIfd;
+ return ifd;
}
void setIfd(int ifdId) {
- mIfd = ifdId;
+ ifd = ifdId;
}
/** Gets the TID of this tag. */
short getTagId() {
- return mTagId;
+ return tagId;
}
/**
@@ -177,7 +177,7 @@ public class ExifTag {
* @see #TYPE_UNSIGNED_SHORT
*/
short getDataType() {
- return mDataType;
+ return dataType;
}
/** Gets the total data size in bytes of the value of this tag. */
@@ -189,7 +189,7 @@ public class ExifTag {
// TODO(blemmon): fix integer overflows with this
int getComponentCount() {
- return mComponentCountActual;
+ return componentCountActual;
}
/**
@@ -197,7 +197,7 @@ public class ExifTag {
* value does not match the component count.
*/
void forceSetComponentCount(int count) {
- mComponentCountActual = count;
+ componentCountActual = count;
}
/**
@@ -205,7 +205,7 @@ public class ExifTag {
* that is determined when the tag is written.
*/
boolean hasValue() {
- return mValue != null;
+ return value != null;
}
/**
@@ -223,14 +223,14 @@ public class ExifTag {
if (checkBadComponentCount(value.length)) {
return false;
}
- if (mDataType != TYPE_UNSIGNED_SHORT
- && mDataType != TYPE_LONG
- && mDataType != TYPE_UNSIGNED_LONG) {
+ if (dataType != TYPE_UNSIGNED_SHORT
+ && dataType != TYPE_LONG
+ && dataType != TYPE_UNSIGNED_LONG) {
return false;
}
- if (mDataType == TYPE_UNSIGNED_SHORT && checkOverflowForUnsignedShort(value)) {
+ if (dataType == TYPE_UNSIGNED_SHORT && checkOverflowForUnsignedShort(value)) {
return false;
- } else if (mDataType == TYPE_UNSIGNED_LONG && checkOverflowForUnsignedLong(value)) {
+ } else if (dataType == TYPE_UNSIGNED_LONG && checkOverflowForUnsignedLong(value)) {
return false;
}
@@ -238,8 +238,8 @@ public class ExifTag {
for (int i = 0; i < value.length; i++) {
data[i] = value[i];
}
- mValue = data;
- mComponentCountActual = value.length;
+ this.value = data;
+ componentCountActual = value.length;
return true;
}
@@ -254,14 +254,14 @@ public class ExifTag {
* </ul>
*/
boolean setValue(long[] value) {
- if (checkBadComponentCount(value.length) || mDataType != TYPE_UNSIGNED_LONG) {
+ if (checkBadComponentCount(value.length) || dataType != TYPE_UNSIGNED_LONG) {
return false;
}
if (checkOverflowForUnsignedLong(value)) {
return false;
}
- mValue = value;
- mComponentCountActual = value.length;
+ this.value = value;
+ componentCountActual = value.length;
return true;
}
@@ -280,7 +280,7 @@ public class ExifTag {
* </ul>
*/
boolean setValue(String value) {
- if (mDataType != TYPE_ASCII && mDataType != TYPE_UNDEFINED) {
+ if (dataType != TYPE_ASCII && dataType != TYPE_UNDEFINED) {
return false;
}
@@ -288,18 +288,18 @@ public class ExifTag {
byte[] finalBuf = buf;
if (buf.length > 0) {
finalBuf =
- (buf[buf.length - 1] == 0 || mDataType == TYPE_UNDEFINED)
+ (buf[buf.length - 1] == 0 || dataType == TYPE_UNDEFINED)
? buf
: Arrays.copyOf(buf, buf.length + 1);
- } else if (mDataType == TYPE_ASCII && mComponentCountActual == 1) {
+ } else if (dataType == TYPE_ASCII && componentCountActual == 1) {
finalBuf = new byte[] {0};
}
int count = finalBuf.length;
if (checkBadComponentCount(count)) {
return false;
}
- mComponentCountActual = count;
- mValue = finalBuf;
+ componentCountActual = count;
+ this.value = finalBuf;
return true;
}
@@ -320,17 +320,17 @@ public class ExifTag {
if (checkBadComponentCount(value.length)) {
return false;
}
- if (mDataType != TYPE_UNSIGNED_RATIONAL && mDataType != TYPE_RATIONAL) {
+ if (dataType != TYPE_UNSIGNED_RATIONAL && dataType != TYPE_RATIONAL) {
return false;
}
- if (mDataType == TYPE_UNSIGNED_RATIONAL && checkOverflowForUnsignedRational(value)) {
+ if (dataType == TYPE_UNSIGNED_RATIONAL && checkOverflowForUnsignedRational(value)) {
return false;
- } else if (mDataType == TYPE_RATIONAL && checkOverflowForRational(value)) {
+ } else if (dataType == TYPE_RATIONAL && checkOverflowForRational(value)) {
return false;
}
- mValue = value;
- mComponentCountActual = value.length;
+ this.value = value;
+ componentCountActual = value.length;
return true;
}
@@ -348,12 +348,12 @@ public class ExifTag {
if (checkBadComponentCount(length)) {
return false;
}
- if (mDataType != TYPE_UNSIGNED_BYTE && mDataType != TYPE_UNDEFINED) {
+ if (dataType != TYPE_UNSIGNED_BYTE && dataType != TYPE_UNDEFINED) {
return false;
}
- mValue = new byte[length];
- System.arraycopy(value, offset, mValue, 0, length);
- mComponentCountActual = length;
+ this.value = new byte[length];
+ System.arraycopy(value, offset, this.value, 0, length);
+ componentCountActual = length;
return true;
}
@@ -370,10 +370,10 @@ public class ExifTag {
* be converted to an array of ints.
*/
int[] getValueAsInts() {
- if (mValue == null) {
+ if (value == null) {
return null;
- } else if (mValue instanceof long[]) {
- long[] val = (long[]) mValue;
+ } else if (value instanceof long[]) {
+ long[] val = (long[]) value;
int[] arr = new int[val.length];
for (int i = 0; i < val.length; i++) {
arr[i] = (int) val[i]; // Truncates
@@ -385,38 +385,38 @@ public class ExifTag {
/** Gets the tag's value or null if none exists. */
public Object getValue() {
- return mValue;
+ return value;
}
/** Gets a string representation of the value. */
private String forceGetValueAsString() {
- if (mValue == null) {
+ if (value == null) {
return "";
- } else if (mValue instanceof byte[]) {
- if (mDataType == TYPE_ASCII) {
- return new String((byte[]) mValue, US_ASCII);
+ } else if (value instanceof byte[]) {
+ if (dataType == TYPE_ASCII) {
+ return new String((byte[]) value, US_ASCII);
} else {
- return Arrays.toString((byte[]) mValue);
+ return Arrays.toString((byte[]) value);
}
- } else if (mValue instanceof long[]) {
- if (((long[]) mValue).length == 1) {
- return String.valueOf(((long[]) mValue)[0]);
+ } else if (value instanceof long[]) {
+ if (((long[]) value).length == 1) {
+ return String.valueOf(((long[]) value)[0]);
} else {
- return Arrays.toString((long[]) mValue);
+ return Arrays.toString((long[]) value);
}
- } else if (mValue instanceof Object[]) {
- if (((Object[]) mValue).length == 1) {
- Object val = ((Object[]) mValue)[0];
+ } else if (value instanceof Object[]) {
+ if (((Object[]) value).length == 1) {
+ Object val = ((Object[]) value)[0];
if (val == null) {
return "";
} else {
return val.toString();
}
} else {
- return Arrays.toString((Object[]) mValue);
+ return Arrays.toString((Object[]) value);
}
} else {
- return mValue.toString();
+ return value.toString();
}
}
@@ -428,13 +428,13 @@ public class ExifTag {
* #TYPE_UNSIGNED_RATIONAL}.
*/
long getValueAt(int index) {
- if (mValue instanceof long[]) {
- return ((long[]) mValue)[index];
- } else if (mValue instanceof byte[]) {
- return ((byte[]) mValue)[index];
+ if (value instanceof long[]) {
+ return ((long[]) value)[index];
+ } else if (value instanceof byte[]) {
+ return ((byte[]) value)[index];
}
throw new IllegalArgumentException(
- "Cannot get integer value from " + convertTypeToString(mDataType));
+ "Cannot get integer value from " + convertTypeToString(dataType));
}
/**
@@ -443,11 +443,11 @@ public class ExifTag {
* @exception IllegalArgumentException If the type is NOT {@link #TYPE_ASCII}.
*/
protected String getString() {
- if (mDataType != TYPE_ASCII) {
+ if (dataType != TYPE_ASCII) {
throw new IllegalArgumentException(
- "Cannot get ASCII value from " + convertTypeToString(mDataType));
+ "Cannot get ASCII value from " + convertTypeToString(dataType));
}
- return new String((byte[]) mValue, US_ASCII);
+ return new String((byte[]) value, US_ASCII);
}
/**
@@ -455,24 +455,24 @@ public class ExifTag {
* the location of the actual value.
*/
protected int getOffset() {
- return mOffset;
+ return offset;
}
/** Sets the offset of this tag. */
protected void setOffset(int offset) {
- mOffset = offset;
+ this.offset = offset;
}
void setHasDefinedCount(boolean d) {
- mHasDefinedDefaultComponentCount = d;
+ hasDefinedDefaultComponentCount = d;
}
boolean hasDefinedCount() {
- return mHasDefinedDefaultComponentCount;
+ return hasDefinedDefaultComponentCount;
}
private boolean checkBadComponentCount(int count) {
- return mHasDefinedDefaultComponentCount && (mComponentCountActual != count);
+ return hasDefinedDefaultComponentCount && (componentCountActual != count);
}
private static String convertTypeToString(short type) {
@@ -556,34 +556,34 @@ public class ExifTag {
}
if (obj instanceof ExifTag) {
ExifTag tag = (ExifTag) obj;
- if (tag.mTagId != this.mTagId
- || tag.mComponentCountActual != this.mComponentCountActual
- || tag.mDataType != this.mDataType) {
+ if (tag.tagId != this.tagId
+ || tag.componentCountActual != this.componentCountActual
+ || tag.dataType != this.dataType) {
return false;
}
- if (mValue != null) {
- if (tag.mValue == null) {
+ if (value != null) {
+ if (tag.value == null) {
return false;
- } else if (mValue instanceof long[]) {
- if (!(tag.mValue instanceof long[])) {
+ } else if (value instanceof long[]) {
+ if (!(tag.value instanceof long[])) {
return false;
}
- return Arrays.equals((long[]) mValue, (long[]) tag.mValue);
- } else if (mValue instanceof Rational[]) {
- if (!(tag.mValue instanceof Rational[])) {
+ return Arrays.equals((long[]) value, (long[]) tag.value);
+ } else if (value instanceof Rational[]) {
+ if (!(tag.value instanceof Rational[])) {
return false;
}
- return Arrays.equals((Rational[]) mValue, (Rational[]) tag.mValue);
- } else if (mValue instanceof byte[]) {
- if (!(tag.mValue instanceof byte[])) {
+ return Arrays.equals((Rational[]) value, (Rational[]) tag.value);
+ } else if (value instanceof byte[]) {
+ if (!(tag.value instanceof byte[])) {
return false;
}
- return Arrays.equals((byte[]) mValue, (byte[]) tag.mValue);
+ return Arrays.equals((byte[]) value, (byte[]) tag.value);
} else {
- return mValue.equals(tag.mValue);
+ return value.equals(tag.value);
}
} else {
- return tag.mValue == null;
+ return tag.value == null;
}
}
return false;
@@ -592,26 +592,20 @@ public class ExifTag {
@Override
public int hashCode() {
return Objects.hash(
- mTagId,
- mDataType,
- mHasDefinedDefaultComponentCount,
- mComponentCountActual,
- mIfd,
- mValue,
- mOffset);
+ tagId, dataType, hasDefinedDefaultComponentCount, componentCountActual, ifd, value, offset);
}
@Override
public String toString() {
- return String.format("tag id: %04X\n", mTagId)
+ return String.format("tag id: %04X\n", tagId)
+ "ifd id: "
- + mIfd
+ + ifd
+ "\ntype: "
- + convertTypeToString(mDataType)
+ + convertTypeToString(dataType)
+ "\ncount: "
- + mComponentCountActual
+ + componentCountActual
+ "\noffset: "
- + mOffset
+ + offset
+ "\nvalue: "
+ forceGetValueAsString()
+ "\n";
diff --git a/java/com/android/dialer/callcomposer/camera/exif/IfdData.java b/java/com/android/dialer/callcomposer/camera/exif/IfdData.java
index b808defc6..e85919e0a 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/IfdData.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/IfdData.java
@@ -16,7 +16,7 @@
package com.android.dialer.callcomposer.camera.exif;
-import java.util.HashMap;
+import android.support.v4.util.ArrayMap;
import java.util.Map;
import java.util.Objects;
@@ -28,9 +28,9 @@ import java.util.Objects;
*/
class IfdData {
- private final int mIfdId;
- private final Map<Short, ExifTag> mExifTags = new HashMap<>();
- private static final int[] sIfds = {
+ private final int ifdId;
+ private final Map<Short, ExifTag> exifTags = new ArrayMap<>();
+ private static final int[] ifds = {
IfdId.TYPE_IFD_0,
IfdId.TYPE_IFD_1,
IfdId.TYPE_IFD_EXIF,
@@ -47,16 +47,16 @@ class IfdData {
* @see IfdId#TYPE_IFD_INTEROPERABILITY
*/
IfdData(int ifdId) {
- mIfdId = ifdId;
+ this.ifdId = ifdId;
}
static int[] getIfds() {
- return sIfds;
+ return ifds;
}
/** Get a array the contains all {@link ExifTag} in this IFD. */
private ExifTag[] getAllTags() {
- return mExifTags.values().toArray(new ExifTag[mExifTags.size()]);
+ return exifTags.values().toArray(new ExifTag[exifTags.size()]);
}
/**
@@ -69,23 +69,23 @@ class IfdData {
* @see IfdId#TYPE_IFD_INTEROPERABILITY
*/
protected int getId() {
- return mIfdId;
+ return ifdId;
}
/** Gets the {@link ExifTag} with given tag id. Return null if there is no such tag. */
protected ExifTag getTag(short tagId) {
- return mExifTags.get(tagId);
+ return exifTags.get(tagId);
}
/** Adds or replaces a {@link ExifTag}. */
protected ExifTag setTag(ExifTag tag) {
- tag.setIfd(mIfdId);
- return mExifTags.put(tag.getTagId(), tag);
+ tag.setIfd(ifdId);
+ return exifTags.put(tag.getTagId(), tag);
}
/** Gets the tags count in the IFD. */
private int getTagCount() {
- return mExifTags.size();
+ return exifTags.size();
}
/**
@@ -102,13 +102,13 @@ class IfdData {
}
if (obj instanceof IfdData) {
IfdData data = (IfdData) obj;
- if (data.getId() == mIfdId && data.getTagCount() == getTagCount()) {
+ if (data.getId() == ifdId && data.getTagCount() == getTagCount()) {
ExifTag[] tags = data.getAllTags();
for (ExifTag tag : tags) {
if (ExifInterface.isOffsetTag(tag.getTagId())) {
continue;
}
- ExifTag tag2 = mExifTags.get(tag.getTagId());
+ ExifTag tag2 = exifTags.get(tag.getTagId());
if (!tag.equals(tag2)) {
return false;
}
@@ -121,6 +121,6 @@ class IfdData {
@Override
public int hashCode() {
- return Objects.hash(mIfdId, mExifTags);
+ return Objects.hash(ifdId, exifTags);
}
}
diff --git a/java/com/android/dialer/callcomposer/camera/exif/Rational.java b/java/com/android/dialer/callcomposer/camera/exif/Rational.java
index 9afca8449..d07778c31 100644
--- a/java/com/android/dialer/callcomposer/camera/exif/Rational.java
+++ b/java/com/android/dialer/callcomposer/camera/exif/Rational.java
@@ -24,23 +24,23 @@ import java.util.Objects;
*/
public class Rational {
- private final long mNumerator;
- private final long mDenominator;
+ private final long numerator;
+ private final long denominator;
/** Create a Rational with a given numerator and denominator. */
Rational(long nominator, long denominator) {
- mNumerator = nominator;
- mDenominator = denominator;
+ numerator = nominator;
+ this.denominator = denominator;
}
/** Gets the numerator of the rational. */
long getNumerator() {
- return mNumerator;
+ return numerator;
}
/** Gets the denominator of the rational */
long getDenominator() {
- return mDenominator;
+ return denominator;
}
@Override
@@ -53,18 +53,18 @@ public class Rational {
}
if (obj instanceof Rational) {
Rational data = (Rational) obj;
- return mNumerator == data.mNumerator && mDenominator == data.mDenominator;
+ return numerator == data.numerator && denominator == data.denominator;
}
return false;
}
@Override
public int hashCode() {
- return Objects.hash(mNumerator, mDenominator);
+ return Objects.hash(numerator, denominator);
}
@Override
public String toString() {
- return mNumerator + "/" + mDenominator;
+ return numerator + "/" + denominator;
}
}