When user completes a stroke (touch up), then I take the path drawn by user, then divide the path such that each small sub path is very close to a line. Then I have combination of lines, Suppose I have four lines, then possibilities are that it can be a quadrilateral or circle, (if the end of last line is close to the start of the first line), then I use variance to determine which shape closely fits to the drawn stroke.
Once I know if this is quadrilateral, then uses various heuristics to find out if it is close to a rectangle or parallelogram etc.