Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from readium/develop
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
aferditamuriqi authored Jun 11, 2018
2 parents 029e5b4 + 2af214b commit ebcd5bd
Show file tree
Hide file tree
Showing 27 changed files with 361 additions and 91 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.10'
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -19,6 +19,7 @@ allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
:END
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

Expand Down
20 changes: 14 additions & 6 deletions r2-shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ group='com.github.readium'

android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
buildToolsVersion "27.0.3"


defaultConfig {
Expand All @@ -27,15 +27,23 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.github.kittinunf.fuel:fuel:1.12.1' //for JVM
implementation 'com.github.kittinunf.fuel:fuel-android:1.12.1' //for Android
implementation 'nl.komponents.kovenant:kovenant:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-core:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-android:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-combine:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-jvm:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-functional:3.3.0'

testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:2.12.0"
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

}
90 changes: 53 additions & 37 deletions r2-shared/r2-shared.iml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
</configuration>
</facet>
<facet type="kotlin-language" name="Kotlin">
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
<configuration version="3" platform="JVM 1.6" useProjectSettings="false">
<compilerSettings />
<compilerArguments>
<option name="destination" value="$MODULE_DIR$/build/tmp/kotlin-classes/debug" />
<option name="noStdlib" value="true" />
<option name="noReflect" value="true" />
<option name="moduleName" value="r2-shared_debug" />
<option name="jvmTarget" value="1.8" />
<option name="addCompilerBuiltIns" value="true" />
<option name="loadBuiltInsFromDependencies" value="true" />
<option name="languageVersion" value="1.2" />
Expand All @@ -44,7 +43,7 @@
</option>
<option name="pluginClasspaths">
<array>
<option value="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-android-extensions/1.2.10/10eb9a3d66aa7c5e17afdf93116082018d0d4643/kotlin-android-extensions-1.2.10.jar" />
<option value="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-android-extensions/1.2.41/10100eedfe2e26b9cf18b850d997b42d02af7500/kotlin-android-extensions-1.2.41.jar" />
</array>
</option>
</compilerArguments>
Expand Down Expand Up @@ -120,6 +119,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-aidl" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
Expand All @@ -129,39 +131,53 @@
</content>
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="com.android.support:animated-vector-drawable-27.0.2" level="project" />
<orderEntry type="library" name="com.android.support:appcompat-v7-27.0.2" level="project" />
<orderEntry type="library" name="com.android.support:support-annotations:27.0.2@jar" level="project" />
<orderEntry type="library" scope="TEST" name="net.bytebuddy:byte-buddy:1.7.9@jar" level="project" />
<orderEntry type="library" scope="TEST" name="junit:junit:4.12@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test.espresso:espresso-core-3.0.1" level="project" />
<orderEntry type="library" name="org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.10@jar" level="project" />
<orderEntry type="library" scope="TEST" name="javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="org.jetbrains.kotlin:kotlin-stdlib:1.2.10@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="org.jetbrains.kotlin:kotlin-test-junit:1.2.10@jar" level="project" />
<orderEntry type="library" name="com.google.code.gson:gson:2.8.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:runner-1.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test:rules-1.0.1" level="project" />
<orderEntry type="library" name="android.arch.lifecycle:runtime-1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="org.mockito:mockito-core:2.12.0@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-vector-drawable-27.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" name="org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.10@jar" level="project" />
<orderEntry type="library" scope="TEST" name="com.android.support.test.espresso:espresso-idling-resource-3.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="org.objenesis:objenesis:2.6@jar" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" name="android.arch.lifecycle:common:1.0.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="net.bytebuddy:byte-buddy-agent:1.7.9@jar" level="project" />
<orderEntry type="library" name="android.arch.core:common:1.0.0@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-core-ui-27.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-compat-27.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="net.sf.kxml:kxml2:2.3.0@jar" level="project" />
<orderEntry type="library" name="org.jetbrains:annotations:13.0@jar" level="project" />
<orderEntry type="library" name="com.android.support:support-core-utils-27.0.2" level="project" />
<orderEntry type="library" name="com.android.support:support-fragment-27.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="org.jetbrains.kotlin:kotlin-test:1.2.10@jar" level="project" />
<orderEntry type="library" name="Gradle: com.github.kittinunf.result:result:1.3.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.bytebuddy:byte-buddy-agent:1.7.9@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.objenesis:objenesis:2.6@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: nl.komponents.kovenant:kovenant-functional:3.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test:1.2.41@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test-annotations-common:1.2.41@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.bytebuddy:byte-buddy:1.7.9@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.github.kittinunf.fuel:fuel-android-1.12.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.2.41@jar" level="project" />
<orderEntry type="library" name="Gradle: com.github.kittinunf.fuel:fuel:1.12.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.41@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test-common:1.2.41@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: nl.komponents.kovenant:kovenant-ui:3.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.41@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0@jar" level="project" />
<orderEntry type="library" name="Gradle: nl.komponents.kovenant:kovenant-android:3.3.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" name="Gradle: nl.komponents.kovenant:kovenant-jvm:3.3.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core-3.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="Gradle: nl.komponents.kovenant:kovenant-core:3.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.mockito:mockito-core:2.12.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:monitor-1.0.2" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource-3.0.2" level="project" />
<orderEntry type="library" name="Gradle: nl.komponents.kovenant:kovenant-combine:3.3.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test-junit:1.2.41@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.8.2@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.1.0" level="project" />
</component>
</module>
9 changes: 9 additions & 0 deletions r2-shared/src/main/java/org/readium/r2/shared/Collection.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.readium.r2.shared

