Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

dataScheme (and other) for @Receiver[Action] #1176

Description

@dodgex

as @ReceiverAction is now merged into develop i thought if it would make sense to add features like dataSchemes similar to @Receiver :)

the annotation would then get an String[] dataSchemes() and the generated code could be somewhat like

    public final static List<String> SAMPLE_RECEIVER_SCHEMES = Arrays.asList("http","https");
    public final static String SAMPLE_RECEIVER_ACTION = "ACTION";
    public final static String ANY_EXTRA = "EXTRA";

    @Override
    public void onReceive(Context context, Intent intent) {
        context_ = context;
        super.onReceive(context, intent);
        String action = intent.getAction();
        String scheme = intent.getScheme();
        if (SAMPLE_RECEIVER_ACTION.equals(action) && SAMPLE_RECEIVER_SCHEMES.contains(scheme)) {
            Bundle extras = intent.getExtras();
            if (extras!= null) {
                KeyEvent anyExtra = extras.getParcelable(ANY_EXTRA);
                super.sampleReceiverAction(context, anyExtra);
            }
            return ;
        }
    }

but as mentioned, i'm not yet sure if this is needed. personally i haven't used any dataScheme in a Receiver yet. but it might still be insteresting.

it this is considered usefull, maybe we should also consider adding some of the other intent filter features e.g. mime type or categories (maybe there are others too). i'm not very deep into BroadcastReceiver related stuff so i can not decide how usefull these features are but they might be usefull in other apps than mine. ;)

Activity

  1. WonderCsabo commented on Oct 5, 2014

    @WonderCsabo
    Member

    I think the most important feature which is now can be considered missing would be @Receiver.Extra. @OnActivityResult and @ReceiverAction both has the @Extra field, but @Receiver not. Opened #1180 for that.

  2. WonderCsabo commented on Oct 6, 2014

    @WonderCsabo
    Member

    Thanks. I think the next thing would be adding dataSchemes to @ReceiverAction as well for parity.

    About category and mime type i am not sure which one is the more widely used. @yDelouis any thoughts?

  3. yDelouis commented on Oct 6, 2014

    @yDelouis
    Contributor

    I'm ok with adding dataSchemes.
    About category and mime type, let's wait for someone to ask us to add them.

  4. dodgex commented on Oct 7, 2014

    @dodgex
    MemberAuthor

    okay. i'll try to get a PR for dataSchemes in @ReceiverAction up asap.

    i agree with waiting until someone asks for category and mimetype. :)

  5. dodgex commented on Oct 9, 2014

    @dodgex
    MemberAuthor

    @WonderCsabo @yDelouis is there any specific reason why the camelCaseToUpperSnakeCase removes numbers from the string?

    i had a test() and a test2() method, both tried to get a ACTION_TEST constant due to this number removal. i think the numbers should not be removed.

  6. WonderCsabo commented on Oct 9, 2014

    @WonderCsabo
    Member

    Did you check what calls that method?

  7. dodgex commented on Oct 9, 2014

    @dodgex
    MemberAuthor

    it is called by a hand full of handler have not checked it in detail. havent seen anything that looked like "whoop no i dont want numbers here". just came up with the above thougth.

  8. WonderCsabo commented on Nov 8, 2014

    @WonderCsabo
    Member

    I am closing this since there was no comment about the other two since a month. Thanks @dodgex for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions