Coder Social home page Coder Social logo

android-material-app-rating's Introduction

Android Material App Rating Build Status Android ArsenalAwesome Android

This library allows to use customized Rating Dialog inside applications.

Download

compile 'com.stepstone.apprating:app-rating:2.3.1'

Supported features

  • custom styles for dialog's background, stars, title, description, hint
  • custom rating scope (number of stars)
  • note descriptions below rating bar, which describes each note
  • defining custom dialog's title, description and hint
  • defining text for positive, negative and neutral button
  • enter/exit window animation

Using different app themes

    

Getting started

Browse samples

There are few samples of rating dialog usage. Please refer to SamplesActivity in samples module. There are also two gradle flavors for sample app which can switched to see dialog in different themes, styles.

Prepare styling for dialog

Styling app rating dialog works in the same way like styling standard android's AlertDialog. Just need to define own style for your dialog.

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- Dialog -->
    <style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="android:background">@color/backgroundColor</item>
        <item name="buttonBarPositiveButtonStyle">@style/MyAlertDialogButtonStyle</item>
        <item name="buttonBarNegativeButtonStyle">@style/MyAlertDialogButtonStyle</item>
        <item name="buttonBarNeutralButtonStyle">@style/MyAlertDialogButtonStyle</item>
    </style>

    <style name="MyAlertDialogButtonStyle" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:textColor">@color/colorAccent</item>
        <item name="android:textSize">@dimen/text_size_medium</item>
    </style>

    <style name="MyDialogFadeAnimation">
        <item name="android:windowEnterAnimation">@android:anim/fade_in</item>
        <item name="android:windowExitAnimation">@android:anim/fade_out</item>
    </style>

</resources>

And assign this style to the theme.

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <!-- Assign dialog style here. -->
        <item name="alertDialogTheme">@style/MyAlertDialogStyle</item>
        <item name="alertDialogStyle">@style/MyAlertDialogStyle</item>

        <!-- Assign custom text styles for title, description, comment -->
        <item name="appRatingDialogTitleStyle">@style/MyDialogTitleStyle</item>
        <item name="appRatingDialogDescriptionStyle">@style/MyDialogDescriptionStyle</item>
        <item name="appRatingDialogNoteDescriptionStyle">@style/MyDialogNoteDescriptionStyle</item>
        <item name="appRatingDialogCommentStyle">@style/MyDialogCommentStyle</item>
    </style>

</resources>

Setup and create dialog

This code need to be invoked inside FragmentActivity. Activity MUST implement RatingDialogListener ! Otherwise an exception will be thrown.

private void showDialog() {
        new AppRatingDialog.Builder()
                .setPositiveButtonText("Submit")
                .setNegativeButtonText("Cancel")
                .setNeutralButtonText("Later")
                .setNoteDescriptions(Arrays.asList("Very Bad", "Not good", "Quite ok", "Very Good", "Excellent !!!"))
                .setDefaultRating(2)
                .setTitle("Rate this application")
                .setDescription("Please select some stars and give your feedback")
                .setCommentInputEnabled(true)
                .setDefaultComment("This app is pretty cool !")
                .setStarColor(R.color.starColor)
                .setNoteDescriptionTextColor(R.color.noteDescriptionTextColor)
                .setTitleTextColor(R.color.titleTextColor)
                .setDescriptionTextColor(R.color.contentTextColor)
                .setHint("Please write your comment here ...")
                .setHintTextColor(R.color.hintTextColor)
                .setCommentTextColor(R.color.commentTextColor)
                .setCommentBackgroundColor(R.color.colorPrimaryDark)
                .setWindowAnimation(R.style.MyDialogFadeAnimation)
                .setCancelable(false)
                .setCanceledOnTouchOutside(false)
                .create(MainActivity.this)
                .setTargetFragment(this, TAG) // only if listener is implemented by fragment
                .show();
    }

Getting results

Rating and comments can be fetched by listener implemented by activity.

class MyActivity implements RatingDialogListener {

        @Override
        public void onPositiveButtonClicked(int rate, String comment) {
            // interpret results, send it to analytics etc...
        }

        @Override
        public void onNegativeButtonClicked() {

        }
        
        @Override
        public void onNeutralButtonClicked() {

        }
}

Changelog

See changelog

License

Copyright 2017 StepStone Services

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Maintained by

Stepstone

android-material-app-rating's People

Contributors

albinekcom avatar defio avatar pglebocki avatar piotrglebocki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-material-app-rating's Issues

Control dismiss behaviour

Is it somehow possible to control the dismiss behaviour of the dialog? I'm trying to validate review text, so If nothing is written, the dialog shouldn't dismiss but display an alert to the user. Currently it dismisses no matter if there is text or not.

