diff options
22 files changed, 399 insertions, 297 deletions
diff --git a/res/drawable/btn_bar_camera.9.png b/res/drawable/btn_bar_camera.9.png Binary files differnew file mode 100644 index 0000000..3c5d7b0 --- /dev/null +++ b/res/drawable/btn_bar_camera.9.png diff --git a/res/drawable/ic_btn_background.xml b/res/drawable/ic_btn_background.xml new file mode 100644 index 0000000..069e04e --- /dev/null +++ b/res/drawable/ic_btn_background.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" android:drawable="@drawable/ic_btn_pressed" /> + <item android:state_window_focused="true" + android:state_focused="true" + android:drawable="@drawable/ic_btn_selected" /> + <item android:drawable="@drawable/ic_btn_default" /> +</selector> diff --git a/res/drawable/ic_btn_default.png b/res/drawable/ic_btn_default.png Binary files differnew file mode 100644 index 0000000..b5da102 --- /dev/null +++ b/res/drawable/ic_btn_default.png diff --git a/res/drawable/ic_btn_pressed.png b/res/drawable/ic_btn_pressed.png Binary files differnew file mode 100644 index 0000000..cf6a996 --- /dev/null +++ b/res/drawable/ic_btn_pressed.png diff --git a/res/drawable/ic_btn_selected.png b/res/drawable/ic_btn_selected.png Binary files differnew file mode 100644 index 0000000..1326fac --- /dev/null +++ b/res/drawable/ic_btn_selected.png diff --git a/res/drawable/ic_camera_indicator_photo.png b/res/drawable/ic_camera_indicator_photo.png Binary files differindex d6c02da..adbb999 100644 --- a/res/drawable/ic_camera_indicator_photo.png +++ b/res/drawable/ic_camera_indicator_photo.png diff --git a/res/drawable/ic_camera_indicator_stop.png b/res/drawable/ic_camera_indicator_stop.png Binary files differnew file mode 100644 index 0000000..c0ff91b --- /dev/null +++ b/res/drawable/ic_camera_indicator_stop.png diff --git a/res/drawable/ic_camera_indicator_video.png b/res/drawable/ic_camera_indicator_video.png Binary files differindex c160c66..7742965 100644 --- a/res/drawable/ic_camera_indicator_video.png +++ b/res/drawable/ic_camera_indicator_video.png diff --git a/res/drawable/ic_menu_multiselect_gallery.png b/res/drawable/ic_menu_multiselect_gallery.png Binary files differindex cb342c6..cb342c6 100755..100644 --- a/res/drawable/ic_menu_multiselect_gallery.png +++ b/res/drawable/ic_menu_multiselect_gallery.png diff --git a/res/drawable/selection_arrow_active.png b/res/drawable/selection_arrow_active.png Binary files differnew file mode 100644 index 0000000..ff99cd8 --- /dev/null +++ b/res/drawable/selection_arrow_active.png diff --git a/res/layout/button_bar.xml b/res/layout/button_bar.xml new file mode 100644 index 0000000..7f4e745 --- /dev/null +++ b/res/layout/button_bar.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/button_bar" + android:orientation="vertical" + android:layout_height="fill_parent" + android:layout_width="65dp" + android:layout_alignParentRight="true" + android:gravity="center" + android:background="#70E0E0E0"> + <RelativeLayout android:layout_weight="1" + android:layout_marginTop="17dp" + android:layout_height="fill_parent" + android:layout_width="fill_parent"> + <ImageView android:id="@+id/photo_indicator" + android:visibility="gone" + android:paddingLeft="1dp" + android:layout_centerVertical="true" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_alignParentLeft="true" + android:src="@drawable/selection_arrow_active"/> + <com.android.camera.ShutterButton + android:id="@+id/camera_button" + android:layout_centerInParent="true" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:scaleType="center" + android:clickable="true" + android:focusable="true" + android:src="@drawable/ic_camera_indicator_photo" + android:background="@drawable/ic_btn_background"/> + </RelativeLayout> + <RelativeLayout android:layout_weight="1" + android:layout_height="fill_parent" + android:layout_width="fill_parent"> + <ImageView android:id="@+id/video_indicator" + android:visibility="gone" + android:paddingLeft="1dp" + android:layout_centerVertical="true" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_alignParentLeft="true" + android:src="@drawable/selection_arrow_active"/> + <com.android.camera.ShutterButton android:id="@+id/video_button" + android:layout_centerInParent="true" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:scaleType="center" + android:clickable="true" + android:focusable="true" + android:src="@drawable/ic_camera_indicator_video" + android:background="@drawable/ic_btn_background"/> + </RelativeLayout> + <RelativeLayout android:layout_weight="1" + android:layout_marginBottom="17dp" + android:layout_height="fill_parent" + android:layout_width="fill_parent"> + <ImageView android:id="@+id/review_indicator" + android:visibility="gone" + android:paddingLeft="1dp" + android:layout_centerVertical="true" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_alignParentLeft="true" + android:src="@drawable/selection_arrow_active"/> + <ImageView android:id="@+id/review_button" + android:layout_centerInParent="true" + android:layout_height="57dp" + android:layout_width="42dp" + android:scaleType="center" + android:clickable="true" + android:focusable="true" + android:background="@drawable/ic_btn_background"/> + </RelativeLayout> +</LinearLayout> diff --git a/res/layout/camera.xml b/res/layout/camera.xml index fcdb9e9..305a789 100644 --- a/res/layout/camera.xml +++ b/res/layout/camera.xml @@ -26,19 +26,6 @@ android:layout_height="fill_parent" android:layout_centerInParent="true" /> - <com.android.camera.ShutterButton - android:id="@+id/shutter_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:visibility="invisible" - android:clickable="true" - android:focusable="true" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:layout_marginRight="5dip" - android:layout_marginTop="5dip" - android:scaleType="center" /> - <ImageView android:id="@+id/gps_indicator" android:layout_width="wrap_content" @@ -48,35 +35,12 @@ android:focusable="false" android:layout_alignParentRight="true" android:layout_alignParentTop="true" - android:layout_marginRight="18dip" - android:layout_marginTop="18dip"/> - - <ImageView - android:id="@+id/focus_indicator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignLeft="@id/shutter_button" - android:layout_alignTop="@id/shutter_button" - android:layout_marginLeft="39dip" - android:layout_marginTop="16dip" - android:scaleType="center" - android:visibility="gone" /> - - <ImageView - android:visibility="gone" - android:id="@+id/last_picture_button" - android:layout_width="72dip" - android:layout_height="72dip" - android:clickable="true" - android:focusable="false" - android:layout_alignParentLeft="true" - android:layout_alignParentTop="true" - android:layout_marginLeft="5dip" - android:layout_marginTop="5dip" /> + android:layout_marginRight="18dp" + android:layout_marginTop="18dp"/> <com.android.camera.FocusRectangle android:id="@+id/focus_rectangle" - android:layout_width="276dip" - android:layout_height="168dip" + android:layout_width="276dp" + android:layout_height="168dp" android:layout_centerInParent="true"/> </RelativeLayout> diff --git a/res/layout/post_picture_panel.xml b/res/layout/post_picture_panel.xml index 54aea73..9b34dfd 100644 --- a/res/layout/post_picture_panel.xml +++ b/res/layout/post_picture_panel.xml @@ -17,9 +17,10 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:visibility="gone" android:id="@+id/post_picture_panel" - android:layout_alignBottom="@id/shutter_button" - android:layout_toLeftOf="@id/shutter_button" - android:layout_marginRight="20dip" + android:layout_alignParentTop="true" + android:layout_toLeftOf="@id/button_bar" + android:layout_marginTop="20dp" + android:layout_marginRight="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> @@ -28,14 +29,14 @@ android:id="@+id/attach" android:drawableTop="@drawable/ic_menu_attach" android:text="@string/camera_attach" - android:layout_marginLeft="20dip" + android:layout_marginLeft="20dp" style="@style/OnscreenActionIcon" /> <com.android.camera.ActionMenuButton android:id="@+id/cancel" android:drawableTop="@drawable/ic_menu_cancel" android:text="@string/camera_cancel" - android:layout_marginLeft="20dip" + android:layout_marginLeft="20dp" style="@style/OnscreenActionIcon" /> </LinearLayout> diff --git a/res/layout/video_camera.xml b/res/layout/video_camera.xml index 667baf7..fa901ee 100644 --- a/res/layout/video_camera.xml +++ b/res/layout/video_camera.xml @@ -15,67 +15,62 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/video_camera" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> - <com.android.camera.VideoPreview - android:id="@+id/camera_preview" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:layout_centerInParent="true" - /> + <include android:id="@+id/button_bar" layout="@layout/button_bar"/> - <ImageView - android:id="@+id/video_frame" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:visibility="gone" - /> + <RelativeLayout android:layout_toLeftOf="@id/button_bar" + android:layout_height="fill_parent" + android:layout_width="fill_parent"> + <com.android.camera.VideoPreview + android:id="@+id/camera_preview" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_centerInParent="true" /> + <ImageView + android:id="@+id/video_frame" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_toLeftOf="@id/button_bar" + android:visibility="gone" /> + </RelativeLayout> - <com.android.camera.ShutterButton - android:id="@+id/shutter_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@drawable/ic_camera_indicator_video" - android:background="@drawable/ic_btn_camera_background" - android:clickable="true" - android:focusable="true" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:layout_marginRight="5dip" - android:layout_marginTop="5dip" - android:scaleType="center" /> <!-- Note: In this TextView the paddingRight="2" attribute is required because otherwise the text's drop shadow will be clipped. --> <TextView android:id="@+id/recording_time" - android:layout_width="90dip" + android:layout_width="90dp" android:layout_height="wrap_content" - android:layout_toLeftOf="@id/shutter_button" - android:layout_alignTop="@id/shutter_button" - android:layout_marginTop="20dip" - android:layout_marginRight="6dip" - android:paddingRight="2dip" + android:layout_toLeftOf="@id/button_bar" + android:layout_alignParentTop="true" + android:layout_marginTop="20dp" + android:layout_marginRight="26dp" + android:paddingRight="2dp" + android:drawablePadding="5dp" + android:drawableRight="@drawable/ic_camera_bar_indicator_record" android:shadowColor="#c0000000" android:shadowDx="1" android:shadowDy="1" android:shadowRadius="1" android:gravity="right" android:textColor="@color/recording_time_elapsed_text" - android:textSize="20dip" + android:textSize="20dp" android:textStyle="bold" android:visibility="gone"/> <LinearLayout android:visibility="gone" android:id="@+id/post_picture_panel" - android:layout_alignTop="@id/shutter_button" - android:layout_toLeftOf="@id/shutter_button" - android:layout_marginRight="20dip" - android:layout_marginLeft="47dip" + android:layout_alignParentTop="true" + android:layout_toLeftOf="@id/button_bar" + android:layout_marginTop="20dp" + android:layout_marginRight="30dp" + android:layout_marginLeft="30dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> @@ -120,12 +115,12 @@ <ImageView android:visibility="invisible" android:id="@+id/last_picture_button" - android:layout_width="72dip" - android:layout_height="72dip" + android:layout_width="72dp" + android:layout_height="72dp" android:clickable="true" android:focusable="false" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" - android:layout_marginLeft="5dip" - android:layout_marginTop="5dip"/> + android:layout_marginLeft="5dp" + android:layout_marginTop="5dp"/> </RelativeLayout> diff --git a/res/layout/viewimage.xml b/res/layout/viewimage.xml index 8e72ffa..1463964 100644 --- a/res/layout/viewimage.xml +++ b/res/layout/viewimage.xml @@ -4,9 +4,9 @@ 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. @@ -19,113 +19,105 @@ android:layout_width="fill_parent" android:layout_height="fill_parent"> - <AbsoluteLayout android:id="@+id/slideShowContainer" + <include android:id="@+id/button_bar" + layout="@layout/button_bar" + android:visibility="gone" /> + + <RelativeLayout android:id="@+id/mainPanel" + android:layout_toLeftOf="@id/button_bar" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <view android:id="@+id/image1_slideShow" - class="com.android.camera.ImageViewTouch" - android:background="#00000000" + <AbsoluteLayout android:id="@+id/slideShowContainer" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <com.android.camera.ImageViewTouch android:id="@+id/image1_slideShow" + android:background="#00000000" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + /> + <com.android.camera.ImageViewTouch android:id="@+id/image2_slideShow" + android:background="#00000000" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + /> + </AbsoluteLayout> + + <AbsoluteLayout android:id="@+id/abs" android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <com.android.camera.ImageViewTouch android:id="@+id/image" + android:background="#FF000000" + android:layout_width="fill_parent" + android:layout_height="fill_parent" /> + </AbsoluteLayout> + <ImageView android:id="@+id/prev_image" + android:clickable="true" + android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:visibility="invisible" + android:src="@drawable/btn_camera_arrow_left" /> - <view android:id="@+id/image2_slideShow" - class="com.android.camera.ImageViewTouch" - android:background="#00000000" - android:layout_width="fill_parent" + + <ImageView android:id="@+id/next_image" + android:clickable="true" + android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:visibility="invisible" + android:src="@drawable/btn_camera_arrow_right" /> - </AbsoluteLayout> - <AbsoluteLayout android:id="@+id/abs" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - <view android:id="@+id/image" - class="com.android.camera.ImageViewTouch" - android:background="#FF000000" + <LinearLayout + android:visibility="gone" + android:id="@+id/action_icon_panel" + android:layout_toLeftOf="@id/button_bar" + android:layout_marginTop="20dp" + android:layout_marginRight="30dp" + android:layout_marginLeft="30dp" android:layout_width="fill_parent" - android:layout_height="fill_parent" /> - </AbsoluteLayout> - - <ImageView android:id="@+id/prev_image" - android:clickable="true" - android:layout_width="wrap_content" android:layout_height="fill_parent" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - android:visibility="invisible" - android:src="@drawable/btn_camera_arrow_left" - /> + android:layout_height="wrap_content" + android:orientation="horizontal"> - <ImageView android:id="@+id/next_image" - android:clickable="true" - android:layout_width="wrap_content" android:layout_height="fill_parent" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:visibility="invisible" - android:src="@drawable/btn_camera_arrow_right" - /> - - <ImageView - android:visibility="gone" - android:id="@+id/shutter_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@drawable/ic_camera_indicator_photo" - android:background="@drawable/ic_btn_camera_background" - android:clickable="true" - android:focusable="true" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:layout_marginRight="5dip" - android:layout_marginTop="5dip" - android:scaleType="center"/> - - <LinearLayout - android:visibility="gone" - android:id="@+id/action_icon_panel" - android:layout_alignBottom="@id/shutter_button" - android:layout_toLeftOf="@id/shutter_button" - android:layout_marginRight="20dip" - android:layout_marginLeft="47dip" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - - <com.android.camera.ActionMenuButton - android:id="@+id/gallery" - android:drawableTop="@drawable/ic_menu_gallery" - android:text="@string/camera_gallery" - style="@style/OnscreenActionIcon" - /> - <com.android.camera.ActionMenuButton - android:id="@+id/setas" - android:drawableTop="@drawable/ic_menu_set_as" - android:text="@string/camera_set" - style="@style/OnscreenActionIcon" - /> - <com.android.camera.ActionMenuButton - android:id="@+id/share" - android:drawableTop="@drawable/ic_menu_share" - android:text="@string/camera_share" - style="@style/OnscreenActionIcon" - /> - <com.android.camera.ActionMenuButton - android:id="@+id/discard" - android:drawableTop="@drawable/ic_menu_delete" - android:text="@string/camera_toss" - style="@style/OnscreenActionIcon" - /> - <com.android.camera.ActionMenuButton - android:id="@+id/attach" - android:drawableTop="@drawable/ic_menu_attach" - android:text="@string/camera_attach" - style="@style/OnscreenActionIcon" - /> - <com.android.camera.ActionMenuButton - android:id="@+id/cancel" - android:drawableTop="@drawable/ic_menu_cancel" - android:text="@string/camera_cancel" - style="@style/OnscreenActionIcon" - /> - </LinearLayout> + <com.android.camera.ActionMenuButton + android:id="@+id/gallery" + android:drawableTop="@drawable/ic_menu_gallery" + android:text="@string/camera_gallery" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/setas" + android:drawableTop="@drawable/ic_menu_set_as" + android:text="@string/camera_set" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/share" + android:drawableTop="@drawable/ic_menu_share" + android:text="@string/camera_share" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/discard" + android:drawableTop="@drawable/ic_menu_delete" + android:text="@string/camera_toss" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/attach" + android:drawableTop="@drawable/ic_menu_attach" + android:text="@string/camera_attach" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/cancel" + android:drawableTop="@drawable/ic_menu_cancel" + android:text="@string/camera_cancel" + style="@style/OnscreenActionIcon" + /> + </LinearLayout> + </RelativeLayout> </RelativeLayout> diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index f21571a..0276355 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -32,7 +32,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.Size; import android.location.Location; @@ -171,8 +170,6 @@ public class Camera extends Activity implements View.OnClickListener, private ShutterButton mShutterButton; - private Animation mFocusBlinkAnimation; - private ImageView mFocusIndicator; private FocusRectangle mFocusRectangle; private ImageView mGpsIndicator; private ToneGenerator mFocusToneGenerator; @@ -283,46 +280,32 @@ public class Camera extends Activity implements View.OnClickListener, // Initialize last picture button. mContentResolver = getContentResolver(); if (!mIsImageCaptureIntent) { - mLastPictureButton = (ImageView) - findViewById(R.id.last_picture_button); - mLastPictureButton.setOnClickListener(Camera.this); - Drawable frame = - getResources().getDrawable(R.drawable.frame_thumbnail); - mThumbController = new ThumbnailController(mLastPictureButton, - frame, mContentResolver); + findViewById(R.id.video_button).setOnClickListener(this); + mLastPictureButton = (ImageView) findViewById(R.id.review_button); + mLastPictureButton.setOnClickListener(this); + mThumbController = new ThumbnailController( + mLastPictureButton, mContentResolver); mThumbController.loadData(ImageManager.getLastImageThumbPath()); - } else { - ViewGroup cameraView = (ViewGroup) findViewById(R.id.camera); - getLayoutInflater().inflate(R.layout.post_picture_panel, - cameraView); - mPostCaptureAlert = findViewById(R.id.post_picture_panel); - } - - // Update last image thumbnail. - if (!mIsImageCaptureIntent) { + // Update last image thumbnail. if (!mThumbController.isUriValid()) { updateLastImage(); } mThumbController.updateDisplayIfNeeded(); + } else { + findViewById(R.id.review_button).setVisibility(View.INVISIBLE); + findViewById(R.id.video_button).setVisibility(View.INVISIBLE); + ViewGroup cameraView = (ViewGroup) findViewById(R.id.camera); + getLayoutInflater().inflate( + R.layout.post_picture_panel, cameraView); + mPostCaptureAlert = findViewById(R.id.post_picture_panel); } + findViewById(R.id.photo_indicator).setVisibility(View.VISIBLE); // Initialize shutter button. - mShutterButton = (ShutterButton) findViewById(R.id.shutter_button); - mShutterButton.setImageResource(R.drawable.ic_camera_indicator_photo); - mShutterButton.setBackgroundResource( - R.drawable.ic_btn_camera_background); - mShutterButton.setOnShutterButtonListener(Camera.this); + mShutterButton = (ShutterButton) findViewById(R.id.camera_button); + mShutterButton.setOnShutterButtonListener(this); mShutterButton.setVisibility(View.VISIBLE); - // Initialize focus related resources. - mFocusBlinkAnimation = - AnimationUtils.loadAnimation(Camera.this, - R.anim.auto_focus_blink); - mFocusBlinkAnimation.setRepeatCount(Animation.INFINITE); - mFocusBlinkAnimation.setRepeatMode(Animation.REVERSE); - mFocusIndicator = (ImageView) findViewById(R.id.focus_indicator); - mFocusIndicator.setImageResource( - R.drawable.ic_camera_indicator_auto_focus_green); mFocusRectangle = (FocusRectangle) findViewById(R.id.focus_rectangle); updateFocusIndicator(); @@ -806,6 +789,8 @@ public class Camera extends Activity implements View.OnClickListener, holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mIsImageCaptureIntent = isImageCaptureIntent(); + getLayoutInflater().inflate( + R.layout.button_bar, (ViewGroup) findViewById(R.id.camera)); // Make sure the services are loaded. try { @@ -836,16 +821,19 @@ public class Camera extends Activity implements View.OnClickListener, public void onClick(View v) { switch (v.getId()) { - case R.id.last_picture_button: - if (mStatus == IDLE && mFocusState == FOCUS_NOT_STARTED) { - viewLastImage(); - } - break; - case R.id.attach: - doAttach(); - break; - case R.id.cancel: - doCancel(); + case R.id.video_button: + MenuHelper.gotoVideoMode(this); + break; + case R.id.review_button: + if (mStatus == IDLE && mFocusState == FOCUS_NOT_STARTED) { + viewLastImage(); + } + break; + case R.id.attach: + doAttach(); + break; + case R.id.cancel: + doCancel(); } } @@ -963,7 +951,7 @@ public class Camera extends Activity implements View.OnClickListener, return; } switch (button.getId()) { - case R.id.shutter_button: + case R.id.camera_button: doFocus(pressed); break; } @@ -974,7 +962,7 @@ public class Camera extends Activity implements View.OnClickListener, return; } switch (button.getId()) { - case R.id.shutter_button: + case R.id.camera_button: doSnap(); break; } @@ -1166,21 +1154,15 @@ public class Camera extends Activity implements View.OnClickListener, } private void updateFocusIndicator() { - if (mFocusIndicator == null || mFocusRectangle == null) return; + if (mFocusRectangle == null) return; if (mFocusState == FOCUSING || mFocusState == FOCUSING_SNAP_ON_FINISH) { mFocusRectangle.showStart(); } else if (mFocusState == FOCUS_SUCCESS) { - mFocusIndicator.setVisibility(View.VISIBLE); - mFocusIndicator.clearAnimation(); mFocusRectangle.showSuccess(); } else if (mFocusState == FOCUS_FAIL) { - mFocusIndicator.setVisibility(View.VISIBLE); - mFocusIndicator.startAnimation(mFocusBlinkAnimation); mFocusRectangle.showFail(); } else { - mFocusIndicator.setVisibility(View.GONE); - mFocusIndicator.clearAnimation(); mFocusRectangle.clear(); } } diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java index 363b429..81c9404 100644 --- a/src/com/android/camera/MenuHelper.java +++ b/src/com/android/camera/MenuHelper.java @@ -36,9 +36,9 @@ import android.text.format.Formatter; import android.util.Log; import android.view.Menu; import android.view.MenuItem; -import android.view.MenuItem.OnMenuItemClickListener; import android.view.SubMenu; import android.view.View; +import android.view.MenuItem.OnMenuItemClickListener; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -49,7 +49,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.List; /** @@ -883,6 +882,14 @@ public class MenuHelper { return true; } + public static void gotoCameraMode(Activity activity) { + onSwitchModeClicked(activity, false); + } + + public static void gotoVideoMode(Activity activity) { + onSwitchModeClicked(activity, true); + } + static void gotoStillImageCapture(Activity activity) { Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/src/com/android/camera/ThumbnailController.java b/src/com/android/camera/ThumbnailController.java index 1147d37..0fcc66c 100644 --- a/src/com/android/camera/ThumbnailController.java +++ b/src/com/android/camera/ThumbnailController.java @@ -22,7 +22,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.TransitionDrawable; import android.net.Uri; import android.view.View; @@ -56,22 +55,20 @@ public class ThumbnailController { @SuppressWarnings("unused") private static final String TAG = "ThumbnailController"; - private ContentResolver mContentResolver; + private final ContentResolver mContentResolver; private Uri mUri; private Bitmap mThumb; - private ImageView mButton; - private Drawable mFrame; + private final ImageView mButton; private Drawable[] mThumbs; private TransitionDrawable mThumbTransition; private boolean mShouldAnimateThumb; - private Animation mShowButtonAnimation = new AlphaAnimation(0F, 1F); + private final Animation mShowButtonAnimation = new AlphaAnimation(0F, 1F); private boolean mShouldAnimateButton; // The "frame" is a drawable we want to put on top of the thumbnail. - public ThumbnailController(ImageView button, Drawable frame, - ContentResolver contentResolver) { + public ThumbnailController( + ImageView button, ContentResolver contentResolver) { mButton = button; - mFrame = frame; mContentResolver = contentResolver; mShowButtonAnimation.setDuration(500); } @@ -176,33 +173,29 @@ public class ThumbnailController { // Make the mini-thumb size smaller than the button size so that the // image corners don't peek out from the rounded corners of the // frame_thumb graphic: - final int PADDING_WIDTH = 12; - final int PADDING_HEIGHT = 12; - LayoutParams layoutParams = mButton.getLayoutParams(); - final int miniThumbWidth = layoutParams.width - 2 * PADDING_WIDTH; - final int miniThumbHeight = layoutParams.height - 2 * PADDING_HEIGHT; + final int PADDING_WIDTH = 4; + final int PADDING_HEIGHT = 4; + LayoutParams param = mButton.getLayoutParams(); + final int miniThumbWidth = param.width - 2 * PADDING_WIDTH; + final int miniThumbHeight = param.height - 2 * PADDING_HEIGHT; mThumb = Util.extractMiniThumb( original, miniThumbWidth, miniThumbHeight, false); - - Drawable[] vignetteLayers = new Drawable[2]; - vignetteLayers[0] = mFrame; + Drawable drawable; if (mThumbs == null) { mThumbs = new Drawable[2]; - mThumbs[1] = new BitmapDrawable(mThumb); - vignetteLayers[1] = mThumbs[1]; + mThumbs[1] = new BitmapDrawable( + Util.makeRoundedCorner(mThumb, 4, 4)); + drawable = mThumbs[1]; mShouldAnimateThumb = false; } else { mThumbs[0] = mThumbs[1]; - mThumbs[1] = new BitmapDrawable(mThumb); + mThumbs[1] = new BitmapDrawable( + Util.makeRoundedCorner(mThumb, 4, 4)); mThumbTransition = new TransitionDrawable(mThumbs); - vignetteLayers[1] = mThumbTransition; + drawable = mThumbTransition; mShouldAnimateThumb = true; } - - LayerDrawable mVignette = new LayerDrawable(vignetteLayers); - mVignette.setLayerInset(1, PADDING_WIDTH, PADDING_HEIGHT, - PADDING_WIDTH, PADDING_HEIGHT); - mButton.setImageDrawable(mVignette); + mButton.setImageDrawable(drawable); if (mButton.getVisibility() != View.VISIBLE) { mShouldAnimateButton = true; diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index 261965a..028725b 100644 --- a/src/com/android/camera/Util.java +++ b/src/com/android/camera/Util.java @@ -25,7 +25,10 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.Path; import android.graphics.Rect; +import android.graphics.RectF; import android.media.MediaMetadataRetriever; import android.net.Uri; import android.os.ParcelFileDescriptor; @@ -412,4 +415,21 @@ public class Util { throw new AssertionError(); } } + + public static Bitmap makeRoundedCorner(Bitmap thumb, int rx, int ry) { + if (thumb == null) return null; + int width = thumb.getWidth(); + int height = thumb.getHeight(); + + Bitmap result = Bitmap.createBitmap( + width, height, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(result); + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + Path path = new Path(); + path.addRoundRect(new RectF( + 0, 0, width, height), rx, ry, Path.Direction.CCW); + canvas.clipPath(path); + canvas.drawBitmap(thumb, 0, 0, paint); + return result; + } } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 1743383..eb0e050 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; @@ -145,7 +145,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, View mPostPictureAlert; - private Handler mHandler = new MainHandler(); + private final Handler mHandler = new MainHandler(); // This Handler is used to post message back onto the main thread of the // application @@ -248,20 +248,24 @@ public class VideoCamera extends Activity implements View.OnClickListener, findViewById(id).setOnClickListener(this); } - mShutterButton = (ShutterButton) findViewById(R.id.shutter_button); + findViewById(R.id.video_indicator).setVisibility(View.VISIBLE); + mShutterButton = (ShutterButton) findViewById(R.id.video_button); mShutterButton.setOnShutterButtonListener(this); + mShutterButton.requestFocus(); + mRecordingTimeView = (TextView) findViewById(R.id.recording_time); mVideoFrame = (ImageView) findViewById(R.id.video_frame); mIsVideoCaptureIntent = isVideoCaptureIntent(); if (!mIsVideoCaptureIntent) { - mLastPictureButton = (ImageView) findViewById( - R.id.last_picture_button); + mLastPictureButton = (ImageView) findViewById(R.id.review_button); mLastPictureButton.setOnClickListener(this); - Drawable frame = getResources().getDrawable( - R.drawable.frame_thumbnail); - mThumbController = new ThumbnailController(mLastPictureButton, - frame, mContentResolver); + mThumbController = new ThumbnailController( + mLastPictureButton, mContentResolver); mThumbController.loadData(ImageManager.getLastVideoThumbPath()); + findViewById(R.id.camera_button).setOnClickListener(this); + } else { + findViewById(R.id.camera_button).setVisibility(View.INVISIBLE); + findViewById(R.id.review_button).setVisibility(View.INVISIBLE); } // Make sure the camera is opened. @@ -293,6 +297,9 @@ public class VideoCamera extends Activity implements View.OnClickListener, public void onClick(View v) { switch (v.getId()) { + case R.id.camera_button: + MenuHelper.gotoCameraMode(this); + break; case R.id.gallery: gotoGallery(); @@ -326,7 +333,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, break; } - case R.id.last_picture_button: { + case R.id.review_button: { stopVideoRecordingAndShowAlert(); break; } @@ -339,7 +346,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, public void onShutterButtonClick(ShutterButton button) { switch (button.getId()) { - case R.id.shutter_button: + case R.id.video_button: if (mMediaRecorderRecording) { if (mIsVideoCaptureIntent) { stopVideoRecordingAndShowAlert(); @@ -479,6 +486,9 @@ public class VideoCamera extends Activity implements View.OnClickListener, // Precondition: mSurfaceHolder != null // Returns true if starting preview succeeds. private boolean startPreview() { + findViewById(R.id.review_indicator).setVisibility(View.INVISIBLE); + findViewById(R.id.video_indicator).setVisibility(View.VISIBLE); + Log.v(TAG, "startPreview"); if (mPreviewing) { // We should just return here, but we stop and start again to avoid @@ -1041,7 +1051,6 @@ public class VideoCamera extends Activity implements View.OnClickListener, mRecordingTimeView.setVisibility(View.VISIBLE); mHandler.sendEmptyMessage(UPDATE_RECORD_TIME); setScreenTimeoutInfinite(); - hideLastPictureButton(); // Last picture button is hidden. No need to update last video. mHandler.removeMessages(UPDATE_LAST_VIDEO); } @@ -1049,7 +1058,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, private void updateRecordingIndicator(boolean showRecording) { int drawableId = showRecording - ? R.drawable.ic_camera_bar_indicator_record + ? R.drawable.ic_camera_indicator_stop : R.drawable.ic_camera_indicator_video; Drawable drawable = getResources().getDrawable(drawableId); mShutterButton.setImageDrawable(drawable); @@ -1066,6 +1075,9 @@ public class VideoCamera extends Activity implements View.OnClickListener, } private void showAlert() { + findViewById(R.id.review_indicator).setVisibility(View.VISIBLE); + findViewById(R.id.video_indicator).setVisibility(View.INVISIBLE); + int[] pickIds = {R.id.attach, R.id.cancel}; int[] normalIds = {R.id.gallery, R.id.share, R.id.discard}; int[] alwaysOnIds = {R.id.play}; @@ -1084,8 +1096,8 @@ public class VideoCamera extends Activity implements View.OnClickListener, mCurrentVideoFileLength > SHARE_FILE_LENGTH_LIMIT); connectAndFadeIn(connectIds); connectAndFadeIn(alwaysOnIds); - hideLastPictureButton(); mPostPictureAlert.setVisibility(View.VISIBLE); + mVideoPreview.setVisibility(View.INVISIBLE); // There are two cases we are here: // (1) We are in a capture video intent, and we are reviewing the video @@ -1114,6 +1126,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, } private void hideAlert() { + mVideoPreview.setVisibility(View.VISIBLE); mVideoFrame.setVisibility(View.INVISIBLE); mPostPictureAlert.setVisibility(View.INVISIBLE); showLastPictureButton(); @@ -1225,12 +1238,6 @@ public class VideoCamera extends Activity implements View.OnClickListener, } } - private void hideLastPictureButton() { - if (!mIsVideoCaptureIntent) { - mLastPictureButton.setVisibility(View.INVISIBLE); - } - } - private static ImageManager.DataLocation dataLocation() { return ImageManager.DataLocation.EXTERNAL; } diff --git a/src/com/android/camera/VideoPreview.java b/src/com/android/camera/VideoPreview.java index cd29e6f..6de3855 100644 --- a/src/com/android/camera/VideoPreview.java +++ b/src/com/android/camera/VideoPreview.java @@ -22,6 +22,7 @@ import android.util.Log; import android.view.SurfaceView; class VideoPreview extends SurfaceView { + private static final String TAG = "VideoPreview"; private float mAspectRatio; private int mHorizontalTileSize = 1; private int mVerticalTileSize = 1; diff --git a/src/com/android/camera/ViewImage.java b/src/com/android/camera/ViewImage.java index 2b171e5..e28ccd8 100644 --- a/src/com/android/camera/ViewImage.java +++ b/src/com/android/camera/ViewImage.java @@ -40,11 +40,13 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationUtils; +import android.widget.ImageView; import android.widget.Toast; import android.widget.ZoomButtonsController; @@ -85,6 +87,7 @@ public class ViewImage extends Activity implements View.OnClickListener { private boolean mSortAscending = false; private int mSlideShowInterval; private int mLastSlideShowImage; + private ThumbnailController mThumbController; int mCurrentPosition = 0; // represents which style animation to use @@ -551,8 +554,6 @@ public class ViewImage extends Activity implements View.OnClickListener { view.setAnimation(animation); } } - mShutterButton = findViewById(R.id.shutter_button); - mShutterButton.setOnClickListener(this); Uri uri = getIntent().getData(); @@ -581,11 +582,10 @@ public class ViewImage extends Activity implements View.OnClickListener { } if (mShowActionIcons) { mActionIconPanel.setVisibility(View.VISIBLE); - mShutterButton.setVisibility(View.VISIBLE); } } - setupZoomButtonController(findViewById(R.id.rootLayout)); + setupZoomButtonController(findViewById(R.id.mainPanel)); setupDismissOnScreenControlRunnable(); mNextImageView = findViewById(R.id.next_image); @@ -597,8 +597,35 @@ public class ViewImage extends Activity implements View.OnClickListener { mNextImageView.setFocusable(true); mPrevImageView.setFocusable(true); } + + if (mCameraReviewMode) { + ViewGroup buttonBar = (ViewGroup) findViewById(R.id.button_bar); + buttonBar.setVisibility(View.VISIBLE); + buttonBar.findViewById( + R.id.review_indicator).setVisibility(View.VISIBLE); + ImageView reviewButton = (ImageView) + buttonBar.findViewById(R.id.review_button); + reviewButton.setClickable(false); + reviewButton.setFocusable(false); + mThumbController = new ThumbnailController( + reviewButton, getContentResolver()); + buttonBar.findViewById(R.id.camera_button).setOnClickListener(this); + buttonBar.findViewById(R.id.video_button).setOnClickListener(this); + } + } + + private void updateLastImage() { + int count = mAllImages.getCount(); + if (count > 0) { + IImage image = mAllImages.getImageAt(count - 1); + Uri uri = image.fullSizeImageUri(); + mThumbController.setData(uri, image.miniThumbBitmap()); + } else { + mThumbController.setData(null, null); + } } + private Animation makeInAnimation(int id) { Animation inAnimation = AnimationUtils.loadAnimation(this, id); return inAnimation; @@ -887,6 +914,9 @@ public class ViewImage extends Activity implements View.OnClickListener { super.onStart(); init(mSavedUri); + if (mCameraReviewMode) { + updateLastImage(); + } // normally this will never be zero but if one "backs" into this // activity after removing the sdcard it could be zero. in that @@ -940,15 +970,12 @@ public class ViewImage extends Activity implements View.OnClickListener { public void onClick(View v) { switch (v.getId()) { - case R.id.shutter_button: { - if (mCameraReviewMode) { - finish(); - } else { - MenuHelper.gotoStillImageCapture(this); - } - } - break; - + case R.id.camera_button: + MenuHelper.gotoCameraMode(this); + break; + case R.id.video_button: + MenuHelper.gotoVideoMode(this); + break; case R.id.gallery: { MenuHelper.gotoCameraImageGallery(this); } |