shortbread icon indicating copy to clipboard operation
shortbread copied to clipboard

Support for dynamic app shortcuts

Open AndreRoss opened this issue 8 years ago • 6 comments

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?

AndreRoss avatar Feb 17 '17 22:02 AndreRoss

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...
    }
} 

MatthiasRobbers avatar Feb 18 '17 18:02 MatthiasRobbers

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...
    }
} 

MatthiasRobbers avatar Feb 20 '17 23:02 MatthiasRobbers

Is there any plans on adding this?

mikeKickserv avatar Jul 13 '17 19:07 mikeKickserv

visible attribute option is better

avtarsingh1122 avatar Sep 24 '17 18:09 avtarsingh1122

Is this visible attribute still in development?

THMCombine avatar Oct 09 '17 09:10 THMCombine

Not at the moment but I still think it's useful, so I will eventually add it if not somebody else implements it.

MatthiasRobbers avatar Oct 09 '17 16:10 MatthiasRobbers