Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Fix Issues #2036 and #1973: Changed currentDate comparisons to minDate and maxDate to be inclusive #2043

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
181ab1a
Update DATETIME.md (#1950)
Mauker1 Feb 18, 2020
8e5d64f
Merge branch 'master' of github.com:afollestad/material-dialogs
afollestad Feb 18, 2020
02529dd
Release 3.3.0
afollestad Feb 18, 2020
c10f3e2
Readme: update dependencies declarations to 3.3.0 (#1951)
enricocid Feb 18, 2020
11e4dfc
Expose maxDateTime for DateTimePicker (#1952)
utkukutlu Feb 18, 2020
9c20855
Delete .travis.yml
afollestad Feb 20, 2020
c6058f9
Replace travis.ci badge with an Actions one
afollestad Feb 20, 2020
fe84774
Update android.yml
afollestad Feb 24, 2020
be74a35
Set hint on TextInputLayout (#1962)
mwajeeh Mar 12, 2020
73e8474
Resolves #1961, allow choice list control color to be changed program…
shynline Apr 6, 2020
66582d9
Update INPUT.md (#1982)
Mauker1 Apr 23, 2020
c66e58e
Resolve #2011 (#2015)
anggrayudi Sep 2, 2020
818f209
Update Feature_request.md
afollestad Sep 3, 2020
399c293
Update Bug_report.md
afollestad Sep 3, 2020
633d835
Delete FUNDING.yml
afollestad Sep 3, 2020
82298ce
Update README.md
afollestad Sep 3, 2020
5cc7db0
Update image URLs for main branch change in README
afollestad Sep 3, 2020
79b2ee4
Update BOTTOMSHEETS.md
afollestad Sep 3, 2020
72c1845
Update COLOR.md
afollestad Sep 3, 2020
eeea783
Update CORE.md
afollestad Sep 3, 2020
2ab205f
Update DATETIME.md
afollestad Sep 3, 2020
e396bdc
Update FILES.md
afollestad Sep 3, 2020
165eb41
Update INPUT.md
afollestad Sep 3, 2020
741b3a5
Added Support for Multiline Input Fields of a designated line height
gobrien37 Dec 11, 2020
f5046b3
Addresses Issue #2018: Added support for multi-line input fields of a…
gobrien37 Dec 11, 2020
6babd28
Changed min and max date comparison to be inclusive with respect to c…
gobrien37 Dec 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ labels: bug

---

*Please consider making a Pull Request if you are capable of doing so.*
*Please consider making a Pull Request if you are capable of doing so. Note that versions before 2.0.0 are no longer supported.*

**Library Version:**

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ labels: improvement

---

*Please consider making a Pull Request if you are capable of doing so.*
*Please consider making a Pull Request if you are capable of doing so. Note that versions before 2.0.0 are no longer supported.*

**What module does this apply to?**

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build check
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

#### [View Releases and Changelogs](https://github.com/afollestad/material-dialogs/releases)

[![Build Status](https://travis-ci.org/afollestad/material-dialogs.svg)](https://travis-ci.org/afollestad/material-dialogs)
[![Android CI](https://github.com/afollestad/material-dialogs/workflows/Android%20CI/badge.svg)](https://github.com/afollestad/material-dialogs/actions?query=workflow%3A%22Android+CI%22)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0a4acc30a9ce440087f7688735359bb8)](https://www.codacy.com/app/drummeraidan_50/material-dialogs?utm_source=github.com&utm_medium=referral&utm_content=afollestad/material-dialogs&utm_campaign=Badge_Grade)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

---

![Showcase](https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/showcase4.png)
![Showcase](https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/showcase4.png)

# Modules

The core module is the fundamental module that you need in order to use this library. The others
are extensions to core.

Please note that since Material Dialogs 2.x.x, this library only supports Kotlin. The latest Java version is `0.9.6.0` and can be found [here](README_OLD.md). Note that 0.9.6.0 is unsupported, bugs & improvements will not be made to that version.

## Core

[ ![Core](https://api.bintray.com/packages/drummer-aidan/maven/material-dialogs%3Acore/images/download.svg) ](https://bintray.com/drummer-aidan/maven/material-dialogs%3Acore/_latestVersion)
Expand All @@ -24,12 +26,12 @@ are extensions to core.
The `core` module contains everything you need to get started with the library. It contains all
core and normal-use functionality.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/basic_with_buttons.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/basic_with_buttons.png" width="250px" />

```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:core:3.2.1'
implementation 'com.afollestad.material-dialogs:core:3.3.0'
}
```

Expand All @@ -41,12 +43,12 @@ dependencies {

The `input` module contains extensions to the core module, such as a text input dialog.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/input.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/input.png" width="250px" />

```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:input:3.2.1'
implementation 'com.afollestad.material-dialogs:input:3.3.0'
}
```

Expand All @@ -58,12 +60,12 @@ dependencies {

The `files` module contains extensions to the core module, such as a file and folder chooser.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/file_chooser.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/file_chooser.png" width="250px" />

```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:files:3.2.1'
implementation 'com.afollestad.material-dialogs:files:3.3.0'
}
```

Expand All @@ -75,12 +77,12 @@ dependencies {

The `color` module contains extensions to the core module, such as a color chooser.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/color_chooser.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/color_chooser.png" width="250px" />

```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:color:3.2.1'
implementation 'com.afollestad.material-dialogs:color:3.3.0'
}
```

Expand All @@ -92,12 +94,12 @@ dependencies {

The `datetime` module contains extensions to make date, time, and date-time picker dialogs.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/datetimepicker.png" width="500px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/datetimepicker.png" width="500px" />

```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:datetime:3.2.1'
implementation 'com.afollestad.material-dialogs:datetime:3.3.0'
}
```

Expand All @@ -111,12 +113,12 @@ The `bottomsheets` module contains extensions to turn modal dialogs into bottom
other functionality like showing a grid of items. Be sure to checkout the sample project for this,
too!

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/bottomsheet_customview.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/bottomsheet_customview.png" width="250px" />

```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:bottomsheets:3.2.1'
implementation 'com.afollestad.material-dialogs:bottomsheets:3.3.0'
}
```

Expand All @@ -131,6 +133,6 @@ The `lifecycle` module contains extensions to make dialogs work with AndroidX li
```gradle
dependencies {
...
implementation 'com.afollestad.material-dialogs:lifecycle:3.2.1'
implementation 'com.afollestad.material-dialogs:lifecycle:3.3.0'
}
```
28 changes: 12 additions & 16 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
3.2.1

* Fixed the module-name given to the Kotlin compiler for each Gradle module, should fix
extension function resolution issues.

---

3.2.0

* Dependency upgrades.
* Reduce single/multi choice list dialog margin between text and controls.
* Fix `updateTextColor(Int)` on action buttons not always persisting. See #1783.
* Fix corner radius not working when views have a background. See #1840.
* All dialogs will have a default corner radius of 4dp. See #1909.
* Non-cancelable bottom sheet dialogs cannot be swiped to dismiss.
* Other minor changes.
3.3.0

* Added `md_line_spacing_body` global theme attribute, which sets a global default for message line
spacing. See #1903.
* Added some assertions and sanity checks to avoid choice list adapter out of bounds crashes.
See #1906.
* Corner radius should not apply to the bottom of bottom sheet dialogs. See #1941.
* Fix dialog titles being cut off with custom fonts. See #1936.
* If `noVerticalPadding` is set with `customView(...)``, padding is not applied to the bottom of
the content `ScrollView` if `scrollable` is enabled. Resolves #1834.
* Input dialog styling is not enforced by the dialog. The global default for `TextInputLayout`
(`textInputStyle`) is used instead. See #1857.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.view.View
import android.view.View.OnClickListener
import android.view.ViewGroup
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.appcompat.widget.AppCompatRadioButton
import androidx.core.widget.CompoundButtonCompat
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -72,7 +73,9 @@ internal class SingleChoiceDialogAdapter(
disabledItems: IntArray?,
initialSelection: Int,
private val waitForActionButton: Boolean,
internal var selection: SingleChoiceListener
internal var selection: SingleChoiceListener,
@ColorInt private val checkedColor: Int,
@ColorInt private val uncheckedColor: Int
) : RecyclerView.Adapter<SingleChoiceViewHolder>(),
DialogAdapter<CharSequence, SingleChoiceListener> {

Expand Down Expand Up @@ -117,7 +120,10 @@ internal class SingleChoiceDialogAdapter(
.let {
CompoundButtonCompat.setButtonTintList(
viewHolder.controlView,
createColorSelector(dialog.windowContext, checked = it[0], unchecked = it[1])
createColorSelector(dialog.windowContext,
checked = if (checkedColor == -1) it[0] else checkedColor,
unchecked = if (uncheckedColor == -1) it[1] else uncheckedColor
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.afollestad.materialdialogs.list
import android.util.Log
import androidx.annotation.ArrayRes
import androidx.annotation.CheckResult
import androidx.annotation.ColorInt
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.WhichButton.POSITIVE
import com.afollestad.materialdialogs.actions.setActionButtonEnabled
Expand All @@ -42,6 +43,8 @@ import com.afollestad.materialdialogs.utils.MDUtil.getStringArray
disabledIndices: IntArray? = null,
initialSelection: Int = -1,
waitForPositiveButton: Boolean = true,
@ColorInt checkedColor: Int = -1,
@ColorInt uncheckedColor: Int = -1,
selection: SingleChoiceListener = null
): MaterialDialog {
assertOneSet("listItemsSingleChoice", items, res)
Expand Down Expand Up @@ -72,7 +75,9 @@ import com.afollestad.materialdialogs.utils.MDUtil.getStringArray
disabledItems = disabledIndices,
initialSelection = initialSelection,
waitForActionButton = waitForPositiveButton,
selection = selection
selection = selection,
checkedColor = checkedColor,
uncheckedColor = uncheckedColor
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fun MaterialDialog.datePicker(
dialogWrapContent = windowContext.isLandscape()
)

check(minDate == null || currentDate == null || minDate.before(currentDate)) {
"Your `minDate` must be less than `currentDate`."
check(minDate == null || currentDate == null || !minDate.after(currentDate)) {
"Your `minDate` cannot be greater than `currentDate`."
}
check(maxDate == null || currentDate == null || maxDate.after(currentDate)) {
"Your `maxDate` must be bigger than `currentDate`."
check(maxDate == null || currentDate == null || !maxDate.before(currentDate)) {
"Your `maxDate` cannot be less than `currentDate`."
}

getDatePicker().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typealias DateTimeCallback = ((dialog: MaterialDialog, datetime: Calendar) -> Un
*/
fun MaterialDialog.dateTimePicker(
minDateTime: Calendar? = null,
maxDateTime: Calendar? = null,
currentDateTime: Calendar? = null,
requireFutureDateTime: Boolean = false,
show24HoursView: Boolean = false,
Expand All @@ -68,6 +69,7 @@ fun MaterialDialog.dateTimePicker(

getDatePicker().apply {
minDateTime?.let { setMinDate(it) }
maxDateTime?.let { setMaxDate(it) }
currentDateTime?.let { setDate(it) }
addOnDateChanged { previous, date ->
val futureTime = isFutureTime(getDatePicker(), getTimePicker())
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ext.versions = [
min_sdk: 16,
compile_sdk: 29,
build_tools: "29.0.0",
publish_version: "3.2.1",
publish_version_code: 261
publish_version: "3.3.0",
publish_version_code: 262
]

ext.deps = [
Expand Down
2 changes: 1 addition & 1 deletion documentation/BOTTOMSHEETS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ If you've used Android bottom sheets before, peek height should be a familiar co
height is the height of the bottom sheet when it's not fully expanded. It's a point between
expanded and hidden.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/bottomsheet_peekheight.gif" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/bottomsheet_peekheight.gif" width="250px" />

The default peek height is 60% of the screen height. You can set a custom peek height if you wish:

Expand Down
8 changes: 4 additions & 4 deletions documentation/COLOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {

Color choosers show a simple grid of colors.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/color_chooser.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/color_chooser.png" width="250px" />

```kotlin
val colors = intArrayOf(RED, GREEN, BLUE)
Expand Down Expand Up @@ -59,7 +59,7 @@ MaterialDialog(this).show {
You can specify sub-colors, which are a level down from each top level color. The size of the top
level array must match the size of the sub-colors array.

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/color_chooser_sub.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/color_chooser_sub.png" width="250px" />

```kotlin
val colors = intArrayOf(RED, GREEN, BLUE) // size = 3
Expand All @@ -81,7 +81,7 @@ MaterialDialog(this).show {

### ARGB Selection

<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/master/art/custom_argb.png" width="250px" />
<img src="https://raw.githubusercontent.com/afollestad/material-dialogs/main/art/custom_argb.png" width="250px" />

```kotlin
MaterialDialog(this).show {
Expand All @@ -98,4 +98,4 @@ MaterialDialog(this).show {
}
```

Omitting `showAlphaSelector` will hide the alpha (transparency) selector.
Omitting `showAlphaSelector` will hide the alpha (transparency) selector.