Chess for Android v4.1.5: sharing

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Chess for Android v4.1.5: sharing

Post by abik »

I had a few very pleasant email exchanges with Gerhard Kalab, and based on our interaction I just released version 4.1.5 of Chess for Android as direct download and at Google Play with enhancements for, what I like to call, the chess ecosystem on Android. First, Chess for Android now understands a few more direct sharing requests from other applications so that, for example, a game can be shared directly from Gerhard Kalab's Chess PGN viewer into Chess for Android, without going through tedious copy-and-paste operations. Conversely, Chess for Android now supports the "Share Game" feature as well to do the opposite operation.

As illustrated in this blog posting (long-press notation window to open the extended menu), exporting a game from Chess for Android to Gerhard Kalab's Chess PGN Viewer or the other way around now only takes a few simple clicks!
User avatar
Dr.Wael Deeb
Posts: 9773
Joined: Wed Mar 08, 2006 8:44 pm
Location: Amman,Jordan

Re: Chess for Android v4.1.5: sharing

Post by Dr.Wael Deeb »

Thanks Aart for the masterpiece of yours :D
Dr.D
_No one can hit as hard as life.But it ain’t about how hard you can hit.It’s about how hard you can get hit and keep moving forward.How much you can take and keep moving forward….
User avatar
asimpereira
Posts: 38
Joined: Sun Mar 25, 2012 9:06 am

Re: Chess for Android v4.1.5: sharing

Post by asimpereira »

Thanks Aart for initiating this. Must say I always "wanted" to have some kind of Chess eco system to exist on Android for all developers to adhere.

I am sure many other developers would be interested too.
Are the details posted somewhere for other developers to follow?

It would be nice to have some kind of specifications:
- for exchanging game info
- position info
- request to analyze etc etc

For ex, my app Analyze This can be made to analyze any kind of position from 3rd party app with a little bit of code:
-----
Intent intent = new Intent();
ComponentName name = new ComponentName("com.pereira.analysis",
"com.pereira.analysis.ui.BoardActivity");
intent.setComponent(name);
intent.putExtra("KEY_FEN", fen);
startActivity(intent);

(where fen = the fen of the current position)
------

Here, instead of explicit component name, we could have certain "data/mime types" such that user can choose the app from the list which Android pops out (when it finds more than one app matching the criteria)
--
Regards,
Asim

For the love of the game http://mychessapps.com
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Chess for Android v4.1.5: sharing

Post by abik »

Thanks Asim. Most details where listed in the Jan 2012 and Jan 2013 blog postings, but I guess it is good to summarize these here, and perhaps discuss further extensions and or conventions.

Two ways of requesting a chess application on Android to view a game in PGN format using data and type is as follows, using the application/x-chess-pgn MIME type.

Code: Select all

  // View game in PGN format that resides in file (with proper permissions for others to view).
  Intent intent = new Intent(Intent.ACTION_VIEW);
  File file = ... file in pgn format ....;
  intent.setDataAndType(Uri.fromFile(file), "application/x-chess-pgn");
  startActivity(intent);

  // View game in PGN format that resides in string (good to avoid 'confusing' characters).
  Intent intent = new Intent(Intent.ACTION_VIEW);  
  String data = ".... game in pgn format ....";
  intent.setDataAndType(Uri.parse(data), "application/x-chess-pgn");
  startActivity(intent);
One way to send a game in PGN format using the extra data mechanism for an intent is as follows (courtesy discussion with Gerhard Kalab).

Code: Select all

    // Send game in PGN format that resides in string.
    Intent intent = new Intent(Intent.ACTION_SEND);
    String data = ".... game in pgn format ....";
    intent.putExtra(Intent.EXTRA_TEXT, data);
    intent.setType("application/x-chess-pgn");
    mycontext.startActivity(intent);
One subtlety to deal with is what action should be used: view (display the data to the user) or send (deliver some data to someone else).
For a chess program, there is probably very little difference between the two, so I recommend to support them both.

Another subtlety is due to the fact that afaik, there is no MIME type for the FEN format. Again, afaik, most chess applications simply tag the data as PGN or text on the sending side, and analyze the contents whether it contains PGN or FEN on the receiving side.

