@Override public void onClick(View v) { if (v.equals(mColorPickerBtn)) { // Toggle boolean bIsColorPickerMode = !mSCanvas.isColorPickerMode(); mSCanvas.setColorPickerMode(bIsColorPickerMode); mColorPickerBtn.setSelected(bIsColorPickerMode); } }
// 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()); }