OSDN Git Service

intent captrue review gets its own ImageView!
authorSpike Sprague <spikuru@google.com>
Thu, 22 May 2014 21:40:53 +0000 (14:40 -0700)
committerSpike Sprague <spikuru@google.com>
Mon, 9 Jun 2014 21:42:48 +0000 (14:42 -0700)
instead of relying on a stopped preview TextureView

bug: 13526027

Change-Id: I40d2a97d15ed5d27b0000fa0a6d96af03ad55cf9

res/layout-land/retake_done_cancel_layout.xml [new file with mode: 0644]
res/layout-port/retake_done_cancel_layout.xml [new file with mode: 0644]
res/layout/bottom_bar_contents.xml
res/layout/intent_review_imageview.xml [new file with mode: 0644]
src/com/android/camera/PhotoModule.java
src/com/android/camera/PhotoUI.java
src/com/android/camera/TextureViewHelper.java
src/com/android/camera/ui/BottomBar.java

diff --git a/res/layout-land/retake_done_cancel_layout.xml b/res/layout-land/retake_done_cancel_layout.xml
new file mode 100644 (file)
index 0000000..5a41f0b
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+  <com.android.camera.ui.TopRightWeightedLayout
+    android:id="@+id/bottombar_intent_review"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal"
+    android:gravity="center"
+    android:visibility="invisible"
+    android:background="@null" >
+      <ImageButton
+        android:id="@+id/cancel_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="right|center_vertical"
+        android:paddingTop="24dp"
+        android:src="@drawable/ic_cancel"
+        android:background="@null"
+        android:contentDescription="@string/cancel_button_description" />
+      <ImageButton
+        android:id="@+id/done_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:src="@drawable/ic_confirm"
+        android:layout_weight="1"
+        android:background="@null"
+        android:contentDescription="@string/done_button_description" />
+      <ImageButton
+        android:id="@+id/retake_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="left|center_vertical"
+        android:paddingBottom="24dp"
+        android:src="@drawable/ic_back"
+        android:background="@null"
+        android:contentDescription="@string/retake_button_description" />
+  </com.android.camera.ui.TopRightWeightedLayout>
+</merge>
\ No newline at end of file
diff --git a/res/layout-port/retake_done_cancel_layout.xml b/res/layout-port/retake_done_cancel_layout.xml
new file mode 100644 (file)
index 0000000..13fbe41
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+  <com.android.camera.ui.TopRightWeightedLayout
+    android:id="@+id/bottombar_intent_review"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal"
+    android:gravity="center"
+    android:visibility="invisible"
+    android:background="@null" >
+      <ImageButton
+        android:id="@+id/retake_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="left|center_vertical"
+        android:paddingLeft="24dp"
+        android:src="@drawable/ic_back"
+        android:background="@null"
+        android:contentDescription="@string/retake_button_description" />
+      <ImageButton
+        android:id="@+id/done_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:src="@drawable/ic_confirm"
+        android:layout_weight="1"
+        android:background="@null"
+        android:contentDescription="@string/done_button_description" />
+      <ImageButton
+        android:id="@+id/cancel_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="right|center_vertical"
+        android:paddingRight="24dp"
+        android:src="@drawable/ic_cancel"
+        android:background="@null"
+        android:contentDescription="@string/cancel_button_description" />
+  </com.android.camera.ui.TopRightWeightedLayout>
+</merge>
\ No newline at end of file
index da9c0c4..5368f9c 100644 (file)
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:visibility="visible" >
-    <ImageButton
-      android:id="@+id/shutter_cancel_button"
-      android:layout_width="match_parent"
-      android:layout_height="match_parent"
-      android:layout_gravity="center"
-      android:scaleType="center"
-      android:clickable="true"
-      android:contentDescription="@string/accessibility_cancel_button"
-      android:focusable="true"
-      android:background="@null"
-      android:src="@drawable/ic_cancel" />
-  </FrameLayout>
-
-
-    <com.android.camera.ui.TopRightWeightedLayout
-      android:id="@+id/bottombar_intent_review"
-      android:layout_width="match_parent"
-      android:layout_height="match_parent"
-      android:orientation="horizontal"
-      android:gravity="center"
-      android:visibility="invisible"
-      android:background="@null" >
-    <ImageButton
-        android:id="@+id/retake_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="left|center_vertical"
-        android:paddingLeft="24dp"
-        android:src="@drawable/ic_back"
-        android:background="@null"
-        android:contentDescription="@string/retake_button_description" />
-    <ImageButton
-        android:id="@+id/done_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+      <ImageButton
+        android:id="@+id/shutter_cancel_button"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:layout_gravity="center"
-        android:src="@drawable/ic_confirm"
-        android:layout_weight="1"
-        android:background="@null"
-        android:contentDescription="@string/done_button_description" />
-    <ImageButton
-        android:id="@+id/cancel_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="right|center_vertical"
-        android:paddingRight="24dp"
-        android:src="@drawable/ic_cancel"
+        android:scaleType="center"
+        android:clickable="true"
+        android:contentDescription="@string/accessibility_cancel_button"
+        android:focusable="true"
         android:background="@null"
