@Override
        public boolean onLongClick(View v) {

          int nBtnID = v.getId();
          // If the mode is not changed, open the setting view. If the mode is same, close the
          // setting view.
          if (nBtnID == mPenBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_PEN,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_PEN) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN, true);
              updateModeState();
            }
            return true;
          } else if (nBtnID == mEraserBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER, true);
              updateModeState();
            }
            return true;
          } else if (nBtnID == mTextBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_TEXT,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_TEXT) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_TEXT);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_TEXT);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_TEXT, true);
              updateModeState();
              Toast.makeText(mContext, "Tap Canvas to insert Text", Toast.LENGTH_SHORT).show();
            }
            return true;
          } else if (nBtnID == mFillingBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_FILLING,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_FILLING) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_FILLING);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_FILLING);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_FILLING, true);
              updateModeState();
              Toast.makeText(mContext, "Tap Canvas to fill color", Toast.LENGTH_SHORT).show();
            }
            return true;
          }

          return false;
        }
  // Update tool button
  private void updateModeState() {
    int nCurMode = mSCanvas.getCanvasMode();
    mPenBtn.setSelected(nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
    mEraserBtn.setSelected(nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
    mTextBtn.setSelected(nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_TEXT);
    mFillingBtn.setSelected(nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_FILLING);

    // Reset color picker tool when Eraser Mode
    if (nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER) mSCanvas.setColorPickerMode(false);
    mColorPickerBtn.setEnabled(nCurMode != SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
    mColorPickerBtn.setSelected(mSCanvas.isColorPickerMode());
  }
        @Override
        public void onClick(View v) {

          int nBtnID = v.getId();
          // If the mode is not changed, open the setting view. If the mode is same, close the
          // setting view.
          if (nBtnID == mPenBtn.getId()) {
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_PEN) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN, false);
              updateModeState();
            }
          } else if (nBtnID == mEraserBtn.getId()) {
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER, false);
              updateModeState();
            }
          }
        }
 private void updateModeState() {
   int nCurMode = mSCanvas.getCanvasMode();
   mPenBtn.setSelected(nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
   mEraserBtn.setSelected(nCurMode == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
 }