SnackEngage


Source link: https://github.com/ligi/SnackEngage

What

Engage users with a Snackbar from the design lib to e.g. rate or translate the app.

How

Get the dependency via JitPack:

or from JCenter ( might be behind JitPack ) like this:

compile "org.ligi:snackengage:$version"

Just add this where you want ( e.g. in the onCreate method of your entry activity )

SnackEngage.from(this).withSnack(new DefaultRateSnack()).build().engageWhenAppropriate();

This would than show this snack after some opportunities and never again when once clicked on Rate ( which takes you to Play store or F-Droid - anything that accepts the generated market:// link )

Other snacks that are possible:

or create your own snack - e.g. to make a survey.

combine them as you wish and add your own conditions:

SnackEngage.from(view)

.withSnack(new DefaultRateSnack())

.withSnack(new GooglePlayOpenBetaTestSnack()

 .withConditions(new NeverAgainWhenClickedOnce(),

  new AfterNumberOfOpportunities(42)))

.withSnack(new TranslateSnack("https://www.transifex.com/projects/p/snackengage")

 .withConditions(new IsOneOfTheseLocales(Locale.CANADA),

 new NeverAgainWhenClickedOnce(),

 new AfterNumberOfOpportunities(10)))

 .build()

.engageWhenAppropriate();

Why

This lib came to exist because I wanted something like discreet-app-rate - but using a Snackbar from the new material design support lib which was emerging at Google I/O 2015. After thinking about it I wanted to make it more broad - not only for rating - also engaging users by pointing them to beta-testing and translation.

Details

The DefaultRateSnack just configures a RateSnack with default conditions:

public class DefaultRateSnack extends RateSnack {

public DefaultRateSnack() {

withConditions(new NeverAgainWhenClickedOnce(), new AfterNumberOfOpportunities(5));

  
}
  
}

you can easily roll your own analog to this default one:

public class AfterNumberOfOpportunities implements SnackCondition {

private final int number;

public  AfterNumberOfOpportunities(final int number) {

this.number = number;
  
}

@Override
  public boolean isAppropriate(final SnackContext context, final Snack snack) {

return context.getStats().getOpportunitiesSinceLastSnack() > number;
  
}
 
}

you can also have a custom snack with an image added:

.withSnack(new OpenURLSnack("market://details?id=org.ligi.survivalmanual", "survival") {

 @NonNull
@Override
protected Snackbar createSnackBar(final SnackContext snackContext) {

  Snackbar snackbar = super.createSnackBar(snackContext);

  final TextView textView = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);

  textView.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.survival, 0, 0, 0);

  textView.setCompoundDrawablePadding(getResources().getDimensionPixelOffset(R.dimen.rhythm));

  return snackbar;

}
 
}
.overrideTitleText("Other App by ligi:\nFree Offline Survival Guide")  .overrideActionText("Get It!")

Hints

If you use a FloatingActionButton inside a CoordinatorLayout from the design-lib and they are not coordinated - pass a view into snackengage from which the Snackbar can find the CoordinatorLayout - e.g. the fab:

SnackEngage.from(fab)..;

So the movements between Snackbar and FAB are coordinated

Methods

License

The MIT License (MIT)

Copyright (c) 2015-2017 ligi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Resources

RoundedLetterView looks like the one in Android 5.0 Contacts app.

Attributes:

  • titleText - The text in the first row.
  • titleSize - The size of the first row text.
  • titleColor - The color of the first row text.
  • backgroundColorValue - the color between the circle and the stroke.

ObservableScrollView is an Android library to observe scroll events on scrollable views.

It's easy to interact with the Toolbar introduced in Android 5.0 Lollipop and may be helpful to implement look and feel of Material Design apps.

AutoFitTextView is a TextView that automatically fit its font and line count based on its available size and content.

Allows to perform various simple operations on bitmaps via JNI , while also providing some protection against OOM using the native Java environment on Android.

Features:

  • store/restore bitmaps to/from JNI.
  • rotate CW/CCW 90, 180, 270 degrees.
  • crop image
  • scale image using either "Nearest-Neighbor" algorithm or "Bilinear-Interpolation" algorithm.

This library enables you to create a window icon similar to Facebooks chat icon, and also similar to the Link Bubble app.

Magnet takes care of all the touching and dragging of the window icon, leaving you with callbacks so you can save your time doing the important stuff.

A simple subclass of android's TextView that counts up or down.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes