├── .gitignore ├── StyleableToastDemo.apk ├── build.gradle ├── cases.png ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── io │ │ └── github │ │ └── muddz │ │ └── styleabletoast │ │ └── demo │ │ └── MainActivity.java │ └── res │ ├── drawable │ ├── ic_autorenew_black_24dp.xml │ └── ic_autorenew_white_24dp.xml │ ├── font │ └── dosis.otf │ ├── layout │ └── activity_main.xml │ ├── values-v27 │ └── styles.xml │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── license ├── readme.md ├── settings.gradle └── styleabletoast ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── java └── io │ └── github │ └── muddz │ └── styleabletoast │ ├── StyleableToast.java │ └── Utils.java └── res ├── drawable-v27 └── shape_toast.xml ├── drawable └── shape_toast.xml ├── layout-v27 └── styleable_layout.xml ├── layout └── styleable_layout.xml ├── values-v27 ├── colors.xml └── dimens.xml └── values ├── attrs.xml ├── colors.xml ├── dimens.xml └── integers.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /StyleableToastDemo.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muddz/StyleableToast/48883c4ec1addba90e061b9a3699ca6680559a23/StyleableToastDemo.apk -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:7.0.0' 11 | classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.5.0' 12 | classpath 'com.vanniktech:gradle-maven-publish-plugin:0.17.0' 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | google() 19 | mavenCentral() 20 | } 21 | plugins.withId("com.vanniktech.maven.publish") { 22 | mavenPublish { 23 | sonatypeHost = "S01" 24 | } 25 | } 26 | } 27 | 28 | task clean(type: Delete) { 29 | delete rootProject.buildDir 30 | } -------------------------------------------------------------------------------- /cases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muddz/StyleableToast/48883c4ec1addba90e061b9a3699ca6680559a23/cases.png -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 30 7 | 8 | defaultConfig { 9 | applicationId "io.github.muddz.styleabletoast.demo" 10 | minSdk 16 11 | targetSdk 30 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | 16 | buildFeatures { 17 | dataBinding true 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | } 27 | 28 | dependencies { 29 | implementation 'androidx.appcompat:appcompat:1.3.1' 30 | implementation 'com.google.android.material:material:1.4.0' 31 | implementation 'io.github.muddz:styleabletoast:2.4.0' 32 | // implementation project(':styleabletoast') 33 | } 34 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /demo/src/main/java/io/github/muddz/styleabletoast/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.github.muddz.styleabletoast.demo; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | import androidx.databinding.DataBindingUtil; 8 | 9 | import io.github.muddz.styleabletoast.StyleableToast; 10 | import io.github.muddz.styleabletoast.demo.databinding.ActivityMainBinding; 11 | 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | 15 | String toastMsg = "Hello World!"; 16 | int redColor = Color.parseColor("#FF5A5F"); 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); 22 | binding.setMain(this); 23 | 24 | } 25 | 26 | public void coloredBackground() { 27 | StyleableToast.Builder st = new StyleableToast.Builder(this) 28 | .text(toastMsg) 29 | .backgroundColor(redColor) 30 | .build(); 31 | 32 | st.show(); 33 | } 34 | 35 | public boolean coloredBackgroundXML() { 36 | StyleableToast.makeText(this, toastMsg, R.style.ColoredBackground).show(); 37 | return true; 38 | } 39 | 40 | 41 | public void coloredText() { 42 | new StyleableToast.Builder(this) 43 | .text(toastMsg) 44 | .textColor(redColor) 45 | .show(); 46 | } 47 | 48 | public boolean coloredTextXML() { 49 | StyleableToast.makeText(this, toastMsg, R.style.ColoredText).show(); 50 | return true; 51 | } 52 | 53 | 54 | public void coloredBoldText() { 55 | new StyleableToast.Builder(this) 56 | .text(toastMsg) 57 | .textColor(redColor) 58 | .textBold() 59 | .show(); 60 | } 61 | 62 | public boolean coloredBoldTextXML() { 63 | StyleableToast.makeText(this, toastMsg, R.style.ColoredBoldText).show(); 64 | return true; 65 | } 66 | 67 | 68 | public void customFont() { 69 | new StyleableToast.Builder(this) 70 | .text(toastMsg) 71 | .font(R.font.dosis) 72 | .show(); 73 | } 74 | 75 | public boolean customFontXML() { 76 | StyleableToast.makeText(this, toastMsg, R.style.CustomFont).show(); 77 | return true; 78 | } 79 | 80 | public void cornerRadius() { 81 | new StyleableToast.Builder(this) 82 | .text(toastMsg) 83 | .cornerRadius(5) 84 | .show(); 85 | } 86 | 87 | public boolean cornerRadiusXML() { 88 | StyleableToast.makeText(this, toastMsg, R.style.CornerRadius5Dp).show(); 89 | return true; 90 | } 91 | 92 | public void iconStart() { 93 | new StyleableToast.Builder(this) 94 | .text(toastMsg) 95 | .iconStart(getIcon()) 96 | .show(); 97 | } 98 | 99 | public boolean iconStartXML() { 100 | StyleableToast.makeText(this, toastMsg, R.style.IconStart).show(); 101 | return true; 102 | } 103 | 104 | 105 | public void iconEnd() { 106 | new StyleableToast.Builder(this) 107 | .text(toastMsg) 108 | .iconEnd(getIcon()) 109 | .show(); 110 | } 111 | 112 | public boolean iconEndXML() { 113 | StyleableToast.makeText(this, toastMsg, R.style.IconEnd).show(); 114 | return true; 115 | } 116 | 117 | 118 | public void iconStartEnd() { 119 | new StyleableToast.Builder(this) 120 | .text(toastMsg) 121 | .iconStart(getIcon()) 122 | .iconEnd(getIcon()) 123 | .show(); 124 | } 125 | 126 | public boolean iconStartEndXML() { 127 | StyleableToast.makeText(this, toastMsg, R.style.IconStartEnd).show(); 128 | return true; 129 | } 130 | 131 | public void coloredStroke() { 132 | new StyleableToast.Builder(this) 133 | .text(toastMsg) 134 | .stroke(2, redColor) 135 | .show(); 136 | } 137 | 138 | public boolean coloredStrokeXML() { 139 | StyleableToast.makeText(this, toastMsg, R.style.ColoredStroke).show(); 140 | return true; 141 | } 142 | 143 | public void allStyles() { 144 | new StyleableToast.Builder(this) 145 | .text(toastMsg) 146 | .stroke(2, Color.BLACK) 147 | .backgroundColor(Color.WHITE) 148 | .solidBackground() 149 | .textColor(Color.RED) 150 | .textBold() 151 | .font(R.font.dosis) 152 | .iconStart(getIcon()) 153 | .iconEnd(getIcon()) 154 | .cornerRadius(12) 155 | .textSize(18) 156 | .show(); 157 | } 158 | 159 | public boolean allStylesXML() { 160 | StyleableToast.makeText(this, toastMsg, R.style.AllStyles).show(); 161 | return true; 162 | } 163 | 164 | public int getIcon() { 165 | if (android.os.Build.VERSION.SDK_INT >= 27) { 166 | return R.drawable.ic_autorenew_black_24dp; 167 | } else { 168 | return R.drawable.ic_autorenew_white_24dp; 169 | } 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/ic_autorenew_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/ic_autorenew_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/font/dosis.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Muddz/StyleableToast/48883c4ec1addba90e061b9a3699ca6680559a23/demo/src/main/res/font/dosis.otf -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 14 | 15 | 23 | 24 | 28 | 29 | 37 | 38 |