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. <http://fsf.org/>
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
================================================
[](https://ko-fi.com/R6R21LO82)
# Toasty
[](https://android-arsenal.com/api?level=14) [](https://jitpack.io/#GrenderG/Toasty) [](https://android-arsenal.com/details/1/5102)
<div align="center">
<img src="https://raw.githubusercontent.com/GrenderG/Toasty/master/art/web_hi_res_512.png" width="128">
</div>
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.**
<img src="https://raw.githubusercontent.com/GrenderG/Toasty/master/art/collage.png">
## 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`.
<table>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=cheetatech.com.colorhub"><img src="https://archive.org/download/ic_launcher_colorhub/ic_launcher_colorhub.png" width="64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=cheetatech.com.colorhub">ColorHub - Color Palette</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.fa.daily.free"><img src="https://lh3.googleusercontent.com/rXB22UBHujsK2uYpN-kAkVFBjTcnAp6ltSZYf9-LdYvRkM-kF-xtwPwR8kEInhludA=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.fa.daily.free">Daily – News flipped around</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=es.jmoral.ozreader"><img src="https://lh3.googleusercontent.com/ISQPSPA__uWU4Csw4N0quI0IPi_WcWN0pY4PK86yljf39vaCObvohT9ak2ubQ7iLDQ=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=es.jmoral.ozreader">Oz! Comic Reader</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.andreacioccarelli.impactor"><img src="https://lh3.googleusercontent.com/KxzCiu-csleONAW9kfAYBCaCe4iAnhyO1ziuKjKK_yEDE0xPQMfy_-sYVYkj4RBE-Srt=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.andreacioccarelli.impactor">Impactor Unroot</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.andreacioccarelli.fusemounter"><img src="https://lh3.googleusercontent.com/7e0iTo60TJXz6U-zQl6pXcfgRCLifQaTp_DczwNA5ZSnrEssBwH6K0MU88gC9BzQlMY=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.andreacioccarelli.fusemounter">Fusemounter</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.thesrb.bluewords&referrer=utm_source%3Dgithub%26utm_medium%3Dtoasty%26utm_content%3Dlogo%26utm_campaign%3Dreadme"><img src="https://lh3.googleusercontent.com/gdGrQHkHsfRAY9ivf8wt9vgaX9KPxpFHdFq5AXY_zw2P8Wat3KNstvf-BkNaKrNX8Qg=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.thesrb.bluewords&referrer=utm_source%3Dgithub%26utm_medium%3Dtoasty%26utm_content%3Dname%26utm_campaign%3Dreadme">BlueWords</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.levionsoftware.instagram_map"><img src="https://lh3.googleusercontent.com/QL0QDLXBm9j2Y2An4MOZtlbI02yx_zuI7I3vMBM_mBO_BbimNKjBQeldQBBKo0P60Og=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.levionsoftware.instagram_map">Photo Map - Photo and Video Gallery</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.sunshine.makilite"><img src="https://lh3.googleusercontent.com/RL082J8D9AyVJdyoT8sN8Mb47LUJEn3ssvp8jgrke_K_sWAXgEl9F8tjudqDoL7y5A0=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.sunshine.makilite">Maki for Facebook & Twitter</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.KillerBLS.modpeide"><img src="https://lh3.googleusercontent.com/nyB12hF6cPHBrm532qQQslvj-X-klmPlKuQ4Z0MYKDpt4sPVZmWYRZ_SShEfVcTmhg=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.KillerBLS.modpeide">ModPE IDE</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=stream.rocketnotes"><img src="https://lh3.googleusercontent.com/tYGJBG8mc7lwC0ZxQUxif2FVMFI8L8xRkPON0ytkWVPTI67ggkrgDl3JpRu9jW0W3sLJ=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=stream.rocketnotes">Rocket Notes</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.thirtydegreesray.openhub"><img src="https://lh3.googleusercontent.com/XP-tvaGf-as9XMQ3kcUjohSZlSD7uyf_AcHsjq6jTI0chXWK1yQrnJJs2Y_Pvbe1FRQ=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.thirtydegreesray.openhub">OpenHub for GitHub</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=org.openhab.habdroid"><img src="https://lh3.googleusercontent.com/RhinsfPN8qFHQDyPKssmiPl4P_-JJpw7GaQO4K7TVixMjrkZsPh0NPXlL2nJRrR4PAbw=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=org.openhab.habdroid">openHAB</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=org.saarang.app"><img src="https://lh3.googleusercontent.com/m683OsEgBAU15kdHOSsl-lckDPEa0bdsK2xvhq3Qs4vww-ueJnW8xY0xXfwfMV6dOyE=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=org.saarang.app">Saarang</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.dizdarevic.kadcemibus"><img src="https://lh3.googleusercontent.com/LFUKgzu8S1V8TSLg3aiFoA7dkfUYmQg6s8lVUSPJYEkv6564UKjaUKhYcqvFMyDbSas=w64"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.dizdarevic.kadcemibus">Kad ce mi bus - red voznje</a></td>
</tr>
<tr>
<td><a href="https://play.google.com/store/apps/details?id=com.katyayini.hidefiles"><img src="https://lh3.googleusercontent.com/hq2dLHXjKoTonzE45uJKzkGfCUSSh0_IJZBnuRIyb8G_EbcpYT5_gPv942yrIKlyo12r=s64-rw"/></a></td>
<td><a href="https://play.google.com/store/apps/details?id=com.katyayini.hidefiles">Hide Files</a></td>
</tr>
<tr>
<td><a href="https://github.com/nikothegreek/logviewer-for-openhab-app"><img src="https://i.imgur.com/a6RbPkJ.png"/></a></td>
<td><a href="https://github.com/nikothegreek/logviewer-for-openhab-app">LogViewer for openHAB</a></td>
</tr>
</table>
================================================
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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.dmoral.toastysample">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
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 <http://www.gnu.org/licenses/>.
*/
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
================================================
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="es.dmoral.toastysample.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<Button
android:text="@string/error_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_error_toast"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/success_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_error_toast"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_success_toast"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/info_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_success_toast"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_info_toast"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/info_toast_with_formatting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_info_toast"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_info_toast_with_formatting"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/warning_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_info_toast_with_formatting"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="@+id/button_warning_toast" />
<Button
android:text="@string/normal_toast_without_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_warning_toast"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_normal_toast_wo_icon"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/normal_toast_with_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_normal_toast_wo_icon"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_normal_toast_w_icon"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/custom_configuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_normal_toast_w_icon"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_custom_config"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</ScrollView>
================================================
FILE: app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">Toasty Sample</string>
<string name="normal_toast_with_icon">NORMAL TOAST (WITH ICON)</string>
<string name="normal_toast_without_icon">NORMAL TOAST (WITHOUT ICON)</string>
<string name="warning_toast">WARNING TOAST</string>
<string name="info_toast">INFO TOAST</string>
<string name="info_toast_with_formatting">INFO TOAST WITH FORMATTING</string>
<string name="error_toast">ERROR TOAST</string>
<string name="success_toast">SUCCESS TOAST</string>
<string name="custom_configuration">CUSTOM CONFIGURATION</string>
<string name="error_message">This is an error toast.</string>
<string name="success_message">Success!</string>
<string name="info_message">Here is some info for you.</string>
<string name="warning_message">Beware of the dog.</string>
<string name="normal_message_without_icon">Normal toast w/o icon</string>
<string name="normal_message_with_icon">Normal toast w/ icon</string>
<string name="custom_message">sudo kill -9 everyone</string>
</resources>
================================================
FILE: app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: app/src/test/java/es/dmoral/toastysample/ExampleUnitTest.java
================================================
package es.dmoral.toastysample;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
ext {
compileSdkVersion = 31
minSdkVersion = 14
targetSdkVersion = compileSdkVersion
supportLibVersion = '1.3.1'
versionCode = 152
versionName = '1.5.2'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Sun Sep 05 22:23:56 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
================================================
FILE: gradle.properties
================================================
# POM
POM_URL=https://github.com/GrenderG/Toasty
POM_SCM_URL=https://github.com/GrenderG/Toasty
POM_SCM_CONNECTION=scm:git@github.com:GrenderG/Toasty.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:GrenderG/Toasty.git
POM_SCM_URL_ISSUES=https://github.com/GrenderG/Toasty/issues
POM_GITHUB_REPO=GrenderG/Toasty
POM_GITHUB_README=README.md
POM_LICENCE_NAME=The GNU Lesser General Public License, Version 3.0
POM_LICENCE_URL=http://www.gnu.org/licenses/lgpl-3.0.html
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=GrenderG
POM_DEVELOPER_NAME=GrenderG
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
include ':app', ':toasty'
================================================
FILE: toasty/.gitignore
================================================
/build
================================================
FILE: toasty/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.GrenderG'
version = rootProject.ext.versionName
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$supportLibVersion"
}
================================================
FILE: toasty/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: toasty/src/androidTest/java/es/dmoral/toasty/ExampleInstrumentedTest.java
================================================
package es.dmoral.toasty;
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.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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.toasty.test", appContext.getPackageName());
}
}
================================================
FILE: toasty/src/main/AndroidManifest.xml
================================================
<manifest package="es.dmoral.toasty">
</manifest>
================================================
FILE: toasty/src/main/java/es/dmoral/toasty/Toasty.java
================================================
package es.dmoral.toasty;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import android.os.Build;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
/**
* This file is part of Toasty.
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with Toasty. If not, see <http://www.gnu.org/licenses/>.
*/
@SuppressLint("InflateParams")
public class Toasty {
private static final Typeface LOADED_TOAST_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
private static Typeface currentTypeface = LOADED_TOAST_TYPEFACE;
private static int textSize = 16; // in SP
private static boolean tintIcon = true;
private static boolean allowQueue = true;
private static int toastGravity = -1;
private static int xOffset = -1;
private static int yOffset = -1;
private static boolean supportDarkTheme = true;
private static boolean isRTL = false;
private static Toast lastToast = null;
public static final int LENGTH_SHORT = Toast.LENGTH_SHORT;
public static final int LENGTH_LONG = Toast.LENGTH_LONG;
private Toasty() {
// avoiding instantiation
}
@CheckResult
public static Toast normal(@NonNull Context context, @StringRes int message) {
return normal(context, context.getString(message), Toast.LENGTH_SHORT, null, false);
}
@CheckResult
public static Toast normal(@NonNull Context context, @NonNull CharSequence message) {
return normal(context, message, Toast.LENGTH_SHORT, null, false);
}
@CheckResult
public static Toast normal(@NonNull Context context, @StringRes int message, Drawable icon) {
return normal(context, context.getString(message), Toast.LENGTH_SHORT, icon, true);
}
@CheckResult
public static Toast normal(@NonNull Context context, @NonNull CharSequence message, Drawable icon) {
return normal(context, message, Toast.LENGTH_SHORT, icon, true);
}
@CheckResult
public static Toast normal(@NonNull Context context, @StringRes int message, int duration) {
return normal(context, context.getString(message), duration, null, false);
}
@CheckResult
public static Toast normal(@NonNull Context context, @NonNull CharSequence message, int duration) {
return normal(context, message, duration, null, false);
}
@CheckResult
public static Toast normal(@NonNull Context context, @StringRes int message, int duration,
Drawable icon) {
return normal(context, context.getString(message), duration, icon, true);
}
@CheckResult
public static Toast normal(@NonNull Context context, @NonNull CharSequence message, int duration,
Drawable icon) {
return normal(context, message, duration, icon, true);
}
@CheckResult
public static Toast normal(@NonNull Context context, @StringRes int message, int duration,
Drawable icon, boolean withIcon) {
return normalWithDarkThemeSupport(context, context.getString(message), icon, duration, withIcon);
}
@CheckResult
public static Toast normal(@NonNull Context context, @NonNull CharSequence message, int duration,
Drawable icon, boolean withIcon) {
return normalWithDarkThemeSupport(context, message, icon, duration, withIcon);
}
@CheckResult
public static Toast warning(@NonNull Context context, @StringRes int message) {
return warning(context, context.getString(message), Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast warning(@NonNull Context context, @NonNull CharSequence message) {
return warning(context, message, Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast warning(@NonNull Context context, @StringRes int message, int duration) {
return warning(context, context.getString(message), duration, true);
}
@CheckResult
public static Toast warning(@NonNull Context context, @NonNull CharSequence message, int duration) {
return warning(context, message, duration, true);
}
@CheckResult
public static Toast warning(@NonNull Context context, @StringRes int message, int duration, boolean withIcon) {
return custom(context, context.getString(message), ToastyUtils.getDrawable(context, R.drawable.ic_error_outline_white_24dp),
ToastyUtils.getColor(context, R.color.warningColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast warning(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
return custom(context, message, ToastyUtils.getDrawable(context, R.drawable.ic_error_outline_white_24dp),
ToastyUtils.getColor(context, R.color.warningColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast info(@NonNull Context context, @StringRes int message) {
return info(context, context.getString(message), Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast info(@NonNull Context context, @NonNull CharSequence message) {
return info(context, message, Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast info(@NonNull Context context, @StringRes int message, int duration) {
return info(context, context.getString(message), duration, true);
}
@CheckResult
public static Toast info(@NonNull Context context, @NonNull CharSequence message, int duration) {
return info(context, message, duration, true);
}
@CheckResult
public static Toast info(@NonNull Context context, @StringRes int message, int duration, boolean withIcon) {
return custom(context, context.getString(message), ToastyUtils.getDrawable(context, R.drawable.ic_info_outline_white_24dp),
ToastyUtils.getColor(context, R.color.infoColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast info(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
return custom(context, message, ToastyUtils.getDrawable(context, R.drawable.ic_info_outline_white_24dp),
ToastyUtils.getColor(context, R.color.infoColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast success(@NonNull Context context, @StringRes int message) {
return success(context, context.getString(message), Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast success(@NonNull Context context, @NonNull CharSequence message) {
return success(context, message, Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast success(@NonNull Context context, @StringRes int message, int duration) {
return success(context, context.getString(message), duration, true);
}
@CheckResult
public static Toast success(@NonNull Context context, @NonNull CharSequence message, int duration) {
return success(context, message, duration, true);
}
@CheckResult
public static Toast success(@NonNull Context context, @StringRes int message, int duration, boolean withIcon) {
return custom(context, context.getString(message), ToastyUtils.getDrawable(context, R.drawable.ic_check_white_24dp),
ToastyUtils.getColor(context, R.color.successColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast success(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
return custom(context, message, ToastyUtils.getDrawable(context, R.drawable.ic_check_white_24dp),
ToastyUtils.getColor(context, R.color.successColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast error(@NonNull Context context, @StringRes int message) {
return error(context, context.getString(message), Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast error(@NonNull Context context, @NonNull CharSequence message) {
return error(context, message, Toast.LENGTH_SHORT, true);
}
@CheckResult
public static Toast error(@NonNull Context context, @StringRes int message, int duration) {
return error(context, context.getString(message), duration, true);
}
@CheckResult
public static Toast error(@NonNull Context context, @NonNull CharSequence message, int duration) {
return error(context, message, duration, true);
}
@CheckResult
public static Toast error(@NonNull Context context, @StringRes int message, int duration, boolean withIcon) {
return custom(context, context.getString(message), ToastyUtils.getDrawable(context, R.drawable.ic_clear_white_24dp),
ToastyUtils.getColor(context, R.color.errorColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast error(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
return custom(context, message, ToastyUtils.getDrawable(context, R.drawable.ic_clear_white_24dp),
ToastyUtils.getColor(context, R.color.errorColor), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, true);
}
@CheckResult
public static Toast custom(@NonNull Context context, @StringRes int message, Drawable icon,
int duration, boolean withIcon) {
return custom(context, context.getString(message), icon, -1, ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, false);
}
@CheckResult
public static Toast custom(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
int duration, boolean withIcon) {
return custom(context, message, icon, -1, ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, false);
}
@CheckResult
public static Toast custom(@NonNull Context context, @StringRes int message, @DrawableRes int iconRes,
@ColorRes int tintColorRes, int duration,
boolean withIcon, boolean shouldTint) {
return custom(context, context.getString(message), ToastyUtils.getDrawable(context, iconRes),
ToastyUtils.getColor(context, tintColorRes), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, shouldTint);
}
@CheckResult
public static Toast custom(@NonNull Context context, @NonNull CharSequence message, @DrawableRes int iconRes,
@ColorRes int tintColorRes, int duration,
boolean withIcon, boolean shouldTint) {
return custom(context, message, ToastyUtils.getDrawable(context, iconRes),
ToastyUtils.getColor(context, tintColorRes), ToastyUtils.getColor(context, R.color.defaultTextColor),
duration, withIcon, shouldTint);
}
@CheckResult
public static Toast custom(@NonNull Context context, @StringRes int message, Drawable icon,
@ColorRes int tintColorRes, int duration,
boolean withIcon, boolean shouldTint) {
return custom(context, context.getString(message), icon, ToastyUtils.getColor(context, tintColorRes),
ToastyUtils.getColor(context, R.color.defaultTextColor), duration, withIcon, shouldTint);
}
@CheckResult
public static Toast custom(@NonNull Context context, @StringRes int message, Drawable icon,
@ColorRes int tintColorRes, @ColorRes int textColorRes, int duration,
boolean withIcon, boolean shouldTint) {
return custom(context, context.getString(message), icon, ToastyUtils.getColor(context, tintColorRes),
ToastyUtils.getColor(context, textColorRes), duration, withIcon, shouldTint);
}
@SuppressLint("ShowToast")
@CheckResult
public static Toast custom(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
@ColorInt int tintColor, @ColorInt int textColor, int duration,
boolean withIcon, boolean shouldTint) {
final Toast currentToast = Toast.makeText(context, "", duration);
final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.toast_layout, null);
final LinearLayout toastRoot = toastLayout.findViewById(R.id.toast_root);
final ImageView toastIcon = toastLayout.findViewById(R.id.toast_icon);
final TextView toastTextView = toastLayout.findViewById(R.id.toast_text);
Drawable drawableFrame;
if (shouldTint)
drawableFrame = ToastyUtils.tint9PatchDrawableFrame(context, tintColor);
else
drawableFrame = ToastyUtils.getDrawable(context, R.drawable.toast_frame);
ToastyUtils.setBackground(toastLayout, drawableFrame);
if (withIcon) {
if (icon == null)
throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
if (isRTL && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
toastRoot.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
ToastyUtils.setBackground(toastIcon, tintIcon ? ToastyUtils.tintIcon(icon, textColor) : icon);
} else {
toastIcon.setVisibility(View.GONE);
}
toastTextView.setText(message);
toastTextView.setTextColor(textColor);
toastTextView.setTypeface(currentTypeface);
toastTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
currentToast.setView(toastLayout);
if (!allowQueue) {
if (lastToast != null)
lastToast.cancel();
lastToast = currentToast;
}
// Make sure to use default values for non-specified ones.
currentToast.setGravity(
toastGravity == -1 ? currentToast.getGravity() : toastGravity,
xOffset == -1 ? currentToast.getXOffset() : xOffset,
yOffset == -1 ? currentToast.getYOffset() : yOffset
);
return currentToast;
}
private static Toast normalWithDarkThemeSupport(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
int duration, boolean withIcon) {
if (supportDarkTheme && Build.VERSION.SDK_INT >= 29) {
int uiMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (uiMode == Configuration.UI_MODE_NIGHT_NO) {
return withLightTheme(context, message, icon, duration, withIcon);
}
return withDarkTheme(context, message, icon, duration, withIcon);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
return withLightTheme(context, message, icon, duration, withIcon);
} else {
return withDarkTheme(context, message, icon, duration, withIcon);
}
}
}
private static Toast withLightTheme(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
int duration, boolean withIcon) {
return custom(context, message, icon, ToastyUtils.getColor(context, R.color.defaultTextColor),
ToastyUtils.getColor(context, R.color.normalColor), duration, withIcon, true);
}
private static Toast withDarkTheme(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
int duration, boolean withIcon) {
return custom(context, message, icon, ToastyUtils.getColor(context, R.color.normalColor),
ToastyUtils.getColor(context, R.color.defaultTextColor), duration, withIcon, true);
}
public static class Config {
private Typeface typeface = Toasty.currentTypeface;
private int textSize = Toasty.textSize;
private boolean tintIcon = Toasty.tintIcon;
private boolean allowQueue = true;
private int toastGravity = Toasty.toastGravity;
private int xOffset = Toasty.xOffset;
private int yOffset = Toasty.yOffset;
private boolean supportDarkTheme = true;
private boolean isRTL = false;
private Config() {
// avoiding instantiation
}
@CheckResult
public static Config getInstance() {
return new Config();
}
public static void reset() {
Toasty.currentTypeface = LOADED_TOAST_TYPEFACE;
Toasty.textSize = 16;
Toasty.tintIcon = true;
Toasty.allowQueue = true;
Toasty.toastGravity = -1;
Toasty.xOffset = -1;
Toasty.yOffset = -1;
Toasty.supportDarkTheme = true;
Toasty.isRTL = false;
}
@CheckResult
public Config setToastTypeface(@NonNull Typeface typeface) {
this.typeface = typeface;
return this;
}
@CheckResult
public Config setTextSize(int sizeInSp) {
this.textSize = sizeInSp;
return this;
}
@CheckResult
public Config tintIcon(boolean tintIcon) {
this.tintIcon = tintIcon;
return this;
}
@CheckResult
public Config allowQueue(boolean allowQueue) {
this.allowQueue = allowQueue;
return this;
}
@CheckResult
public Config setGravity(int gravity, int xOffset, int yOffset) {
this.toastGravity = gravity;
this.xOffset = xOffset;
this.yOffset = yOffset;
return this;
}
@CheckResult
public Config setGravity(int gravity) {
this.toastGravity = gravity;
return this;
}
@CheckResult
public Config supportDarkTheme(boolean supportDarkTheme) {
this.supportDarkTheme = supportDarkTheme;
return this;
}
public Config setRTL(boolean isRTL) {
this.isRTL = isRTL;
return this;
}
public void apply() {
Toasty.currentTypeface = typeface;
Toasty.textSize = textSize;
Toasty.tintIcon = tintIcon;
Toasty.allowQueue = allowQueue;
Toasty.toastGravity = toastGravity;
Toasty.xOffset = xOffset;
Toasty.yOffset = yOffset;
Toasty.supportDarkTheme = supportDarkTheme;
Toasty.isRTL = isRTL;
}
}
}
================================================
FILE: toasty/src/main/java/es/dmoral/toasty/ToastyUtils.java
================================================
package es.dmoral.toasty;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.appcompat.content.res.AppCompatResources;
import android.view.View;
/**
* 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 <http://www.gnu.org/licenses/>.
*/
final class ToastyUtils {
private ToastyUtils() {
}
static Drawable tintIcon(@NonNull Drawable drawable, @ColorInt int tintColor) {
drawable.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
return drawable;
}
static Drawable tint9PatchDrawableFrame(@NonNull Context context, @ColorInt int tintColor) {
final NinePatchDrawable toastDrawable = (NinePatchDrawable) getDrawable(context, R.drawable.toast_frame);
return tintIcon(toastDrawable, tintColor);
}
static void setBackground(@NonNull View view, Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
view.setBackground(drawable);
else
view.setBackgroundDrawable(drawable);
}
static Drawable getDrawable(@NonNull Context context, @DrawableRes int id) {
return AppCompatResources.getDrawable(context, id);
}
static int getColor(@NonNull Context context, @ColorRes int color){
return ContextCompat.getColor(context, color);
}
}
================================================
FILE: toasty/src/main/res/drawable/ic_check_white_24dp.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z" />
</vector>
================================================
FILE: toasty/src/main/res/drawable/ic_clear_white_24dp.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
</vector>
================================================
FILE: toasty/src/main/res/drawable/ic_error_outline_white_24dp.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector>
================================================
FILE: toasty/src/main/res/drawable/ic_info_outline_white_24dp.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
</vector>
================================================
FILE: toasty/src/main/res/layout/toast_layout.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toast_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:gravity="center"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/toast_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:contentDescription="@string/toast_message" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
================================================
FILE: toasty/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="defaultTextColor">#FFFFFF</color>
<color name="errorColor">#D50000</color>
<color name="infoColor">#3F51B5</color>
<color name="successColor">#388E3C</color>
<color name="warningColor">#FFA900</color>
<color name="normalColor">#353A3E</color>
</resources>
================================================
FILE: toasty/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">Toasty</string>
<string name="toast_message">Toast message</string>
</resources>
================================================
FILE: toasty/src/test/java/es/dmoral/toasty/ExampleUnitTest.java
================================================
package es.dmoral.toasty;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
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
SYMBOL INDEX (77 symbols across 7 files)
FILE: app/src/androidTest/java/es/dmoral/toastysample/ExampleInstrumentedTest.java
class ExampleInstrumentedTest (line 17) | @RunWith(AndroidJUnit4.class)
method useAppContext (line 19) | @Test
FILE: app/src/main/java/es/dmoral/toastysample/MainActivity.java
class MainActivity (line 33) | public class MainActivity extends AppCompatActivity {
method onCreate (line 34) | @Override
method getFormattedMessage (line 96) | private CharSequence getFormattedMessage() {
FILE: app/src/test/java/es/dmoral/toastysample/ExampleUnitTest.java
class ExampleUnitTest (line 12) | public class ExampleUnitTest {
method addition_isCorrect (line 13) | @Test
FILE: toasty/src/androidTest/java/es/dmoral/toasty/ExampleInstrumentedTest.java
class ExampleInstrumentedTest (line 17) | @RunWith(AndroidJUnit4.class)
method useAppContext (line 19) | @Test
FILE: toasty/src/main/java/es/dmoral/toasty/Toasty.java
class Toasty (line 40) | @SuppressLint("InflateParams")
method Toasty (line 59) | private Toasty() {
method normal (line 63) | @CheckResult
method normal (line 68) | @CheckResult
method normal (line 73) | @CheckResult
method normal (line 78) | @CheckResult
method normal (line 83) | @CheckResult
method normal (line 88) | @CheckResult
method normal (line 93) | @CheckResult
method normal (line 99) | @CheckResult
method normal (line 105) | @CheckResult
method normal (line 111) | @CheckResult
method warning (line 117) | @CheckResult
method warning (line 122) | @CheckResult
method warning (line 127) | @CheckResult
method warning (line 132) | @CheckResult
method warning (line 137) | @CheckResult
method warning (line 144) | @CheckResult
method info (line 151) | @CheckResult
method info (line 156) | @CheckResult
method info (line 161) | @CheckResult
method info (line 166) | @CheckResult
method info (line 171) | @CheckResult
method info (line 178) | @CheckResult
method success (line 185) | @CheckResult
method success (line 190) | @CheckResult
method success (line 195) | @CheckResult
method success (line 200) | @CheckResult
method success (line 205) | @CheckResult
method success (line 212) | @CheckResult
method error (line 219) | @CheckResult
method error (line 224) | @CheckResult
method error (line 229) | @CheckResult
method error (line 234) | @CheckResult
method error (line 239) | @CheckResult
method error (line 246) | @CheckResult
method custom (line 253) | @CheckResult
method custom (line 260) | @CheckResult
method custom (line 267) | @CheckResult
method custom (line 276) | @CheckResult
method custom (line 285) | @CheckResult
method custom (line 293) | @CheckResult
method custom (line 301) | @SuppressLint("ShowToast")
method normalWithDarkThemeSupport (line 353) | private static Toast normalWithDarkThemeSupport(@NonNull Context conte...
method withLightTheme (line 370) | private static Toast withLightTheme(@NonNull Context context, @NonNull...
method withDarkTheme (line 376) | private static Toast withDarkTheme(@NonNull Context context, @NonNull ...
class Config (line 382) | public static class Config {
method Config (line 394) | private Config() {
method getInstance (line 398) | @CheckResult
method reset (line 403) | public static void reset() {
method setToastTypeface (line 415) | @CheckResult
method setTextSize (line 421) | @CheckResult
method tintIcon (line 427) | @CheckResult
method allowQueue (line 433) | @CheckResult
method setGravity (line 439) | @CheckResult
method setGravity (line 447) | @CheckResult
method supportDarkTheme (line 453) | @CheckResult
method setRTL (line 459) | public Config setRTL(boolean isRTL) {
method apply (line 464) | public void apply() {
FILE: toasty/src/main/java/es/dmoral/toasty/ToastyUtils.java
class ToastyUtils (line 33) | final class ToastyUtils {
method ToastyUtils (line 34) | private ToastyUtils() {
method tintIcon (line 37) | static Drawable tintIcon(@NonNull Drawable drawable, @ColorInt int tin...
method tint9PatchDrawableFrame (line 42) | static Drawable tint9PatchDrawableFrame(@NonNull Context context, @Col...
method setBackground (line 47) | static void setBackground(@NonNull View view, Drawable drawable) {
method getDrawable (line 54) | static Drawable getDrawable(@NonNull Context context, @DrawableRes int...
method getColor (line 58) | static int getColor(@NonNull Context context, @ColorRes int color){
FILE: toasty/src/test/java/es/dmoral/toasty/ExampleUnitTest.java
class ExampleUnitTest (line 12) | public class ExampleUnitTest {
method addition_isCorrect (line 13) | @Test
Condensed preview — 39 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (76K chars).
[
{
"path": ".gitignore",
"chars": 471,
"preview": "# Built application files\n*.apk\n*.ap_\n\n# Files for the ART/Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated file"
},
{
"path": "LICENSE",
"chars": 7651,
"preview": " GNU LESSER GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007"
},
{
"path": "README.md",
"chars": 9333,
"preview": "[](https://ko-fi.com/R6R21LO82)\n\n# Toasty\n[
About this extraction
This page contains the full source code of the GrenderG/Toasty GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 39 files (69.2 KB), approximately 18.7k tokens, and a symbol index with 77 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.