├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml ├── vcs.xml └── workspace.xml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── pierry │ │ └── simpletoast │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── pierry │ │ └── simpletoast │ │ └── SimpleToast.java │ └── res │ ├── drawable-hdpi │ ├── cancel.png │ ├── info.png │ └── ok.png │ ├── drawable-mdpi │ ├── cancel.png │ ├── info.png │ └── ok.png │ ├── drawable-xhdpi │ ├── cancel.png │ ├── info.png │ └── ok.png │ ├── drawable-xxhdpi │ ├── cancel.png │ ├── info.png │ └── ok.png │ ├── drawable-xxxhdpi │ ├── cancel.png │ ├── info.png │ └── ok.png │ ├── drawable │ ├── background_empty.xml │ ├── list_border_back_blue.xml │ ├── list_border_back_gray.xml │ ├── list_border_back_green.xml │ ├── list_border_back_red.xml │ └── list_border_back_yellow.xml │ ├── layout │ ├── toast_error.xml │ ├── toast_error_icon.xml │ ├── toast_info.xml │ ├── toast_info_icon.xml │ ├── toast_muted.xml │ ├── toast_muted_icon.xml │ ├── toast_ok.xml │ ├── toast_ok_icon.xml │ ├── toast_warning.xml │ └── toast_warning_icon.xml │ └── values │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── config └── checkstyle │ └── checkstyle.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screentshots ├── cancel.png ├── cancel_default.png ├── info.png ├── info_default.png ├── muted.png ├── ok.png ├── ok_default.png └── warning.png ├── settings.gradle ├── simpletoast.iml └── travis.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | simpletoast -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 105 | 106 | 130 | 1124 | 1132 | 1421 | 1424 | 1425 | 1426 | 1437 | 1438 | 1439 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | 1454 | 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1476 | 1477 | 1480 | 1481 | 1482 | 1483 | 1486 | 1487 | 1490 | 1491 | 1494 | 1495 | 1498 | 1499 | 1500 | 1501 | 1504 | 1505 | 1508 | 1509 | 1512 | 1513 | 1514 | 1515 | 1518 | 1519 | 1522 | 1523 | 1526 | 1527 | 1528 | 1529 | 1532 | 1533 | 1536 | 1537 | 1540 | 1541 | 1544 | 1545 | 1546 | 1547 | 1550 | 1551 | 1554 | 1555 | 1558 | 1559 | 1560 | 1561 | 1562 | 1563 | 1564 | 1565 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 | 1578 | 1579 | 1580 | 1581 | 1582 | 1583 | 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | 1590 | 1591 | 1592 | 1593 | 1594 | 1626 | 1627 | 1628 | 1659 | 1660 | 1661 | 1674 | 1675 | 1676 | 1677 | 1691 | 1692 | 1693 | 1694 | 1697 | 1698 | 1699 | 1700 | 1701 | 1702 | 1703 | 1704 | 1711 | 1712 | 1713 | 1714 | 1732 | 1739 | 1740 | 1748 | 1749 | 1751 | 1752 | localhost 1753 | 5050 1754 | 1755 | 1756 | 1757 | 1758 | 1759 | 1760 | 1761 | 1762 | 1763 | 1445876280758 1764 | 1767 | 1768 | 1454333896836 1769 | 1773 | 1776 | 1777 | 1778 | 1779 | 1780 | 1781 | 1782 | 1783 | 1784 | 1785 | 1786 | 1787 | 1788 | 1789 | 1790 | 1791 | 1792 | 1793 | 1794 | 1795 | 1796 | 1797 | 1798 | 1799 | 1800 | 1801 | 1802 | 1803 | 1804 | 1805 | 1806 | 1807 | 1808 | 1809 | 1810 | 1811 | 1812 | 1813 | 1814 | 1816 | 1817 | 1818 | 1820 | 1821 | 1822 | 1823 | 1824 | 1825 | 1826 | 1827 | 1828 | 1829 | 1830 | 1831 | 1832 | 1833 | 1834 | 1835 | 1836 | 1837 | 1838 | 1839 | 1840 | 1841 | 1842 | 1843 | 1844 | 1845 | 1846 | 1847 | 1848 | 1849 | 1850 | 1851 | 1852 | 1853 | 1854 | 1855 | 1856 | 1857 | 1858 | 1859 | 1860 | 1861 | 1862 | 1863 | 1864 | 1865 | 1866 | 1867 | 1868 | 1869 | 1870 | 1871 | 1872 | 1873 | 1874 | 1875 | 1876 | 1877 | 1878 | 1879 | 1880 | 1881 | 1882 | 1883 | 1884 | 1885 | 1886 | 1887 | 1888 | 1889 | 1890 | 1891 | 1892 | 1893 | 1894 | 1895 | 1896 | 1897 | 1898 | 1899 | 1900 | 1901 | 1902 | 1903 | 1904 | 1905 | 1906 | 1907 | 1908 | 1909 | 1910 | 1911 | 1912 | 1913 | 1914 | 1915 | 1916 | 1917 | 1918 | 1919 | 1920 | 1921 | 1922 | 1923 | 1924 | 1925 | 1926 | 1927 | 1928 | 1929 | 1930 | 1931 | 1932 | 1933 | 1934 | 1935 | 1936 | 1937 | 1938 | 1939 | 1940 | 1941 | 1942 | 1943 | 1944 | 1945 | 1946 | 1947 | 1948 | 1949 | 1950 | 1951 | 1952 | 1953 | 1954 | 1955 | 1956 | 1957 | 1958 | 1959 | 1960 | 1961 | 1962 | 1963 | 1964 | 1965 | 1966 | 1967 | 1968 | 1969 | 1970 | 1971 | 1972 | 1973 | 1974 | 1975 | 1976 | 1977 | 1978 | 1979 | 1980 | 1981 | 1982 | 1983 | 1984 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SimpleToast 2 | =========== 3 | 4 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SimpleToast-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1031) 5 | ![](https://img.shields.io/github/tag/Pierry/SimpleToast.svg?label=maven) 6 | 7 | Notifications for Android (like a Toast) 8 | 9 | Current version: v1.9 10 | 11 | Example 12 | =========== 13 | ### Default icons 14 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/ok_default.png) 15 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/cancel_default.png) 16 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/info_default.png) 17 | ### Font awesome 18 | 19 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/cancel.png) 20 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/ok.png) 21 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/info.png) 22 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/muted.png) 23 | ![alt tag](https://raw.githubusercontent.com/Pierry/SimpleToast/master/screentshots/warning.png) 24 | 25 | 26 | Gradle 27 | =========== 28 | 29 | This library uses android-iconify:1.0.9. 30 | 31 | Into your build.gradle: 32 | 33 | repositories { 34 | maven { url "https://jitpack.io" } 35 | } 36 | 37 | dependencies { 38 | compile 'com.github.Pierry:SimpleToast:v1.7' 39 | } 40 | 41 | Ref. https://jitpack.io/#Pierry/SimpleToast/v1.7 42 | 43 | Usage 44 | ============= 45 | 46 | The API is kept as simple as the Toast API: 47 | 48 | Create a SimpleToast for any CharSequence with default icon: 49 | 50 | SimpleToast.ok(Context, CharSequence); 51 | SimpleToast.error(Context, CharSequence); 52 | SimpleToast.info(Context, CharSequence); 53 | SimpleToast.muted(Context, CharSequence); 54 | SimpleToast.warning(Context, CharSequence); 55 | 56 | Using [Font Awesome](http://fortawesome.github.io/Font-Awesome/icons/): 57 | 58 | SimpleToast.ok(Context, CharSequence, "{fa-home}"); 59 | SimpleToast.error(Context, CharSequence, "{fa-user}"); 60 | SimpleToast.info(Context, CharSequence, "{fa-check-square}"); 61 | SimpleToast.muted(Context, CharSequence, "{fa-github}"); 62 | SimpleToast.warning(Context, CharSequence, "{fa-exclamation-circle}"); 63 | 64 | Use this link for icons: 65 | http://fortawesome.github.io/Font-Awesome/icons/ 66 | 67 | Questions 68 | ========== 69 | Questions regarding SimpleToast can be asked on [StackOverflow, using the simpletoast tag](http://stackoverflow.com/questions/tagged/simpletoast). 70 | 71 | Credits 72 | ========== 73 | [Joan Zapata](https://github.com/JoanZapata) creator of [Android-Iconify](https://github.com/JoanZapata/android-iconify) 74 | 75 | [Dave Gandy](https://github.com/davegandy) creator of [Font-Awesome](https://github.com/FortAwesome/Font-Awesome) 76 | 77 | Developed By 78 | ========== 79 | Pierry Borges - http://pierry.github.io - pieerry@gmail.com 80 | 81 | License 82 | ========== 83 | 84 | [Apache Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) 85 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'checkstyle' 3 | 4 | dependencies { 5 | compile 'com.android.support:appcompat-v7:22.1.0' 6 | compile 'com.joanzapata.android:android-iconify:1.0.9' 7 | } 8 | 9 | android { 10 | compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION) 11 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 12 | 13 | defaultConfig { 14 | versionCode Integer.parseInt(project.VERSION_CODE) 15 | versionName project.VERSION_NAME 16 | minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK) 17 | targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION) 18 | } 19 | 20 | sourceSets { 21 | main { 22 | manifest.srcFile 'src/main/AndroidManifest.xml' 23 | java.srcDirs = ['src/main/java'] 24 | res.srcDirs = ['src/main/res'] 25 | } 26 | } 27 | lintOptions { 28 | abortOnError false 29 | } 30 | } 31 | 32 | task checkstyle(type: Checkstyle) { 33 | configFile file('../config/checkstyle/checkstyle.xml') 34 | source 'src/main/java' 35 | include '**/*.java' 36 | exclude '**/gen/**' 37 | classpath = files() 38 | } -------------------------------------------------------------------------------- /app/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 C:\Users\Pierry\AppData\Local\Android\sdk/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/github/pierry/simpletoast/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.github.pierry.simpletoast; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/pierry/simpletoast/SimpleToast.java: -------------------------------------------------------------------------------- 1 | package com.github.pierry.simpletoast; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.os.Build; 6 | import android.os.Handler; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.IconTextView; 11 | import android.widget.Toast; 12 | 13 | /* 14 | * Copyright (C) 2015 Pierry Borges 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | */ 28 | public class SimpleToast { 29 | 30 | private static LayoutInflater mInflater; 31 | private static Toast mToast; 32 | private static View mView; 33 | 34 | public static void ok(Context context, String msg){ 35 | ok(context,msg,Toast.LENGTH_SHORT); 36 | } 37 | 38 | public static void ok(Context context, String msg, int duration) { 39 | mInflater = LayoutInflater.from(context); 40 | mView = mInflater.inflate(R.layout.toast_ok, null); 41 | initSetButtonMsg(msg); 42 | mToast = new Toast(context); 43 | mToast.setView(mView); 44 | mToast.setDuration(duration); 45 | mToast.show(); 46 | } 47 | 48 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 49 | public static void ok(Context context, String msg, 50 | String icon) { 51 | mInflater = LayoutInflater.from(context); 52 | mView = mInflater.inflate(R.layout.toast_ok_icon, null); 53 | initSetButtonMsg(msg); 54 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 55 | img.setText(icon); 56 | img.setTextSize(20); 57 | mToast = new Toast(context); 58 | mToast.setView(mView); 59 | mToast.setDuration(Toast.LENGTH_SHORT); 60 | mToast.show(); 61 | } 62 | 63 | public static void ok(Context context, String msg, String icon, int time){ 64 | mInflater = LayoutInflater.from(context); 65 | if (!icon.equals("")) { 66 | mView = mInflater.inflate(R.layout.toast_ok_icon, null); 67 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 68 | img.setText(icon); 69 | img.setTextSize(20); 70 | } else { 71 | mView = mInflater.inflate(R.layout.toast_ok, null); 72 | } 73 | initSetButtonMsg(msg); 74 | mToast = new Toast(context); 75 | mToast.setView(mView); 76 | mToast.setDuration(Toast.LENGTH_LONG); 77 | mToast.show(); 78 | if (time != 0) { 79 | Handler handler = new Handler(); 80 | handler.postDelayed(new Runnable() { 81 | @Override public void run() { 82 | mToast.cancel(); 83 | } 84 | }, time); 85 | } 86 | } 87 | 88 | public static void error(Context context, String msg) { 89 | error(context,msg,Toast.LENGTH_SHORT); 90 | } 91 | 92 | 93 | public static void error(Context context, String msg, int duration) { 94 | mInflater = LayoutInflater.from(context); 95 | mView = mInflater.inflate(R.layout.toast_error, null); 96 | initSetButtonMsg(msg); 97 | mToast = new Toast(context); 98 | mToast.setView(mView); 99 | mToast.setDuration(duration); 100 | mToast.show(); 101 | } 102 | 103 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg, String icon){ 104 | mInflater = LayoutInflater.from(context); 105 | if (!icon.equals("")) { 106 | mView = mInflater.inflate(R.layout.toast_error_icon, null); 107 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 108 | img.setText(icon); 109 | img.setTextSize(20); 110 | } else { 111 | mView = mInflater.inflate(R.layout.toast_error, null); 112 | } 113 | initSetButtonMsg(msg); 114 | mToast = new Toast(context); 115 | mToast.setView(mView); 116 | mToast.setDuration(Toast.LENGTH_SHORT); 117 | mToast.show(); 118 | } 119 | 120 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg, String icon, int time){ 121 | mInflater = LayoutInflater.from(context); 122 | if (!icon.equals("")) { 123 | mView = mInflater.inflate(R.layout.toast_error_icon, null); 124 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 125 | img.setText(icon); 126 | img.setTextSize(20); 127 | } else { 128 | mView = mInflater.inflate(R.layout.toast_error, null); 129 | } 130 | initSetButtonMsg(msg); 131 | mToast = new Toast(context); 132 | mToast.setView(mView); 133 | mToast.setDuration(Toast.LENGTH_LONG); 134 | mToast.show(); 135 | if (time != 0) { 136 | Handler handler = new Handler(); 137 | handler.postDelayed(new Runnable() { 138 | @Override public void run() { 139 | mToast.cancel(); 140 | } 141 | }, time); 142 | } 143 | } 144 | 145 | public static void info(Context context, String msg) { 146 | info(context,msg,Toast.LENGTH_SHORT); 147 | } 148 | 149 | public static void info(Context context, String msg, int duration) { 150 | mInflater = LayoutInflater.from(context); 151 | mView = mInflater.inflate(R.layout.toast_info, null); 152 | initSetButtonMsg(msg); 153 | mToast = new Toast(context); 154 | mToast.setView(mView); 155 | mToast.setDuration(duration); 156 | mToast.show(); 157 | } 158 | 159 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg, String icon){ 160 | mInflater = LayoutInflater.from(context); 161 | if (!icon.equals("")) { 162 | mView = mInflater.inflate(R.layout.toast_info_icon, null); 163 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 164 | img.setText(icon); 165 | img.setTextSize(20); 166 | } else { 167 | mView = mInflater.inflate(R.layout.toast_info, null); 168 | } 169 | initSetButtonMsg(msg); 170 | mToast = new Toast(context); 171 | mToast.setView(mView); 172 | mToast.setDuration(Toast.LENGTH_SHORT); 173 | mToast.show(); 174 | } 175 | 176 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg, String icon, int time){ 177 | mInflater = LayoutInflater.from(context); 178 | if (!icon.equals("")) { 179 | mView = mInflater.inflate(R.layout.toast_info_icon, null); 180 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 181 | img.setText(icon); 182 | img.setTextSize(20); 183 | } else { 184 | mView = mInflater.inflate(R.layout.toast_info, null); 185 | } 186 | initSetButtonMsg(msg); 187 | mToast = new Toast(context); 188 | mToast.setView(mView); 189 | mToast.setDuration(Toast.LENGTH_LONG); 190 | mToast.show(); 191 | if (time != 0) { 192 | Handler handler = new Handler(); 193 | handler.postDelayed(new Runnable() { 194 | @Override public void run() { 195 | mToast.cancel(); 196 | } 197 | }, time); 198 | } 199 | } 200 | 201 | public static void muted(Context context, String msg) { 202 | muted(context,msg,Toast.LENGTH_SHORT); 203 | } 204 | 205 | public static void muted(Context context, String msg, int duration) { 206 | mInflater = LayoutInflater.from(context); 207 | mView = mInflater.inflate(R.layout.toast_muted, null); 208 | initSetButtonMsg(msg); 209 | mToast = new Toast(context); 210 | mToast.setView(mView); 211 | mToast.setDuration(duration); 212 | mToast.show(); 213 | } 214 | 215 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void muted(Context context, String msg, String icon){ 216 | mInflater = LayoutInflater.from(context); 217 | if (!icon.equals("")) { 218 | mView = mInflater.inflate(R.layout.toast_muted_icon, null); 219 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 220 | img.setText(icon); 221 | img.setTextSize(20); 222 | } else { 223 | mView = mInflater.inflate(R.layout.toast_muted, null); 224 | } 225 | initSetButtonMsg(msg); 226 | mToast = new Toast(context); 227 | mToast.setView(mView); 228 | mToast.setDuration(Toast.LENGTH_SHORT); 229 | mToast.show(); 230 | } 231 | 232 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void muted(Context context, String msg, String icon, int time){ 233 | mInflater = LayoutInflater.from(context); 234 | if (!icon.equals("")) { 235 | mView = mInflater.inflate(R.layout.toast_muted_icon, null); 236 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 237 | img.setText(icon); 238 | img.setTextSize(20); 239 | } else { 240 | mView = mInflater.inflate(R.layout.toast_muted, null); 241 | } 242 | initSetButtonMsg(msg); 243 | mToast = new Toast(context); 244 | mToast.setView(mView); 245 | mToast.setDuration(Toast.LENGTH_LONG); 246 | mToast.show(); 247 | if (time != 0) { 248 | Handler handler = new Handler(); 249 | handler.postDelayed(new Runnable() { 250 | @Override public void run() { 251 | mToast.cancel(); 252 | } 253 | }, time); 254 | } 255 | } 256 | 257 | public static void warning(Context context, String msg) { 258 | warning(context,msg,Toast.LENGTH_SHORT); 259 | } 260 | 261 | public static void warning(Context context, String msg, int duration) { 262 | mInflater = LayoutInflater.from(context); 263 | mView = mInflater.inflate(R.layout.toast_warning, null); 264 | initSetButtonMsg(msg); 265 | mToast = new Toast(context); 266 | mToast.setView(mView); 267 | mToast.setDuration(duration); 268 | mToast.show(); 269 | } 270 | 271 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void warning(Context context, String msg, String icon){ 272 | mInflater = LayoutInflater.from(context); 273 | if (!icon.equals("")) { 274 | mView = mInflater.inflate(R.layout.toast_warning_icon, null); 275 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 276 | img.setText(icon); 277 | img.setTextSize(20); 278 | } else { 279 | mView = mInflater.inflate(R.layout.toast_warning, null); 280 | } 281 | initSetButtonMsg(msg); 282 | mToast = new Toast(context); 283 | mToast.setView(mView); 284 | mToast.setDuration(Toast.LENGTH_SHORT); 285 | mToast.show(); 286 | } 287 | 288 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void warning(Context context, String msg, String icon, int time){ 289 | mInflater = LayoutInflater.from(context); 290 | if (!icon.equals("")) { 291 | mView = mInflater.inflate(R.layout.toast_warning_icon, null); 292 | IconTextView img = (IconTextView) mView.findViewById(R.id.img); 293 | img.setText(icon); 294 | img.setTextSize(20); 295 | } else { 296 | mView = mInflater.inflate(R.layout.toast_warning, null); 297 | } 298 | initSetButtonMsg(msg); 299 | mToast = new Toast(context); 300 | mToast.setView(mView); 301 | mToast.setDuration(Toast.LENGTH_LONG); 302 | mToast.show(); 303 | if (time != 0) { 304 | Handler handler = new Handler(); 305 | handler.postDelayed(new Runnable() { 306 | @Override public void run() { 307 | mToast.cancel(); 308 | } 309 | }, time); 310 | } 311 | } 312 | 313 | private static Button initSetButtonMsg(String msg) { 314 | Button mButton = (Button) mView.findViewById(R.id.button); 315 | mButton.setText(msg); 316 | return mButton; 317 | } 318 | 319 | public static void CancelCurrentToast(){ 320 | if (mToast != null) 321 | mToast.cancel(); 322 | } 323 | } 324 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-hdpi/cancel.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-hdpi/info.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-hdpi/ok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-mdpi/cancel.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-mdpi/info.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-mdpi/ok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xhdpi/cancel.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xhdpi/info.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xhdpi/ok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xxhdpi/cancel.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xxhdpi/info.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xxhdpi/ok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xxxhdpi/cancel.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xxxhdpi/info.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pierry/SimpleToast/4f2c367d9d0ce852a90db78e62bb9b44d63c845a/app/src/main/res/drawable-xxxhdpi/ok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_border_back_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_border_back_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_border_back_green.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_border_back_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_border_back_yellow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toast_error.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 17 | 18 |