diff options
author | ztenghui <ztenghui@google.com> | 2013-08-13 13:53:16 -0700 |
---|---|---|
committer | ztenghui <ztenghui@google.com> | 2013-08-13 15:53:19 -0700 |
commit | 0353ca2e048543bd6e233b4c2110a1df1070cd3f (patch) | |
tree | df9fbb875b079289ca16cf359ff4ffc237bcfc0f | |
parent | 6d8bb2792391182cf75783acaff5acb1c38d9be4 (diff) | |
download | android_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
-rw-r--r-- | res/menu/operations.xml | 67 | ||||
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 126 |
2 files changed, 193 insertions, 0 deletions
diff --git a/res/menu/operations.xml b/res/menu/operations.xml new file mode 100644 index 000000000..bcebbb47b --- /dev/null +++ b/res/menu/operations.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013 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. +--> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/action_share" + android:icon="@drawable/ic_menu_share_holo_light" + android:title="@string/share" + android:visible="false" + android:actionProviderClass="android.widget.ShareActionProvider" + android:showAsAction="ifRoom"> + </item> + <item android:id="@+id/action_delete" + android:icon="@drawable/ic_menu_trash_holo_light" + android:title="@string/delete" + android:visible="false" + android:showAsAction="never" /> + <item android:id="@+id/action_edit" + android:title="@string/edit" + android:showAsAction="never" + android:visible="false" /> + <item android:id="@+id/action_trim" + android:title="@string/trim_action" + android:showAsAction="never" + android:visible="false" /> + <item android:id="@+id/action_mute" + android:title="@string/mute_action" + android:showAsAction="never" + android:visible="false" /> + <item android:id="@+id/action_rotate_ccw" + android:showAsAction="never" + android:visible="false" + android:title="@string/rotate_left" /> + <item android:id="@+id/action_rotate_cw" + android:showAsAction="never" + android:visible="false" + android:title="@string/rotate_right" /> + <item android:id="@+id/action_crop" + android:title="@string/crop_action" + android:showAsAction="never" + android:visible="false" /> + <item android:id="@+id/action_setas" + android:title="@string/set_image" + android:showAsAction="never" + android:visible="false" /> + <item android:id="@+id/action_details" + android:icon="@drawable/ic_menu_info_details" + android:title="@string/details" + android:visible="false" + android:showAsAction="never" /> + <item android:id="@+id/action_show_on_map" + android:title="@string/show_on_map" + android:showAsAction="never" + android:visible="false" /> +</menu> 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); |