Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.inlacou:cookiebar3:2.0.3.1'
}
dependencies {
implementation("com.github.inlacou:cookiebar3:2.0.3.1")
}
<dependency>
<groupId>com.github.inlacou</groupId>
<artifactId>cookiebar3</artifactId>
<version>2.0.3.1</version>
</dependency>
libraryDependencies += "com.github.inlacou" % "cookiebar3" % "2.0.3.1"
:dependencies [[com.github.inlacou/cookiebar3 "2.0.3.1"]]
CookieBar is a lightweight library for showing a brief message at the top or bottom of the screen.<br/><br/>
Main differences from the original Cookiebar library are:
CookieBar.build(this@MainActivity)
.setTitle("TITLE") // String resources are also supported
.setMessage("MESSAGE") // i.e. R.string.message
.show() // Cookies are displayed at the top by default
CookieBar.build(MainActivity.this)
.setTitle("TITLE")
.setMessage("MESSAGE")
.setCookiePosition(CookieBar.BOTTOM) // Cookie will be displayed at the bottom
.show(); // of the screen
CookieBar.build(MainActivity.this)
.setTitle(R.string.title)
.setTitleColor(R.color.green)
.setIcon(R.drawable.icon)
.setIconAnimation(R.animator.spin)
.setMessage(R.string.message)
.setAction(R.string.action_text, new OnActionClickListener() {
@Override
public void onClick() {
// Do something
}
})
.setDuration(5000) // 5 seconds
.show();
CookieBar.build(MainActivity.this)
.setTitle(R.string.title)
.setMessage(R.string.message)
.setAnimationIn(android.R.anim.slide_in_left, android.R.anim.slide_in_left)
.setAnimationOut(android.R.anim.slide_out_right, android.R.anim.slide_out_right)
.show();
CookieBar.dismiss(MainActivity.this);
/* setCustomView - Set the layout resource for your custom cookie view.
setCustomViewInitializer - Called after layout inflation, for subview setup. */
CookieBar.build(MainActivity.this)
.setCustomView(R.layout.custom_cookie)
.setCustomViewInitializer(new CookieBar.CustomViewInitializer() {
@Override
public void initView(View view) {
Button btnNew = view.findViewById(R.id.custom_cookie_btn_new);
Button btnOpen = view.findViewById(R.id.custom_cookie_btn_open);
Button btnSave = view.findViewById(R.id.custom_cookie_btn_save);
View.OnClickListener btnListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
Button button = (Button) view;
button.setText(R.string.clicked);
}
};
btnNew.setOnClickListener(btnListener);
btnOpen.setOnClickListener(btnListener);
btnSave.setOnClickListener(btnListener);
}
})
.setAction("Close", new OnActionClickListener() {
@Override
public void onClick() {
CookieBar.dismiss(MainActivity.this);
}
})
.setTitle(R.string.title)
.setMessage(R.string.message)
.setEnableAutoDismiss(false) // Cookie will stay on display until manually dismissed
.setSwipeToDismiss(false) // Deny dismiss by swiping off the view
.setCookiePosition(CookieBar.BOTTOM)
.show();
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="cookieTitleColor">@color/default_title_color</item>
<item name="cookieMessageColor">@color/default_message_color</item>
<item name="cookieActionColor">@color/default_action_color</item>
<item name="cookieBackgroundColor">@color/default_bg_color</item>
<item name="cookiePadding">24dp</item>
<item name="cookieTitleSize">24sp</item>
<item name="cookieMessageSize">16sp</item>
<item name="cookieActionSize">18sp</item>
</style>
Forked from the early code base of CookieBar2, by Aviran Abady.
Copyright 2019, Iñigo Lacoume.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.