diff options
author | Chung-yih Wang <cywang@google.com> | 2011-10-18 12:47:44 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2011-11-01 15:31:16 +0800 |
commit | d33109730e0ab81230f84e2bd35599e8e24fc4ba (patch) | |
tree | df80db1d6647bf952f495a81d8ab67ee7498880d /src | |
parent | abf79a3e25e6c631275e9f81424c0aa25ec9191b (diff) | |
download | LegacyCamera-d33109730e0ab81230f84e2bd35599e8e24fc4ba.zip LegacyCamera-d33109730e0ab81230f84e2bd35599e8e24fc4ba.tar.gz LegacyCamera-d33109730e0ab81230f84e2bd35599e8e24fc4ba.tar.bz2 |
Change the default orientation to portrait.
bug:5446617
Since the orientation is mainly portrait on phones, the default
orientation of an application will decide if the window animation will
be played before it starts. In order to reduce the launch time of Camera
apps, this change is to skip the window animations by changing the default
orientation to portrait.
Change-Id: I6682ab408d7e8d1f0580f3c1600b6c9c3d6a7f6e
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/ActivityBase.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/Camera.java | 7 | ||||
-rwxr-xr-x | src/com/android/camera/panorama/PanoramaActivity.java | 120 | ||||
-rw-r--r-- | src/com/android/camera/ui/ControlPanelLayout.java | 9 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlBar.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlBarContainer.java | 8 | ||||
-rw-r--r-- | src/com/android/camera/ui/OneRowGridView.java | 43 | ||||
-rw-r--r-- | src/com/android/camera/ui/RightAlignedHorizontalScrollView.java | 44 | ||||
-rw-r--r-- | src/com/android/camera/ui/SecondLevelIndicatorControlBar.java | 60 | ||||
-rw-r--r-- | src/com/android/camera/ui/SharePopup.java | 17 | ||||
-rw-r--r-- | src/com/android/camera/ui/ZoomControlBar.java | 52 |
11 files changed, 266 insertions, 111 deletions
diff --git a/src/com/android/camera/ActivityBase.java b/src/com/android/camera/ActivityBase.java index 711ed8e..ea523c8 100644 --- a/src/com/android/camera/ActivityBase.java +++ b/src/com/android/camera/ActivityBase.java @@ -44,6 +44,8 @@ abstract public class ActivityBase extends Activity { public void onCreate(Bundle icicle) { if (Util.isTabletUI()) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } super.onCreate(icicle); setVolumeControlStream(AudioManager.STREAM_MUSIC); diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index f78d51f..1bd759b 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -33,6 +33,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences.Editor; +import android.content.pm.ActivityInfo; import android.graphics.Bitmap; import android.hardware.Camera.CameraInfo; import android.hardware.Camera.Face; @@ -823,7 +824,11 @@ public class Camera extends ActivityBase implements FocusManager.Listener, r.width = width; r.height = height; r.dateTaken = System.currentTimeMillis(); - r.previewWidth = mPreviewFrameLayout.getWidth(); + if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { + r.previewWidth = mPreviewFrameLayout.getHeight(); + } else { + r.previewWidth = mPreviewFrameLayout.getWidth(); + } synchronized (this) { while (mQueue.size() >= QUEUE_LIMIT) { try { diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index 81859ec..ab220de 100755 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -30,15 +30,18 @@ import com.android.camera.SoundPlayer; import com.android.camera.Storage; import com.android.camera.Thumbnail; import com.android.camera.Util; +import com.android.camera.ui.Rotatable; import com.android.camera.ui.RotateImageView; +import com.android.camera.ui.RotateLayout; import com.android.camera.ui.SharePopup; -import android.app.AlertDialog; +import android.app.Dialog; import android.app.ProgressDialog; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.res.AssetFileDescriptor; +import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -60,18 +63,23 @@ import android.os.ParcelFileDescriptor; import android.os.SystemProperties; import android.util.Log; import android.view.Gravity; +import android.view.LayoutInflater; import android.view.Menu; import android.view.OrientationEventListener; import android.view.View; +import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.widget.Button; import android.widget.ImageView; +import android.widget.ProgressBar; import android.widget.TextView; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.File; import java.util.List; +import java.util.Vector; /** * Activity to handle panorama capturing. @@ -112,7 +120,7 @@ public class PanoramaActivity extends ActivityBase implements private View mCaptureLayout; private View mReviewLayout; private ImageView mReview; - private TextView mCaptureIndicator; + private RotateLayout mCaptureIndicator; private PanoProgressBar mPanoProgressBar; private PanoProgressBar mSavingProgressBar; private View mFastIndicationBorder; @@ -123,11 +131,19 @@ public class PanoramaActivity extends ActivityBase implements private ShutterButton mShutterButton; private Object mWaitObject = new Object(); + private RotateLayout mRotateDialog; + private View mRotateDialogTitleLayout; + private View mRotateDialogButtonLayout; + private TextView mRotateDialogTitle; + private View mRotateDialogTitleSeperator; + private ProgressBar mRotateDialogSpinner; + private TextView mRotateDialogText; + private TextView mRotateDialogButton; + private String mPreparePreviewString; - private AlertDialog mAlertDialog; - private ProgressDialog mProgressDialog; private String mDialogTitle; - private String mDialogOk; + private String mDialogOkString; + private String mDialogPanoramaFailedString; private int mIndicatorColor; private int mIndicatorColorFast; @@ -272,7 +288,9 @@ public class PanoramaActivity extends ActivityBase implements mPreparePreviewString = getResources().getString(R.string.pano_dialog_prepare_preview); mDialogTitle = getResources().getString(R.string.pano_dialog_title); - mDialogOk = getResources().getString(R.string.dialog_ok); + mDialogOkString = getResources().getString(R.string.dialog_ok); + mDialogPanoramaFailedString = + getResources().getString(R.string.pano_dialog_panorama_failed); mMainHandler = new Handler() { @Override @@ -298,7 +316,8 @@ public class PanoramaActivity extends ActivityBase implements if (mPausing) { resetToPreview(); } else { - mAlertDialog.show(); + showAlertDialog( + mDialogTitle, mDialogPanoramaFailedString, mDialogOkString); } break; case MSG_RESET_TO_PREVIEW: @@ -313,20 +332,12 @@ public class PanoramaActivity extends ActivityBase implements clearMosaicFrameProcessorIfNeeded(); } }; + } - mAlertDialog = (new AlertDialog.Builder(this)) - .setTitle(mDialogTitle) - .setMessage(R.string.pano_dialog_panorama_failed) - .create(); - mAlertDialog.setCancelable(false); - mAlertDialog.setButton(DialogInterface.BUTTON_POSITIVE, mDialogOk, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - resetToPreview(); - } - }); + @OnClickAttr + public void onAlertDialogButtonClicked(View v) { + dismissDialog(); + resetToPreview(); } private void setupCamera() { @@ -593,7 +604,7 @@ public class PanoramaActivity extends ActivityBase implements mSurfaceTexture.setOnFrameAvailableListener(null); if (!aborted && !mThreadRunning) { - showDialog(mPreparePreviewString); + showWaitingDialog(mPreparePreviewString); runBackgroundThread(new Thread() { @Override public void run() { @@ -684,7 +695,7 @@ public class PanoramaActivity extends ActivityBase implements mSavingProgressBar.setBackgroundColor(appRes.getColor(R.color.pano_progress_empty)); mSavingProgressBar.setDoneColor(appRes.getColor(R.color.pano_progress_indication)); - mCaptureIndicator = (TextView) findViewById(R.id.pano_capture_indicator); + mCaptureIndicator = (RotateLayout) findViewById(R.id.pano_capture_indicator); mThumbnailView = (RotateImageView) findViewById(R.id.thumbnail); mThumbnailView.enableFilter(false); @@ -704,6 +715,29 @@ public class PanoramaActivity extends ActivityBase implements mShutterButton.setOnShutterButtonListener(this); mPanoLayout = findViewById(R.id.pano_layout); + + mRotateDialog = (RotateLayout) findViewById(R.id.rotate_dialog_layout); + mRotateDialogTitleLayout = findViewById(R.id.rotate_dialog_title_layout); + mRotateDialogButtonLayout = findViewById(R.id.rotate_dialog_button_layout); + mRotateDialogTitle = (TextView) findViewById(R.id.rotate_dialog_title); + mRotateDialogTitleSeperator = (View) findViewById(R.id.rotate_dialog_title_divider); + mRotateDialogSpinner = (ProgressBar) findViewById(R.id.rotate_dialog_spinner); + mRotateDialogText = (TextView) findViewById(R.id.rotate_dialog_text); + mRotateDialogButton = (Button) findViewById(R.id.rotate_dialog_button); + + if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { + Rotatable[] rotateLayout = { + (Rotatable) findViewById(R.id.pano_pan_progress_bar_layout), + (Rotatable) findViewById(R.id.pano_capture_too_fast_textview_layout), + (Rotatable) findViewById(R.id.pano_review_saving_indication_layout), + (Rotatable) findViewById(R.id.pano_saving_progress_bar_layout), + (Rotatable) findViewById(R.id.pano_review_cancel_button_layout), + (Rotatable) mRotateDialog, + (Rotatable) mCaptureIndicator}; + for (Rotatable r : rotateLayout) { + r.setOrientation(270); + } + } } @Override @@ -811,10 +845,39 @@ public class PanoramaActivity extends ActivityBase implements reportProgress(); } - private void showDialog(String str) { - mProgressDialog = new ProgressDialog(this); - mProgressDialog.setMessage(str); - mProgressDialog.show(); + private void resetRotateDialog() { + mRotateDialogTitleLayout.setVisibility(View.GONE); + mRotateDialogSpinner.setVisibility(View.GONE); + mRotateDialogButtonLayout.setVisibility(View.GONE); + } + + private void dismissDialog() { + if (mRotateDialog.getVisibility() != View.INVISIBLE) { + mRotateDialog.setVisibility(View.INVISIBLE); + } + } + + private void showAlertDialog(String title, String msg, String buttonText) { + resetRotateDialog(); + + mRotateDialogTitle.setText(title); + mRotateDialogTitleLayout.setVisibility(View.VISIBLE); + + mRotateDialogText.setText(msg); + + mRotateDialogButton.setText(buttonText); + mRotateDialogButtonLayout.setVisibility(View.VISIBLE); + + mRotateDialog.setVisibility(View.VISIBLE); + } + + private void showWaitingDialog(String msg) { + resetRotateDialog(); + + mRotateDialogText.setText(msg); + mRotateDialogSpinner.setVisibility(View.VISIBLE); + + mRotateDialog.setVisibility(View.VISIBLE); } private void runBackgroundThread(Thread thread) { @@ -824,10 +887,7 @@ public class PanoramaActivity extends ActivityBase implements private void onBackgroundThreadFinished() { mThreadRunning = false; - if (mProgressDialog != null) { - mProgressDialog.dismiss(); - mProgressDialog = null; - } + dismissDialog(); } private void cancelHighResComputation() { 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 |