All Projects → MatthiasRobbers → Shortbread

MatthiasRobbers / Shortbread

Licence: apache-2.0
Android library that creates app shortcuts from annotations

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Shortbread

kobby
Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Stars: ✭ 52 (-97.12%)
Mutual labels:  gradle-plugin, code-generation
Moshix
Moshi Extensions
Stars: ✭ 243 (-86.52%)
Mutual labels:  annotation-processor, code-generation
aptk
A toolkit project to enable you to build annotation processors more easily
Stars: ✭ 28 (-98.45%)
Mutual labels:  annotation-processor, code-generation
laboratory
Feature flags for multi-module Kotlin Android projects
Stars: ✭ 71 (-96.06%)
Mutual labels:  gradle-plugin, code-generation
simple-annotation-processor
Simple annotation processor example. Inspired by the idea of "How ButterKnife works?"
Stars: ✭ 54 (-97%)
Mutual labels:  annotation-processor, code-generation
Deeplinkdispatch
A simple, annotation-based library for making deep link handling better on Android
Stars: ✭ 4,108 (+127.84%)
Mutual labels:  annotation-processor, deep-links
Dexter
Manage multidexing using simple annotations and gradle tasks.
Stars: ✭ 41 (-97.73%)
Mutual labels:  gradle-plugin, annotation-processor
Gradle Xjc Plugin
A Gradle plugin to run the XJC binding compiler during a build
Stars: ✭ 38 (-97.89%)
Mutual labels:  code-generation, gradle-plugin
Bulldog
Android library to simplify reading and writing to SharedPreferences, never write code like this anymore prefs.edit().putString("someKey","someString").apply()
Stars: ✭ 133 (-92.62%)
Mutual labels:  annotation-processor
Dbcc
CAN DBC to C (and CSV, JSON and XML) compiler using the mpc parser combinator library
Stars: ✭ 142 (-92.12%)
Mutual labels:  code-generation
Yguard
The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts
Stars: ✭ 130 (-92.79%)
Mutual labels:  gradle-plugin
Findbugs Android
Gradle plugin that creates FindBugs reports for android projects
Stars: ✭ 133 (-92.62%)
Mutual labels:  gradle-plugin
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (-92.01%)
Mutual labels:  gradle-plugin
Gson Plugin
辅助 Gson 库的 gradle 插件,防止 Json 数据解析类型异常。
Stars: ✭ 133 (-92.62%)
Mutual labels:  gradle-plugin
Androidannotations
Fast Android Development. Easy maintainance.
Stars: ✭ 11,167 (+519.36%)
Mutual labels:  annotation-processor
Forma
Meta build system with Android and Gradle support.
Stars: ✭ 127 (-92.96%)
Mutual labels:  gradle-plugin
Gradle Eclipse Aar Plugin
Gradle plugin to use Android AAR libraries on Eclipse.
Stars: ✭ 127 (-92.96%)
Mutual labels:  gradle-plugin
Umple
Umple: Model-Oriented Programming - embed models in code and vice versa and generate complete systems
Stars: ✭ 147 (-91.85%)
Mutual labels:  code-generation
Gradle Aem Plugin
Swiss army knife for Adobe Experience Manager related automation. Environment setup & incremental AEM application build which takes seconds, not minutes.
Stars: ✭ 145 (-91.96%)
Mutual labels:  gradle-plugin
Php Code Generator
PHP code generator library
Stars: ✭ 141 (-92.18%)
Mutual labels:  code-generation

Shortbread

Android library that generates app shortcuts for activities and methods annotated with @Shortcut. No need to touch the manifest, create XML files or use the shortcut manager. Just annotate the code that you want the shortcut to call.

Sample

The four shortcuts above are produced by the following code:

@Shortcut(id = "movies", icon = R.drawable.ic_shortcut_movies, shortLabel = "Movies")
class MoviesActivity : Activity() {

    // ...

    @Shortcut(id = "add_movie", icon = R.drawable.ic_shortcut_add, shortLabel = "Add movie")
    fun addMovie() {
        // could show an AddMovieDialogFragment for example
    }
}
@Shortcut(id = "books", icon = R.drawable.ic_shortcut_books, shortLabel = "Books")
class BooksActivity : Activity() {

    // ...

    @Shortcut(id = "favorite_books", icon = R.drawable.ic_shortcut_favorite, shortLabel = "Favorite books")
    fun showFavoriteBooks() {
        // could show a FavoriteBooksFragment for example
    }
}

Shortcuts can be customized with attributes, just like using the framework API.

Kotlin
@Shortcut(
    id = "books",
    icon = R.drawable.ic_shortcut_books,
    shortLabel = "Books",
    shortLabelRes = R.string.shortcut_books_short_label,
    longLabel = "List of books",
    longLabelRes = R.string.shortcut_books_long_label,
    rank = 2, // order in list, relative to other shortcuts
    disabledMessage = "No books are available",
    disabledMessageRes = R.string.shortcut_books_disabled_message,
    enabled = true, // default
    backStack = [MainActivity::class, MainActivity::class],
    activity = MainActivity::class, // the launcher activity to which the shortcut should be attached
    action = "shortcut_books" // intent action to identify the shortcut from the launched activity
)
Java
@Shortcut(
    id = "books",
    icon = R.drawable.ic_shortcut_books,
    shortLabel = "Books",
    shortLabelRes = R.string.shortcut_books_short_label,
    longLabel = "List of books",
    longLabelRes = R.string.shortcut_books_long_label,
    rank = 2, // order in list, relative to other shortcuts
    disabledMessage = "No books are available",
    disabledMessageRes = R.string.shortcut_books_disabled_message,
    enabled = true, // default
    backStack = {MainActivity.class, LibraryActivity.class},
    activity = MainActivity.class, // the launcher activity to which the shortcut should be attached
    action = "shortcut_books" // intent action to identify the shortcut from the launched activity
)

Download

Shortbread is available on mavenCentral().

Kotlin
apply plugin: 'kotlin-kapt'

dependencies {
    implementation 'com.github.matthiasrobbers:shortbread:1.4.0'
    kapt 'com.github.matthiasrobbers:shortbread-compiler:1.4.0'
}
Java
dependencies {
    implementation 'com.github.matthiasrobbers:shortbread:1.4.0'
    annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.4.0'
}

Non-final resource IDs

If you are using resource IDs in @Shortcut attributes auch as shortLabelRes, which is recommended, you may see this warning in Android Studio:

Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them as annotation attributes.

If the annotation is located inside a library, the project won't even compile. To overcome this, add the Shortbread Gradle plugin and apply it to your modules:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.matthiasrobbers:shortbread-gradle-plugin:1.4.0'
    }
}
apply plugin: 'com.github.matthiasrobbers.shortbread'

Now make sure you use R2 instead of R inside all @Shortcut annotations. If you are using mipmap as shortcut icon resource type, switch to drawable by simply moving the resources from the mipmap- folders to the corresponding drawable- folders.

@Shortcut(icon = R2.drawable.ic_shortcut_movies, shortLabelRes = R2.string.label_movies)

The plugin uses the Butter Knife Gradle plugin to generate the R2 class with final values. Referencing them does not make the warning disappear (you can suppress it with @SuppressLint("NonConstantResourceId")), but most likely will be the only way to use resource IDs in annotations in the future.

Alternative to Gradle plugin

If for you can't (or don't want to) use the plugin, you can use the additional deprecated string attributes like iconResName, shortLabelResName and so on.

@Shortcut(iconResName = "ic_shortcut_movies", shortLabelResName = "label_movies")

License

Copyright 2017 Matthias Robbers

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].