public boolean onTouchDrawMode(MotionEvent event){
  float eventX=event.getX();
  float eventY=event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    currentPath=new CPath();
  currentPaint=new Paint();
currentPaint.setAntiAlias(true);
currentPaint.setColor(mColor);
currentPaint.setStyle(mStyle);
currentPaint.setStrokeJoin(Paint.Join.ROUND);
currentPaint.setStrokeWidth(mSize);
currentPath.moveTo(eventX,eventY);
currentPath.setPaint(currentPaint);
lastTouchX=eventX;
lastTouchY=eventY;
mDrawableList.add(currentPath);
return true;
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:
currentPath.lineTo(eventX,eventY);
int historySize=event.getHistorySize();
for (int i=0; i < historySize; i++) {
float historicalX=event.getHistoricalX(i);
float historicalY=event.getHistoricalY(i);
if (historicalX < dirtyRect.left) {
dirtyRect.left=historicalX;
}
 else if (historicalX > dirtyRect.right) {
dirtyRect.right=historicalX;
}
if (historicalY < dirtyRect.top) {
dirtyRect.top=historicalY;
}
 else if (historicalY > dirtyRect.bottom) {
dirtyRect.bottom=historicalY;
}
currentPath.lineTo(historicalX,historicalY);
}
currentPath.lineTo(eventX,eventY);
cleanDirtyRegion(eventX,eventY);
break;
default :
return false;
}
invalidate((int)(dirtyRect.left - 20),(int)(dirtyRect.top - 20),(int)(dirtyRect.right + 20),(int)(dirtyRect.bottom + 20));
lastTouchX=eventX;
lastTouchY=eventY;
return true;
}

public boolean onTouchDrawMode ( MotionEvent event ) { float eventX = event . getX ( ) ; float eventY = event . getY ( ) ; switch ( event . getAction ( ) ) { case MotionEvent . ACTION_DOWN : currentPath = new CPath ( ) ; currentPaint = new Paint ( ) ; currentPaint . setAntiAlias ( true ) ; currentPaint . setColor ( mColor ) ; currentPaint . setStyle ( mStyle ) ; currentPaint . setStrokeJoin ( Paint . Join . ROUND ) ; currentPaint . setStrokeWidth ( mSize ) ; currentPath . moveTo ( eventX , eventY ) ; currentPath . setPaint ( currentPaint ) ; lastTouchX = eventX ; lastTouchY = eventY ; mDrawableList . add ( currentPath ) ; return true ; case MotionEvent . ACTION_MOVE : case MotionEvent . ACTION_UP : currentPath . lineTo ( eventX , eventY ) ; int historySize = event . getHistorySize ( ) ; for ( int i = 0 ; i < historySize ; i ++ ) { float historicalX = event . getHistoricalX ( i ) ; float historicalY = event . getHistoricalY ( i ) ; if ( historicalX < dirtyRect . left ) { dirtyRect . left = historicalX ; } else if ( historicalX > dirtyRect . right ) { dirtyRect . right = historicalX ; } if ( historicalY < dirtyRect . top ) { dirtyRect . top = historicalY ; } else if ( historicalY > dirtyRect . bottom ) { dirtyRect . bottom = historicalY ; } currentPath . lineTo ( historicalX , historicalY ) ; } currentPath . lineTo ( eventX , eventY ) ; cleanDirtyRegion ( eventX , eventY ) ; break ; default : return false ; } invalidate ( ( int ) ( dirtyRect . left - 20 ) , ( int ) ( dirtyRect . top - 20 ) , ( int ) ( dirtyRect . right + 20 ) , ( int ) ( dirtyRect . bottom + 20 ) ) ; lastTouchX = eventX ; lastTouchY = eventY ; return true ; }
handles the touch input if the mode is set to draw
