From: Doris Liu Date: Wed, 31 Jul 2013 18:25:09 +0000 (-0700) Subject: Set default video quality to the highest X-Git-Tag: android-x86-7.1-r1~499 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=17f5d9c8ec1074f60ee89d6f7529b939c6d63d76;p=android-x86%2Fpackages-apps-Gallery2.git Set default video quality to the highest Bug: 9886141 Change-Id: I4741d5c898ac666923cfc12abc78d5d3517cb05f --- diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index f58045007..f4de5c9ff 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -125,9 +125,6 @@ public class ApiHelper { public static final boolean HAS_CAMERA_METERING_AREA = Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH; - public static final boolean HAS_FINE_RESOLUTION_QUALITY_LEVELS = - Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; - public static final boolean HAS_MOTION_EVENT_TRANSFORM = Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; diff --git a/res/xml/video_preferences.xml b/res/xml/video_preferences.xml index faf5f655b..79154e653 100644 --- a/res/xml/video_preferences.xml +++ b/res/xml/video_preferences.xml @@ -19,7 +19,6 @@ camera:title="@string/pref_camcorder_settings_category"> diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 4e9a5ddfe..3558014cc 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -93,16 +93,16 @@ public class CameraSettings { return group; } - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - public static String getDefaultVideoQuality(int cameraId, + public static String getSupportedHighestVideoQuality(int cameraId, String defaultQuality) { - if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) { - if (CamcorderProfile.hasProfile( - cameraId, Integer.valueOf(defaultQuality))) { - return defaultQuality; - } - } - return Integer.toString(CamcorderProfile.QUALITY_HIGH); + // When launching the camera app first time, we will set the video quality + // to the first one (i.e. highest quality) in the supported list + List supported = getSupportedVideoQuality(cameraId); + if (supported == null) { + Log.e(TAG, "No supported video quality is found"); + return defaultQuality; + } + return supported.get(0); } public static void initialCameraPictureSize( @@ -177,7 +177,7 @@ public class CameraSettings { // Since the screen could be loaded from different resources, we need // to check if the preference is available here if (videoQuality != null) { - filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality()); + filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality(mCameraId)); } if (pictureSize != null) { @@ -532,37 +532,19 @@ public class CameraSettings { writePreferredCameraId(preferences, currentCameraId); } - private ArrayList getSupportedVideoQuality() { + private static ArrayList getSupportedVideoQuality(int cameraId) { ArrayList supported = new ArrayList(); // Check for supported quality - if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) { - getFineResolutionQuality(supported); - } else { - supported.add(Integer.toString(CamcorderProfile.QUALITY_HIGH)); - CamcorderProfile high = CamcorderProfile.get( - mCameraId, CamcorderProfile.QUALITY_HIGH); - CamcorderProfile low = CamcorderProfile.get( - mCameraId, CamcorderProfile.QUALITY_LOW); - if (high.videoFrameHeight * high.videoFrameWidth > - low.videoFrameHeight * low.videoFrameWidth) { - supported.add(Integer.toString(CamcorderProfile.QUALITY_LOW)); - } - } - - return supported; - } - - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - private void getFineResolutionQuality(ArrayList supported) { - if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) { + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_1080P)) { supported.add(Integer.toString(CamcorderProfile.QUALITY_1080P)); } - if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) { + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_720P)) { supported.add(Integer.toString(CamcorderProfile.QUALITY_720P)); } - if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) { + if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) { supported.add(Integer.toString(CamcorderProfile.QUALITY_480P)); } + return supported; } private void initVideoEffect(PreferenceGroup group, ListPreference videoEffect) { diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index e3efa22b6..956890e5e 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -472,20 +472,10 @@ public class VideoModule implements CameraModule, if (effectsActive()) { mUI.overrideSettings( CameraSettings.KEY_VIDEO_QUALITY, - Integer.toString(getLowVideoQuality())); + Integer.toString(CamcorderProfile.QUALITY_480P)); } } - @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) - private static int getLowVideoQuality() { - if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) { - return CamcorderProfile.QUALITY_480P; - } else { - return CamcorderProfile.QUALITY_LOW; - } - } - - @Override public void onOrientationChanged(int orientation) { // We keep the last known orientation. So if the user first orient @@ -565,7 +555,7 @@ public class VideoModule implements CameraModule, // back to use SurfaceTexture for preview and we need to stop then start // the preview. This will cause the preview flicker since the preview // will not be continuous for a short period of time. - // TODO: need to get the capture animation to work + // TODO: need to get the capture animation to work // ((CameraScreenNail) mActivity.mCameraScreenNail).animateCapture(mDisplayRotation); mUI.enablePreviewThumb(true); @@ -613,11 +603,14 @@ public class VideoModule implements CameraModule, private void readVideoPreferences() { // The preference stores values from ListPreference and is thus string type for all values. // We need to convert it to int manually. - String defaultQuality = CameraSettings.getDefaultVideoQuality(mCameraId, - mActivity.getResources().getString(R.string.pref_video_quality_default)); - String videoQuality = - mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY, - defaultQuality); + String videoQuality = mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY, + null); + if (videoQuality == null) { + // check for highest quality before setting default value + videoQuality = CameraSettings.getSupportedHighestVideoQuality(mCameraId, + mActivity.getResources().getString(R.string.pref_video_quality_default)); + mPreferences.edit().putString(CameraSettings.KEY_VIDEO_QUALITY, videoQuality); + } int quality = Integer.valueOf(videoQuality); // Set video quality. @@ -649,7 +642,7 @@ public class VideoModule implements CameraModule, // Set quality to be no higher than 480p. CamcorderProfile profile = CamcorderProfile.get(mCameraId, quality); if (profile.videoFrameHeight > 480) { - quality = getLowVideoQuality(); + quality = CamcorderProfile.QUALITY_480P; } } else { mEffectParameter = null;