From d8715eec14b3627d361bff36e43978277744c694 Mon Sep 17 00:00:00 2001 From: aviran Date: Tue, 4 Dec 2018 20:04:57 +0200 Subject: [PATCH] Code style fix ups --- README.md | 11 +++-- .../java/org/aviran/cookiebar2/CookieBar.java | 46 +++++++++---------- .../org/aviran/cookiebar2/ThemeResolver.java | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 4a9d78b..e154eee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CookieBar2-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6122) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6474fc01133444e0b6f615d9b1af8589)](https://www.codacy.com/app/AviranAbady/CookieBar2?utm_source=github.com&utm_medium=referral&utm_content=AviranAbady/CookieBar2&utm_campaign=badger) +[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CookieBar2-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6122) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6474fc01133444e0b6f615d9b1af8589)](https://www.codacy.com/app/AviranAbady/CookieBar2?utm_source=github.com&utm_medium=referral&utm_content=AviranAbady/CookieBar2&utm_campaign=badger) [![AndroidWeekly335](https://raw.githubusercontent.com/AviranAbady/storage/master/AndroidWeekly335.png)](http://androidweekly.net/issues/issue-335) CookieBar 2 =============== @@ -11,7 +11,7 @@ implementation 'org.aviran.cookiebar2:cookiebar2:1.1.0' ## Screenshot -Main differences from the original Cookiebar are: +Main differences from the original Cookiebar library are: * Swipe to dismiss has been added. * Programmatic dismiss functionality added. @@ -132,7 +132,7 @@ CookieBar.build(MainActivity.this) ## Dynamically set cookie properties * Cookie position (Top/Bottom) - * Display Duration + * Display duration * Title text color * Body text color * Action text color @@ -142,9 +142,12 @@ CookieBar.build(MainActivity.this) * In/Out animations for the entire view * View layout +## Attribution +Forked from the early code base of CookieBar, by Eric Liu. + ## License - Copyright 2017 + Copyright 2018, Aviran Abady. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/cookiebar2/src/main/java/org/aviran/cookiebar2/CookieBar.java b/cookiebar2/src/main/java/org/aviran/cookiebar2/CookieBar.java index b525bda..b882f8c 100644 --- a/cookiebar2/src/main/java/org/aviran/cookiebar2/CookieBar.java +++ b/cookiebar2/src/main/java/org/aviran/cookiebar2/CookieBar.java @@ -13,9 +13,6 @@ import android.view.View; import android.view.ViewGroup; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - /** * CookieBar is a lightweight library for showing a brief message at the top or bottom of the * screen. @@ -28,6 +25,9 @@ * .show(); */ public class CookieBar { + public static final int TOP = Gravity.TOP; + public static final int BOTTOM = Gravity.BOTTOM; + private Cookie cookieView; private final Activity context; @@ -114,8 +114,7 @@ public View getView() { public static class Builder { private final Params params = new Params(); - - final Activity context; + private final Activity context; /** * Create a builder for an cookie. @@ -268,29 +267,26 @@ final static class Params { public String title; public String message; public String action; - boolean enableSwipeToDismiss = true; - boolean enableAutoDismiss = true; - int iconResId; - int backgroundColor; - int titleColor; - int messageColor; - int actionColor; - long duration = 2000; - int cookiePosition = Gravity.TOP; - int customViewResource; - int animationInTop = R.anim.slide_in_from_top; - int animationInBottom = R.anim.slide_in_from_bottom; - int animationOutTop = R.anim.slide_out_to_top; - int animationOutBottom = R.anim.slide_out_to_bottom; - CustomViewInitializer viewInitializer; - OnActionClickListener onActionClickListener; - AnimatorSet iconAnimator; + public boolean enableSwipeToDismiss = true; + public boolean enableAutoDismiss = true; + public int iconResId; + public int backgroundColor; + public int titleColor; + public int messageColor; + public int actionColor; + public long duration = 2000; + public int cookiePosition = Gravity.TOP; + public int customViewResource; + public int animationInTop = R.anim.slide_in_from_top; + public int animationInBottom = R.anim.slide_in_from_bottom; + public int animationOutTop = R.anim.slide_out_to_top; + public int animationOutBottom = R.anim.slide_out_to_bottom; + public CustomViewInitializer viewInitializer; + public OnActionClickListener onActionClickListener; + public AnimatorSet iconAnimator; } public interface CustomViewInitializer { void initView(View view); } - - public static final int TOP = Gravity.TOP; - public static final int BOTTOM = Gravity.BOTTOM; } \ No newline at end of file diff --git a/cookiebar2/src/main/java/org/aviran/cookiebar2/ThemeResolver.java b/cookiebar2/src/main/java/org/aviran/cookiebar2/ThemeResolver.java index 2f26961..e517621 100644 --- a/cookiebar2/src/main/java/org/aviran/cookiebar2/ThemeResolver.java +++ b/cookiebar2/src/main/java/org/aviran/cookiebar2/ThemeResolver.java @@ -10,7 +10,7 @@ public static int getColor(Context context, @AttrRes int attr) { return getColor(context, attr, 0); } - static int getColor(Context context, @AttrRes int attr, int defaultColor) { + public static int getColor(Context context, @AttrRes int attr, int defaultColor) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr}); try { return a.getColor(0, defaultColor);