package com.bokecc.livemodule.replay;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import com.bokecc.dwlivedemo.BuildConfig;
import com.bokecc.dwlivedemo.DWApplication;
import com.bokecc.livemodule.replay.video.DWReplayVideoListener;
import com.bokecc.livemodule.utils.ProRecordWorker;
import com.bokecc.livemodule.utils.ThreadUtils;
import com.bokecc.sdk.mobile.live.Exception.DWLiveException;
import com.bokecc.sdk.mobile.live.ReplayPlayerListener;
import com.bokecc.sdk.mobile.live.pojo.BaseRecordInfo;
import com.bokecc.sdk.mobile.live.pojo.RecordInfo;
import com.bokecc.sdk.mobile.live.pojo.RoomInfo;
import com.bokecc.sdk.mobile.live.replay.DWLiveReplay;
import com.bokecc.sdk.mobile.live.replay.DWLiveReplayListener;
import com.bokecc.sdk.mobile.live.replay.ReplayChangeSourceListener;
import com.bokecc.sdk.mobile.live.replay.entity.ReplayLineParams;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayBroadCastMsg;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayChatMsg;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayDot;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayLineInfo;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayLiveInfo;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayPageInfo;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayPracticeInfo;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayQAMsg;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayQualityinfo;
import com.bokecc.sdk.mobile.live.replay.pojo.ReplayUrlInfo;
import com.bokecc.sdk.mobile.live.replay.pojo.Viewer;
import com.bokecc.sdk.mobile.live.stream.live.rtc.HDMediaView;
import com.bokecc.sdk.mobile.live.widget.DocView;
import com.bokecc.stream.ali.CCBasePlayer;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;

/**
 * 回放相关逻辑核心处理机制
 */
public class DWReplayCoreHandler {

    private static final String TAG = "DWReplayCoreHandler";

    private static final DWReplayCoreHandler dwReplayCoreHandler = new DWReplayCoreHandler();
    // 进度记忆功能
    private ProRecordWorker proRecordWorker;

    private boolean isAllowShowRecordWindow = false;

    private boolean docTouchMode = false;

    /**
     * 私有构造函数
     */
    private DWReplayCoreHandler() {
    }

    /**
     * 获取DWReplayCoreHandler单例的实例
     */
    public static DWReplayCoreHandler getInstance() {
        return dwReplayCoreHandler;
    }

    //******************************* 各类监听相关 ***************************************/

    /**
     * 回放聊天监听
     */
    private DWReplayChatListener replayChatListener;

    /**
     * 设置回放聊天监听
     *
     * @param replayChatListener 回放聊天监听
     */
    public void setReplayChatListener(DWReplayChatListener replayChatListener) {
        this.replayChatListener = replayChatListener;
    }

    /**
     * 回放问答监听
     */
    private DWReplayQAListener replayQAListener;

    /**
     * 设置回放问答监听
     *
     * @param replayQAListener 回放问答监听
     */
    public void setReplayQAListener(DWReplayQAListener replayQAListener) {
        this.replayQAListener = replayQAListener;
    }

    // 直播间信息监听
    private DWReplayRoomListener replayRoomListener;

    /**
     * 设置直播间信息监听
     *
     * @param listener 直播间信息监听
     */
    public void setReplayRoomListener(DWReplayRoomListener listener) {
        this.replayRoomListener = listener;
    }

    //播放器监听
    private DWReplayVideoListener replayVideoListener;

    public void setReplayVideoListener(DWReplayVideoListener replayVideoListener) {
        this.replayVideoListener = replayVideoListener;
    }
    //******************************* 设置"播放"组件/控件相关 ***************************************/

    // 进度记忆控件和唯一id
    private TextView proRecordJump;
    private String recordTag;

    /**
     * 设置播放器
     *
     * @param player 播放器
     */

    /**
     * 获取当前的播放器
     */

