diff options
Diffstat (limited to 'src/com/android/camera/util/CameraUtil.java')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index dbd078d14..68211d648 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -679,6 +679,16 @@ public class CameraUtil { rect.bottom = Math.round(rectF.bottom); } + public static Rect rectFToRect(RectF rectF) { + Rect rect = new Rect(); + rectFToRect(rectF, rect); + return rect; + } + + public static RectF rectToRectF(Rect r) { + return new RectF(r.left, r.top, r.right, r.bottom); + } + public static void prepareMatrix(Matrix matrix, boolean mirror, int displayOrientation, int viewWidth, int viewHeight) { // Need mirror for front camera. @@ -691,6 +701,21 @@ public class CameraUtil { matrix.postTranslate(viewWidth / 2f, viewHeight / 2f); } + public static void prepareMatrix(Matrix matrix, boolean mirror, int displayOrientation, + Rect previewRect) { + // Need mirror for front camera. + matrix.setScale(mirror ? -1 : 1, 1); + // This is the value for android.hardware.Camera.setDisplayOrientation. + matrix.postRotate(displayOrientation); + + // Camera driver coordinates range from (-1000, -1000) to (1000, 1000). + // We need to map camera driver coordinates to preview rect coordinates + Matrix mapping = new Matrix(); + mapping.setRectToRect(new RectF(-1000, -1000, 1000, 1000), rectToRectF(previewRect), + Matrix.ScaleToFit.FILL); + matrix.setConcat(mapping, matrix); + } + public static String createJpegName(long dateTaken) { synchronized (sImageFileNamer) { return sImageFileNamer.generateName(dateTaken); @@ -820,7 +845,10 @@ public class CameraUtil { * the right range. */ public static int[] getPhotoPreviewFpsRange(Parameters params) { - List<int[]> frameRates = params.getSupportedPreviewFpsRange(); + return getPhotoPreviewFpsRange(params.getSupportedPreviewFpsRange()); + } + + public static int[] getPhotoPreviewFpsRange(List<int[]> frameRates) { if (frameRates.size() == 0) { Log.e(TAG, "No suppoted frame rates returned!"); return null; @@ -902,6 +930,8 @@ public class CameraUtil { public static void playVideo(Activity activity, Uri uri, String title) { try { boolean isSecureCamera = ((CameraActivity)activity).isSecureCamera(); + UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA, + UsageStatistics.ACTION_PLAY_VIDEO, null); if (!isSecureCamera) { Intent intent = IntentHelper.getVideoPlayerIntent(activity, uri) .putExtra(Intent.EXTRA_TITLE, title) @@ -966,20 +996,4 @@ public class CameraUtil { } return ret; } - - /** - * Launches apps supporting action {@link Intent.ACTION_MAIN} of category - * {@link Intent.CATEGORY_APP_GALLERY}. Note that - * {@link Intent.CATEGORY_APP_GALLERY} is only available on API level 15+. - * - * @param ctx The {@link android.content.Context} to launch the app. - * @return {@code true} on success. - */ - public static boolean launchGallery(Context ctx) { - if (ApiHelper.HAS_APP_GALLERY) { - ctx.startActivity(IntentHelper.getGalleryIntent(ctx)); - return true; - } - return false; - } } |