In-layout notifications. Based on Toast notifications and article by Cyril Mottier (http://android.cyrilmottier.com/?p=773).

Last update: May 19, 2022

Android AppMsg (Crouton) Library

Implementation of in-layout notifications. Based on Toast notifications and article The making of Prixing #4: in-layout notifications by Cyril Mottier.

Description

Toast is far from being perfect and I am not entirely satisfied with it. Toast can be un-accurate in some cases. Indeed, Toast has one major drawback: it completely breaks contexts. This issue can be reproduced effortless. Let’s say a user is currently in an app firing a Toast and wants to switch to another application using the dedicated “multitask” button. The Toast will remain on screen even if the brought-to-front application has nothing do to with the previously shown app as described on the following figure: Example Image

As you can easily notice, the problem with Toasts is they are persistent. Once a Toast has been fired, it is displayed on top of any screen and remains visible for the duration specified at its creation.

In order to bypass the Toast persistence problem and ensure information is displayed in the correct context, we decided to create a new notification system: Activity-bound notifications. This is what it looks like in the current version of Prixing: Example Image

Crouton overcomes the main issue of having a Toast being shown while the menu is open. It sticks to the current screen sliding with it and leaving the menu completely free of any information that would have not been related to it.

Copyright (C) by Cyril Mottier

Sample

A sample application is available on Google Play:

Get it on Google Play

Example Image

The source code is available in this repository.

Compatibility

This library is compatible from API 4 (Android 1.6).

Installation

The sample project requires:

Usage

Android AppMsg is presented as an Android library project. You can include this project by referencing it as a library project in Eclipse or ant.

To display the item you need the following code:

  • Show AppMsg:
AppMsg.makeText(/*Activity*/, /*CharSequence*/, /*AppMsg.Style*/).show();

Gradle

Android-AppMsg Library is now pushed to Maven Central as a AAR, so you just need to add the following dependency to your build.gradle.

dependencies {
	implementation 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
}

Example Gradle project using Android-AppMsg:

Contribution

Please fork dev repository and contribute back using pull requests.

Contributors are recommended to follow the Android Code Style Guidelines.

Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

Developed By

License

Copyright 2012 Evgeny Shishkin

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.

GitHub

https://github.com/johnkil/Android-AppMsg
Comments
  • 1. No Activity leaking

    Currently Activities are being leaked for as long they are kept in the queue, this PR aims to fix this issues by:

    • Auto releasing it onDestroy for ICS+, older versions must call cancelAll(Activity) (preferred) or cancelAll() at earliest convenience.
    • Using one MsgManager per Activity, this way Activity A won't have to wait for AppMsgs belonging to Activity B to be removed in order to show A's AppMsgs
    • Also updates gradle files/vars
    Reviewed by eveliotc at 2014-02-09 21:57
  • 2. java.lang.NoClassDefFoundError: com.devspark.appmsg.R$color

    It's a Fatal Exception: Main.

    And the cause is:

    java.lang.NoClassDefFoundError: com.devspark.appmsg.R$color
        at com.devspark.appmsg.AppMsg.<clinit>(AppMsg.java:52)
    

    Any ideas?

    Reviewed by joshuapinter at 2013-09-27 05:56
  • 3. I added Maven support, possibility to use custom layout, the possibility to create non-floating messages with a custom View and I also fixed a wrong behavior

    I added the possibility to use custom layout for the message, since it has an TextView with the android.R.id.message. I also added the feature of using an in-layout View, instead of a floating View for the message. If this new feature is used, the custom view will be hidden, instead of removed from the layout. So, it can be reused as many times as the user wants to. I also fixed the behavior of the clear() method, since it wasn't removing the message when it was being shown.

    Reviewed by fernandocamargoai at 2013-06-05 18:46
  • 4. Out animation patch

    This proposed patch will allow the out animation to actually be visible on screen. Originally, the out animation was attached to the view using view.startAnimation(). Immediately following that, the message is removed from the queue and the view is removed from the parent. In most cases, the view is removed from the parent before the animation is visible on screen, thus the resulting effect is the view suddenly disappearing from the screen instead of playing the animation.

    Reviewed by alexfu at 2013-03-29 17:13
  • 5. Added support for custom Animations

    Hello! The following pull request is to add support for using user defined animations instead of always using the default fade in/fade out animations. If no user defined animation is set, it will default back to the fade in/fade out animations that were originally there.

    Reviewed by alexfu at 2013-03-29 16:18
  • 6. Customizable layoutparams

    This is some code to enable the caller to have a bit of control over the placement of the AppMsg by specifying LayoutParameters. There is also a helper method provided in the case where all you want to change is the layout gravity, for example to show the AppMsg at the bottom of the Actitivy.

    Reviewed by mlc at 2012-11-05 17:38
  • 7. Where is Crouton?

    I was reading Appolo-CM, which imported AppMsg from here. But in Appolo-CM the class Crouton is needed. And I looked for Crouton in AppMsg here and there but found nothing about it. So, where is it or does Crouton exist in another projects?

    Reviewed by bytebeats at 2014-04-25 08:07
  • 8. Display the Android-AppMsg (crouton) for the an individual nested fragment

    I'm trying to display the crouton on child fragment it's not displaying anything

    //=================================

    //activity-->viewpager fragment--->childfragment /calling crouton here/

    MeetingFragment f = new MeetingFragment();

    AppMsg.makeText(f.getActivity(), "Hello AppMsg",AppMsg.STYLE_ALERT,(ViewGroup) f.getView()).show(); //failed in nested fragment

    Crouton.makeText(getActivity(), "Hello Crouton", Style.INFO,(ViewGroup) getView()).show(); //failed in nested fragment

    //=================================

    http://stackoverflow.com/questions/14760042/appmsg-crouton-library-support-for-fragments-urgent

    any solutions to make it available for fragment or child (nested) fragment ?!! or this will still display the crouton for the activity, not for an individual fragment?

    Reviewed by LOG-TAG at 2013-11-01 06:11
  • 9. super-preliminary support for building with gradle.

    This is some preliminary support for building AppMsg with gradle, for use in the new Android build system.

    In particular, if gradle is on your PATH and the Android SDK is set up properly, you can now do gradle :library:assemble to build the AppMsg library, and then you can include it in your projects.

    Not supported yet:

    • building the sample project (because it relies on ActionBarSherlock, which is not yet easily available as an AAR, though support for this is pending, see JakeWharton/ActionBarSherlock#891)
    • publishing an AAR of AppMsg itself to Maven Central or something like that

    I can work on these two issues (especially the latter) later, but the patch included here is sufficient to let me build my app with AppMsg, so hopefully it will be useful to someone else even in this limited state.

    Reviewed by mlc at 2013-05-24 22:42
  • 10. Message under dimmed background of a dialog.

    In my application i have a fragment dialog with some controls. Controls make possibility to chose some data and has button. This button validates entered data and make message if data is not valid. But there is a bug (maybe it's feature) - message is appeared under dimmed background of this dialog. Is it possible to show message over the dimmed background.

    Image

    Reviewed by vlebedynskyi at 2014-06-20 11:48
  • 11. waffle.io Badge

    Merge this to receive a badge indicating the number of issues in the ready column on your waffle.io board at http://waffle.io/johnkil/Android-AppMsg

    This was requested by a real person on waffle.io, we're not trying to spam you.

    Reviewed by waffleio at 2013-07-12 17:28
  • 12. AppMsg keeps showing forever

    When I move from one activity to another very fast, the app msg showing there keeps there FOREVER, even I use cancelAll() or cancelMsg(). What is the solution. Please help me.

    Reviewed by gauravarora90 at 2016-11-22 04:31
  • 13. Example of custom view

    As I have not seen any example of positioning the messages in a custom view, I want to share how I solved the problem to get inputs from other users. I am not sure if this is the proper way but it works for me.... more or less:

    I added this code to the layout embedded in a RelativeLayout:

                          <!-- required by AppMsg to position in another place -->
                          <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                              android:id="@+id/messagescontainer"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:layout_centerInParent="true">
    
                              <include layout="@layout/app_msg"/>
    
                          </LinearLayout>
    

    and this code into the Java

                LinearLayout messagesContainer = (LinearLayout) findViewById(R.id.messagesContainer);
    
                AppMsg.makeText(OfferActivity.this, "Error Performing this Operation", AppMsg.STYLE_ALERT, carouselContainer).show();
    

    However, there seems to be a bug because the message is shown as soon is instantiated in makeText(), without the need to call show() method. However, you need to call show() in order to make cancel() method work. Otherwise, cancel() does not remove the message.

    Are these bugs or I am not using it in the proper way?

    Reviewed by pellyadolfo at 2015-08-31 05:24
  • 14. Error: Attempt to invoke virtual method 'boolean com.devspark.appmsg.AppMsg.isShowing()' on a null object reference

    Hi, I have created two AppMsg object like below,

    public MyActivity extends Activity {
         AppMsg noConnectionMsg, connectedMsg; 
    
        @Override
        public void onCreate(Bundle bundle) {
          noConnectionMsg = AppMsg.makeText(this,
                    getResources().getString(R.string.msgNoConnection),
                    AppMsg.STYLE_ALERT);
    
            noConnectionMsg.setDuration(AppMsg.LENGTH_STICKY);
    
    
            connectedMsg = AppMsg.makeText(this,
                    getResources().getString(R.string.msgConnected),
                    AppMsg.STYLE_INFO);
        }
    
       ...
       ...
    
    }
    

    But when I run the application, notifications are successfully shown. After cancelling the AppMsgs, App is getting crashed with this Error:

    Attempt to invoke virtual method 'boolean com.devspark.appmsg.AppMsg.isShowing()' on a null object reference.

    Reviewed by gyanminda at 2015-08-04 19:33
  • 15. Latest changes not in release

    I am using the makeText method with OnClickListener, but I recently switched to gradle and it appears that these methods are not present in Maven Central repository, I can only use the methods without OnClickListener.

    Is it possible to make a new release with these changes?

    Reviewed by wychowanek at 2014-12-29 12:58
Attractive, stylish and customizable toast library for Android.

FabToast min SDK 16 (Jelly Bean 4.1) written in Java To download the demo app for this library from Google Playstore so you can see it in action, clic

Feb 14, 2022
Android : IamToast Another Toast library for Android
 Android : IamToast  Another Toast library for Android

Android : IamToast Another Toast library for Android Warning. toast custom view is deprecated since android 11(R) Setup allprojects { repositories

Feb 7, 2022
A library that extends the Android toast framework.
A library that extends the Android toast framework.

SuperToasts Library The SuperToasts library enhances and builds upon the Android Toast class. This library includes support for context sensitive Supe

May 13, 2022
An Android Toast replacement, similar to the one seen in the GMail app.

MessageBar An Android Toast replacement, similar to the one seen in the GMail app. Multiple messages can be posted in succession, and each message wil

Feb 16, 2022
🍞 The missing toast library for Android.
🍞 The missing toast library for Android.

Literally Toast ?? A toast library for Android. Usage: ?? Use the LitToast to get lit and show your users a proper toast. LitToast.create(context, "My

Dec 17, 2021
Toastie is a customizable Android toast library.
Toastie is a customizable Android toast library.

Toastie Getting Started Gradle Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories: Note

Apr 3, 2021
Android Custom Toast
Android Custom Toast

Super Toast Library Written Purely in Kotlin ❤️ Usual Toast but with super powers!!! ?? A Fully Customised and Customisable Toast. ]( https://android-

May 2, 2021
Android Toast For RTL Applications
Android Toast For RTL Applications

RTL-Toast Android library to show Toasts in a pretty RTL way Install Add it in your root build.gradle allprojects { repositories { ... ma

Oct 19, 2021
Customizable toast message library for Android
Customizable toast message library for Android

Android Custom Toast Message (SnToast) Customizable Toast Message Library For Android Add this in your root build.gradle file allprojects { reposito

Nov 15, 2021
The usual Toast, but with steroids 💪
The usual Toast, but with steroids 💪

Toasty The usual Toast, but with steroids. Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { r

May 24, 2022
A really simple library that help you to display a custom toast with many colors (for : success, warning, danger, info, dark, light, primary...etc ), or with rounded corners, or event with image.

CoolToast A really simple library that help you to display a custom toast with many colors (for : success, warning, danger, info, dark, light, primary

Jun 22, 2020
Simple toast

newlibrary Simple toast Step 1. Add the JitPack repository to your build file allprojects { repositories { ... maven { url 'https://jitpack.io

Nov 5, 2021
An easy, flexible way to have the toast message displayed.
 An easy, flexible way to have the toast message displayed.

IToaster Library An easy, flexible way to have the toast message displayed. Download Gradle Add below codes to your root build.gradle file (not your m

Mar 19, 2022
Custom Toast Library by Google Developer Student Club University of Brawijaya
Custom Toast Library by Google Developer Student Club University of Brawijaya

GDSCToast Custom Toast Library by Google Developer Student Club University of Brawijaya Prerequisites For old version of gradle (before arctic fox upd

May 22, 2022
MDToast - MaterialDesign Toast library written with Kotlin with lots of extensions to interact easily in contexts
MDToast - MaterialDesign Toast library written with Kotlin with lots of extensions to interact easily in contexts

MDToast - MaterialDesign Toast A lightweight Toast library written with Kotlin i

Apr 22, 2022
Context sensitive notifications for Android
Context sensitive notifications for Android

Crouton Context sensitive notifications for Android DEPRECATION NOTICE This library has passed it's prime and is now considered deprecated. With the A

May 11, 2022
Custom toasts with color and icon for Android.
Custom toasts with color and icon for Android.

Dynamic Toasts A simple library to display themed toasts with icon and text on Android 2.3 (API 9) and above devices. Since v0.4.0, it uses 26.x.x sup

May 10, 2022
Balloon 🎈 A lightweight popup like tooltips, fully customizable with arrow and animations.
Balloon  🎈 A lightweight popup like tooltips, fully customizable with arrow and animations.

Balloon ?? A lightweight popup like tooltips, fully customizable with arrow and animations.

May 20, 2022
An android library for easy implementation of Toasts in Android with easy customisation.
An android library for easy implementation of Toasts in Android with easy customisation.

ToastTypeDecore ©️ A library for easy implementation of Toasts in Android with easy customisation. Latest Version : v2.1 Screenshots Success Toast1 Su

Oct 27, 2021