diff options
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r-- | src/com/android/camera/ui/CameraRootView.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/ui/LayoutChangeHelper.java | 43 | ||||
-rw-r--r-- | src/com/android/camera/ui/LayoutChangeNotifier.java | 28 | ||||
-rw-r--r-- | src/com/android/camera/ui/LayoutNotifyView.java | 48 | ||||
-rw-r--r-- | src/com/android/camera/ui/ModuleSwitcher.java (renamed from src/com/android/camera/ui/CameraSwitcher.java) | 30 |
5 files changed, 21 insertions, 132 deletions
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java index 48f24e4f2..75d08428b 100644 --- a/src/com/android/camera/ui/CameraRootView.java +++ b/src/com/android/camera/ui/CameraRootView.java @@ -77,7 +77,9 @@ public class CameraRootView extends FrameLayout { @Override public void onDisplayChanged(int arg0) { - mListener.onDisplayChanged(); + if (mListener != null) { + mListener.onDisplayChanged(); + } } @Override diff --git a/src/com/android/camera/ui/LayoutChangeHelper.java b/src/com/android/camera/ui/LayoutChangeHelper.java deleted file mode 100644 index ef4eb6a7a..000000000 --- a/src/com/android/camera/ui/LayoutChangeHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2012 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.view.View; - -public class LayoutChangeHelper implements LayoutChangeNotifier { - private LayoutChangeNotifier.Listener mListener; - private boolean mFirstTimeLayout; - private View mView; - - public LayoutChangeHelper(View v) { - mView = v; - mFirstTimeLayout = true; - } - - @Override - public void setOnLayoutChangeListener(LayoutChangeNotifier.Listener listener) { - mListener = listener; - } - - public void onLayout(boolean changed, int l, int t, int r, int b) { - if (mListener == null) return; - if (mFirstTimeLayout || changed) { - mFirstTimeLayout = false; - mListener.onLayoutChange(mView, l, t, r, b); - } - } -} diff --git a/src/com/android/camera/ui/LayoutChangeNotifier.java b/src/com/android/camera/ui/LayoutChangeNotifier.java deleted file mode 100644 index 6261d34f6..000000000 --- a/src/com/android/camera/ui/LayoutChangeNotifier.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 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.view.View; - -public interface LayoutChangeNotifier { - public interface Listener { - // Invoked only when the layout has changed or it is the first layout. - public void onLayoutChange(View v, int l, int t, int r, int b); - } - - public void setOnLayoutChangeListener(LayoutChangeNotifier.Listener listener); -} diff --git a/src/com/android/camera/ui/LayoutNotifyView.java b/src/com/android/camera/ui/LayoutNotifyView.java deleted file mode 100644 index 6e118fc3a..000000000 --- a/src/com/android/camera/ui/LayoutNotifyView.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 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.util.AttributeSet; -import android.view.View; - -/* - * Customized view to support onLayoutChange() at or before API 10. - */ -public class LayoutNotifyView extends View implements LayoutChangeNotifier { - private LayoutChangeHelper mLayoutChangeHelper = new LayoutChangeHelper(this); - - public LayoutNotifyView(Context context) { - super(context); - } - - public LayoutNotifyView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public void setOnLayoutChangeListener( - LayoutChangeNotifier.Listener listener) { - mLayoutChangeHelper.setOnLayoutChangeListener(listener); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - mLayoutChangeHelper.onLayout(changed, l, t, r, b); - } -} diff --git a/src/com/android/camera/ui/CameraSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java index aaa9cdac8..5eb316c7f 100644 --- a/src/com/android/camera/ui/CameraSwitcher.java +++ b/src/com/android/camera/ui/ModuleSwitcher.java @@ -34,13 +34,13 @@ import android.view.ViewGroup; import android.widget.FrameLayout.LayoutParams; import android.widget.LinearLayout; +import com.android.camera.util.ApiHelper; import com.android.camera.util.CameraUtil; import com.android.camera.util.PhotoSphereHelper; import com.android.camera.util.UsageStatistics; import com.android.camera2.R; -import com.android.camera.util.ApiHelper; -public class CameraSwitcher extends RotateImageView +public class ModuleSwitcher extends RotateImageView implements OnClickListener, OnTouchListener { @SuppressWarnings("unused") @@ -49,20 +49,22 @@ public class CameraSwitcher extends RotateImageView public static final int PHOTO_MODULE_INDEX = 0; public static final int VIDEO_MODULE_INDEX = 1; - public static final int LIGHTCYCLE_MODULE_INDEX = 2; + public static final int WIDE_ANGLE_PANO_MODULE_INDEX = 2; + public static final int LIGHTCYCLE_MODULE_INDEX = 3; private static final int[] DRAW_IDS = { R.drawable.ic_switch_camera, R.drawable.ic_switch_video, + R.drawable.ic_switch_pan, R.drawable.ic_switch_photosphere, }; - public interface CameraSwitchListener { - public void onCameraSelected(int i); + public interface ModuleSwitchListener { + public void onModuleSelected(int i); public void onShowSwitcherPopup(); } - private CameraSwitchListener mListener; + private ModuleSwitchListener mListener; private int mCurrentIndex; private int[] mModuleIds; private int[] mDrawIds; @@ -79,12 +81,12 @@ public class CameraSwitcher extends RotateImageView private AnimatorListener mHideAnimationListener; private AnimatorListener mShowAnimationListener; - public CameraSwitcher(Context context) { + public ModuleSwitcher(Context context) { super(context); init(context); } - public CameraSwitcher(Context context, AttributeSet attrs) { + public ModuleSwitcher(Context context, AttributeSet attrs) { super(context, attrs); init(context); } @@ -126,7 +128,7 @@ public class CameraSwitcher extends RotateImageView setImageResource(mDrawIds[i]); } - public void setSwitchListener(CameraSwitchListener l) { + public void setSwitchListener(ModuleSwitchListener l) { mListener = l; } @@ -136,14 +138,14 @@ public class CameraSwitcher extends RotateImageView mListener.onShowSwitcherPopup(); } - private void onCameraSelected(int ix) { + private void onModuleSelected(int ix) { hidePopup(); if ((ix != mCurrentIndex) && (mListener != null)) { UsageStatistics.onEvent("CameraModeSwitch", null, null); UsageStatistics.setPendingTransitionCause( UsageStatistics.TRANSITION_MENU_TAP); setCurrentIndex(ix); - mListener.onCameraSelected(mModuleIds[ix]); + mListener.onModuleSelected(mModuleIds[ix]); } } @@ -178,7 +180,7 @@ public class CameraSwitcher extends RotateImageView @Override public void onClick(View v) { if (showsPopup()) { - onCameraSelected(index); + onModuleSelected(index); } } }); @@ -191,6 +193,10 @@ public class CameraSwitcher extends RotateImageView item.setContentDescription(getContext().getResources().getString( R.string.accessibility_switch_to_video)); break; + case R.drawable.ic_switch_pan: + item.setContentDescription(getContext().getResources().getString( + R.string.accessibility_switch_to_panorama)); + break; case R.drawable.ic_switch_photosphere: item.setContentDescription(getContext().getResources().getString( R.string.accessibility_switch_to_photo_sphere)); |