diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-11-13 15:34:11 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-11-13 16:05:45 +0800 |
commit | 13161c7fe39bf019a334d8ea7e4eaddc1988adad (patch) | |
tree | 0d61a37b70d10e2275f34a872077937ae4834f0e /src | |
parent | 70027ba6263ffc7958a24ad8524e7e0a00323816 (diff) | |
download | packages_apps_LegacyCamera-13161c7fe39bf019a334d8ea7e4eaddc1988adad.zip packages_apps_LegacyCamera-13161c7fe39bf019a334d8ea7e4eaddc1988adad.tar.gz packages_apps_LegacyCamera-13161c7fe39bf019a334d8ea7e4eaddc1988adad.tar.bz2 |
Change the thumbnail list to a single thumbnail.
UI was re-designed.
bug:3156693
Change-Id: I766aab7dce9030f3b2800ea0995e7f4e118241a6
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 71 | ||||
-rw-r--r-- | src/com/android/camera/ThumbnailAdapter.java | 101 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 72 |
3 files changed, 2 insertions, 242 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 3cb0b71..91af236 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -78,11 +78,6 @@ import android.view.ViewStub; import android.view.Window; import android.view.WindowManager; import android.view.MenuItem.OnMenuItemClickListener; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.Button; -import android.widget.CursorAdapter; -import android.widget.ListView; import java.io.File; import java.io.FileNotFoundException; @@ -170,15 +165,8 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, private GLRootView mGLRootView; - // The layouts of small devices have a thumbnail button, which shows the last - // captured picture. + // The last captured picture. private RotateImageView mThumbnailButton; - // The layouts of xlarge devices have a list of thumbnails, which show the - // last captured pictures. - private ListView mThumbnailList; - private OnItemClickListener mThumbnailItemClickListener = - new ThumbnailItemClickListener(); - private ThumbnailAdapter mThumbnailAdapter; // mCropValue and mSaveUri are used only if isImageCaptureIntent() is true. private String mCropValue; @@ -350,7 +338,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, if (!mIsImageCaptureIntent) { findViewById(R.id.camera_switch).setOnClickListener(this); initThumbnailButton(); - initThumbnailList(); } // Initialize shutter button. @@ -428,54 +415,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, mThumbnailButton.setData(uri, lastPictureThumb); } - private void initThumbnailList() { - mThumbnailList = (ListView) findViewById(R.id.thumbnail_list); - if (mThumbnailList == null) return; - - int width = mThumbnailList.getWidth(); - int height = mThumbnailList.getHeight(); - - // Add gallery button to header view. - if (mThumbnailList.getHeaderViewsCount() == 0) { - Button b = new Button(this); - ListView.LayoutParams params = new ListView.LayoutParams(width, width); - b.setId(R.id.btn_gallery); - b.setLayoutParams(params); - b.setOnClickListener(this); - b.setBackgroundResource(R.drawable.ic_menu_gallery); - mThumbnailList.addHeaderView(b); - } - - // Set data adapter. - int thumbnailCount = (height + mThumbnailList.getDividerHeight()) - / (width + mThumbnailList.getDividerHeight()) - 1; - Cursor cursor = getThumbnailsCursor(thumbnailCount); - mThumbnailAdapter = new ThumbnailAdapter( - getApplicationContext(), R.layout.thumbnail_item, cursor, true); - mThumbnailList.setAdapter(mThumbnailAdapter); - mThumbnailList.setOnItemClickListener(mThumbnailItemClickListener); - } - - private void updateThumbnailList() { - if (mThumbnailList == null) return; - mThumbnailAdapter.getCursor().requery(); - mThumbnailAdapter.notifyDataSetChanged(); - } - - private Cursor getThumbnailsCursor(int thumbnailCount) { - Log.v(TAG, "thumbnailCount=" + thumbnailCount); - String[] projections = { MediaStore.Images.Thumbnails._ID }; - Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI - .buildUpon() - .appendQueryParameter("limit", String.valueOf(thumbnailCount)) - .build(); - // TODO: managedQuery is deprecated. - return managedQuery(uri, projections, - Media.MIME_TYPE + " = 'image/jpeg' AND " + Media.BUCKET_ID + " = ?", - new String[] {ImageManager.CAMERA_IMAGE_BUCKET_ID}, - ImageColumns._ID + " DESC"); - } - // If the activity is paused and resumed, this method will be called in // onResume. private void initializeSecondTime() { @@ -639,7 +578,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, checkStorage(); if (!mIsImageCaptureIntent) { updateThumbnailButton(); - updateThumbnailList(); } } } @@ -913,7 +851,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, "com.android.camera.NEW_PICTURE", mLastContentUri)); setLastPictureThumb(data, degree, mImageCapture.getLastCaptureUri()); - updateThumbnailList(); } else { mCaptureOnlyData = data; if (!mQuickCapture) { @@ -1319,12 +1256,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, } } - private class ThumbnailItemClickListener implements OnItemClickListener { - public void onItemClick(AdapterView<?> p, View v, int pos, long id) { - viewImage((RotateImageView)v); - } - } - private Bitmap createCaptureBitmap(byte[] data) { // This is really stupid...we just want to read the orientation in // the jpeg header. diff --git a/src/com/android/camera/ThumbnailAdapter.java b/src/com/android/camera/ThumbnailAdapter.java deleted file mode 100644 index ba3fb68..0000000 --- a/src/com/android/camera/ThumbnailAdapter.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2010 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 android.content.Context; -import android.database.Cursor; -import android.graphics.Bitmap; -import android.net.Uri; -import android.provider.MediaStore; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ResourceCursorAdapter; -import android.util.Log; - -import java.lang.Math; -import java.util.LinkedHashMap; -import java.util.Map; - -public class ThumbnailAdapter extends ResourceCursorAdapter { - private final String TAG = "ThumbnailAdapter"; - private int idIndex; - private boolean mIsImage; - private LinkedHashMap<String, Bitmap> mMap; - - public ThumbnailAdapter(Context context, int layout, Cursor c, - boolean isImage) { - super(context, layout, c, false); - mIsImage = isImage; - if (mIsImage) { - idIndex = c.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID); - } else { - idIndex = c.getColumnIndexOrThrow(MediaStore.Video.Thumbnails._ID); - } - final int capacity = Math.max(c.getCount() * 2, 16); - mMap = new LinkedHashMap<String, Bitmap>(16, 0.75f, true) { - @Override - protected boolean removeEldestEntry(Map.Entry<String, Bitmap> eldest) { - return size() > capacity; - } - }; - - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - int id = cursor.getInt(idIndex); - Bitmap b; - Uri uri; - RotateImageView v = (RotateImageView) view; - - if (mIsImage) { - uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, - Integer.toString(id)); - } else { - uri = Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, - Integer.toString(id)); - } - long start = System.currentTimeMillis(); - // Sometimes MetadataRetriever fails to generate video thumbnail. To - // avoid wasting time to get thumbnail again, null is still put into - // hash map. - if (!mMap.containsKey(uri.toString())) { - if (mIsImage) { - b = MediaStore.Images.Thumbnails.getThumbnail( - context.getContentResolver(), id, - MediaStore.Images.Thumbnails.MICRO_KIND, null); - } else { - b = MediaStore.Video.Thumbnails.getThumbnail( - context.getContentResolver(), id, - MediaStore.Video.Thumbnails.MICRO_KIND, null); - } - mMap.put(uri.toString(), b); - } else { - b = mMap.get(uri.toString()); - } - long end = System.currentTimeMillis(); - Log.v(TAG, "Getting thumbnail takes " + (end - start) + "ms"); - v.setData(uri, b); - } - - @Override - public View newView(Context context, Cursor cursor, ViewGroup parent) { - View view = super.newView(context, cursor, parent); - ((RotateImageView)view).enableAnimation(false); - return view; - } -} diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 9978d04..813fe44 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -73,13 +73,7 @@ import android.view.WindowManager; import android.view.MenuItem.OnMenuItemClickListener; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.Button; -import android.widget.CursorAdapter; -import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -152,15 +146,8 @@ public class VideoCamera extends NoSearchActivity private boolean mIsVideoCaptureIntent; private boolean mQuickCapture; - // The layout of small devices has a thumbnail button, which shows the last - // captured picture. + // The last recorded video. private RotateImageView mThumbnailButton; - // The layout of xlarge devices have a list of thumbnails, which show the - // last captured pictures. - private ListView mThumbnailList; - private OnItemClickListener mThumbnailItemClickListener = - new ThumbnailItemClickListener(); - private ThumbnailAdapter mThumbnailAdapter; private boolean mStartPreviewFail = false; @@ -733,7 +720,6 @@ public class VideoCamera extends NoSearchActivity if (mThumbnailButton != null && !mThumbnailButton.isUriValid()) { updateThumbnailButton(); } - updateThumbnailList(); } } @@ -930,7 +916,6 @@ public class VideoCamera extends NoSearchActivity setPreviewDisplay(holder); mCameraDevice.unlock(); mHandler.sendEmptyMessage(INIT_RECORDER); - initThumbnailList(); } else { stopVideoRecording(); // If video quality changes, the surface will change. But we need to @@ -1386,7 +1371,6 @@ public class VideoCamera extends NoSearchActivity private void getThumbnail() { acquireVideoThumb(); - updateThumbnailList(); } private void showAlert() { @@ -1536,60 +1520,6 @@ public class VideoCamera extends NoSearchActivity list.close(); } - private Cursor getThumbnailsCursor(int thumbnailCount) { - Log.v(TAG, "thumbnailCount=" + thumbnailCount); - String[] projections = { MediaStore.Video.Thumbnails._ID }; - Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI - .buildUpon() - .appendQueryParameter("limit", String.valueOf(thumbnailCount)) - .build(); - // TODO: managedQuery is deprecated. Use CursorLoader. - return managedQuery(uri, projections, Media.BUCKET_ID + " = ?", - new String[] {ImageManager.CAMERA_IMAGE_BUCKET_ID}, - VideoColumns._ID + " DESC"); - } - - private void initThumbnailList() { - mThumbnailList = (ListView) findViewById(R.id.thumbnail_list); - if (mThumbnailList == null) return; - - int width = mThumbnailList.getWidth(); - int height = mThumbnailList.getHeight(); - - // Add gallery button to header view. - if (mThumbnailList.getHeaderViewsCount() == 0) { - Button b = new Button(this); - ListView.LayoutParams params = new ListView.LayoutParams(width, width); - b.setId(R.id.btn_gallery); - b.setLayoutParams(params); - b.setOnClickListener(this); - b.setBackgroundResource(R.drawable.ic_menu_gallery); - mThumbnailList.addHeaderView(b); - } - - // Set cursor adapter. - int thumbnailCount = (height + mThumbnailList.getDividerHeight()) - / (width + mThumbnailList.getDividerHeight()) - 1; - Cursor cursor = getThumbnailsCursor(thumbnailCount); - mThumbnailAdapter = new ThumbnailAdapter( - getApplicationContext(), R.layout.thumbnail_item, cursor, - false); - mThumbnailList.setAdapter(mThumbnailAdapter); - mThumbnailList.setOnItemClickListener(mThumbnailItemClickListener); - } - - private void updateThumbnailList() { - if (mThumbnailList == null) return; - mThumbnailAdapter.getCursor().requery(); - mThumbnailAdapter.notifyDataSetChanged(); - } - - private class ThumbnailItemClickListener implements OnItemClickListener { - public void onItemClick(AdapterView<?> p, View v, int pos, long id) { - viewVideo((RotateImageView)v); - } - } - private static ImageManager.DataLocation dataLocation() { return ImageManager.DataLocation.EXTERNAL; } |