├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── README_ES.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── build.gradle ├── gradle-mvn-push.gradle ├── gradle.properties └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── wdullaer │ │ └── materialdatetimepicker │ │ ├── date │ │ └── DefaultDateRangeLimiterTest.java │ │ └── time │ │ ├── DefaultTimepointLimiterTest.java │ │ └── TimepointTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── wdullaer │ │ │ └── materialdatetimepicker │ │ │ ├── AccessibleLinearLayout.java │ │ │ ├── AccessibleTextView.java │ │ │ ├── GravitySnapHelper.java │ │ │ ├── HapticFeedbackController.java │ │ │ ├── Utils.java │ │ │ ├── VerticalTextView.java │ │ │ ├── date │ │ │ ├── AccessibleDateAnimator.java │ │ │ ├── DatePickerController.java │ │ │ ├── DatePickerDialog.java │ │ │ ├── DateRangeLimiter.java │ │ │ ├── DayOfWeek.java │ │ │ ├── DayPickerGroup.java │ │ │ ├── DayPickerView.java │ │ │ ├── DefaultDateRangeLimiter.java │ │ │ ├── MonthAdapter.java │ │ │ ├── MonthView.java │ │ │ ├── SimpleDayPickerView.java │ │ │ ├── SimpleMonthAdapter.java │ │ │ ├── SimpleMonthView.java │ │ │ ├── TextViewWithCircularIndicator.java │ │ │ └── YearPickerView.java │ │ │ └── time │ │ │ ├── AmPmCirclesView.java │ │ │ ├── CircleView.java │ │ │ ├── DefaultTimepointLimiter.java │ │ │ ├── RadialPickerLayout.java │ │ │ ├── RadialSelectorView.java │ │ │ ├── RadialTextsView.java │ │ │ ├── TimePickerController.java │ │ │ ├── TimePickerDialog.java │ │ │ ├── Timepoint.java │ │ │ └── TimepointLimiter.java │ └── res │ │ ├── color │ │ ├── mdtp_date_picker_selector.xml │ │ ├── mdtp_date_picker_year_selector.xml │ │ ├── mdtp_done_text_color.xml │ │ └── mdtp_done_text_color_dark.xml │ │ ├── drawable-land-v19 │ │ └── mdtp_done_background_color.xml │ │ ├── drawable-land │ │ ├── mdtp_done_background_color.xml │ │ └── mdtp_done_background_color_dark.xml │ │ ├── drawable-v19 │ │ └── mdtp_done_background_color.xml │ │ ├── drawable-v21 │ │ ├── mdtp_material_button_background.xml │ │ ├── mdtp_material_button_selected.xml │ │ └── mdtp_month_arrow_background.xml │ │ ├── drawable │ │ ├── mdtp_done_background_color.xml │ │ ├── mdtp_done_background_color_dark.xml │ │ ├── mdtp_ic_chevron_left_black_24dp.xml │ │ ├── mdtp_ic_chevron_right_black_24dp.xml │ │ ├── mdtp_material_button_background.xml │ │ ├── mdtp_material_button_selected.xml │ │ └── mdtp_month_arrow_background.xml │ │ ├── font │ │ └── robotomedium.ttf │ │ ├── layout-land │ │ ├── mdtp_date_picker_dialog.xml │ │ ├── mdtp_date_picker_dialog_v2.xml │ │ ├── mdtp_date_picker_header_view_v2.xml │ │ ├── mdtp_time_header_label.xml │ │ ├── mdtp_time_picker_dialog.xml │ │ ├── mdtp_time_picker_dialog_v2.xml │ │ └── mdtp_time_title_view_v2.xml │ │ ├── layout-ldrtl │ │ └── mdtp_daypicker_group.xml │ │ ├── layout-sw600dp-land │ │ └── mdtp_date_picker_dialog.xml │ │ ├── layout-sw600dp │ │ └── mdtp_date_picker_dialog.xml │ │ ├── layout-w270dp-h560dp │ │ └── mdtp_date_picker_dialog.xml │ │ ├── layout │ │ ├── mdtp_date_picker_dialog.xml │ │ ├── mdtp_date_picker_dialog_v2.xml │ │ ├── mdtp_date_picker_header_view.xml │ │ ├── mdtp_date_picker_header_view_v2.xml │ │ ├── mdtp_date_picker_selected_date.xml │ │ ├── mdtp_date_picker_selected_date_v2.xml │ │ ├── mdtp_date_picker_view_animator.xml │ │ ├── mdtp_date_picker_view_animator_v2.xml │ │ ├── mdtp_daypicker_group.xml │ │ ├── mdtp_done_button.xml │ │ ├── mdtp_time_header_label.xml │ │ ├── mdtp_time_picker_dialog.xml │ │ ├── mdtp_time_picker_dialog_v2.xml │ │ ├── mdtp_time_title_view.xml │ │ ├── mdtp_time_title_view_v2.xml │ │ └── mdtp_year_label_text_view.xml │ │ ├── values-af │ │ └── strings.xml │ │ ├── values-am │ │ └── strings.xml │ │ ├── values-ar │ │ └── strings.xml │ │ ├── values-bg │ │ └── strings.xml │ │ ├── values-bn-rBD │ │ └── strings.xml │ │ ├── values-ca │ │ └── strings.xml │ │ ├── values-cs │ │ └── strings.xml │ │ ├── values-da │ │ └── strings.xml │ │ ├── values-de │ │ └── strings.xml │ │ ├── values-el │ │ └── strings.xml │ │ ├── values-en-rGB │ │ └── strings.xml │ │ ├── values-en-rIN │ │ └── strings.xml │ │ ├── values-es-rUS │ │ └── strings.xml │ │ ├── values-es │ │ └── strings.xml │ │ ├── values-et-rEE │ │ └── strings.xml │ │ ├── values-eu-rES │ │ └── strings.xml │ │ ├── values-fa │ │ └── strings.xml │ │ ├── values-fi │ │ └── strings.xml │ │ ├── values-fr-rCA │ │ └── strings.xml │ │ ├── values-fr │ │ └── strings.xml │ │ ├── values-gl-rES │ │ └── strings.xml │ │ ├── values-hi │ │ └── strings.xml │ │ ├── values-hr │ │ └── strings.xml │ │ ├── values-hu │ │ └── strings.xml │ │ ├── values-hy-rAM │ │ └── strings.xml │ │ ├── values-in │ │ └── strings.xml │ │ ├── values-is-rIS │ │ └── strings.xml │ │ ├── values-it │ │ └── strings.xml │ │ ├── values-iw │ │ └── strings.xml │ │ ├── values-ja │ │ └── strings.xml │ │ ├── values-ka-rGE │ │ └── strings.xml │ │ ├── values-kk-rKZ │ │ └── strings.xml │ │ ├── values-km-rKH │ │ └── strings.xml │ │ ├── values-kn-rIN │ │ └── strings.xml │ │ ├── values-ko │ │ └── strings.xml │ │ ├── values-ky-rKG │ │ └── strings.xml │ │ ├── values-land │ │ └── dimens.xml │ │ ├── values-lo-rLA │ │ └── strings.xml │ │ ├── values-lt │ │ └── strings.xml │ │ ├── values-lv │ │ └── strings.xml │ │ ├── values-mk-rMK │ │ └── strings.xml │ │ ├── values-ml-rIN │ │ └── strings.xml │ │ ├── values-mn-rMN │ │ └── strings.xml │ │ ├── values-mr-rIN │ │ └── strings.xml │ │ ├── values-ms-rMY │ │ └── strings.xml │ │ ├── values-my-rMM │ │ └── strings.xml │ │ ├── values-nb │ │ └── strings.xml │ │ ├── values-ne-rNP │ │ └── strings.xml │ │ ├── values-nl │ │ └── strings.xml │ │ ├── values-pl │ │ └── strings.xml │ │ ├── values-pt-rPT │ │ └── strings.xml │ │ ├── values-pt │ │ └── strings.xml │ │ ├── values-ro │ │ └── strings.xml │ │ ├── values-ru │ │ └── strings.xml │ │ ├── values-si-rLK │ │ └── strings.xml │ │ ├── values-sk │ │ └── strings.xml │ │ ├── values-sl │ │ └── strings.xml │ │ ├── values-sr │ │ └── strings.xml │ │ ├── values-sv │ │ └── strings.xml │ │ ├── values-sw │ │ └── strings.xml │ │ ├── values-sw600dp-land │ │ └── dimens.xml │ │ ├── values-sw600dp │ │ └── dimens.xml │ │ ├── values-ta-rIN │ │ └── strings.xml │ │ ├── values-te-rIN │ │ └── strings.xml │ │ ├── values-th │ │ └── strings.xml │ │ ├── values-tl │ │ └── strings.xml │ │ ├── values-tr │ │ └── strings.xml │ │ ├── values-uk │ │ └── strings.xml │ │ ├── values-ur-rPK │ │ └── strings.xml │ │ ├── values-uz-rUZ │ │ └── strings.xml │ │ ├── values-v16 │ │ ├── strings.xml │ │ └── styles.xml │ │ ├── values-vi │ │ └── strings.xml │ │ ├── values-w270dp-h560dp │ │ └── dimens.xml │ │ ├── values-w560dp-land │ │ └── dimens.xml │ │ ├── values-zh-rCN │ │ └── strings.xml │ │ ├── values-zh-rHK │ │ └── strings.xml │ │ ├── values-zh-rTW │ │ └── strings.xml │ │ ├── values-zu │ │ └── strings.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── wdullaer │ └── materialdatetimepicker │ ├── date │ ├── DatePickerDialogTest.java │ ├── DefaultDateRangeLimiterPropertyTest.java │ └── DefaultDateRangeLimiterTest.java │ └── time │ ├── DefaultTimepointLimiterTest.java │ ├── TimePickerDialogTest.java │ └── TimepointTest.java ├── licenses ├── android-sdk-license ├── android-sdk-preview-license └── intel-android-extra-license ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── wdullaer │ │ └── datetimepickerexample │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── wdullaer │ │ └── datetimepickerexample │ │ ├── DatePickerFragment.java │ │ ├── MainActivity.java │ │ └── TimePickerFragment.java │ └── res │ ├── layout │ ├── activity_main.xml │ ├── datepicker_layout.xml │ └── timepicker_layout.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── settings.gradle └── supported_languages.txt /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [wdullaer] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # IntelliJ IDEA 19 | .idea/ 20 | *.iml 21 | *.iws 22 | *.ipr 23 | 24 | # Gradle 25 | .gradle 26 | build/ 27 | 28 | # System files 29 | .DS_Store 30 | .directory 31 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: 3 | - oraclejdk8 4 | android: 5 | components: 6 | - tools 7 | - platform-tools 8 | - build-tools-28.0.3 9 | - tools 10 | - android-28 11 | - android-14 12 | - extra-android-m2repository 13 | 14 | before_cache: 15 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 16 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 17 | cache: 18 | directories: 19 | - $HOME/.gradle/caches/ 20 | - $HOME/.gradle/wrapper/ 21 | - $HOME/.android/build-cache 22 | 23 | before_script: 24 | - mkdir "$ANDROID_HOME/licenses" || true 25 | - cp ./licenses/* "$ANDROID_HOME/licenses/" 26 | script: ./gradlew check 27 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.6.3' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | VERSION_NAME=4.2.3 20 | VERSION_CODE=54 21 | GROUP=com.wdullaer 22 | 23 | ANDROID_BUILD_MIN_SDK_VERSION=16 24 | ANDROID_BUILD_TARGET_SDK_VERSION=28 25 | ANDROID_BUILD_SDK_VERSION=28 26 | ANDROID_BUILD_TOOLS_VERSION=28.0.3 27 | 28 | POM_DESCRIPTION=Material DateTimepicker 29 | POM_URL=https://github.com/wdullaer/MaterialDateTimePicker 30 | POM_SCM_URL=https://github.com/wdullaer/MaterialDateTimePicker 31 | POM_SCM_CONNECTION=scm:git@github.com:wdullaer/MaterialDateTimePicker.git 32 | POM_SCM_DEV_CONNECTION=scm:git@github.com:wdullaer/MaterialDateTimePicker.git 33 | POM_LICENCE_NAME=Apache v2 License 34 | POM_LICENCE_URL=https://github.com/wdullaer/MaterialDateTimePicker/blob/master/LICENSE 35 | POM_LICENCE_DIST=repo 36 | POM_DEVELOPER_ID=wdullaer 37 | POM_DEVELOPER_NAME=Wouter Dullaert 38 | 39 | android.useAndroidX=true 40 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdullaer/MaterialDateTimePicker/f849a5c2704c974ba182fe4e2e205fa7f4fd395d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Apr 18 14:00:14 CEST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 5 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 6 | 7 | defaultConfig { 8 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 9 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 10 | versionName project.VERSION_NAME 11 | versionCode Integer.parseInt(project.VERSION_CODE) 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | } 19 | } 20 | 21 | lintOptions { 22 | abortOnError false 23 | } 24 | 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | implementation 'androidx.appcompat:appcompat:1.1.0' 34 | implementation 'androidx.recyclerview:recyclerview:1.1.0' 35 | 36 | testImplementation 'junit:junit:4.13' 37 | testImplementation 'com.pholser:junit-quickcheck-core:0.9.2' 38 | testImplementation 'com.pholser:junit-quickcheck-generators:0.9.1' 39 | 40 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 41 | androidTestImplementation 'androidx.test:runner:1.2.0' 42 | androidTestImplementation 'androidx.test:rules:1.2.0' 43 | } 44 | 45 | apply from: 'gradle-mvn-push.gradle' 46 | -------------------------------------------------------------------------------- /library/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=MaterialDateTimePicker 2 | POM_ARTIFACT_ID=materialdatetimepicker 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /library/src/androidTest/java/com/wdullaer/materialdatetimepicker/time/TimepointTest.java: -------------------------------------------------------------------------------- 1 | package com.wdullaer.materialdatetimepicker.time; 2 | 3 | import android.os.Parcel; 4 | import androidx.test.ext.junit.runners.AndroidJUnit4; 5 | 6 | import static org.junit.Assert.*; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | /** 11 | * Test for Timepoint which need to run on an actual device 12 | * Created by wdullaer on 1/11/17. 13 | */ 14 | @RunWith(AndroidJUnit4.class) 15 | public class TimepointTest { 16 | @Test 17 | public void shouldCorrectlySaveAndRestoreAParcel() { 18 | Timepoint input = new Timepoint(1, 2, 3); 19 | Parcel timepointParcel = Parcel.obtain(); 20 | input.writeToParcel(timepointParcel, 0); 21 | timepointParcel.setDataPosition(0); 22 | 23 | Timepoint output = Timepoint.CREATOR.createFromParcel(timepointParcel); 24 | assertEquals(input.getHour(), output.getHour()); 25 | assertEquals(input.getMinute(), output.getMinute()); 26 | assertEquals(input.getSecond(), output.getSecond()); 27 | } 28 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/AccessibleLinearLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.wdullaer.materialdatetimepicker; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | import android.view.accessibility.AccessibilityEvent; 22 | import android.view.accessibility.AccessibilityNodeInfo; 23 | import android.widget.Button; 24 | import android.widget.LinearLayout; 25 | 26 | /** 27 | * Fake Button class, used so TextViews can announce themselves as Buttons, for accessibility. 28 | */ 29 | public class AccessibleLinearLayout extends LinearLayout { 30 | 31 | public AccessibleLinearLayout(Context context, AttributeSet attrs) { 32 | super(context, attrs); 33 | } 34 | 35 | @Override 36 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { 37 | super.onInitializeAccessibilityEvent(event); 38 | event.setClassName(Button.class.getName()); 39 | } 40 | 41 | @Override 42 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { 43 | super.onInitializeAccessibilityNodeInfo(info); 44 | info.setClassName(Button.class.getName()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/AccessibleTextView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.wdullaer.materialdatetimepicker; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | import android.view.accessibility.AccessibilityEvent; 22 | import android.view.accessibility.AccessibilityNodeInfo; 23 | import android.widget.Button; 24 | 25 | /** 26 | * Fake Button class, used so TextViews can announce themselves as Buttons, for accessibility. 27 | */ 28 | public class AccessibleTextView extends androidx.appcompat.widget.AppCompatTextView { 29 | 30 | public AccessibleTextView(Context context, AttributeSet attrs) { 31 | super(context, attrs); 32 | } 33 | 34 | @Override 35 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { 36 | super.onInitializeAccessibilityEvent(event); 37 | event.setClassName(Button.class.getName()); 38 | } 39 | 40 | @Override 41 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { 42 | super.onInitializeAccessibilityNodeInfo(info); 43 | info.setClassName(Button.class.getName()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/VerticalTextView.java: -------------------------------------------------------------------------------- 1 | package com.wdullaer.materialdatetimepicker; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.text.TextPaint; 6 | import android.util.AttributeSet; 7 | import android.view.Gravity; 8 | 9 | /** 10 | * TextView that renders it's contents vertically. (Just using rotate doesn't work because onMeasure 11 | * happens before the View is rotated causing incorrect View boundaries) 12 | * Created by wdullaer on 28/03/16. 13 | */ 14 | public class VerticalTextView extends androidx.appcompat.widget.AppCompatTextView { 15 | final boolean topDown; 16 | 17 | public VerticalTextView(Context context, AttributeSet attrs){ 18 | super(context, attrs); 19 | final int gravity = getGravity(); 20 | if (Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { 21 | setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); 22 | topDown = false; 23 | } else { 24 | topDown = true; 25 | } 26 | } 27 | 28 | @Override 29 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ 30 | //noinspection SuspiciousNameCombination 31 | super.onMeasure(heightMeasureSpec, widthMeasureSpec); 32 | setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); 33 | } 34 | 35 | @Override 36 | protected void onDraw(Canvas canvas){ 37 | TextPaint textPaint = getPaint(); 38 | textPaint.setColor(getCurrentTextColor()); 39 | textPaint.drawableState = getDrawableState(); 40 | 41 | canvas.save(); 42 | 43 | if (topDown){ 44 | canvas.translate(getWidth(), 0); 45 | canvas.rotate(90); 46 | } else { 47 | canvas.translate(0, getHeight()); 48 | canvas.rotate(-90); 49 | } 50 | 51 | 52 | canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop()); 53 | 54 | getLayout().draw(canvas); 55 | canvas.restore(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/date/AccessibleDateAnimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.wdullaer.materialdatetimepicker.date; 18 | 19 | import android.content.Context; 20 | import android.text.format.DateUtils; 21 | import android.util.AttributeSet; 22 | import android.view.accessibility.AccessibilityEvent; 23 | import android.widget.ViewAnimator; 24 | 25 | public class AccessibleDateAnimator extends ViewAnimator { 26 | private long mDateMillis; 27 | 28 | public AccessibleDateAnimator(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | } 31 | 32 | public void setDateMillis(long dateMillis) { 33 | mDateMillis = dateMillis; 34 | } 35 | 36 | /** 37 | * Announce the currently-selected date when launched. 38 | */ 39 | @Override 40 | public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { 41 | if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { 42 | // Clear the event's current text so that only the current date will be spoken. 43 | event.getText().clear(); 44 | int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | 45 | DateUtils.FORMAT_SHOW_WEEKDAY; 46 | 47 | String dateString = DateUtils.formatDateTime(getContext(), mDateMillis, flags); 48 | event.getText().add(dateString); 49 | return true; 50 | } 51 | return super.dispatchPopulateAccessibilityEvent(event); 52 | } 53 | } -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/date/DatePickerController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.wdullaer.materialdatetimepicker.date; 18 | 19 | import java.util.Calendar; 20 | import java.util.Locale; 21 | import java.util.TimeZone; 22 | 23 | /** 24 | * Controller class to communicate among the various components of the date picker dialog. 25 | */ 26 | public interface DatePickerController { 27 | 28 | void onYearSelected(int year); 29 | 30 | void onDayOfMonthSelected(int year, int month, int day); 31 | 32 | void registerOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener); 33 | 34 | @SuppressWarnings("unused") 35 | void unregisterOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener); 36 | 37 | MonthAdapter.CalendarDay getSelectedDay(); 38 | 39 | boolean isThemeDark(); 40 | 41 | int getAccentColor(); 42 | 43 | boolean isHighlighted(int year, int month, int day); 44 | 45 | int getFirstDayOfWeek(); 46 | 47 | int getMinYear(); 48 | 49 | int getMaxYear(); 50 | 51 | Calendar getStartDate(); 52 | 53 | Calendar getEndDate(); 54 | 55 | boolean isOutOfRange(int year, int month, int day); 56 | 57 | void tryVibrate(); 58 | 59 | TimeZone getTimeZone(); 60 | 61 | Locale getLocale(); 62 | 63 | DatePickerDialog.Version getVersion(); 64 | 65 | DatePickerDialog.ScrollOrientation getScrollOrientation(); 66 | } 67 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/date/DayOfWeek.java: -------------------------------------------------------------------------------- 1 | package com.wdullaer.materialdatetimepicker.date; 2 | 3 | public enum DayOfWeek { 4 | } 5 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/date/SimpleDayPickerView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.wdullaer.materialdatetimepicker.date; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | 22 | /** 23 | * A DayPickerView customized for {@link SimpleMonthAdapter} 24 | */ 25 | public class SimpleDayPickerView extends DayPickerView { 26 | 27 | public SimpleDayPickerView(Context context, AttributeSet attrs) { 28 | super(context, attrs); 29 | } 30 | 31 | public SimpleDayPickerView(Context context, DatePickerController controller) { 32 | super(context, controller); 33 | } 34 | 35 | @Override 36 | public MonthAdapter createMonthAdapter(DatePickerController controller) { 37 | return new SimpleMonthAdapter(controller); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/date/SimpleMonthAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.wdullaer.materialdatetimepicker.date; 18 | 19 | import android.content.Context; 20 | 21 | /** 22 | * An adapter for a list of {@link SimpleMonthView} items. 23 | */ 24 | public class SimpleMonthAdapter extends MonthAdapter { 25 | 26 | public SimpleMonthAdapter(DatePickerController controller) { 27 | super(controller); 28 | } 29 | 30 | @Override 31 | public MonthView createMonthView(Context context) { 32 | return new SimpleMonthView(context, null, mController); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /library/src/main/java/com/wdullaer/materialdatetimepicker/time/TimePickerController.java: -------------------------------------------------------------------------------- 1 | package com.wdullaer.materialdatetimepicker.time; 2 | 3 | /** 4 | * A collection of methods which need to be shared with all components of the TimePicker 5 | * 6 | * Created by wdullaer on 6/10/15. 7 | */ 8 | interface TimePickerController { 9 | /** 10 | * @return boolean - true if the dark theme should be used 11 | */ 12 | boolean isThemeDark(); 13 | 14 | /** 15 | * @return boolean - true if 24 hour mode is used / false if AM/PM is used 16 | */ 17 | boolean is24HourMode(); 18 | 19 | /** 20 | * @return int - the accent color currently in use 21 | */ 22 | int getAccentColor(); 23 | 24 | /** 25 | * @return Version - The current version to render 26 | */ 27 | TimePickerDialog.Version getVersion(); 28 | 29 | /** 30 | * Request the device to vibrate 31 | */ 32 | void tryVibrate(); 33 | 34 | /** 35 | * @param time Timepoint - the selected point in time 36 | * @param index int - The current view to consider when calculating the range 37 | * @return boolean - true if this is not a selectable value 38 | */ 39 | boolean isOutOfRange(Timepoint time, int index); 40 | 41 | /** 42 | * @return boolean - true if AM times are outside the range of valid selections 43 | */ 44 | boolean isAmDisabled(); 45 | 46 | /** 47 | * @return boolean - true if PM times are outside the range of valid selections 48 | */ 49 | boolean isPmDisabled(); 50 | 51 | /** 52 | * Will round the given Timepoint to the nearest valid Timepoint given the following restrictions: 53 | * - TYPE.HOUR, it will just round to the next valid point, possible adjusting minutes and seconds 54 | * - TYPE.MINUTE, it will round to the next valid point, without adjusting the hour, but possibly adjusting the seconds 55 | * - TYPE.SECOND, it will round to the next valid point, only adjusting the seconds 56 | * @param time Timepoint - the timepoint to validate 57 | * @param type Timepoint.TYPE - whether we should round the hours, minutes or seconds 58 | * @return timepoint - the nearest valid timepoint 59 | */ 60 | Timepoint roundToNearest(Timepoint time, Timepoint.TYPE type); 61 | } 62 | -------------------------------------------------------------------------------- /library/src/main/res/color/mdtp_date_picker_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | -------------------------------------------------------------------------------- /library/src/main/res/color/mdtp_date_picker_year_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | -------------------------------------------------------------------------------- /library/src/main/res/color/mdtp_done_text_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/color/mdtp_done_text_color_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-land-v19/mdtp_done_background_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-land/mdtp_done_background_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-land/mdtp_done_background_color_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-v19/mdtp_done_background_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-v21/mdtp_material_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-v21/mdtp_material_button_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-v21/mdtp_month_arrow_background.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_done_background_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_done_background_color_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_ic_chevron_left_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_ic_chevron_right_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_material_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_material_button_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/mdtp_month_arrow_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/res/font/robotomedium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdullaer/MaterialDateTimePicker/f849a5c2704c974ba182fe4e2e205fa7f4fd395d/library/src/main/res/font/robotomedium.ttf -------------------------------------------------------------------------------- /library/src/main/res/layout-land/mdtp_date_picker_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 28 | 29 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /library/src/main/res/layout-land/mdtp_date_picker_dialog_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /library/src/main/res/layout-land/mdtp_date_picker_header_view_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /library/src/main/res/layout-land/mdtp_time_title_view_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /library/src/main/res/layout-ldrtl/mdtp_daypicker_group.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 15 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/layout-sw600dp-land/mdtp_date_picker_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /library/src/main/res/layout-sw600dp/mdtp_date_picker_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /library/src/main/res/layout-w270dp-h560dp/mdtp_date_picker_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_date_picker_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 23 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_date_picker_dialog_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_date_picker_header_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 28 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_date_picker_header_view_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_date_picker_view_animator.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 19 | 28 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_date_picker_view_animator_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 19 | 26 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_daypicker_group.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 15 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/layout/mdtp_done_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 25 | 26 |