Repository: GrenderG/Toasty Branch: master Commit: 1d9a280da12a Files: 39 Total size: 69.2 KB Directory structure: gitextract_90zdvycu/ ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── es/ │ │ └── dmoral/ │ │ └── toastysample/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── assets/ │ │ │ └── PCap Terminal.otf │ │ ├── java/ │ │ │ └── es/ │ │ │ └── dmoral/ │ │ │ └── toastysample/ │ │ │ └── MainActivity.java │ │ └── res/ │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── es/ │ └── dmoral/ │ └── toastysample/ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── toasty/ ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src/ ├── androidTest/ │ └── java/ │ └── es/ │ └── dmoral/ │ └── toasty/ │ └── ExampleInstrumentedTest.java ├── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── es/ │ │ └── dmoral/ │ │ └── toasty/ │ │ ├── Toasty.java │ │ └── ToastyUtils.java │ └── res/ │ ├── drawable/ │ │ ├── ic_check_white_24dp.xml │ │ ├── ic_clear_white_24dp.xml │ │ ├── ic_error_outline_white_24dp.xml │ │ └── ic_info_outline_white_24dp.xml │ ├── layout/ │ │ └── toast_layout.xml │ └── values/ │ ├── colors.xml │ └── strings.xml └── test/ └── java/ └── es/ └── dmoral/ └── toasty/ └── ExampleUnitTest.java ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Built application files *.apk *.ap_ # Files for the ART/Dalvik VM *.dex # Java class files *.class # Generated files bin/ gen/ out/ # Gradle files .gradle/ build/ # Local configuration file (sdk path, etc) local.properties # Proguard folder generated by Eclipse proguard/ # Log Files *.log # Android Studio Navigation editor temp files .navigation/ # Android Studio captures folder captures/ # Intellij *.iml .idea/workspace.xml # Keystore files *.jks .idea ================================================ FILE: LICENSE ================================================ GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ================================================ FILE: README.md ================================================ [![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R21LO82) # Toasty [![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14) [![](https://jitpack.io/v/GrenderG/Toasty.svg)](https://jitpack.io/#GrenderG/Toasty) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Toasty-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5102)
The usual Toast, but with steroids. ## Prerequisites Add this in your root `build.gradle` file (**not** your module `build.gradle` file): ```gradle 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): ```gradle 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: ```java 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: ```java 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: ``` java Toasty.error(yourContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show(); ``` To display a success Toast: ``` java Toasty.success(yourContext, "Success!", Toast.LENGTH_SHORT, true).show(); ``` To display an info Toast: ``` java Toasty.info(yourContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show(); ``` To display a warning Toast: ``` java Toasty.warning(yourContext, "Beware of the dog.", Toast.LENGTH_SHORT, true).show(); ``` To display the usual Toast: ``` java Toasty.normal(yourContext, "Normal toast w/o icon").show(); ``` To display the usual Toast with icon: ``` java Toasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show(); ``` You can also create your custom Toasts with the `custom()` method: ``` java Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon, shouldTint).show(); ``` ### Extra [You can pass formatted text to Toasty!](https://github.com/GrenderG/Toasty/blob/master/app/src/main/java/es/dmoral/toastysample/MainActivity.java#L98-L107) **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](https://github.com/facebook/react-native) via this [module](https://github.com/prscX/react-native-toasty). 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
================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { applicationId "es.dmoral.toastysample" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation "androidx.appcompat:appcompat:$supportLibVersion" testImplementation 'junit:junit:4.12' implementation project(':toasty') } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /home/grender/Android/Sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: app/src/androidTest/java/es/dmoral/toastysample/ExampleInstrumentedTest.java ================================================ package es.dmoral.toastysample; import android.content.Context; import androidx.test.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Instrumentation test, which will execute on an Android device. * * @see Testing documentation */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("es.dmoral.toastysample", appContext.getPackageName()); } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/es/dmoral/toastysample/MainActivity.java ================================================ package es.dmoral.toastysample; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.StyleSpan; import android.view.View; import es.dmoral.toasty.Toasty; import static android.graphics.Typeface.BOLD_ITALIC; /** * This file is part of Toasty. * * Toasty is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Toasty is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Toasty. If not, see . */ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.button_error_toast).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.error(MainActivity.this, R.string.error_message, Toasty.LENGTH_SHORT, true).show(); } }); findViewById(R.id.button_success_toast).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.success(MainActivity.this, R.string.success_message, Toasty.LENGTH_SHORT, true).show(); } }); findViewById(R.id.button_info_toast).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.info(MainActivity.this, R.string.info_message, Toasty.LENGTH_SHORT, true).show(); } }); findViewById(R.id.button_warning_toast).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.warning(MainActivity.this, R.string.warning_message, Toasty.LENGTH_SHORT, true).show(); } }); findViewById(R.id.button_normal_toast_wo_icon).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.normal(MainActivity.this, R.string.normal_message_without_icon).show(); } }); findViewById(R.id.button_normal_toast_w_icon).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Drawable icon = getResources().getDrawable(R.drawable.ic_pets_white_48dp); Toasty.normal(MainActivity.this, R.string.normal_message_with_icon, icon).show(); } }); findViewById(R.id.button_info_toast_with_formatting).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.info(MainActivity.this, getFormattedMessage()).show(); } }); findViewById(R.id.button_custom_config).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toasty.Config.getInstance() .setToastTypeface(Typeface.createFromAsset(getAssets(), "PCap Terminal.otf")) .allowQueue(false) .apply(); Toasty.custom(MainActivity.this, R.string.custom_message, getResources().getDrawable(R.drawable.laptop512), android.R.color.black, android.R.color.holo_green_light, Toasty.LENGTH_SHORT, true, true).show(); Toasty.Config.reset(); // Use this if you want to use the configuration above only once } }); } private CharSequence getFormattedMessage() { final String prefix = "Formatted "; final String highlight = "bold italic"; final String suffix = " text"; SpannableStringBuilder ssb = new SpannableStringBuilder(prefix).append(highlight).append(suffix); int prefixLen = prefix.length(); ssb.setSpan(new StyleSpan(BOLD_ITALIC), prefixLen, prefixLen + highlight.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return ssb; } } ================================================ FILE: app/src/main/res/layout/activity_main.xml ================================================