aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2015-08-23 20:38:34 +0200
committerrsudev <rasch@munin-soft.de>2015-08-23 20:43:22 +0200
commitab4fb0b4f5a11c3e2f6d1ff1226006abeabe4098 (patch)
tree6cc50528f25b1366abc6185249eda43d6413bec6
parent5423bd6ea1ed272c41f7ab044d952675390ddee5 (diff)
downloadcgeo-ab4fb0b4f5a11c3e2f6d1ff1226006abeabe4098.zip
cgeo-ab4fb0b4f5a11c3e2f6d1ff1226006abeabe4098.tar.gz
cgeo-ab4fb0b4f5a11c3e2f6d1ff1226006abeabe4098.tar.bz2
Fixes #5148, Date Picker looks strange
- Replace date view by DatePickerDialog - Replace time view by TimePickerDialog
-rw-r--r--main/res/layout/date.xml12
-rw-r--r--main/res/layout/time.xml11
-rw-r--r--main/src/cgeo/geocaching/ui/dialog/DateDialog.java41
-rw-r--r--main/src/cgeo/geocaching/ui/dialog/TimeDialog.java46
4 files changed, 31 insertions, 79 deletions
diff --git a/main/res/layout/date.xml b/main/res/layout/date.xml
deleted file mode 100644
index 8357de4..0000000
--- a/main/res/layout/date.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <DatePicker
- android:id="@+id/picker"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="10dip" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/main/res/layout/time.xml b/main/res/layout/time.xml
deleted file mode 100644
index d0079b0..0000000
--- a/main/res/layout/time.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TimePicker
- android:id="@+id/picker"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="10dip" />
-</LinearLayout> \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/ui/dialog/DateDialog.java b/main/src/cgeo/geocaching/ui/dialog/DateDialog.java
index 15c9556..295ee19 100644
--- a/main/src/cgeo/geocaching/ui/dialog/DateDialog.java
+++ b/main/src/cgeo/geocaching/ui/dialog/DateDialog.java
@@ -1,19 +1,15 @@
package cgeo.geocaching.ui.dialog;
-import butterknife.ButterKnife;
-
-import cgeo.geocaching.R;
-
+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.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import android.widget.DatePicker;
import java.util.Calendar;
-public class DateDialog extends DialogFragment {
+public class DateDialog extends DialogFragment implements OnDateSetListener {
public interface DateDialogParent {
abstract public void setDate(final Calendar date);
@@ -30,30 +26,23 @@ public class DateDialog extends DialogFragment {
}
@Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setStyle(DialogFragment.STYLE_NO_TITLE, 0);
+ public Dialog onCreateDialog(final Bundle savedInstanceState) {
+
final Bundle args = getArguments();
date = (Calendar) args.getSerializable("date");
- }
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- final View v = inflater.inflate(R.layout.date, container, false);
+ final int year = date.get(Calendar.YEAR);
+ final int month = date.get(Calendar.MONTH);
+ final int day = date.get(Calendar.DAY_OF_MONTH);
- final DatePicker picker = ButterKnife.findById(v, R.id.picker);
- picker.init(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DATE), new DatePickerListener());
- return v;
+ // Create a new instance of DatePickerDialog and return it
+ return new DatePickerDialog(getActivity(), this, year, month, day);
}
- private class DatePickerListener implements DatePicker.OnDateChangedListener {
-
- @Override
- public void onDateChanged(final DatePicker picker, final int year, final int month, final int day) {
- date.set(year, month, day);
-
- ((DateDialogParent) getActivity()).setDate(date);
+ @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);
}
} \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/ui/dialog/TimeDialog.java b/main/src/cgeo/geocaching/ui/dialog/TimeDialog.java
index b0505be..00e0409 100644
--- a/main/src/cgeo/geocaching/ui/dialog/TimeDialog.java
+++ b/main/src/cgeo/geocaching/ui/dialog/TimeDialog.java
@@ -1,20 +1,16 @@
package cgeo.geocaching.ui.dialog;
-import butterknife.ButterKnife;
-
-import cgeo.geocaching.R;
-
+import android.app.Dialog;
+import android.app.TimePickerDialog;
+import android.app.TimePickerDialog.OnTimeSetListener;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.text.format.DateFormat;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import android.widget.TimePicker;
import java.util.Calendar;
-public class TimeDialog extends DialogFragment {
+public class TimeDialog extends DialogFragment implements OnTimeSetListener {
public interface TimeDialogParent {
abstract public void setTime(final Calendar date);
@@ -31,34 +27,24 @@ public class TimeDialog extends DialogFragment {
}
@Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setStyle(DialogFragment.STYLE_NO_TITLE, 0);
+ public Dialog onCreateDialog(final Bundle savedInstanceState) {
+
final Bundle args = getArguments();
date = (Calendar) args.getSerializable("date");
- }
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- final View view = inflater.inflate(R.layout.time, container, false);
+ final int hour = date.get(Calendar.HOUR_OF_DAY);
+ final int minute = date.get(Calendar.MINUTE);
- final TimePicker picker = ButterKnife.findById(view, R.id.picker);
- picker.setCurrentHour(date.get(Calendar.HOUR_OF_DAY));
- picker.setCurrentMinute(date.get(Calendar.MINUTE));
- picker.setOnTimeChangedListener(new TimePickerListener());
- picker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));
- return view;
+ // Create a new instance of TimePickerDialog and return it
+ return new TimePickerDialog(getActivity(), this, hour, minute,
+ DateFormat.is24HourFormat(getActivity()));
}
- private class TimePickerListener implements TimePicker.OnTimeChangedListener {
-
- @Override
- public void onTimeChanged(final TimePicker picker, final int hour, final int minutes) {
- date.set(Calendar.HOUR_OF_DAY, hour);
- date.set(Calendar.MINUTE, minutes);
-
- ((TimeDialogParent) getActivity()).setTime(date);
+ @Override
+ public void onTimeSet(final TimePicker view, final int hourOfDay, final int minute) {
+ date.set(Calendar.HOUR_OF_DAY, hourOfDay);
+ date.set(Calendar.MINUTE, minute);
- }
+ ((TimeDialogParent) getActivity()).setTime(date);
}
} \ No newline at end of file