You need to add more details regarding the themes. Ie where to past that code. Which folders etc.

Make sure these boxes are checked before submitting your issue - thank you!

  • Check in the issue tracker whether
    this issue wasn't already reported.
  • If it's a bug report check that clear steps to reproduce,
    stacktrace, expected behaviour and other needed details are provided.
  • Feature requests contain a description of the feature
    you're requesting as well as a brief scenario explaining
    under what circumstances this might be useful.

JCenter is deprecated

Make sure these boxes are checked before submitting your issue - thank you!

  • Check in the issue tracker whether
    this issue wasn't already reported.
  • If it's a bug report check that clear steps to reproduce,
    stacktrace, expected behaviour and other needed details are provided.
  • Feature requests contain a description of the feature
    you're requesting as well as a brief scenario explaining
    under what circumstances this might be useful.

JCenter is deprecated and will allow to download until feb 1st 2022 as stated here https://developer.android.com/studio/build/jcenter-migration

Any plan to migrate elsewhere? maven or jitpack?

Add neutral button

Hi, I would like to contribute to your project by adding a neutral button.

It would be useful, for example, to show a "later" button.
Can I submit a pull to request?

screenshot-1505222113243

Comment Text

How to limit the number of characters in comment text

I need a help

I am new in Android developing , therefore i have a question how rate and review i directly send to playstore ?

can I use this in api 15?

I try your lib, and my min sdk target is 15, while your lib is 16.
Is there any problem if use in api 15?

android.content.res.Resources$NotFoundException: Resource ID #0xff000000

this is my code
private fun showRateAppDialog() {

    AppRatingDialog.Builder()
            .setPositiveButtonText(getString(R.string.submit))
            .setNegativeButtonText(getString(R.string.cancel))
            .setNeutralButtonText(getString(R.string.later))
            .setNoteDescriptions(listOf(getString(R.string.very_bad_rate_dialog)
                    , getString(R.string.not_good_rate_dialog)
                    , getString(R.string.quite_ok_rate_dialog)
                    , getString(R.string.very_good_rate_dialog)
                    , getString(R.string.excellent_rate_dialog)))
            .setDefaultRating(2)
            .setTitle("Rate this application")
            .setDescription("Please select some stars and give your feedback!")
            .setCommentInputEnabled(true)
            .setDefaultComment("This app is pretty cool !")
            .setStarColor(context?.resources?.getColor(R.color.red)!!)
            .setNoteDescriptionTextColor(context?.resources?.getColor(R.color.red)!!)
            .setTitleTextColor(context?.resources?.getColor(R.color.black)!!)
            .setDescriptionTextColor(context?.resources?.getColor(R.color.black)!!)
            .setHint("Please write your comment here ...")
            .setHintTextColor(context?.resources?.getColor(R.color.grey)!!)
            .setCommentTextColor(context?.resources?.getColor(R.color.black)!!)
            .setCommentBackgroundColor(context?.resources?.getColor(R.color.white)!!)
            .setCancelable(false)
            .setWindowAnimation(android.R.anim.slide_out_right)
            .setCanceledOnTouchOutside(false)
            .create(activity!!)
            .setTargetFragment(this, 0)
            .show()
}

and xml

@color/red
#b7112a
#d81b60
#F05053
#707070
#000
#FFFF

app crash when send to background

Hi, the library crash when application detached from window.

throw NotSerializableException

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.stepstone.apprating.AppRatingDialog$Builder$Data)

Caused by: java.io.NotSerializableException: com.stepstone.apprating.listener.OnNegativeButtonClickedListener$Companion$NULL$1

thanks

Change Stars Color

I have see the stars use accentcolor of theme but if i need to change only stars color without change accentcolor of theme?

Add change font style

Because multiple applications use a proprietary or branded font. Could this type of font be implemented in Rating Dialog?

android.content.res.Resources$NotFoundException: File res/drawable/edit_text_background.xml from drawable resource ID ( On Abdroid 4)

Make sure these boxes are checked before submitting your issue - thank you!

  • Check in the issue tracker whether
    this issue wasn't already reported.
  • If it's a bug report check that clear steps to reproduce,
    stacktrace, expected behaviour and other needed details are provided.
  • Feature requests contain a description of the feature
    you're requesting as well as a brief scenario explaining
    under what circumstances this might be useful.

bug: java.lang.NoSuchFieldError: No field textSpacerNoTitle of type I in class Landroid/support/v7/appcompat/R$id; or its superclasses

