mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-02-17 09:37:50 +01:00
DroidFish: Handle PGN intents with scheme "file".
This commit is contained in:
parent
1c1640d73c
commit
b97303fd5b
|
@ -254,19 +254,22 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
String pgn = null;
|
String pgn = null;
|
||||||
try {
|
try {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if ((intent.getData() != null) && intent.getScheme().equals("content")) {
|
if (intent.getData() != null) {
|
||||||
ContentResolver resolver = getContentResolver();
|
if ("content".equals(intent.getScheme()) ||
|
||||||
InputStream in = resolver.openInputStream(intent.getData());
|
"file".equals(intent.getScheme())) {
|
||||||
StringBuilder sb = new StringBuilder();
|
ContentResolver resolver = getContentResolver();
|
||||||
while (true) {
|
InputStream in = resolver.openInputStream(intent.getData());
|
||||||
byte[] buffer = new byte[16384];
|
StringBuilder sb = new StringBuilder();
|
||||||
int len = in.read(buffer);
|
while (true) {
|
||||||
if (len <= 0)
|
byte[] buffer = new byte[16384];
|
||||||
break;
|
int len = in.read(buffer);
|
||||||
sb.append(new String(buffer, 0, len));
|
if (len <= 0)
|
||||||
|
break;
|
||||||
|
sb.append(new String(buffer, 0, len));
|
||||||
|
}
|
||||||
|
pgn = sb.toString();
|
||||||
}
|
}
|
||||||
pgn = sb.toString();
|
}
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.failed_to_read_pgn_data,
|
Toast.makeText(getApplicationContext(), R.string.failed_to_read_pgn_data,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user