summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wagner <mxw@google.com>2011-10-06 10:25:49 -0700
committerMark Wagner <mxw@google.com>2011-10-07 09:52:37 -0700
commit5201b1e0051877d8e8ed0ef5b461ffcac534eb5c (patch)
tree9d80f215f395934c8a1b166b9ec6e5f018820d61
parentfc52f4a9bf815633739125883807bfe965cf6009 (diff)
downloadLegacyCamera-5201b1e0051877d8e8ed0ef5b461ffcac534eb5c.zip
LegacyCamera-5201b1e0051877d8e8ed0ef5b461ffcac534eb5c.tar.gz
LegacyCamera-5201b1e0051877d8e8ed0ef5b461ffcac534eb5c.tar.bz2
bugfix 5290450 Share UI should match redlines
Incremental work towards matching the redline. This will probably require a review pass from UX to catch any missed items. Change-Id: I0496aa0fc1941f8ffa06050ae8fbed3fe7246878
-rw-r--r--res/layout/share_popup.xml12
-rw-r--r--res/values/colors.xml3
-rwxr-xr-xsrc/com/android/camera/panorama/PanoramaActivity.java31
-rw-r--r--src/com/android/camera/ui/SharePopup.java107
4 files changed, 116 insertions, 37 deletions
diff --git a/res/layout/share_popup.xml b/res/layout/share_popup.xml
index 1bae66b..416f46e 100644
--- a/res/layout/share_popup.xml
+++ b/res/layout/share_popup.xml
@@ -25,12 +25,10 @@
<FrameLayout android:id="@+id/root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:padding="8dp"
android:layout_gravity="left|center">
<RelativeLayout android:id="@+id/share_view"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:background="@drawable/border_last_picture">
<com.android.camera.ui.RotateLayout
android:id="@+id/thumbnail_rotate_layout"
@@ -45,12 +43,6 @@
android:adjustViewBounds="true"
android:scaleType="fitCenter"/>
</com.android.camera.ui.RotateLayout>
- <ImageView android:id="@+id/arrow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:src="@drawable/ic_switch_arrow"/>
<ImageView android:id="@+id/play"
style="@style/ReviewPlayIcon"/>
</RelativeLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9539210..f341e8c 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -26,7 +26,8 @@
<color name="time_lapse_arc">#FFC5C5C5</color>
<color name="dark_gray">#151515</color>
<color name="share_popup_background">#DA000000</color>
- <color name="share_icon_background">#40000000</color>
+ <color name="share_popup_blackout">#ff222222</color>
+ <color name="share_icon_background">#80000000</color>
<color name="indicator_background">#40000000</color>
<color name="popup_title_color">#ff33b5e5</color>
<color name="popup_background">#ff282828</color>
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index 09df1e0..d465bf7 100755
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -174,6 +174,7 @@ public class PanoramaActivity extends ActivityBase implements
// The value could be 0, 1, 2, 3 for the 4 different orientations measured in clockwise
// respectively.
private int mDeviceOrientation;
+ private int mOrientationCompensation;
private class MosaicJpeg {
public MosaicJpeg(byte[] data, int width, int height) {
@@ -196,6 +197,10 @@ public class PanoramaActivity extends ActivityBase implements
public final boolean isValid;
}
+ public static int roundOrientation(int orientation) {
+ return ((orientation + 45) / 90 * 90) % 360;
+ }
+
private class PanoOrientationEventListener extends OrientationEventListener {
public PanoOrientationEventListener(Context context) {
super(context);
@@ -203,12 +208,26 @@ public class PanoramaActivity extends ActivityBase implements
@Override
public void onOrientationChanged(int orientation) {
- // Default to the last known orientation.
+ // We keep the last known orientation. So if the user first orient
+ // the camera then point the camera to floor or sky, we still have
+ // the correct orientation.
if (orientation == ORIENTATION_UNKNOWN) return;
- mDeviceOrientation = ((orientation + 45) / 90) % 4;
+ mDeviceOrientation = roundOrientation(orientation);
+ // When the screen is unlocked, display rotation may change. Always
+ // calculate the up-to-date orientationCompensation.
+ int orientationCompensation = mDeviceOrientation
+ + Util.getDisplayRotation(PanoramaActivity.this);
+ if (mOrientationCompensation != orientationCompensation) {
+ mOrientationCompensation = orientationCompensation;
+ setOrientationIndicator(mOrientationCompensation);
+ }
}
}
+ private void setOrientationIndicator(int degree) {
+ if (mSharePopup != null) mSharePopup.setOrientation(degree);
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
@@ -814,7 +833,8 @@ public class PanoramaActivity extends ActivityBase implements
Uri uri = mThumbnail.getUri();
if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) {
// The orientation compensation is set to 0 here because we only support landscape.
- mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(), 0,
+ mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(),
+ mOrientationCompensation,
findViewById(R.id.frame_layout));
}
mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0);
@@ -881,6 +901,11 @@ public class PanoramaActivity extends ActivityBase implements
reset();
}
if (mSharePopup != null) mSharePopup.dismiss();
+
+ if (mThumbnail != null && !mThumbnail.fromFile()) {
+ mThumbnail.saveTo(new File(getFilesDir(), Thumbnail.LAST_THUMB_FILENAME));
+ }
+
releaseCamera();
mMosaicView.onPause();
clearMosaicFrameProcessorIfNeeded();
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java
index c3934c5..42b27d1 100644
--- a/src/com/android/camera/ui/SharePopup.java
+++ b/src/com/android/camera/ui/SharePopup.java
@@ -40,6 +40,7 @@ import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
+import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
@@ -107,8 +108,7 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
mUri = uri;
mMimeType = mContext.getContentResolver().getType(mUri);
mPreviewFrame = previewFrame;
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater inflater = activity.getLayoutInflater();
ViewGroup sharePopup = (ViewGroup) inflater.inflate(R.layout.share_popup, null, false);
// This is required because popup window is full screen.
sharePopup.setOnTouchListener(this);
@@ -119,16 +119,56 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
mThumbnail.setImageBitmap(bitmap);
mShareView = (ViewGroup) sharePopup.findViewById(R.id.share_view);
mShareView.setOnClickListener(this);
+
+ mBitmapWidth = bitmap.getWidth();
+ mBitmapHeight = bitmap.getHeight();
+
// Show play button if this is a video thumbnail.
if (mMimeType.startsWith("video/")) {
sharePopup.findViewById(R.id.play).setVisibility(View.VISIBLE);
+
+ // for some reason we want to show video thumbnail in a 4/3 ratio
+ // crop the image here, for dispaly, as necessary
+ final float targetRatio = 4F/3F;
+ final float existingRatio = (float)mBitmapWidth / (float)mBitmapHeight;
+
+ if (existingRatio > targetRatio) {
+ int newWidth = (int) ((float)mBitmapHeight * targetRatio);
+
+ // check if we end up with the same width due to rounding
+ if (newWidth != mBitmapWidth) {
+ bitmap = Bitmap.createBitmap(
+ bitmap,
+ (mBitmapWidth - newWidth) / 2,
+ 0, // yCoord
+ newWidth,
+ mBitmapHeight,
+ null,
+ false);
+ }
+ } else if (existingRatio < targetRatio) {
+ int newHeight = (int) ((float)mBitmapWidth * targetRatio);
+
+ // check if we end up with the same width due to rounding
+ if (newHeight != mBitmapHeight) {
+ bitmap = Bitmap.createBitmap(
+ bitmap,
+ 0, // xCoord
+ (mBitmapHeight - newHeight) / 2,
+ mBitmapWidth,
+ newHeight,
+ null,
+ false);
+ }
+ }
}
mBitmapWidth = bitmap.getWidth();
mBitmapHeight = bitmap.getHeight();
+
Resources res = mContext.getResources();
// Initialize popup window size.
- mRootView = (View) sharePopup.findViewById(R.id.root);
+ mRootView = sharePopup.findViewById(R.id.root);
LayoutParams params = mRootView.getLayoutParams();
params.width = previewFrame.getWidth();
params.height = previewFrame.getHeight();
@@ -143,6 +183,40 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
setFocusable(true);
setAnimationStyle(R.style.AnimationPopup);
createShareMenu();
+
+ adjustThumbnailPosition();
+ }
+
+ private void adjustThumbnailPosition() {
+ RelativeLayout.LayoutParams lpOld =
+ (RelativeLayout.LayoutParams) mThumbnailRotateLayout.getLayoutParams();
+ RelativeLayout.LayoutParams lpNew =
+ new RelativeLayout.LayoutParams(lpOld.width, lpOld.height);
+
+ mRootView.setBackgroundDrawable(null);
+ if (mBitmapWidth > mBitmapHeight*2) {
+ // panorama image
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ lpNew.addRule(RelativeLayout.CENTER_VERTICAL);
+
+ // panorama images block the preview from showing in the background
+ // use a special color here for that.
+ mRootView.setBackgroundColor(
+ mContext.getResources().getColor(R.color.share_popup_blackout));
+ } else if (mBitmapWidth > mBitmapHeight) {
+ // landscape image
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ } else {
+ // portrait image
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ lpNew.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ }
+
+ mThumbnailRotateLayout.setLayoutParams(lpNew);
}
public void setOrientation(int orientation) {
@@ -175,19 +249,6 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
}
mThumbnail.setLayoutParams(params);
- // Calculate the width and the height of the share view.
- int width = params.width + hPadding;
- int height = params.height + vPadding;
- LayoutParams shareViewParams = mShareView.getLayoutParams();
- if (orientation == 90 || orientation == 270) {
- shareViewParams.width = height;
- shareViewParams.height = width;
- } else {
- shareViewParams.width = width;
- shareViewParams.height = height;
- }
- mShareView.setLayoutParams(shareViewParams);
-
if (mThumbnailRotateLayout != null) mThumbnailRotateLayout.setOrientation(orientation);
int count = mShareList.getChildCount();
@@ -196,6 +257,8 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
RotateLayout r = (RotateLayout) f.findViewById(R.id.share_icon_rotate_layout);
r.setOrientation(orientation);
}
+
+ adjustThumbnailPosition();
}
@Override
@@ -225,21 +288,19 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
public void createShareMenu() {
PackageManager packageManager = mContext.getPackageManager();
- List<ResolveInfo> infos;
- infos = packageManager.queryIntentActivities(
+ List<ResolveInfo> infos = packageManager.queryIntentActivities(
new Intent(Intent.ACTION_SEND).setType(mMimeType), 0);
- ArrayList<HashMap<String, Object>> listItem =
- new ArrayList<HashMap<String, Object>>();
- for(ResolveInfo info: infos) {
+ ArrayList<HashMap<String, Object>> items = new ArrayList<HashMap<String, Object>>();
+ for (ResolveInfo info: infos) {
ComponentName component = new ComponentName(
info.activityInfo.packageName, info.activityInfo.name);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put(ADAPTER_COLUMN_ICON, info.loadIcon(packageManager));
- listItem.add(map);
+ items.add(map);
mComponent.add(component);
}
- SimpleAdapter listItemAdapter = new MySimpleAdapter(mContext, listItem,
+ SimpleAdapter listItemAdapter = new MySimpleAdapter(mContext, items,
R.layout.share_icon,
new String[] {ADAPTER_COLUMN_ICON},
new int[] {R.id.icon});