diff --git a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java index 9f6e7d5..59479ae 100644 --- a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java +++ b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java @@ -23,6 +23,7 @@ import com.prolificinteractive.materialcalendarview.MaterialCalendarView; import com.prolificinteractive.materialcalendarview.OnDateSelectedListener; +import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -235,7 +236,7 @@ public void onClick(View view) { yearSimpleDate = new SimpleDateFormat("yyyy", Locale.getDefault()); // Init headers - yearHeaderValues.setText(String.valueOf(dateTimeCalendar.get(Calendar.YEAR))); + yearHeaderValues.setText(yearSimpleDate.format(dateTimeCalendar.getTime())); monthAndDayHeaderValues.setText(dayAndMonthSimpleDate.format(dateTimeCalendar.getTime())); // Construct TimePicker @@ -270,7 +271,7 @@ public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull Calend dateTimeCalendar.set(Calendar.MONTH, calendarDay.getMonth()); dateTimeCalendar.set(Calendar.DAY_OF_MONTH, calendarDay.getDay()); listPickerYearView.assignCurrentYear(calendarDay.getYear()); - yearHeaderValues.setText(String.valueOf(calendarDay.getYear())); + yearHeaderValues.setText(yearSimpleDate.format(dateTimeCalendar.getTime())); monthAndDayHeaderValues.setText(dayAndMonthSimpleDate.format(currentDate)); } }); @@ -285,7 +286,7 @@ public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull Calend @Override public void onYearSelected(View view, int yearPicker) { dateTimeCalendar.set(Calendar.YEAR, yearPicker); - yearHeaderValues.setText(String.valueOf(yearPicker)); + yearHeaderValues.setText(yearSimpleDate.format(dateTimeCalendar.getTime())); // Unfortunately, we have lags here and thread isn't a solution :/ materialCalendarView.setCurrentDate(dateTimeCalendar.getTime()); diff --git a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/TextCircularIndicatorView.java b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/TextCircularIndicatorView.java index 11bffbd..ebb8aea 100644 --- a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/TextCircularIndicatorView.java +++ b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/TextCircularIndicatorView.java @@ -5,11 +5,9 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.os.Build; import android.support.annotation.ColorInt; -import android.support.annotation.RequiresApi; +import android.support.v7.widget.AppCompatTextView; import android.util.AttributeSet; -import android.widget.TextView; import com.kunzisoft.switchdatetime.R; @@ -17,7 +15,7 @@ * TextView with circular colored background * @author JJamet */ -public class TextCircularIndicatorView extends TextView { +public class TextCircularIndicatorView extends AppCompatTextView { private int mCircleColor = Color.BLUE; private Paint mCirclePaint = new Paint(); @@ -35,12 +33,6 @@ public TextCircularIndicatorView(Context context, AttributeSet attrs, int defSty init(attrs); } - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) - public TextCircularIndicatorView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - init(attrs); - } - /** * Initialize constructor * @param attrs diff --git a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/YearPickerAdapter.java b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/YearPickerAdapter.java index bf973c9..23cd8f4 100644 --- a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/YearPickerAdapter.java +++ b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/date/widget/YearPickerAdapter.java @@ -8,8 +8,12 @@ import com.kunzisoft.switchdatetime.R; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; +import java.util.Locale; /** * Adapter for manage elements of ListPickerYearView @@ -22,6 +26,9 @@ class YearPickerAdapter extends RecyclerView.Adapter listYears; private Integer selectedYear; private int positionSelectedYear; @@ -34,6 +41,8 @@ class YearPickerAdapter extends RecyclerView.Adapter(); this.selectedYear = UNDEFINED; + this.yearFormat = new SimpleDateFormat("yyyy", Locale.getDefault()); + this.calendar = Calendar.getInstance(); } @Override @@ -62,7 +71,9 @@ public TextIndicatorViewHolder onCreateViewHolder(ViewGroup parent, int viewType @Override public void onBindViewHolder(TextIndicatorViewHolder holder, int position) { Integer currentYear = listYears.get(position); - holder.textView.setText(String.valueOf(currentYear)); + + calendar.set(Calendar.YEAR, currentYear); + holder.textView.setText(yearFormat.format(calendar.getTime())); if(onClickYearListener != null) holder.container.setOnClickListener(new BufferYearClickListener(currentYear, position)); diff --git a/switchdatetime/src/main/res/layout-ldrtl-v17/time_header_label.xml b/switchdatetime/src/main/res/layout-ldrtl-v17/time_header_label.xml index 4956222..26c3d59 100644 --- a/switchdatetime/src/main/res/layout-ldrtl-v17/time_header_label.xml +++ b/switchdatetime/src/main/res/layout-ldrtl-v17/time_header_label.xml @@ -16,28 +16,9 @@ --> - - - + + + style="@style/Theme.SwitchDateTime.TimeLabelText" /> + style="@style/Theme.SwitchDateTime.TimeLabelText" /> + style="@style/Theme.SwitchDateTime.TimeLabelAmPm" /> \ No newline at end of file diff --git a/switchdatetime/src/main/res/layout/time_header_label.xml b/switchdatetime/src/main/res/layout/time_header_label.xml index e51db04..f187f31 100644 --- a/switchdatetime/src/main/res/layout/time_header_label.xml +++ b/switchdatetime/src/main/res/layout/time_header_label.xml @@ -16,27 +16,10 @@ --> - - + + + + style="@style/Theme.SwitchDateTime.TimeLabelText" /> + style="@style/Theme.SwitchDateTime.TimeLabelText" /> + style="@style/Theme.SwitchDateTime.TimeLabelAmPm" /> \ No newline at end of file