summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2009-04-29 11:57:06 +0800
committerChih-Chung Chang <chihchung@google.com>2009-04-29 12:22:25 +0800
commit6b270508bdbc78a52a825c2d934465d99fb779f7 (patch)
treeae4072af85a0ad0bd873425a952d09a2e7f435ca
parent27576d1b5abbddfc3da7add5a9b9f602d9e9e954 (diff)
downloadLegacyCamera-6b270508bdbc78a52a825c2d934465d99fb779f7.zip
LegacyCamera-6b270508bdbc78a52a825c2d934465d99fb779f7.tar.gz
LegacyCamera-6b270508bdbc78a52a825c2d934465d99fb779f7.tar.bz2
Code clean up.
-rw-r--r--src/com/android/camera/Camera.java8
-rw-r--r--src/com/android/camera/GalleryPicker.java57
-rw-r--r--src/com/android/camera/GridViewSpecial.java20
-rw-r--r--src/com/android/camera/ImageGallery.java12
-rw-r--r--src/com/android/camera/ImageLoader.java1
-rw-r--r--src/com/android/camera/MenuHelper.java17
-rw-r--r--src/com/android/camera/MovieView.java2
-rw-r--r--src/com/android/camera/PriorityTask.java16
-rw-r--r--src/com/android/camera/PriorityTaskQueue.java16
-rw-r--r--src/com/android/camera/VideoCamera.java2
-rw-r--r--src/com/android/camera/gallery/BaseImage.java3
-rw-r--r--src/com/android/camera/gallery/BaseImageList.java1
-rw-r--r--src/com/android/camera/gallery/DrmImageList.java1
-rw-r--r--src/com/android/camera/gallery/Image.java5
-rw-r--r--src/com/android/camera/gallery/ImageList.java2
15 files changed, 99 insertions, 64 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 8f8bce9..2167b2a 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -29,7 +29,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
-import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
@@ -59,13 +58,13 @@ import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
-import android.view.MenuItem.OnMenuItemClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@@ -1051,8 +1050,7 @@ public class Camera extends Activity implements View.OnClickListener,
if (mCurrentBrightness < BRIGHTNESS_MIN) {
mCurrentBrightness = BRIGHTNESS_MIN;
}
- }
- catch (NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
// Use the default value if it cannot be parsed.
mCurrentBrightness = BRIGHTNESS_DEFAULT;
}
@@ -1409,7 +1407,7 @@ public class Camera extends Activity implements View.OnClickListener,
return;
}
- if (!ensureCameraDevice() ) return;
+ if (!ensureCameraDevice()) return;
if (mSurfaceHolder == null) return;
diff --git a/src/com/android/camera/GalleryPicker.java b/src/com/android/camera/GalleryPicker.java
index b88fbf4..9590a84 100644
--- a/src/com/android/camera/GalleryPicker.java
+++ b/src/com/android/camera/GalleryPicker.java
@@ -26,7 +26,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -41,23 +40,22 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.StatFs;
-import android.preference.PreferenceManager;
import android.provider.MediaStore.Images;
import android.util.Log;
import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.MenuItem.OnMenuItemClickListener;
import android.widget.AdapterView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.AdapterView.AdapterContextMenuInfo;
import java.util.ArrayList;
import java.util.HashMap;
@@ -80,15 +78,10 @@ public class GalleryPicker extends Activity {
Dialog mMediaScanningDialog;
- SharedPreferences mPrefs;
-
boolean mPausing = false;
private static final long LOW_STORAGE_THRESHOLD = 1024 * 1024 * 2;
- public GalleryPicker() {
- }
-
private void rebake(boolean unmounted, boolean scanning) {
if (mMediaScanningDialog != null) {
mMediaScanningDialog.cancel();
@@ -111,7 +104,6 @@ public class GalleryPicker extends Activity {
// Warn the user if space is getting low
Thread t = new Thread(new Runnable() {
public void run() {
-
// Check available space only if we are writable
if (ImageManager.hasStorage()) {
String storageDirectory = Environment
@@ -120,7 +112,6 @@ public class GalleryPicker extends Activity {
long remaining = (long) stat.getAvailableBlocks()
* (long) stat.getBlockSize();
if (remaining < LOW_STORAGE_THRESHOLD) {
-
mHandler.post(new Runnable() {
public void run() {
Toast.makeText(GalleryPicker.this
@@ -155,13 +146,12 @@ public class GalleryPicker extends Activity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
-
setContentView(R.layout.gallerypicker);
mNoImagesView = findViewById(R.id.no_images);
mGridView = (GridView) findViewById(R.id.albums);
mGridView.setSelector(android.R.color.transparent);
+ setBackgrounds(getResources());
mReceiver = new BroadcastReceiver() {
@Override
@@ -345,7 +335,7 @@ public class GalleryPicker extends Activity {
case TYPE_NORMAL_FOLDERS:
return R.drawable.frame_overlay_gallery_folder;
default:
- return -1;
+ return -1;
}
}
@@ -410,37 +400,39 @@ public class GalleryPicker extends Activity {
BitmapThread mWorkerThread;
public void init(boolean assumeMounted) {
+
+ if (mWorkerThread != null) {
+ try {
+ mDone = true;
+ mWorkerThread.join();
+ } finally {
+ mWorkerThread = null;
+ }
+ }
+
mItems.clear();
- IImageList images;
+ IImageList allImages;
if (assumeMounted) {
- images = ImageManager.allImages(
+ allImages = ImageManager.allImages(
getContentResolver(),
ImageManager.DataLocation.ALL,
ImageManager.INCLUDE_IMAGES
| ImageManager.INCLUDE_VIDEOS,
ImageManager.SORT_DESCENDING);
} else {
- images = ImageManager.emptyImageList();
+ allImages = ImageManager.emptyImageList();
}
- if (mWorkerThread != null) {
- try {
- mDone = true;
- mWorkerThread.join();
- } finally {
- mWorkerThread = null;
- }
- }
- String cameraItem = ImageManager.CAMERA_IMAGE_BUCKET_ID;
- final HashMap<String, String> hashMap = images.getBucketIds();
+ String cameraBucket = ImageManager.CAMERA_IMAGE_BUCKET_ID;
+ final HashMap<String, String> hashMap = allImages.getBucketIds();
for (Map.Entry<String, String> entry : hashMap.entrySet()) {
String key = entry.getKey();
if (key == null) {
continue;
}
- if (!key.equals(cameraItem)) {
+ if (!key.equals(cameraBucket)) {
IImageList list = createImageList(
ImageManager.INCLUDE_IMAGES
| ImageManager.INCLUDE_VIDEOS, key);
@@ -448,7 +440,7 @@ public class GalleryPicker extends Activity {
entry.getValue(), list));
}
}
- images.deactivate();
+ allImages.deactivate();
// Add lists to mItems.
IImageList[] lists = new IImageList[4];
@@ -462,7 +454,7 @@ public class GalleryPicker extends Activity {
// lists[i-2] is the corresponding Camera Images/Camera Videos.
// We want to add the "All" list only if it's different from
// the "Camera" list.
- if (i >= 2 && lists[i].getCount() == lists[i-2].getCount()) {
+ if (i >= 2 && lists[i].getCount() == lists[i - 2].getCount()) {
continue;
}
@@ -626,7 +618,6 @@ public class GalleryPicker extends Activity {
BitmapManager.instance().allowAllDecoding();
mAdapter = new GalleryPickerAdapter();
mGridView.setAdapter(mAdapter);
- setBackgrounds(getResources());
boolean scanning = ImageManager.isMediaScannerScanning(
getContentResolver());
@@ -685,7 +676,7 @@ public class GalleryPicker extends Activity {
// images
imageHeight = (imageHeight - padding) / 2; // per row and column
- final Paint p = new Paint();
+ final Paint p = new Paint();
final Bitmap b = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
final Canvas c = new Canvas(b);
diff --git a/src/com/android/camera/GridViewSpecial.java b/src/com/android/camera/GridViewSpecial.java
index 5d9deff..102f410 100644
--- a/src/com/android/camera/GridViewSpecial.java
+++ b/src/com/android/camera/GridViewSpecial.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;
import com.android.camera.gallery.IImage;
@@ -14,11 +30,11 @@ import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
+import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
-import android.view.GestureDetector.SimpleOnGestureListener;
import android.widget.Scroller;
class GridViewSpecial extends View {
@@ -306,7 +322,7 @@ class GridViewSpecial extends View {
mMaxScrollY = spec.mCellSpacing
+ (rows
* (spec.mCellSpacing + spec.mCellHeight))
- - (bottom - top) ;
+ - (bottom - top);
if (mImageBlockManager == null) {
mImageBlockManager = new ImageBlockManager(mLoader);
mImageBlockManager.moveDataWindow(true);
diff --git a/src/com/android/camera/ImageGallery.java b/src/com/android/camera/ImageGallery.java
index 29b46a8..54588e0 100644
--- a/src/com/android/camera/ImageGallery.java
+++ b/src/com/android/camera/ImageGallery.java
@@ -452,8 +452,7 @@ public class ImageGallery extends Activity implements
if (type != null) {
if (isImageType(type)) {
MenuHelper.addCapturePictureMenuItems(menu, this);
- }
- else if (isVideoType(type)) {
+ } else if (isVideoType(type)) {
MenuHelper.addCaptureVideoMenuItems(menu, this);
}
}
@@ -468,7 +467,8 @@ public class ImageGallery extends Activity implements
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Intent preferences = new Intent();
- preferences.setClass(ImageGallery.this, GallerySettings.class);
+ preferences.setClass(ImageGallery.this,
+ GallerySettings.class);
startActivity(preferences);
return true;
}
@@ -644,7 +644,7 @@ public class ImageGallery extends Activity implements
private final TextView mProgressTextView;
private final String mProgressTextFormatString;
boolean mDidSetProgress = false;
- private long lastUpdateTime; // initialized to 0
+ private long mLastUpdateTime; // initialized to 0
private PowerManager.WakeLock mWakeLock;
private MyThumbCheckCallback() {
@@ -680,7 +680,7 @@ public class ImageGallery extends Activity implements
// second since last update, to avoid the UI thread
// being overwhelmed by the update).
long currentTime = System.currentTimeMillis();
- if (currentTime - lastUpdateTime > 1000) {
+ if (currentTime - mLastUpdateTime > 1000) {
mHandler.post(new Runnable() {
public void run() {
String s = String.format(mProgressTextFormatString,
@@ -688,7 +688,7 @@ public class ImageGallery extends Activity implements
mProgressTextView.setText(s);
}
});
- lastUpdateTime = currentTime;
+ mLastUpdateTime = currentTime;
}
return !mPausing;
}
diff --git a/src/com/android/camera/ImageLoader.java b/src/com/android/camera/ImageLoader.java
index 667bd5b..778d3b9 100644
--- a/src/com/android/camera/ImageLoader.java
+++ b/src/com/android/camera/ImageLoader.java
@@ -20,7 +20,6 @@ import com.android.camera.gallery.IImage;
import com.android.camera.gallery.IImageList;
import android.graphics.Bitmap;
-import android.net.Uri;
import android.os.Handler;
import android.util.Log;
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index 0e3658c..feb9256 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -51,8 +51,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
-import java.util.StringTokenizer;
public class MenuHelper {
private static final String TAG = "MenuHelper";
@@ -286,7 +284,8 @@ public class MenuHelper {
return;
}
- final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ final AlertDialog.Builder builder =
+ new AlertDialog.Builder(activity);
final View d = View.inflate(activity, R.layout.detailsview,
null);
@@ -434,8 +433,10 @@ public class MenuHelper {
activity.getString(R.string.details_dimension_x),
dimensionWidth, dimensionHeight);
} else {
- String width = img.getExifTag(ExifInterface.TAG_IMAGE_WIDTH);
- String height = img.getExifTag(ExifInterface.TAG_IMAGE_LENGTH);
+ String width = img.getExifTag(
+ ExifInterface.TAG_IMAGE_WIDTH);
+ String height = img.getExifTag(
+ ExifInterface.TAG_IMAGE_LENGTH);
if (width != null && height != null) {
value = EMPTY_STRING + width + " x " + height;
}
@@ -503,7 +504,8 @@ public class MenuHelper {
handler.post(
new Runnable() {
public void run() {
- builder.setIcon(android.R.drawable.ic_dialog_info)
+ builder.setIcon(
+ android.R.drawable.ic_dialog_info)
.setTitle(R.string.details_panel_title)
.setView(d)
.show();
@@ -718,7 +720,8 @@ public class MenuHelper {
MenuItem detailsMenu = menu.add(0, 0, 80, R.string.details)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- return onDetailsClicked(onInvoke, handler, activity, isImage);
+ return onDetailsClicked(onInvoke, handler, activity,
+ isImage);
}
});
detailsMenu.setIcon(R.drawable.ic_menu_view_details);
diff --git a/src/com/android/camera/MovieView.java b/src/com/android/camera/MovieView.java
index 956e3b9..0f1eccd 100644
--- a/src/com/android/camera/MovieView.java
+++ b/src/com/android/camera/MovieView.java
@@ -21,9 +21,9 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
-import android.content.Intent;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
diff --git a/src/com/android/camera/PriorityTask.java b/src/com/android/camera/PriorityTask.java
index afbdb89..db8ed3c 100644
--- a/src/com/android/camera/PriorityTask.java
+++ b/src/com/android/camera/PriorityTask.java
@@ -1,4 +1,18 @@
-// Copyright 2009 Google Inc. All Rights Reserved.
+/*
+ * 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;
diff --git a/src/com/android/camera/PriorityTaskQueue.java b/src/com/android/camera/PriorityTaskQueue.java
index 93aeaf2..bbd4910 100644
--- a/src/com/android/camera/PriorityTaskQueue.java
+++ b/src/com/android/camera/PriorityTaskQueue.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;
import java.lang.ref.WeakReference;
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index a39ad59..c1a3e2a 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -46,11 +46,11 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
-import android.view.MenuItem.OnMenuItemClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;
diff --git a/src/com/android/camera/gallery/BaseImage.java b/src/com/android/camera/gallery/BaseImage.java
index 33554ce..4bd542a 100644
--- a/src/com/android/camera/gallery/BaseImage.java
+++ b/src/com/android/camera/gallery/BaseImage.java
@@ -156,7 +156,8 @@ public abstract class BaseImage implements IImage {
private class LoadBitmapCancelable extends BaseCancelable<Bitmap> {
private final ParcelFileDescriptor mPFD;
- private final BitmapFactory.Options mOptions = new BitmapFactory.Options();
+ private final BitmapFactory.Options mOptions =
+ new BitmapFactory.Options();
private final int mTargetWidthHeight;
public LoadBitmapCancelable(
diff --git a/src/com/android/camera/gallery/BaseImageList.java b/src/com/android/camera/gallery/BaseImageList.java
index 17e8b65..b40c008 100644
--- a/src/com/android/camera/gallery/BaseImageList.java
+++ b/src/com/android/camera/gallery/BaseImageList.java
@@ -16,7 +16,6 @@
package com.android.camera.gallery;
-import com.android.camera.BitmapManager;
import com.android.camera.ExifInterface;
import com.android.camera.ImageManager;
import com.android.camera.Util;
diff --git a/src/com/android/camera/gallery/DrmImageList.java b/src/com/android/camera/gallery/DrmImageList.java
index 68e9c07..36fe4f8 100644
--- a/src/com/android/camera/gallery/DrmImageList.java
+++ b/src/com/android/camera/gallery/DrmImageList.java
@@ -17,7 +17,6 @@
package com.android.camera.gallery;
import com.android.camera.ImageManager;
-import com.android.camera.gallery.IImage;
import android.content.ContentResolver;
import android.database.Cursor;
diff --git a/src/com/android/camera/gallery/Image.java b/src/com/android/camera/gallery/Image.java
index a8a6796..2d60a47 100644
--- a/src/com/android/camera/gallery/Image.java
+++ b/src/com/android/camera/gallery/Image.java
@@ -18,7 +18,6 @@ package com.android.camera.gallery;
import com.android.camera.BitmapManager;
import com.android.camera.ExifInterface;
-import com.android.camera.ImageManager;
import com.android.camera.Util;
import android.content.ContentResolver;
@@ -34,7 +33,6 @@ import android.util.Log;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.HashMap;
/**
* The class for normal images in gallery.
@@ -261,7 +259,8 @@ public class Image extends BaseImage implements IImage {
}
public ICancelable<Boolean> saveImageContents(Bitmap image,
- byte [] jpegData, int orientation, boolean newFile, String filePath) {
+ byte [] jpegData, int orientation, boolean newFile,
+ String filePath) {
return new SaveImageContentsCancelable(
image, jpegData, orientation, filePath);
}
diff --git a/src/com/android/camera/gallery/ImageList.java b/src/com/android/camera/gallery/ImageList.java
index 2cd382b..36fea22 100644
--- a/src/com/android/camera/gallery/ImageList.java
+++ b/src/com/android/camera/gallery/ImageList.java
@@ -24,8 +24,8 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.BaseColumns;
import android.provider.MediaStore.Images;
-import android.provider.MediaStore.MediaColumns;
import android.provider.MediaStore.Images.ImageColumns;
+import android.provider.MediaStore.MediaColumns;
import android.util.Log;
import java.util.HashMap;