    /**
     * 设置文档展示控件
     *
     * @param docView 文档展示控件
     */
    public void setDocView(DocView docView) {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null) {
            dwLiveReplay.setReplayDocView(docView);
        }
    }

    /**
     * 设置进度记忆控件
     *
     * @param textView textView
     */
    public void setProRecordJumpTextView(TextView textView) {
        proRecordJump = textView;
    }

    /**
     * 设置进度记忆唯一标识
     *
     * @param recordTag recordTag
     */
    public void setRecordTag(String recordTag) {
        this.recordTag = recordTag;
    }

    //******************************* 直播间模版相关 ***************************************/

    private final static String ViEW_VISIBLE_TAG = "1";

    /**
     * 当前直播间是否有'文档'
     */
    public boolean hasDocView() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null && dwLiveReplay.getTemplateInfo() != null) {
            return dwLiveReplay.getTemplateInfo().hasDoc();
        }
        return false;
    }

    /**
     * 当前直播间是否有'聊天'
     */
    public boolean hasChatView() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null && dwLiveReplay.getTemplateInfo() != null) {
            return dwLiveReplay.getTemplateInfo().hasChat();
        }
        return false;
    }

    /**
     * 当前直播间是否有'问答'
     */
    public boolean hasQaView() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null && dwLiveReplay.getTemplateInfo() != null) {
            return dwLiveReplay.getTemplateInfo().hasQa();
        }
        return false;
    }

    /**
     * 当前直播间是否显示跑马灯
     *
     * @return true 显示 false 不显示
     */
    public boolean isOpenMarquee() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null && dwLiveReplay.getRoomInfo() != null) {
            if (dwLiveReplay.getRoomInfo().getOpenMarquee() == 1) {
                return true;
            }
        }
        return false;
    }

    /**
     * 获取文档显示模式
     *
     * @return 文档窗口状态：1——适合窗口，2——适合宽度
     */
    public int getDocumentDisplayMode() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null && dwLiveReplay.getRoomInfo() != null) {
            return dwLiveReplay.getRoomInfo().getDocumentDisplayMode();
        }
        return 1;
    }

    /**
     * 获取基本信息
     *
     * @return BaseRecordInfo
     */
    public BaseRecordInfo getBaseRecordInfo() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null && dwLiveReplay.getRoomInfo() != null) {
            return dwLiveReplay.getRoomInfo().getBaseRecordInfo();
        }
        return null;
    }

    /**
     * 获取直播信息
     *
     * @return ReplayLiveInfo
     */
    public ReplayLiveInfo getReplayLiveInfo() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null) {
            return dwLiveReplay.getReplayLiveInfo();
        }
        return null;
    }


    //***************************** 视频播放相关 ***************************************/

    /**
     * 开始播放
     */
    public void start(Context context) {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        dwLiveReplay.setReplayListener(dwLiveReplayListener);
        dwLiveReplay.setReplayPlayerListener(replayPlayerListener);
        //可以显示记忆播放小浮窗
        isAllowShowRecordWindow = true;
        dwLiveReplay.start(context);
    }

    /**
     * 暂停播放
     */
    public void pause() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null) {
            dwLiveReplay.pause();
        }
    }

    /**
     * 释放资源
     */
    public void destroy() {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null) {
            dwLiveReplay.onDestroy();
        }
        replayChatListener = null;
        replayQAListener = null;
        replayRoomListener = null;
        replayVideoListener = null;
        replayPageListener = null;
        if (proRecordJump != null) {
            proRecordJump = null;
        }
        if (proRecordWorker != null) {
            proRecordWorker = null;
            //重置记忆播放小浮窗
            isAllowShowRecordWindow = true;
        }
        docTouchMode = false;
    }

    /**
     * 重试播放
     *
     * @param time:时间点，是否强制更新流地址
     */
    public void retryReplay(long time, boolean updateStream) {
        DWLiveReplay dwLiveReplay = DWLiveReplay.getInstance();
        if (dwLiveReplay != null) {
            dwLiveReplay.retryReplay(time, updateStream);
        }
    }

    /**
     * 更新当前缓冲进度
     */
    public void updateBufferPercent(int percent) {
        if (replayRoomListener != null) {
            replayRoomListener.updateBufferPercent(percent);
        }
    }

    /**
     * 切换清晰度
     *
     * @param quality quality
     */
    public void changeQuality(int quality, ReplayChangeSourceListener changeLineCallback) {
        isAllowShowRecordWindow = false;
        DWLiveReplay.getInstance().changeQuality(quality, changeLineCallback);
    }

    /**
     * 切换线路
     *
     * @param lineIndex 线路索引
     */
    public void changeLine(int lineIndex, ReplayChangeSourceListener changeLineCallback) {
        isAllowShowRecordWindow = false;
        DWLiveReplay.getInstance().changeLine(lineIndex, changeLineCallback);
    }

    /**
     * 切换播放模式
     *
     * @param playMode DWLive.PlayMode
     */
    public void changePlayMode(DWLiveReplay.PlayMode playMode, final ReplayChangeSourceListener changeCallBack) {
        isAllowShowRecordWindow = false;
        DWLiveReplay.getInstance().changePlayMode(playMode, changeCallBack);
    }

    /**
     * 拖拽进度
     * @param time
     */
    public void seekTo(long time) {
        DWLiveReplay.getInstance().seekTo((int) time);
    }
    private CCBasePlayer.CCPlayerStatus status;

    /**
     * 是否处于播放中
     * @return
     */
    public boolean isPlaying() {
        return DWLiveReplay.getInstance().isPlaying();
    }

    /**
     * 是否可拖拽
     * @return
     */
    public boolean isInPlaybackState() {
        return status != null
                && status != CCBasePlayer.CCPlayerStatus.ERROR
                && status != CCBasePlayer.CCPlayerStatus.IDLE
                && status != CCBasePlayer.CCPlayerStatus.PREPARING
                && status != CCBasePlayer.CCPlayerStatus.COMPLETED;
    }
    ReplayPlayerListener replayPlayerListener = new ReplayPlayerListener() {
        @Override
        public void onError(CCBasePlayer.CCPlayerError error, DWLiveException exception) {
            if (replayRoomListener != null) {
                replayRoomListener.onPlayError(exception.getErrorCode().getCode());
            }
            if (replayVideoListener!=null){
                replayVideoListener.onError(exception.getErrorCode().getCode());
            }
        }

        @Override
        public void onVideoSizeChanged(int width, int height) {
            super.onVideoSizeChanged(width, height);
        }

        @Override
        public void onPlayStateChange(CCBasePlayer.CCPlayerStatus state) {
            super.onPlayStateChange(state);
            status = state;
            if (state == CCBasePlayer.CCPlayerStatus.PREPARED){
                if (replayRoomListener != null) {
                    replayRoomListener.videoPrepared(DWLiveReplay.getInstance().getDuration());
                }
                if (replayVideoListener!=null){
                    replayVideoListener.onPrepared();
                }
                //进入回放，只显示一次 记忆播放小浮窗
                if (isAllowShowRecordWindow){
                    startProRecord(DWApplication.getInstance().getContext(), new ProRecordWorker.UICallback(){

                        @Override
                        public void proRecordSeek(long time) {
                            if (isPlaying()) {
                                seekTo(time);
                            } else {
                                //如果不是播放中  为了安全起见 重新播放
                                retryReplay(time, false);
                            }
                        }
                    });
                }

            }else if (state == CCBasePlayer.CCPlayerStatus.BUFFERRING){
                if (replayVideoListener!=null){
                    replayVideoListener.onBufferStart();
                }
                if (replayRoomListener != null) {
                    replayRoomListener.onBufferStart();
                }
            }else if (state == CCBasePlayer.CCPlayerStatus.BUFFERRED){
                if (replayVideoListener!=null){
                    replayVideoListener.onBufferEnd();
                }
                if (replayRoomListener != null) {
                    replayRoomListener.onPlay();
                }
            }else if (state == CCBasePlayer.CCPlayerStatus.COMPLETED){
                if (replayRoomListener != null) {
                    replayRoomListener.onPlayComplete();
                }
                if (proRecordWorker != null) {
                    proRecordWorker.clear();
                }
            }else if (state == CCBasePlayer.CCPlayerStatus.SEEKED){
                if (replayRoomListener != null) {
                    replayRoomListener.onSeekComplete();
                }
            }else if (state == CCBasePlayer.CCPlayerStatus.PLAYING){
                if (replayVideoListener!=null){
                    replayVideoListener.onPlaying();
                }
                if (replayRoomListener != null) {
                    replayRoomListener.onPlay();
                }
            }
        }

        @Override
        public void onBufferSpeed(float speed) {
            super.onBufferSpeed(speed);
            if (replayVideoListener!=null){
                replayVideoListener.onBufferSpeed(speed);
            }
        }
    };

    //--------------------------------------记忆播放相关--------------------------------------------

    // 开启进度记忆
    public void startProRecord(Context context, ProRecordWorker.UICallback callback) {
        if (proRecordWorker != null) {
            proRecordWorker.stop();
        }
        proRecordWorker = new ProRecordWorker(context, callback);
        proRecordWorker.setRecordTag(recordTag);
        proRecordWorker.setTextView(proRecordJump);
        proRecordWorker.start();

    }

    public void stopProRecord() {
        if (proRecordWorker != null) {
            proRecordWorker.stop();
            proRecordWorker = null;
        }

    }

    public void clearProRecord() {
        if (proRecordWorker != null) {
            proRecordWorker.clear();
        }
    }


    //******************************* 实现 DWLiveListener 定义的方法 *********************************/

    private final DWLiveReplayListener dwLiveReplayListener = new DWLiveReplayListener() {
        @Override
        public void onException(DWLiveException exception) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onException:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayRoomListener != null) {
                replayRoomListener.onException(exception);
            }
        }

        // 回放打点功能
        @Override
        public void onHDReplayDotList(List<ReplayDot> dotList) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onHDReplayDotList:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayRoomListener != null) {
                replayRoomListener.onHDReplayDotList(dotList);
            }
        }

        @Override
        public void onMediaInfoPrepared() {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onMediaInfoPrepared:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
        }

        @Override
        public void onPageInfoList(ArrayList<ReplayPageInfo> infoList) {
            //方法在4.7.0版本及以后废弃不再使用
            if (replayPageListener!=null){
                replayPageListener.onPageInfo(infoList);
            }
        }

        @Override
        public void onPageChange(String docId, String docName, int width, int height, int pageNum, int docTotalPage) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onPageChange:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            Log.d(TAG, "onPageChange: pageNum:" + pageNum + " docTotalPage:" + docTotalPage + " docId=" + docId);
        }

        @Override
        public void onDataPrepared() {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onDataPrepared:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
        }

        @Override
        public void numberOfReceivedLines(int lines) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "numberOfReceivedLines:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
        }

        @Override
        public void numberOfReceivedLinesWithVideoAndAudio(List<ReplayLineParams> videoLines, List<ReplayLineParams> audioLines) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "numberOfReceivedLinesWithVideoAndAudio:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
        }

        @Override
        public void onHDAudioMode(DWLiveReplay.Audio hasAudio) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onHDAudioMode:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayRoomListener != null) {
                replayRoomListener.onHDAudioMode(hasAudio);
            }
        }

        @Override
        public void onHDReceivedVideoQuality(List<ReplayQualityinfo> videoQuality, ReplayQualityinfo currentQuality) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onHDReceivedVideoQuality:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayRoomListener != null) {
                replayRoomListener.onHDReceivedVideoQuality(videoQuality, currentQuality);
            }
        }

        @Override
        public void onHDReceivedVideoAudioLines(List<ReplayLineInfo> lines, int currentLineIndex) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onHDReceivedVideoAudioLines:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayRoomListener != null) {
                replayRoomListener.onHDReceivedVideoAudioLines(lines, currentLineIndex);
            }
        }


        @Override
        public void onInitFinished() {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onInitFinished:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }


        }

        @Override
        public void onBroadCastMessage(ArrayList<ReplayBroadCastMsg> broadCastMsgList) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onBroadCastMessage:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
        }

        /**
         * 聊天信息
         *
         * @param replayChatMsgs 聊天信息
         */
        @Override
        public void onChatMessage(TreeSet<ReplayChatMsg> replayChatMsgs) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onChatMessage:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayChatListener != null) {
                replayChatListener.onChatMessage(replayChatMsgs);
            }
        }


        /**
         * 提问回答信息
         *
         * @param qaMsgs 问答信息
         */
        @Override
        public void onQuestionAnswer(TreeSet<ReplayQAMsg> qaMsgs) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onQuestionAnswer:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
            if (replayQAListener != null) {
                replayQAListener.onQuestionAnswer(qaMsgs);
            }
        }

        @Override
        public void onHDReceivePracticeList(List<ReplayPracticeInfo> list) {
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "onHDReceivePracticeList:" + Thread.currentThread().getName());
                // 检查是否在主线程
                ThreadUtils.checkIsOnMainThread();
            }