-        android:contentDescription="@string/cancel_button_description" />
-  </com.android.camera.ui.TopRightWeightedLayout>
+        android:src="@drawable/ic_cancel" />
+  </FrameLayout>
+
+  <include layout="@layout/retake_done_cancel_layout" />
 </merge>
diff --git a/res/layout/intent_review_imageview.xml b/res/layout/intent_review_imageview.xml
new file mode 100644 (file)
index 0000000..9bd4a51
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<ImageView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/intent_review_imageview"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:scaleType="fitCenter"
+    android:background="@android:color/black"
+    android:visibility="invisible" />
index 99b6ec3..910e9c1 100644 (file)
@@ -1349,6 +1349,7 @@ public class PhotoModule
             return;
         }
         mUI.hidePostCaptureAlert();
+        mUI.hideIntentReviewImageView();
         setupPreview();
     }
 
index 6048145..97ccfcd 100644 (file)
@@ -19,6 +19,7 @@ package com.android.camera;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.graphics.Bitmap;
+import android.graphics.Color;
 import android.graphics.Matrix;
 import android.graphics.RectF;
 import android.graphics.SurfaceTexture;
@@ -30,6 +31,8 @@ import android.view.GestureDetector;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
 
 import com.android.camera.FocusOverlayManager.FocusUI;
 import com.android.camera.cameradevice.CameraManager;
@@ -72,6 +75,8 @@ public class PhotoUI implements PreviewStatusListener,
     private int mPreviewHeight = 0;
     private float mAspectRatio = UNSET;
 
+    private ImageView mIntentReviewImageView;
+
     private final GestureDetector.OnGestureListener mPreviewGestureListener
             = new GestureDetector.SimpleOnGestureListener() {
         @Override
@@ -210,6 +215,10 @@ public class PhotoUI implements PreviewStatusListener,
             if (isCancelled()) {
                 return;
             }
+
+            mIntentReviewImageView.setImageBitmap(bitmap);
+            showIntentReviewImageView();
+
             mDecodeTaskForReview = null;
         }
     }
@@ -226,8 +235,52 @@ public class PhotoUI implements PreviewStatusListener,
         mFocusUI = (FocusUI) mRootView.findViewById(R.id.focus_overlay);
         mPreviewOverlay = (PreviewOverlay) mRootView.findViewById(R.id.preview_overlay);
         mCountdownView = (CountDownView) mRootView.findViewById(R.id.count_down_view);
+
+        if (mController.isImageCaptureIntent()) {
+            createIntentReviewImageView();
+        }
+    }
+
+    private void createIntentReviewImageView() {
+        ViewGroup parentViewGroup = (ViewGroup) mRootView;
+        mIntentReviewImageView = (ImageView) mActivity.getLayoutInflater()
+            .inflate(R.layout.intent_review_imageview, parentViewGroup, false);
+        parentViewGroup.addView(mIntentReviewImageView);
+        mIntentReviewImageView.bringToFront();
+
+        mActivity.getCameraAppUI().addPreviewAreaChangedListener(
+                new PreviewStatusListener.PreviewAreaChangedListener() {
+                    @Override
+                    public void onPreviewAreaChanged(RectF previewArea) {
+                        FrameLayout.LayoutParams params =
+                            (FrameLayout.LayoutParams) mIntentReviewImageView.getLayoutParams();
+                        params.width = (int) previewArea.width();
+                        params.height = (int) previewArea.height();
+                        params.setMargins((int) previewArea.left, (int) previewArea.top, 0, 0);
+                        mIntentReviewImageView.setLayoutParams(params);
+                    }
+                });
     }
 
+    /**
+     * Show the image review over the live preview for intent captures.
+     */
+    public void showIntentReviewImageView() {
+        if (mIntentReviewImageView != null) {
+            mIntentReviewImageView.setVisibility(View.VISIBLE);
+        }
+    }
+
+    /**
+     * Hide the image review over the live preview for intent captures.
+     */
+    public void hideIntentReviewImageView() {
+        if (mIntentReviewImageView != null) {
+            mIntentReviewImageView.setVisibility(View.INVISIBLE);
+        }
+    }
+
+
     public FocusUI getFocusUI() {
         return mFocusUI;
     }
index f4c9e00..3d44e27 100644 (file)
@@ -160,7 +160,7 @@ public class TextureViewHelper implements TextureView.SurfaceTextureListener,
     /**
      * This takes a matrix to apply to the texture view and uses the screen
      * aspect ratio as the target aspect ratio
-     * 
+     *
      * @param matrix the matrix to apply
      * @param aspectRatio the aspectRatio that the preview should be
      */
index 224093c..3dcfc5e 100644 (file)
@@ -210,15 +210,14 @@ public class BottomBar extends FrameLayout {
     }
 
     /**
-     * Perform a transition to the global intent layout.  The current
-     * layout state of the bottom bar is irrelevant.
+     * Perform a transition to the global intent layout.
+     * The current layout state of the bottom bar is irrelevant.
      */
     public void transitionToIntentCaptureLayout() {
         mIntentReviewLayout.setVisibility(View.INVISIBLE);
         mCaptureLayout.setVisibility(View.VISIBLE);
         mCancelLayout.setVisibility(View.INVISIBLE);
 
-
         mMode = MODE_INTENT;
     }