Skip to content

Commit

Permalink
Merge pull request #13 from SuddenH4X/release/2.1.0
Browse files Browse the repository at this point in the history
Release/2.1.0
  • Loading branch information
SuddenH4X authored Jun 1, 2020
2 parents 8d9b137 + c20b864 commit fa9c7cc
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A highly customizable Android library providing a dialog, which asks the user to
This library:
- is completely written in Kotlin
- is Unit tested
- is optimized for MaterialComponent themes
- uses AndroidX
- uses no third party dependencies
- is easy debuggable
Expand Down Expand Up @@ -410,6 +411,7 @@ If you want to show the dialog on app start, but with your custom conditions, yo

## Note

* Use a MaterialComponent theme for better design
* Don't forget to set up the mail settings if you want to use the mail feedback dialog (otherwise nothing will happen)
* Use `setRatingThreshold(RatingThreshold.NONE)` if you don't want to show the feedback form to the user
* If you set `setUseCustomFeedback()` to `true`, you have to handle the feedback text by yourself by adding a click listener (`setCustomFeedbackButtonClickListener()`)
Expand All @@ -431,7 +433,7 @@ The following things are highly recommended to not annoy the user, which in turn
## License

```
Copyright (C) 2019 SuddenH4X
Copyright (C) 2020 SuddenH4X
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ buildscript {
}
}
dependencies {
// can't update because of incompatibility with bintray-release: https://github.com/novoda/bintray-release/issues/298
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.novoda:bintray-release:0.9.1'
Expand Down
3 changes: 2 additions & 1 deletion exampleapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':library')

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
3 changes: 1 addition & 2 deletions exampleapp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand All @@ -18,5 +18,4 @@
<item name="android:layout_marginBottom">@dimen/margin_normal</item>
<item name="android:layout_marginTop">@dimen/margin_normal</item>
</style>

</resources>
5 changes: 3 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: "de.mannodermaus.android-junit5"
apply plugin: 'com.novoda.bintray-release'

def version = "2.0.0"
def version = "2.1.0"

android {
compileSdkVersion 29
Expand All @@ -31,8 +31,9 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.annotation:annotation:1.1.0'

testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.suddenh4x.ratingdialog.dialog

import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context
import android.text.Editable
import android.text.TextWatcher
Expand All @@ -10,7 +9,9 @@ import android.view.View
import android.widget.EditText
import android.widget.RatingBar
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.FragmentActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.suddenh4x.ratingdialog.R
import com.suddenh4x.ratingdialog.buttons.RateButton
import com.suddenh4x.ratingdialog.logging.RatingLogger
Expand All @@ -33,7 +34,7 @@ internal object DialogManager {
dialogOptions: DialogOptions
): AlertDialog {
RatingLogger.debug("Creating rating overview dialog.")
val builder = AlertDialog.Builder(activity)
val builder = getDialogBuilder(activity)

val inflater = activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val ratingOverviewDialogView = inflater.inflate(R.layout.dialog_rating_overview, null)
Expand Down Expand Up @@ -124,7 +125,7 @@ internal object DialogManager {
dialogOptions: DialogOptions
): AlertDialog {
RatingLogger.debug("Creating store rating dialog.")
val builder = AlertDialog.Builder(context)
val builder = getDialogBuilder(context)

val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val ratingStoreDialogView = inflater.inflate(R.layout.dialog_rating_store, null)
Expand Down Expand Up @@ -161,7 +162,7 @@ internal object DialogManager {
dialogOptions: DialogOptions
): AlertDialog {
RatingLogger.debug("Creating mail feedback dialog.")
val builder = AlertDialog.Builder(context)
val builder = getDialogBuilder(context)

builder.apply {
setTitle(dialogOptions.feedbackTitleTextId)
Expand Down Expand Up @@ -201,7 +202,7 @@ internal object DialogManager {
dialogOptions: DialogOptions
): AlertDialog {
RatingLogger.debug("Creating custom feedback dialog.")
val builder = AlertDialog.Builder(context)
val builder = getDialogBuilder(context)

val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val ratingCustomFeedbackDialogView =
Expand Down Expand Up @@ -320,4 +321,13 @@ internal object DialogManager {
}
}
}

private fun getDialogBuilder(context: Context): AlertDialog.Builder {
return try {
MaterialAlertDialogBuilder(context)
} catch (ex: IllegalArgumentException) {
RatingLogger.debug("This app doesn't use a MaterialComponents theme. Using normal AlertDialog instead.")
AlertDialog.Builder(context)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.suddenh4x.ratingdialog.dialog

import android.app.AlertDialog
import android.app.Dialog
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment

internal class RateDialogFragment : DialogFragment() {
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/drawable/edittext_border.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#ffffffff"/>
<solid android:color="?attr/backgroundColor"/>

<stroke android:width="1dp" android:color="#ddd"/>

Expand Down
Binary file modified preview/showcase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa9c7cc

Please sign in to comment.