diff options
Diffstat (limited to 'src/com/android/camera/ui')
8 files changed, 168 insertions, 80 deletions
diff --git a/src/com/android/camera/ui/ControlPanelLayout.java b/src/com/android/camera/ui/ControlPanelLayout.java index c6ab99f..24efb8b 100644 --- a/src/com/android/camera/ui/ControlPanelLayout.java +++ b/src/com/android/camera/ui/ControlPanelLayout.java @@ -41,7 +41,7 @@ public class ControlPanelLayout extends RelativeLayout { int widthSpecSize = MeasureSpec.getSize(widthSpec); int heightSpecSize = MeasureSpec.getSize(heightSpec); int measuredSize = 0; - int mode, longSideSize, shortSideSize, minSize, specSize; + int mode, longSideSize, shortSideSize, specSize; boolean isLandscape = (((Activity) getContext()).getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); @@ -50,13 +50,11 @@ public class ControlPanelLayout extends RelativeLayout { mode = MeasureSpec.getMode(widthSpec); longSideSize = widthSpecSize; shortSideSize = heightSpecSize; - minSize = getSuggestedMinimumWidth(); specSize = widthSpecSize; } else { mode = MeasureSpec.getMode(heightSpec); longSideSize = heightSpecSize; shortSideSize = widthSpecSize; - minSize = getSuggestedMinimumHeight(); specSize = heightSpecSize; } @@ -68,11 +66,6 @@ public class ControlPanelLayout extends RelativeLayout { Log.e(TAG, "layout_xxx of ControlPanelLayout should be wrap_content"); } - // Make sure the width is bigger than the minimum length. - if (minSize > measuredSize) { - measuredSize = minSize; - } - // The width cannot be bigger than the constraint. if (mode == MeasureSpec.AT_MOST && measuredSize > specSize) { measuredSize = specSize; diff --git a/src/com/android/camera/ui/IndicatorControlBar.java b/src/com/android/camera/ui/IndicatorControlBar.java index 6c2151d..8ab61fd 100644 --- a/src/com/android/camera/ui/IndicatorControlBar.java +++ b/src/com/android/camera/ui/IndicatorControlBar.java @@ -87,20 +87,19 @@ public class IndicatorControlBar extends IndicatorControl implements int count = getChildCount(); if (count == 0) return; - int width = right - left; + int height = bottom - top; - // First indicator will be CameraPicker if exists. - if (mCameraPicker != null) { - mCameraPicker.layout(0, padding, width, padding + width); - } + mSecondLevelIcon.layout(0, 0, height, height); // Layout the zoom control if required. - int offset = padding + width; // the padding and the icon height + int offset = padding + height; // the padding and the icon height if (mZoomControl != null) { - mZoomControl.layout(0, offset, width, bottom - top - offset); + mZoomControl.layout(offset, 0, right - left - offset, height); } - mSecondLevelIcon.layout(0, bottom - top - offset, width, bottom - top); + if (mCameraPicker != null) { + mCameraPicker.layout(right - left - offset, 0, right - left, height); + } } @Override diff --git a/src/com/android/camera/ui/IndicatorControlBarContainer.java b/src/com/android/camera/ui/IndicatorControlBarContainer.java index 1e860ad..3c907a8 100644 --- a/src/com/android/camera/ui/IndicatorControlBarContainer.java +++ b/src/com/android/camera/ui/IndicatorControlBarContainer.java @@ -43,14 +43,14 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer { public IndicatorControlBarContainer(Context context, AttributeSet attrs) { super(context, attrs); mFadeIn = AnimationUtils.loadAnimation( - context, R.anim.grow_fade_in_from_top); + context, R.anim.first_level_fade_in); mFadeOut = AnimationUtils.loadAnimation( - context, R.anim.shrink_fade_out_from_bottom); + context, R.anim.first_level_fade_out); mFadeOut.setAnimationListener(mAnimationListener); mSecondLevelFadeIn = AnimationUtils.loadAnimation( - context, R.anim.grow_fade_in_from_bottom); + context, R.anim.second_level_fade_in); mSecondLevelFadeOut = AnimationUtils.loadAnimation( - context, R.anim.shrink_fade_out_from_top); + context, R.anim.second_level_fade_out); mSecondLevelFadeOut.setAnimationListener(mAnimationListener); } diff --git a/src/com/android/camera/ui/OneRowGridView.java b/src/com/android/camera/ui/OneRowGridView.java new file mode 100644 index 0000000..5e37d35 --- /dev/null +++ b/src/com/android/camera/ui/OneRowGridView.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 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.content.Context; +import android.util.AttributeSet; +import android.widget.GridView; + +public class OneRowGridView extends GridView { + public OneRowGridView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // Once we know the number of children in this view, we have to set + // the correct width and height for containing the icons in one row. + int n = getChildCount(); + if (n == 0) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } else { + setMeasuredDimension((n * getChildAt(0).getMeasuredWidth()), + getMeasuredHeight()); + } + } +} diff --git a/src/com/android/camera/ui/RightAlignedHorizontalScrollView.java b/src/com/android/camera/ui/RightAlignedHorizontalScrollView.java new file mode 100644 index 0000000..cd4c5f5 --- /dev/null +++ b/src/com/android/camera/ui/RightAlignedHorizontalScrollView.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 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.view.View; +import android.util.AttributeSet; +import android.widget.HorizontalScrollView; + +public class RightAlignedHorizontalScrollView extends HorizontalScrollView { + + public RightAlignedHorizontalScrollView(Context context) { + super(context); + } + + public RightAlignedHorizontalScrollView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + if (changed) { + // Get the width of the child, i.e. the LinearLayout, and scroll to + // the rightmost position. + View child = getChildAt(0); + if (child != null) scrollTo(child.getWidth(), 0); + } + } +} diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java index 45bbca8..1fb9a80 100644 --- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java +++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java @@ -73,20 +73,20 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements OnIndicatorEventListener.EVENT_LEAVE_SECOND_LEVEL_INDICATOR_BAR); } - private int getTouchViewIndex(int y, int height) { + private int getTouchViewIndex(int x, int width) { // If the current touch location is on close icon and above. - if (y < mCloseIcon.getBottom()) return indexOfChild(mCloseIcon); + if (x > mCloseIcon.getLeft()) return indexOfChild(mCloseIcon); // Calculate if the touch event is on the indicator buttons. int count = getChildCount(); if (count == mNonIndicatorButtonCount) return -1; // The baseline will be the first indicator button's top minus spacing. View firstIndicatorButton = getChildAt(mNonIndicatorButtonCount); - int baselineY = firstIndicatorButton.getTop() - (ICON_SPACING / 2); - if (y < baselineY) return -1; - int iconHeight = firstIndicatorButton.getMeasuredHeight(); - int buttonRange = iconHeight + ICON_SPACING; - return (mNonIndicatorButtonCount + (y - baselineY) / buttonRange); + int baselineX = firstIndicatorButton.getRight() + (ICON_SPACING / 2); + if (x > baselineX) return -1; + int iconWidth = firstIndicatorButton.getMeasuredWidth(); + int buttonRange = iconWidth + ICON_SPACING; + return (mNonIndicatorButtonCount + ((baselineX - x) / buttonRange)); } @Override @@ -98,12 +98,12 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements double x = (double) event.getX(); double y = (double) event.getY(); - int height = getHeight(); - if (height == 0) return false; // the event is sent before onMeasure() - if (x > getWidth()) x = getWidth(); - if (y >= height) y = height - 1; + int width = getWidth(); + if (width == 0) return false; // the event is sent before onMeasure() + if (x > width) x = width; + if (y >= getHeight()) y = getHeight() - 1; - int index = getTouchViewIndex((int) y, height); + int index = getTouchViewIndex((int) x, width); if (index == -1) return true; View b = getChildAt(index); b.dispatchTouchEvent(event); @@ -163,26 +163,26 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements if (count == 0) return; int width = right - left; int height = bottom - top; - int iconHeight = mCloseIcon.getMeasuredHeight(); - int padding = getPaddingTop(); - - // The first icon is close button. - int offsetY = padding; - mCloseIcon.layout(0, padding, width, (padding + iconHeight)); - - // And layout the divider line. - offsetY += (iconHeight + padding); - mDivider.layout(padding, offsetY, - (width - padding), (offsetY + mDivider.getMeasuredHeight())); + int iconWidth = mCloseIcon.getMeasuredWidth(); + int padding = getPaddingLeft(); // Layout from the last icon up. - int startY = height - iconHeight - padding; - int decrement = iconHeight + ICON_SPACING; + int offsetX = padding; + int increment = iconWidth + ICON_SPACING; for (int i = count - 1; i >= mNonIndicatorButtonCount; --i) { - getChildAt(i).layout(0, startY, width, startY + iconHeight); - startY -= decrement; + getChildAt(i).layout(offsetX, 0, offsetX + iconWidth, height); + offsetX += increment; } + // And layout the divider line. + offsetX = width - iconWidth - 2 * padding; + mDivider.layout(offsetX, padding, (offsetX + mDivider.getMeasuredWidth()), + (height - padding)); + + offsetX = width - iconWidth - padding; + // The first icon is close button. + mCloseIcon.layout(offsetX, 0, (offsetX + iconWidth), height); + // Hightlight the selected indicator if exists. if (mPopupedIndicator == null) { mIndicatorHighlight.setVisibility(View.GONE); @@ -190,9 +190,9 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements mIndicatorHighlight.setVisibility(View.VISIBLE); // Keep the top and bottom of the hightlight the same as // the 'active' indicator button. - mIndicatorHighlight.layout(0, mPopupedIndicator.getTop(), - mIndicatorHighlight.getLayoutParams().width, - mPopupedIndicator.getBottom()); + mIndicatorHighlight.layout(mPopupedIndicator.getLeft(), 0, + mPopupedIndicator.getRight(), + mIndicatorHighlight.getLayoutParams().height); } } diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java index 384634a..134b7c0 100644 --- a/src/com/android/camera/ui/SharePopup.java +++ b/src/com/android/camera/ui/SharePopup.java @@ -23,6 +23,7 @@ import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; @@ -38,7 +39,7 @@ import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ImageView; -import android.widget.ListView; +import android.widget.GridView; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.SimpleAdapter; @@ -65,7 +66,7 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, // A view that contains a list of application icons and the share view. private View mRootView; // The list of the application icons. - private ListView mShareList; + private GridView mShareList; // A rotated view that contains the thumbnail. private RotateLayout mThumbnailRotateLayout; private RotateLayout mGotoGalleryRotate; @@ -114,8 +115,7 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, // This is required because popup window is full screen. sharePopup.setOnTouchListener(this); mThumbnailRotateLayout = (RotateLayout) sharePopup.findViewById(R.id.thumbnail_rotate_layout); - mShareList = (ListView) sharePopup.findViewById(R.id.share_list); - mShareList.setDivider(null); + mShareList = (GridView) sharePopup.findViewById(R.id.share_list); mThumbnail = (ImageView) sharePopup.findViewById(R.id.thumbnail); mThumbnail.setImageBitmap(bitmap); mShareView = (ViewGroup) sharePopup.findViewById(R.id.share_view); @@ -279,10 +279,19 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, items.add(map); mComponent.add(component); } + + // On phone UI, we have to know how many icons in the grid view before + // the view is measured. + if (((Activity) mContext).getRequestedOrientation() + == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { + mShareList.setNumColumns(items.size()); + } + SimpleAdapter listItemAdapter = new MySimpleAdapter(mContext, items, R.layout.share_icon, new String[] {ADAPTER_COLUMN_ICON}, new int[] {R.id.icon}); + listItemAdapter.setViewBinder(mViewBinder); mShareList.setAdapter(listItemAdapter); mShareList.setOnItemClickListener(this); diff --git a/src/com/android/camera/ui/ZoomControlBar.java b/src/com/android/camera/ui/ZoomControlBar.java index 2e14e53..4e572cf 100644 --- a/src/com/android/camera/ui/ZoomControlBar.java +++ b/src/com/android/camera/ui/ZoomControlBar.java @@ -36,9 +36,9 @@ public class ZoomControlBar extends ZoomControl { private View mBar; private boolean mStartChanging; private int mSliderLength; - private int mHeight; - private int mIconHeight; - private int mTotalIconHeight; + private int mWidth; + private int mIconWidth; + private int mTotalIconWidth; public ZoomControlBar(Context context, AttributeSet attrs) { super(context, attrs); @@ -53,16 +53,16 @@ public class ZoomControlBar extends ZoomControl { mBar.setActivated(activated); } - private int getSliderPosition(int y) { + private int getSliderPosition(int x) { // Calculate the absolute offset of the slider in the zoom control bar. // For left-hand users, as the device is rotated for 180 degree for // landscape mode, the zoom-in bottom should be on the top, so the // position should be reversed. int pos; // the relative position in the zoom slider bar - if (mOrientation == 180) { - pos = y - mTotalIconHeight; + if (mOrientation == 90) { + pos = mWidth - mTotalIconWidth - x; } else { - pos = mHeight - mTotalIconHeight - y; + pos = x - mTotalIconWidth; } if (pos < 0) pos = 0; if (pos > mSliderLength) pos = mSliderLength; @@ -71,15 +71,15 @@ public class ZoomControlBar extends ZoomControl { @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { - mHeight = h; - mIconHeight = mZoomIn.getMeasuredHeight(); - mTotalIconHeight = mIconHeight + ICON_SPACING; - mSliderLength = mHeight - (2 * mTotalIconHeight); + mWidth = w; + mIconWidth = mZoomIn.getMeasuredWidth(); + mTotalIconWidth = mIconWidth + ICON_SPACING; + mSliderLength = mWidth - (2 * mTotalIconWidth); } @Override public boolean dispatchTouchEvent(MotionEvent event) { - if (!isEnabled() || (mHeight == 0)) return false; + if (!isEnabled() || (mWidth == 0)) return false; int action = event.getAction(); switch (action) { @@ -94,7 +94,7 @@ public class ZoomControlBar extends ZoomControl { setActivated(true); mStartChanging = false; case MotionEvent.ACTION_MOVE: - int pos = getSliderPosition((int) event.getY()); + int pos = getSliderPosition((int) event.getX()); if (!mStartChanging) { // Make sure the movement is large enough before we start // changing the zoom. @@ -116,7 +116,7 @@ public class ZoomControlBar extends ZoomControl { @Override public void setOrientation(int orientation) { // layout for the left-hand camera control - if ((orientation == 180) || (mOrientation == 180)) requestLayout(); + if ((orientation == 90) || (mOrientation == 90)) requestLayout(); super.setOrientation(orientation); } @@ -124,8 +124,8 @@ public class ZoomControlBar extends ZoomControl { protected void onLayout( boolean changed, int left, int top, int right, int bottom) { if (mZoomMax == 0) return; - int width = right - left; - mBar.layout(0, mTotalIconHeight, width, mHeight - mTotalIconHeight); + int height = bottom - top; + mBar.layout(mTotalIconWidth, 0, mWidth - mTotalIconWidth, height); // For left-hand users, as the device is rotated for 180 degree, // the zoom-in button should be on the top. int pos; // slider position @@ -135,18 +135,18 @@ public class ZoomControlBar extends ZoomControl { } else { sliderPosition = (int) ((double) mSliderLength * mZoomIndex / mZoomMax); } - if (mOrientation == 180) { - mZoomOut.layout(0, 0, width, mIconHeight); - mZoomIn.layout(0, mHeight - mIconHeight, width, mHeight); - pos = mBar.getTop() + sliderPosition; + if (mOrientation == 90) { + mZoomIn.layout(0, 0, mIconWidth, height); + mZoomOut.layout(mWidth - mIconWidth, 0, mWidth, height); + pos = mBar.getRight() - sliderPosition; } else { - mZoomIn.layout(0, 0, width, mIconHeight); - mZoomOut.layout(0, mHeight - mIconHeight, width, mHeight); - pos = mBar.getBottom() - sliderPosition; + mZoomOut.layout(0, 0, mIconWidth, height); + mZoomIn.layout(mWidth - mIconWidth, 0, mWidth, height); + pos = mBar.getLeft() + sliderPosition; } - int sliderHeight = mZoomSlider.getMeasuredHeight(); - mZoomSlider.layout(0, (pos - sliderHeight / 2), - width, (pos + sliderHeight / 2)); + int sliderWidth = mZoomSlider.getMeasuredWidth(); + mZoomSlider.layout((pos - sliderWidth / 2), 0, + (pos + sliderWidth / 2), height); } @Override |