[Deprecated] Android Library that implements Snackbars (former known as Undobar) from Google's Material Design documentation.

Related tags

UI/UX UndoBar
Overview

UndoBar

Build Status

This lib is deprecated in favor of Google's Design Support Library which includes a Snackbar and is no longer being developed.

Thanks for all your support!

Android Library that implements Snackbars (former known as Undobar) from Google's Material Design documentation.

UndoBar Sample UndoBar Sample UndoBar Sample UndoBar Sample UndoBar Sample

How to use this library

  • Download this library, import to your IDE (eclipse...) as a library project.

  • Using Gradle(from 0.5)

    compile 'com.cocosw:undobar:1.+@aar' 
  • Using Maven

    <dependency>
        <groupId>com.cocosw</groupId>
        <artifactId>undobar</artifactId>
        <version>*</version>
        <type>apklib</type>
    </dependency>

API

  • You can also use UndoBar with builder style.

    new UndoBar(getActivity()).message("Undo-bar title").listener(listener).show();
  • Or you can use UndoBar by just one line code (Deprecated from 1.4)

    UndoBarController.show(getActivity(), "Undo-bar title" , listener, undoToken);
  • UndoBar support customize style with background/icon/duration/animation attribution.

  • UndoBar will determine if tranlucent mode(4.4) is using and adjust its position.

Style

  • UndoBar provides 3 default styles. You can use them for different purposes like undo,refresh, or just use it as replacement of toasts. For example, you can use retry style in this way.

    new UndoBarController.UndoBar(this).message(loader.getException().getMessage()).style(UndoBarController.RETRYSTYLE).listener(this).show();
  • UndoBar will switch to KitKat L&F in API-19 target and Material design in API20+.

  • You can set theme in your appliation to change the look and feel. For example, you can use following lines in your style.xml to always use material style UndoBar.

    <style name="MaterialTheme" parent="android:Theme.Light">
        <item name="undoBarStyle">@style/UndoBarMaterialStyle</item>
    </style>
  • You can change undobar style completely by define your own style

        <style name="UndoBarClassicStyle">
            <item name="containerStyle">@style/UndoBarClassic</item>
            <item name="messageStyle">@style/UndoBarMessageClassic</item>
            <item name="buttonStyle">@style/UndoBarButtonClassic</item>
            <item name="dividerStyle">@style/UndoBarDividerClassic</item>
            <item name="inAnimation">@anim/undobar_classic_in_anim</item>
            <item name="outAnimation">@anim/undobar_classic_out_anim</item>
        </style>

Advanced usage

  • Using UndoBarController.AdvancedUndoListener if you need to get notification when UndoBar was cleared or hidden.
  • UndoBar is designed to dynamically add to activity viewgroup, so you need to handle screen-rotation by your self. Check this example to see more.

Contribute

  • Feel free to fork it

License

