21 |
22 |
--------------------------------------------------------------------------------
/floatingsnackbar/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.2"
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 29
11 | versionCode 3
12 | versionName "1.0.1"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 |
30 | implementation 'androidx.appcompat:appcompat:1.1.0'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'androidx.test:runner:1.2.0'
33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
34 |
35 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
36 |
37 | implementation 'com.google.android.material:material:1.0.0'
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Ankush Yerawar
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/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 |
21 |
--------------------------------------------------------------------------------
/floatingsnackbar/src/main/java/com/ankushyerwar/floatingsnackbar/utils/Type.java:
--------------------------------------------------------------------------------
1 | package com.ankushyerwar.floatingsnackbar.utils;
2 |
3 | import android.graphics.Color;
4 |
5 | import com.ankushyerwar.floatingsnackbar.R;
6 | import com.ankushyerwar.floatingsnackbar.definations.DrawableRes;
7 |
8 | public enum Type {
9 |
10 | DEFAULT(R.drawable.ic_default, R.drawable.bg_default),
11 | SUCCESS(R.drawable.ic_success, R.drawable.bg_success),
12 | ERROR(R.drawable.ic_error, R.drawable.bg_error),
13 | WARNING(R.drawable.ic_info, R.drawable.bg_warning),
14 | INFO(R.drawable.ic_info, R.drawable.bg_info);
15 |
16 | private int iconResId;
17 | private int backResId;
18 | private int textColor = Color.WHITE;
19 | private int backColor = Color.DKGRAY;
20 |
21 | Type(@DrawableRes int iconResId, @DrawableRes int backResId) {
22 | this.iconResId = iconResId;
23 | this.backResId = backResId;
24 | }
25 |
26 | public int getBackColor() {
27 | return backColor;
28 | }
29 |
30 | public int getTextColor() {
31 | return textColor;
32 | }
33 |
34 | public int getIcon() {
35 | return iconResId;
36 | }
37 |
38 | public int getBackground() {
39 | return backResId;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | ext.versionMajor = 1
4 | ext.versionMinor = 0
5 | ext.versionPatch = 3
6 | ext.versionClassifier = null
7 | ext.isSnapshot = false
8 | ext.minimumSdkVersion = 21
9 |
10 | android {
11 | compileSdkVersion 29
12 | defaultConfig {
13 | applicationId "com.rexaware.uppwd.snackbardemo"
14 | minSdkVersion 21
15 | targetSdkVersion 29
16 | versionCode generateVersionCode()
17 | versionName generateVersionName()
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | private Integer generateVersionCode() {
30 | return ext.minimumSdkVersion * 10000000 + ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch
31 | }
32 |
33 | private String generateVersionName() {
34 | String versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
35 | if (ext.versionClassifier == null && ext.isSnapshot) {
36 | ext.versionClassifier = "FloatingSnackbar"
37 | }
38 |
39 | if (ext.versionClassifier != null) {
40 | versionName += "-" + ext.versionClassifier
41 | }
42 | return versionName
43 | }
44 |
45 | dependencies {
46 | implementation fileTree(dir: 'libs', include: ['*.jar'])
47 |
48 | implementation 'androidx.appcompat:appcompat:1.2.0'
49 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
50 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
51 | testImplementation 'junit:junit:4.13'
52 | androidTestImplementation 'androidx.test:runner:1.2.0'
53 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
54 | implementation 'com.google.android.material:material:1.2.0'
55 |
56 | implementation project(":floatingsnackbar")
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://jitpack.io/#ankushyerawar/FloatingSnackBar) [](https://opensource.org/licenses/MIT)
2 | # FloatingSnackBar
3 | Gmail Style Floating Snackbar with Custom Functionality.
4 |
5 |
6 | # Prerequisites
7 |
8 | Add this in your root `build.gradle` file (not your module `build.gradle` file) :
9 |
10 | allprojects {
11 | repositories {
12 | ...
13 | maven { url 'https://jitpack.io' }
14 | }
15 | }
16 |
17 | # Dependency
18 |
19 | Add this to your module's `build.gradle` file (make sure the version matches the JitPack badge above):
20 |
21 | dependencies {
22 | implementation 'com.google.android.material:material:1.2.0'
23 | implementation 'com.github.ankushyerawar:FloatingSnackBar:1.0.3'
24 | }
25 |
26 | # Versions
27 |
28 | **Version 0.1.0**
29 |
30 | First Release.
31 |
32 | **Version 1.0.0**
33 |
34 | Added a New Functionality to add icon to Normal Snackbar.
35 |
36 | **Version 1.0.1**
37 |
38 | Now you can change Icons of Default SnackBar Methods like success, error by passing Resource Id.
39 |
40 | **Version 1.0.2**
41 |
42 | Some small changes and Error handling.
43 |
44 | **Version 1.0.3**
45 |
46 | Now supports material design librery 1.1.0 and 1.2.0.
47 | All new featrue to support text RTL.
48 |
49 | # Sneak Peek
50 |
51 | 
52 |
53 | # Usage
54 |
55 | Each method always returns a `Snackbar` object, so you can customize the `Snackbar` much more. **DON'T FORGET THE `show()` METHOD!**
56 |
57 | To display an error Snackbar:
58 | ```
59 | SnackBar.error(getView(),R.string.app_name, SnackBar.LENGTH_LONG).show();
60 | ```
61 |
62 | To display a success Snackbar:
63 | ```
64 | SnackBar.success(view, R.string.app_name, SnackBar.LENGTH_LONG).show();
65 | ```
66 |
67 | To display an info Snackbar:
68 | ```
69 | SnackBar.info(getView(),R.string.app_name, SnackBar.LENGTH_LONG).show();
70 | ```
71 |
72 | To display a warning Snackbar:
73 | ```
74 | SnackBar.warning(getView(),R.string.app_name, SnackBar.LENGTH_LONG).show();
75 | ```
76 | To display the usual Snackbar:
77 | ```
78 | SnackBar.normal(getView(),R.string.app_name, SnackBar.LENGTH_LONG).show();
79 | ```
80 | To display the usual Snackbar with icon:
81 | ```
82 | SnackBar.normal(getView(),"Snackbar with icon", SnackBar.LENGTH_LONG, R.drawable.ic_normal).show();
83 | ```
84 | You can also create your custom Snackbar with the custom() method:
85 | ```
86 | SnackBar.custom(view, R.string.app_name, SnackBar.LENGTH_LONG,R.drawable.ic_custom, Color.DKGRAY, Color.WHITE,true).show();
87 | ```
88 | Here, This method also supports text rtl.
89 |
90 | # Extra
91 |
92 | **There are variants of each method, feel free to explore this library.**
93 |
94 | # Pull Request
95 |
96 | Have some new ideas or found a `bug`? Do not hesitate to open an `issue` and make a `pull request`.
97 |
98 | # License
99 |
100 | This library is under MIT License. See the [License](https://github.com/ankushyerawar/FloatingSnackBar/blob/master/LICENSE) file for more info.
101 |
102 | # Follow Me On
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_blank.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
21 |
22 |
33 |
34 |
45 |
46 |
57 |
58 |
69 |
70 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ankushyerawar/floatingsnackbar/BlankFragment.java:
--------------------------------------------------------------------------------
1 | package com.ankushyerawar.floatingsnackbar;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import androidx.fragment.app.Fragment;
9 |
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.Button;
14 |
15 | import com.ankushyerwar.floatingsnackbar.SnackBar;
16 |
17 | public class BlankFragment extends Fragment {
18 |
19 | public BlankFragment() {
20 | // Required empty public constructor
21 | }
22 |
23 | static BlankFragment newInstance() {
24 | return new BlankFragment();
25 | }
26 |
27 |
28 | @Override
29 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
30 | Bundle savedInstanceState) {
31 | // Inflate the layout for this fragment
32 | return inflater.inflate(R.layout.fragment_blank, container, false);
33 | }
34 |
35 | @Override
36 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
37 | super.onViewCreated(view, savedInstanceState);
38 |
39 | Button mBtnSuccess = view.findViewById(R.id.btnSuccess);
40 | Button mBtnError = view.findViewById(R.id.btnError);
41 | Button mBtnWarning = view.findViewById(R.id.btnWarning);
42 | Button mBtnInfo = view.findViewById(R.id.btnInfo);
43 | Button mBtnNormal = view.findViewById(R.id.btnNormal);
44 | Button mBtnCustom = view.findViewById(R.id.btnCustom);
45 |
46 | mBtnSuccess.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View view) {
49 |
50 | //Here you can pass String id
51 | SnackBar.success(view, R.string.app_name, SnackBar.LENGTH_LONG).show();
52 |
53 | //Here you can pass your own icon
54 | //SnackBar.success(view, R.string.app_name, SnackBar.LENGTH_LONG, R.drawable.ic_normal).show();
55 |
56 | //Here you can pass String text
57 | //SnackBar.success(view, "Sting Success", SnackBar.LENGTH_LONG).show();
58 |
59 | //Here you can specify if you want SnackBar without icon
60 | //SnackBar.success(view, "Sting Success", SnackBar.LENGTH_LONG, false).show();
61 |
62 | }
63 | });
64 |
65 | mBtnError.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View view) {
68 |
69 | //Here you can pass String id
70 | SnackBar.error(view, R.string.app_name, SnackBar.LENGTH_LONG).show();
71 |
72 | //Here you can pass your own icon
73 | //SnackBar.error(view, R.string.app_name, SnackBar.LENGTH_LONG, R.drawable.ic_normal).show();
74 |
75 | //Here you can pass String text
76 | //SnackBar.error(view,"String Error", SnackBar.LENGTH_LONG).show();
77 |
78 | //Here you can specify if you want snackbar without icon
79 | //SnackBar.error(view,"String Error", SnackBar.LENGTH_LONG,false).show();
80 |
81 | }
82 | });
83 |
84 | mBtnWarning.setOnClickListener(new View.OnClickListener() {
85 | @Override
86 | public void onClick(View view) {
87 |
88 | //Here you can pass String id
89 | SnackBar.warning(view, R.string.app_name, SnackBar.LENGTH_LONG).show();
90 |
91 | //Here you can pass your own icon
92 | //SnackBar.warning(view, R.string.app_name, SnackBar.LENGTH_LONG, R.drawable.ic_normal).show();
93 |
94 | //Here you can pass String text
95 | //SnackBar.warning(view,"String Warning", SnackBar.LENGTH_LONG).show();
96 |
97 | //Here you can specify if you want snackbar without icon
98 | //SnackBar.warning(view,"String Warning", SnackBar.LENGTH_LONG, false).show();
99 |
100 | }
101 | });
102 |
103 | mBtnInfo.setOnClickListener(new View.OnClickListener() {
104 | @Override
105 | public void onClick(View view) {
106 |
107 | //Here you can pass String id
108 | SnackBar.info(view, R.string.app_name, SnackBar.LENGTH_LONG).show();
109 |
110 | //Here you can pass your own icon
111 | //SnackBar.info(view, R.string.app_name, SnackBar.LENGTH_LONG, R.drawable.ic_normal).show();
112 |
113 | //Here you can pass String text
114 | //SnackBar.info(view,"String Info", SnackBar.LENGTH_LONG).show();
115 |
116 | //Here you can specify if you want snackbar without icon
117 | //SnackBar.info(view,R.string.app_name, SnackBar.LENGTH_LONG,false).show();
118 |
119 | }
120 | });
121 |
122 | mBtnNormal.setOnClickListener(new View.OnClickListener() {
123 | @Override
124 | public void onClick(View view) {
125 |
126 | //Here you can pass String id
127 | SnackBar.normal(view,R.string.app_name, SnackBar.LENGTH_LONG).show();
128 |
129 | //Here you can pass String text
130 | //SnackBar.normal(view,"String Normal", SnackBar.LENGTH_LONG).show();
131 |
132 | //Here you can pass your icon
133 | //SnackBar.normal(view, R.string.app_name, SnackBar.LENGTH_LONG, R.drawable.ic_normal).show();
134 |
135 | }
136 | });
137 |
138 | mBtnCustom.setOnClickListener(new View.OnClickListener() {
139 | @Override
140 | public void onClick(View view) {
141 |
142 | //Here you can pass String id
143 | SnackBar.custom(view, R.string.app_name, SnackBar.LENGTH_LONG,
144 | R.drawable.ic_custom, Color.DKGRAY, Color.WHITE,true).show();
145 |
146 | //Here you can pass String text
147 | /*SnackBar.custom(view, "String Custom", SnackBar.LENGTH_LONG,
148 | R.drawable.ic_custom, Color.DKGRAY, Color.WHITE).show();*/
149 |
150 | }
151 | });
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/floatingsnackbar/src/main/java/com/ankushyerwar/floatingsnackbar/SnackBar.java:
--------------------------------------------------------------------------------
1 | package com.ankushyerwar.floatingsnackbar;
2 |
3 | import android.view.View;
4 |
5 | import androidx.annotation.NonNull;
6 |
7 | import com.ankushyerwar.floatingsnackbar.definations.ColorInt;
8 | import com.ankushyerwar.floatingsnackbar.definations.DrawableRes;
9 | import com.ankushyerwar.floatingsnackbar.definations.Duration;
10 | import com.ankushyerwar.floatingsnackbar.definations.StringRes;
11 | import com.ankushyerwar.floatingsnackbar.utils.Type;
12 | import com.google.android.material.snackbar.Snackbar;
13 |
14 | import static com.ankushyerwar.floatingsnackbar.customization.Customize.customIcon;
15 | import static com.ankushyerwar.floatingsnackbar.customization.Customize.defaultRes;
16 | import static com.ankushyerwar.floatingsnackbar.customization.Customize.defaultChar;
17 | import static com.ankushyerwar.floatingsnackbar.customization.Customize.customChar;
18 | import static com.ankushyerwar.floatingsnackbar.customization.Customize.customRes;
19 |
20 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.withIcon;
21 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.withNoIcon;
22 |
23 |
24 | public class SnackBar {
25 |
26 | public static final int LENGTH_INDEFINITE = -2;
27 | public static final int LENGTH_SHORT = -1;
28 | public static final int LENGTH_LONG = 0;
29 |
30 | @NonNull
31 | public static Snackbar success(@NonNull View view, CharSequence text, @Duration int length, boolean withIcon) {
32 | return defaultChar(view, text, length, Type.SUCCESS, withIcon);
33 | }
34 |
35 | @NonNull
36 | public static Snackbar success(@NonNull View view, @StringRes int resId, @Duration int length, boolean withIcon) {
37 | return defaultRes(view, resId, length, Type.SUCCESS, withIcon);
38 | }
39 |
40 | @NonNull
41 | public static Snackbar success(@NonNull View view, CharSequence text, @Duration int length,
42 | @DrawableRes int iconId) {
43 | return customIcon(view, text, length, Type.SUCCESS, iconId);
44 | }
45 |
46 | @NonNull
47 | public static Snackbar success(@NonNull View view, @StringRes int resId, @Duration int length,
48 | @DrawableRes int iconId) {
49 | return customIcon(view, resId, length, Type.SUCCESS, iconId);
50 | }
51 |
52 | @NonNull
53 | public static Snackbar success(@NonNull View view, CharSequence text, @Duration int length) {
54 | return defaultChar(view, text, length, Type.SUCCESS, withIcon);
55 | }
56 |
57 | @NonNull
58 | public static Snackbar success(@NonNull View view, @StringRes int resId, @Duration int length) {
59 | return defaultRes(view, resId, length, Type.SUCCESS, withIcon);
60 | }
61 |
62 | @NonNull
63 | public static Snackbar error(@NonNull View view, CharSequence text, @Duration int length, boolean withIcon) {
64 | return defaultChar(view, text, length, Type.ERROR, withIcon);
65 | }
66 |
67 | @NonNull
68 | public static Snackbar error(@NonNull View view, @StringRes int resId, @Duration int length, boolean withIcon) {
69 | return defaultRes(view, resId, length, Type.ERROR, withIcon);
70 | }
71 |
72 | @NonNull
73 | public static Snackbar error(@NonNull View view, CharSequence text, @Duration int length,
74 | @DrawableRes int iconId) {
75 | return customIcon(view, text, length, Type.ERROR, iconId);
76 | }
77 |
78 | @NonNull
79 | public static Snackbar error(@NonNull View view, @StringRes int resId, @Duration int length,
80 | @DrawableRes int iconId) {
81 | return customIcon(view, resId, length, Type.ERROR, iconId);
82 | }
83 |
84 | @NonNull
85 | public static Snackbar error(@NonNull View view, CharSequence text, @Duration int length) {
86 | return defaultChar(view, text, length, Type.ERROR, withIcon);
87 | }
88 |
89 | @NonNull
90 | public static Snackbar error(@NonNull View view, @StringRes int resId, @Duration int length) {
91 | return defaultRes(view, resId, length, Type.ERROR, withIcon);
92 | }
93 |
94 | @NonNull
95 | public static Snackbar warning(@NonNull View view, CharSequence text, @Duration int length, boolean withIcon) {
96 | return defaultChar(view, text, length, Type.WARNING, withIcon);
97 | }
98 |
99 | @NonNull
100 | public static Snackbar warning(@NonNull View view, @StringRes int resId, @Duration int length, boolean withIcon) {
101 | return defaultRes(view, resId, length, Type.WARNING, withIcon);
102 | }
103 |
104 | @NonNull
105 | public static Snackbar warning(@NonNull View view, CharSequence text, @Duration int length,
106 | @DrawableRes int iconId) {
107 | return customIcon(view, text, length, Type.WARNING, iconId);
108 | }
109 |
110 | @NonNull
111 | public static Snackbar warning(@NonNull View view, @StringRes int resId, @Duration int length,
112 | @DrawableRes int iconId) {
113 | return customIcon(view, resId, length, Type.WARNING, iconId);
114 | }
115 |
116 |
117 | @NonNull
118 | public static Snackbar warning(@NonNull View view, CharSequence text, @Duration int length) {
119 | return defaultChar(view, text, length, Type.WARNING, withIcon);
120 | }
121 |
122 | @NonNull
123 | public static Snackbar warning(@NonNull View view, @StringRes int resId, @Duration int length) {
124 | return defaultRes(view, resId, length, Type.WARNING, withIcon);
125 | }
126 |
127 | @NonNull
128 | public static Snackbar info(@NonNull View view, CharSequence text, @Duration int length) {
129 | return defaultChar(view, text, length, Type.INFO, withIcon);
130 | }
131 |
132 | @NonNull
133 | public static Snackbar info(@NonNull View view, @StringRes int resId, @Duration int length) {
134 | return defaultRes(view, resId, length, Type.INFO, withIcon);
135 | }
136 |
137 | @NonNull
138 | public static Snackbar info(@NonNull View view, CharSequence text, @Duration int length,
139 | @DrawableRes int iconId) {
140 | return customIcon(view, text, length, Type.INFO, iconId);
141 | }
142 |
143 | @NonNull
144 | public static Snackbar info(@NonNull View view, @StringRes int resId, @Duration int length,
145 | @DrawableRes int iconId) {
146 | return customIcon(view, resId, length, Type.INFO, iconId);
147 | }
148 |
149 | @NonNull
150 | public static Snackbar info(@NonNull View view, CharSequence text, @Duration int length, boolean withIcon) {
151 | return defaultChar(view, text, length, Type.INFO, withIcon);
152 | }
153 |
154 |
155 | @NonNull
156 | public static Snackbar info(@NonNull View view, @StringRes int resId, @Duration int length, boolean withIcon) {
157 | return defaultRes(view, resId, length, Type.INFO, withIcon);
158 | }
159 |
160 | @NonNull
161 | public static Snackbar normal(@NonNull View view, CharSequence text, @Duration int length) {
162 | return defaultChar(view, text, length, Type.DEFAULT, withNoIcon);
163 | }
164 |
165 | @NonNull
166 | public static Snackbar normal(@NonNull View view, @StringRes int resId, @Duration int length) {
167 | return defaultRes(view, resId, length, Type.DEFAULT, withNoIcon);
168 | }
169 |
170 | @NonNull
171 | public static Snackbar normal(@NonNull View view, CharSequence text, @Duration int length,
172 | @DrawableRes int iconId, boolean supportsRTL) {
173 | return customChar(iconId, view, text, length, Type.DEFAULT.getBackColor(), Type.DEFAULT.getTextColor(), supportsRTL);
174 | }
175 |
176 | @NonNull
177 | public static Snackbar normal(@NonNull View view, @StringRes int resId, @Duration int length,
178 | @DrawableRes int iconId, boolean supportsRTL) {
179 | return customRes(iconId, view, resId, length, Type.DEFAULT.getBackColor(), Type.DEFAULT.getTextColor(), supportsRTL);
180 | }
181 |
182 | @NonNull
183 | public static Snackbar custom(@NonNull View view, CharSequence text, @Duration int length,
184 | @DrawableRes int iconId, @ColorInt int backgroundColor,
185 | @ColorInt int textColor, boolean supportsRTL) {
186 | return customChar(iconId, view, text, length, backgroundColor, textColor, supportsRTL);
187 | }
188 |
189 | @NonNull
190 | public static Snackbar custom(@NonNull View view, @StringRes int resId, @Duration int length,
191 | @DrawableRes int iconId, @ColorInt int backgroundColor,
192 | @ColorInt int textColor, boolean supportsRTL) {
193 | return customRes(iconId, view, resId, length, backgroundColor, textColor, supportsRTL);
194 | }
195 |
196 | }
--------------------------------------------------------------------------------
/floatingsnackbar/src/main/java/com/ankushyerwar/floatingsnackbar/customization/Customize.java:
--------------------------------------------------------------------------------
1 | package com.ankushyerwar.floatingsnackbar.customization;
2 |
3 | import android.graphics.Rect;
4 | import android.graphics.drawable.GradientDrawable;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import androidx.annotation.NonNull;
11 |
12 | import com.ankushyerwar.floatingsnackbar.R;
13 | import com.ankushyerwar.floatingsnackbar.definations.ColorInt;
14 | import com.ankushyerwar.floatingsnackbar.definations.DrawableRes;
15 | import com.ankushyerwar.floatingsnackbar.definations.Duration;
16 | import com.ankushyerwar.floatingsnackbar.definations.StringRes;
17 | import com.ankushyerwar.floatingsnackbar.utils.Type;
18 | import com.google.android.material.snackbar.Snackbar;
19 |
20 | import java.lang.reflect.Field;
21 | import java.util.Objects;
22 |
23 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.TAG;
24 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.corner;
25 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.margin;
26 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.maxLines;
27 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.noVal;
28 | import static com.ankushyerwar.floatingsnackbar.utils.Constants.textSize;
29 |
30 | /** Last Updated: 04\12\2019
31 | * @author: Ankush Yerawar
32 | */
33 |
34 | public class Customize {
35 |
36 | private static Snackbar makeSnack(@NonNull View view, @StringRes int resId, @Duration int length) {
37 | return Snackbar.make(view, resId, length);
38 | }
39 |
40 | private static Snackbar makeSnack(@NonNull View view, CharSequence text, @Duration int length) {
41 | return Snackbar.make(view, text, length);
42 | }
43 |
44 | public static Snackbar defaultRes(@NonNull View view, @StringRes int resId, @Duration int length,
45 | Type type, boolean withIcon) {
46 |
47 | return modify(makeSnack(view, resId, length), type, withIcon);
48 | }
49 |
50 | public static Snackbar defaultChar(@NonNull View view, CharSequence text, @Duration int length,
51 | Type type, boolean withIcon) {
52 |
53 | return modify(makeSnack(view, text, length), type, withIcon);
54 | }
55 |
56 | public static Snackbar customIcon(@NonNull View view, CharSequence text, @Duration int length,
57 | Type type, @DrawableRes int iconId) {
58 |
59 | return modifyIcon(makeSnack(view, text, length),type,iconId);
60 | }
61 |
62 | public static Snackbar customIcon(@NonNull View view, @StringRes int resId, @Duration int length,
63 | Type type, @DrawableRes int iconId) {
64 |
65 | return modifyIcon(makeSnack(view, resId, length),type,iconId);
66 | }
67 |
68 | public static Snackbar customChar(@DrawableRes int iconId, @NonNull View view, CharSequence text,
69 | @Duration int length, @ColorInt int backgroundColor,
70 | @ColorInt int textColor, @NonNull boolean supportsRTL) {
71 |
72 | return customModify(makeSnack(view, text, length), iconId, textColor, backgroundColor, supportsRTL);
73 | }
74 |
75 | public static Snackbar customRes(@DrawableRes int iconId, @NonNull View view, @StringRes int resId,
76 | @Duration int length, @ColorInt int backgroundColor,
77 | @ColorInt int textColor, @NonNull boolean supportsRTL) {
78 |
79 | return customModify(makeSnack(view, resId, length), iconId, textColor, backgroundColor, supportsRTL);
80 | }
81 |
82 | private static Snackbar modify(Snackbar snackbar, Type type, boolean withIcon) {
83 | try {
84 |
85 | final View snackBarView = snackbar.getView();
86 |
87 | setTextStyle(snackBarView, type.getIcon(), withIcon);
88 |
89 | //snackBarView.setLayoutParams(setMargins(snackBarView));
90 | fixSnackBarMarginBottomBug(snackbar);
91 |
92 | snackBarView.setBackground(snackBarView.getContext().getDrawable(type.getBackground()));
93 |
94 | return snackbar;
95 |
96 | } catch (NullPointerException | ClassCastException exception) {
97 | Log.e(TAG,"Exception" + exception.getMessage());
98 | }
99 | return snackbar;
100 | }
101 |
102 | private static Snackbar modifyIcon(Snackbar snackbar, Type type, @DrawableRes int iconId) {
103 | try {
104 |
105 | final View snackBarView = snackbar.getView();
106 |
107 | setTextStyle(snackBarView, iconId, true);
108 |
109 | //snackBarView.setLayoutParams(setMargins(snackBarView));
110 | fixSnackBarMarginBottomBug(snackbar);
111 |
112 | snackBarView.setBackground(snackBarView.getContext().getDrawable(type.getBackground()));
113 |
114 | return snackbar;
115 |
116 | } catch (NullPointerException | ClassCastException exception) {
117 | Log.e(TAG,"Exception" + exception.getMessage());
118 | }
119 | return snackbar;
120 | }
121 |
122 | private static Snackbar customModify(Snackbar snackbar, @DrawableRes int iconId, @ColorInt int textColor,
123 | @ColorInt int backgroundColor, boolean supportsRTL) {
124 | try {
125 |
126 | final View snackBarView = snackbar.getView();
127 |
128 | setCustomTextStyle(snackBarView, iconId, textColor, supportsRTL);
129 |
130 | //snackBarView.setLayoutParams(setMargins(snackBarView));
131 | fixSnackBarMarginBottomBug(snackbar);
132 |
133 | snackBarView.setBackground(setBackground(backgroundColor));
134 |
135 | return snackbar;
136 |
137 | } catch (NullPointerException | ClassCastException exception) {
138 | Log.e(TAG,"Exception" + exception.getMessage());
139 | }
140 | return snackbar;
141 | }
142 |
143 | private static void setTextStyle(View view, @DrawableRes int resId, boolean withIcon) {
144 | TextView textView = view.findViewById(R.id.snackbar_text);
145 | textView.setTextSize(textSize);
146 | textView.setMaxLines(maxLines);
147 | if (withIcon) {
148 | textView.setCompoundDrawablesWithIntrinsicBounds(resId, noVal, noVal, noVal);
149 | textView.setCompoundDrawablePadding(textView.getResources().getDimensionPixelOffset(R.dimen.icon_padding));
150 | }
151 | }
152 |
153 | private static void setCustomTextStyle(View view, @DrawableRes int resId, @ColorInt int textColor, boolean supportsRTL) {
154 | TextView textView = view.findViewById(R.id.snackbar_text);
155 | textView.setTextSize(textSize);
156 | textView.setMaxLines(maxLines);
157 | textView.setTextColor(textColor);
158 | textView.setCompoundDrawablePadding(textView.getResources().getDimensionPixelOffset(R.dimen.icon_padding));
159 | if (supportsRTL) {
160 | textView.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
161 | textView.setCompoundDrawablesWithIntrinsicBounds(noVal, noVal, resId, noVal);
162 | } else {
163 | textView.setCompoundDrawablesWithIntrinsicBounds(resId, noVal, noVal, noVal);
164 | }
165 | }
166 |
167 | /*private static ViewGroup.MarginLayoutParams setMargins(View view) {
168 | ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams)
169 | view.getLayoutParams();
170 |
171 | marginLayoutParams.setMargins(marginLayoutParams.leftMargin + margin,
172 | marginLayoutParams.topMargin, marginLayoutParams.rightMargin + margin,
173 | marginLayoutParams.bottomMargin + margin);
174 |
175 |
176 |
177 | return marginLayoutParams;
178 | }*/
179 |
180 | private static void fixSnackBarMarginBottomBug(Object snackBar) {
181 | try {
182 | Class snackbarClass = Class.forName("com.google.android.material.snackbar.Snackbar");
183 | Field originalMarginsField = Objects.requireNonNull(snackbarClass.getSuperclass()).getDeclaredField("originalMargins");
184 | originalMarginsField.setAccessible(true);
185 | Rect fixedOriginalMargins = new Rect();
186 | fixedOriginalMargins.left = margin;
187 | fixedOriginalMargins.right = margin;
188 | fixedOriginalMargins.bottom = margin;
189 | originalMarginsField.set(snackBar, fixedOriginalMargins);
190 | } catch (IllegalAccessException | NoSuchFieldException | ClassNotFoundException ignored) {
191 |
192 | }
193 | }
194 |
195 | private static GradientDrawable setBackground(int backgroundColor) {
196 | GradientDrawable shape = new GradientDrawable();
197 | shape.setShape(GradientDrawable.RECTANGLE);
198 | shape.setCornerRadius(corner);
199 | shape.setColor(backgroundColor);
200 | return shape;
201 | }
202 | }
203 |
--------------------------------------------------------------------------------