shortbread
shortbread copied to clipboard
Support for dynamic app shortcuts
The library is based on the creation of dynamic app shortcuts but itself does not provide this functionality. The annotated shortcuts are always displayed.
Any ideas how the implement that feature?
It's true that the library currently uses dynamic shortcuts for the purpose of static shortcuts. Although there is more about dynamic shortcuts than just runtime enabling/disabling, I agree that this feature could be supported. I think of something like this for the example of displaying the next episode to watch as a dynamic shortcut:
public class TvSeriesActivity extends Activity {
@DynamicInfo(shortcutId = "next_episode")
Shortcut nextEpisodeShortcut; // dynamic parts of the shortcut
public void onCreate(Bundle b) {
// load data about next episode
// ...
nextEpisodeShortcut.icon(episode.cover());
nextEpisodeShortcut.longLabel(episode.title());
Shortbread.create(this);
}
@Shortcut(id = "next_episode", shortLabel = "Next episode") // static parts of the shortcut
public void showNextEpisode() {
// show next episode...
}
}
Another idea: We still define the shortcut statically via the method annotation but add a visible attribute to initially hide it. We can then set the dynamic part with methods for every property and make the shortcut visible. I think this would be simpler than using the shortcut manager.
public class TvSeriesActivity extends Activity {
public void onCreate(Bundle b) {
// load data about next episode
// ...
// dynamic parts of the shortcut
Shortbread.getShortcut("next_episode")
.setIcon(episode.cover())
.setLongLabel(episode.title())
.setVisible(true);
}
@Shortcut(id = "next_episode", shortLabel = "Next episode", visible = false) // static parts of the shortcut
public void showNextEpisode() {
// show next episode...
}
}
Is there any plans on adding this?
visible attribute option is better
Is this visible attribute still in development?
Not at the moment but I still think it's useful, so I will eventually add it if not somebody else implements it.