Copyright 2011, 2015 Kai Liao

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.
Comments
  • Red line below

    Red line below "Undo" text

    Hello,

    if Undobar is called the second time on a device with Android 5 it shows a red line below the "Undo" text. Any idea where this is coming from? First time it shows the Undobar without a red line.

    redline

    opened by peah90 10
  • Listener for UndoBar Hidden/Finished

    Listener for UndoBar Hidden/Finished

    Is it possible to get a listener hook for when the Undo Bar vanishes after the time limit? This could be used to clean up state when an action is NOT Undone.

    For example:

    • User selects "delete item"
    • Item is flagged deleted
    • Undo bar is shown
    • IF Undo selected:
      • Un-flag item as deleted
    • IF Undo bar completes with nothing selected [new listener]
      • Fully delete item

    This could be done by extending the current listener to support an extra function. eg; void onUndo(Parcelable token, Boolean undone);

    ...and then implementations could check "undone" to determine if, for the token, the action was undone, or can proceed with committing the action.

    enhancement 
    opened by dortamur 9
  • onHide() is not executed when UndoBar is cleared prematurely

    onHide() is not executed when UndoBar is cleared prematurely

    OnHide() is not called when a new UndoBar is created before a previous UndoBar has time to time out and execute OnHide().

    For example, I have an UndoBar come up every time I swipe away a list item. If I swipe away one list item, an UndoBar appears. If I then swipe away another list item immediately after, not giving the first UndoBar time to time out and animate out, then the first UndoBar's onHide() is not executed, and a new UndoBar comes up for the second item swiped away, replacing the first.

    If I swipe two items away, I need the onHide callback to run for both items. Is this the intended functionality?

    opened by jakis39 8
  • Compile error with support-v7 22.1

    Compile error with support-v7 22.1

    When I try to compile with the new v7 support library, I get the following error:

    Error: Attribute "buttonStyle" has already been defined
    

    I do not get this error with 22.0. I assume this caused by the definition in attrs.xml conflicting with one introduced in the new support library version.

    opened by cheeplusplus 7
  • UndoBar with translucent Navigationbar

    UndoBar with translucent Navigationbar

    When implementing the translucent Navigationbar, the Undobar pops up behind this bar.

    I'd suggest changing the position depending on whether it is used or not.

    (e.g. by passing a boolean to the constructor and switching the position depending on this boolean)

    opened by homj 7
  • No resource found that matches the given name (at 'id' with value '@android:id/mask')

    No resource found that matches the given name (at 'id' with value '@android:id/mask')

    I get this "No resource found that matches the given name (at 'id' with value '@android:id/mask')" error in "UndoBar / library / res / drawable-v21 /undobar_material_button.xml" resource file. Do I need to add a new dependency? I did not face this any time before. I see you have updated the lib few hours back. Please help.

    opened by supareek 5
  • Get height UndoBar to move Floating Action Button out of the way

    Get height UndoBar to move Floating Action Button out of the way

    I really like the UndoBar, works great! I just have one problem. I'm using the new Material Design UndoBar and want to move my Floating Action Button out of the way. The thing is that I only know its max height is 80dp, but I want to know the exact height for the best animation. Thanks in advance!

    opened by kevinvanmierlo 4
  •  java.lang.NullPointerException

    java.lang.NullPointerException

    Hello,

    I downloaded the code and add the project as an Android library to my eclipse project.

    When trying to invoke the undobar from my adapter I got the following error

     java.lang.NullPointerException
        at com.cocosw.undobar.UndoBarController.<init>(UndoBarController.java:89)
        at com.cocosw.undobar.UndoBarController.ensureView(UndoBarController.java:272)
        at com.cocosw.undobar.UndoBarController.show(UndoBarController.java:259)
        at com.cocosw.undobar.UndoBarController.show(UndoBarController.java:251)
        at com.cocosw.undobar.UndoBarController.show(UndoBarController.java:305)
        at rainstudios.kelo.ui.FavoriteAdapter$1.onDismiss(FavoriteAdapter.java:64)
        at androidextras.widget.SwipeDismissTouchListener$2.onAnimationEnd(SwipeDismissTouchListener.java:228)
        at com.nineoldandroids.animation.ValueAnimator.endAnimation(ValueAnimator.java:1034)
        at com.nineoldandroids.animation.ValueAnimator.access$900(ValueAnimator.java:43)
        at com.nineoldandroids.animation.ValueAnimator$AnimationHandler.handleMessage(ValueAnimator.java:669)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)
    

    It seems that the inflation fails and the mButton variable is null.

    I don't understand what is wrong with my application (API 11 and using AndroidAnnotations).

    Here's the code I use to invoke undobar

    @EBean
    public class FavoriteAdapter extends BaseAdapter implements UndoListener {
    
        @SuppressWarnings("unchecked")
        List<Favorite> items = Collections.EMPTY_LIST;
    
        @RootContext
        Activity context;
             ....
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
    
            FavoriteItemView view;
            if (convertView == null) {
                view = FavoriteItemView_.build(context);
            } else {
                view = (FavoriteItemView) convertView;
            }
            view.setLongClickable(false);
            view.setClickable(false);
            view.setOnClickListener(null);
            view.bind(getItem(position));
            final int pos = position;
            // Create a generic swipe-to-dismiss touch listener.
            view.setOnTouchListener(new SwipeDismissTouchListener(view, null,
                    new SwipeDismissTouchListener.OnDismissCallback() {
                        @Override
                        public void onDismiss(View view, Object token) {
                            Favorite item = items.get(pos);
                            db.deleteFavorite(FavoriteType.Subreddit, item.title);
                            items.remove(pos);
                            UndoBarController.show(context, "Undo-bar title",
                            FavoriteAdapter.this, null);
                        }
                    }));
    
            return view;
        }
    
    opened by PerfectCarl 4
  • New button highlight colour for KitKat

    New button highlight colour for KitKat

    Currently the button highlights when pressed are the old Holo blue colour. It would be nice to also have the new Holo gray colour when running on KitKat.

    enhancement 
    opened by pushbit 4
  • UndoBar crashes if you hold Undo button and the Undobar disappears

    UndoBar crashes if you hold Undo button and the Undobar disappears

    Hello,

    if you press on the "Undo" button of Undobar and hold your press on the button, the Undobar disappears after the specified timeout. This is still correct. If you release your press on the button now (AFTER Undobar disappeared) the Undobar crashes.

    We reproduced the bug on a device with Android 4 and Android 5.

    See stacktrace:

    11-25 14:26:03.830    3058-3058/de.whs.moa.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: de.whs.moa.app, PID: 3058
        java.lang.NullPointerException: Attempt to read from field 'android.os.Parcelable com.cocosw.undobar.UndoBarController$Message.undoToken' on a null object reference
                at com.cocosw.undobar.UndoBarController$Message.access$200(UndoBarController.java:775)
                at com.cocosw.undobar.UndoBarController$2.onClick(UndoBarController.java:127)
                at android.view.View.performClick(View.java:4756)
                at android.view.View$PerformClick.run(View.java:19749)
                at android.os.Handler.handleCallback(Handler.java:739)
                at android.os.Handler.dispatchMessage(Handler.java:95)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5221)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    
    opened by peah90 3
  • UndoBar doesn't save it's instance state.

    UndoBar doesn't save it's instance state.

    Hi! First of all thanks for your work and very useful library!

    My problem is that on device rotation a visible undo bar is not restored. It seems UndoBar instance state is not saved.

    I tried to debug and noticed that onSaveInstanceState and onRestoreInstanceState are not being invoked on device rotation.

    May it happen because UndoBar view is added dynamically?

    opened by makovkastar 3
  • CountDown style like in ListViewAnimations (https://github.com/nhaarman/ListViewAnimations)

    CountDown style like in ListViewAnimations (https://github.com/nhaarman/ListViewAnimations)

    Thanks for your library. I've modified it and added possibility to have UndoBar with countdown (like in ListViewAnimations/SwipeToDismiss demo). Perhaps this will be useful for somebody

    image

    library:

    • UndoBarController: removed mHideRunnable field
    • UndoBarController: added new fields mDismissStartMillis, mCountDownRunnable, mMessageCountdownView
    • UndoBarController: added mCountDownRunnable, mMessageCountdownView fields initialization to the constructor
    • UndoBarController: updated runnable reference for the removeCallback call in the undoBar method
    • UndoBarController: modified showUndoBar to adjust visibility and text of mMessageCountdownView if countDownFormatter is present in the style
    • UndoBarController: updated hide handler logic in the showUndoBar method
    • UndoBarController.CountDownRunnable: added
    • UndoBarStyle: added countDownFormatter field and its setter method
    • UndoBarStyle: added countDownFormatter support to parcelable implementation
    • res/layout/undobar.xml: reworked TextView part, added hidden countdown view below it
    • res/values/styles.xml: added UndoBarMessageContainer, UndoBarMessageCountdown, UndoBarMessageContainerClassic, UndoBarMessageCountdownClassic, UndoBarMessageContainerKitKat, UndoBarMessageCountdownKitKat styles

    demo:

    • MainActivity: added onClick handling for the button5
    • UndoCountdownStyle: added
    • res/layout/activity_main.xml: added button5 declaration
    • res/values/strings.xml: added couple of string constants
    • res/values/styles.xml: added definition for the UndoBarMessageContainer and UndoBarMessageCountdown styles
    • AndroidManifest.xml: added UndoCountdownStyle activity declaration
    opened by httpdispatch 3
Android library that implements a table with fixed headers.

TableFixHeaders [DISCONTINUED] This project it's not deprecated, it do what it must, but we don't have time to improve it or, even, answer issues. Wha

inqbarna 803 Dec 20, 2022
A Material design Android pincode library. Supports Fingerprint.

LolliPin A Lollipop material design styled android pincode library (API 14+) To include in your project, add this to your build.gradle file: //Loll

Omada Health 1.6k Nov 25, 2022
An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.

MaterialScrollBar An Android library that brings the Material Design 5.1 scrollbar to pre-5.1 devices. Designed for Android's recyclerView. Video Imag

Turing Technologies (Wynne Plaga) 784 Nov 29, 2022
An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.

MaterialScrollBar An Android library that brings the Material Design 5.1 scrollbar to pre-5.1 devices. Designed for Android's recyclerView. Video Imag

Turing Technologies (Wynne Plaga) 784 Nov 29, 2022
A library that provides an implementation of the banner widget from the Material design.

MaterialBanner A banner displays a prominent message and related optional actions. MaterialBanner is a library that provides an implementation of the

Sergey Ivanov 252 Nov 18, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Dec 30, 2022
A skeleton of google's appcompat android navigation drawer with material design.

Lollipop AppCompat Skeleton A skeleton of google's appcompat android navigation drawer with material design. Compatible to work on 4.0+ Based on Googl

Sachin Shinde 99 Nov 29, 2022
Material Design tap target for Android. https://sjwall.github.io/MaterialTapTargetPrompt/

Material Tap Target Prompt A Tap Target implementation in Android based on Material Design Onboarding guidelines. For more information on tap targets

Sam Wall 1.5k Jan 4, 2023
An implementation of tap targets from the Material Design guidelines for feature discovery.

TapTargetView An implementation of tap targets from Google's Material Design guidelines on feature discovery. Min SDK: 14 JavaDoc Installation TapTar

Keepsafe 5.2k Dec 30, 2022
Android Material Json Form Wizard is a library for creating beautiful form based wizards within your app just by defining json in a particular format.

Android Json Wizard Android Json Wizard is a library for creating beautiful form based wizards within your app just by defining json in a particular f

Vijay Rawat 355 Nov 11, 2022
Kotlin Wrapper Library of Material-UI

kotlin-material-ui Kotlin Wrapper Library of Material-UI Core: Lab: Installation repositories { jcenter() // or maven { url 'https://dl.bintra

Subroh Nishikori 78 Nov 24, 2022
Frogo Android UI Kit - Frogo UI Design Kit Guideline

About This Project Follow-up project from frogo-ui-kit UI Kit for helping you in apps development Migrate from frogo-ui-kit Just renaming package com.

Frogobox 6 Nov 25, 2022
ScratchView 7.0 0.0 L4 Java repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal.

ScratchView Intro ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal. There a

Harish Sridharan 1.1k Dec 24, 2022
ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal.

ScratchView Intro ScratchView repo is UX Design involving scratch cards like views which are scratched to reveal the information they conceal. There a

Harish Sridharan 1.1k Dec 24, 2022
Awesome RunnerBe design system and more!

Honeycomb Awesome RunnerBe design system and more! Core Preview 아직 모든 요소가 구현되지 않았으며 단순히 미리보기 입니다 class MainActivity : AppCompatActivity() { overri

RunnerBe 2 Apr 21, 2022
NeoPOP was created with one simple goal; to create the next generation of a beautiful, affirmative design system

NeoPop is CRED's inbuilt library for using NeoPop components in your app

CRED 254 Dec 29, 2022
Create an header for com.google.android.material.navigation.NavigationView

Header View This is a view for NavigationView in android.support.design library Import At the moment the library is in my personal maven repo reposito

Raphaël Bussa 106 Nov 25, 2022
Inspired by Heinrich Reimer Material Intro and developed with love from scratch

Android Material Intro Screen Material intro screen is inspired by Material Intro and developed with love from scratch. I decided to rewrite completel

Tango Agency 2.7k Dec 19, 2022
A material Switch with icon animations and color transitions

Material Animated Switch A material Switch with icon animations and color transitions Sample video: Youtube Material Animated Switch video Sample app:

Adrián Lomas 1.2k Dec 29, 2022