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 #29 from readium/fixes/RTL
Browse files Browse the repository at this point in the history
RTL
  • Loading branch information
aferditamuriqi authored Oct 23, 2018
2 parents 6bf6bbb + 11d191f commit 281ff76
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion r2-shared/src/main/java/org/readium/r2/shared/Metadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Metadata : Serializable {
var inkers: MutableList<Contributor> = mutableListOf()
var narrators: MutableList<Contributor> = mutableListOf()
var imprints: MutableList<Contributor> = mutableListOf()
var direction: String = "default"
var direction: String = PageProgressionDirection.default.name
var subjects: MutableList<Subject> = mutableListOf()
var publishers: MutableList<Contributor> = mutableListOf()
var contributors: MutableList<Contributor> = mutableListOf()
Expand Down Expand Up @@ -84,6 +84,26 @@ class Metadata : Serializable {
return obj
}


fun contentLayoutStyle(langType: LangType, pageDirection: String?) : ContentLayoutStyle {

when(langType) {
LangType.afh -> return ContentLayoutStyle.rtl
LangType.cjk -> {
if (pageDirection == ContentLayoutStyle.rtl.name)
return ContentLayoutStyle.cjkv
else
return ContentLayoutStyle.cjkh
}
else -> {
if (pageDirection == ContentLayoutStyle.rtl.name)
return ContentLayoutStyle.rtl
else
return ContentLayoutStyle.ltr
}
}
}

}

fun parseMetadata(metadataDict: JSONObject): Metadata {
Expand Down Expand Up @@ -243,3 +263,19 @@ fun parseMetadata(metadataDict: JSONObject): Metadata {

return m
}

enum class LangType {
cjk, afh, other
}


enum class PageProgressionDirection {
default,
ltr,
rtl
}

enum class ContentLayoutStyle {
ltr, rtl,
cjkv, cjkh
}

0 comments on commit 281ff76

Please sign in to comment.