Android support (still not useable, just a test)
authorNiki Roo <niki@nikiroo.be>
Mon, 4 Dec 2017 21:33:46 +0000 (22:33 +0100)
committerNiki Roo <niki@nikiroo.be>
Mon, 4 Dec 2017 21:33:46 +0000 (22:33 +0100)
31 files changed:
res/drawable-v24/ic_launcher_foreground.xml [new file with mode: 0644]
res/drawable/ic_launcher_background.xml [new file with mode: 0644]
res/layout/activity_main.xml [new file with mode: 0644]
res/layout/activity_say_it.xml [new file with mode: 0644]
res/layout/fragment_android_reader_book.xml [new file with mode: 0644]
res/layout/fragment_android_reader_group.xml [new file with mode: 0644]
res/mipmap-anydpi-v26/ic_launcher.xml [new file with mode: 0644]
res/mipmap-anydpi-v26/ic_launcher_round.xml [new file with mode: 0644]
res/mipmap-hdpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-hdpi/ic_launcher_round.png [new file with mode: 0644]
res/mipmap-ldpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-ldpi/ic_launcher_round.png [new file with mode: 0644]
res/mipmap-mdpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-mdpi/ic_launcher_round.png [new file with mode: 0644]
res/mipmap-tvdpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-tvdpi/ic_launcher_round.png [new file with mode: 0644]
res/mipmap-xhdpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-xhdpi/ic_launcher_round.png [new file with mode: 0644]
res/mipmap-xxhdpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-xxhdpi/ic_launcher_round.png [new file with mode: 0644]
res/mipmap-xxxhdpi/ic_launcher.png [new file with mode: 0644]
res/mipmap-xxxhdpi/ic_launcher_round.png [new file with mode: 0644]
res/values/colors.xml [new file with mode: 0644]
res/values/strings.xml [new file with mode: 0644]
res/values/styles.xml [new file with mode: 0644]
src/AndroidManifest.xml [new file with mode: 0644]
src/be/nikiroo/fanfix/reader/android/AndroidReader.java [new file with mode: 0644]
src/be/nikiroo/fanfix/reader/android/AndroidReaderActivity.java [new file with mode: 0644]
src/be/nikiroo/fanfix/reader/android/AndroidReaderBook.java [new file with mode: 0644]
src/be/nikiroo/fanfix/reader/android/AndroidReaderGroup.java [new file with mode: 0644]
src/be/nikiroo/fanfix/reader/android/SayIt.java [new file with mode: 0644]

