You’ve probably seen a lot of other Android apps that use the Quick Swipe gesture to quickly launch a shortcut into an app. And you might’ve seen a lot of other apps that use the Quick Swipe gesture to quickly launch a shortcut into an app. In fact, there are so many apps out there that use this seemingly simple idea that I’m starting to wonder why no one has ever made a library or an app that uses this simple idea. Well, I did, and I’ve put together a library called “Quick Swipe Android App Shortcut” that can create app shortcuts from annotations.
What is a shortcut? In short, it is another way of describing an Android library. In this case, “Annotate” provides a way for you to create those app shortcuts from your annotated Android code. The library is super simple: all you have to do is declare an annotation in your AndroidManifest.xml and then “Annotate” will take care of the rest.
Android developers face an unpleasant situation when designing the user experience. They must divide the screen into small pieces (called “Views”) and then arrange them in the same manner as the app widgets. This means that the app widgets are simply containers for other views and the targets of actions, so it is impossible to create certain user experiences, which require actions to be performed on those views, for example.. Read more about app shortcuts android github and let us know what you think.
shortbread cookies
Android library that creates application shortcuts for actions and methods annotated with @Shortcut. You don’t need to touch the manifest, create XML files or use a shortcut manager. Just highlight the code where you want to call the shortcut.
The four key combinations above are generated 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() {
// can z. B. Show AddMovieDialogFragment
}
}
@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() {
// can z. B. View FavoriteBooksFragment}
Links can be configured via attributes, just like with the Framework API.
Kotlin
@Shortcut(
id = books,
icon = R.drawable.ic_shortcut_books,
shortLabel = Books,
shortLabelRes = R.string.shortcut_books_short_label,
longLabel = Book list,
longLabelRes = R.string.shortcut_books_long_label,
rank = 2, // order in list, relative to other links
disabledMessage = No books available,
disabledMessageRes = R.string.shortcut_books_disabled_message,
enabled = true, // by default
backStack = [MainActivity::class, MainActivity::class],
activity = MainActivity::class, // current activity to which the shortcut should be linked
action = shortcut_books // intended action to identify the shortcut from the current activity
)
Java
@Shortcut(
id = books,
icon = R.drawable.ic_shortcut_books,
shortLabel = Books,
shortLabelRes = R.string.shortcut_books_short_label,
longLabel = Book List,
longLabelRes = R.string.shortcut_books_long_label,
rank = 2, // order in the list, relative to other links
disabledMessage = No books available,
disabledMessageRes = R.string.shortcut_books_disabled_message,
enabled = true, // by default
backStack = {MainActivity.class, LibraryActivity.class},
activity = MainActivity.class, // current activity to which the shortcut should be linked
action = shortcut_books // intended action to identify the shortcut from the current activity
)
Download
Shortbread is available on mavenCentral().
Kotlin
applies the plugin: ‘kotlin-capt’.
Dependencies {
implementation ‘com.github.matthiasrobbers:shortbread:1.4.0’
captures ‘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 means sign
If you use resource identifiers in @Shortcut attributes like shortLabelRes, which is recommended, you may see this
warning in Android Studio:
Resource IDs will not be final in version 5.0 of the Android Gradle plugin, so avoid using them as annotation attributes.
If the annotation is in a library, the project is not even compiled. To solve this problem, add the Gradle Shortbread
plugin and apply it to your :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.github.matthiasrobbers:shortbread-gradle-plugin:1.4.0’
}
}
apply the plugin: ‘com.github.matthiasrobbers.shortbread’.
Now make sure you use R2 instead of R in all @Shortcut annotations. If you are using mipmap as a shortcut to the
icon, switch to drawable by simply moving the resources of the mipmap folders to the corresponding drawable
folders.
@Shortcut(icon = R2.drawable.ic_shortcut_movies, shortLabelRes = R2.string.label_movies)
The plugin uses the Gradle [Butterknife][2] plugin to create an R2 class with finite values. Referring to
doesn’t make the warning go away (you can @SuppressLint(NonConstantResourceId)), but
will probably be the only way to use resource identifiers in annotations in the future.
Alternative for the Gradle plugin
If you can’t (or don’t want to) use the plugin, you can use other deprecated string attributes, such as
iconResName, shortLabelResName and so on.
@Shortcut(iconResName = ic_shortcut_movies, shortLabelResName = label_movies)
GitHub
https://github.com/MatthiasRobbers/shortbreadAndroid has been around for a few years now, and while it’s gotten a lot better over the years, one of the things that still needs to get fixed is the navigation system. With the introduction of the home screen, there needs to be something that makes it easier to jump back and forth between apps, even if you’ve used them before. That’s where ShortcutSheet comes in. ShortcutSheet takes a list of data that has been stored in the app itself, and creates a list of shortcuts that take you right back to it.. Read more about create app shortcut android programmatically and let us know what you think.
Related Tags:
app shortcuts android githubandroid app shortcutsapp shortcuts android exampleshortcut maker android githubandroid dynamic shortcuts exampleandroid create shortcut to url,People also search for,Privacy settings,How Search works,app shortcuts android github,android app shortcuts,app shortcuts android example,shortcut maker android github,create app shortcut android programmatically,how to create shortcut on android home screen,android dynamic shortcuts example,android create shortcut to url