diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 8d1133318..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: afollestad -ko_fi: afollestad diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index f49c32f60..9afb5bc4e 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -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:** diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index 711e88113..f3f42fdc5 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -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?** diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3071e5de4..889022aab 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -14,4 +14,4 @@ jobs: with: java-version: 1.8 - name: Build with Gradle - run: ./gradlew build + run: ./gradlew build check diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index aa5ed12ec..000000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: android -dist: trusty -android: - components: - - tools - - platform-tools - - build-tools-29.0.0 - - android-29 - - extra-android-support - - extra-android-m2repository - - extra-google-m2repository - - # Additional components - #- extra-google-google_play_services - #- addon-google_apis-google-19 - - # Specify at least one system image, if you need to run emulator(s) during your tests - #- sys-img-armeabi-v7a-android-19 - #- sys-img-x86-android-17 - - licenses: - - '.+' diff --git a/README.md b/README.md index 4b1ae6a13..1e97ab161 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. - + ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:core:3.2.1' + implementation 'com.afollestad.material-dialogs:core:3.3.0' } ``` @@ -41,12 +43,12 @@ dependencies { The `input` module contains extensions to the core module, such as a text input dialog. - + ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:input:3.2.1' + implementation 'com.afollestad.material-dialogs:input:3.3.0' } ``` @@ -58,12 +60,12 @@ dependencies { The `files` module contains extensions to the core module, such as a file and folder chooser. - + ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:files:3.2.1' + implementation 'com.afollestad.material-dialogs:files:3.3.0' } ``` @@ -75,12 +77,12 @@ dependencies { The `color` module contains extensions to the core module, such as a color chooser. - + ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:color:3.2.1' + implementation 'com.afollestad.material-dialogs:color:3.3.0' } ``` @@ -92,12 +94,12 @@ dependencies { The `datetime` module contains extensions to make date, time, and date-time picker dialogs. - + ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:datetime:3.2.1' + implementation 'com.afollestad.material-dialogs:datetime:3.3.0' } ``` @@ -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! - + ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:bottomsheets:3.2.1' + implementation 'com.afollestad.material-dialogs:bottomsheets:3.3.0' } ``` @@ -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' } ``` diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5fb398668..b5b361cdd 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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. \ No newline at end of file diff --git a/bottomsheets/src/main/java/com/afollestad/materialdialogs/bottomsheets/Util.kt b/bottomsheets/src/main/java/com/afollestad/materialdialogs/bottomsheets/Util.kt index e63db24df..842b169e4 100644 --- a/bottomsheets/src/main/java/com/afollestad/materialdialogs/bottomsheets/Util.kt +++ b/bottomsheets/src/main/java/com/afollestad/materialdialogs/bottomsheets/Util.kt @@ -33,7 +33,7 @@ internal fun BottomSheetBehavior<*>.setCallbacks( onSlide: (currentHeight: Int) -> Unit, onHide: () -> Unit ) { - setBottomSheetCallback(object : BottomSheetCallback() { + addBottomSheetCallback(object : BottomSheetCallback() { private var currentState: Int = STATE_COLLAPSED override fun onSlide( diff --git a/core/src/main/java/com/afollestad/materialdialogs/internal/list/SingleChoiceDialogAdapter.kt b/core/src/main/java/com/afollestad/materialdialogs/internal/list/SingleChoiceDialogAdapter.kt index 796ac027f..ac6916e97 100644 --- a/core/src/main/java/com/afollestad/materialdialogs/internal/list/SingleChoiceDialogAdapter.kt +++ b/core/src/main/java/com/afollestad/materialdialogs/internal/list/SingleChoiceDialogAdapter.kt @@ -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 @@ -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(), DialogAdapter { @@ -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 + ) ) } diff --git a/core/src/main/java/com/afollestad/materialdialogs/list/DialogSingleChoiceExt.kt b/core/src/main/java/com/afollestad/materialdialogs/list/DialogSingleChoiceExt.kt index 9c1ff11c9..1dcf35e92 100644 --- a/core/src/main/java/com/afollestad/materialdialogs/list/DialogSingleChoiceExt.kt +++ b/core/src/main/java/com/afollestad/materialdialogs/list/DialogSingleChoiceExt.kt @@ -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 @@ -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) @@ -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 ) ) } diff --git a/datetime/src/main/java/com/afollestad/materialdialogs/datetime/DateTimePickerExt.kt b/datetime/src/main/java/com/afollestad/materialdialogs/datetime/DateTimePickerExt.kt index 45a3b739a..81828c7ad 100644 --- a/datetime/src/main/java/com/afollestad/materialdialogs/datetime/DateTimePickerExt.kt +++ b/datetime/src/main/java/com/afollestad/materialdialogs/datetime/DateTimePickerExt.kt @@ -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, @@ -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()) diff --git a/dependencies.gradle b/dependencies.gradle index f08bed9fb..647896731 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -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 = [ diff --git a/documentation/BOTTOMSHEETS.md b/documentation/BOTTOMSHEETS.md index 86d315864..fec2b0740 100644 --- a/documentation/BOTTOMSHEETS.md +++ b/documentation/BOTTOMSHEETS.md @@ -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. - + The default peek height is 60% of the screen height. You can set a custom peek height if you wish: diff --git a/documentation/COLOR.md b/documentation/COLOR.md index 9811d82be..5c329864c 100644 --- a/documentation/COLOR.md +++ b/documentation/COLOR.md @@ -26,7 +26,7 @@ dependencies { Color choosers show a simple grid of colors. - + ```kotlin val colors = intArrayOf(RED, GREEN, BLUE) @@ -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. - + ```kotlin val colors = intArrayOf(RED, GREEN, BLUE) // size = 3 @@ -81,7 +81,7 @@ MaterialDialog(this).show { ### ARGB Selection - + ```kotlin MaterialDialog(this).show { @@ -98,4 +98,4 @@ MaterialDialog(this).show { } ``` -Omitting `showAlphaSelector` will hide the alpha (transparency) selector. \ No newline at end of file +Omitting `showAlphaSelector` will hide the alpha (transparency) selector. diff --git a/documentation/CORE.md b/documentation/CORE.md index 097ae9ad6..ccbdcabe9 100644 --- a/documentation/CORE.md +++ b/documentation/CORE.md @@ -44,7 +44,7 @@ dependencies { Here's a very basic example of creating and showing a dialog: - + ```kotlin MaterialDialog(this).show { @@ -99,7 +99,7 @@ MaterialDialog(this).show { There are simple methods for adding action buttons: - + ```kotlin MaterialDialog(this).show { @@ -135,13 +135,13 @@ MaterialDialog(this).show { If action buttons together are too long to fit in the dialog's width, they will be automatically stacked: - + ## Adding an Icon You can display an icon to the left of the title: - + ```kotlin MaterialDialog(this).show { @@ -198,7 +198,7 @@ MaterialDialog(this).show { You can show lists using the `listItems` extension on `MaterialDialog`: - + ```kotlin MaterialDialog(this).show { @@ -231,7 +231,7 @@ MaterialDialog(this).show { You can show single choice (radio button) lists using the `listItemsSingleChoice` extension on `MaterialDialog`: - + ```kotlin MaterialDialog(this).show { @@ -314,7 +314,7 @@ val checked: Boolean = dialog.isItemChecked(index) You can show multiple choice (checkbox) lists using the `listItemsMultiChoice` extension on `MaterialDialog`: - + ```kotlin MaterialDialog(this).show { @@ -437,7 +437,7 @@ val recyclerView: RecyclerView = dialog.getRecyclerView() Checkbox prompts can be used together with any other dialog type, it gets shown in the same view which shows the action buttons. - + ```kotlin MaterialDialog(this).show { @@ -482,7 +482,7 @@ MaterialDialog(this).show { A lot of the included extensions use custom views, such as the color chooser dialog. There's also a simple example in the sample project. - + ```kotlin MaterialDialog(this).show { @@ -543,7 +543,7 @@ change fonts, corner rounding, etc. Light and dark theming is automatic based on your app's theme (basically whether `android:textColorPrimary` is more light or more dark): - + ### Background Color @@ -561,7 +561,7 @@ theme for the ripple color of list items, buttons, etc. by default. You can over Corner radius is the rounding of dialog corners: - + it can be changed with an attribute in your app theme. It defaults to 4dp: @@ -618,4 +618,4 @@ using attributes in your app's theme. See the "Custom Theme" example in the sample project (open the overflow menu for the theme switcher). - + diff --git a/documentation/DATETIME.md b/documentation/DATETIME.md index 0008e9ca3..38d7ce5b9 100644 --- a/documentation/DATETIME.md +++ b/documentation/DATETIME.md @@ -22,7 +22,7 @@ dependencies { ## Date - + ```kotlin MaterialDialog(this).show { @@ -33,11 +33,11 @@ MaterialDialog(this).show { } ``` -You can optionally provide `minDate` and `currentDate` parameters as well. +You can optionally provide `minDate`, `maxDate` and `currentDate` parameters as well. ## Time - + ```kotlin MaterialDialog(this).show { @@ -52,7 +52,7 @@ You can optionally provide `currentTime` and `show24HoursView` parameters as wel ## DateTime - + ```kotlin MaterialDialog(this).show { @@ -63,5 +63,5 @@ MaterialDialog(this).show { } ``` -You can optionally provide `minDateTime`, `currentDateTime`, `show24HoursView`, -and `requireFutureDateTime` parameters as well. \ No newline at end of file +You can optionally provide `minDateTime`, `maxDate`, `currentDateTime`, `show24HoursView`, +and `requireFutureDateTime` parameters as well. diff --git a/documentation/FILES.md b/documentation/FILES.md index 1eac899dd..6fad288cf 100644 --- a/documentation/FILES.md +++ b/documentation/FILES.md @@ -36,7 +36,7 @@ directory listings will come back empty. You create file choosers using the `fileChooser` extension on `MaterialDialog`: - + ```kotlin MaterialDialog(this).show { @@ -83,7 +83,7 @@ MaterialDialog(this).show { Empty text is shown when a folder has no contents. You can configure the empty text label: - + ```kotlin MaterialDialog(this).show { @@ -95,7 +95,7 @@ MaterialDialog(this).show { ### Folder Creation - + You can allow your users to create folders. @@ -151,7 +151,7 @@ MaterialDialog(this).show { Empty text is shown when a folder has no contents. You can configure the empty text label: - + ```kotlin MaterialDialog(this).show { @@ -163,7 +163,7 @@ MaterialDialog(this).show { ### Folder Creation - + You can allow your users to create folders. @@ -178,4 +178,4 @@ MaterialDialog(this).show { } ``` -This "New Folder" option is only show in directories which are writable. \ No newline at end of file +This "New Folder" option is only show in directories which are writable. diff --git a/documentation/INPUT.md b/documentation/INPUT.md index 181e3e482..cc7ab4e89 100644 --- a/documentation/INPUT.md +++ b/documentation/INPUT.md @@ -19,7 +19,7 @@ The `input` module contains extensions to the core module, such as a text input ```gradle dependencies { ... - implementation 'com.afollestad.material-dialogs:input:3.2.1' + implementation 'com.afollestad.material-dialogs:input:3.3.0' } ``` @@ -29,7 +29,7 @@ dependencies { You can setup an input dialog using the `input` extension on `MaterialDialog`: - + ```kotlin MaterialDialog(this).show { @@ -138,7 +138,7 @@ MaterialDialog(this).show { You can set a max length which makes a character counter visible, and disables the positive action button if the input length goes over that: - + ```kotlin MaterialDialog(this).show { diff --git a/input/src/main/java/com/afollestad/materialdialogs/input/DialogInputExt.kt b/input/src/main/java/com/afollestad/materialdialogs/input/DialogInputExt.kt index aa6c6d2f6..678010283 100644 --- a/input/src/main/java/com/afollestad/materialdialogs/input/DialogInputExt.kt +++ b/input/src/main/java/com/afollestad/materialdialogs/input/DialogInputExt.kt @@ -159,7 +159,7 @@ private fun MaterialDialog.styleInput( val resources = windowContext.resources val editText = getInputField() - editText.hint = hint ?: if (hintRes != null) resources.getString(hintRes) else null + getInputLayout().hint = hint ?: if (hintRes != null) resources.getString(hintRes) else null editText.inputType = inputType editText.maybeSetTextColor( windowContext, diff --git a/sample/sample.apk b/sample/sample.apk index daf257823..8ad269bad 100644 Binary files a/sample/sample.apk and b/sample/sample.apk differ diff --git a/sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.kt b/sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.kt index 842197c29..f2ccecd02 100644 --- a/sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.kt +++ b/sample/src/main/java/com/afollestad/materialdialogssample/MainActivity.kt @@ -333,6 +333,20 @@ class MainActivity : AppCompatActivity() { } } + R.id.single_choice_custom_radio_color.onClickDebounced { + MaterialDialog(this).show { + title(R.string.socialNetworks) + listItemsSingleChoice( + R.array.socialNetworks, initialSelection = 1, checkedColor = Color.RED, uncheckedColor = Color.CYAN + ) { _, index, text -> + toast("Selected item $text at index $index") + } + positiveButton(R.string.choose) + debugMode(debugMode) + lifecycleOwner(this@MainActivity) + } + } + R.id.multiple_choice.onClickDebounced { MaterialDialog(this).show { title(R.string.socialNetworks) diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 7707382c7..6e7092057 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -168,6 +168,12 @@ style="@style/SampleButton" /> +