summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r--src/com/android/camera/ui/IndicatorWheel.java29
-rw-r--r--src/com/android/camera/ui/RotateImageView.java1
-rw-r--r--src/com/android/camera/ui/RotateLayout.java117
-rw-r--r--src/com/android/camera/ui/SharePopup.java143
4 files changed, 266 insertions, 24 deletions
diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java
index 1a374da..c2d7d3c 100644
--- a/src/com/android/camera/ui/IndicatorWheel.java
+++ b/src/com/android/camera/ui/IndicatorWheel.java
@@ -16,7 +16,6 @@
package com.android.camera.ui;
-import com.android.camera.ComboPreferences;
import com.android.camera.IconListPreference;
import com.android.camera.PreferenceGroup;
import com.android.camera.R;
@@ -26,24 +25,22 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
-import android.os.Handler;
import android.os.SystemClock;
import android.util.AttributeSet;
-import android.util.Log;
-import android.widget.ImageView;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
-import android.view.ViewGroup;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
import java.util.ArrayList;
/**
* A view that contains shutter button and camera setting indicators. The
* indicators are spreaded around the shutter button. The first child is always
- * the shutter button. The last indicator is always the share button.
+ * the shutter button.
*/
public class IndicatorWheel extends ViewGroup implements
BasicSettingPopup.Listener, OtherSettingsPopup.Listener {
@@ -98,7 +95,6 @@ public class IndicatorWheel extends ViewGroup implements
public void onSharedPreferenceChanged();
public void onRestorePreferencesClicked();
public void onOverriddenPreferencesClicked();
- public void onShareButtonClicked();
}
public void setListener(Listener listener) {
@@ -467,9 +463,6 @@ public class IndicatorWheel extends ViewGroup implements
}
mSettingPopups = new AbstractSettingPopup[len];
- // Add share button. It is always the last one.
- addIndicator(context, R.drawable.ic_viewfinder_share);
-
requestLayout();
}
@@ -494,12 +487,6 @@ public class IndicatorWheel extends ViewGroup implements
}
}
- public void onShareButtonClicked() {
- if (mListener != null) {
- mListener.onShareButtonClicked();
- }
- }
-
private void initializeSettingPopup(int index) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
@@ -527,12 +514,6 @@ public class IndicatorWheel extends ViewGroup implements
private void showSettingPopup(int index) {
if (index == mSelectedIndex) return;
- // The share button is the last indicator.
- if (index == mIndicatorCount - 1) {
- onShareButtonClicked();
- return;
- }
-
if (mSettingPopups[index] == null) initializeSettingPopup(index);
if (mPrevAnimatingView != null) mPrevAnimatingView.clearAnimation();
diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java
index 2d88a47..a76d7bc 100644
--- a/src/com/android/camera/ui/RotateImageView.java
+++ b/src/com/android/camera/ui/RotateImageView.java
@@ -56,6 +56,7 @@ public class RotateImageView extends ImageView {
mEnableAnimation = enable;
}
+ // Rotate the view counter-clockwise
public void setDegree(int degree) {
// make sure in the range of [0, 359]
degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java
new file mode 100644
index 0000000..6e1aa92
--- /dev/null
+++ b/src/com/android/camera/ui/RotateLayout.java
@@ -0,0 +1,117 @@
+/*
+ * 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.ui;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+
+// A RotateLayout is designed to display a single item and provides the
+// capabilities to rotate the item.
+class RotateLayout extends ViewGroup {
+ private int mOrientation;
+ private View mChild;
+
+ public RotateLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ mChild = getChildAt(0);
+ }
+
+ @Override
+ protected void onLayout(
+ boolean change, int left, int top, int right, int bottom) {
+ int width = right - left;
+ int height = bottom - top;
+ switch (mOrientation) {
+ case 0:
+ case 180:
+ mChild.layout(0, 0, width, height);
+ break;
+ case 90:
+ case 270:
+ mChild.layout(0, 0, height, width);
+ break;
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthSpec, int heightSpec) {
+ switch(mOrientation) {
+ case 0:
+ case 180:
+ measureChild(mChild, widthSpec, heightSpec);
+ setMeasuredDimension(mChild.getMeasuredWidth(), mChild.getMeasuredHeight());
+ break;
+ case 90:
+ case 270:
+ measureChild(mChild, heightSpec, widthSpec);
+ setMeasuredDimension(mChild.getMeasuredHeight(), mChild.getMeasuredWidth());
+ break;
+ }
+ }
+
+ @Override
+ public void dispatchDraw(Canvas canvas) {
+ int w = getWidth();
+ int h = getHeight();
+ switch (mOrientation) {
+ case 90:
+ canvas.translate(0, h);
+ canvas.rotate(-mOrientation);
+ break;
+ case 180:
+ canvas.rotate(-mOrientation, w / 2, h / 2);
+ break;
+ case 270:
+ canvas.translate(w, 0);
+ canvas.rotate(-mOrientation);
+ break;
+ }
+ super.dispatchDraw(canvas);
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ float x = event.getX();
+ float y = event.getY();
+ float width = getWidth();
+ float height = getHeight();
+ switch (mOrientation) {
+ case 90: event.setLocation(height - y, x); break;
+ case 180: event.setLocation(width - x, height - y); break;
+ case 270: event.setLocation(y, width - x); break;
+ }
+ boolean result = mChild.dispatchTouchEvent(event);
+ event.setLocation(x, y);
+ return result;
+ }
+
+ // Rotate the view counter-clockwise
+ public void setOrientation(int orientation) {
+ orientation = orientation % 360;
+ if (mOrientation == orientation) return;
+ mOrientation = orientation;
+ requestLayout();
+ }
+}
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java
new file mode 100644
index 0000000..d182e2d
--- /dev/null
+++ b/src/com/android/camera/ui/SharePopup.java
@@ -0,0 +1,143 @@
+/*
+ * 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.ui;
+
+import com.android.camera.R;
+import com.android.camera.Util;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.drawable.ColorDrawable;
+import android.net.Uri;
+import android.util.DisplayMetrics;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.ViewGroup.MarginLayoutParams;
+import android.view.WindowManager;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.PopupWindow;
+
+// A popup window that contains a big thumbnail and a list of apps to share.
+public class SharePopup extends PopupWindow implements View.OnClickListener,
+ View.OnTouchListener {
+ private Context mContext;
+ private Uri mUri;
+
+ // The maximum width of the thumbnail in landscape orientation.
+ private final float mImageMaxWidthLandscape;
+ // The maximum height of the thumbnail in landscape orientation.
+ private final float mImageMaxHeightLandscape;
+ // The maximum width of the thumbnail in portrait orientation.
+ private final float mImageMaxWidthPortrait;
+ // The maximum height of the thumbnail in portrait orientation.
+ private final float mImageMaxHeightPortrait;
+
+ private ImageView mThumbnail;
+ private int mBitmapWidth, mBitmapHeight;
+ private RotateLayout mRotateLayout;
+
+ public SharePopup(Activity activity, Uri uri, Bitmap bitmap, int orientation, View anchor) {
+ super(activity);
+
+ // Initailize variables
+ mContext = activity;
+ mUri = uri;
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ View contentView = inflater.inflate(R.layout.share_popup, null, false);
+ // This is required because popup window is full screen.
+ contentView.setOnTouchListener(this);
+ mRotateLayout = (RotateLayout) contentView.findViewById(R.id.rotate_layout);
+ mThumbnail = (ImageView) contentView.findViewById(R.id.expanded_thumbnail);
+ mThumbnail.setImageBitmap(bitmap);
+ mThumbnail.setOnClickListener(this);
+ mBitmapWidth = bitmap.getWidth();
+ mBitmapHeight = bitmap.getHeight();
+ Resources res = mContext.getResources();
+ mImageMaxWidthLandscape = res.getDimension(R.dimen.share_image_max_width_landscape);
+ mImageMaxHeightLandscape = res.getDimension(R.dimen.share_image_max_height_landscape);
+ mImageMaxWidthPortrait = res.getDimension(R.dimen.share_image_max_width_portrait);
+ mImageMaxHeightPortrait = res.getDimension(R.dimen.share_image_max_height_portrait);
+
+ // Initialize popup window
+ setWidth(WindowManager.LayoutParams.MATCH_PARENT);
+ setHeight(WindowManager.LayoutParams.MATCH_PARENT);
+ setBackgroundDrawable(new ColorDrawable());
+ setContentView(contentView);
+ setOrientation(orientation);
+
+ // Initialize view location
+ int location[] = new int[2];
+ anchor.getLocationOnScreen(location);
+ DisplayMetrics metrics = new DisplayMetrics();
+ activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ MarginLayoutParams params = (MarginLayoutParams) mRotateLayout.getLayoutParams();
+ params.topMargin = location[1] / 2;
+ params.rightMargin = (metrics.widthPixels - location[0] - anchor.getWidth()) / 2;
+ mRotateLayout.setLayoutParams(params);
+
+ // Start animation
+ Animation fadeIn = AnimationUtils.loadAnimation(mContext, R.anim.grow_fade_in_from_right);
+ mRotateLayout.startAnimation(fadeIn);
+ }
+
+ public void setOrientation(int orientation) {
+ // Calculate the width and the height of the thumbnail.
+ float width, height;
+ if (orientation == 90 || orientation == 270) {
+ width = mImageMaxWidthPortrait;
+ height = mImageMaxHeightPortrait;
+ } else {
+ width = mImageMaxWidthLandscape;
+ height = mImageMaxHeightLandscape;
+ }
+ LayoutParams params = mThumbnail.getLayoutParams();
+ if (width * mBitmapHeight > height * mBitmapWidth) {
+ params.width = Math.round(mBitmapWidth * height / mBitmapHeight);
+ params.height = Math.round(height);
+ } else {
+ params.width = Math.round(width);
+ params.height = Math.round(mBitmapHeight * params.width / mBitmapWidth);
+ }
+ mThumbnail.setLayoutParams(params);
+ mRotateLayout.setOrientation(orientation);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.expanded_thumbnail:
+ Util.viewUri(mUri, mContext);
+ break;
+ }
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ dismiss();
+ return true;
+ }
+ return false;
+ }
+}