├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── issue_template.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── build.yml ├── .gitignore ├── .travis.yml ├── CNAME ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── build.gradle ├── dynamic-toasts ├── build.gradle ├── maven.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── pranavpandey │ │ └── android │ │ └── dynamic │ │ └── toasts │ │ ├── DynamicHint.java │ │ ├── DynamicToast.java │ │ └── internal │ │ ├── ToastCompat.java │ │ └── ToastContext.java │ └── res │ ├── drawable-hdpi │ ├── adt_ic_error.png │ ├── adt_ic_success.png │ └── adt_ic_warning.png │ ├── drawable-mdpi │ ├── adt_ic_error.png │ ├── adt_ic_success.png │ └── adt_ic_warning.png │ ├── drawable-xhdpi │ ├── adt_ic_error.png │ ├── adt_ic_success.png │ └── adt_ic_warning.png │ ├── drawable-xxhdpi │ ├── adt_ic_error.png │ ├── adt_ic_success.png │ └── adt_ic_warning.png │ ├── drawable-xxxhdpi │ ├── adt_ic_error.png │ ├── adt_ic_success.png │ └── adt_ic_warning.png │ ├── drawable │ ├── adt_hint_background.xml │ └── adt_toast_background.xml │ ├── layout │ ├── adt_layout_hint.xml │ └── adt_layout_toast.xml │ └── values │ └── dimens.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── graphics ├── icon.png ├── icon.psd ├── legacy │ ├── icon-alt.png │ ├── icon.png │ └── icon.psd ├── play │ ├── feature-graphic.png │ ├── promo-graphic.png │ └── screenshots │ │ ├── phone-1.png │ │ ├── phone-2.png │ │ ├── phone-3.png │ │ ├── phone-4.png │ │ ├── phone-5.png │ │ ├── phone-6.png │ │ ├── phone-7.png │ │ └── phone-8.png ├── preview.png └── preview.psd ├── sample ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── pranavpandey │ │ └── android │ │ └── dynamic │ │ └── toasts │ │ └── sample │ │ ├── DynamicToastsActivity.kt │ │ └── dialog │ │ └── AboutDialogFragment.kt │ └── res │ ├── drawable │ ├── app_bar_shadow.xml │ ├── bg_custom_toast.xml │ ├── ic_info.xml │ ├── ic_launcher_foreground.xml │ ├── ic_social_github.xml │ └── ic_toast_icon.xml │ ├── layout │ ├── activity_dynamic_toasts.xml │ ├── content_dynamic_toasts.xml │ └── dialog_about.xml │ ├── menu │ └── main.xml │ ├── mipmap-anydpi-v26 │ └── ic_launcher.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: pranavpandey 4 | patreon: pranavpandey 5 | open_collective: pranavpandeydev 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['paypal.me/pranavpandeydev'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue 3 | about: Create a issue to help us improve 4 | title: "Short description of the issue" 5 | --- 6 | 7 | **Description:** Full description of the issue. 8 | 9 | **Expected behavior:** Screenshots and/or description of the expected behavior. 10 | 11 | **Source code:** [OPTIONAL] The code snippet which is causing this issue. 12 | 13 | **Sample app and/or repro:** [OPTIONAL] A sample app or steps to reproduce the issue. You may attach a `zip` or `APK` file of the sample app or a link to the GitHub repository. 14 | 15 | **Android API version:** Android API version. `API 19` 16 | 17 | **Library version:** The Library version you are using. `1.0.0` 18 | 19 | **Device:** Device on which the bug was encountered. `Emulator or Brand Model` 20 | 21 | *Please make sure that you are using the [latest version](https://github.com/pranavpandey/dynamic-toasts/releases) of the library and we also accept [pull requests](https://github.com/pranavpandey/dynamic-toasts/pulls).* 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Thanks for starting a pull request! 2 | 3 | ## Changes 4 | 5 | - 6 | - 7 | 8 | ## Testing 9 | 10 | Describe how you tested your changes. 11 | 12 | ## Issues 13 | 14 | [OPTIONAL] Link to GitHub issues it solves. `Resolve #1234` 15 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | timeout-minutes: 60 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v3 16 | 17 | - name: Setup JDK 17 18 | uses: actions/setup-java@v3 19 | with: 20 | distribution: 'zulu' 21 | java-version: 17 22 | 23 | - name: Setup Gradle 24 | uses: gradle/gradle-build-action@v2 25 | 26 | - name: Build with Gradle 27 | run: | 28 | chmod +x gradlew 29 | ./gradlew build 30 | 31 | - name: Generate Javadoc 32 | if: github.ref_type == 'tag' 33 | run: ./gradlew generateJavadoc 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | release/ 19 | 20 | # IntelliJ project files 21 | **.iml 22 | .idea 23 | 24 | # Android Studio captures folder 25 | captures/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Misc 37 | .DS_Store -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk17 3 | 4 | before_install: 5 | - mkdir "$ANDROID_HOME/licenses" || true 6 | - echo -e "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license" 7 | - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" 8 | 9 | android: 10 | components: 11 | - tools 12 | - platform-tools 13 | - build-tools-35.0.0 14 | - android-35 15 | - extra-android-support 16 | - extra-android-m2repository 17 | - extra-google-m2repository 18 | before_script: 19 | - chmod +x gradlew 20 | script: 21 | - ./gradlew build 22 | 23 | after_success: 24 | - ./gradlew generateJavadoc 25 | 26 | deploy: 27 | provider: pages 28 | token: $GITHUB_TOKEN 29 | edge: true 30 | keep_history: true 31 | local_dir: dynamic-toasts/build/docs/javadoc/release 32 | on: 33 | branch: master 34 | tags: true 35 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | pranavpandey.org -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | support@pranavpandey.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series of 86 | actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or permanent 93 | ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within the 113 | community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.1, available at 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 120 | 121 | Community Impact Guidelines were inspired by 122 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 123 | 124 | For answers to common questions about this code of conduct, see the FAQ at 125 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 126 | [https://www.contributor-covenant.org/translations][translations]. 127 | 128 | [homepage]: https://www.contributor-covenant.org 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 130 | [Mozilla CoC]: https://github.com/mozilla/diversity 131 | [FAQ]: https://www.contributor-covenant.org/faq 132 | [translations]: https://www.contributor-covenant.org/translations 133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2017-2024 Pranav Pandey 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Dynamic Toasts 4 | 5 | [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?)](https://www.apache.org/licenses/LICENSE-2.0.html) 6 | [![Build Status](https://travis-ci.org/pranavpandey/dynamic-toasts.svg?branch=master)](https://travis-ci.org/pranavpandey/dynamic-toasts) 7 | [![Release](https://img.shields.io/maven-central/v/com.pranavpandey.android/dynamic-toasts)](https://search.maven.org/artifact/com.pranavpandey.android/dynamic-toasts) 8 | 9 | **A simple library to display themed toasts with icon and text on Android 2.3 (API 9) and above.** 10 | 11 | > [!IMPORTANT] 12 | > Since v0.4.0, it uses [26.x.x support libraries][android-support] so, minimum SDK will be 13 | Android 4.0 (API 14). 14 |
Since v2.0.0, it uses [AndroidX][androidx] so, first [migrate][androidx-migrate] your 15 | project to AndroidX. 16 |
Since v4.1.0, it is dependent on Java 8 due to the dependency on 17 | [Dynamic Utils][dynamic-utils]. 18 |
Since v4.2.0, it is targeting Java 17 to provide maximum compatibility. 19 |
Since v4.3.0, the minimum SDK is Android 4.4 (API 19) to comply with the latest policies. 20 | 21 | 22 | 23 | --- 24 | 25 | ## Contents 26 | 27 | - [Installation](#installation) 28 | - [Usage](#usage) 29 | - [Configuration](#configuration) 30 | - [Default toast](#default-toast) 31 | - [Default toast with duration](#default-toast-with-duration) 32 | - [Default toast with icon](#default-toast-with-icon) 33 | - [Default toast with icon and duration](#default-toast-with-icon-and-duration) 34 | - [Error toast](#error-toast) 35 | - [Error toast with duration](#error-toast-with-duration) 36 | - [Success toast](#success-toast) 37 | - [Success toast with duration](#success-toast-with-duration) 38 | - [Warning toast](#warning-toast) 39 | - [Warning toast with duration](#warning-toast-with-duration) 40 | - [Custom toast](#custom-toast) 41 | - [Custom toast with duration](#custom-toast-with-duration) 42 | - [Custom toast with icon](#custom-toast-with-icon) 43 | - [Custom toast with icon and duration](#custom-toast-with-icon-and-duration) 44 | - [Cheat sheets](#cheat-sheets) 45 | - [Dependency](#dependency) 46 | - [License](#license) 47 | 48 | --- 49 | 50 | ## Installation 51 | 52 | It can be installed by adding the following dependency to your `build.gradle` file: 53 | 54 | ```groovy 55 | dependencies { 56 | // For AndroidX enabled projects. 57 | implementation 'com.pranavpandey.android:dynamic-toasts:4.3.0' 58 | 59 | // For legacy projects. 60 | implementation 'com.pranavpandey.android:dynamic-toasts:1.3.0' 61 | } 62 | ``` 63 | 64 | --- 65 | 66 | ## Usage 67 | 68 | It has several method to display toasts based on the requirement. Each method returns a `Toast` 69 | object which can be customised further. 70 | 71 | Please call `show()` method to display the toast. 72 | 73 | > For a complete reference, please read the [documentation][documentation]. 74 | 75 | ### Configuration 76 | 77 | Optional configuration to customise the toasts further like custom background color or drawable, 78 | custom text size, typeface or icon size, etc. 79 | 80 | Various methods can be called anywhere in the app to do customisations. 81 | 82 | ```java 83 | DynamicToast.Config.getInstance() 84 | // Background color for default toast. 85 | .setDefaultBackgroundColor(@ColorInt int defaultBackgroundColor) 86 | // Tint color for default toast. 87 | .setDefaultTintColor(@ColorInt int defaultTintColor) 88 | // Background color for error toast. 89 | .setErrorBackgroundColor(@ColorInt int errorBackgroundColor) 90 | // Background color for success toast. 91 | .setSuccessBackgroundColor(@ColorInt int successBackgroundColor) 92 | // Background color for warning toast. 93 | .setWarningBackgroundColor(@ColorInt int warningBackgroundColor) 94 | // Custom icon for error toast. Pass `null` to use default icon. 95 | .setErrorIcon(@Nullable Drawable errorIcon) 96 | // Custom icon for success toast. Pass `null` to use default icon. 97 | .setSuccessIcon(@Nullable Drawable successIcon) 98 | // Custom icon for warning toast. Pass `null` to use default icon. 99 | .setWarningIcon(@Nullable Drawable warningIcon) 100 | // Disable icon for all the toasts. 101 | .setDisableIcon(boolean disableIcon) 102 | // Custom icon size in `pixels` for all the toasts. 103 | .setIconSize(int iconSize) 104 | // Custom text size in `SP` for all the toasts. 105 | .setTextSize(int textSize) 106 | // Custom text typeface for all the toasts. Pass `null` to use system typeface. 107 | .setTextTypeface(@Nullable Typeface textTypeface) 108 | // Custom background drawable for all the toasts. Pass `null` to use default background. 109 | .setToastBackground(@Nullable Drawable toastBackground) 110 | // Apply customisations. 111 | .apply(); 112 | ``` 113 | 114 | Call `reset()` method to reset all the customisations. 115 | 116 | ```java 117 | // Reset customisations. 118 | DynamicToast.Config.getInstance().reset(); 119 | ``` 120 | 121 | ### Default toast 122 | 123 | Simple toast based on the vanilla Android theme for `Toast.LENGTH_SHORT` duration. 124 | 125 | ```java 126 | DynamicToast.make(context, "Default toast").show(); 127 | ``` 128 | 129 | ### Default toast with duration 130 | 131 | Simple toast based on the vanilla Android theme for supplied duration. 132 | 133 | ```java 134 | DynamicToast.make(context, "Default toast with duration", duration).show(); 135 | ``` 136 | 137 | ### Default toast with icon 138 | 139 | Simple toast based on the vanilla Android theme with a icon for `Toast.LENGTH_SHORT` duration. 140 | 141 | ```java 142 | DynamicToast.make(context, "Default toast with icon", drawable).show(); 143 | ``` 144 | 145 | ### Default toast with icon and duration 146 | 147 | Simple toast based on the vanilla Android theme with a icon for supplied duration. 148 | 149 | ```java 150 | DynamicToast.make(context, "Default toast with icon and duration", drawable, duration).show(); 151 | ``` 152 | 153 | ### Error toast 154 | 155 | Error toast with `#F44336` background for `Toast.LENGTH_SHORT` duration. 156 | 157 | ```java 158 | DynamicToast.makeError(context, "Error toast").show(); 159 | ``` 160 | 161 | ### Error toast with duration 162 | 163 | Error toast with `#F44336` background for supplied duration. 164 | 165 | ```java 166 | DynamicToast.makeError(context, "Error toast with duration", duration).show(); 167 | ``` 168 | 169 | ### Success toast 170 | 171 | Success toast with `#4CAF50` background for `Toast.LENGTH_SHORT` duration. 172 | 173 | ```java 174 | DynamicToast.makeSuccess(context, "Success toast").show(); 175 | ``` 176 | 177 | ### Success toast with duration 178 | 179 | Success toast with `#4CAF50` background for supplied duration. 180 | 181 | ```java 182 | DynamicToast.makeSuccess(context, "Success toast with duration", duration).show(); 183 | ``` 184 | 185 | ### Warning toast 186 | 187 | Warning toast with `#FFEB3B` background for `Toast.LENGTH_SHORT` duration. 188 | 189 | ```java 190 | DynamicToast.makeWarning(context, "Warning toast").show(); 191 | ``` 192 | 193 | ### Warning toast with duration 194 | 195 | Warning toast with `#FFEB3B` background for supplied duration. 196 | 197 | ```java 198 | DynamicToast.makeWarning(context, "Warning toast with duration", duration).show(); 199 | ``` 200 | 201 | ### Custom toast 202 | 203 | Custom toast based on the supplied background and tint color for `Toast.LENGTH_SHORT` duration. 204 | 205 | ```java 206 | DynamicToast.make(context, "Custom toast", tintColor, backgroundColor).show(); 207 | ``` 208 | 209 | ### Custom toast with duration 210 | 211 | Custom toast based on the supplied background and tint color for supplied duration. 212 | 213 | ```java 214 | DynamicToast.make(context, "Custom toast with duration", tintColor, backgroundColor, duration).show(); 215 | ``` 216 | 217 | ### Custom toast with icon 218 | 219 | Custom toast based on the supplied icon, background and tint color theme for `Toast.LENGTH_SHORT` 220 | duration. 221 | 222 | ```java 223 | DynamicToast.make(context, "Custom toast with icon", drawable, tintColor, backgroundColor).show(); 224 | ``` 225 | 226 | ### Custom toast with icon and duration 227 | 228 | Custom toast based on the supplied icon, background and tint color theme for supplied duration. 229 | 230 | ```java 231 | DynamicToast.make(context, "Custom toast with icon and duration", drawable, 232 | tintColor, backgroundColor, duration).show(); 233 | ``` 234 | 235 | ### Cheat sheets 236 | 237 | Use dynamic hint to display cheat sheets for any `view`. All the methods are same as explained 238 | above, just replace `DynamicToast` with `DynamicHint` to create a cheat sheet. 239 | 240 | > Use `DynamicHint.show(view, toast)` method to display it according to the anchor view position. 241 | 242 | ### Dependency 243 | 244 | It depends on the [dynamic-utils][dynamic-utils] to perform various internal operations. 245 | So, its functions can also be used to perform other useful operations. 246 | 247 | --- 248 | 249 | ## Author 250 | 251 | Pranav Pandey 252 | 253 | [![GitHub](https://img.shields.io/github/followers/pranavpandey?label=GitHub&style=social)](https://github.com/pranavpandey) 254 | [![Follow on Twitter](https://img.shields.io/twitter/follow/pranavpandeydev?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=pranavpandeydev) 255 | [![Donate via PayPal](https://img.shields.io/static/v1?label=Donate&message=PayPal&color=blue)](https://paypal.me/pranavpandeydev) 256 | 257 | --- 258 | 259 | ## License 260 | 261 | Copyright 2017-2024 Pranav Pandey 262 | 263 | Licensed under the Apache License, Version 2.0 (the "License"); 264 | you may not use this file except in compliance with the License. 265 | You may obtain a copy of the License at 266 | 267 | http://www.apache.org/licenses/LICENSE-2.0 268 | 269 | Unless required by applicable law or agreed to in writing, software 270 | distributed under the License is distributed on an "AS IS" BASIS, 271 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 272 | See the License for the specific language governing permissions and 273 | limitations under the License. 274 | 275 | 276 | [android-support]: https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0 277 | [androidx]: https://developer.android.com/jetpack/androidx 278 | [androidx core]: https://developer.android.com/jetpack/androidx/releases/core 279 | [androidx-migrate]: https://developer.android.com/jetpack/androidx/migrate 280 | [documentation]: https://pranavpandey.github.io/dynamic-toasts 281 | [dynamic-utils]: https://github.com/pranavpandey/dynamic-utils 282 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2025 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | buildscript { 18 | ext.versions = [ 19 | 'compileSdk' : 35, 20 | 'minSdk' : 21, 21 | 'targetSdk' : 35, 22 | 'buildTools' : '35.0.0', 23 | 'constraintlayout': '2.1.4', 24 | 'dynamic' : '4.6.1', 25 | 'dialogs' : '4.5.0', 26 | 'flexbox' : '3.0.0', 27 | 'kotlin' : '1.9.24' 28 | ] 29 | 30 | repositories { 31 | mavenCentral() 32 | google() 33 | } 34 | 35 | dependencies { 36 | classpath 'com.android.tools.build:gradle:8.7.3' 37 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" 38 | } 39 | } 40 | 41 | plugins { 42 | id("io.github.gradle-nexus.publish-plugin") version "2.0.0" 43 | } 44 | 45 | allprojects { 46 | repositories { 47 | mavenCentral() 48 | google() 49 | } 50 | } 51 | 52 | tasks.register('clean', Delete) { 53 | delete rootProject.layout.buildDirectory 54 | } 55 | 56 | ext { 57 | projectName = 'dynamic-toasts' 58 | projectDesc = 'A simple library to display themed toasts with icon and text on Android.' 59 | versionDesc = 'A simple library to display themed toasts with icon and text on Android 4.0 ' + 60 | '(API 14) and above.' 61 | referenceTitle = 'Dynamic Toasts API reference' 62 | 63 | siteUrl = 'https://github.com/pranavpandey/dynamic-toasts' 64 | gitUrl = 'https://github.com/pranavpandey/dynamic-toasts' 65 | issueUrl = 'https://github.com/pranavpandey/dynamic-toasts/issues' 66 | githubUrl = 'pranavpandey/dynamic-toasts' 67 | 68 | mavenRepo = 'android' 69 | mavenGroup = 'com.pranavpandey.android' 70 | mavenDir = 'com/pranavpandey/android' 71 | mavenArtifactId = 'dynamic-toasts' 72 | mavenInceptionYear = '2017' 73 | mavenVersion = '4.3.0' 74 | mavenVersionCode = 34 75 | sampleVersionCode = 35 76 | 77 | developerId = 'pranavpandey' 78 | developerName = 'Pranav Pandey' 79 | developerEmail = 'dynamic@pranavpandey.com' 80 | 81 | licenseName = 'The Apache Software License, Version 2.0' 82 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 83 | licenseDistribution = 'repo' 84 | allLicenses = ["Apache-2.0"] 85 | 86 | publication = 'local.properties' 87 | 88 | ext["signing.keyId"] = '' 89 | ext["signing.password"] = '' 90 | ext["signing.secretKeyRingFile"] = '' 91 | 92 | ossrhUsername = '' 93 | ossrhPassword = '' 94 | sonatypeStagingProfileId = '' 95 | } 96 | 97 | apply plugin: 'io.github.gradle-nexus.publish-plugin' 98 | 99 | File publish = project.rootProject.file("${publication}") 100 | if (publish.exists()) { 101 | Properties properties = new Properties() 102 | new FileInputStream(publish).withCloseable { is -> properties.load(is) } 103 | properties.each { name, value -> ext[name] = value } 104 | } 105 | 106 | nexusPublishing { 107 | repositories { 108 | sonatype { 109 | username = ossrhUsername 110 | password = ossrhPassword 111 | stagingProfileId = sonatypeStagingProfileId 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /dynamic-toasts/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2024 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.library' 18 | 19 | android { 20 | compileSdkVersion versions.compileSdk 21 | buildToolsVersion versions.buildTools 22 | namespace 'com.pranavpandey.android.dynamic.toasts' 23 | 24 | defaultConfig { 25 | minSdkVersion versions.minSdk 26 | targetSdkVersion versions.targetSdk 27 | } 28 | 29 | sourceSets { 30 | main.res.srcDirs 'res' 31 | } 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_17 35 | targetCompatibility JavaVersion.VERSION_17 36 | } 37 | } 38 | 39 | dependencies { 40 | implementation(platform("org.jetbrains.kotlin:kotlin-bom:${versions.kotlin}")) 41 | 42 | api "com.pranavpandey.android:dynamic-utils:${versions.dynamic}" 43 | } 44 | 45 | if (project.rootProject.file("${publication}").exists()) { 46 | apply from: 'maven.gradle' 47 | } 48 | 49 | tasks.register('generateJavadoc') { 50 | description "Generates Javadoc." 51 | } 52 | 53 | project.afterEvaluate { 54 | android.libraryVariants.configureEach { variant -> 55 | def task = project.tasks.create( 56 | "generate${variant.name.capitalize()}Javadoc", Javadoc) { 57 | title "${referenceTitle}

${versionDesc}

${mavenVersion}
" 58 | description "Generates Javadoc for $variant.name." 59 | destinationDir = new File(destinationDir, variant.baseName) 60 | 61 | source = variant.sourceSets.collect { 62 | it.java.sourceFiles 63 | }.inject { 64 | m, i -> m + i 65 | } 66 | doFirst { 67 | classpath = project.files(variant.javaCompileProvider.get().classpath.files, 68 | project.android.getBootClasspath()) 69 | } 70 | 71 | if (JavaVersion.current().isJava8Compatible()) { 72 | options.addStringOption('Xdoclint:none', '-quiet') 73 | } 74 | 75 | options.memberLevel = JavadocMemberLevel.PROTECTED 76 | exclude "**/R", "**/R.**", "**/R\$**", "**/BuildConfig*" 77 | 78 | options.windowTitle = "${referenceTitle}" 79 | options.links('http://docs.oracle.com/javase/8/docs/api', 80 | 'http://docs.oracle.com/javase/17/docs/api') 81 | options.links('https://developer.android.com/reference') 82 | options.linksOffline('https://developer.android.com/reference', 83 | 'https://developer.android.com/reference/androidx') 84 | options.links('https://pranavpandey.org/dynamic-utils') 85 | 86 | failOnError false 87 | } 88 | 89 | task.dependsOn "assemble${variant.name.capitalize()}" 90 | generateJavadoc.dependsOn task 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /dynamic-toasts/maven.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2024 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'maven-publish' 18 | apply plugin: 'signing' 19 | 20 | group = mavenGroup 21 | version = mavenVersion 22 | 23 | // Android libraries 24 | if (project.hasProperty("android")) { 25 | tasks.register('sourcesJar', Jar) { 26 | archiveClassifier.set("sources") 27 | from android.sourceSets.main.java.srcDirs 28 | } 29 | 30 | tasks.register('javadoc', Javadoc) { 31 | dependsOn "generateReleaseRFile" 32 | title "${referenceTitle}

${versionDesc}

${mavenVersion}
" 33 | failOnError = false 34 | 35 | source = android.sourceSets.main.java.sourceFiles 36 | doNotTrackState("Javadoc needs to be generated every time.") 37 | 38 | if (JavaVersion.current().isJava8Compatible()) { 39 | options.addStringOption('Xdoclint:none', '-quiet') 40 | } 41 | 42 | options.memberLevel = JavadocMemberLevel.PROTECTED 43 | exclude "**/R", "**/R.**", "**/R\$**", "**/BuildConfig*" 44 | 45 | options.windowTitle = "${referenceTitle}" 46 | options.links('http://docs.oracle.com/javase/8/docs/api', 47 | 'http://docs.oracle.com/javase/17/docs/api') 48 | options.links('https://developer.android.com/reference') 49 | options.linksOffline('https://developer.android.com/reference', 50 | 'https://developer.android.com/reference/androidx') 51 | options.links('https://pranavpandey.org/dynamic-utils') 52 | } 53 | } else { // Java libraries 54 | tasks.register('sourcesJar', Jar) { 55 | dependsOn classes 56 | 57 | archiveClassifier.set("sources") 58 | from sourceSets.main.allSource 59 | } 60 | } 61 | 62 | tasks.register('javadocJar', Jar) { 63 | dependsOn javadoc 64 | 65 | archiveClassifier.set("javadoc") 66 | from javadoc.destinationDir 67 | } 68 | 69 | artifacts { 70 | archives javadocJar 71 | archives sourcesJar 72 | } 73 | 74 | // Maven 75 | publishing { 76 | publications { 77 | library(MavenPublication) { 78 | groupId mavenGroup 79 | artifactId mavenArtifactId 80 | version mavenVersion 81 | 82 | artifact "$buildDir/outputs/aar/$mavenArtifactId-release.aar" 83 | artifact javadocJar 84 | artifact sourcesJar 85 | 86 | pom.withXml { 87 | // Project 88 | asNode().appendNode('name', projectName) 89 | asNode().appendNode('description', projectDesc) 90 | asNode().appendNode('url', siteUrl) 91 | asNode().appendNode('inceptionYear', mavenInceptionYear) 92 | 93 | // Licenses 94 | def license = asNode().appendNode('licenses').appendNode('license') 95 | license.appendNode('name', licenseName) 96 | license.appendNode('url', licenseUrl) 97 | license.appendNode('distribution', licenseDistribution) 98 | 99 | // Developers 100 | def developer = asNode().appendNode('developers').appendNode('developer') 101 | developer.appendNode('id', developerId) 102 | developer.appendNode('name', developerName) 103 | developer.appendNode('email', developerEmail) 104 | 105 | // SCM 106 | def scm = asNode().appendNode('scm') 107 | scm.appendNode('connection', "scm:git:${gitUrl}.git") 108 | scm.appendNode('developerConnection', gitUrl) 109 | scm.appendNode('url', siteUrl) 110 | 111 | // Dependencies 112 | def dependenciesNode = asNode()['dependencies'][0] 113 | if (dependenciesNode == null) { 114 | dependenciesNode = asNode().appendNode('dependencies') 115 | } 116 | 117 | // Add all that are 'compile' dependencies. 118 | configurations.api.allDependencies.each { 119 | def dependencyNode = dependenciesNode.appendNode('dependency') 120 | dependencyNode.appendNode('groupId', it.group) 121 | dependencyNode.appendNode('artifactId', it.name) 122 | dependencyNode.appendNode('version', it.version) 123 | } 124 | } 125 | } 126 | } 127 | } 128 | 129 | ext["signing.keyId"] = rootProject.ext["signing.keyId"] 130 | ext["signing.password"] = rootProject.ext["signing.password"] 131 | ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] 132 | 133 | signing { 134 | sign publishing.publications 135 | } 136 | 137 | afterEvaluate { project -> 138 | // Fix javadoc generation. 139 | javadoc.classpath += files(android.libraryVariants.collect { variant -> 140 | variant.javaCompileProvider.get().classpath.files 141 | }) 142 | 143 | def pomTask = "generatePomFileForLibraryPublication" 144 | def dependencies = [javadocJar, sourcesJar, assembleRelease, pomTask] 145 | 146 | // Convenience task to prepare everything we need for releases. 147 | tasks.register('prepareArtifacts') { 148 | dependsOn dependencies 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/java/com/pranavpandey/android/dynamic/toasts/DynamicToast.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2022 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.pranavpandey.android.dynamic.toasts; 18 | 19 | import android.app.Activity; 20 | import android.content.Context; 21 | import android.graphics.Color; 22 | import android.graphics.PorterDuff; 23 | import android.graphics.Typeface; 24 | import android.graphics.drawable.Drawable; 25 | import android.util.TypedValue; 26 | import android.view.LayoutInflater; 27 | import android.view.View; 28 | import android.widget.ImageView; 29 | import android.widget.LinearLayout; 30 | import android.widget.TextView; 31 | import android.widget.Toast; 32 | 33 | import androidx.annotation.ColorInt; 34 | import androidx.annotation.NonNull; 35 | import androidx.annotation.Nullable; 36 | import androidx.core.content.ContextCompat; 37 | 38 | import com.pranavpandey.android.dynamic.toasts.internal.ToastCompat; 39 | import com.pranavpandey.android.dynamic.util.DynamicColorUtils; 40 | import com.pranavpandey.android.dynamic.util.DynamicDrawableUtils; 41 | 42 | /** 43 | * Helper class to display themed {@link Toast} with icon and text. 44 | *

If no color is supplied, it will display default toast based on the vanilla Android. 45 | */ 46 | public class DynamicToast { 47 | 48 | /** 49 | * Default background color for the toast. 50 | */ 51 | private static final @ColorInt int ADT_DEFAULT_BG_COLOR = 52 | Color.parseColor("#454545"); 53 | 54 | /** 55 | * Default tint color for the toast. 56 | */ 57 | private static final @ColorInt int ADT_DEFAULT_TINT_COLOR = 58 | Color.parseColor("#FFFFFF"); 59 | 60 | /** 61 | * Default background color for the error toast. 62 | */ 63 | private static final @ColorInt int ADT_DEFAULT_ERROR_BG_COLOR = 64 | Color.parseColor("#F44336"); 65 | 66 | /** 67 | * Default background color for the success toast. 68 | */ 69 | private static final @ColorInt int ADT_DEFAULT_SUCCESS_BG_COLOR = 70 | Color.parseColor("#4CAF50"); 71 | 72 | /** 73 | * Default background color for the warning toast. 74 | */ 75 | private static final @ColorInt int ADT_DEFAULT_WARNING_BG_COLOR = 76 | Color.parseColor("#FFEB3B"); 77 | 78 | /** 79 | * Default value for the {@link #disableIcon}. 80 | *

{@code false} to enable the toast icon. 81 | */ 82 | private static final boolean ADT_DEFAULT_DISABLE_ICON = false; 83 | 84 | /** 85 | * Default value for the {@link #tintIcon}. 86 | *

{@code true} to tint the toast icon. 87 | */ 88 | private static final boolean ADT_DEFAULT_TINT_ICON = true; 89 | 90 | /** 91 | * Default icon size for the toast in pixels. 92 | *

{@code -1} to use in-built icon size. 93 | */ 94 | private static final @ColorInt int ADT_DEFAULT_ICON_SIZE = -1; 95 | 96 | /** 97 | * Default text size for the toast in SP. 98 | *

{@code -1} to use system text size. 99 | * 100 | * @see TypedValue#COMPLEX_UNIT_SP; 101 | */ 102 | private static final @ColorInt int ADT_DEFAULT_TEXT_SIZE = -1; 103 | 104 | /** 105 | * Background color for the default toast. 106 | */ 107 | private static @Nullable @ColorInt Integer defaultBackgroundColor = ADT_DEFAULT_BG_COLOR; 108 | 109 | /** 110 | * Tint color for the default toast. 111 | */ 112 | private static @Nullable @ColorInt Integer defaultTintColor = ADT_DEFAULT_TINT_COLOR; 113 | 114 | /** 115 | * Background color for the error toast. 116 | */ 117 | private static @Nullable @ColorInt Integer errorBackgroundColor = ADT_DEFAULT_ERROR_BG_COLOR; 118 | 119 | /** 120 | * Background color for the success toast. 121 | */ 122 | private static @Nullable @ColorInt Integer successBackgroundColor = 123 | ADT_DEFAULT_SUCCESS_BG_COLOR; 124 | 125 | /** 126 | * Background color for the warning toast. 127 | */ 128 | private static @Nullable @ColorInt Integer warningBackgroundColor = 129 | ADT_DEFAULT_WARNING_BG_COLOR; 130 | 131 | /** 132 | * Custom icon for the error toast. 133 | *

{@code null} to use the default icon. 134 | */ 135 | private static Drawable errorIcon = null; 136 | 137 | /** 138 | * Custom icon for the success toast. 139 | *

{@code null} to use the default icon. 140 | */ 141 | private static Drawable successIcon = null; 142 | 143 | /** 144 | * Custom icon for the warning toast. 145 | *

{@code null} to use the default icon. 146 | */ 147 | private static Drawable warningIcon = null; 148 | 149 | /** 150 | * {@code true} to disable icon for all the toasts. 151 | */ 152 | private static boolean disableIcon = ADT_DEFAULT_DISABLE_ICON; 153 | 154 | /** 155 | * {@code true} to tint icon for all the toasts. 156 | */ 157 | private static boolean tintIcon = ADT_DEFAULT_TINT_ICON; 158 | 159 | /** 160 | * Icon size for the toast in pixels. 161 | */ 162 | private static int iconSize = ADT_DEFAULT_ICON_SIZE; 163 | 164 | /** 165 | * Text size for the toast in SP. 166 | * 167 | * @see TypedValue#COMPLEX_UNIT_SP; 168 | */ 169 | private static int textSize = ADT_DEFAULT_TEXT_SIZE; 170 | 171 | /** 172 | * Custom typeface used by the toast. 173 | *

{@code null} to use the system typeface. 174 | */ 175 | private static Typeface textTypeface = null; 176 | 177 | /** 178 | * Custom background used by the toast. 179 | *

{@code null} to use the default background. 180 | */ 181 | private static Drawable toastBackground = null; 182 | 183 | /** 184 | * Generate tint color according to the supplied color, otherwise return the default value. 185 | * 186 | * @param color The color to be used to generate the tint color. 187 | * @param defaultColor The default value for the tint color. 188 | * 189 | * @return The generated tint color according to the supplied color, otherwise return the 190 | * default value. 191 | */ 192 | private static @Nullable @ColorInt Integer generateTintColor( 193 | @Nullable @ColorInt Integer color, @Nullable @ColorInt Integer defaultColor) { 194 | if (color != null) { 195 | return DynamicColorUtils.getTintColor(color); 196 | } 197 | 198 | return defaultColor; 199 | } 200 | 201 | /** 202 | * Make a standard toast that just contains a text view. 203 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 204 | * 205 | * @param context The context to use. 206 | * @param text The text to show. Can be formatted text. 207 | * 208 | * @return The toast with the supplied parameters. 209 | *

Use {@link Toast#show()} to display the toast. 210 | */ 211 | public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text) { 212 | return make(context, text, null, defaultTintColor, 213 | defaultBackgroundColor, Toast.LENGTH_SHORT); 214 | } 215 | 216 | /** 217 | * Make a standard toast that just contains a text view. 218 | * 219 | * @param context The context to use. 220 | * @param text The text to show. Can be formatted text. 221 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 222 | * or {@link Toast#LENGTH_LONG}. 223 | * 224 | * @return The toast with the supplied parameters. 225 | *

Use {@link Toast#show()} to display the toast. 226 | */ 227 | public static @NonNull Toast make(@NonNull Context context, 228 | @Nullable CharSequence text, int duration) { 229 | return make(context, text, null, defaultTintColor, 230 | defaultBackgroundColor, duration); 231 | } 232 | 233 | /** 234 | * Make a error toast with icon and the text. 235 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 236 | * 237 | * @param context The context to use. 238 | * @param text The text to show. Can be formatted text. 239 | * 240 | * @return The toast with the supplied parameters. 241 | *

Use {@link Toast#show()} to display the toast. 242 | */ 243 | public static @NonNull Toast makeError(@NonNull Context context, @Nullable CharSequence text) { 244 | return make(context, text, errorIcon != null ? errorIcon 245 | : ContextCompat.getDrawable(context, R.drawable.adt_ic_error), 246 | generateTintColor(errorBackgroundColor, defaultTintColor), errorBackgroundColor); 247 | } 248 | 249 | /** 250 | * Make a error toast with icon and the text. 251 | * 252 | * @param context The context to use. 253 | * @param text The text to show. Can be formatted text. 254 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 255 | * or {@link Toast#LENGTH_LONG}. 256 | * 257 | * @return The toast with the supplied parameters. 258 | *

Use {@link Toast#show()} to display the toast. 259 | */ 260 | public static @NonNull Toast makeError(@NonNull Context context, 261 | @Nullable CharSequence text, int duration) { 262 | return make(context, text, ContextCompat.getDrawable(context, R.drawable.adt_ic_error), 263 | generateTintColor(errorBackgroundColor, defaultTintColor), 264 | errorBackgroundColor, duration); 265 | } 266 | 267 | /** 268 | * Make a success toast with icon and the text. 269 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 270 | * 271 | * @param context The context to use. 272 | * @param text The text to show. Can be formatted text. 273 | * 274 | * @return The toast with the supplied parameters. 275 | *

Use {@link Toast#show()} to display the toast. 276 | */ 277 | public static @NonNull Toast makeSuccess(@NonNull Context context, 278 | @Nullable CharSequence text) { 279 | return make(context, text, successIcon != null ? successIcon 280 | : ContextCompat.getDrawable(context, R.drawable.adt_ic_success), 281 | generateTintColor(successBackgroundColor, defaultTintColor), successBackgroundColor); 282 | } 283 | 284 | /** 285 | * Make a success toast with icon and the text. 286 | * 287 | * @param context The context to use. 288 | * @param text The text to show. Can be formatted text. 289 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 290 | * or {@link Toast#LENGTH_LONG}. 291 | * 292 | * @return The toast with the supplied parameters. 293 | *

Use {@link Toast#show()} to display the toast. 294 | */ 295 | public static @NonNull Toast makeSuccess(@NonNull Context context, 296 | @Nullable CharSequence text, int duration) { 297 | return make(context, text, ContextCompat.getDrawable(context, R.drawable.adt_ic_success), 298 | generateTintColor(successBackgroundColor, defaultTintColor), 299 | successBackgroundColor, duration); 300 | } 301 | 302 | /** 303 | * Make a warning toast with icon and the text. 304 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 305 | * 306 | * @param context The context to use. 307 | * @param text The text to show. Can be formatted text. 308 | * 309 | * @return The toast with the supplied parameters. 310 | *

Use {@link Toast#show()} to display the toast. 311 | */ 312 | public static @NonNull Toast makeWarning(@NonNull Context context, 313 | @Nullable CharSequence text) { 314 | return make(context, text, warningIcon != null ? warningIcon 315 | : ContextCompat.getDrawable(context, R.drawable.adt_ic_warning), 316 | generateTintColor(warningBackgroundColor, defaultTintColor), warningBackgroundColor); 317 | } 318 | 319 | /** 320 | * Make a warning toast with icon and the text. 321 | * 322 | * @param context The context to use. 323 | * @param text The text to show. Can be formatted text. 324 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 325 | * or {@link Toast#LENGTH_LONG}. 326 | * 327 | * @return The toast with the supplied parameters. 328 | *

Use {@link Toast#show()} to display the toast. 329 | */ 330 | public static @NonNull Toast makeWarning(@NonNull Context context, 331 | @Nullable CharSequence text, int duration) { 332 | return make(context, text, ContextCompat.getDrawable(context, R.drawable.adt_ic_warning), 333 | generateTintColor(warningBackgroundColor, defaultTintColor), 334 | warningBackgroundColor, duration); 335 | } 336 | 337 | /** 338 | * Make a error toast with icon and the text. 339 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 340 | * 341 | * @param context The context to use. 342 | * @param text The text to show. Can be formatted text. 343 | * @param icon The toast icon to show. 344 | * 345 | * @return The toast with the supplied parameters. 346 | *

Use {@link Toast#show()} to display the toast. 347 | */ 348 | public static @NonNull Toast make(@NonNull Context context, 349 | @Nullable CharSequence text, @Nullable Drawable icon) { 350 | return make(context, text, icon, defaultTintColor, 351 | defaultBackgroundColor, Toast.LENGTH_SHORT); 352 | } 353 | 354 | /** 355 | * Make a themed toast with icon and the text. 356 | * 357 | * @param context The context to use. 358 | * @param text The text to show. Can be formatted text. 359 | * @param icon The toast icon to show. 360 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 361 | * or {@link Toast#LENGTH_LONG}. 362 | * 363 | * @return The toast with the supplied parameters. 364 | *

Use {@link Toast#show()} to display the toast. 365 | */ 366 | public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text, 367 | @Nullable Drawable icon, int duration) { 368 | return make(context, text, icon, defaultTintColor, defaultBackgroundColor, duration); 369 | } 370 | 371 | /** 372 | * Make a themed toast with icon and the text. 373 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 374 | * 375 | * @param context The context to use. 376 | * @param text The text to show. Can be formatted text. 377 | * @param tintColor The toast tint color based on the toast background. 378 | *

It will automatically check for the contrast to provide the 379 | * best visibility. 380 | * @param backgroundColor The toast background color. 381 | * 382 | * @return The toast with the supplied parameters. 383 | *

Use {@link Toast#show()} to display the toast. 384 | */ 385 | public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text, 386 | @Nullable @ColorInt Integer tintColor, @Nullable @ColorInt Integer backgroundColor) { 387 | return make(context, text, null, tintColor, backgroundColor, Toast.LENGTH_SHORT); 388 | } 389 | 390 | /** 391 | * Make a themed toast with text, background and the tint color. 392 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 393 | * 394 | * @param context The context to use. 395 | * @param text The text to show. Can be formatted text. 396 | * @param tintColor The toast tint color based on the toast background. 397 | *

It will automatically check for the contrast to provide the 398 | * best visibility. 399 | * @param backgroundColor The toast background color. 400 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 401 | * or {@link Toast#LENGTH_LONG}. 402 | * 403 | * @return The toast with the supplied parameters. 404 | *

Use {@link Toast#show()} to display the toast. 405 | */ 406 | public static @NonNull Toast make(@NonNull Context context, 407 | @Nullable CharSequence text, @Nullable @ColorInt Integer tintColor, 408 | @Nullable @ColorInt Integer backgroundColor, int duration) { 409 | return make(context, text, null, tintColor, backgroundColor, duration); 410 | } 411 | 412 | /** 413 | * Make a themed toast with text, icon, background and the tint color. 414 | *

The toast duration will be {@link Toast#LENGTH_SHORT}. 415 | * 416 | * @param context The context to use. 417 | * @param text The text to show. Can be formatted text. 418 | * @param icon The toast icon to show. 419 | * @param tintColor The toast tint color based on the toast background. 420 | *

It will automatically check for the contrast to provide the 421 | * best visibility. 422 | * @param backgroundColor The toast background color. 423 | * 424 | * @return The toast with the supplied parameters. 425 | *

Use {@link Toast#show()} to display the toast. 426 | */ 427 | public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text, 428 | @Nullable Drawable icon, @Nullable @ColorInt Integer tintColor, 429 | @Nullable @ColorInt Integer backgroundColor) { 430 | return make(context, text, icon, tintColor, backgroundColor, Toast.LENGTH_SHORT); 431 | } 432 | 433 | /** 434 | * Make a themed toast with text, icon, background and the tint color. 435 | * 436 | * @param context The context to use. 437 | * @param text The text to show. Can be formatted text. 438 | * @param icon The toast icon to show. 439 | * @param tintColor The toast tint color based on the toast background. 440 | *

It will automatically check for the contrast to provide the 441 | * best visibility. 442 | * @param backgroundColor The toast background color. 443 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 444 | * or {@link Toast#LENGTH_LONG}. 445 | * 446 | * @return The toast with the supplied parameters. 447 | *

Use {@link Toast#show()} to display the toast. 448 | */ 449 | public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text, 450 | @Nullable Drawable icon, @Nullable @ColorInt Integer tintColor, 451 | @Nullable @ColorInt Integer backgroundColor, int duration) { 452 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 453 | context = context.getApplicationContext(); 454 | } 455 | 456 | @Nullable @ColorInt Integer toastTintColor = tintColor; 457 | if (tintColor != null && backgroundColor != null) { 458 | toastTintColor = DynamicColorUtils.getContrastColor(toastTintColor, backgroundColor); 459 | } 460 | 461 | ToastCompat toast = new ToastCompat(context, new Toast(context)); 462 | View toastLayout = LayoutInflater.from(context).inflate( 463 | R.layout.adt_layout_toast, new LinearLayout(context), false); 464 | ImageView toastIcon = toastLayout.findViewById(R.id.adt_toast_icon); 465 | TextView toastText = toastLayout.findViewById(R.id.adt_toast_text); 466 | 467 | if (!disableIcon && icon != null) { 468 | if (iconSize != ADT_DEFAULT_ICON_SIZE) { 469 | toastIcon.getLayoutParams().width = iconSize; 470 | toastIcon.getLayoutParams().height = iconSize; 471 | toastIcon.requestLayout(); 472 | } 473 | 474 | if (tintIcon && toastTintColor != null) { 475 | toastIcon.setColorFilter(toastTintColor); 476 | } else { 477 | toastIcon.clearColorFilter(); 478 | } 479 | toastIcon.setImageDrawable(icon); 480 | } else { 481 | toastIcon.setVisibility(View.GONE); 482 | } 483 | 484 | if (textTypeface != null) { 485 | toastText.setTypeface(textTypeface); 486 | } 487 | if (textSize != ADT_DEFAULT_TEXT_SIZE) { 488 | toastText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); 489 | } 490 | 491 | if (toastTintColor != null) { 492 | toastText.setTextColor(toastTintColor); 493 | } 494 | toastText.setText(text); 495 | 496 | if (toastBackground != null) { 497 | DynamicDrawableUtils.setBackground(toastLayout, backgroundColor != null 498 | ? DynamicDrawableUtils.colorizeDrawable(toastBackground, 499 | backgroundColor, PorterDuff.Mode.MULTIPLY) : toastBackground); 500 | } else { 501 | DynamicDrawableUtils.setBackground(toastLayout, backgroundColor != null 502 | ? DynamicDrawableUtils.colorizeDrawable(ContextCompat.getDrawable(context, 503 | R.drawable.adt_toast_background), backgroundColor, PorterDuff.Mode.MULTIPLY) 504 | : ContextCompat.getDrawable(context, R.drawable.adt_toast_background)); 505 | } 506 | 507 | toast.setDuration(duration); 508 | toast.setView(toastLayout); 509 | 510 | return toast; 511 | } 512 | 513 | /** 514 | * Configuration class to customise the {@link DynamicToast} attributes. 515 | */ 516 | public static class Config { 517 | 518 | /** 519 | * Singleton instance of {@link Config}. 520 | */ 521 | private static Config sInstance; 522 | 523 | /** 524 | * Background color for the default toast. 525 | */ 526 | private @ColorInt Integer defaultBackgroundColor = DynamicToast.defaultBackgroundColor; 527 | 528 | /** 529 | * Tint color for the default toast. 530 | */ 531 | private @ColorInt Integer defaultTintColor = DynamicToast.defaultTintColor; 532 | 533 | /** 534 | * Background color for the error toast. 535 | */ 536 | private @ColorInt Integer errorBackgroundColor = DynamicToast.errorBackgroundColor; 537 | 538 | /** 539 | * Background color for the success toast. 540 | */ 541 | private @ColorInt Integer successBackgroundColor = DynamicToast.successBackgroundColor; 542 | 543 | /** 544 | * Background color for the warning toast. 545 | */ 546 | private @ColorInt Integer warningBackgroundColor = DynamicToast.warningBackgroundColor; 547 | 548 | /** 549 | * Custom icon for the error toast. 550 | */ 551 | private Drawable errorIcon = DynamicToast.errorIcon; 552 | 553 | /** 554 | * Custom icon for the success toast. 555 | */ 556 | private Drawable successIcon = DynamicToast.successIcon; 557 | 558 | /** 559 | * Custom icon for the warning toast. 560 | */ 561 | private Drawable warningIcon = DynamicToast.warningIcon; 562 | 563 | /** 564 | * {@code true} to disable icon for all the toasts. 565 | */ 566 | private boolean disableIcon = DynamicToast.disableIcon; 567 | 568 | /** 569 | * {@code true} to tint icon for all the toasts. 570 | */ 571 | private boolean tintIcon = DynamicToast.tintIcon; 572 | 573 | /** 574 | * Icon size for the toast in pixels. 575 | */ 576 | private int iconSize = DynamicToast.iconSize; 577 | 578 | /** 579 | * Text size for the toast in SP. 580 | * 581 | * @see TypedValue#COMPLEX_UNIT_SP; 582 | */ 583 | private @ColorInt int textSize = DynamicToast.textSize; 584 | 585 | /** 586 | * Custom text typeface used by the toast. 587 | */ 588 | private Typeface textTypeface = null; 589 | 590 | /** 591 | * Custom background used by the toast. 592 | */ 593 | private Drawable toastBackground = null; 594 | 595 | /** 596 | * Making default constructor private to avoid instantiation. 597 | */ 598 | private Config() { } 599 | 600 | /** 601 | * Get instance to access public methods. Must be called before accessing methods. 602 | * 603 | * @return The singleton instance of this class. 604 | */ 605 | public static @NonNull Config getInstance() { 606 | if (sInstance == null) { 607 | sInstance = new Config(); 608 | } 609 | 610 | return sInstance; 611 | } 612 | 613 | /** 614 | * Set the default background color. 615 | * 616 | * @param defaultBackgroundColor The background color to be set. 617 | * 618 | * @return The {@link Config} object to allow for chaining of calls to set methods. 619 | */ 620 | public @NonNull Config setDefaultBackgroundColor( 621 | @Nullable @ColorInt Integer defaultBackgroundColor) { 622 | this.defaultBackgroundColor = defaultBackgroundColor; 623 | 624 | return this; 625 | } 626 | 627 | /** 628 | * Set the default tint color. 629 | * 630 | * @param defaultTintColor The tint color to be set. 631 | * 632 | * @return The {@link Config} object to allow for chaining of calls to set methods. 633 | */ 634 | public @NonNull Config setDefaultTintColor(@Nullable @ColorInt Integer defaultTintColor) { 635 | this.defaultTintColor = defaultTintColor; 636 | 637 | return this; 638 | } 639 | 640 | /** 641 | * Set the error background color. 642 | * 643 | * @param errorBackgroundColor The error background color to be set. 644 | * 645 | * @return The {@link Config} object to allow for chaining of calls to set methods. 646 | */ 647 | public @NonNull Config setErrorBackgroundColor( 648 | @Nullable @ColorInt Integer errorBackgroundColor) { 649 | this.errorBackgroundColor = errorBackgroundColor; 650 | 651 | return this; 652 | } 653 | 654 | /** 655 | * Set the success background color. 656 | * 657 | * @param successBackgroundColor The success background color 658 | * to be set. 659 | * 660 | * @return The {@link Config} object to allow for chaining of calls to set methods. 661 | */ 662 | public @NonNull Config setSuccessBackgroundColor( 663 | @Nullable @ColorInt Integer successBackgroundColor) { 664 | this.successBackgroundColor = successBackgroundColor; 665 | 666 | return this; 667 | } 668 | 669 | /** 670 | * Set the warning background color. 671 | * 672 | * @param warningBackgroundColor The warning background color to be set. 673 | * 674 | * @return The {@link Config} object to allow for chaining of calls to set methods. 675 | */ 676 | public @NonNull Config setWarningBackgroundColor( 677 | @Nullable @ColorInt Integer warningBackgroundColor) { 678 | this.warningBackgroundColor = warningBackgroundColor; 679 | 680 | return this; 681 | } 682 | 683 | /** 684 | * Set the error icon. 685 | *

Pass {@code null} to use the default icon. 686 | * 687 | * @param errorIcon The error icon to be set. 688 | * 689 | * @return The {@link Config} object to allow for chaining of calls to set methods. 690 | */ 691 | public @NonNull Config setErrorIcon(@Nullable Drawable errorIcon) { 692 | this.errorIcon = errorIcon; 693 | 694 | return this; 695 | } 696 | 697 | /** 698 | * Set the success icon. 699 | *

Pass {@code null} to use the default icon. 700 | * 701 | * @param successIcon The success icon to be set. 702 | * 703 | * @return The {@link Config} object to allow for chaining of calls to set methods. 704 | */ 705 | public @NonNull Config setSuccessIcon(@Nullable Drawable successIcon) { 706 | this.successIcon = successIcon; 707 | 708 | return this; 709 | } 710 | 711 | /** 712 | * Set the warning icon. 713 | *

Pass {@code null} to use the default icon. 714 | * 715 | * @param warningIcon The warning icon to be set. 716 | * 717 | * @return The {@link Config} object to allow for chaining of calls to set methods. 718 | */ 719 | public @NonNull Config setWarningIcon(@Nullable Drawable warningIcon) { 720 | this.warningIcon = warningIcon; 721 | 722 | return this; 723 | } 724 | 725 | /** 726 | * Set the icon visibility. 727 | * 728 | * @param disableIcon {@code true} to disable icon for all the toasts. 729 | * 730 | * @return The {@link Config} object to allow for chaining of calls to set methods. 731 | */ 732 | public @NonNull Config setDisableIcon(boolean disableIcon) { 733 | this.disableIcon = disableIcon; 734 | 735 | return this; 736 | } 737 | 738 | /** 739 | * Set whether to tint the icon. 740 | * 741 | * @param tintIcon {@code true} to tint icon for all the toasts. 742 | * 743 | * @return The {@link Config} object to allow for chaining of calls to set methods. 744 | */ 745 | public @NonNull Config setTintIcon(boolean tintIcon) { 746 | this.tintIcon = tintIcon; 747 | 748 | return this; 749 | } 750 | 751 | /** 752 | * Set the icon size. 753 | * 754 | * @param iconSize The icon size to be set in {@code pixels}. 755 | * 756 | * @return The {@link Config} object to allow for chaining of calls to set methods. 757 | */ 758 | public @NonNull Config setIconSize(int iconSize) { 759 | this.iconSize = iconSize; 760 | 761 | return this; 762 | } 763 | 764 | /** 765 | * Set the text size. 766 | * 767 | * @param textSize The text size to be set in {@code sp}. 768 | * 769 | * @return The {@link Config} object to allow for chaining of calls to set methods. 770 | */ 771 | public @NonNull Config setTextSize(int textSize) { 772 | this.textSize = textSize; 773 | 774 | return this; 775 | } 776 | 777 | /** 778 | * Set the text typeface. 779 | *

Pass {@code null} to use the default typeface. 780 | * 781 | * @param textTypeface The text typeface to be set. 782 | * 783 | * @return The {@link Config} object to allow for chaining of calls to set methods. 784 | */ 785 | public @NonNull Config setTextTypeface(@Nullable Typeface textTypeface) { 786 | this.textTypeface = textTypeface; 787 | 788 | return this; 789 | } 790 | 791 | /** 792 | * Set the toast background. 793 | *

Pass {@code null} to use the default background. 794 | * 795 | * @param toastBackground The toast background to be set. 796 | * 797 | * @return The {@link Config} object to allow for chaining of calls to set methods. 798 | */ 799 | public @NonNull Config setToastBackground(@Nullable Drawable toastBackground) { 800 | this.toastBackground = toastBackground; 801 | 802 | return this; 803 | } 804 | 805 | /** 806 | * Apply customisations. 807 | */ 808 | public void apply() { 809 | DynamicToast.defaultBackgroundColor = defaultBackgroundColor; 810 | DynamicToast.defaultTintColor = defaultTintColor; 811 | DynamicToast.errorBackgroundColor = errorBackgroundColor; 812 | DynamicToast.successBackgroundColor = successBackgroundColor; 813 | DynamicToast.warningBackgroundColor = warningBackgroundColor; 814 | DynamicToast.errorIcon = errorIcon; 815 | DynamicToast.successIcon = successIcon; 816 | DynamicToast.warningIcon = warningIcon; 817 | DynamicToast.disableIcon = disableIcon; 818 | DynamicToast.tintIcon = tintIcon; 819 | DynamicToast.iconSize = iconSize; 820 | DynamicToast.textSize = textSize; 821 | DynamicToast.textTypeface = textTypeface; 822 | DynamicToast.toastBackground = toastBackground; 823 | 824 | sInstance = null; 825 | } 826 | 827 | /** 828 | * Reset customisations. 829 | */ 830 | public void reset() { 831 | DynamicToast.defaultBackgroundColor = ADT_DEFAULT_BG_COLOR; 832 | DynamicToast.defaultTintColor = ADT_DEFAULT_TINT_COLOR; 833 | DynamicToast.errorBackgroundColor = ADT_DEFAULT_ERROR_BG_COLOR; 834 | DynamicToast.successBackgroundColor = ADT_DEFAULT_SUCCESS_BG_COLOR; 835 | DynamicToast.warningBackgroundColor = ADT_DEFAULT_WARNING_BG_COLOR; 836 | DynamicToast.errorIcon = null; 837 | DynamicToast.successIcon = null; 838 | DynamicToast.warningIcon = null; 839 | DynamicToast.disableIcon = ADT_DEFAULT_DISABLE_ICON; 840 | DynamicToast.tintIcon = ADT_DEFAULT_TINT_ICON; 841 | DynamicToast.iconSize = ADT_DEFAULT_ICON_SIZE; 842 | DynamicToast.textSize = ADT_DEFAULT_TEXT_SIZE; 843 | DynamicToast.textTypeface = null; 844 | DynamicToast.toastBackground = null; 845 | 846 | sInstance = null; 847 | } 848 | } 849 | } 850 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/java/com/pranavpandey/android/dynamic/toasts/internal/ToastCompat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2022 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.pranavpandey.android.dynamic.toasts.internal; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.content.Context; 21 | import android.content.res.Resources; 22 | import android.view.View; 23 | import android.widget.Toast; 24 | 25 | import androidx.annotation.NonNull; 26 | import androidx.annotation.Nullable; 27 | import androidx.annotation.StringRes; 28 | 29 | import com.pranavpandey.android.dynamic.util.DynamicSdkUtils; 30 | 31 | import java.lang.reflect.Field; 32 | 33 | /** 34 | * A Toast to fix the bad token exception on API 25. 35 | */ 36 | @SuppressWarnings("deprecation") 37 | public final class ToastCompat extends Toast { 38 | 39 | /** 40 | * Base toast used by this toast compat. 41 | */ 42 | private final @NonNull Toast mToast; 43 | 44 | public ToastCompat(Context context, @NonNull Toast base) { 45 | super(context); 46 | 47 | this.mToast = base; 48 | } 49 | 50 | /** 51 | * Make a standard toast that just contains a text view. 52 | * 53 | * @param context The context to use. 54 | * @param text The text to show. Can be formatted text. 55 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 56 | * or {@link Toast#LENGTH_LONG}. 57 | * 58 | * @return The standard toast that just contains a text view. 59 | */ 60 | @SuppressLint("ShowToast") 61 | public static ToastCompat makeText(@NonNull Context context, 62 | @Nullable CharSequence text, int duration) { 63 | Toast toast = Toast.makeText(context, text, duration); 64 | setToastContext(toast.getView(), new ToastContext(context, toast)); 65 | return new ToastCompat(context, toast); 66 | } 67 | 68 | /** 69 | * Make a standard toast that just contains a text view. 70 | * 71 | * @param context The context to use. 72 | * @param resId The resource id of the string resource to use. Can be formatted text. 73 | * @param duration The duration for the toast, either {@link Toast#LENGTH_SHORT} 74 | * or {@link Toast#LENGTH_LONG}. 75 | * 76 | * @return The standard toast that just contains a text view. 77 | */ 78 | public static Toast makeText(@NonNull Context context, @StringRes int resId, int duration) 79 | throws Resources.NotFoundException { 80 | return makeText(context, context.getResources().getText(resId), duration); 81 | } 82 | 83 | /** 84 | * Sets the toast context to fix bad token exception. 85 | * 86 | * @param view The view used by the toast 87 | * @param context The context used by the toast. 88 | */ 89 | @SuppressLint("DiscouragedPrivateApi") 90 | private static void setToastContext(@Nullable View view, @NonNull Context context) { 91 | if (view != null && DynamicSdkUtils.is25()) { 92 | try { 93 | Field field = View.class.getDeclaredField("mContext"); 94 | field.setAccessible(true); 95 | field.set(view, context); 96 | } catch (Throwable throwable) { 97 | throwable.printStackTrace(); 98 | } 99 | } 100 | } 101 | 102 | @Override 103 | public void show() { 104 | mToast.show(); 105 | } 106 | 107 | @Override 108 | public void setDuration(int duration) { 109 | mToast.setDuration(duration); 110 | } 111 | 112 | @Override 113 | public void setGravity(int gravity, int xOffset, int yOffset) { 114 | mToast.setGravity(gravity, xOffset, yOffset); 115 | } 116 | 117 | @Override 118 | public void setMargin(float horizontalMargin, float verticalMargin) { 119 | mToast.setMargin(horizontalMargin, verticalMargin); 120 | } 121 | 122 | @Override 123 | public void setText(int resId) { 124 | mToast.setText(resId); 125 | } 126 | 127 | @Override 128 | public void setText(CharSequence s) { 129 | mToast.setText(s); 130 | } 131 | 132 | @Override 133 | public void setView(View view) { 134 | mToast.setView(view); 135 | setToastContext(view, new ToastContext(view.getContext(), this)); 136 | } 137 | 138 | @Override 139 | public float getHorizontalMargin() { 140 | return mToast.getHorizontalMargin(); 141 | } 142 | 143 | @Override 144 | public float getVerticalMargin() { 145 | return mToast.getVerticalMargin(); 146 | } 147 | 148 | @Override 149 | public int getDuration() { 150 | return mToast.getDuration(); 151 | } 152 | 153 | @Override 154 | public int getGravity() { 155 | return mToast.getGravity(); 156 | } 157 | 158 | @Override 159 | public int getXOffset() { 160 | return mToast.getXOffset(); 161 | } 162 | 163 | @Override 164 | public int getYOffset() { 165 | return mToast.getYOffset(); 166 | } 167 | 168 | @Override 169 | public @Nullable View getView() { 170 | return mToast.getView(); 171 | } 172 | 173 | public @NonNull Toast getToast() { 174 | return mToast; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/java/com/pranavpandey/android/dynamic/toasts/internal/ToastContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2022 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.pranavpandey.android.dynamic.toasts.internal; 18 | 19 | import android.content.Context; 20 | import android.content.ContextWrapper; 21 | import android.view.Display; 22 | import android.view.View; 23 | import android.view.ViewGroup; 24 | import android.view.WindowManager; 25 | import android.widget.Toast; 26 | 27 | import androidx.annotation.NonNull; 28 | import androidx.annotation.Nullable; 29 | 30 | /** 31 | * A ContextWrapper to fix bad token exception. 32 | */ 33 | public final class ToastContext extends ContextWrapper { 34 | 35 | /** 36 | * Boast used by this context wrapper. 37 | */ 38 | private @NonNull Toast toast; 39 | 40 | /** 41 | * Constructor to initialize an object of this class. 42 | * 43 | * @param base The base context for this wrapper. 44 | * @param toast The toast for this wrapper. 45 | */ 46 | public ToastContext(@NonNull Context base, @NonNull Toast toast) { 47 | super(base); 48 | 49 | this.toast = toast; 50 | } 51 | 52 | @Override 53 | public Context getApplicationContext() { 54 | return new ApplicationContextWrapper(getBaseContext().getApplicationContext()); 55 | } 56 | 57 | /** 58 | * A ContextWrapper to initialize window manager service. 59 | */ 60 | static final class ApplicationContextWrapper extends ContextWrapper { 61 | 62 | /** 63 | * Constructor to initialize an object of this class. 64 | * 65 | * @param base The base context for this wrapper. 66 | */ 67 | private ApplicationContextWrapper(@NonNull Context base) { 68 | super(base); 69 | } 70 | 71 | @Override 72 | public Object getSystemService(@NonNull String name) { 73 | @Nullable Object service = null; 74 | if (Context.WINDOW_SERVICE.equals(name)) { 75 | service = getBaseContext().getSystemService(name); 76 | } 77 | 78 | if (service != null) { 79 | return new WindowManagerWrapper((WindowManager) service); 80 | } 81 | 82 | return super.getSystemService(name); 83 | } 84 | } 85 | 86 | /** 87 | * A WindowManager to fix the bad token exception. 88 | */ 89 | @SuppressWarnings("deprecation") 90 | static final class WindowManagerWrapper implements WindowManager { 91 | 92 | /** 93 | * The base window manager used by this wrapper. 94 | */ 95 | private final @NonNull WindowManager base; 96 | 97 | /** 98 | * Constructor to initialize an object of this class. 99 | * 100 | * @param base The base window manager for this wrapper. 101 | */ 102 | private WindowManagerWrapper(@NonNull WindowManager base) { 103 | this.base = base; 104 | } 105 | 106 | @Override 107 | public Display getDefaultDisplay() { 108 | return base.getDefaultDisplay(); 109 | } 110 | 111 | @Override 112 | public void removeViewImmediate(View view) { 113 | base.removeViewImmediate(view); 114 | } 115 | 116 | @Override 117 | public void addView(View view, ViewGroup.LayoutParams params) { 118 | try { 119 | base.addView(view, params); 120 | } catch (BadTokenException e) { 121 | e.printStackTrace(); 122 | } catch (Throwable throwable) { 123 | throwable.printStackTrace(); 124 | } 125 | } 126 | 127 | @Override 128 | public void updateViewLayout(View view, ViewGroup.LayoutParams params) { 129 | base.updateViewLayout(view, params); 130 | } 131 | 132 | @Override 133 | public void removeView(View view) { 134 | base.removeView(view); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-hdpi/adt_ic_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-hdpi/adt_ic_error.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-hdpi/adt_ic_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-hdpi/adt_ic_success.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-hdpi/adt_ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-hdpi/adt_ic_warning.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-mdpi/adt_ic_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-mdpi/adt_ic_error.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-mdpi/adt_ic_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-mdpi/adt_ic_success.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-mdpi/adt_ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-mdpi/adt_ic_warning.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xhdpi/adt_ic_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xhdpi/adt_ic_error.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xhdpi/adt_ic_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xhdpi/adt_ic_success.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xhdpi/adt_ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xhdpi/adt_ic_warning.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xxhdpi/adt_ic_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xxhdpi/adt_ic_error.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xxhdpi/adt_ic_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xxhdpi/adt_ic_success.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xxhdpi/adt_ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xxhdpi/adt_ic_warning.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xxxhdpi/adt_ic_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xxxhdpi/adt_ic_error.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xxxhdpi/adt_ic_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xxxhdpi/adt_ic_success.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable-xxxhdpi/adt_ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/dynamic-toasts/src/main/res/drawable-xxxhdpi/adt_ic_warning.png -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable/adt_hint_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/drawable/adt_toast_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/layout/adt_layout_hint.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 35 | 36 | 43 | 44 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/layout/adt_layout_toast.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 36 | 37 | 44 | 45 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /dynamic-toasts/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 15sp 22 | 24dp 23 | 12dp 24 | 16dp 25 | 8dp 26 | 27 | 28 | 13sp 29 | 20dp 30 | 8dp 31 | 12dp 32 | 4dp 33 | 34 | 35 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | android.nonTransitiveRClass=false 21 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jan 28 10:36:42 IST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /graphics/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/icon.png -------------------------------------------------------------------------------- /graphics/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/icon.psd -------------------------------------------------------------------------------- /graphics/legacy/icon-alt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/legacy/icon-alt.png -------------------------------------------------------------------------------- /graphics/legacy/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/legacy/icon.png -------------------------------------------------------------------------------- /graphics/legacy/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/legacy/icon.psd -------------------------------------------------------------------------------- /graphics/play/feature-graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/feature-graphic.png -------------------------------------------------------------------------------- /graphics/play/promo-graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/promo-graphic.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-1.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-2.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-3.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-4.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-5.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-6.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-7.png -------------------------------------------------------------------------------- /graphics/play/screenshots/phone-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/play/screenshots/phone-8.png -------------------------------------------------------------------------------- /graphics/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/preview.png -------------------------------------------------------------------------------- /graphics/preview.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/graphics/preview.psd -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2023 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.application' 18 | apply plugin: 'kotlin-android' 19 | 20 | android { 21 | compileSdkVersion versions.compileSdk 22 | buildToolsVersion versions.buildTools 23 | namespace 'com.pranavpandey.android.dynamic.toasts.sample' 24 | 25 | defaultConfig { 26 | applicationId "com.pranavpandey.android.dynamic.toasts.sample" 27 | minSdkVersion versions.minSdk 28 | targetSdkVersion versions.targetSdk 29 | versionCode sampleVersionCode 30 | versionName mavenVersion 31 | 32 | vectorDrawables.useSupportLibrary = true 33 | } 34 | 35 | buildTypes { 36 | release { 37 | minifyEnabled false 38 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 39 | } 40 | } 41 | 42 | lintOptions { 43 | abortOnError false 44 | } 45 | 46 | compileOptions { 47 | sourceCompatibility JavaVersion.VERSION_17 48 | targetCompatibility JavaVersion.VERSION_17 49 | } 50 | } 51 | 52 | dependencies { 53 | implementation(platform("org.jetbrains.kotlin:kotlin-bom:${versions.kotlin}")) 54 | 55 | implementation project(':dynamic-toasts') 56 | implementation "com.pranavpandey.android:dynamic-dialogs:${versions.dialogs}" 57 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" 58 | implementation "androidx.constraintlayout:constraintlayout:${versions.constraintlayout}" 59 | implementation "com.google.android.flexbox:flexbox:${versions.flexbox}" 60 | } 61 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in ANDROID_HOME/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 34 | 35 | 36 | 37 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /sample/src/main/java/com/pranavpandey/android/dynamic/toasts/sample/DynamicToastsActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2022 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.pranavpandey.android.dynamic.toasts.sample 18 | 19 | import android.content.res.Configuration 20 | import android.graphics.Color 21 | import android.graphics.Typeface 22 | import android.os.Bundle 23 | import android.view.Menu 24 | import android.view.MenuItem 25 | import android.view.View 26 | import android.widget.TextView 27 | import android.widget.Toast 28 | import androidx.appcompat.app.AppCompatActivity 29 | import androidx.appcompat.content.res.AppCompatResources 30 | import androidx.appcompat.widget.Toolbar 31 | import androidx.core.content.ContextCompat 32 | import com.google.android.material.floatingactionbutton.FloatingActionButton 33 | import com.pranavpandey.android.dynamic.toasts.DynamicHint 34 | import com.pranavpandey.android.dynamic.toasts.DynamicToast 35 | import com.pranavpandey.android.dynamic.toasts.sample.dialog.AboutDialogFragment 36 | import com.pranavpandey.android.dynamic.util.DynamicColorUtils 37 | import com.pranavpandey.android.dynamic.util.DynamicLinkUtils 38 | import com.pranavpandey.android.dynamic.util.DynamicPackageUtils 39 | import com.pranavpandey.android.dynamic.util.DynamicUnitUtils 40 | 41 | /** 42 | * Main activity to show the implementation of [DynamicToast]. 43 | */ 44 | class DynamicToastsActivity : AppCompatActivity(), View.OnClickListener { 45 | 46 | companion object { 47 | 48 | /** 49 | * Open source repository url. 50 | */ 51 | const val URL_GITHUB = "https://github.com/pranavpandey/dynamic-toasts" 52 | } 53 | 54 | override fun onCreate(savedInstanceState: Bundle?) { 55 | super.onCreate(savedInstanceState) 56 | 57 | setContentView(R.layout.activity_dynamic_toasts) 58 | val toolbar = findViewById(R.id.toolbar) 59 | toolbar.setSubtitle(R.string.app_name_sample) 60 | setSupportActionBar(toolbar) 61 | 62 | val fab = findViewById(R.id.fab) 63 | fab.setColorFilter(DynamicColorUtils.getTintColor( 64 | ContextCompat.getColor(this, R.color.color_accent))) 65 | 66 | (findViewById(R.id.gradle) as TextView).text = String.format( 67 | getString(R.string.format_version), 68 | DynamicPackageUtils.getVersionName(this)) 69 | 70 | fab.setOnClickListener(this) 71 | findViewById(R.id.toast_default).setOnClickListener(this) 72 | findViewById(R.id.toast_default_icon).setOnClickListener(this) 73 | findViewById(R.id.toast_success).setOnClickListener(this) 74 | findViewById(R.id.toast_error).setOnClickListener(this) 75 | findViewById(R.id.toast_success).setOnClickListener(this) 76 | findViewById(R.id.toast_warning).setOnClickListener(this) 77 | findViewById(R.id.toast_custom_icon).setOnClickListener(this) 78 | findViewById(R.id.toast_custom).setOnClickListener(this) 79 | findViewById(R.id.toast_error_color).setOnClickListener(this) 80 | findViewById(R.id.toast_success_color).setOnClickListener(this) 81 | findViewById(R.id.toast_warning_color).setOnClickListener(this) 82 | findViewById(R.id.toast_default_color).setOnClickListener(this) 83 | findViewById(R.id.toast_error_icon).setOnClickListener(this) 84 | findViewById(R.id.toast_success_icon).setOnClickListener(this) 85 | findViewById(R.id.toast_warning_icon).setOnClickListener(this) 86 | findViewById(R.id.toast_error_icon_disable).setOnClickListener(this) 87 | findViewById(R.id.toast_success_icon_disable).setOnClickListener(this) 88 | findViewById(R.id.toast_warning_icon_disable).setOnClickListener(this) 89 | findViewById(R.id.toast_error_icon_disable_tint).setOnClickListener(this) 90 | findViewById(R.id.toast_success_icon_disable_tint).setOnClickListener(this) 91 | findViewById(R.id.toast_warning_icon_disable_tint).setOnClickListener(this) 92 | findViewById(R.id.toast_config_text).setOnClickListener(this) 93 | findViewById(R.id.toast_config_background).setOnClickListener(this) 94 | findViewById(R.id.toast_config_icon_size).setOnClickListener(this) 95 | findViewById(R.id.hint_default).setOnClickListener(this) 96 | findViewById(R.id.hint_custom).setOnClickListener(this) 97 | } 98 | 99 | /** 100 | * Fix for AppCompat 1.1.0. 101 | * 102 | * https://issuetracker.google.com/issues/140602653 103 | */ 104 | override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) { 105 | if (overrideConfiguration != null) { 106 | val uiMode = overrideConfiguration.uiMode 107 | overrideConfiguration.setTo(baseContext.resources.configuration) 108 | overrideConfiguration.uiMode = uiMode 109 | } 110 | super.applyOverrideConfiguration(resources.configuration) 111 | } 112 | 113 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 114 | menuInflater.inflate(R.menu.main, menu) 115 | return super.onCreateOptionsMenu(menu) 116 | 117 | } 118 | 119 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 120 | if (item.itemId == R.id.menu_about) { 121 | AboutDialogFragment.newInstance().showDialog(this) 122 | 123 | return true 124 | } 125 | return super.onOptionsItemSelected(item) 126 | } 127 | 128 | override fun onClick(v: View) { 129 | when (v.id) { 130 | R.id.fab -> DynamicLinkUtils.viewUrl(this@DynamicToastsActivity, URL_GITHUB) 131 | 132 | // Default toast without icon. 133 | R.id.toast_default -> DynamicToast.make( 134 | this, getString(R.string.without_icon_desc)).show() 135 | 136 | // Default toast with icon. 137 | R.id.toast_default_icon -> DynamicToast.make( 138 | this, getString(R.string.with_icon_desc), 139 | AppCompatResources.getDrawable( 140 | this, R.drawable.ic_toast_icon)).show() 141 | 142 | // Error toast. 143 | R.id.toast_error -> DynamicToast.makeError( 144 | this, getString(R.string.error_desc)).show() 145 | 146 | // Success toast. 147 | R.id.toast_success -> DynamicToast.makeSuccess( 148 | this, getString(R.string.success_desc)).show() 149 | 150 | // Warning toast. 151 | R.id.toast_warning -> DynamicToast.makeWarning( 152 | this, getString(R.string.warning_desc)).show() 153 | 154 | // Custom toast without icon. 155 | R.id.toast_custom -> DynamicToast.make( 156 | this, getString(R.string.custom_desc), 157 | Color.parseColor("#FFFFFF"), Color.parseColor("#000000"), 158 | Toast.LENGTH_LONG).show() 159 | 160 | // Custom toast with icon. 161 | R.id.toast_custom_icon -> DynamicToast.make( 162 | this, getString(R.string.custom_desc), 163 | AppCompatResources.getDrawable(this, R.drawable.ic_social_github), 164 | Color.parseColor("#FFFFFF"), Color.parseColor("#000000"), 165 | Toast.LENGTH_LONG).show() 166 | 167 | // Error toast with custom color. 168 | R.id.toast_error_color -> { 169 | // Customise toast. 170 | DynamicToast.Config.getInstance() 171 | .setErrorBackgroundColor(Color.parseColor("#673AB7")) 172 | .apply() 173 | 174 | DynamicToast.makeError(this, getString(R.string.error_color_desc)).show() 175 | 176 | // Reset customisations. 177 | DynamicToast.Config.getInstance().reset() 178 | } 179 | 180 | // Success toast with custom color. 181 | R.id.toast_success_color -> { 182 | // Customise toast. 183 | DynamicToast.Config.getInstance() 184 | .setSuccessBackgroundColor(Color.parseColor("#2196F3")) 185 | .apply() 186 | 187 | DynamicToast.makeSuccess( 188 | this, getString(R.string.success_color_desc)).show() 189 | 190 | // Reset customisations. 191 | DynamicToast.Config.getInstance().reset() 192 | } 193 | 194 | // Warning toast with custom color. 195 | R.id.toast_warning_color -> { 196 | // Customise toast. 197 | DynamicToast.Config.getInstance() 198 | .setWarningBackgroundColor(Color.parseColor("#8BC34A")) 199 | .apply() 200 | 201 | DynamicToast.makeWarning( 202 | this, getString(R.string.warning_color_desc)).show() 203 | 204 | // Reset customisations. 205 | DynamicToast.Config.getInstance().reset() 206 | } 207 | 208 | // Default toast with custom color. 209 | R.id.toast_default_color -> { 210 | // Customise toast. 211 | DynamicToast.Config.getInstance() 212 | .setDefaultBackgroundColor(Color.parseColor("#607d8b")) 213 | .setDefaultTintColor(DynamicColorUtils.getTintColor( 214 | Color.parseColor("#607d8b"))) 215 | .apply() 216 | 217 | DynamicToast.make( 218 | this, getString(R.string.default_color_desc)).show() 219 | 220 | // Reset customisations. 221 | DynamicToast.Config.getInstance().reset() 222 | } 223 | 224 | // Error toast with custom icon. 225 | R.id.toast_error_icon -> { 226 | // Customise toast. 227 | DynamicToast.Config.getInstance() 228 | .setErrorIcon(AppCompatResources.getDrawable( 229 | this, R.drawable.ic_toast_icon)) 230 | .apply() 231 | 232 | DynamicToast.makeError(this, 233 | getString(R.string.error_icon_desc)).show() 234 | 235 | // Reset customisations. 236 | DynamicToast.Config.getInstance().reset() 237 | } 238 | 239 | // Success toast with custom icon. 240 | R.id.toast_success_icon -> { 241 | // Customise toast. 242 | DynamicToast.Config.getInstance() 243 | .setSuccessIcon(AppCompatResources.getDrawable( 244 | this, R.drawable.ic_toast_icon)) 245 | .apply() 246 | 247 | DynamicToast.makeSuccess(this, 248 | getString(R.string.success_icon_desc)).show() 249 | 250 | // Reset customisations. 251 | DynamicToast.Config.getInstance().reset() 252 | } 253 | 254 | // Warning toast with custom icon. 255 | R.id.toast_warning_icon -> { 256 | // Customise toast. 257 | DynamicToast.Config.getInstance() 258 | .setWarningIcon(AppCompatResources.getDrawable( 259 | this, R.drawable.ic_toast_icon)) 260 | .apply() 261 | 262 | DynamicToast.makeWarning(this, 263 | getString(R.string.warning_icon_desc)).show() 264 | 265 | // Reset customisations. 266 | DynamicToast.Config.getInstance().reset() 267 | } 268 | 269 | // Error toast without icon. 270 | R.id.toast_error_icon_disable -> { 271 | // Customise toast. 272 | DynamicToast.Config.getInstance() 273 | .setDisableIcon(true) 274 | .apply() 275 | 276 | DynamicToast.makeError(this, 277 | getString(R.string.error_icon_disable_desc)).show() 278 | 279 | // Reset customisations. 280 | DynamicToast.Config.getInstance().reset() 281 | } 282 | 283 | // Success toast without icon. 284 | R.id.toast_success_icon_disable -> { 285 | // Customise toast. 286 | DynamicToast.Config.getInstance() 287 | .setDisableIcon(true) 288 | .apply() 289 | 290 | DynamicToast.makeSuccess(this, 291 | getString(R.string.success_icon_disable_desc)).show() 292 | 293 | // Reset customisations. 294 | DynamicToast.Config.getInstance().reset() 295 | } 296 | 297 | // Warning toast without icon. 298 | R.id.toast_warning_icon_disable -> { 299 | // Customise toast. 300 | DynamicToast.Config.getInstance() 301 | .setDisableIcon(true) 302 | .apply() 303 | 304 | DynamicToast.makeWarning(this, getString( 305 | R.string.warning_icon_disable_desc)).show() 306 | 307 | // Reset customisations. 308 | DynamicToast.Config.getInstance().reset() 309 | } 310 | 311 | // Error toast without icon tint. 312 | R.id.toast_error_icon_disable_tint -> { 313 | // Customise toast. 314 | DynamicToast.Config.getInstance() 315 | .setErrorIcon(AppCompatResources.getDrawable( 316 | this, R.mipmap.ic_launcher)) 317 | .setTintIcon(false) 318 | .apply() 319 | 320 | DynamicToast.makeError(this, 321 | getString(R.string.error_icon_disable_tint_desc)).show() 322 | 323 | // Reset customisations. 324 | DynamicToast.Config.getInstance().reset() 325 | } 326 | 327 | // Success toast without icon tint. 328 | R.id.toast_success_icon_disable_tint -> { 329 | // Customise toast. 330 | DynamicToast.Config.getInstance() 331 | .setSuccessIcon(AppCompatResources.getDrawable( 332 | this, R.mipmap.ic_launcher)) 333 | .setTintIcon(false) 334 | .apply() 335 | 336 | DynamicToast.makeSuccess(this, 337 | getString(R.string.success_icon_disable_tint_desc)).show() 338 | 339 | // Reset customisations. 340 | DynamicToast.Config.getInstance().reset() 341 | } 342 | 343 | // Warning toast without icon tint. 344 | R.id.toast_warning_icon_disable_tint -> { 345 | // Customise toast. 346 | DynamicToast.Config.getInstance() 347 | .setWarningIcon(AppCompatResources.getDrawable( 348 | this, R.mipmap.ic_launcher)) 349 | .setTintIcon(false) 350 | .apply() 351 | 352 | DynamicToast.makeWarning(this, getString( 353 | R.string.warning_icon_disable_tint_desc)).show() 354 | 355 | // Reset customisations. 356 | DynamicToast.Config.getInstance().reset() 357 | } 358 | 359 | // Toast with custom text size and typeface. 360 | R.id.toast_config_text -> { 361 | // Customise toast. 362 | DynamicToast.Config.getInstance() 363 | .setTextSize(18) 364 | .setErrorIcon(AppCompatResources.getDrawable( 365 | this, R.drawable.ic_toast_icon)) 366 | .setTextTypeface(Typeface.create( 367 | Typeface.SERIF, Typeface.BOLD_ITALIC)) 368 | .setErrorBackgroundColor(Color.parseColor("#2196F3")) 369 | .apply() 370 | 371 | DynamicToast.makeError(this, getString(R.string.text_desc)).show() 372 | 373 | // Reset customisations. 374 | DynamicToast.Config.getInstance().reset() 375 | } 376 | 377 | // Toast with custom background. 378 | R.id.toast_config_background -> { 379 | // Customise toast. 380 | DynamicToast.Config.getInstance() 381 | .setToastBackground(AppCompatResources.getDrawable( 382 | this, R.drawable.bg_custom_toast)) 383 | .apply() 384 | 385 | DynamicToast.makeSuccess(this, getString(R.string.background_desc)).show() 386 | 387 | // Reset customisations. 388 | DynamicToast.Config.getInstance().reset() 389 | } 390 | 391 | // Toast with custom icon size. 392 | R.id.toast_config_icon_size -> { 393 | // Customise toast. 394 | DynamicToast.Config.getInstance() 395 | .setIconSize(DynamicUnitUtils.convertDpToPixels(48f)) 396 | .apply() 397 | 398 | DynamicToast.makeWarning(this, getString(R.string.icon_size_desc)).show() 399 | 400 | // Reset customisations. 401 | DynamicToast.Config.getInstance().reset() 402 | } 403 | 404 | // Default hint without icon. 405 | R.id.hint_default -> DynamicHint.show(v, 406 | DynamicHint.make(this, getString(R.string.default_hint))) 407 | 408 | // Custom hint with icon. 409 | R.id.hint_custom -> { 410 | // Customise hint. 411 | DynamicHint.Config.getInstance() 412 | .setDefaultBackgroundColor(Color.parseColor("#607d8b")) 413 | .setDefaultTintColor(DynamicColorUtils.getTintColor( 414 | Color.parseColor("#607d8b"))) 415 | .apply() 416 | 417 | DynamicHint.show(v, DynamicHint.make(this, getString(R.string.custom_hint), 418 | AppCompatResources.getDrawable(this, R.drawable.adt_ic_warning))) 419 | 420 | // Reset customisations. 421 | DynamicHint.Config.getInstance().reset() 422 | } 423 | } 424 | } 425 | } 426 | -------------------------------------------------------------------------------- /sample/src/main/java/com/pranavpandey/android/dynamic/toasts/sample/dialog/AboutDialogFragment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2022 Pranav Pandey 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.pranavpandey.android.dynamic.toasts.sample.dialog 18 | 19 | import android.os.Build 20 | import android.os.Bundle 21 | import android.text.Html 22 | import android.text.Spanned 23 | import android.text.method.LinkMovementMethod 24 | import android.view.LayoutInflater 25 | import android.view.View 26 | import android.widget.LinearLayout 27 | import android.widget.TextView 28 | import androidx.core.content.ContextCompat 29 | import com.pranavpandey.android.dynamic.dialogs.DynamicDialog 30 | import com.pranavpandey.android.dynamic.dialogs.fragment.DynamicDialogFragment 31 | import com.pranavpandey.android.dynamic.toasts.sample.R 32 | import com.pranavpandey.android.dynamic.util.DynamicLinkUtils 33 | 34 | /** 35 | * About dialog to show library info. 36 | */ 37 | class AboutDialogFragment : DynamicDialogFragment() { 38 | 39 | companion object { 40 | 41 | /** 42 | * Url for other apps on Google Play. 43 | */ 44 | const val URL_PLAY_STORE = 45 | "https://play.google.com/store/apps/dev?id=6608630615059087491" 46 | 47 | /** 48 | * Initialize the new instance of this fragment. 49 | * 50 | * @return An instance of [AboutDialogFragment]. 51 | */ 52 | fun newInstance(): AboutDialogFragment { 53 | return AboutDialogFragment() 54 | } 55 | 56 | /** 57 | * Method to handle [Html.fromHtml] deprecation. 58 | */ 59 | @Suppress("DEPRECATION") 60 | private fun fromHtml(html: String): Spanned { 61 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 62 | Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY) 63 | } else { 64 | Html.fromHtml(html) 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * Customise [DynamicDialog.Builder] by overriding this method. 71 | */ 72 | override fun onCustomiseBuilder( 73 | alertDialogBuilder: DynamicDialog.Builder, 74 | savedInstanceState: Bundle? 75 | ): DynamicDialog.Builder { 76 | // Customise dialog builder to add neutral, positive and negative buttons. 77 | // Also, set a view root to add top and bottom scroll indicators. 78 | return alertDialogBuilder.setTitle(R.string.about) 79 | .setPositiveButton(R.string.more_apps) { _, _ -> 80 | DynamicLinkUtils.viewUrl(requireContext(), URL_PLAY_STORE) 81 | } 82 | .setNegativeButton(android.R.string.cancel, null) 83 | // Set custom view for the dialog. 84 | .setView( 85 | LayoutInflater.from(context).inflate( 86 | R.layout.dialog_about, 87 | LinearLayout(context), false 88 | ) 89 | ) 90 | // Set view root to automatically add scroll dividers. 91 | .setViewRoot(R.id.dialog_about_root) 92 | } 93 | 94 | /** 95 | * Customise [DynamicDialog] by overriding this method. 96 | */ 97 | override fun onCustomiseDialog( 98 | alertDialog: DynamicDialog, 99 | view: View?, savedInstanceState: Bundle? 100 | ) { 101 | super.onCustomiseDialog(alertDialog, view, savedInstanceState) 102 | 103 | // Customise the custom view. 104 | val message = view?.findViewById(R.id.dialog_about_text) 105 | 106 | message?.text = fromHtml(getString(R.string.about_content)) 107 | message?.setLineSpacing(0f, 1.2f) 108 | message?.movementMethod = LinkMovementMethod.getInstance() 109 | message?.setLinkTextColor(ContextCompat.getColor(requireContext(), R.color.color_primary)) 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/app_bar_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/bg_custom_toast.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_social_github.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_toast_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 27 | 28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_dynamic_toasts.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 25 | 26 | 31 | 32 | 38 | 39 | 40 | 41 | 42 | 43 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/content_dynamic_toasts.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 32 | 33 | 41 | 42 | 45 | 46 | 53 | 54 | 61 | 62 | 70 | 71 | 80 | 81 | 86 | 87 | 92 | 93 | 94 | 95 | 103 | 104 | 113 | 114 | 119 | 120 | 125 | 126 | 131 | 132 | 133 | 134 | 142 | 143 | 152 | 153 | 158 | 159 | 164 | 165 | 166 | 167 | 175 | 176 | 185 | 186 | 191 | 192 | 197 | 198 | 203 | 204 | 209 | 210 | 211 | 212 | 220 | 221 | 230 | 231 | 236 | 237 | 242 | 243 | 248 | 249 | 250 | 251 | 259 | 260 | 269 | 270 | 275 | 276 | 281 | 282 | 287 | 288 | 289 | 290 | 298 | 299 | 308 | 309 | 314 | 315 | 320 | 321 | 326 | 327 | 328 | 329 | 337 | 338 | 347 | 348 | 353 | 354 | 359 | 360 | 365 | 366 | 367 | 368 | 376 | 377 | 386 | 387 | 392 | 393 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 412 | 413 | 414 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/dialog_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 24 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 |

21 | 22 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pranavpandey/dynamic-toasts/06483b06973e9ca627637c5b30011d5ed53e98d5/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | #F44336 22 | #D32F2F 23 | #673AB7 24 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 16dp 22 | 64dp 23 | 16dp 24 | 25 | 26 | 24dp 27 | 28 | 29 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | Dynamic Toasts 21 | Sample 22 | Gradle dependency 23 | com.pranavpandey.android:dynamic-toasts:%1$s 24 | 25 | Sources 26 | About 27 | dynamic-toasts
29 | A simple library to display themed toasts with icon and text on Android.

30 | © Pranav Pandey

31 | Website   32 | GitHub   33 | LinkedIn

34 | Please download my other apps via Google Play to support the development. 35 | ]]>
36 | Donate 37 | Google Play 38 | 39 | Default toasts 40 | Without icon 41 | Default toast without icon 42 | With icon 43 | Default toast with icon 44 | In-built toasts 45 | Default 46 | Custom 47 | Default toast with custom color 48 | Error 49 | An error has occurred 50 | Error toast with custom color 51 | Error toast with custom icon 52 | Error toast without icon 53 | Error toast without icon tint 54 | Success 55 | Task has been completed successfully 56 | Success toast with custom color 57 | Success toast with custom icon 58 | Success toast without icon 59 | Success toast without icon tint 60 | Warning 61 | This is a warning! 62 | Warning toast with custom color 63 | Warning toast with custom icon 64 | Warning toast without icon 65 | Warning toast without icon tint 66 | Custom toasts 67 | Sources are available on GitHub 68 | Custom colors 69 | Custom icons 70 | Disable icon 71 | Disable icon tint 72 | Other customisations 73 | Cheat sheets 74 | Default hint 75 | Custom hint 76 | text 77 | Toast with custom text size and typeface 78 | background 79 | Toast with custom background 80 | Icon size 81 | Toast with custom icon size 82 | 83 |
84 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 29 | 30 | 34 | 35 |