04-13 22:45:09.151 551-551/ir.example.nbd E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.example.nbd, PID: 551
java.lang.NoSuchFieldError: No field textSpacerNoTitle of type I in class Landroid/support/v7/appcompat/R$id; or its superclasses (declaration of 'android.support.v7.appcompat.R$id' appears in /data/app/ir.example.nbd-2/base.apk)
at android.support.v7.app.AlertController.setupView(AlertController.java:513)
at android.support.v7.app.AlertController.installContent(AlertController.java:227)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:260)
at android.app.Dialog.dispatchOnCreate(Dialog.java:436)
at android.app.Dialog.show(Dialog.java:314)
at android.support.v4.app.DialogFragment.onStart(DialogFragment.java:416)
at android.support.v4.app.Fragment.performStart(Fragment.java:2287)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1458)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2590)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2377)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2239)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

default EditText color

the default EditText background color is white !
it is annoying when i have dark theme (commentBackgroundColorResId and commentTextColorResId is white!!)

EditText configuration

How can I set the embedded edittext to be single line? and I also want to know if #54 is ready.
Thanks.

Default comment text

if I want to use AppRatingDialog to edit an user review, i can't set the previous user comment.

RatingDialogListener in CustomAdapter

I am Showing rating dialog on listviewitem click . and listview is inside fragment . so is it possible to create rating dialog listner inside the custom adapter ?

Problem : create ([email protected] FragmentActivity) in Builder cannot be applied to (......myActivity)

I have an activity
@NotNull public class myActivity extends FragmentActivity implements RatingDialogListener, myActivityContract.View

But when I write in my activity this function :
`private void showDialog()

{
new AppRatingDialog.Builder()
.setPositiveButtonText("Submit")
.setNegativeButtonText("Cancel")
.setNeutralButtonText("Later")
.setNoteDescriptions(Arrays.asList("Very Bad", "Not good", "Quite ok", "Very Good", "Excellent !!!"))
.setDefaultRating(2)
.setTitle("Rate this application")
.setDescription("Please select some stars and give your feedback")
.setCommentInputEnabled(true)
.setDefaultComment("This app is pretty cool !")
.setStarColor(R.color.black)
.setNoteDescriptionTextColor(R.color.black)
.setTitleTextColor(R.color.black)
.setDescriptionTextColor(R.color.black)
.setHint("Please write your comment here ...")
.setHintTextColor(R.color.black)
.setCommentTextColor(R.color.black)
.setCommentBackgroundColor(R.color.colorPrimaryDark)
.setWindowAnimation(R.style.MyDialogFadeAnimation)
.setCancelable(false)
.setCanceledOnTouchOutside(false)
.create(myActivity.this)
.show();
}`

AndroidStudio tells me on the "create" function parameter that :

create ([email protected] FragmentActivity) in Builder cannot be applied to (com.visitey.eip.visitey.pages.my.view.myActivity)

Am I doing something wrong or is this a bug ?

Can we add a picture in this dialogue?

Make sure these boxes are checked before submitting your issue - thank you!

  • Check in the issue tracker whether
    this issue wasn't already reported.
  • If it's a bug report check that clear steps to reproduce,
    stacktrace, expected behaviour and other needed details are provided.
  • Feature requests contain a description of the feature
    you're requesting as well as a brief scenario explaining
    under what circumstances this might be useful.

Apply in fragment

How to use this in a fragment? I've implemented RatingDialogListener in my fragment, but it doesn't work.

Setup detekt plugin for code formatting validation

Make sure these boxes are checked before submitting your issue - thank you!

  • Check in the issue tracker whether
    this issue wasn't already reported.
  • If it's a bug report check that clear steps to reproduce,
    stacktrace, expected behaviour and other needed details are provided.
  • Feature requests contain a description of the feature
    you're requesting as well as a brief scenario explaining
    under what circumstances this might be useful.

Auto-hide the keyboard

Hello!
On older versions of operating systems (and small screens), the keyboard covers the "Send" and "Cancel" buttons. How can I hide the keyboard, for example, when I click outside the Comment field?

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0-beta01] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:20:5-136:19 to override.

Hi,
I just import this library, and facing this issue on project build. Can you tell me whats happening ?.
This library only support androidX??

setTypeface

Hi dear with the best Thanks...
i want to choose a custom typeface for title and others...
How can in use...
best regards.
Mostafa

Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0-beta01] AndroidManifest.xml:22:18-86 is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91

  1. Start new Android project.
  2. add library to build.gradle
  3. insert showDialog() method in MainActivity.
  4. Project doesn't compile.
Executing tasks: [:app:assembleDebug]

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript UP-TO-DATE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE

> Task :app:processDebugManifest FAILED
/Users/jimclermonts/Downloads/MyApplication/app/src/main/AndroidManifest.xml:22:18-86 Error:
	Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0-beta01] AndroidManifest.xml:22:18-86
	is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0-beta01] AndroidManifest.xml:22:18-86
  	is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
  	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
9 actionable tasks: 1 executed, 8 up-to-date



Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.