bug-Gallery2-menu-No1-20160818

来源:互联网 发布:天子网络 编辑:程序博客网 时间:2024/05/18 00:46

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
原创粉丝点击