ported from simpledialogfragment