summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-08-13 13:53:16 -0700
committerztenghui <ztenghui@google.com>2013-08-13 15:53:19 -0700
commit0353ca2e048543bd6e233b4c2110a1df1070cd3f (patch)
treedf9fbb875b079289ca16cf359ff4ffc237bcfc0f /src
parent6d8bb2792391182cf75783acaff5acb1c38d9be4 (diff)
downloadandroid_packages_apps_Snap-0353ca2e048543bd6e233b4c2110a1df1070cd3f.tar.gz
android_packages_apps_Snap-0353ca2e048543bd6e233b4c2110a1df1070cd3f.tar.bz2
android_packages_apps_Snap-0353ca2e048543bd6e233b4c2110a1df1070cd3f.zip
Add the menu items back
bug:10245009 Change-Id: I4e11e0cd64800bd9c07158d1a46ea5765ba51d15
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/CameraActivity.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 82d10a98b..66667e12d 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -37,6 +37,9 @@ import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewGroup;
@@ -77,6 +80,19 @@ public class CameraActivity extends Activity
// panorama. If the extra is not set, it is in the normal camera mode.
public static final String SECURE_CAMERA_EXTRA = "secure_camera";
+ // Supported operations at FilmStripView. Different data has different
+ // set of supported operations.
+ private static final int SUPPORT_DELETE = 1 << 0;
+ private static final int SUPPORT_ROTATE = 1 << 1;
+ private static final int SUPPORT_INFO = 1 << 2;
+ private static final int SUPPORT_CROP = 1 << 3;
+ private static final int SUPPORT_SETAS = 1 << 4;
+ private static final int SUPPORT_EDIT = 1 << 5;
+ private static final int SUPPORT_TRIM = 1 << 6;
+ private static final int SUPPORT_MUTE = 1 << 7;
+ private static final int SUPPORT_SHOW_ON_MAP = 1 << 8;
+ private static final int SUPPORT_ALL = 0xffffffff;
+
/** This data adapter is used by FilmStirpView. */
private LocalDataAdapter mDataAdapter;
/** This data adapter represents the real local camera data. */
@@ -104,6 +120,7 @@ public class CameraActivity extends Activity
private PanoramaViewHelper mPanoramaViewHelper;
private CameraPreviewData mCameraPreviewData;
private ActionBar mActionBar;
+ private Menu mActionBarMenu;
private class MyOrientationEventListener
extends OrientationEventListener {
@@ -195,6 +212,9 @@ public class CameraActivity extends Activity
hidePanoStitchingProgress();
return;
}
+ int type = currentData.getLocalDataType(dataID);
+ updateActionBarMenu(type);
+
Uri contentUri = currentData.getContentUri();
if (contentUri == null) {
hidePanoStitchingProgress();
@@ -223,6 +243,64 @@ public class CameraActivity extends Activity
mBottomProgress.setProgress(progress);
}
+ /**
+ * According to the data type, make the menu items for supported operations
+ * visible.
+ * @param type : the data type for the current local data.
+ */
+ private void updateActionBarMenu(int type) {
+ if (mActionBarMenu == null) {
+ return;
+ }
+
+ int supported = 0;
+ switch (type) {
+ case LocalData.LOCAL_IMAGE:
+ supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
+ | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
+ | SUPPORT_SHOW_ON_MAP;
+ break;
+ case LocalData.LOCAL_VIDEO:
+ supported |= SUPPORT_DELETE | SUPPORT_INFO | SUPPORT_TRIM
+ | SUPPORT_MUTE;
+ break;
+ case LocalData.LOCAL_PHOTO_SPHERE:
+ supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
+ | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
+ | SUPPORT_SHOW_ON_MAP;
+ break;
+ default:
+ break;
+ }
+
+ setMenuItemVisible(mActionBarMenu, R.id.action_delete,
+ (supported & SUPPORT_DELETE) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_rotate_ccw,
+ (supported & SUPPORT_ROTATE) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_rotate_cw,
+ (supported & SUPPORT_ROTATE) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_crop,
+ (supported & SUPPORT_CROP) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_trim,
+ (supported & SUPPORT_TRIM) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_mute,
+ (supported & SUPPORT_MUTE) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_setas,
+ (supported & SUPPORT_SETAS) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_show_on_map,
+ (supported & SUPPORT_SHOW_ON_MAP) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_edit,
+ (supported & SUPPORT_EDIT) != 0);
+ setMenuItemVisible(mActionBarMenu, R.id.action_details,
+ (supported & SUPPORT_INFO) != 0);
+ }
+
+ private void setMenuItemVisible(Menu menu, int itemId, boolean visible) {
+ MenuItem item = menu.findItem(itemId);
+ if (item != null)
+ item.setVisible(visible);
+ }
+
private Runnable mDeletionRunnable = new Runnable() {
@Override
public void run() {
@@ -324,6 +402,54 @@ public class CameraActivity extends Activity
}
@Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu items for use in the action bar
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.operations, menu);
+ mActionBarMenu = menu;
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle presses on the action bar items
+ switch (item.getItemId()) {
+ case R.id.action_delete:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_edit:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_trim:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_mute:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_rotate_ccw:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_rotate_cw:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_crop:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_setas:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_details:
+ // TODO: add the functionality.
+ return true;
+ case R.id.action_show_on_map:
+ // TODO: add the functionality.
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.camera_filmstrip);