Skip to content

Commit b69db6a

Browse files
Merge pull request #58 from readium/develop
1.1.3
2 parents 9aa1509 + 1bb779c commit b69db6a

File tree

15 files changed

+111
-345
lines changed

15 files changed

+111
-345
lines changed

readium/lcp/.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @aferditamuriqi

readium/lcp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.iml
12
/local.properties
23
/.idea/workspace.xml
34
/.idea/libraries

readium/lcp/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.31'
5-
ext.r2branch = 'develop'
4+
ext.kotlin_version = '1.3.61'
65

76
repositories {
87
google()
98
jcenter()
109
}
1110
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.4.1'
11+
classpath 'com.android.tools.build:gradle:3.5.3'
1312
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1413
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1514
// NOTE: Do not place your application dependencies here; they belong

readium/lcp/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

readium/lcp/r2-lcp/build.gradle

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,24 @@ apply plugin: 'com.github.dcendents.android-maven'
1414
group='com.github.readium'
1515

1616
android {
17-
flavorDimensions "testapp"
1817

19-
compileSdkVersion 28
18+
compileSdkVersion 29
2019

2120
defaultConfig {
2221
minSdkVersion 21
23-
targetSdkVersion 28
24-
22+
targetSdkVersion 29
2523
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
26-
24+
}
25+
compileOptions {
26+
sourceCompatibility 1.8
27+
targetCompatibility 1.8
2728
}
2829
buildTypes {
2930
release {
3031
minifyEnabled false
3132
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3233
}
3334
}
34-
productFlavors {
35-
intTestapp {
36-
dimension "testapp"
37-
}
38-
intTestappWithLcp {
39-
dimension "testapp"
40-
}
41-
devTestapp {
42-
dimension "testapp"
43-
}
44-
devTestappWithLcp {
45-
dimension "testapp"
46-
}
47-
}
48-
49-
// default build flavour
50-
defaultPublishConfig "intTestappDebug"
5135
}
5236

5337
dependencies {
@@ -58,10 +42,10 @@ dependencies {
5842
if (findProject(':r2-shared')) {
5943
implementation project(':r2-shared')
6044
} else {
61-
implementation "com.github.readium:r2-shared-kotlin:1.0.10"
45+
implementation "com.github.readium:r2-shared-kotlin:1.1.6"
6246
}
6347

64-
implementation project(':liblcp')
48+
implementation "readium:liblcp:1.0.0@aar"
6549

6650
implementation('com.mcxiaoke.koi:core:0.5.5') {
6751
exclude module: 'support-v4'
@@ -84,7 +68,7 @@ dependencies {
8468
implementation 'nl.komponents.kovenant:kovenant-jvm:3.3.0'
8569
implementation 'nl.komponents.kovenant:kovenant-functional:3.3.0'
8670

87-
implementation 'org.zeroturnaround:zt-zip:1.12'
71+
implementation 'org.zeroturnaround:zt-zip:1.13'
8872

8973
testImplementation 'junit:junit:4.12'
9074
androidTestImplementation 'androidx.test:runner:1.2.0'

readium/lcp/r2-lcp/r2-lcp.iml

Lines changed: 0 additions & 236 deletions
This file was deleted.

readium/lcp/r2-lcp/src/main/java/org/readium/r2/lcp/license/License.kt

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import nl.komponents.kovenant.Promise
1616
import nl.komponents.kovenant.then
1717
import org.joda.time.DateTime
1818
import org.readium.lcp.sdk.Lcp
19+
import org.readium.r2.lcp.BuildConfig.DEBUG
1920
import org.readium.r2.lcp.license.model.LicenseDocument
2021
import org.readium.r2.lcp.license.model.StatusDocument
2122
import org.readium.r2.lcp.public.*
@@ -56,7 +57,7 @@ class License(private var documents: ValidatedDocuments,
5657
return charactersLeft
5758
}
5859
} catch (error: Error) {
59-
Timber.e(error)
60+
if (DEBUG) Timber.e(error)
6061
}
6162
return null
6263
}
@@ -77,7 +78,7 @@ class License(private var documents: ValidatedDocuments,
7778
charactersLeft = maxOf(0, charactersLeft - result.length)
7879
licenses.setCopiesLeft(charactersLeft, license.id)
7980
} catch (error: Error) {
80-
Timber.e(error)
81+
if (DEBUG) Timber.e(error)
8182
}
8283
return result
8384
}
@@ -90,7 +91,7 @@ class License(private var documents: ValidatedDocuments,
9091
return pagesLeft
9192
}
9293
} catch (error: Error) {
93-
Timber.e(error)
94+
if (DEBUG) Timber.e(error)
9495
}
9596
return null
9697
}
@@ -106,7 +107,7 @@ class License(private var documents: ValidatedDocuments,
106107
pagesLeft = maxOf(0, pagesLeft - pagesCount)
107108
licenses.setPrintsLeft(pagesLeft, license.id)
108109
} catch (error: Error) {
109-
Timber.e(error)
110+
if (DEBUG) Timber.e(error)
110111
}
111112
return true
112113
}
@@ -161,7 +162,6 @@ class License(private var documents: ValidatedDocuments,
161162
if (link.type == "text/html") {
162163
callHTML(url, params) {
163164
validateStatusDocument(it)
164-
165165
}
166166
} else {
167167
callPUT(url, params) {
@@ -171,7 +171,7 @@ class License(private var documents: ValidatedDocuments,
171171
} catch (e: LCPError) {
172172
completion(LCPError.wrap(e))
173173
}
174-
174+
completion(null)
175175
}
176176

177177
override val canReturnPublication: Boolean
@@ -197,6 +197,7 @@ class License(private var documents: ValidatedDocuments,
197197
}
198198
completion(null)
199199
}
200+
completion(null)
200201
}
201202