diff --git a/res/drawable-v24/ic_launcher_foreground.xml b/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644 (file)
index 0000000..c7bd21d
--- /dev/null
@@ -0,0 +1,34 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:aapt="http://schemas.android.com/aapt"
+    android:width="108dp"
+    android:height="108dp"
+    android:viewportHeight="108"
+    android:viewportWidth="108">
+    <path
+        android:fillType="evenOdd"
+        android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
+        android:strokeColor="#00000000"
+        android:strokeWidth="1">
+        <aapt:attr name="android:fillColor">
+            <gradient
+                android:endX="78.5885"
+                android:endY="90.9159"
+                android:startX="48.7653"
+                android:startY="61.0927"
+                android:type="linear">
+                <item
+                    android:color="#44000000"
+                    android:offset="0.0" />
+                <item
+                    android:color="#00000000"
+                    android:offset="1.0" />
+            </gradient>
+        </aapt:attr>
+    </path>
+    <path
+        android:fillColor="#FFFFFF"
+        android:fillType="nonZero"
+        android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
+        android:strokeColor="#00000000"
+        android:strokeWidth="1" />
+</vector>
diff --git a/res/drawable/ic_launcher_background.xml b/res/drawable/ic_launcher_background.xml
new file mode 100644 (file)
index 0000000..01f0af0
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector
+    android:height="108dp"
+    android:width="108dp"
+    android:viewportHeight="108"
+    android:viewportWidth="108"
+    xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#26A69A"
+          android:pathData="M0,0h108v108h-108z"/>
+    <path android:fillColor="#00000000" android:pathData="M9,0L9,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,0L19,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M29,0L29,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M39,0L39,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M49,0L49,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M59,0L59,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M69,0L69,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M79,0L79,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M89,0L89,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M99,0L99,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,9L108,9"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,19L108,19"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,29L108,29"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,39L108,39"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,49L108,49"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,59L108,59"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,69L108,69"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,79L108,79"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,89L108,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,99L108,99"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,29L89,29"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,39L89,39"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,49L89,49"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,59L89,59"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,69L89,69"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,79L89,79"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M29,19L29,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M39,19L39,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M49,19L49,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M59,19L59,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M69,19L69,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M79,19L79,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+</vector>
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
new file mode 100644 (file)
index 0000000..6187f32
--- /dev/null
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/mainRoot"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".AndroidReaderActivity">
+
+    <EditText
+        android:id="@+id/editText"
+        android:layout_width="177dp"
+        android:layout_height="38dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginTop="8dp"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="@string/enter_text"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <Button
+        android:id="@+id/button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="8dp"
+        android:layout_marginStart="8dp"
+        android:onClick="onClick"
+        android:text="Download if needed"
+        app:layout_constraintBottom_toBottomOf="@+id/editText"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="1.0"
+        app:layout_constraintStart_toEndOf="@+id/editText" />
+
+    <Button
+        android:id="@+id/button2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="8dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginTop="28dp"
+        android:onClick="buttonClick"
+        android:text="Add all sources"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0.472"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/editText" />
+
+    <LinearLayout
+        android:id="@+id/dropZone"
+        android:layout_width="363dp"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="8dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginTop="88dp"
+        android:orientation="vertical"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/editText"></LinearLayout>
+
+</android.support.constraint.ConstraintLayout>
diff --git a/res/layout/activity_say_it.xml b/res/layout/activity_say_it.xml
new file mode 100644 (file)
index 0000000..527ae08
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="be.nikiroo.testy.be.nikiroo.fanfix.reader.android.SayIt">
+
+    <TextView
+        android:id="@+id/textView"
+        android:layout_width="285dp"
+        android:layout_height="250dp"
+        android:text="TextView"
+        tools:layout_editor_absoluteX="38dp"
+        tools:layout_editor_absoluteY="130dp" />
+</android.support.constraint.ConstraintLayout>
diff --git a/res/layout/fragment_android_reader_book.xml b/res/layout/fragment_android_reader_book.xml
new file mode 100644 (file)
index 0000000..a742c86
--- /dev/null
@@ -0,0 +1,41 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/coverWidget"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:clickable="true"
+    android:focusable="true"
+    android:onClick="onFrag">
+
+    <!-- TODO: Update blank fragment layout -->
+
+    <android.support.constraint.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="8dp"
+            android:layout_marginStart="8dp"
+            android:layout_marginTop="8dp"
+            android:text="TITLE"
+            app:layout_constraintEnd_toStartOf="@+id/cover"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="@+id/cover" />
+
+        <ImageView
+            android:id="@+id/cover"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="8dp"
+            android:layout_marginEnd="8dp"
+            android:layout_marginTop="8dp"
+            android:src="@mipmap/ic_launcher"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+    </android.support.constraint.ConstraintLayout>
+</FrameLayout>
diff --git a/res/layout/fragment_android_reader_group.xml b/res/layout/fragment_android_reader_group.xml
new file mode 100644 (file)
index 0000000..978a2f1
--- /dev/null
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="be.nikiroo.fanfix.reader.android.AndroidReaderGroup">
+
+    <!-- TODO: Update blank fragment layout -->
+
+    <LinearLayout
+        android:id="@+id/AndroidReaderGroup_root"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"></LinearLayout>
+
+</FrameLayout>
diff --git a/res/mipmap-anydpi-v26/ic_launcher.xml b/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644 (file)
index 0000000..bbd3e02
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_background"/>
+    <foreground android:drawable="@drawable/ic_launcher_foreground"/>
+</adaptive-icon>
\ No newline at end of file
diff --git a/res/mipmap-anydpi-v26/ic_launcher_round.xml b/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644 (file)
index 0000000..bbd3e02
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_background"/>
+    <foreground android:drawable="@drawable/ic_launcher_foreground"/>
+</adaptive-icon>
\ No newline at end of file
diff --git a/res/mipmap-hdpi/ic_launcher.png b/res/mipmap-hdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..fb77539
Binary files /dev/null and b/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/res/mipmap-hdpi/ic_launcher_round.png b/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..fb77539
Binary files /dev/null and b/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/res/mipmap-ldpi/ic_launcher.png b/res/mipmap-ldpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..081acc5
Binary files /dev/null and b/res/mipmap-ldpi/ic_launcher.png differ
diff --git a/res/mipmap-ldpi/ic_launcher_round.png b/res/mipmap-ldpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..081acc5
Binary files /dev/null and b/res/mipmap-ldpi/ic_launcher_round.png differ
diff --git a/res/mipmap-mdpi/ic_launcher.png b/res/mipmap-mdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..088c92b
Binary files /dev/null and b/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/res/mipmap-mdpi/ic_launcher_round.png b/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..088c92b
Binary files /dev/null and b/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/res/mipmap-tvdpi/ic_launcher.png b/res/mipmap-tvdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..eab0a4a
Binary files /dev/null and b/res/mipmap-tvdpi/ic_launcher.png differ
diff --git a/res/mipmap-tvdpi/ic_launcher_round.png b/res/mipmap-tvdpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..eab0a4a
Binary files /dev/null and b/res/mipmap-tvdpi/ic_launcher_round.png differ
diff --git a/res/mipmap-xhdpi/ic_launcher.png b/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..9fdb356
Binary files /dev/null and b/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/res/mipmap-xhdpi/ic_launcher_round.png b/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..9fdb356
Binary files /dev/null and b/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/res/mipmap-xxhdpi/ic_launcher.png b/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..469fd7d
Binary files /dev/null and b/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/res/mipmap-xxhdpi/ic_launcher_round.png b/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..469fd7d
Binary files /dev/null and b/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/res/mipmap-xxxhdpi/ic_launcher.png b/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..f7bd70b
Binary files /dev/null and b/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/res/mipmap-xxxhdpi/ic_launcher_round.png b/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644 (file)
index 0000000..f7bd70b
Binary files /dev/null and b/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/res/values/colors.xml b/res/values/colors.xml
new file mode 100644 (file)
index 0000000..3ab3e9c
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimaryDark">#303F9F</color>
+    <color name="colorAccent">#FF4081</color>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644 (file)
index 0000000..fd8ae42
--- /dev/null
@@ -0,0 +1,8 @@
+<resources>
+    <string name="app_name">Fanfix</string>
+    <string name="enter_text">testy</string>
+    <string name="clickit">Click here</string>
+
+    <!-- TODO: Remove or change this placeholder text -->
+    <string name="hello_blank_fragment">Hello blank fragment</string>
+</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644 (file)
index 0000000..ff6c9d2
--- /dev/null
@@ -0,0 +1,8 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
diff --git a/src/AndroidManifest.xml b/src/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..931bcb5
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="be.nikiroo.fanfix.reader.android">
+
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:roundIcon="@mipmap/ic_launcher_round"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+        <activity android:name="be.nikiroo.fanfix.reader.android.AndroidReaderActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity android:name="be.nikiroo.fanfix.reader.android.SayIt" />
+    </application>
+</manifest>
\ No newline at end of file
diff --git a/src/be/nikiroo/fanfix/reader/android/AndroidReader.java b/src/be/nikiroo/fanfix/reader/android/AndroidReader.java
new file mode 100644 (file)
index 0000000..85f07f2
--- /dev/null
@@ -0,0 +1,62 @@
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+
+import java.io.File;
+import java.io.IOException;
+
+import be.nikiroo.fanfix.reader.BasicReader;
+
+public class AndroidReader extends BasicReader {
+       private Activity app;
+
+       /**
+        * Do not use.
+        */
+       private AndroidReader() {
+               // Required for reflection
+       }
+
+       public AndroidReader(Activity app) {
+               this.app = app;
+       }
+
+       @Override
+       public void read() throws IOException {
+       }
+
+       @Override
+       public void browse(String source) {
+       }
+
+       @Override
+       protected void start(File target, String program) throws IOException {
+               if (program == null) {
+                       try {
+                               Intent[] intents = new Intent[] { //
+                               new Intent(Intent.ACTION_VIEW), //
+                                               new Intent(Intent.ACTION_OPEN_DOCUMENT) //
+                               };
+
+                               for (Intent intent : intents) {
+                                       intent.setDataAndType(Uri.parse(target.toURI().toString()),
+                                                       "application/x-cbz");
+                               }
+
+                               Intent chooserIntent = Intent.createChooser(intents[0],
+                                               "Open CBZ in...");
+
+                               // chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
+                               // intents);
+
+                               app.startActivity(chooserIntent);
+                       } catch (UnsupportedOperationException e) {
+                               super.start(target, program);
+                       }
+               } else {
+                       super.start(target, program);
+               }
+       }
+}
diff --git a/src/be/nikiroo/fanfix/reader/android/AndroidReaderActivity.java b/src/be/nikiroo/fanfix/reader/android/AndroidReaderActivity.java
new file mode 100644 (file)
index 0000000..b4d33d7
--- /dev/null
@@ -0,0 +1,135 @@
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Environment;
+import android.view.View;
+import android.widget.EditText;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.fanfix.reader.BasicReader;
+import be.nikiroo.fanfix.reader.Reader;
+import be.nikiroo.utils.TraceHandler;
+
+public class AndroidReaderActivity extends Activity implements
+               AndroidReaderBook.OnFragmentInteractionListener {
+       private static Reader reader = null;
+
+       @Override
+       protected void onCreate(Bundle savedInstanceState) {
+               config();
+               super.onCreate(savedInstanceState);
+               setContentView(R.layout.activity_main);
+       }
+
+       int i = 1;
+
+       public void buttonClick(View view) {
+               AndroidReaderGroup group = null;
+               if (group == null) {
+                       group = new AndroidReaderGroup();
+               }
+
+               FragmentTransaction trans = getFragmentManager().beginTransaction();
+               trans.replace(R.id.dropZone, group);
+               trans.commit();
+               getFragmentManager().executePendingTransactions();
+
+               group.fill(reader, null);
+       }
+
+       public void onClick(View view) {
+               new AsyncTask<Void, Void, String>() {
+                       @Override
+                       protected void onPreExecute() {
+                               EditText editText = findViewById(R.id.editText);
+                               editText.setText("Downloading...");
+                       }
+
+                       @Override
+                       protected String doInBackground(Void... voids) {
+                               try {
+                                       URL[] urls = new URL[] {
+                                                       new URL("https://e621.net/pool/show/13124"),
+                                                       new URL("https://e621.net/pool/show/13121"), };
+
+                                       for (int i = 0; i < urls.length; i++) {
+                                               if (reader.getLibrary().getList().size() <= i) {
+                                                       reader.getLibrary().imprt(urls[i], null);
+                                               }
+                                       }
+
+                                       String message = "";
+                                       for (MetaData meta : reader.getLibrary().getList()) {
+                                               message += meta.getTitle() + "\n";
+                                       }
+
+                                       return message;
+                               } catch (Exception e) {
+                                       return e.getClass() + ": " + e.getMessage();
+                               }
+                       }
+
+                       @Override
+                       protected void onPostExecute(String message) {
+                               EditText editText = findViewById(R.id.editText);
+                               editText.setText("testy");
+
+                               Intent intent = new Intent(AndroidReaderActivity.this,
+                                               SayIt.class);
+                               intent.putExtra(SayIt.MESSAGE, message);
+                               startActivity(intent);
+                       }
+               }.execute();
+       }
+
+       @Override
+       public void onFragmentInteraction(MetaData meta) {
+               AndroidReader reader = new AndroidReader(this);
+               try {
+                       reader.openExternal(Instance.getLibrary(), meta.getLuid());
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private void config() {
+               if (reader != null) {
+                       return;
+               }
+
+               String internal = getExternalFilesDir(null).toString();
+               File user = Environment
+                               .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
+
+               try {
+                       File parent = user.getParentFile();
+                       if (parent.exists() || parent.mkdirs()) {
+                               File test = new File(parent, "test");
+                               if (test.exists() || (test.createNewFile() && test.delete())) {
+                                       user = parent;
+                               }
+                       }
+               } catch (Exception e) {
+                       // Fall back to Documents/Books
+               }
+
+               System.setProperty("DEBUG", "1");
+               System.setProperty("fanfix.home", internal);
+               System.setProperty("fanfix.libdir", new File(user, "Books").toString());
+
+               Instance.resetConfig(false);
+               Instance.setTraceHandler(new TraceHandler(true, true, 2));
+
+               BasicReader.setDefaultReaderType(Reader.ReaderType.ANDROID);
+               reader = BasicReader.getReader();
+       }
+}
\ No newline at end of file
diff --git a/src/be/nikiroo/fanfix/reader/android/AndroidReaderBook.java b/src/be/nikiroo/fanfix/reader/android/AndroidReaderBook.java
new file mode 100644 (file)
index 0000000..5d3f65d
--- /dev/null
@@ -0,0 +1,118 @@
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.graphics.Bitmap;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.io.IOException;
+
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.fanfix.reader.Reader;
+import be.nikiroo.utils.Image;
+import be.nikiroo.utils.android.ImageUtilsAndroid;
+
+public class AndroidReaderBook extends Fragment {
+       private Reader reader;
+       private OnFragmentInteractionListener listener;
+       private MetaData meta;
+
+       /**
+        * This interface must be implemented by activities that contain this
+        * fragment to allow an interaction in this fragment to be communicated to
+        * the activity and potentially other fragments contained in that activity.
+        * <p>
+        * See the Android Training lesson <a href=
+        * "http://developer.android.com/training/basics/fragments/communicating.html"
+        * >Communicating with Other Fragments</a> for more information.
+        */
+       public interface OnFragmentInteractionListener {
+               void onFragmentInteraction(MetaData meta);
+       }
+
+       public AndroidReaderBook() {
+               // Required empty public constructor
+       }
+
+       @Override
+       public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                       Bundle savedInstanceState) {
+               return inflater.inflate(R.layout.fragment_android_reader_book,
+                               container, false);
+       }
+
+       @Override
+       public void onAttach(Activity context) {
+               super.onAttach(context);
+               if (context instanceof OnFragmentInteractionListener) {
+                       listener = (OnFragmentInteractionListener) context;
+               }
+       }
+
+       @Override
+       public void onDetach() {
+               super.onDetach();
+               listener = null;
+       }
+
+       public void fill(final Reader reader, final String luid) {
+               View view = getView();
+               if (view == null) {
+                       return;
+               }
+
+               final ImageView cover = view.findViewById(R.id.cover);
+               final TextView title = view.findViewById(R.id.title);
+               final FrameLayout frame = view.findViewById(R.id.coverWidget);
+
+               new AsyncTask<Void, Void, MetaData>() {
+                       @Override
+                       protected MetaData doInBackground(Void[] objects) {
+                               return Instance.getLibrary().getInfo(luid);
+                       }
+
+                       @Override
+                       protected void onPostExecute(MetaData meta) {
+                               AndroidReaderBook.this.meta = meta;
+
+                               if (meta != null) {
+                                       title.setText(meta.getTitle());
+                                       try {
+                                               Image coverImage = reader.getLibrary().getCover(
+                                                               meta.getLuid());
+                                               if (coverImage != null) {
+                                                       Bitmap coverBitmap = ImageUtilsAndroid
+                                                                       .fromImage(coverImage);
+                                                       coverBitmap = Bitmap.createScaledBitmap(
+                                                                       coverBitmap, 128, 128, true);
+                                                       cover.setImageBitmap(coverBitmap);
+                                               }
+                                       } catch (IOException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+
+                               frame.setClickable(true);
+                               frame.setFocusable(true);
+                               frame.setOnClickListener(new View.OnClickListener() {
+                                       @Override
+                                       public void onClick(View v) {
+                                               OnFragmentInteractionListener llistener = listener;
+                                               if (llistener != null) {
+                                                       llistener
+                                                                       .onFragmentInteraction(AndroidReaderBook.this.meta);
+                                               }
+                                       }
+                               });
+                       }
+               }.execute();
+       }
+}
diff --git a/src/be/nikiroo/fanfix/reader/android/AndroidReaderGroup.java b/src/be/nikiroo/fanfix/reader/android/AndroidReaderGroup.java
new file mode 100644 (file)
index 0000000..d998a8c
--- /dev/null
@@ -0,0 +1,82 @@
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.List;
+
+import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.fanfix.reader.Reader;
+
+/**
+ * A simple {@link Fragment} subclass. Activities that contain this fragment
+ * must implement the {@link AndroidReaderGroup.OnFragmentInteractionListener}
+ * interface to handle interaction events.
+ */
+public class AndroidReaderGroup extends Fragment {
+       private OnFragmentInteractionListener listener;
+
+       public interface OnFragmentInteractionListener {
+               void onFragmentInteraction(MetaData meta);
+       }
+
+       public AndroidReaderGroup() {
+               // Required empty public constructor
+       }
+
+       @Override
+       public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                       Bundle savedInstanceState) {
+               // Inflate the layout for this fragment
+               return inflater.inflate(R.layout.fragment_android_reader_group,
+                               container, false);
+       }
+
+       @Override
+       public void onAttach(Context context) {
+               super.onAttach(context);
+               if (context instanceof OnFragmentInteractionListener) {
+                       listener = (OnFragmentInteractionListener) context;
+               }
+       }
+
+       @Override
+       public void onDetach() {
+               super.onDetach();
+               listener = null;
+       }
+
+       public void fill(final Reader reader, final String source) {
+               new AsyncTask<Void, Void, List<MetaData>>() {
+                       @Override
+                       protected List<MetaData> doInBackground(Void... voids) {
+                               return reader.getLibrary().getListBySource(source);
+                       }
+
+                       @Override
+                       protected void onPostExecute(List<MetaData> metas) {
+                               for (MetaData meta : metas) {
+                                       String tag = "Book_" + meta.getLuid();
+                                       tag = null; // TODO: how does it work?
+                                       AndroidReaderBook book = null;// (AndroidReaderBook)
+                                                                                                       // getFragmentManager().findFragmentByTag(tag);
+                                       if (book == null) {
+                                               book = new AndroidReaderBook();
+                                               FragmentTransaction trans = getFragmentManager()
+                                                               .beginTransaction();
+                                               trans.add(R.id.AndroidReaderGroup_root, book, tag);
+                                               trans.commit();
+                                               getFragmentManager().executePendingTransactions();
+                                       }
+                                       book.fill(reader, meta.getLuid());
+                               }
+                       }
+               }.execute();
+       }
+}
diff --git a/src/be/nikiroo/fanfix/reader/android/SayIt.java b/src/be/nikiroo/fanfix/reader/android/SayIt.java
new file mode 100644 (file)
index 0000000..1346506
--- /dev/null
@@ -0,0 +1,25 @@
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.TextView;
+
+
+public class SayIt extends Activity {
+    public static final String MESSAGE = "be.nikiroo.testy.message";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_say_it);
+
+        // Get the Intent that started this activity and extract the string
+        Intent intent = getIntent();
+        String message = intent.getStringExtra(SayIt.MESSAGE);
+
+        // Capture the layout's TextView and set the string as its text
+        TextView textView = findViewById(R.id.textView);
+        textView.setText(message);
+    }
+}