//            if (list.size() == 0) {
//                CustomToast.showToast(getContext(), "本场直播无随堂测数据", Toast.LENGTH_LONG);
//            } else {
//                CustomToast.showToast(getContext(), "本场直播进行了" + list.size() + "次随堂测", Toast.LENGTH_LONG);
//                for (int i = 0; i < list.size(); i++) {
//                    ReplayPracticeInfo replayPracticeInfo = list.get(i);
//                    PracticeRankInfo rankInfo = replayPracticeInfo.getRankInfo();
//                    PracticeStatisInfo statisInfo = replayPracticeInfo.getStatisInfo();
//                    Log.i(TAG, rankInfo.toString());
//                    Log.i(TAG, statisInfo.toString());
//                }
//
//            }
        }

        @Override
        public void onPlayBackStreamViewPrepared(HDMediaView hdMediaView) {
            if (replayVideoListener!=null){
                replayVideoListener.onVideoViewPrepared(hdMediaView);
            }
        }

        @Override
        public void onTrialDuration(int trialDuration) {
            super.onTrialDuration(trialDuration);
            if (replayRoomListener != null) {
                replayRoomListener.onTrialDuration(trialDuration);
            }
        }

        @Override
        public void onSubtitles(ReplayUrlInfo.SubtitleData subtitles) {
            if (replayRoomListener!=null){
                replayRoomListener.onSubtitles(subtitles);
            }
        }

    };
    //获取当前播放进度
    public float getCurrentPosition() {
        return DWLiveReplay.getInstance().getCurrentPosition();
    }
    //设置防录屏
    public void setAntiRecordScreen(Activity activity) {
        DWLiveReplay.getInstance().setAntiRecordScreen(activity);
    }

    public CCBasePlayer.CCPlayerStatus getStatus() {
        return status;
    }

    public void setSpeed(float v) {
        DWLiveReplay.getInstance().setSpeed(v);
    }

    public float getDuration() {
        return DWLiveReplay.getInstance().getDuration();
    }

    public Viewer getViewer() {
        return DWLiveReplay.getInstance().getViewer();
    }

    public RoomInfo getRoomInfo() {
        return DWLiveReplay.getInstance().getRoomInfo();
    }

    public RecordInfo getRoomRecordInfo() {
        return DWLiveReplay.getInstance().getRoomRecordInfo();
    }

    public void setLastPosition(long progress) {
        DWLiveReplay.getInstance().setLastPosition(progress);
    }


    private ReplayPageListener replayPageListener;
    public void setReplayPageListener(ReplayPageListener replayPageListener) {
        this.replayPageListener = replayPageListener;
    }

    public void onReplayDocPageInfo(ArrayList<com.bokecc.doc.docsdk.bean.ReplayPageInfo> infoList) {
        if (replayPageListener!=null){
            replayPageListener.onDocPageInfo(infoList);
        }
    }

    /**
     * 设置 vr 重力感应开关，默认开启
     *
     * @param enable true，开启重力感应，false，关闭重力感应
     */
    public void enableVrSensorControl(boolean enable){
        DWLiveReplay.getInstance().enableVrSensorControl(enable);
    }

    /**
     * 设置 vr 分屏开关，默认关闭
     *
     * @param enable true，开启分屏，false，关闭分屏
     */
    public void enableVrSplitView(boolean enable){
        DWLiveReplay.getInstance().enableVrSplitView(enable);
    }
    public boolean getIsVr(){
        return DWLiveReplay.getInstance().getIsVr();
    }

    public boolean hasCoursewareView() {
        return DWLiveReplay.getInstance().getIsAllowCoursewareDownload();
    }

    public void setDocTouchMode(boolean open) {
        this.docTouchMode = open;
    }
    public boolean getDocTouchMode() {
        return this.docTouchMode;
    }
}
