Android 11.0 修复Camera预览照片时按键盘左右键,底部功能栏的焦点也同时变动

Posted 王睿丶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 11.0 修复Camera预览照片时按键盘左右键,底部功能栏的焦点也同时变动相关的知识,希望对你有一定的参考价值。

改成了:默认底部导航栏禁用,但不消失,这样左右键切换时,只切换照片
若需要底部导航功能,按方向下键即可启用底部导航功能,此时左右键只切换底部导航按钮,若需要切换照片,则需要按上键,此时底部导航禁用,照片正常切换。从而达到修复的效果

packages/apps/Camera2/src/com/android/camera/CameraActivity.java

    //wangrui Bottom navigation bar enabled state Default false off, true on
    private boolean bottomPanelFlag = false;
    //wangrui get myFilmstripItem
    private FilmstripItem myFilmstripItem;

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) 
        if (ActivityManager.isUserAMonkey())
            return super.onKeyUp(keyCode, event);
        if (!mFilmstripVisible) 
            // If a module is in the middle of capture, it should
            // consume the key event.
            if (mCurrentModule.onKeyUp(keyCode, event)) 
                Log.i(TAG, "onKeyUp->mCurrentModule->onKeyup->true");
                return true;
             else if (keyCode == KeyEvent.KEYCODE_MENU
                    || keyCode == KeyEvent.KEYCODE_DPAD_LEFT) 
                // Let the mode list view consume the event.
                mCameraAppUI.openModeList();
                return true;
             else if(keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
                Log.i(TAG, "onKeyUp->keycode_dpad_down");
                if(mModeListView.getVisibility() == View.VISIBLE && mCurrentModeIndex == 0)
                    mModeListView.getListView().getChildAt(1).performClick();
                
             else if(keyCode == KeyEvent.KEYCODE_DPAD_UP)
                Log.i(TAG, "onKeyUp->keycode_dpad_up");
                if(mModeListView.getVisibility() == View.VISIBLE && mCurrentModeIndex == 1)
                    mModeListView.getListView().getChildAt(0).performClick();
                
             else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) 
                if (mDataAdapter.getTotalNumber() > 0)
                    mCameraAppUI.showFilmstrip();
                return true;
            
         else 

            // wangrui DOWN,Enable bottom navigation buttons
++            if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
++                bottomPanelFlag = true;
++                updateBottomControlsByData(myFilmstripItem);
++            else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) // UP Close bottom navigation buttons
++               bottomPanelFlag = false;
++                updateBottomControlsByData(myFilmstripItem);
++            

            // wangrui When the current state of the bottom navigation bar is true, switching is allowed, otherwise it is not allowed
            if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) 
++                if (!bottomPanelFlag) mFilmstripController.goToNextItem();
                return true;
             else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) 
++                if (!bottomPanelFlag)
                    boolean wentToPrevious = mFilmstripController.goToPreviousItem();
                    if (!wentToPrevious) 
                        // at beginning of filmstrip, hide and go back to preview
                        mCameraAppUI.hideFilmstrip();
                    
++                
                return true;
            
        
        return super.onKeyUp(keyCode, event);
    


我是王睿丶,加入我的Q群:901440630,欢迎一起讨论安卓技术!

以上是关于Android 11.0 修复Camera预览照片时按键盘左右键,底部功能栏的焦点也同时变动的主要内容,如果未能解决你的问题,请参考以下文章

Android 11.0 修复Camera 录像后,视频出现加速

Android 11.0 修复Camera 启用后置摄像头在拍照界面下,白平衡按钮无法点击

Android 11.0 修复Camera 使用闪光灯拍照后,查看图片时详细信息为“未使用闪光灯”状态

Android 11.0 修复:Camera 拍照后,图片详情信息的分辨率和画质信息概率性丢失

Android 11.0 Camera2 默认选择拍照尺寸修改及流程分析

如何使用Android中的Camera2 API在不预览的情况下拍摄多张照片?