Mark-Lauman / DominionPicker

An Android companion app for Rio Grande Games' Dominion
MIT License
12 stars 14 forks source link

BGG integration #19

Open dkniffin opened 9 years ago

dkniffin commented 9 years ago

It'd be awesome if you could say you played with a set of cards, and have it log the play to boardgamegeek.com. You might also see if it could somehow integrate with the unofficial BGG app.

dkniffin commented 9 years ago

I just opened an issue with the BGG app, to add an intent to create a game.

Mark-Lauman commented 9 years ago

I'm willing to work with the BGG guys if they want to make cross-app a possibility =)

dkniffin commented 8 years ago

I'm not very experienced with android development, but I took a stab at looking into this, and it might already be possible. I found this BroadcastReceiver. @Mark-Lauman Maybe you can tell me if that does what we would need on the BGG app side?

Mark-Lauman commented 8 years ago

I'm afraid that doesn't do much, I think it just allows that activity to change its playId when the active playId is changed by BGG.

For me to send a play to the BGG app, they'd need the following:

  1. An Activity (a new screen - in Dominion Picker the Picker and Options screens are separate Activities, while the Black Market and the Picker are not) that is used to submit a play to the BGG website.
  2. That Activity must have exported="true" in the AndroidManifest (PlayActivity has exported set to false).
  3. Some way of passing arguments to that Activity. This would allow me to provide text for text fields and so on. I obviously have my preferences on how to go about this, but what really matters is that the parameter passing is there.

For BGG to launch Dominion Picker (without passing a game), they'd need these 2 lines of code:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("ca.marklauman.dominionpicker");
startActivity(launchIntent);

with some additional checks to verify that the app is installed.

For BGG to launch Dominion Picker and pass a set of cards, I'd need to do some more coding work on the SupplyActivity =)

dkniffin commented 8 years ago

Thanks! That helps a lot. I'm going to see if I can implement this on their side. I did a little android development 4 years ago or so, but haven't touched it since, so it'll be a learning experience.

For opening board game apps (eg Dominion Picker) from the BGG app, could it also be written as a generic Intent, sending something about the game that it want's to open? That way, if a new game app wants to support that interaction, the BGG doesn't have to code anything new.

Mark-Lauman commented 8 years ago

Oh! Well that will make things considerably easier.

For argument passing, one possibility is me doing something like this:

Intent launchBGG = // make intent pointing to the BGG play activity
launchBGG.putExtra( KEY_TEXT, "text to display in the play");
startActivity(launchBGG);

Which you could then retrieve like this:

getIntent().getStringExtra( KEY_TEXT );

But if you find another way that works better, then use that - how I code is not necessarily how everyone should code :)

As for making the Intents generic, this seems possible. I know you can launch "generic email client" with this

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("message/rfc822");
intent.setData(Uri.parse("mailto:"+Uri.encode(target)+"?subject="+Uri.encode(subject)));
startActivity(Intent.createChooser(intent, "Send Email"));

but I haven't done my research, so I don't feel confident about how it works.