This commit is contained in:
Daniele 2021-09-05 11:28:57 +02:00
parent 7114c6199a
commit 5026415e45
2 changed files with 19 additions and 2 deletions

View File

@ -122,7 +122,14 @@ class BeersFragment : Fragment(), BeersRepository.Listener, BeerRecyclerAdapter.
}
val year = if (type == FILTERTYPE.SINCE) repo.filter.brewedAfterYear else repo.filter.brewedBeforeYear
val month = if (type == FILTERTYPE.SINCE) repo.filter.brewedAfterMonth else repo.filter.brewedBeforeMonth
val dpd = DatePickerDialog(requireContext(), listener, year, month - 1,1)
val dpd = DatePickerDialog(requireContext(), R.style.beer_date_picker_dialog, listener, year, month - 1,1)
// Try to hide unused day spinner
val daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android")
if (daySpinnerId != 0) {
val daySpinnerView = dpd.datePicker.findViewById<View>(daySpinnerId)
if (daySpinnerView != null)
daySpinnerView.visibility = View.GONE
}
dpd.show()
}

View File

@ -11,6 +11,16 @@
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
<!-- Date picker style -->
<style name="beer_date_picker_dialog" parent="android:Theme.Material.Dialog">
<item name="android:datePickerStyle">@style/beer_date_picker</item>
<item name="android:colorAccent">@color/accent_500</item>
<item name="android:colorControlNormal">@color/accent_500</item>
</style>
<style name="beer_date_picker" parent="android:Widget.DatePicker">
<item name="android:datePickerMode">spinner</item>
<item name="android:calendarViewShown">false</item>
</style>
</resources>