From 9b93bcbe3ccc49db5ce42de19fda1d3a9ef0011b Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Fri, 4 Sep 2009 19:46:14 +0800 Subject: [PATCH] Code clean up. Change-Id: I8814d8482df5709b03ef105f547f4981db34919a --- src/com/android/camera/Camera.java | 14 ++++++-------- src/com/android/camera/CameraButtonIntentReceiver.java | 2 +- src/com/android/camera/CameraHardwareException.java | 16 ++++++++++++++++ src/com/android/camera/CameraSettings.java | 6 +++--- src/com/android/camera/ImageGallery.java | 6 +++--- src/com/android/camera/ImageViewTouchBase.java | 1 - src/com/android/camera/MenuHelper.java | 2 +- src/com/android/camera/OnScreenHint.java | 1 - src/com/android/camera/Switcher.java | 8 -------- src/com/android/camera/VideoCamera.java | 3 ++- src/com/android/camera/gallery/BaseImage.java | 2 -- src/com/android/camera/gallery/MiniThumbFile.java | 3 --- src/com/android/camera/gallery/SingleImageList.java | 3 --- 13 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index abd1257..89a5ad3 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -120,7 +120,7 @@ public class Camera extends Activity implements View.OnClickListener, public static final String ZOOM_IMMEDIATE = "zoom-immediate"; public static final String ZOOM_CONTINUOUS = "zoom-continuous"; public static final double ZOOM_MIN = 1.0; - public static final String ZOOM_SPEED ="99"; + public static final String ZOOM_SPEED = "99"; // The parameter strings to communicate with camera driver. public static final String PARM_ZOOM_STATE = "zoom-state"; @@ -215,7 +215,7 @@ public class Camera extends Activity implements View.OnClickListener, public long mJpegPictureCallbackTimeLag; public long mRawPictureAndJpegPictureCallbackTime; - //Add the media server tag + // Add the media server tag public static boolean mMediaServerDied = false; // Focus mode. Options are pref_camera_focusmode_entryvalues. private String mFocusMode; @@ -455,8 +455,7 @@ public class Camera extends Activity implements View.OnClickListener, // Wait for a while so we are not changing zoom too fast. try { Thread.currentThread().sleep(5); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { } } } else { @@ -467,8 +466,7 @@ public class Camera extends Activity implements View.OnClickListener, // Wait for a while so we are not changing zoom too fast. try { Thread.currentThread().sleep(5); - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { } } } @@ -667,7 +665,7 @@ public class Camera extends Activity implements View.OnClickListener, private final class ErrorCallback implements android.hardware.Camera.ErrorCallback { - public void onError(int error, android.hardware.Camera camera) { + public void onError(int error, android.hardware.Camera camera) { if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) { mMediaServerDied = true; Log.v(TAG, "media server died"); @@ -679,7 +677,7 @@ public class Camera extends Activity implements View.OnClickListener, implements android.hardware.Camera.ZoomCallback { public void onZoomUpdate(int zoomLevel, android.hardware.Camera camera) { - mZoomValue = (double)zoomLevel / 1000; + mZoomValue = (double) zoomLevel / 1000; mZooming = false; } } diff --git a/src/com/android/camera/CameraButtonIntentReceiver.java b/src/com/android/camera/CameraButtonIntentReceiver.java index 5926709..ce79440 100644 --- a/src/com/android/camera/CameraButtonIntentReceiver.java +++ b/src/com/android/camera/CameraButtonIntentReceiver.java @@ -29,7 +29,7 @@ public class CameraButtonIntentReceiver extends BroadcastReceiver { // Try to get the camera hardware try { CameraHolder holder = CameraHolder.instance(); - android.hardware.Camera device = holder.open(); + holder.open(); holder.keep(); holder.release(); } catch (CameraHardwareException e) { diff --git a/src/com/android/camera/CameraHardwareException.java b/src/com/android/camera/CameraHardwareException.java index f746f48..8316065 100644 --- a/src/com/android/camera/CameraHardwareException.java +++ b/src/com/android/camera/CameraHardwareException.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.camera; public class CameraHardwareException extends Exception { diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 7538120..799c89e 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -27,11 +27,9 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceGroup; -import android.util.Log; import java.util.ArrayList; import java.util.List; -import java.util.StringTokenizer; /** * CameraSettings @@ -49,7 +47,9 @@ public class CameraSettings extends PreferenceActivity implements public static final String KEY_FOCUS_MODE = "pref_camera_focusmode_key"; public static final String KEY_FLASH_MODE = "pref_camera_flashmode_key"; public static final boolean DEFAULT_VIDEO_QUALITY_VALUE = true; - public static final int DEFAULT_VIDEO_DURATION_VALUE = -1; // MMS video length + + // MMS video length + public static final int DEFAULT_VIDEO_DURATION_VALUE = -1; // max mms video duration in seconds. public static final int MMS_VIDEO_DURATION = diff --git a/src/com/android/camera/ImageGallery.java b/src/com/android/camera/ImageGallery.java index 6f0f801..b77428a 100644 --- a/src/com/android/camera/ImageGallery.java +++ b/src/com/android/camera/ImageGallery.java @@ -676,9 +676,9 @@ public class ImageGallery extends Activity implements // the selection box by setting the selected index to none. However, if // we use the dpad center key, we will keep the selected index in order // to show the the selection box. We do this because we have the - // multiselect marker on the images to indicate which of them are selected, - // so we don't need the selection box, but in the dpad case we still - // need the selection box to show as a "cursor". + // multiselect marker on the images to indicate which of them are + // selected, so we don't need the selection box, but in the dpad case + // we still need the selection box to show as a "cursor". if (isInMultiSelectMode()) { mGvs.setSelectedIndex(GridViewSpecial.INDEX_NONE); diff --git a/src/com/android/camera/ImageViewTouchBase.java b/src/com/android/camera/ImageViewTouchBase.java index 56b334f..1ca6843 100644 --- a/src/com/android/camera/ImageViewTouchBase.java +++ b/src/com/android/camera/ImageViewTouchBase.java @@ -252,7 +252,6 @@ abstract class ImageViewTouchBase extends ImageView { float w = bitmap.getWidth(); float h = bitmap.getHeight(); - int rotation = bitmap.getRotation(); matrix.reset(); // We limit up-scaling to 2x otherwise the result may look bad if it's diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java index ed208a6..09892bb 100644 --- a/src/com/android/camera/MenuHelper.java +++ b/src/com/android/camera/MenuHelper.java @@ -193,7 +193,7 @@ public class MenuHelper { // details dialog is dismissed or not. View view = mView.get(); if (view == null) return; - if (location != MenuHelper.EMPTY_STRING) { + if (!location.equals(MenuHelper.EMPTY_STRING)) { MenuHelper.setDetailsValue(view, location, R.id.details_location_value); } else { diff --git a/src/com/android/camera/OnScreenHint.java b/src/com/android/camera/OnScreenHint.java index c6824c7..9918428 100644 --- a/src/com/android/camera/OnScreenHint.java +++ b/src/com/android/camera/OnScreenHint.java @@ -17,7 +17,6 @@ package com.android.camera; import android.content.Context; -import android.content.res.Resources; import android.graphics.PixelFormat; import android.os.Handler; import android.view.Gravity; diff --git a/src/com/android/camera/Switcher.java b/src/com/android/camera/Switcher.java index 938f6a1..ba205a8 100644 --- a/src/com/android/camera/Switcher.java +++ b/src/com/android/camera/Switcher.java @@ -107,10 +107,6 @@ public class Switcher extends ImageView implements View.OnTouchListener { } private void startParkingAnimation() { - int drawableHeight = getDrawable().getIntrinsicHeight(); - int target = mSwitch - ? getHeight() - drawableHeight - mPaddingBottom - : mPaddingTop; mAnimationStartTime = AnimationUtils.currentAnimationTimeMillis(); } @@ -134,10 +130,6 @@ public class Switcher extends ImageView implements View.OnTouchListener { int drawableHeight = drawable.getIntrinsicHeight(); int drawableWidth = drawable.getIntrinsicWidth(); - if (drawable == null) { - return; // couldn't resolve the URI - } - if (drawableWidth == 0 || drawableHeight == 0) { return; // nothing to draw (empty bounds) } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 9aa72af..997223c 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -481,7 +481,8 @@ public class VideoCamera extends Activity implements View.OnClickListener, // This is a special case: the value -1 means we want to use the // device-dependent duration for MMS messages. The value is // represented in seconds. - mMaxVideoDurationInMs = 1000 * CameraSettings.MMS_VIDEO_DURATION; + mMaxVideoDurationInMs = + 1000 * CameraSettings.MMS_VIDEO_DURATION; } else { // 1 minute = 60000ms mMaxVideoDurationInMs = 60000 * minutes; diff --git a/src/com/android/camera/gallery/BaseImage.java b/src/com/android/camera/gallery/BaseImage.java index d3e6769..9539c21 100644 --- a/src/com/android/camera/gallery/BaseImage.java +++ b/src/com/android/camera/gallery/BaseImage.java @@ -20,12 +20,10 @@ import com.android.camera.BitmapManager; import com.android.camera.Util; import android.content.ContentResolver; -import android.content.ContentValues; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.ParcelFileDescriptor; -import android.provider.MediaStore.Images.ImageColumns; import android.util.Log; import java.io.FileNotFoundException; diff --git a/src/com/android/camera/gallery/MiniThumbFile.java b/src/com/android/camera/gallery/MiniThumbFile.java index a0df8d9..cee91c0 100644 --- a/src/com/android/camera/gallery/MiniThumbFile.java +++ b/src/com/android/camera/gallery/MiniThumbFile.java @@ -16,9 +16,6 @@ package com.android.camera.gallery; -import com.android.camera.Util; - -import android.graphics.Bitmap; import android.net.Uri; import android.os.Environment; import android.util.Log; diff --git a/src/com/android/camera/gallery/SingleImageList.java b/src/com/android/camera/gallery/SingleImageList.java index 322f3da..b6850aa 100644 --- a/src/com/android/camera/gallery/SingleImageList.java +++ b/src/com/android/camera/gallery/SingleImageList.java @@ -16,10 +16,7 @@ package com.android.camera.gallery; -import com.android.camera.ImageManager; - import android.content.ContentResolver; -import android.database.Cursor; import android.net.Uri; import java.util.HashMap; -- 2.11.0