Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for dynamic app shortcuts #3

Open
AndreRoss opened this issue Feb 17, 2017 · 6 comments
Open

Support for dynamic app shortcuts #3

AndreRoss opened this issue Feb 17, 2017 · 6 comments

Comments

@AndreRoss
Copy link

AndreRoss commented Feb 17, 2017

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 AndreRoss changed the title Support of dynamic app shortcuts Support for dynamic app shortcuts Feb 18, 2017
@MatthiasRobbers
Copy link
Owner

MatthiasRobbers commented Feb 18, 2017

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
Copy link
Owner

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

@mikeKickserv
Copy link

Is there any plans on adding this?

@avtarsingh1122
Copy link

visible attribute option is better

@THMCombine
Copy link

Is this visible attribute still in development?

@MatthiasRobbers
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants