{"id":13604120,"url":"https://github.com/MatthiasRobbers/shortbread","last_synced_at":"2025-04-11T22:32:40.496Z","repository":{"id":52999413,"uuid":"81653189","full_name":"MatthiasRobbers/shortbread","owner":"MatthiasRobbers","description":"Android library that creates app shortcuts from annotations","archived":false,"fork":false,"pushed_at":"2021-04-10T13:04:09.000Z","size":452,"stargazers_count":1777,"open_issues_count":2,"forks_count":147,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-04-08T01:34:30.557Z","etag":null,"topics":["android","android-library","annotation-processor","app-shortcuts","code-generation","deep-links","gradle-plugin","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatthiasRobbers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-11T13:00:08.000Z","updated_at":"2025-04-02T14:09:22.000Z","dependencies_parsed_at":"2022-09-26T21:41:30.131Z","dependency_job_id":null,"html_url":"https://github.com/MatthiasRobbers/shortbread","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthiasRobbers%2Fshortbread","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthiasRobbers%2Fshortbread/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthiasRobbers%2Fshortbread/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthiasRobbers%2Fshortbread/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatthiasRobbers","download_url":"https://codeload.github.com/MatthiasRobbers/shortbread/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248489902,"owners_count":21112659,"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","annotation-processor","app-shortcuts","code-generation","deep-links","gradle-plugin","kotlin"],"created_at":"2024-08-01T19:00:40.269Z","updated_at":"2025-04-11T22:32:35.483Z","avatar_url":"https://github.com/MatthiasRobbers.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"Shortbread\n==========\n\nAndroid library that generates [app shortcuts][1] for activities and methods annotated with `@Shortcut`.\nNo need to touch the manifest, create XML files or use the shortcut manager. Just annotate the code that\nyou want the shortcut to call.\n\n![Sample](sample.png)\n\nThe four shortcuts above are produced by the following code:\n\n```kotlin\n@Shortcut(id = \"movies\", icon = R.drawable.ic_shortcut_movies, shortLabel = \"Movies\")\nclass MoviesActivity : Activity() {\n\n    // ...\n\n    @Shortcut(id = \"add_movie\", icon = R.drawable.ic_shortcut_add, shortLabel = \"Add movie\")\n    fun addMovie() {\n        // could show an AddMovieDialogFragment for example\n    }\n}\n```\n\n```kotlin\n@Shortcut(id = \"books\", icon = R.drawable.ic_shortcut_books, shortLabel = \"Books\")\nclass BooksActivity : Activity() {\n\n    // ...\n\n    @Shortcut(id = \"favorite_books\", icon = R.drawable.ic_shortcut_favorite, shortLabel = \"Favorite books\")\n    fun showFavoriteBooks() {\n        // could show a FavoriteBooksFragment for example\n    }\n}\n```\n\nShortcuts can be customized with attributes, just like using the framework API.\n\n\u003cdetails open\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\n@Shortcut(\n    id = \"books\",\n    icon = R.drawable.ic_shortcut_books,\n    shortLabel = \"Books\",\n    shortLabelRes = R.string.shortcut_books_short_label,\n    longLabel = \"List of books\",\n    longLabelRes = R.string.shortcut_books_long_label,\n    rank = 2, // order in list, relative to other shortcuts\n    disabledMessage = \"No books are available\",\n    disabledMessageRes = R.string.shortcut_books_disabled_message,\n    enabled = true, // default\n    backStack = [MainActivity::class, MainActivity::class],\n    activity = MainActivity::class, // the launcher activity to which the shortcut should be attached\n    action = \"shortcut_books\" // intent action to identify the shortcut from the launched activity\n)\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eJava\u003c/summary\u003e\n\n```java\n@Shortcut(\n    id = \"books\",\n    icon = R.drawable.ic_shortcut_books,\n    shortLabel = \"Books\",\n    shortLabelRes = R.string.shortcut_books_short_label,\n    longLabel = \"List of books\",\n    longLabelRes = R.string.shortcut_books_long_label,\n    rank = 2, // order in list, relative to other shortcuts\n    disabledMessage = \"No books are available\",\n    disabledMessageRes = R.string.shortcut_books_disabled_message,\n    enabled = true, // default\n    backStack = {MainActivity.class, LibraryActivity.class},\n    activity = MainActivity.class, // the launcher activity to which the shortcut should be attached\n    action = \"shortcut_books\" // intent action to identify the shortcut from the launched activity\n)\n```\n\u003c/details\u003e\n\nDownload\n--------\n\nShortbread is available on `mavenCentral()`.\n\n\u003cdetails open\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```groovy\napply plugin: 'kotlin-kapt'\n\ndependencies {\n    implementation 'com.github.matthiasrobbers:shortbread:1.4.0'\n    kapt 'com.github.matthiasrobbers:shortbread-compiler:1.4.0'\n}\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eJava\u003c/summary\u003e\n\n```groovy\ndependencies {\n    implementation 'com.github.matthiasrobbers:shortbread:1.4.0'\n    annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.4.0'\n}\n```\n\u003c/details\u003e\n\nNon-final resource IDs\n----------------------\nIf you are using resource IDs in `@Shortcut` attributes auch as `shortLabelRes`, which is recommended, you may see this\nwarning in Android Studio:\n\u003e Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them as annotation attributes.\n\nIf the annotation is located inside a library, the project won't even compile. To overcome this, add the Shortbread\nGradle plugin and apply it to your modules:\n\n```groovy\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n    dependencies {\n        classpath 'com.github.matthiasrobbers:shortbread-gradle-plugin:1.4.0'\n    }\n}\n```\n\n```groovy\napply plugin: 'com.github.matthiasrobbers.shortbread'\n```\n\nNow make sure you use `R2` instead of `R` inside all `@Shortcut` annotations. If you are using `mipmap` as shortcut icon\nresource type, switch to `drawable` by simply moving the resources from the `mipmap-` folders to the corresponding\n`drawable-` folders.\n\n```kotlin\n@Shortcut(icon = R2.drawable.ic_shortcut_movies, shortLabelRes = R2.string.label_movies)\n```\n\nThe plugin uses the [Butter Knife][2] Gradle plugin to generate the `R2` class with final values. Referencing them does\nnot make the warning disappear (you can suppress it with `@SuppressLint(\"NonConstantResourceId\")`), but most likely will\nbe the only way to use resource IDs in annotations in the future.\n\u003cdetails\u003e\n\u003csummary\u003eAlternative to Gradle plugin\u003c/summary\u003e\n\nIf for you can't (or don't want to) use the plugin, you can use the additional deprecated string attributes like\n`iconResName`, `shortLabelResName` and so on.\n\n```kotlin\n@Shortcut(iconResName = \"ic_shortcut_movies\", shortLabelResName = \"label_movies\")\n```\n\u003c/details\u003e\n\nLicense\n-------\n\n    Copyright 2017 Matthias Robbers\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n\n [1]: https://developer.android.com/guide/topics/ui/shortcuts.html\n [2]: https://github.com/JakeWharton/butterknife\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMatthiasRobbers%2Fshortbread","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMatthiasRobbers%2Fshortbread","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMatthiasRobbers%2Fshortbread/lists"}