package cgeo.geocaching.ui.dialog;

import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;

import java.util.Calendar;

public class DateDialog extends DialogFragment implements OnDateSetListener {

    public interface DateDialogParent {
        abstract public void setDate(final Calendar date);
    }

    private Calendar date;

    public static DateDialog getInstance(final Calendar date) {
        final DateDialog dateDialog = new DateDialog();
        final Bundle args = new Bundle();
        args.putSerializable("date", date);
        dateDialog.setArguments(args);
        return dateDialog;
    }

    @Override
    public Dialog onCreateDialog(final Bundle savedInstanceState) {

        final Bundle args = getArguments();
        date = (Calendar) args.getSerializable("date");

        final int year = date.get(Calendar.YEAR);
        final int month = date.get(Calendar.MONTH);
        final int day = date.get(Calendar.DAY_OF_MONTH);

        // Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    @Override
    public void onDateSet(final DatePicker view, final int year, final int monthOfYear, final int dayOfMonth) {
        date.set(year, monthOfYear, dayOfMonth);

        ((DateDialogParent) getActivity()).setDate(date);
    }
}
@@ -29,16 +29,53 @@
 ialog;%0A%0A
+import android.annotation.TargetApi;%0A
 import a
@@ -95,32 +95,32 @@
 tePickerDialog;%0A
-
 import android.a
@@ -177,32 +177,57 @@
 oid.app.Dialog;%0A
+import android.os.Build;%0A
 import android.o
@@ -919,17 +919,16 @@
 tate) %7B%0A
-%0A
         
@@ -1255,22 +1255,47 @@
         
-return
+final DatePickerDialog dialog =
  new Dat
@@ -1347,16 +1347,423 @@
 h, day);
+%0A%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.HONEYCOMB) %7B%0A            forceTitleUpdate(year, month, day, dialog);%0A        %7D%0A        return dialog;%0A    %7D%0A%0A    @TargetApi(Build.VERSION_CODES.HONEYCOMB)%0A    private static void forceTitleUpdate(final int year, final int month, final int day, final DatePickerDialog dialog) %7B%0A        dialog.onDateChanged(dialog.getDatePicker(), year, month, day);
 %0A    %7D%0A%0A

have weekday in date selection title