GithubHelp home page GithubHelp logo

ibotta / supported-picker-dialogs Goto Github PK

View Code? Open in Web Editor NEW
76.0 19.0 13.0 1.86 MB

An Android DatePickerDialog and TimePickerDialog that works correctly on API 14+

License: Apache License 2.0

Kotlin 100.00%
android datepickerdialog timepickerdialog datepicker timepicker kotlin-android android-library

supported-picker-dialogs's Introduction

Supported-Picker-Dialogs - ๐Ÿ›‘ DEPRECATED ๐Ÿ›‘

This project repo is no longer being maintained.

Travis CI Badge

Code Climate Maintainability

Jitpack.io Badge

Installation

Step 1: Add jitpack.io repository to your root build.gradle

allprojects {
 repositories {
    jcenter()
    maven { url "https://jitpack.io" }
 }
}

Step 2. Add this dependency

dependencies {
    implementation 'com.github.Ibotta:Supported-Picker-Dialogs:1.0.0'
}

Usage

An Android DatePickerDialog and TimePickerDialog that works correctly on API 14+

The main reason for this library is to fix an issue with the spinner datepickermode and timepickermode style attributes not being applied to the DatePickerDialog and TimePickerDialog on devices running Android 7.0. Google responded that they wont fix the issue for 7.0 through these tracked issues: https://issuetracker.google.com/issues/37120178, https://issuetracker.google.com/issues/37119315. It's a pretty strange issue with how the Android platform library handles these style attributes for the picker views. Fear not though! This library adds a SupportedDatePickerDialog and SupportedTimePickerDialog to your project to fix the issue. These classes can be used in place of any DatePickerDialog or TimePickerDialog and will continue to have the same functionality that these Android platform library's picker dialogs have.

Background

If you would like to know how I got to my solution, check out my blog post on Medium! https://medium.com/building-ibotta/spinner-picker-dialogs-on-android-7-0-we-fixed-them-4dcda0f6102b

Development

SupportedDatePickerDialog style example:

<style name="SpinnerDatePickerDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <!-- android:datePickerStyle was not added until API 21 -->
    <item name="android:datePickerStyle">@style/DatePickerStyle</item>
</style>

<style name="DatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker">
    <item name="android:datePickerMode">spinner</item>
</style>

SupportedDatePickerDialog code example:

val currentDate = Calendar.getInstance()
val year = currentDate.get(Calendar.YEAR)
val month = currentDate.get(Calendar.MONTH)
val dayOfMonth = currentDate.get(Calendar.DAY_OF_MONTH)
SupportedDatePickerDialog(this, R.style.SpinnerDatePickerDialogTheme, this, year, month, dayOfMonth).show()

SupportedTimePickerDialog style example:

<style name="SpinnerTimePickerDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <!-- android:timePickerStyle was not added until API 21 -->
    <item name="android:timePickerStyle">@style/TimePickerStyle</item>
</style>

<style name="TimePickerStyle" parent="@android:style/Widget.Material.Light.TimePicker">
    <item name="android:timePickerMode">spinner</item>
</style>

SupportedTimePickerDialog code example:

val currentDate = Calendar.getInstance()
val month = currentDate.get(Calendar.MONTH)
val dayOfMonth = currentDate.get(Calendar.DAY_OF_MONTH)
SupportedTimePickerDialog(
    context = this,
    themeResId =  R.style.SpinnerTimePickerDialogTheme,
    timeSetListener = this,
    mInitialHourOfDay = month,
    mInitialMinute = dayOfMonth,
    mIs24HourView = true)
    .show()

SupportedDatePickerDialog on Android 7.0 (API 21):

Supported Date Picker Dialog

SupportedTimePickerDialog on Android 7.0 (API 21):

Supported Time Picker Dialog

supported-picker-dialogs's People

Contributors

lnewcomer1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

supported-picker-dialogs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.