data class Collection(var name: String) {
var sortAs: String? = null
var identifier: String? = null
var position: Double? = null
var links:MutableList<Link> = mutableListOf()

}
2 changes: 2 additions & 0 deletions r2-shared/src/main/java/org/readium/r2/shared/Contributor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Contributor : JSONable, Serializable {
var multilangName:MultilangString = MultilangString()
var sortAs: String? = null
var roles: MutableList<String> = mutableListOf()
var links: MutableList<Link> = mutableListOf()
var identifier: String? = null

var name: String? = null
get() = multilangName.singleString
Expand Down
23 changes: 0 additions & 23 deletions r2-shared/src/main/java/org/readium/r2/shared/Drm.kt

This file was deleted.

3 changes: 2 additions & 1 deletion r2-shared/src/main/java/org/readium/r2/shared/Encryption.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.readium.r2.shared

import org.readium.r2.shared.drm.Drm
import java.io.Serializable

// Contains metadata parsed from Encryption.xml
Expand All @@ -16,5 +17,5 @@ class Encryption : Serializable{
// Identifies the encryption profile used to encrypt the resource
var profile: String? = null
// Identifies the encrytpion scheme used to encrypt the resource
var scheme: String? = null
var scheme: Drm.Scheme? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.readium.r2.shared

import com.github.kittinunf.fuel.core.Request
import com.github.kittinunf.fuel.core.Response
import com.github.kittinunf.result.Result
import nl.komponents.kovenant.Promise
import nl.komponents.kovenant.deferred
import nl.komponents.kovenant.task

fun Request.promise(): Promise<Triple<Request, Response, ByteArray>, Exception> {
val deferred = deferred<Triple<Request, Response, ByteArray>, Exception>()
task { response() } success {
val (request, response, result) = it
when(result) {
is Result.Success -> deferred.resolve(Triple(request, response, result.value))
is Result.Failure -> deferred.reject(result.error)
}
} fail {
deferred.reject(it)
}
return deferred.promise
}

val Response.contentTypeEncoding: String
get() = contentTypeEncoding()

fun Response.contentTypeEncoding(default: String = "utf-8"): String {
val contentType: String = httpResponseHeaders["Content-Type"]?.first() ?: return default
return contentType.substringAfterLast("charset=", default).substringAfter(' ', default)
}
11 changes: 7 additions & 4 deletions r2-shared/src/main/java/org/readium/r2/shared/Link.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.io.Serializable
import java.sql.Timestamp

// A link to a resource
class Link : JSONable, Serializable{
class Link : JSONable, Serializable {

private val TAG = this::class.java.simpleName

Expand All @@ -22,18 +22,21 @@ class Link : JSONable, Serializable{

var title: String? = null
/// Properties associated to the linked resource.
var properties: Properties? = null
var properties: Properties = Properties()
/// Indicates the length of the linked resource in seconds.
var duration: Timestamp? = null
var duration: Double? = null
/// Indicates that the linked resource is a URI template.
var templated: Boolean? = false
/// Indicate the bitrate for the link resource.
var bitrate: Int? = null

// The underlaying nodes in a tree structure of Links
var children: MutableList<Link> = mutableListOf()
// The MediaOverlays associated to the resource of the Link
var mediaOverlays: MediaOverlays? = null

fun isEncrypted() : Boolean {
return properties?.encryption != null
return properties.encryption != null
}

override fun getJSON(): JSONObject {
Expand Down
9 changes: 8 additions & 1 deletion r2-shared/src/main/java/org/readium/r2/shared/Metadata.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.readium.r2.shared

import org.json.JSONObject
import org.readium.r2.shared.metadata.BelongsTo
import java.io.Serializable
import java.util.*

class Metadata : Serializable {

Expand Down Expand Up @@ -31,15 +33,20 @@ class Metadata : Serializable {
var subjects: MutableList<Subject> = mutableListOf()
var publishers: MutableList<Contributor> = mutableListOf()
var contributors: MutableList<Contributor> = mutableListOf()
var modified: String? = null
var modified: Date? = null
var publicationDate: String? = null
var description: String? = null
var rendition: Rendition = Rendition()
var source: String? = null
var epubType: MutableList<String> = mutableListOf()
var rights: String? = null
var rdfType: String? = null
var otherMetadata: MutableList<MetadataItem> = mutableListOf()

var belongsTo: BelongsTo? = null

var duration: Int? = null

fun titleForLang(key: String) : String? = multilangTitle?.multiString?.get(key)

fun writeJSON() : JSONObject{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class MultilangString : Serializable{
private val TAG = this::class.java.simpleName

var singleString: String? = null
var multiString: Map<String, String> = mapOf()
var multiString: MutableMap<String, String> = mutableMapOf()

}
Loading

0 comments on commit ebcd5bd

Please sign in to comment.