202203
init {
@@ -209,7 +210,7 @@ class License(private var documents: ValidatedDocuments,
209210

210211
fun moveLicense(archivePath: String, licenseData: ByteArray) {
211212
val pathInZip = "META-INF/license.lcpl"
212-
Timber.i("LCP moveLicense")
213+
if (DEBUG) Timber.i("LCP moveLicense")
213214
val source = File(archivePath)
214215
val tmpZip = File("$archivePath.tmp")
215216
tmpZip.delete()
@@ -227,16 +228,26 @@ class License(private var documents: ValidatedDocuments,
227228
val title = license.link(LicenseDocument.Rel.publication)?.title
228229
val url = license.url(LicenseDocument.Rel.publication)
229230

230-
val rootDir: String = context.getExternalFilesDir(null)?.path + "/"
231+
val properties = Properties()
232+
val inputStream = context.assets.open("configs/config.properties")
233+
properties.load(inputStream)
234+
val useExternalFileDir = properties.getProperty("useExternalFileDir", "false")!!.toBoolean()
235+
236+
val rootDir: String = if (useExternalFileDir) {
237+
context.getExternalFilesDir(null)?.path + "/"
238+
} else {
239+
context.filesDir.path + "/"
240+
}
241+
231242
val fileName = UUID.randomUUID().toString()
232243
return Fuel.download(url.toString()).destination { _, _ ->
233-
Timber.i("LCP destination %s%s", rootDir, fileName)
244+
if (DEBUG) Timber.i("LCP destination %s%s", rootDir, fileName)
234245
File(rootDir, fileName)
235246

236247
}.promise() then {
237248
val (_, response, _) = it
238-
Timber.i("LCP destination %s%s", rootDir, fileName)
239-
Timber.i("LCP then %s", response.url.toString())
249+
if (DEBUG) Timber.i("LCP destination %s%s", rootDir, fileName)
250+
if (DEBUG) Timber.i("LCP then %s", response.url.toString())
240251

241252
rootDir + fileName
242253

0 commit comments

Comments
 (0)