{"id":15448937,"url":"https://github.com/ligi/snackengage","last_synced_at":"2025-04-19T21:39:10.332Z","repository":{"id":34895548,"uuid":"38925313","full_name":"ligi/SnackEngage","owner":"ligi","description":"Engage Users with a Snackbar to e.g. rate or translate the app","archived":false,"fork":false,"pushed_at":"2022-12-16T23:35:37.000Z","size":705,"stargazers_count":62,"open_issues_count":6,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T13:35:21.584Z","etag":null,"topics":["android","android-library","library"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ligi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-11T12:41:21.000Z","updated_at":"2024-10-24T18:52:20.000Z","dependencies_parsed_at":"2023-01-15T10:01:46.656Z","dependency_job_id":null,"html_url":"https://github.com/ligi/SnackEngage","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ligi%2FSnackEngage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ligi%2FSnackEngage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ligi%2FSnackEngage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ligi%2FSnackEngage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ligi","download_url":"https://codeload.github.com/ligi/SnackEngage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249811844,"owners_count":21328876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","library"],"created_at":"2024-10-01T20:41:15.438Z","updated_at":"2025-04-19T21:39:10.313Z","avatar_url":"https://github.com/ligi.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### What\n\nEngage users with a [Snackbar][material-snackbars] from the design lib to e.g. rate or translate the app.\n\n### How\n\nGet the dependency via JitPack: [![](https://jitpack.io/v/ligi/snackengage.svg)](https://jitpack.io/#ligi/snackengage)\n\nor from JCenter ( might be behind JitPack ) like this:\n```groovy\nimplementation \"org.ligi:snackengage:$version\"\n```\n\nJust add this where you want ( e.g. in the `onCreate` method of your entry activity )\n\n```java\nSnackEngage.from(this).withSnack(new DefaultRateSnack()).build().engageWhenAppropriate();\n```\n\nThis 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 )\n\n![rate screenshot](doc/screenshots/rate_small.png)\n\n#### Other snacks that are possible:\n![rate screenshot](doc/screenshots/betatest_small.png) ![rate screenshot](doc/screenshots/translate_small.png)\n\nor create your own snack - e.g. to make a survey.\n\ncombine them as you wish and add your own conditions:\n\n```java\nSnackEngage.from(view)\n           .withSnack(new DefaultRateSnack())\n           .withSnack(new GooglePlayOpenBetaTestSnack()\n                              .withConditions(new NeverAgainWhenClickedOnce(),\n                                              new AfterNumberOfOpportunities(42)))\n           .withSnack(new TranslateSnack(\"https://www.transifex.com/projects/p/snackengage\")\n                              .withConditions(new IsOneOfTheseLocales(Locale.CANADA),\n                              new NeverAgainWhenClickedOnce(),\n                              new AfterNumberOfOpportunities(10)))\n\n           .build()\n           .engageWhenAppropriate();\n```\n\nThe rate snack exists in different versions: snackengage-playrate and snackengage-amazonrate. You can use them in different flavors of your app.\n\n### Why\n\nThis lib came to exist because I wanted something like [discreet-app-rate](https://github.com/PomepuyN/discreet-app-rate) - but using a Snackbar from the new material design support lib which was emerging at Google I/O 2015.\nAfter 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.\n\n### Details\n\nThe DefaultRateSnack just configures a RateSnack with default conditions:\n\n```java\npublic class DefaultRateSnack extends RateSnack {\n\n    public DefaultRateSnack() {\n        withConditions(new NeverAgainWhenClickedOnce(), new AfterNumberOfOpportunities(5));\n    }\n\n}\n```\n\nyou can easily roll your own analog to this default one:\n\n```java\npublic class AfterNumberOfOpportunities implements SnackCondition {\n\n    private final int number;\n\n    public  AfterNumberOfOpportunities(final int number) {\n        this.number = number;\n    }\n\n    @Override\n    public boolean isAppropriate(final SnackContext context, final Snack snack) {\n        return context.getStats().getOpportunitiesSinceLastSnack() \u003e number;\n    }\n}\n```\n\nyou can also have a custom snack with an image added:\n\n![rate screenshot](doc/screenshots/with_icon_small.png)\n\n```java\n.withSnack(new OpenURLSnack(\"market://details?id=org.ligi.survivalmanual\", \"survival\") {\n\n  @NonNull\n  @Override\n  protected Snackbar createSnackBar(final SnackContext snackContext) {\n    Snackbar snackbar = super.createSnackBar(snackContext);\n    final TextView textView = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);\n    textView.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.survival, 0, 0, 0);\n    textView.setCompoundDrawablePadding(getResources().getDimensionPixelOffset(R.dimen.rhythm));\n    return snackbar;\n  }\n}.overrideTitleText(\"Other App by ligi:\\nFree Offline Survival Guide\")\n .overrideActionText(\"Get It!\")\n```\n\n### Hints\n\nIf 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:\n\n```java\nSnackEngage.from(fab)..;\n```\n\nSo the movements between Snackbar and FAB are coordinated\n\n### Methods\n\n\u003ca href=\"http://www.methodscount.com/?lib=org.ligi%3Asnackengage%3A0.5\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods and size-core: 124 | deps: 19823 | 33 KB-e91e63.svg\"\u003e\u003c/img\u003e\u003c/a\u003e\n\n### License\nThe MIT License (MIT)\n\nCopyright (c) 2015-2022 SnackEngage Developers (see commit history)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n\n[material-snackbars]: https://material.io/guidelines/components/snackbars-toasts.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fligi%2Fsnackengage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fligi%2Fsnackengage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fligi%2Fsnackengage/lists"}