summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2009-09-08 13:32:52 +0800
committerChih-Chung Chang <chihchung@google.com>2009-09-08 14:24:14 +0800
commitd189083d760820ad0b0d88e11feb897e4ab5011c (patch)
treed5147a016dc0ce06620fc3f59310eff33ec79e87 /src/com/android/camera
parentcc5a6356055dd8a8a4017b0af5410b53f25aaef0 (diff)
downloadLegacyCamera-d189083d760820ad0b0d88e11feb897e4ab5011c.zip
LegacyCamera-d189083d760820ad0b0d88e11feb897e4ab5011c.tar.gz
LegacyCamera-d189083d760820ad0b0d88e11feb897e4ab5011c.tar.bz2
Clean menu creation code.
Change-Id: Ie8ed04e74beef78208946688ee2f33297de0b6d1
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/Camera.java22
-rw-r--r--src/com/android/camera/GalleryPicker.java7
-rw-r--r--src/com/android/camera/ImageGallery.java20
-rw-r--r--src/com/android/camera/MenuHelper.java82
-rw-r--r--src/com/android/camera/VideoCamera.java17
-rw-r--r--src/com/android/camera/ViewImage.java9
6 files changed, 76 insertions, 81 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 1e89d4c..0c7dfde 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -96,22 +96,6 @@ public class Camera extends Activity implements View.OnClickListener,
private static final int SCREEN_DELAY = 2 * 60 * 1000;
private static final int FOCUS_BEEP_VOLUME = 100;
- public static final int MENU_SWITCH_TO_VIDEO = 0;
- public static final int MENU_SWITCH_TO_CAMERA = 1;
- public static final int MENU_FLASH_SETTING = 2;
- public static final int MENU_FLASH_AUTO = 3;
- public static final int MENU_FLASH_ON = 4;
- public static final int MENU_FLASH_OFF = 5;
- public static final int MENU_SETTINGS = 6;
- public static final int MENU_GALLERY_PHOTOS = 7;
- public static final int MENU_GALLERY_VIDEOS = 8;
- public static final int MENU_SAVE_SELECT_PHOTOS = 30;
- public static final int MENU_SAVE_NEW_PHOTO = 31;
- public static final int MENU_SAVE_GALLERY_PHOTO = 34;
- public static final int MENU_SAVE_GALLERY_VIDEO_PHOTO = 35;
- public static final int MENU_SAVE_CAMERA_DONE = 36;
- public static final int MENU_SAVE_CAMERA_VIDEO_DONE = 37;
-
private double mZoomValue; // The current zoom value.
private boolean mZooming = false;
private double mZoomStep;
@@ -1718,7 +1702,8 @@ public class Camera extends Activity implements View.OnClickListener,
private void addBaseMenuItems(Menu menu) {
MenuHelper.addSwitchModeMenuItem(menu, this, true);
- MenuItem gallery = menu.add(0, MENU_GALLERY_PHOTOS, 0,
+ MenuItem gallery = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_GOTO_GALLERY,
R.string.camera_gallery_photos_text)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -1729,7 +1714,8 @@ public class Camera extends Activity implements View.OnClickListener,
gallery.setIcon(android.R.drawable.ic_menu_gallery);
mGalleryItems.add(gallery);
- MenuItem item = menu.add(0, MENU_SETTINGS, 0, R.string.settings)
+ MenuItem item = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_CAMERA_SETTING, R.string.settings)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
if (mSettings == null) {
diff --git a/src/com/android/camera/GalleryPicker.java b/src/com/android/camera/GalleryPicker.java
index b0f8531..7c063d3 100644
--- a/src/com/android/camera/GalleryPicker.java
+++ b/src/com/android/camera/GalleryPicker.java
@@ -203,7 +203,7 @@ public class GalleryPicker extends Activity {
// "Slide Show"
if ((mAdapter.getIncludeMediaTypes(position)
& ImageManager.INCLUDE_IMAGES) != 0) {
- menu.add(0, 207, 0, R.string.slide_show)
+ menu.add(R.string.slide_show)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onSlideShowClicked(menuInfo);
@@ -211,7 +211,7 @@ public class GalleryPicker extends Activity {
});
}
// "View"
- menu.add(0, 208, 0, R.string.view)
+ menu.add(R.string.view)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onViewClicked(menuInfo);
@@ -732,7 +732,8 @@ public class GalleryPicker extends Activity {
MenuHelper.addCaptureMenuItems(menu, this);
- menu.add(0, 0, 5, R.string.camerasettings)
+ menu.add(Menu.NONE, Menu.NONE, MenuHelper.POSITION_GALLERY_SETTING,
+ R.string.camerasettings)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Intent preferences = new Intent();
diff --git a/src/com/android/camera/ImageGallery.java b/src/com/android/camera/ImageGallery.java
index 332db2a..26456ae 100644
--- a/src/com/android/camera/ImageGallery.java
+++ b/src/com/android/camera/ImageGallery.java
@@ -163,8 +163,9 @@ public class ImageGallery extends Activity implements
});
}
- private MenuItem addSlideShowMenu(Menu menu, int position) {
- return menu.add(0, 207, position, R.string.slide_show)
+ private MenuItem addSlideShowMenu(Menu menu) {
+ return menu.add(Menu.NONE, Menu.NONE, MenuHelper.POSITION_SLIDESHOW,
+ R.string.slide_show)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -498,10 +499,12 @@ public class ImageGallery extends Activity implements
} else {
MenuHelper.addCaptureMenuItems(menu, this);
if ((mInclusion & ImageManager.INCLUDE_IMAGES) != 0) {
- mSlideShowItem = addSlideShowMenu(menu, 5);
+ mSlideShowItem = addSlideShowMenu(menu);
}
- MenuItem item = menu.add(0, 0, 1000, R.string.camerasettings);
+ MenuItem item = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_GALLERY_SETTING,
+ R.string.camerasettings);
item.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -515,7 +518,9 @@ public class ImageGallery extends Activity implements
item.setAlphabeticShortcut('p');
item.setIcon(android.R.drawable.ic_menu_preferences);
- item = menu.add(0, 0, 900, R.string.multiselect);
+ item = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_MULTISELECT,
+ R.string.multiselect);
item.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -773,7 +778,8 @@ public class ImageGallery extends Activity implements
boolean isImage = ImageManager.isImage(image);
if (isImage) {
- menu.add(0, 0, 0, R.string.view).setOnMenuItemClickListener(
+ menu.add(R.string.view)
+ .setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
if (!canHandleEvent()) return false;
@@ -811,7 +817,7 @@ public class ImageGallery extends Activity implements
if (isImage) {
MenuHelper.enableShowOnMapMenuItem(
menu, MenuHelper.hasLatLngData(image));
- addSlideShowMenu(menu, 1000);
+ addSlideShowMenu(menu);
}
}
}
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index c3cf5a0..429bd61 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -70,20 +70,25 @@ public class MenuHelper {
public static final int INCLUDE_DETAILS_MENU = (1 << 6);
public static final int INCLUDE_SHOWMAP_MENU = (1 << 7);
- public static final int MENU_SWITCH_CAMERA_MODE = 0;
- public static final int MENU_CAPTURE_PICTURE = 1;
- public static final int MENU_CAPTURE_VIDEO = 2;
- public static final int MENU_IMAGE_SHARE = 3;
- public static final int MENU_IMAGE_SET = 4;
- public static final int MENU_IMAGE_SET_WALLPAPER = 5;
- public static final int MENU_IMAGE_CROP = 6;
- public static final int MENU_IMAGE_ROTATE = 7;
- public static final int MENU_IMAGE_ROTATE_LEFT = 8;
- public static final int MENU_IMAGE_ROTATE_RIGHT = 9;
- public static final int MENU_IMAGE_TOSS = 10;
- public static final int MENU_IMAGE_SHOWMAP = 11;
- public static final int MENU_VIDEO_PLAY = 12;
- public static final int MENU_VIDEO_SHARE = 13;
+ public static final int MENU_IMAGE_SHARE = 1;
+ public static final int MENU_IMAGE_SHOWMAP = 2;
+
+ public static final int POSITION_SWITCH_CAMERA_MODE = 1;
+ public static final int POSITION_GOTO_GALLERY = 2;
+ public static final int POSITION_VIEWPLAY = 3;
+ public static final int POSITION_CAPTURE_PICTURE = 4;
+ public static final int POSITION_CAPTURE_VIDEO = 5;
+ public static final int POSITION_IMAGE_SHARE = 6;
+ public static final int POSITION_IMAGE_ROTATE = 7;
+ public static final int POSITION_IMAGE_TOSS = 8;
+ public static final int POSITION_IMAGE_CROP = 9;
+ public static final int POSITION_IMAGE_SET = 10;
+ public static final int POSITION_DETAILS = 11;
+ public static final int POSITION_SHOWMAP = 12;
+ public static final int POSITION_SLIDESHOW = 13;
+ public static final int POSITION_MULTISELECT = 14;
+ public static final int POSITION_CAMERA_SETTING = 15;
+ public static final int POSITION_GALLERY_SETTING = 16;
public static final int NO_STORAGE_ERROR = -1;
public static final int CANNOT_STAT_ERROR = -2;
@@ -168,7 +173,7 @@ public class MenuHelper {
public static boolean hasLatLngData(IImage image) {
return ExifInterface.getLatLng(getExifData(image)) != null;
}
-
+
public static void enableShowOnMapMenuItem(Menu menu, boolean enabled) {
MenuItem item = menu.findItem(MENU_IMAGE_SHOWMAP);
if (item != null) {
@@ -654,15 +659,14 @@ public class MenuHelper {
new ArrayList<MenuItem>();
if ((inclusions & INCLUDE_ROTATE_MENU) != 0) {
- SubMenu rotateSubmenu = menu.addSubMenu(0, MENU_IMAGE_ROTATE, 40,
- R.string.rotate)
+ SubMenu rotateSubmenu = menu.addSubMenu(Menu.NONE, Menu.NONE,
+ POSITION_IMAGE_ROTATE, R.string.rotate)
.setIcon(android.R.drawable.ic_menu_rotate);
// Don't show the rotate submenu if the item at hand is read only
// since the items within the submenu won't be shown anyway. This
// is really a framework bug in that it shouldn't show the submenu
// if the submenu has no visible items.
- MenuItem rotateLeft = rotateSubmenu.add(0, MENU_IMAGE_ROTATE_LEFT,
- 50, R.string.rotate_left)
+ MenuItem rotateLeft = rotateSubmenu.add(R.string.rotate_left)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -670,8 +674,7 @@ public class MenuHelper {
}
}).setAlphabeticShortcut('l');
- MenuItem rotateRight = rotateSubmenu.add(0, MENU_IMAGE_ROTATE_RIGHT,
- 60, R.string.rotate_right)
+ MenuItem rotateRight = rotateSubmenu.add(R.string.rotate_right)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -689,8 +692,8 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_CROP_MENU) != 0) {
- MenuItem autoCrop = menu.add(0, MENU_IMAGE_CROP, 73,
- R.string.camera_crop);
+ MenuItem autoCrop = menu.add(Menu.NONE, Menu.NONE,
+ POSITION_IMAGE_CROP, R.string.camera_crop);
autoCrop.setIcon(android.R.drawable.ic_menu_crop);
autoCrop.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@@ -703,8 +706,8 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_SET_MENU) != 0) {
- MenuItem setMenu = menu.add(0, MENU_IMAGE_SET, 75,
- R.string.camera_set);
+ MenuItem setMenu = menu.add(Menu.NONE, Menu.NONE,
+ POSITION_IMAGE_SET, R.string.camera_set);
setMenu.setIcon(android.R.drawable.ic_menu_set_as);
setMenu.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@@ -716,8 +719,9 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_SHARE_MENU) != 0) {
- MenuItem item1 = menu.add(0, MENU_IMAGE_SHARE, 10,
- R.string.camera_share).setOnMenuItemClickListener(
+ MenuItem item1 = menu.add(Menu.NONE, MENU_IMAGE_SHARE,
+ POSITION_IMAGE_SHARE, R.string.camera_share)
+ .setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onImageShareClicked(onInvoke, activity);
@@ -729,8 +733,8 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_DELETE_MENU) != 0) {
- MenuItem deleteItem = menu.add(0, MENU_IMAGE_TOSS,
- 70, R.string.camera_toss);
+ MenuItem deleteItem = menu.add(Menu.NONE, Menu.NONE,
+ POSITION_IMAGE_TOSS, R.string.camera_toss);
requiresWriteAccessItems.add(deleteItem);
deleteItem.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@@ -744,7 +748,8 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_DETAILS_MENU) != 0) {
- MenuItem detailsMenu = menu.add(0, 0, 80, R.string.details)
+ MenuItem detailsMenu = menu.add(Menu.NONE, Menu.NONE,
+ POSITION_DETAILS, R.string.details)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
return onDetailsClicked(onInvoke, handler, activity);
@@ -754,8 +759,8 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_SHOWMAP_MENU) != 0) {
- MenuItem showOnMapItem = menu.add(0, MENU_IMAGE_SHOWMAP,
- 80, R.string.show_on_map);
+ MenuItem showOnMapItem = menu.add(Menu.NONE, MENU_IMAGE_SHOWMAP,
+ POSITION_SHOWMAP, R.string.show_on_map);
showOnMapItem.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -767,8 +772,8 @@ public class MenuHelper {
}
if ((inclusions & INCLUDE_VIEWPLAY_MENU) != 0) {
- MenuItem videoPlayItem = menu.add(0, MENU_VIDEO_PLAY, 0,
- R.string.video_play)
+ MenuItem videoPlayItem = menu.add(Menu.NONE, Menu.NONE,
+ POSITION_VIEWPLAY, R.string.video_play)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -896,7 +901,8 @@ public class MenuHelper {
final String action = switchToVideo
? MediaStore.INTENT_ACTION_VIDEO_CAMERA
: MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA;
- MenuItem item = menu.add(0, MENU_SWITCH_CAMERA_MODE, 0, labelId)
+ MenuItem item = menu.add(Menu.NONE, Menu.NONE,
+ POSITION_SWITCH_CAMERA_MODE, labelId)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
startCameraActivity(activity, action);
@@ -955,7 +961,8 @@ public class MenuHelper {
}
static void addCapturePictureMenuItems(Menu menu, final Activity activity) {
- menu.add(0, MENU_CAPTURE_PICTURE, 1, R.string.capture_picture)
+ menu.add(Menu.NONE, Menu.NONE, POSITION_CAPTURE_PICTURE,
+ R.string.capture_picture)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -976,7 +983,8 @@ public class MenuHelper {
}
static void addCaptureVideoMenuItems(Menu menu, final Activity activity) {
- menu.add(0, MENU_CAPTURE_VIDEO, 2, R.string.capture_video)
+ menu.add(Menu.NONE, Menu.NONE, POSITION_CAPTURE_VIDEO,
+ R.string.capture_video)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index f9ec08a..93cad4a 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -96,14 +96,6 @@ public class VideoCamera extends Activity implements View.OnClickListener,
private static final boolean SWITCH_CAMERA = true;
private static final boolean SWITCH_VIDEO = false;
- public static final int MENU_SETTINGS = 6;
- public static final int MENU_GALLERY_PHOTOS = 7;
- public static final int MENU_GALLERY_VIDEOS = 8;
- public static final int MENU_SAVE_GALLERY_PHOTO = 34;
- public static final int MENU_SAVE_PLAY_VIDEO = 35;
- public static final int MENU_SAVE_SELECT_VIDEO = 36;
- public static final int MENU_SAVE_NEW_VIDEO = 37;
-
private SharedPreferences mPreferences;
private VideoPreview mVideoPreview;
@@ -1005,8 +997,8 @@ public class VideoCamera extends Activity implements View.OnClickListener,
private void addBaseMenuItems(Menu menu) {
MenuHelper.addSwitchModeMenuItem(menu, this, false);
- MenuItem gallery =
- menu.add(0, MENU_GALLERY_VIDEOS, 0,
+ MenuItem gallery = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_GOTO_GALLERY,
R.string.camera_gallery_photos_text)
.setOnMenuItemClickListener(
new OnMenuItemClickListener() {
@@ -1018,8 +1010,9 @@ public class VideoCamera extends Activity implements View.OnClickListener,
gallery.setIcon(android.R.drawable.ic_menu_gallery);
mGalleryItems.add(gallery);
- MenuItem item =
- menu.add(0, MENU_SETTINGS, 0, R.string.settings)
+ MenuItem item = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_CAMERA_SETTING,
+ R.string.settings)
.setOnMenuItemClickListener(
new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
diff --git a/src/com/android/camera/ViewImage.java b/src/com/android/camera/ViewImage.java
index c5d7881..fe5bf05 100644
--- a/src/com/android/camera/ViewImage.java
+++ b/src/com/android/camera/ViewImage.java
@@ -339,8 +339,9 @@ public class ViewImage extends Activity implements View.OnClickListener {
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
- MenuItem item = menu.add(Menu.CATEGORY_SECONDARY, 203, 0,
- R.string.slide_show);
+ MenuItem item = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_SLIDESHOW,
+ R.string.slide_show);
item.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
@@ -372,8 +373,8 @@ public class ViewImage extends Activity implements View.OnClickListener {
}
});
- item = menu.add(Menu.CATEGORY_SECONDARY, 203, 1000,
- R.string.camerasettings);
+ item = menu.add(Menu.NONE, Menu.NONE,
+ MenuHelper.POSITION_GALLERY_SETTING, R.string.camerasettings);
item.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {