Giter VIP home page Giter VIP logo

toasty's Introduction

ko-fi

Toasty

API Android Arsenal

The usual Toast, but with steroids.

Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Dependency

Add this to your module's build.gradle file (make sure the version matches the JitPack badge above):

dependencies {
	...
	implementation 'com.github.GrenderG:Toasty:1.5.2'
}

Configuration

This step is optional, but if you want you can configure some Toasty parameters. Place this anywhere in your app:

Toasty.Config.getInstance()
    .tintIcon(boolean tintIcon) // optional (apply textColor also to the icon)
    .setToastTypeface(@NonNull Typeface typeface) // optional
    .setTextSize(int sizeInSp) // optional
    .allowQueue(boolean allowQueue) // optional (prevents several Toastys from queuing)
    .setGravity(int gravity, int xOffset, int yOffset) // optional (set toast gravity, offsets are optional)
    .supportDarkTheme(boolean supportDarkTheme) // optional (whether to support dark theme or not)
    .setRTL(boolean isRTL) // optional (icon is on the right)
    .apply(); // required

You can reset the configuration by using reset() method:

Toasty.Config.reset();

Usage

Each method always returns a Toast object, so you can customize the Toast much more. DON'T FORGET THE show() METHOD!

To display an error Toast:

Toasty.error(yourContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show();

To display a success Toast:

Toasty.success(yourContext, "Success!", Toast.LENGTH_SHORT, true).show();

To display an info Toast:

Toasty.info(yourContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show();

To display a warning Toast:

Toasty.warning(yourContext, "Beware of the dog.", Toast.LENGTH_SHORT, true).show();

To display the usual Toast:

Toasty.normal(yourContext, "Normal toast w/o icon").show();

To display the usual Toast with icon:

Toasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show();

You can also create your custom Toasts with the custom() method:

Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon, 
shouldTint).show();

Extra

You can pass formatted text to Toasty!

There are variants of each method, feel free to explore this library.

Screenshots

Please click the image below to enlarge.

Third Party Bindings

React Native

You may now use this library with React Native via this module.

Apps using Toasty

Want to be here? Open an issue or make a pull request.

ColorHub - Color Palette
Daily – News flipped around
Oz! Comic Reader
Impactor Unroot
Fusemounter
BlueWords
Photo Map - Photo and Video Gallery
Maki for Facebook & Twitter
ModPE IDE
Rocket Notes
OpenHub for GitHub
openHAB
Saarang
Kad ce mi bus - red voznje
Hide Files
LogViewer for openHAB

toasty's People

Contributors

anandkumarkparmar avatar avneeshgupta1 avatar chintanrathod avatar coderkan avatar cyb3rko avatar dennyweinberg avatar emamirazavi avatar grenderg avatar mueller-ma avatar ofekocohen avatar percy-g2 avatar prscx avatar rayliverified avatar ryuunoakaihitomi avatar sami286 avatar sfilmak avatar vango121 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  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

toasty's Issues

No padding in toasty

Great library, just having an issue with it which I think is a bug. When I create any type of Toasty the text and icon have no right or left padding. Using Android 7.1.1 on API 25.

Toast padding is being removed with fitsSystemWindows set to true.

Hi @GrenderG , thanks for the great library!
I have a question about how the text padding for Toasty is set. Usually, text in Toasty has a 16-20dp left right margin. However, when I am using the library in a fullscreen activity, the text padding disappears. What is setting the toast's text padding?

P.S. I am currently adding spaces around my toast messages like " Toast Message " to simulate padding. It works great :D

Failed to resolve compile 'com.github.GrenderG:Toasty:1.2.5'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.github.GrenderG:Toasty:1.2.5'
testCompile 'junit:junit:4.12'
}

Failed to resolve: com.github.GrenderG:Toasty:1.1.4

Gradle can't find the lib
I add compile
'com.github.GrenderG:Toasty:1.1.4' into buil.gradle (app) with the rest of the lib, but get Failed to resolve: com.github.GrenderG:Toasty:1.1.4 error message.

ANy help?

Crash in ToastyUtils.getDrawable

Got this exception from crash reporting in my app:

java.lang.NullPointerException: Attempt to invoke virtual method  'android.graphics.drawable.Drawable android.content.Context.getDrawable(int)' on  a null object reference
     at  es.dmoral.toasty.ToastyUtils.getDrawable(ToastyUtils.java:53)
     at  es.dmoral.toasty.Toasty.info(Toasty.java:116)
     at  es.dmoral.toasty.Toasty.info(Toasty.java:106)

Possible issue

I use Toasty, and I had the following error :

Exception java.lang.IndexOutOfBoundsException: setSpan (9 ... 9) ends beyond length 4
android.text.SpannableStringBuilder.checkRange (SpannableStringBuilder.java:1090)
android.text.SpannableStringBuilder.setSpan (SpannableStringBuilder.java:665)
android.text.SpannableStringBuilder.setSpan (SpannableStringBuilder.java:658)
android.text.Selection.setSelection (Selection.java:76)
android.text.Selection.setSelection (Selection.java:87)
android.widget.EditText.setSelection (EditText.java:98)
android.widget.EditText.performAccessibilityActionInternal (EditText.java:138)
android.view.View.performAccessibilityAction (View.java:8889)
android.view.AccessibilityInteractionController.performAccessibilityActionUiThread (AccessibilityInteractionController.java:668)
android.view.AccessibilityInteractionController.-wrap6 (AccessibilityInteractionController.java)
android.view.AccessibilityInteractionController$PrivateHandler.handleMessage (AccessibilityInteractionController.java:1194)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5417)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)

As in my code, I don't use SpannableString, I suppose it can be from Toasty library...

I don't know on which Toasty it happens, so I don't know which string make this error (may be a special character like "" ?). Sorry, I cannot give more details...

Gradle fail after adding dependency.

Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.3.1) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
androidTestCompile 'com.android.support:support-annotations:23.1.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
compile 'com.github.GrenderG:Toasty:1.2.5'

}

I'm getting error Failed to resolve: com.github.GrednerG:Toasty:1.1.2

I'm getting error Failed to resolve: com.github.GrednerG:Toasty:1.1.2 whenever I try to build.

Here is my gradle file:

buildscript {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

screen shot 2017-01-21 at 11 17 21 pm

Apply Radius to toast message

Hi @GrenderG

Great plugin you have here, just request if possible to have or assign the toast radius (so corners are not so rounded).

Programmatically

Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, textColor, tintColor, duration, withIcon, cornerRadius, true).show();

Using in my app

So I just published an update to my app, ChromoPhoto, and included your Toasty project! When in the app, it shows snackbars for most notifications, and out of the app, the customized Toastys.

I also have one in-app Toasty for the set image quality dialog.

You said to post an issue if an app is using your Toasty, so here I am :D
I also plan on using them more, and even adding them to my app, Get Assistant if I have time.

Also, thanks for the gorgeous customized toasts, they look great!

Here's my app: https://play.google.com/store/apps/details?id=com.trivisionzero.chromophoto

The latest update is 1.5, I just published it, so it may take a while to roll out everywhere.

documentation question: what does "withIcon" stand for?

Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, textColor, tintColor, duration, withIcon, true).show();

what does "withIcon" stand for?
Also is their a way to have your own custom colors while using Toasty's default icons like the checkmark?

重复弹出

hi 博主,这个toast会重复弹出。可以优化一下

[Refactoring] Exude color variables to resources

I think it will be better to move color variables into resource file.

  1. It will reduce code duplication

  2. it will increase readability, since I thought through code that warning and error colors are constants, also actualy they not

  3. It will give the user more flexibility to config toast. They will able to rewrite your color resources in their own complex resources files. Suppose, we have aaplication, that for different regions use different color schemes. With code-config-aproach it will request for library user more effort to adjust colors by config changes, that if colors were in resource file

Toast.LENGTH_LONG does not work on Android 7.1 in onCreate()

Android OS version 7.1

when I call Toasty in onCreate(), Toasty show only 1 sec.
This probrem causes only Android 7.1.
Toast.makeText(LENGTH_LONG).show() works fine.

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toasty.success(getApplicationContext(), "this toast show only 1 sec",  Toast.LENGTH_LONG).show(); // (A)
        }
    });

    Toasty.success(getApplicationContext(), "this toast show 4 sec", Toast.LENGTH_LONG).show(); // (B)



}

}

after adding your library in project these errors come up

build error

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
C:\Users\tariq\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\d8468f24b31c24ee8d29575dc26584f6\res\values-v26\values-v26.xml
Error:(9, 5) error: resource android:attr/colorError not found.
Error:(13, 5) error: resource android:attr/colorError not found.
Error:(17, 5) error: style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\tariq\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\d8468f24b31c24ee8d29575dc26584f6\res\values\values.xml
Error:(252, 5) error: resource android:attr/fontStyle not found.
Error:(252, 5) error: resource android:attr/font not found.
Error:(252, 5) error: resource android:attr/fontWeight not found.
C:\Users\tariq\Desktop\adnan laravel android pharamacy\materiallogindemo-master\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml
Error:(7) resource android:attr/colorError not found.
Error:(11) resource android:attr/colorError not found.
Error:(15) style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\tariq\Desktop\adnan laravel android pharamacy\materiallogindemo-master\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(438) resource android:attr/fontStyle not found.
Error:(438) resource android:attr/font not found.
Error:(438) resource android:attr/fontWeight not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 13s
Information:17 errors
Information:0 warnings
Information:See complete output in console

v1.2.0 Removes Set Text Color, Why?

Hi @GrenderG ,
This library is absolutely amazing and I am currently using it in 3 apps! Today when I upgraded from v1.1.5 to 1.2.0, the existing code broke because the set text color value was removed. Why was set text color removed? How is text color controlled now? Thank you for your great work!

How to set custom toast?

Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon, 
shouldTint).show();

I want to use this to make a custom toast but the problem is I cannot understand what is tintColor here for? is it for the text or background of the toast?
Could you please post an example for clearer understanding?

Toasty.custom(this, "Success!", R.drawable.ic_check_circle_black_24dp, R.color.white, Toast.LENGTH_SHORT, withIcon, R.color.success).show();
I have done this so far and stuck with the withIcon thing.

Any help would be appreciated.

java.lang.NoSuchFieldError

java.lang.NoSuchFieldError: No static field toast_icon of type I in class Les/dmoral/toasty/R$id; or its superclasses (declaration of 'es.dmoral.toasty.R$id' appears in

Toast overlap problem

The previous toast should be cancelled when a new toast is emitted. The new toast should be displayed immediately instead of cumulating all toasts and times in a "queue".

Could you please fix this? Do you have a workaround for this problem for me?

can`t show icon

To display the usual Toast with icon:

Toasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show();

i use :
Toasty.normal(MainActivity.this, "Icon Toast", R.drawable.ic_check_circle_black_24dp).show();

is the same as : Toasty.normal(MainActivity.this, "Normal Toast").show();

Change Toast Color Feature

Wow, these toasts look amazing! A definite upgrade to the system default toast messages. I have a quick question about the toast features. Is it possible to customize the color of a toast message? I see that there are different types of toast notifications such as Red for error, Green for success, and Grey for Normal. Would it not be easier to just have one toast that can be customized with the desired color?

Border Color, Thickness etc

Hi @GrenderG

Great plugin you have here, just request if possible to have or assign the toast borders etc
Something like ...

  • borderColor (all borders of toast message color)
  • borderThickness (all borders of toast message thickness)
  • borderLeftColor (left border of toast message color)
  • borderLeftThickness (left border of toast message thickness)
  • etc

Programmatically

Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, textColor, tintColor, duration, withIcon, borderLeftThickness, borderLeftColor, true).show();

AndroidManifest.xml application label

Hi, is there any specific reason as to why android:label is used in the library? I'm asking since it causes conflicts when merging the AndroidManifests.

Now, I know there's workarounds (like using tools:replace) but if it's not needed, could you remove it? It just adds unnecessary clutter.

Thanks in advance 👍

Toasty not accept string from strings file

when i try to make this
Toasty.error(SignUpActivity.this, getString(R.string.action_save));
update: not add .show yet

it not accept it it want a charsequesne how to solve this ?

java.lang.NoSuchFieldError: No static field toast_icon of type I in class Les/dmoral/toasty/R$id; or its superclasses (declaration of 'es.dmoral.toasty.R$id' appears in /data/app/com.***

as 3.0.1
build.gradle
compileSdkVersion 26 buildToolsVersion "26.0.3" minSdkVersion 16 targetSdkVersion 26 compile 'com.github.GrenderG:Toasty:1.2.8'

Activity
Toasty.success(applicationContext, "sss").show()

error msg
01-03 16:47:27.553 26958-26958/com.dreamtd.tapplay E/AndroidRuntime: FATAL EXCEPTION: main Process: com.dreamtd.tapplay, PID: 26958 java.lang.NoSuchFieldError: No static field toast_icon of type I in class Les/dmoral/toasty/R$id; or its superclasses (declaration of 'es.dmoral.toasty.R$id' appears in /data/app/com.dreamtd.tapplay-2/base.apk:classes22.dex) at es.dmoral.toasty.Toasty.custom(Toasty.java:174) at es.dmoral.toasty.Toasty.success(Toasty.java:132) at es.dmoral.toasty.Toasty.success(Toasty.java:122)

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.