bug-Gallery2-menu-No1-20160818

bug描述:
1. Launch camera app;
2. Switch to record video and record a video;
3. Tap the preview button;
4. Tap the options menu---->tap edit option

视频文件是不能编辑的,而图库菜单中却可以编辑,点击编辑无任何反应。解决办法去掉编辑控件。

首先找到菜单的xml文件,在res/menu/ 下,将setting设置成英文,编辑英文叫edit,在menu下grep edit 即可。

<item android:id="@+id/action_edit"
             android:title="@string/edit"
             android:showAsAction="never"
             android:visible="false" />

接下来在源代码中grep action_edit


packages/apps/Gallery2/src/com/android/gallery3d/ui/MenuExecutor.java:194      

setMenuItemVisible(menu, R.id.action_edit, supportEdit);

case R.id.action_edit: {  .....}

注释掉代码 setMenuItemVisible(menu, R.id.action_edit, supportEdit);  发现编辑控件全没有了。

supportEdit 是在

boolean supportEdit = (supported & MediaObject.SUPPORT_EDIT) != 0;   定义的。

MediaObject.SUPPORT_EDIT 是常量。

supported  决定控件可见与不可见。

找updateMenuOperation()方法调用的地方。


在src/com/android/gallery3d/app/PhotoPage.java中

 763     private void updateMenuOperations() {
 764         Menu menu = mActionBar.getMenu();
 765 
 766         // it could be null if onCreateActionBar has not been called yet
 767         if (menu == null) return;
 768 
 769         MenuItem item = menu.findItem(R.id.action_slideshow);
 770         if (item != null) {
 771             item.setVisible((mSecureAlbum == null) && canDoSlideShow());
 772         }
 773         if (mCurrentPhoto == null) return;
 774 
 775         int supportedOperations = mCurrentPhoto.getSupportedOperations();
 776           
 777         if (mReadOnlyView) {
 778             
 779             supportedOperations ^= MediaObject.SUPPORT_EDIT;
 780             //supportedOperations &= ~MediaObject.SUPPORT_EDIT;
 781             Log.e("snmu","supportedOperations6666---is--" + supportedOperations);
 782         }
 783         if (mSecureAlbum != null) {
 784             supportedOperations &= MediaObject.SUPPORT_DELETE;
 785         } else {
 786          
 787             mCurrentPhoto.getPanoramaSupport(mUpdatePanoramaMenuItemsCallback);
 788             if (!mHaveImageEditor) {
 789        
 790                 supportedOperations &= ~MediaObject.SUPPORT_EDIT;
 791             }
 792         }
 793        
 794         MenuExecutor.updateMenuOperation(menu, supportedOperations);
 795     }

最终定位到779行

<pre name="code" class="html">if (mReadOnlyView)
supportedOperations ^= MediaObject.SUPPORT_EDIT


 if条件是只读预览时,也就是从camera点击图库预览图片时 ,走这行代码。 

问题就出在这行代码,不应该异或(会造成图片不可编辑,视频可编辑),而应该是与非。


menu控件的用法可见此博文 http://blog.csdn.net/flying_tao/article/details/6570098







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值