The most important feature is of course the late binding between data and handling application (so never hard-code a handling application name). Users should decide what program to use!

Other chess authors on Android, please chime in with your ideas!
User avatar
asimpereira
Posts: 38
Joined: Sun Mar 25, 2012 9:06 am

Re: Chess for Android v4.1.5: sharing

Post by asimpereira »

Sorry missed your blog posts; have a lot of feeds to catch since the holiday season.

Yesterday, Gerhard forwarded me some email conversation and I was pleasantly surprised to know that application/x-chess-fen can be used for FEN positions!

Overall, I think it may be a good experience for Chess users, knowing that they can easily switch between their favorite apps without much manual intervention (although sometimes Android's "Always" "Just once" dialog does annoy me)

Would it be a good idea to put this information on chess programming wiki (maybe under Android section)?
--
Regards,
Asim

For the love of the game http://mychessapps.com
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Chess for Android v4.1.5: sharing

Post by abik »

Excellent. The x-chess-fen indeed seems to gain ground. I had a similar private communication with Gerhard and Peter with the outcome that the correct MIME type should be used to enable applications to register for one but not the other format if it does not make sense to support both.

Code: Select all

application/x-chess-fen  // for FEN contents
application/x-chess-pgn  // for PGN contents
I am about to release an update of Chess for Android that follows this new convention.

A Wiki entry sounds great. Perhaps Gerd would be so kind to get something started so we can all contribute?
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Chess for Android v4.1.5: sharing

Post by abik »

abik wrote:I am about to release an update of Chess for Android that follows this new convention.
Version 4.1.6 available for those that want to experiment with FEN or PGN types.
petero2
Posts: 688
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: Chess for Android v4.1.5: sharing

Post by petero2 »

abik wrote:Thanks Asim. Most details where listed in the Jan 2012 and Jan 2013 blog postings, but I guess it is good to summarize these here, and perhaps discuss further extensions and or conventions.

Two ways of requesting a chess application on Android to view a game in PGN format using data and type is as follows, using the application/x-chess-pgn MIME type.

Code: Select all

  // View game in PGN format that resides in file (with proper permissions for others to view).
  Intent intent = new Intent(Intent.ACTION_VIEW);
  File file = ... file in pgn format ....;
  intent.setDataAndType(Uri.fromFile(file), "application/x-chess-pgn");
  startActivity(intent);

  // View game in PGN format that resides in string (good to avoid 'confusing' characters).
  Intent intent = new Intent(Intent.ACTION_VIEW);  
  String data = ".... game in pgn format ....";
  intent.setDataAndType(Uri.parse(data), "application/x-chess-pgn");
  startActivity(intent);
One way to send a game in PGN format using the extra data mechanism for an intent is as follows (courtesy discussion with Gerhard Kalab).

Code: Select all

    // Send game in PGN format that resides in string.
    Intent intent = new Intent(Intent.ACTION_SEND);
    String data = ".... game in pgn format ....";
    intent.putExtra(Intent.EXTRA_TEXT, data);
    intent.setType("application/x-chess-pgn");
    mycontext.startActivity(intent);
One subtlety to deal with is what action should be used: view (display the data to the user) or send (deliver some data to someone else).
For a chess program, there is probably very little difference between the two, so I recommend to support them both.

Another subtlety is due to the fact that afaik, there is no MIME type for the FEN format. Again, afaik, most chess applications simply tag the data as PGN or text on the sending side, and analyze the contents whether it contains PGN or FEN on the receiving side.

The most important feature is of course the late binding between data and handling application (so never hard-code a handling application name). Users should decide what program to use!

Other chess authors on Android, please chime in with your ideas!
The latest development version of DroidFish now understands intents with action VIEW and SEND, and MIME types application/x-chess-pgn and application/x-chess-fen.

For FEN data, if the FEN is syntactically correct but represents an illegal chess position, DroidFish goes into edit board mode so the user gets a chance to correct the position.

The current development version can be downloaded from http://web.comhem.se/petero2home/upload/DroidFish.apk.