diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-03-12 16:37:35 -0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2010-03-15 20:23:37 -0700 |
commit | 9ae7d027bb8f55b85a158cddeb7ed84c5a0a7983 (patch) | |
tree | 908e50db88918b0a49231e37a5e21f601fd9d8f8 /src | |
parent | ee1cf3f0509987e9c76626077bd8117399311ced (diff) | |
download | LegacyCamera-9ae7d027bb8f55b85a158cddeb7ed84c5a0a7983.zip LegacyCamera-9ae7d027bb8f55b85a158cddeb7ed84c5a0a7983.tar.gz LegacyCamera-9ae7d027bb8f55b85a158cddeb7ed84c5a0a7983.tar.bz2 |
Add switch to Camera/VideoCamera menu item.
Bug: 2249997
Change-Id: I14434fb5c617a62e02eaace120157c4a9d32e681
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 21 | ||||
-rw-r--r-- | src/com/android/camera/MenuHelper.java | 22 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 21 |
3 files changed, 54 insertions, 10 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 311f56d..77ed9c7 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -2021,6 +2021,11 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, } private void addBaseMenuItems(Menu menu) { + MenuHelper.addSwitchModeMenuItem(menu, true, new Runnable() { + public void run() { + switchToVideoMode(); + } + }); MenuItem gallery = menu.add(Menu.NONE, Menu.NONE, MenuHelper.POSITION_GOTO_GALLERY, R.string.camera_gallery_photos_text) @@ -2034,14 +2039,20 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, mGalleryItems.add(gallery); } + private boolean switchToVideoMode() { + if (!isCameraIdle()) return false; + MenuHelper.gotoVideoMode(this); + ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); + finish(); + return true; + } + public boolean onSwitchChanged(Switcher source, boolean onOff) { if (onOff == SWITCH_VIDEO) { - if (!isCameraIdle()) return false; - MenuHelper.gotoVideoMode(this); - ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); - finish(); + return switchToVideoMode(); + } else { + return true; } - return true; } private void onSharedPreferenceChanged() { diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java index 65b8272..1c8f0fa 100644 --- a/src/com/android/camera/MenuHelper.java +++ b/src/com/android/camera/MenuHelper.java @@ -29,6 +29,9 @@ import android.os.StatFs; import android.provider.MediaStore; import android.provider.MediaStore.Images; import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MenuItem.OnMenuItemClickListener; import com.android.camera.R; @@ -113,6 +116,25 @@ public class MenuHelper { .show(); } + static void addSwitchModeMenuItem(Menu menu, boolean switchToVideo, + final Runnable r) { + int labelId = switchToVideo + ? R.string.switch_to_video_lable + : R.string.switch_to_camera_lable; + int iconId = switchToVideo + ? R.drawable.ic_menu_camera_video_view + : android.R.drawable.ic_menu_camera; + MenuItem item = menu.add(Menu.NONE, Menu.NONE, + POSITION_SWITCH_CAMERA_MODE, labelId) + .setOnMenuItemClickListener(new OnMenuItemClickListener() { + public boolean onMenuItemClick(MenuItem item) { + r.run(); + return true; + } + }); + item.setIcon(iconId); + } + private static void startCameraActivity(Activity activity, String action) { Intent intent = new Intent(action); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 82e2ae0..ee62825 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -1009,6 +1009,11 @@ public class VideoCamera extends NoSearchActivity } private void addBaseMenuItems(Menu menu) { + MenuHelper.addSwitchModeMenuItem(menu, false, new Runnable() { + public void run() { + switchToCameraMode(); + } + }); MenuItem gallery = menu.add(Menu.NONE, Menu.NONE, MenuHelper.POSITION_GOTO_GALLERY, R.string.camera_gallery_photos_text) @@ -1378,14 +1383,20 @@ public class VideoCamera extends NoSearchActivity mCameraDevice.setParameters(mParameters); } + private boolean switchToCameraMode() { + if (mMediaRecorderRecording) return false; + MenuHelper.gotoCameraMode(this); + ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); + finish(); + return true; + } + public boolean onSwitchChanged(Switcher source, boolean onOff) { if (onOff == SWITCH_CAMERA) { - if (mMediaRecorderRecording) return false; - MenuHelper.gotoCameraMode(this); - ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); - finish(); + return switchToCameraMode(); + } else { + return true; } - return true; } private void resetCameraParameters() { |