From b05e7efb0ce16e5e2fe3d1992b9f7f2a03c9a679 Mon Sep 17 00:00:00 2001 From: amcneilly Date: Mon, 13 Dec 2021 16:08:42 -0500 Subject: [PATCH 01/14] Cleaning up duplicate functions. --- .idea/compiler.xml | 2 +- .idea/misc.xml | 2 +- gradlew | 0 .../developingdeveloper/toaster/Toaster.kt | 22 +++++-------------- 4 files changed, 7 insertions(+), 19 deletions(-) mode change 100644 => 100755 gradlew diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..61a9130 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 98de6fa..3378229 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index cc6998e..67313cf 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -33,18 +33,10 @@ class Toaster private constructor( fun pop( context: Context, message: CharSequence, - duration: Int + duration: Int, + drawableRes: Int? = null, ): Toast { - return pop(prepare(context, message, duration)) - } - - fun pop( - context: Context, - message: CharSequence, - drawableRes: Int, - duration: Int - ): Toast { - return pop(prepare(context, message, drawableRes, duration)) + return pop(prepare(context, message, duration, drawableRes)) } fun pop(toaster: Toaster): Toast { @@ -82,15 +74,11 @@ class Toaster private constructor( return pop(prepareError(context, message, duration)) } - private fun prepare(context: Context, message: CharSequence, duration: Int): Toaster { - return prepare(context, message, null, duration) - } - private fun prepare( context: Context, message: CharSequence, - drawableRes: Int?, - duration: Int + duration: Int, + drawableRes: Int? = null, ): Toaster { return Builder(context) .setMessage(message) From 12dcc59709e456dee0ab69a2ad4da01cbbfdb704 Mon Sep 17 00:00:00 2001 From: amcneilly Date: Mon, 13 Dec 2021 16:16:45 -0500 Subject: [PATCH 02/14] Creating an individual file for each default toaster type. --- .../developingdeveloper/toaster/Toaster.kt | 53 ++++--------------- .../toaster/defaults/DefaultToaster.kt | 16 ++++++ .../toaster/defaults/ErrorToaster.kt | 18 +++++++ .../toaster/defaults/SuccessToaster.kt | 22 ++++++++ .../toaster/defaults/WarningToaster.kt | 18 +++++++ 5 files changed, 83 insertions(+), 44 deletions(-) create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToaster.kt create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index 67313cf..19e3659 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -9,6 +9,9 @@ import android.widget.TextView import android.widget.Toast import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat +import tech.developingdeveloper.toaster.defaults.ErrorToaster +import tech.developingdeveloper.toaster.defaults.SuccessToaster +import tech.developingdeveloper.toaster.defaults.WarningToaster import tech.developingdeveloper.toaster.utils.Colors @@ -53,25 +56,25 @@ class Toaster private constructor( fun popSuccess( context: Context, message: CharSequence, - duration: Int + duration: Int, ): Toast { - return pop(prepareSuccess(context, message, duration)) + return pop(SuccessToaster.create(context, message, duration)) } fun popWarning( context: Context, message: CharSequence, - duration: Int + duration: Int, ): Toast { - return pop(prepareWarning(context, message, duration)) + return pop(WarningToaster.create(context, message, duration)) } fun popError( context: Context, message: CharSequence, - duration: Int + duration: Int, ): Toast { - return pop(prepareError(context, message, duration)) + return pop(ErrorToaster.create(context, message, duration)) } private fun prepare( @@ -90,44 +93,6 @@ class Toaster private constructor( .setDuration(duration) .make() } - - private fun prepareSuccess( - context: Context, - message: CharSequence, - duration: Int - ): Toaster { - return Builder(context) - .setMessage(message) - .setLeftDrawable(R.drawable.ic_baseline_check_circle_24) - .setLeftDrawableTint(Colors.SUCCESS) - .setStripTint(Colors.SUCCESS) - .setDuration(duration) - .make() - } - - private fun prepareWarning( - context: Context, - message: CharSequence, - duration: Int - ): Toaster { - return Builder(context) - .setMessage(message) - .setLeftDrawable(R.drawable.ic_baseline_warning_24) - .setLeftDrawableTint(Colors.WARNING) - .setStripTint(Colors.WARNING) - .setDuration(duration) - .make() - } - - private fun prepareError(context: Context, message: CharSequence, duration: Int): Toaster { - return Builder(context) - .setMessage(message) - .setLeftDrawable(R.drawable.ic_baseline_error_24) - .setLeftDrawableTint(Colors.ERROR) - .setStripTint(Colors.ERROR) - .setDuration(duration) - .make() - } } class Builder(private val context: Context) { diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToaster.kt new file mode 100644 index 0000000..2d9431e --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToaster.kt @@ -0,0 +1,16 @@ +package tech.developingdeveloper.toaster.defaults + +import android.content.Context +import tech.developingdeveloper.toaster.Toaster + +/** + * This interface provides a [create] method that will be used to generate a + * default [Toaster] for different scenarios. + */ +internal interface DefaultToaster { + fun create( + context: Context, + message: CharSequence, + duration: Int, + ): Toaster +} diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt new file mode 100644 index 0000000..8f93723 --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt @@ -0,0 +1,18 @@ +package tech.developingdeveloper.toaster.defaults + +import android.content.Context +import tech.developingdeveloper.toaster.R +import tech.developingdeveloper.toaster.Toaster +import tech.developingdeveloper.toaster.utils.Colors + +internal object ErrorToaster : DefaultToaster { + override fun create(context: Context, message: CharSequence, duration: Int): Toaster { + return Toaster.Builder(context) + .setMessage(message) + .setLeftDrawable(R.drawable.ic_baseline_warning_24) + .setLeftDrawableTint(Colors.WARNING) + .setStripTint(Colors.WARNING) + .setDuration(duration) + .make() + } +} \ No newline at end of file diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt new file mode 100644 index 0000000..3d3531e --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt @@ -0,0 +1,22 @@ +package tech.developingdeveloper.toaster.defaults + +import android.content.Context +import tech.developingdeveloper.toaster.R +import tech.developingdeveloper.toaster.Toaster +import tech.developingdeveloper.toaster.utils.Colors + +internal object SuccessToaster : DefaultToaster { + override fun create( + context: Context, + message: CharSequence, + duration: Int, + ): Toaster { + return Toaster.Builder(context) + .setMessage(message) + .setLeftDrawable(R.drawable.ic_baseline_check_circle_24) + .setLeftDrawableTint(Colors.SUCCESS) + .setStripTint(Colors.SUCCESS) + .setDuration(duration) + .make() + } +} diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt new file mode 100644 index 0000000..54cafe4 --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt @@ -0,0 +1,18 @@ +package tech.developingdeveloper.toaster.defaults + +import android.content.Context +import tech.developingdeveloper.toaster.R +import tech.developingdeveloper.toaster.Toaster +import tech.developingdeveloper.toaster.utils.Colors + +internal object WarningToaster : DefaultToaster { + override fun create(context: Context, message: CharSequence, duration: Int): Toaster { + return Toaster.Builder(context) + .setMessage(message) + .setLeftDrawable(R.drawable.ic_baseline_warning_24) + .setLeftDrawableTint(Colors.WARNING) + .setStripTint(Colors.WARNING) + .setDuration(duration) + .make() + } +} From a96782b72d74c427cf92ce9e0f0e13960a01f73b Mon Sep 17 00:00:00 2001 From: amcneilly Date: Mon, 13 Dec 2021 16:37:15 -0500 Subject: [PATCH 03/14] Creating a single `popDefault` function. --- .../toasterexample/MainActivity.kt | 28 ++++++------ .../toaster/DefaultToasterType.kt | 11 +++++ .../developingdeveloper/toaster/Toaster.kt | 43 ++++++++----------- 3 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/DefaultToasterType.kt diff --git a/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt b/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt index 5c4e395..522bc5f 100644 --- a/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt +++ b/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt @@ -2,6 +2,7 @@ package tech.developingdeveloper.toasterexample import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +import tech.developingdeveloper.toaster.DefaultToasterType import tech.developingdeveloper.toaster.Toaster import tech.developingdeveloper.toasterexample.databinding.ActivityMainBinding @@ -40,26 +41,29 @@ class MainActivity : AppCompatActivity() { } binding.errorButton.setOnClickListener { - Toaster.popError( - this, - "This is an error message", - Toaster.LENGTH_SHORT + Toaster.popDefault( + context = this, + message = "This is an error message", + duration = Toaster.LENGTH_SHORT, + toasterType = DefaultToasterType.ERROR, ).show() } binding.warningButton.setOnClickListener { - Toaster.popWarning( - this, - "This is a warning message", - Toaster.LENGTH_SHORT + Toaster.popDefault( + context = this, + message = "This is a warning message", + duration = Toaster.LENGTH_SHORT, + toasterType = DefaultToasterType.WARNING, ).show() } binding.successButton.setOnClickListener { - Toaster.popSuccess( - this, - "This is a success message", - Toaster.LENGTH_SHORT + Toaster.popDefault( + context = this, + message = "This is a success message", + duration = Toaster.LENGTH_SHORT, + toasterType = DefaultToasterType.SUCCESS, ).show() } } diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/DefaultToasterType.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/DefaultToasterType.kt new file mode 100644 index 0000000..365c74a --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/DefaultToasterType.kt @@ -0,0 +1,11 @@ +package tech.developingdeveloper.toaster + +/** + * An enumeration of all possible default [Toaster]s that + * the user can create. + */ +enum class DefaultToasterType { + SUCCESS, + WARNING, + ERROR, +} diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index 19e3659..b2a16e3 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -12,7 +12,6 @@ import androidx.core.content.ContextCompat import tech.developingdeveloper.toaster.defaults.ErrorToaster import tech.developingdeveloper.toaster.defaults.SuccessToaster import tech.developingdeveloper.toaster.defaults.WarningToaster -import tech.developingdeveloper.toaster.utils.Colors /** @@ -33,6 +32,24 @@ class Toaster private constructor( const val LENGTH_SHORT = Toast.LENGTH_SHORT const val LENGTH_LONG = Toast.LENGTH_LONG + /** + * Used to create a [Toast] that has some default values based on the supplied [toasterType]. + */ + fun popDefault( + context: Context, + message: CharSequence, + duration: Int, + toasterType: DefaultToasterType, + ): Toast { + val defaultToaster = when(toasterType) { + DefaultToasterType.SUCCESS -> SuccessToaster.create(context, message, duration) + DefaultToasterType.WARNING -> WarningToaster.create(context, message, duration) + DefaultToasterType.ERROR -> ErrorToaster.create(context, message, duration) + } + + return pop(defaultToaster) + } + fun pop( context: Context, message: CharSequence, @@ -53,30 +70,6 @@ class Toaster private constructor( } } - fun popSuccess( - context: Context, - message: CharSequence, - duration: Int, - ): Toast { - return pop(SuccessToaster.create(context, message, duration)) - } - - fun popWarning( - context: Context, - message: CharSequence, - duration: Int, - ): Toast { - return pop(WarningToaster.create(context, message, duration)) - } - - fun popError( - context: Context, - message: CharSequence, - duration: Int, - ): Toast { - return pop(ErrorToaster.create(context, message, duration)) - } - private fun prepare( context: Context, message: CharSequence, From defaf3ce2e39e65d574112b5db93108a3879b1eb Mon Sep 17 00:00:00 2001 From: amcneilly Date: Mon, 13 Dec 2021 17:04:05 -0500 Subject: [PATCH 04/14] Moving builder pattern to data class. --- .../toasterexample/MainActivity.kt | 16 +-- .../toasterktx/ToasterBuilderKtx.kt | 21 ++-- .../developingdeveloper/toaster/Toaster.kt | 114 ++++++++---------- .../toaster/defaults/ErrorToaster.kt | 14 +-- .../toaster/defaults/SuccessToaster.kt | 14 +-- .../toaster/defaults/WarningToaster.kt | 14 +-- .../toaster/utils/ViewUtils.kt | 7 ++ 7 files changed, 94 insertions(+), 106 deletions(-) create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/utils/ViewUtils.kt diff --git a/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt b/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt index 522bc5f..77dcbbf 100644 --- a/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt +++ b/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt @@ -31,13 +31,15 @@ class MainActivity : AppCompatActivity() { } binding.builderButton.setOnClickListener { - val toastBuilder = Toaster.Builder(this) - .setMessage("File uploaded successfully") - .setLeftDrawable(R.drawable.ic_baseline_cloud_done_24) - .setLeftDrawableTint(R.color.blue) - .setStripTint(R.color.blue) - .setDuration(Toaster.LENGTH_SHORT) - Toaster.pop(toastBuilder.make()).show() + val toaster = Toaster.Config( + message = "File uploaded successfully", + leftDrawableRes = R.drawable.ic_baseline_cloud_done_24, + leftDrawableTint = R.color.blue, + stripTint = R.color.blue, + duration = Toaster.LENGTH_SHORT, + ).make(this) + + Toaster.pop(toaster).show() } binding.errorButton.setOnClickListener { diff --git a/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt b/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt index db4918d..0931fad 100644 --- a/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt +++ b/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt @@ -28,20 +28,13 @@ class ToasterBuilderKtx private constructor(private val context: Context) { var duration: Int = Toaster.LENGTH_SHORT private fun prepare(): Toaster { - val toasterBuilder = Toaster.Builder(context) - .setMessage(message) - .setDuration(duration) - - if (leftDrawableRes != DEFAULT_VALUE) - toasterBuilder.setLeftDrawable(leftDrawableRes) - - if (leftDrawableTint != DEFAULT_VALUE) - toasterBuilder.setLeftDrawableTint(leftDrawableTint) - - if (stripTint != DEFAULT_VALUE) - toasterBuilder.setStripTint(stripTint) - - return toasterBuilder.make() + return Toaster.Config( + message = message, + duration = duration, + leftDrawableRes = leftDrawableRes.takeIf { it != DEFAULT_VALUE }, + leftDrawableTint = leftDrawableTint.takeIf { it != DEFAULT_VALUE }, + stripTint = stripTint.takeIf { it != DEFAULT_VALUE }, + ).make(context) } companion object { diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index b2a16e3..2b8f6d1 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -7,11 +7,14 @@ import android.view.View import android.widget.ImageView import android.widget.TextView import android.widget.Toast +import androidx.annotation.ColorRes +import androidx.annotation.DrawableRes import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import tech.developingdeveloper.toaster.defaults.ErrorToaster import tech.developingdeveloper.toaster.defaults.SuccessToaster import tech.developingdeveloper.toaster.defaults.WarningToaster +import tech.developingdeveloper.toaster.utils.visibleIf /** @@ -41,7 +44,7 @@ class Toaster private constructor( duration: Int, toasterType: DefaultToasterType, ): Toast { - val defaultToaster = when(toasterType) { + val defaultToaster = when (toasterType) { DefaultToasterType.SUCCESS -> SuccessToaster.create(context, message, duration) DefaultToasterType.WARNING -> WarningToaster.create(context, message, duration) DefaultToasterType.ERROR -> ErrorToaster.create(context, message, duration) @@ -76,84 +79,67 @@ class Toaster private constructor( duration: Int, drawableRes: Int? = null, ): Toaster { - return Builder(context) - .setMessage(message) - .apply { - drawableRes?.let { - setLeftDrawable(it) - } - } - .setDuration(duration) - .make() + return Config( + message = message, + leftDrawableRes = drawableRes, + duration = duration, + ).make(context) } } - class Builder(private val context: Context) { - - private val rootView: View - private var messageTextView: TextView? = null - private var leftDrawableImageView: ImageView? = null - private var leftDrawableRes: Int? = null - private var colorStripView: View? = null - - private var message: CharSequence = "" - private var duration: Int = LENGTH_SHORT - - init { - rootView = initView(context) + /** + * In Kotlin, since we can have default parameters, we have less of a need for a builder pattern. + * + * We can create a single data class that has a property for every customizable field, and then + * in [make] we can read our properties and configure our view based on that. + */ + data class Config( + private var message: CharSequence = "", + private var duration: Int = LENGTH_SHORT, + @DrawableRes + private var leftDrawableRes: Int? = null, + @ColorRes + private var leftDrawableTint: Int? = null, + @ColorRes + private var stripTint: Int? = null, + ) { + fun make(context: Context): Toaster { + return Toaster(context, message, duration).also { + it.rootView = buildView(context) + it.leftDrawableRes = leftDrawableRes + } } - private fun initView(context: Context): View { + /** + * Creates a [View] for a [Toaster] that matches this [Config]. + */ + private fun buildView(context: Context): View { val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val rootView = inflater.inflate(R.layout.layout_toast, ConstraintLayout(context), false) - messageTextView = rootView.findViewById(R.id.message_text_view) - leftDrawableImageView = rootView.findViewById(R.id.left_drawable_image_view) - colorStripView = rootView.findViewById(R.id.color_strip_view) - - setInitViewProperties() + val messageTextView: TextView = rootView.findViewById(R.id.message_text_view) + val leftDrawableImageView: ImageView = rootView.findViewById(R.id.left_drawable_image_view) + val colorStripView: View = rootView.findViewById(R.id.color_strip_view) - return rootView - } + messageTextView.text = this.message + messageTextView.visibleIf(this.message.isNotEmpty()) - fun setMessage(message: CharSequence) = apply { - this.message = message - messageTextView?.text = message - messageTextView?.visibility = View.VISIBLE - } + leftDrawableRes?.let(leftDrawableImageView::setImageResource) + leftDrawableImageView.visibleIf(leftDrawableRes != null) - fun setLeftDrawable(leftDrawableRes: Int) = apply { - this.leftDrawableRes = leftDrawableRes - leftDrawableImageView?.setImageResource(leftDrawableRes) - leftDrawableImageView?.visibility = View.VISIBLE - } - - fun setDuration(duration: Int) = apply { - this.duration = duration - } - - fun setLeftDrawableTint(colorRes: Int) = apply { - leftDrawableImageView?.setColorFilter(ContextCompat.getColor(context, colorRes)) - leftDrawableImageView?.visibility = View.VISIBLE - } - - fun setStripTint(colorRes: Int) = apply { - colorStripView?.setBackgroundColor(ContextCompat.getColor(this.context, colorRes)) - colorStripView?.visibility = View.VISIBLE - } + val tintColor = this.leftDrawableTint?.let { tintRes -> + ContextCompat.getColor(context, tintRes) + } + tintColor?.let(leftDrawableImageView::setColorFilter) - fun make(): Toaster { - return Toaster(context, message, duration).also { - it.rootView = rootView - it.leftDrawableRes = leftDrawableRes + val stripColor = this.stripTint?.let { tintRes -> + ContextCompat.getColor(context, tintRes) } - } + stripColor?.let(colorStripView::setBackgroundColor) + colorStripView.visibleIf(stripColor != null) - private fun setInitViewProperties() { - colorStripView?.visibility = View.GONE - leftDrawableImageView?.visibility = View.GONE - messageTextView?.visibility = View.GONE + return rootView } } } \ No newline at end of file diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt index 8f93723..58aa46e 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt @@ -7,12 +7,12 @@ import tech.developingdeveloper.toaster.utils.Colors internal object ErrorToaster : DefaultToaster { override fun create(context: Context, message: CharSequence, duration: Int): Toaster { - return Toaster.Builder(context) - .setMessage(message) - .setLeftDrawable(R.drawable.ic_baseline_warning_24) - .setLeftDrawableTint(Colors.WARNING) - .setStripTint(Colors.WARNING) - .setDuration(duration) - .make() + return Toaster.Config( + message = message, + leftDrawableRes = R.drawable.ic_baseline_warning_24, + leftDrawableTint = Colors.WARNING, + stripTint = Colors.WARNING, + duration = duration, + ).make(context) } } \ No newline at end of file diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt index 3d3531e..1731669 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/SuccessToaster.kt @@ -11,12 +11,12 @@ internal object SuccessToaster : DefaultToaster { message: CharSequence, duration: Int, ): Toaster { - return Toaster.Builder(context) - .setMessage(message) - .setLeftDrawable(R.drawable.ic_baseline_check_circle_24) - .setLeftDrawableTint(Colors.SUCCESS) - .setStripTint(Colors.SUCCESS) - .setDuration(duration) - .make() + return Toaster.Config( + message = message, + leftDrawableRes = R.drawable.ic_baseline_check_circle_24, + leftDrawableTint = Colors.SUCCESS, + stripTint = Colors.SUCCESS, + duration = duration, + ).make(context) } } diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt index 54cafe4..0cf48fa 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/WarningToaster.kt @@ -7,12 +7,12 @@ import tech.developingdeveloper.toaster.utils.Colors internal object WarningToaster : DefaultToaster { override fun create(context: Context, message: CharSequence, duration: Int): Toaster { - return Toaster.Builder(context) - .setMessage(message) - .setLeftDrawable(R.drawable.ic_baseline_warning_24) - .setLeftDrawableTint(Colors.WARNING) - .setStripTint(Colors.WARNING) - .setDuration(duration) - .make() + return Toaster.Config( + message = message, + leftDrawableRes = R.drawable.ic_baseline_warning_24, + leftDrawableTint = Colors.WARNING, + stripTint = Colors.WARNING, + duration = duration, + ).make(context) } } diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/utils/ViewUtils.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/utils/ViewUtils.kt new file mode 100644 index 0000000..2410dc5 --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/utils/ViewUtils.kt @@ -0,0 +1,7 @@ +package tech.developingdeveloper.toaster.utils + +import android.view.View + +internal fun View.visibleIf(condition: Boolean?) { + this.visibility = if (condition == true) View.VISIBLE else View.GONE +} \ No newline at end of file From e9e9f6c6a0b5d59ffc333ca183536a5771738ae6 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 17 Sep 2022 20:20:07 +0530 Subject: [PATCH 05/14] Abstracting default toast type creation into a factory. --- .../developingdeveloper/toaster/Toaster.kt | 14 ++++------ .../toaster/defaults/DefaultToasterFactory.kt | 26 +++++++++++++++++++ .../toaster/defaults/ToasterMapProvider.kt | 17 ++++++++++++ 3 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToasterFactory.kt create mode 100644 toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ToasterMapProvider.kt diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index 2b8f6d1..bf44846 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -11,9 +11,7 @@ import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat -import tech.developingdeveloper.toaster.defaults.ErrorToaster -import tech.developingdeveloper.toaster.defaults.SuccessToaster -import tech.developingdeveloper.toaster.defaults.WarningToaster +import tech.developingdeveloper.toaster.defaults.DefaultToasterFactory import tech.developingdeveloper.toaster.utils.visibleIf @@ -44,11 +42,8 @@ class Toaster private constructor( duration: Int, toasterType: DefaultToasterType, ): Toast { - val defaultToaster = when (toasterType) { - DefaultToasterType.SUCCESS -> SuccessToaster.create(context, message, duration) - DefaultToasterType.WARNING -> WarningToaster.create(context, message, duration) - DefaultToasterType.ERROR -> ErrorToaster.create(context, message, duration) - } + val defaultToaster = + DefaultToasterFactory.create(context, message, duration, toasterType) return pop(defaultToaster) } @@ -119,7 +114,8 @@ class Toaster private constructor( val rootView = inflater.inflate(R.layout.layout_toast, ConstraintLayout(context), false) val messageTextView: TextView = rootView.findViewById(R.id.message_text_view) - val leftDrawableImageView: ImageView = rootView.findViewById(R.id.left_drawable_image_view) + val leftDrawableImageView: ImageView = + rootView.findViewById(R.id.left_drawable_image_view) val colorStripView: View = rootView.findViewById(R.id.color_strip_view) messageTextView.text = this.message diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToasterFactory.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToasterFactory.kt new file mode 100644 index 0000000..18ce82b --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/DefaultToasterFactory.kt @@ -0,0 +1,26 @@ +package tech.developingdeveloper.toaster.defaults + +import android.content.Context +import tech.developingdeveloper.toaster.DefaultToasterType +import tech.developingdeveloper.toaster.Toaster + +/** + * A simple factory to return [DefaultToaster] instance from [DefaultToasterType]. It uses + * [java.util.EnumMap] to map the [DefaultToasterType] with the [DefaultToaster]. The map is provided + * using [ToasterMapProvider] which handles the mapping of the enum to the implementation. + */ +internal object DefaultToasterFactory { + + private val toasterMap = ToasterMapProvider.provide() + + fun create( + context: Context, + message: CharSequence, + duration: Int, + toasterType: DefaultToasterType, + ): Toaster { + val defaultToaster = toasterMap[toasterType] + ?: throw IllegalArgumentException("Unknown toaster type.") + return defaultToaster.create(context, message, duration) + } +} \ No newline at end of file diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ToasterMapProvider.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ToasterMapProvider.kt new file mode 100644 index 0000000..1c52c65 --- /dev/null +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ToasterMapProvider.kt @@ -0,0 +1,17 @@ +package tech.developingdeveloper.toaster.defaults + +import tech.developingdeveloper.toaster.DefaultToasterType +import java.util.EnumMap + +/** + * It is responsible for mapping [DefaultToasterType] to [DefaultToaster]. + */ +internal object ToasterMapProvider { + fun provide(): EnumMap = EnumMap( + mapOf( + DefaultToasterType.SUCCESS to SuccessToaster, + DefaultToasterType.WARNING to WarningToaster, + DefaultToasterType.ERROR to ErrorToaster, + ) + ) +} \ No newline at end of file From bdd67fe2356ace7be48faaf5a14bffa8b58d395b Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 17 Sep 2022 20:39:01 +0530 Subject: [PATCH 06/14] Fix malformed manifest. --- app/src/main/AndroidManifest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 946a08a..1030cde 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,7 +9,9 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + From 525135b4688da49cf39f6d740e52a3265a1e181b Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 17 Sep 2022 20:40:45 +0530 Subject: [PATCH 07/14] Fix error color in default toast. --- .../tech/developingdeveloper/toaster/defaults/ErrorToaster.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt index 58aa46e..f1d16ff 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/defaults/ErrorToaster.kt @@ -10,8 +10,8 @@ internal object ErrorToaster : DefaultToaster { return Toaster.Config( message = message, leftDrawableRes = R.drawable.ic_baseline_warning_24, - leftDrawableTint = Colors.WARNING, - stripTint = Colors.WARNING, + leftDrawableTint = Colors.ERROR, + stripTint = Colors.ERROR, duration = duration, ).make(context) } From 2e8d8f1621daa7f5c266f4bf734efb7120119e53 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 17 Sep 2022 21:09:05 +0530 Subject: [PATCH 08/14] Making pop method polymorphic. --- .../toasterexample/MainActivity.kt | 6 +++--- .../developingdeveloper/toaster/Toaster.kt | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt b/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt index 77dcbbf..4a42337 100644 --- a/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt +++ b/app/src/main/java/tech/developingdeveloper/toasterexample/MainActivity.kt @@ -43,7 +43,7 @@ class MainActivity : AppCompatActivity() { } binding.errorButton.setOnClickListener { - Toaster.popDefault( + Toaster.pop( context = this, message = "This is an error message", duration = Toaster.LENGTH_SHORT, @@ -52,7 +52,7 @@ class MainActivity : AppCompatActivity() { } binding.warningButton.setOnClickListener { - Toaster.popDefault( + Toaster.pop( context = this, message = "This is a warning message", duration = Toaster.LENGTH_SHORT, @@ -61,7 +61,7 @@ class MainActivity : AppCompatActivity() { } binding.successButton.setOnClickListener { - Toaster.popDefault( + Toaster.pop( context = this, message = "This is a success message", duration = Toaster.LENGTH_SHORT, diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index bf44846..2a10f0b 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -33,10 +33,19 @@ class Toaster private constructor( const val LENGTH_SHORT = Toast.LENGTH_SHORT const val LENGTH_LONG = Toast.LENGTH_LONG + fun pop( + context: Context, + message: CharSequence, + duration: Int, + drawableRes: Int? = null, + ): Toast { + return pop(prepare(context, message, duration, drawableRes)) + } + /** * Used to create a [Toast] that has some default values based on the supplied [toasterType]. */ - fun popDefault( + fun pop( context: Context, message: CharSequence, duration: Int, @@ -48,15 +57,6 @@ class Toaster private constructor( return pop(defaultToaster) } - fun pop( - context: Context, - message: CharSequence, - duration: Int, - drawableRes: Int? = null, - ): Toast { - return pop(prepare(context, message, duration, drawableRes)) - } - fun pop(toaster: Toaster): Toast { return if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { Toast(toaster.context).apply { From 66dd18c67bbb5dea748bb3b552c53365df87b368 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 17 Sep 2022 21:10:30 +0530 Subject: [PATCH 09/14] Minor changes. --- .../src/main/java/tech/developingdeveloper/toaster/Toaster.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt index 2a10f0b..d298991 100644 --- a/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt +++ b/toaster/src/main/java/tech/developingdeveloper/toaster/Toaster.kt @@ -39,7 +39,8 @@ class Toaster private constructor( duration: Int, drawableRes: Int? = null, ): Toast { - return pop(prepare(context, message, duration, drawableRes)) + val toaster = prepare(context, message, duration, drawableRes) + return pop(toaster) } /** From 86a0e0acd5f66902dcdf1a597d66c163898139d4 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 14 Jan 2023 01:13:35 +0530 Subject: [PATCH 10/14] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1530e5f..1fdbfce 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ It has some predefined templates for common use-cases like warning, error and su ``` dependencies { - implementation 'tech.developingdeveloper.toaster-android:toaster:2.3.0' - implementation 'tech.developingdeveloper.toaster-android:toaster-ktx:2.3.0' //for ktx support + implementation 'com.github.5AbhishekSaxena.toaster-android:toaster:2.3.0' + implementation 'com.github.5AbhishekSaxena.toaster-android:toaster-ktx:2.3.0' //for ktx support } ``` *Please Note:* toaster-ktx includes toaster module so, if you are using toaster-ktx version then you don't have to add taoster From e531a1e239397e99d7f63640c1baff01d5ed83e9 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 14 Jan 2023 01:29:18 +0530 Subject: [PATCH 11/14] Refactor Toaster ktx API functions as top-level functions. --- .../toasterexample/KtxExampleActivity.kt | 7 +++--- .../toasterktx/ToasterBuilderKtx.kt | 22 ++----------------- .../toasterktx/ToasterKtx.kt | 21 ++++++++++++++++++ 3 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterKtx.kt diff --git a/app/src/main/java/tech/developingdeveloper/toasterexample/KtxExampleActivity.kt b/app/src/main/java/tech/developingdeveloper/toasterexample/KtxExampleActivity.kt index c7af57b..5997b11 100644 --- a/app/src/main/java/tech/developingdeveloper/toasterexample/KtxExampleActivity.kt +++ b/app/src/main/java/tech/developingdeveloper/toasterexample/KtxExampleActivity.kt @@ -4,7 +4,8 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import tech.developingdeveloper.toaster.Toaster import tech.developingdeveloper.toasterexample.databinding.ActivityMainBinding -import tech.developingdeveloper.toasterktx.ToasterBuilderKtx +import tech.developingdeveloper.toasterktx.prepareToast +import tech.developingdeveloper.toasterktx.prepareToaster /** @@ -22,7 +23,7 @@ class KtxExampleActivity : AppCompatActivity() { setContentView(binding.root) binding.builderButton.setOnClickListener { - val toaster = ToasterBuilderKtx.prepareToaster(this) { + val toaster = prepareToaster(this) { message = "File uploaded successfully" leftDrawableRes = R.drawable.ic_baseline_cloud_done_24 leftDrawableTint = R.color.blue @@ -34,7 +35,7 @@ class KtxExampleActivity : AppCompatActivity() { // or - ToasterBuilderKtx.prepareToast(this) { + prepareToast(this) { message = "File uploaded successfully" leftDrawableRes = R.drawable.ic_baseline_cloud_done_24 leftDrawableTint = R.color.blue diff --git a/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt b/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt index 0931fad..8b734f3 100644 --- a/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt +++ b/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterBuilderKtx.kt @@ -1,8 +1,6 @@ package tech.developingdeveloper.toasterktx import android.content.Context -import android.widget.Toast -import androidx.annotation.ColorInt import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import tech.developingdeveloper.toaster.Toaster @@ -13,7 +11,7 @@ import tech.developingdeveloper.toaster.Toaster * @since 07-09-2021 12:01 */ -class ToasterBuilderKtx private constructor(private val context: Context) { +class ToasterBuilderKtx internal constructor(private val context: Context) { @DrawableRes var leftDrawableRes: Int = DEFAULT_VALUE @@ -27,7 +25,7 @@ class ToasterBuilderKtx private constructor(private val context: Context) { var message: CharSequence = "" var duration: Int = Toaster.LENGTH_SHORT - private fun prepare(): Toaster { + internal fun prepare(): Toaster { return Toaster.Config( message = message, duration = duration, @@ -39,21 +37,5 @@ class ToasterBuilderKtx private constructor(private val context: Context) { companion object { private const val DEFAULT_VALUE = -1 - - fun prepareToast( - context: Context, - block: ToasterBuilderKtx.() -> Unit - ): Toast { - val toaster = prepareToaster(context, block) - return Toaster.pop(toaster) - } - - fun prepareToaster( - context: Context, - block: ToasterBuilderKtx.() -> Unit - ): Toaster { - val toastBuilder = ToasterBuilderKtx(context).apply(block) - return toastBuilder.prepare() - } } } diff --git a/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterKtx.kt b/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterKtx.kt new file mode 100644 index 0000000..538275e --- /dev/null +++ b/toaster-ktx/src/main/java/tech/developingdeveloper/toasterktx/ToasterKtx.kt @@ -0,0 +1,21 @@ +package tech.developingdeveloper.toasterktx + +import android.content.Context +import android.widget.Toast +import tech.developingdeveloper.toaster.Toaster + +fun prepareToast( + context: Context, + block: ToasterBuilderKtx.() -> Unit +): Toast { + val toaster = prepareToaster(context, block) + return Toaster.pop(toaster) +} + +fun prepareToaster( + context: Context, + block: ToasterBuilderKtx.() -> Unit +): Toaster { + val toastBuilder = ToasterBuilderKtx(context).apply(block) + return toastBuilder.prepare() +} \ No newline at end of file From 2f0e1482193b09f420173e6e359db09d1713be29 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 14 Jan 2023 01:40:50 +0530 Subject: [PATCH 12/14] Update gradle to 7.4 --- .idea/compiler.xml | 2 +- .idea/misc.xml | 2 +- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 3 +-- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- toaster-ktx/build.gradle | 1 + toaster-ktx/src/main/AndroidManifest.xml | 3 +-- toaster/build.gradle | 2 +- toaster/src/main/AndroidManifest.xml | 6 +----- 10 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 61a9130..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 3378229..98de6fa 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index a3635f3..182a4d4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 31 - buildToolsVersion "29.0.3" defaultConfig { applicationId "tech.developingdeveloper.toasterexample" @@ -31,6 +30,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + namespace 'tech.developingdeveloper.toasterexample' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1030cde..e296fc8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + - + \ No newline at end of file diff --git a/toaster/build.gradle b/toaster/build.gradle index 340e73b..5032559 100644 --- a/toaster/build.gradle +++ b/toaster/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 31 - buildToolsVersion "29.0.3" defaultConfig { minSdkVersion 19 @@ -22,6 +21,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + namespace 'tech.developingdeveloper.toaster' } dependencies { diff --git a/toaster/src/main/AndroidManifest.xml b/toaster/src/main/AndroidManifest.xml index 67966db..25df386 100644 --- a/toaster/src/main/AndroidManifest.xml +++ b/toaster/src/main/AndroidManifest.xml @@ -1,5 +1 @@ - - - / - \ No newline at end of file + \ No newline at end of file From 548f745e38a6c5143d1924782655aabf43a13b47 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 14 Jan 2023 02:06:04 +0530 Subject: [PATCH 13/14] Update library version to 2.3.1. --- app/build.gradle | 4 ++-- toaster/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 182a4d4..af075ec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "tech.developingdeveloper.toasterexample" minSdkVersion 19 targetSdkVersion 31 - versionCode 1 - versionName "1.2" + versionCode 3 + versionName "1.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/toaster/build.gradle b/toaster/build.gradle index 5032559..6781ab8 100644 --- a/toaster/build.gradle +++ b/toaster/build.gradle @@ -8,8 +8,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 31 - versionCode 2 - versionName "2.3.0" + versionCode 3 + versionName "2.3.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" From 41a395b400ef1f272a34fd8c3388c7a226cbeef3 Mon Sep 17 00:00:00 2001 From: Abhishek Saxena <5abhisheksaxena@gmail.com> Date: Sat, 14 Jan 2023 02:17:19 +0530 Subject: [PATCH 14/14] Update dependencies --- app/build.gradle | 16 ++++++++-------- build.gradle | 2 +- toaster-ktx/build.gradle | 10 +++++----- toaster/build.gradle | 14 +++++++------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index af075ec..f79dee3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 31 + compileSdkVersion 33 defaultConfig { applicationId "tech.developingdeveloper.toasterexample" @@ -36,16 +36,16 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30" - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20" + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation project(path: ':toaster') implementation project(path: ':toaster-ktx') testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'com.google.android.material:material:1.4.0' + implementation 'com.google.android.material:material:1.7.0' } \ No newline at end of file diff --git a/build.gradle b/build.gradle index c2f30bf..bbec396 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:7.3.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/toaster-ktx/build.gradle b/toaster-ktx/build.gradle index 04b78a9..43c9c9c 100644 --- a/toaster-ktx/build.gradle +++ b/toaster-ktx/build.gradle @@ -32,11 +32,11 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'com.google.android.material:material:1.7.0' api project(path: ':toaster') testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } \ No newline at end of file diff --git a/toaster/build.gradle b/toaster/build.gradle index 6781ab8..ced1190 100644 --- a/toaster/build.gradle +++ b/toaster/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 31 + compileSdkVersion 33 defaultConfig { minSdkVersion 19 @@ -26,13 +26,13 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30" - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20" + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' // CardView implementation "androidx.cardview:cardview:1.0.0"