update nikiroo-utils
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / android / AndroidReader.java
CommitLineData
64968418
NR
1package be.nikiroo.fanfix.reader.android;
2
3import android.app.Activity;
4import android.content.Intent;
5import android.net.Uri;
6
7import java.io.File;
8import java.io.IOException;
9
10import be.nikiroo.fanfix.reader.BasicReader;
11
12public class AndroidReader extends BasicReader {
13 private Activity app;
14
15 /**
16 * Do not use.
17 */
18 private AndroidReader() {
19 // Required for reflection
20 }
21
22 public AndroidReader(Activity app) {
23 this.app = app;
24 }
25
26 @Override
350bc060 27 public void read(boolean sync) throws IOException {
64968418
NR
28 }
29
30 @Override
31 public void browse(String source) {
32 }
33
34 @Override
350bc060 35 protected void start(File target, String program, boolean sync) throws IOException {
64968418
NR
36 if (program == null) {
37 try {
38 Intent[] intents = new Intent[] { //
39 new Intent(Intent.ACTION_VIEW), //
40 new Intent(Intent.ACTION_OPEN_DOCUMENT) //
41 };
42
43 for (Intent intent : intents) {
44 intent.setDataAndType(Uri.parse(target.toURI().toString()),
45 "application/x-cbz");
46 }
47
48 Intent chooserIntent = Intent.createChooser(intents[0],
49 "Open CBZ in...");
50
51 // chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
52 // intents);
53
54 app.startActivity(chooserIntent);
55 } catch (UnsupportedOperationException e) {
350bc060 56 super.start(target, program, sync);
64968418
NR
57 }
58 } else {
350bc060 59 super.start(target, program, sync);
64968418
NR
60 }
61 }
62}