This commit is contained in:
lunaticbum 2024-08-22 20:38:56 +09:00
parent 0232c9dad0
commit 06e95de43d
13 changed files with 469 additions and 313 deletions

View File

@ -7,12 +7,12 @@ plugins {
android { android {
namespace 'com.mime.dualscreenview' namespace 'com.mime.dualscreenview'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
applicationId "com.mime.dualscreenview" applicationId "com.mime.dualscreenview"
minSdk 24 minSdk 24
targetSdk 33 targetSdk 34
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -43,24 +43,23 @@ android {
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.collection:collection-ktx:1.2.0' implementation 'androidx.collection:collection-ktx:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.12.0'
implementation 'com.google.android.material:material:1.8.0'
implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.code.gson:gson:2.10.1'
// implementation files('libs/DualScreen.jar') // implementation files('libs/DualScreen.jar')
implementation 'io.realm.kotlin:library-base:1.6.0' implementation 'io.realm.kotlin:library-base:1.16.0'
testImplementation 'junit:junit:4.13.2' // testImplementation 'junit:junit:4.13.2'
} }

View File

@ -126,6 +126,6 @@ open class Base : AppCompatActivity() {
return false return false
} }
fun openRealm() : Realm = HistoryManager.openRealm() fun openRealm() : Realm = HistoryManager.openRealm
} }

View File

@ -58,6 +58,9 @@ import com.mime.dualscreenview.webcontents.contentsinfo.GotoSomeWhere
import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.ext.copyFromRealm import io.realm.kotlin.ext.copyFromRealm
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import java.lang.System.currentTimeMillis import java.lang.System.currentTimeMillis
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
@ -106,8 +109,8 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
mBaseWebContentsViewer = BaseWebContentsViewer(it,this) mBaseWebContentsViewer = BaseWebContentsViewer(it,this)
} }
paged_layer =findViewById<PagedTextLayout>(R.id.paged_layer) paged_layer = findViewById<PagedTextLayout>(R.id.paged_layer)
textview_title =findViewById<TextView>(R.id.textview_title) textview_title = findViewById<TextView>(R.id.textview_title)
findViewById<ImageButton>(R.id.btn_list).setOnClickListener { v -> findViewById<ImageButton>(R.id.btn_list).setOnClickListener { v ->
mBaseWebContentsViewer?.webview?.url?.let { mBaseWebContentsViewer?.webview?.url?.let {
@ -170,7 +173,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
realm.query<HistoryItem>()?.find()?.let { realm.query<HistoryItem>()?.find()?.let {
showHistory(realm.copyFromRealm(it)) showHistory(realm.copyFromRealm(it))
} }
realm.close()
} }
@ -185,8 +187,61 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
fun loadLastInfo(){ fun loadLastInfo(){
val realm = openRealm() val realm = openRealm()
try { lastInfo = realm?.query<LastInfo>()?.find()?.last()?.copyFromRealm() } catch (e : Exception) { } try { lastInfo = realm?.query<LastInfo>()?.find()?.last()?.copyFromRealm()
realm.close() try {
if (lastInfo != null) {
HistoryManager.getBooPageInfo(Uri.parse(lastInfo!!.pageUrl!!).path!!) {
it?.let {
currentBooinfo = it
paged_layer.text = it!!.contents!!
paged_layer.visibility = VISIBLE
if(it?.pathUrl?.length ?: 0 > 0) {
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
}
it?.pathUrl?.let {
HistoryManager.getBooInfo(it) {
saveItem(it)
}
}
}
HistoryManager.openRealm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) {
realm.copyFromRealm(it.first()).let {
runOnUiThread {
paged_layer.setTextSize(it.textSize?.toFloat()?: 14f)
paged_layer.setLineSpacing(it.lineSpace?.toFloat() ?: 1f)
paged_layer.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f)
paged_layer.setPadding(
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1)
var typeface = typesfacez.get(getIndex(typesfacez as PairArray<Any>,it.font ?: ""))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
paged_layer.setTypeface(resources.getFont(typeface.second))
}
val color = colorz.get(it.style ?: 0)
paged_layer.setColorStyle(color.second)
}
}
}
}
}
}
}
}catch (e1 : Exception){
}} catch (e : Exception) { }
} }
fun reloadLastInfo() { fun reloadLastInfo() {
val configuration: Configuration = getResources().getConfiguration() val configuration: Configuration = getResources().getConfiguration()
@ -240,7 +295,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
realm.close()
infos?.bookPageUrl?.let { infos?.bookPageUrl?.let {
HistoryManager.getBooInfo(it){ HistoryManager.getBooInfo(it){
it?.let { it?.let {
@ -274,7 +328,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
fun proceedLastPage() { fun proceedLastPage() {
var realm = HistoryManager.openRealm() var realm = HistoryManager.openRealm
realm.query<ReaderConfig>()?.find()?.let { realm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) { if (it.size > 0) {
realm.copyFromRealm(it.first())?.let { realm.copyFromRealm(it.first())?.let {
@ -285,7 +339,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
} }
realm.close()
reloadLastInfo() reloadLastInfo()
reloadTo(lastInfo) reloadTo(lastInfo)
} }
@ -333,7 +386,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
this.delete(it) this.delete(it)
} }
} }
realm.close()
dialog.dismiss() dialog.dismiss()
}) })
builderInner.setNegativeButton("취소", builderInner.setNegativeButton("취소",
@ -388,40 +440,33 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
override fun onPageFinished(webView: WebView?, url: String?) { override fun onPageFinished(webView: WebView?, url: String?) {
super.onPageFinished(webView, url) super.onPageFinished(webView, url)
isLoading = false isLoading = false
var ramdomTimeSec = 1500L + Random(System.currentTimeMillis()).nextLong().rem(2999) var ramdomTimeSec = 1000L + Random(System.currentTimeMillis()).nextLong().rem(3999)
Blog.LOGE("ramdomTime >>> ${ramdomTimeSec}") Blog.LOGE("ramdomTime >>> ${ramdomTimeSec}")
webView?.postDelayed( { webView?.postDelayed( {
Blog.LOGE("saveClient >>> ${isLoading} ${url}") Blog.LOGE("saveClient >>> ${isLoading} ${url}")
var findContents = Booktoki.getFindContentsJs() var findContents = Booktoki.getFindContentsJs()
Blog.LOGE("saveClient find >>> ${findContents}")
Random(System.currentTimeMillis()).nextLong().rem(999)
webView?.evaluateJavascript(findContents){ result: String? -> webView?.evaluateJavascript(findContents){ result: String? ->
Blog.LOGE("saveClient result >>> ${result}")
result?.let { string: String -> result?.let { string: String ->
Blog.LOGE("saveClient contents >>> ${string.length}") Blog.LOGE("saveClient contents >>> ${string.length}")
if (string.length > 10) { if (string.length > 10) {
Blog.LOGE("saveClient it.length >>> ${string.length}") Blog.LOGE("saveClient it.length >>> ${string.length}")
var contents = string.replace("\\\"", "\"") var contents = string.replace("\\\"","\"")
contents = contents = (contents.replace("\\n", System.getProperty("line.separator")))
(contents.replace("\\n", System.getProperty("line.separator"))) contents = (contents.replace("\\n", System.getProperty("line.separator")))
Blog.LOGE("saveClient contents >>> ${contents.length}") Blog.LOGE("saveClient contents >>> ${contents.length}")
Uri.parse(url)?.let { Uri.parse(url)?.let {
it.path?.let { it.path?.let {
HistoryManager.getBooPageInfo(it) { HistoryManager.getBooPageInfo(it) { info ->
HistoryManager.openRealm().apply {
this.writeBlocking {
it?.contents = contents
if (it != null) {
copyToRealm(it, UpdatePolicy.ALL)
}
}
}.close()
runOnUiThread { runOnUiThread {
it?.let { info?.let {
var origin = it.getTitleItem() HistoryManager.openRealm.writeBlocking {
it.contents = contents
}
var origin = info.getTitleItem()
val biggerText = SpannableStringBuilder(origin) val biggerText = SpannableStringBuilder(origin)
biggerText.setSpan(RelativeSizeSpan(1.6f), 0, origin.length, 0) biggerText.setSpan(RelativeSizeSpan(1.6f), 0, origin.length, 0)
Toast.makeText(baseContext,biggerText, Toast.LENGTH_LONG).apply { Toast.makeText(baseContext,biggerText, Toast.LENGTH_SHORT).apply {
setGravity(Gravity.CENTER, 0, 0) setGravity(Gravity.CENTER, 0, 0)
}.show() }.show()
} }
@ -430,7 +475,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
} }
var ramdomTime = 10000L + Random(System.currentTimeMillis()).nextLong().rem(9999) var ramdomTime = 8000L + Random(System.currentTimeMillis()).nextLong().rem(7999)
Blog.LOGE("ramdomTime >>> ${ramdomTime}") Blog.LOGE("ramdomTime >>> ${ramdomTime}")
contentsSaver?.postDelayed( { saveItem(null) }, ramdomTime) contentsSaver?.postDelayed( { saveItem(null) }, ramdomTime)
} }
@ -441,9 +486,10 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
var saveTarget : ArrayList<BookPageInfo> = arrayListOf() var saveTarget : ArrayList<BookPageInfo> = arrayListOf()
private fun saveItem(infos: BookPageInfos?) { private fun saveItem(infos: BookPageInfos?) {
Blog.LOGE("saveItem >>> infos?.pages ${infos?.pages?.size ?: 0}") Blog.LOGE("saveItem >>> infos?.pages ${infos?.pages?.size ?: 0}")
var savedCount = Random(System.currentTimeMillis()).nextLong().rem(19) + 6L var savedCount = Math.abs(Random(System.currentTimeMillis()).nextLong().rem(19) + 6L)
Blog.LOGE("saveItem >>> targetCount = ${savedCount}")
infos?.pages?.reversed()?.forEach { infos?.pages?.reversed()?.forEach {
if (it.contents?.length ?: 0 > 10) { if ((it.contents?.length ?: 0) > 10) {
} else { } else {
if (saveTarget.size < savedCount.toInt()) { if (saveTarget.size < savedCount.toInt()) {
saveTarget.add(it) saveTarget.add(it)
@ -454,7 +500,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
Blog.LOGE("saveItem >>> saveTarget ${saveTarget.count()}") Blog.LOGE("saveItem >>> saveTarget ${saveTarget.count()}")
if (isLoading == false) { if (isLoading == false) {
try { try {
saveTarget?.removeFirst()?.let { saveTarget.removeFirst().let {
Blog.LOGE("saveItem >>> ${it.pathUrl}") Blog.LOGE("saveItem >>> ${it.pathUrl}")
runOnUiThread { runOnUiThread {
mBaseWebContentsViewer.webview.url?.let { currentUrl -> mBaseWebContentsViewer.webview.url?.let { currentUrl ->
@ -521,7 +567,49 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && (paged_layer!!.current() < paged_layer!!.size() - 1) ) { if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && (paged_layer!!.current() < paged_layer!!.size() - 1) ) {
paged_layer!!.doNext(fast) paged_layer!!.doNext(fast)
updateLastInfo(paged_layer!!) updateLastInfo(paged_layer!!)
}else { } else {
val pathUrl = currentBooinfo?.pathUrl
if (pathUrl != null && pathUrl.length > 6) {
HistoryManager.getNextPage(pathUrl) {
currentBooinfo = it
paged_layer.text = it!!.contents!!
Blog.LOGE("HistoryManager.getNextPage(${it})")
if ((it?.contents?.length ?: 0) > 10) {
paged_layer.visibility = VISIBLE
if((it?.pathUrl?.length ?: 0) > 0) {
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
}
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
}
applyReaderConfig()
} else {
if(it?.pathUrl?.length ?: 0 > 0) {
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
paged_layer.visibility = GONE
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
paged_layer.visibility = GONE
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
}
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
}
}
it?.pathUrl?.let {
HistoryManager.getBooInfo(it) {
saveItem(it)
}
}
}
} else {
Uri.parse(mBaseWebContentsViewer.webview.url)?.let { Uri.parse(mBaseWebContentsViewer.webview.url)?.let {
it.path?.let { it.path?.let {
HistoryManager.getNextPage(it) { HistoryManager.getNextPage(it) {
@ -530,12 +618,25 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
currentBooinfo = it currentBooinfo = it
paged_layer.text = it!!.contents!! paged_layer.text = it!!.contents!!
paged_layer.visibility = VISIBLE paged_layer.visibility = VISIBLE
if(it?.pathUrl?.length ?: 0 > 0) { if (it?.pathUrl?.length ?: 0 > 0) {
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) HistoryManager.save(
historyItem = HistoryItem().putHistory(
it,
mBaseWebContentsViewer.webview.url!!
)
)
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})") Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) { if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith(
"http"
)
) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})") Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!)) mBaseWebContentsViewer.webview.loadUrl(
lastInfo!!.pageUrl!!.replace(
Uri.parse(lastInfo!!.pageUrl)!!.path!!,
it?.pathUrl!!
)
)
} else { } else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})") Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
@ -547,28 +648,30 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
} else { } else {
if(it?.pathUrl?.length ?: 0 > 0) { if (it?.pathUrl?.length ?: 0 > 0) {
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) HistoryManager.save(historyItem = HistoryItem().putHistory(it, mBaseWebContentsViewer.webview.url!!))
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})") Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) { if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})") Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!)) mBaseWebContentsViewer.webview.loadUrl(
lastInfo!!.pageUrl!!.replace(
Uri.parse(lastInfo!!.pageUrl)!!.path!!,
it?.pathUrl!!
)
)
paged_layer?.visibility = GONE paged_layer?.visibility = GONE
} else { } else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})") Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
paged_layer?.visibility = GONE paged_layer?.visibility = GONE
} }
it?.pathUrl?.let {
HistoryManager.getBooInfo(it) {
saveItem(it)
}
}
}
}
} }
} }
it?.pathUrl?.let { HistoryManager.getBooInfo(it) { saveItem(it) } }
}
}
}
} }
// onNextClickAction?.let { it() } // onNextClickAction?.let { it() }
} }
@ -585,11 +688,80 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
fun applyReaderConfig() {
var realm = HistoryManager.openRealm
realm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) {
realm.copyFromRealm(it.first())?.let {
runOnUiThread {
paged_layer.setTextSize(it.textSize?.toFloat()?: 14f)
paged_layer.setLineSpacing(it.lineSpace?.toFloat() ?: 1f)
paged_layer.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f)
paged_layer.setPadding(
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1)
var typeface = typesfacez.get(getIndex(typesfacez as PairArray<Any>,it.font ?: ""))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
paged_layer?.setTypeface(resources.getFont(typeface.second))
}
val color = colorz.get(it.style ?: 0)
paged_layer?.setColorStyle(color.second)
}
}
}
}
}
fun actionPrevEvent(fast : Boolean = false) { fun actionPrevEvent(fast : Boolean = false) {
if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && paged_layer!!.current() > 0 ) { if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && paged_layer!!.current() > 0 ) {
paged_layer!!.doPrev(fast) paged_layer!!.doPrev(fast)
updateLastInfo(paged_layer!!) updateLastInfo(paged_layer!!)
} else {
if (currentBooinfo != null) {
HistoryManager.getPrevPage(currentBooinfo!!.pathUrl!!) {
Blog.LOGE("HistoryManager.getNextPage(${it})")
if (it?.contents?.length ?: 0 > 10) {
currentBooinfo = it
paged_layer.text = it!!.contents!!
paged_layer.visibility = VISIBLE
if(it?.pathUrl?.length ?: 0 > 0) {
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
}
}
applyReaderConfig()
} else {
if(it?.pathUrl?.length ?: 0 > 0) {
Blog.LOGE("HistoryManager.getNextPage(${it?.pathUrl})")
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
paged_layer.visibility = GONE
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
paged_layer.visibility = GONE
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
}
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
}
}
if(it?.pathUrl?.length ?: 0 > 0) {
it?.pathUrl?.let {
HistoryManager.getBooInfo(it) {
saveItem(it)
}
}
}
}
} else { } else {
Uri.parse(mBaseWebContentsViewer.webview.url)?.let { Uri.parse(mBaseWebContentsViewer.webview.url)?.let {
it.path?.let { it.path?.let {
@ -600,10 +772,23 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
paged_layer.visibility = VISIBLE paged_layer.visibility = VISIBLE
} }
if(it?.pathUrl?.length ?: 0 > 0) { if (it?.pathUrl?.length ?: 0 > 0) {
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) HistoryManager.save(
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) { historyItem = HistoryItem().putHistory(
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!)) it,
mBaseWebContentsViewer.webview.url!!
)
)
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith(
"http"
)
) {
mBaseWebContentsViewer.webview.loadUrl(
lastInfo!!.pageUrl!!.replace(
Uri.parse(lastInfo!!.pageUrl)!!.path!!,
it?.pathUrl!!
)
)
} else { } else {
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
} }
@ -611,11 +796,13 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
} }
}
// onPrevClickAction?.let{ it() } // onPrevClickAction?.let{ it() }
} }
} }
override fun onBackPressed() { override fun onBackPressed() {
// super.onBackPressed() // super.onBackPressed()
var layer = findViewById<PagedTextLayout>(R.id.paged_layer) var layer = findViewById<PagedTextLayout>(R.id.paged_layer)
@ -642,6 +829,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} else { } else {
finishAffinity() finishAffinity()
didBackPress = false didBackPress = false
// super.onBackPressed()
} }
} }
@ -653,39 +841,11 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
override fun onLoadedContents(aContents: String) { override fun onLoadedContents(aContents: String) {
paged_layer.apply { paged_layer.apply {
if (aContents != null) { if (aContents != null && aContents.length > 10) {
var contents = aContents.replace("\\\"","\"") var contents = aContents.replace("\\\"","\"")
contents = (contents.replace("\\n", System.getProperty("line.separator"))) contents = (contents.replace("\\n", System.getProperty("line.separator")))
contents = (contents.replace("\\n", System.getProperty("line.separator")))
mPagedTextViewInterface = this@Intro mPagedTextViewInterface = this@Intro
var realm = HistoryManager.openRealm()
realm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) {
realm.copyFromRealm(it.first())?.let {
runOnUiThread {
paged_layer?.setTextSize(it.textSize?.toFloat()?: 14f)
paged_layer?.setLineSpacing(it.lineSpace?.toFloat() ?: 1f)
paged_layer?.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f)
paged_layer?.setPadding(
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1)
var typeface = typesfacez.get(getIndex(typesfacez as PairArray<Any>,it.font ?: ""))
paged_layer?.setTypeface(resources.getFont(typeface.second))
val color = colorz.get(it.style ?: 0)
paged_layer?.setColorStyle(color.second)
}
}
}
}
realm.close()
// text = (contents.replace("\\n", System.getProperty("line.separator")))
if(lastInfo != null && mBaseWebContentsViewer.webview.url?.endsWith(lastInfo!!.pageUrl) ?: false) { if(lastInfo != null && mBaseWebContentsViewer.webview.url?.endsWith(lastInfo!!.pageUrl) ?: false) {
this@Intro.findViewById<ProgressBar>(R.id.progress)?.visibility = VISIBLE this@Intro.findViewById<ProgressBar>(R.id.progress)?.visibility = VISIBLE
paged_layer?.postDelayed({ paged_layer?.postDelayed({
@ -693,28 +853,21 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
},1000) },1000)
} }
runOnUiThread { runOnUiThread {
text = (contents.replace("\\n", System.getProperty("line.separator"))) text = contents
visibility = VISIBLE visibility = VISIBLE
} }
applyReaderConfig()
forceUpdateUI() forceUpdateUI()
mBaseWebContentsViewer.webview.url?.let { mBaseWebContentsViewer.webview.url?.let {
Uri.parse(it)?.let { Uri.parse(it)?.let {
it.path?.let { it.path?.let {
HistoryManager.getBooPageInfo(it){ HistoryManager.getBooPageInfo(it){
currentBooinfo = it currentBooinfo = it
HistoryManager.openRealm().apply { HistoryManager.openRealm.writeBlocking {
this.writeBlocking { currentBooinfo?.contents = contents
it?.chapterTitle?.let {
onFindTitle(it)
} }
currentChapter = it?.chapterNum ?: 0 currentChapter = it?.chapterNum ?: 0
currentPage = it?.chapterNum ?: 0 currentPage = it?.chapterNum ?: 0
it?.contents = contents
if (it != null) {
copyToRealm(it, UpdatePolicy.ALL)
}
}
}.close()
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
} }
} }
@ -804,7 +957,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}") Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}")
realm.close()
} }
fun updateLastInfo(pagedTextLayout: PagedTextLayout) { fun updateLastInfo(pagedTextLayout: PagedTextLayout) {
@ -826,7 +979,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}") Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}")
realm.close()
} }
override fun onKeyClick(keyCode: Int): Boolean { override fun onKeyClick(keyCode: Int): Boolean {
when(keyCode) { when(keyCode) {

View File

@ -24,7 +24,7 @@ class Settings : Base() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.settings) binding = DataBindingUtil.setContentView(this, R.layout.settings)
// setContentView(R.layout.settings) // setContentView(R.layout.settings)
var realm = HistoryManager.openRealm() var realm = HistoryManager.openRealm
realm.writeBlocking { realm.writeBlocking {
this.query<ReaderConfig>()?.find()?.let { this.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) { if (it.size > 0) {
@ -35,7 +35,6 @@ class Settings : Base() {
} }
} }
realm.close()
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
@ -116,10 +115,9 @@ class Settings : Base() {
fun configSave() { fun configSave() {
var realm = HistoryManager.openRealm() var realm = HistoryManager.openRealm
realm.writeBlocking { realm.writeBlocking {
copyToRealm(readerConfig!!, UpdatePolicy.ALL) copyToRealm(readerConfig!!, UpdatePolicy.ALL)
} }
realm.close()
} }
} }

View File

@ -18,72 +18,59 @@ object HistoryManager {
val clazz : Set<KClass<out BaseRealmObject>> = setOf(LastInfo::class, HistoryItem::class, ReaderConfig::class, BookPageInfos::class, BookPageInfo::class) val clazz : Set<KClass<out BaseRealmObject>> = setOf(LastInfo::class, HistoryItem::class, ReaderConfig::class, BookPageInfos::class, BookPageInfo::class)
val schemaVersion : Long = 5 val schemaVersion : Long = 5
fun openRealm() : Realm = Realm.open(RealmConfiguration.Builder(clazz as Set<KClass<out TypedRealmObject>>)
val openRealm : Realm = Realm.open(RealmConfiguration.Builder(clazz as Set<KClass<out TypedRealmObject>>)
.schemaVersion(schemaVersion) .schemaVersion(schemaVersion)
.log(LogLevel.ALL) .log(LogLevel.ALL)
// .deleteRealmIfMigrationNeeded()
.build()) .build())
fun save(lastInfo: LastInfo) { fun save(lastInfo: LastInfo) {
openRealm()?.apply{ openRealm.apply{
this.writeBlocking { this.writeBlocking {
copyToRealm(lastInfo, UpdatePolicy.ALL) copyToRealm(lastInfo, UpdatePolicy.ALL)
} }
}?.close() }
} }
fun save(historyItem: HistoryItem) { fun save(historyItem: HistoryItem) {
openRealm()?.apply{ openRealm.apply{
this.writeBlocking { this.writeBlocking {
copyToRealm(historyItem, UpdatePolicy.ALL) copyToRealm(historyItem, UpdatePolicy.ALL)
} }
}?.close() }
} }
fun requestLastInfo(callback : (LastInfo)->Unit) { fun requestLastInfo(callback : (LastInfo)->Unit) {
openRealm()?.apply{ openRealm.apply{
}?.close() }
} }
fun save(config : ReaderConfig) { fun save(config : ReaderConfig) {
openRealm()?.apply{ openRealm.apply{
this.writeBlocking { this.writeBlocking {
copyToRealm(config,UpdatePolicy.ALL) copyToRealm(config,UpdatePolicy.ALL)
} }
}?.close() }
} }
fun getBooInfo(url : String ,callback : (BookPageInfos?)->Unit) { fun getBooInfo(url : String ,callback : (BookPageInfos?)->Unit) {
openRealm()?.apply{ openRealm.apply{
Blog.LOGE("get ${url}" ) Blog.LOGE("get ${url}" )
Blog.LOGE("get ${this.query(BookPageInfo::class).count().find()}" ) Blog.LOGE("get ${this.query(BookPageInfo::class).count().find()}" )
var list = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find() var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find().first()
if (list.size > 0) {
var bookPageInfo = list.first()
if (bookPageInfo != null) { if (bookPageInfo != null) {
Blog.LOGE("get ${bookPageInfo}") Blog.LOGE("get ${bookPageInfo}" )
this.query(BookPageInfos::class, "bookPageUrl == $0", bookPageInfo.bookPageUrl) this.query(BookPageInfos::class,"bookPageUrl == $0",bookPageInfo.bookPageUrl).find().first().let {
.find().first().let { Blog.LOGE("get ${it} , ${it?.pages}" )
Blog.LOGE("get ${it} , ${it?.pages}")
callback.invoke(this.copyFromRealm(it)) callback.invoke(this.copyFromRealm(it))
} }
} else {
callback.invoke(null)
}
} else {
var list = this.query(BookPageInfos::class).query("bookPageUrl == $0","${url}").find()
if (list.size > 0) {
callback.invoke(this.copyFromRealm(list.first()))
} else {
callback.invoke(null)
} }
} }
}?.close()
} }
fun getBooPageInfo(url : String ,callback : (BookPageInfo?)->Unit) { fun getBooPageInfo(url : String ,callback : (BookPageInfo?)->Unit) {
openRealm()?.apply{ openRealm.apply{
Blog.LOGE("get ${url}" ) Blog.LOGE("get ${url}" )
Blog.LOGE("get ${this.query(BookPageInfo::class).count().find()}" ) Blog.LOGE("get ${this.query(BookPageInfo::class).count().find()}" )
var result = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find() var result = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()
@ -93,13 +80,29 @@ object HistoryManager {
callback.invoke(this.copyFromRealm(bookPageInfo)) callback.invoke(this.copyFromRealm(bookPageInfo))
} }
} }
}?.close() }
}
suspend fun getBooPageInfoContentsSave(url : String, contents : String) {
val realm = openRealm
Blog.LOGE("get ${url}" )
Blog.LOGE("get ${realm.query(BookPageInfo::class).count().find()}" )
val result = realm.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()
if (result.size > 0) {
val bookPageInfo = realm.copyFromRealm(result.first())
realm.write {
bookPageInfo.contents = contents
copyToRealm(bookPageInfo, UpdatePolicy.ALL)
}
}
} }
fun getNextPage(url : String ,callback : (BookPageInfo?)->Unit) { fun getNextPage(url : String ,callback : (BookPageInfo?)->Unit) {
openRealm()?.apply{ openRealm.apply{
Blog.LOGE("getNextPage ${url}" ) Blog.LOGE("getNextPage ${url}" )
Blog.LOGE("getNextPage ${this.query(BookPageInfo::class).count().find()}" ) Blog.LOGE("getNextPage ${this.query(BookPageInfo::class).count().find()}" )
var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()?.first() var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()?.first()
@ -109,25 +112,25 @@ object HistoryManager {
Blog.LOGE("getNextPage 2 ${bookPageInfo.bookPageUrl}" ) Blog.LOGE("getNextPage 2 ${bookPageInfo.bookPageUrl}" )
var results = this.query(BookPageInfo::class).query("chapterNum == $0",bookPageInfo.chapterNum + 1).query("bookPageUrl == $0","${bookPageInfo.bookPageUrl}").find() var results = this.query(BookPageInfo::class).query("chapterNum == $0",bookPageInfo.chapterNum + 1).query("bookPageUrl == $0","${bookPageInfo.bookPageUrl}").find()
if(results.size > 0) { if(results.size > 0) {
results.first()?.let { results.first().let {
Blog.LOGE("getNextPage 2 ${it.pathUrl}" ) Blog.LOGE("getNextPage 2 ${it.pathUrl}" )
callback.invoke(it) callback.invoke(it)
} }
} }
} }
}?.close() }
} }
fun getPrevPage(url : String ,callback : (BookPageInfo?)->Unit) { fun getPrevPage(url : String ,callback : (BookPageInfo?)->Unit) {
openRealm()?.apply{ openRealm.apply{
Blog.LOGE("getPrevPage ${url}" ) Blog.LOGE("getPrevPage ${url}" )
Blog.LOGE("getPrevPage ${this.query(BookPageInfo::class).count().find()}" ) Blog.LOGE("getPrevPage ${this.query(BookPageInfo::class).count().find()}" )
var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()?.first() var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()?.first()
Blog.LOGE("getPrevPage ${bookPageInfo}" ) Blog.LOGE("getNextPage ${bookPageInfo}" )
if (bookPageInfo != null) { if (bookPageInfo != null) {
Blog.LOGE("getPrevPage 2 ${bookPageInfo.chapterNum}" ) Blog.LOGE("getNextPage 2 ${bookPageInfo.chapterNum}" )
Blog.LOGE("getPrevPage 2 ${bookPageInfo.bookPageUrl}" ) Blog.LOGE("getNextPage 2 ${bookPageInfo.bookPageUrl}" )
var results = this.query(BookPageInfo::class).query("chapterNum == $0 && bookPageUrl == $1",bookPageInfo.chapterNum - 1,"${bookPageInfo.bookPageUrl}").find() var results = this.query(BookPageInfo::class).query("chapterNum == $0 && bookPageUrl == $1",bookPageInfo.chapterNum - 1,"${bookPageInfo.bookPageUrl}").find()
if(results.size > 0) { if(results.size > 0) {
results.first()?.let { results.first()?.let {
@ -135,7 +138,7 @@ object HistoryManager {
} }
} }
} }
}?.close() }
} }
} }

View File

@ -1,22 +1,22 @@
package com.mime.dualscreenview.data.model package com.mime.dualscreenview.data.model
import com.mime.dualscreenview.common.Blog
import io.realm.kotlin.ext.realmListOf import io.realm.kotlin.ext.realmListOf
import io.realm.kotlin.types.RealmList import io.realm.kotlin.types.RealmList
import io.realm.kotlin.types.RealmObject import io.realm.kotlin.types.RealmObject
import io.realm.kotlin.types.RealmSet import io.realm.kotlin.types.annotations.Ignore
import io.realm.kotlin.types.annotations.Index
import io.realm.kotlin.types.annotations.PrimaryKey import io.realm.kotlin.types.annotations.PrimaryKey
class BookPageInfosJ : RealmObject { class BookPageInfosJ {
var bookTitle : String = "" var bookTitle : String = ""
var bookPageUrl : String = "" var bookPageUrl : String = ""
var pages : ArrayList<BookPageInfoJ> = arrayListOf<BookPageInfoJ>() var pages : ArrayList<BookPageInfoJ> = arrayListOf<BookPageInfoJ>()
fun getTitleArray() : ArrayList<String> { fun getTitleArray() : ArrayList<String> {
var arrayList = ArrayList<String>() var arrayList = ArrayList<String>()
pages?.forEach { arrayList.add(it.bookTitle ?: "") } pages.forEach { arrayList.add(it.bookTitle ?: "") }
return arrayList return arrayList
} }
@ -24,14 +24,11 @@ class BookPageInfosJ : RealmObject {
var r = BookPageInfos() var r = BookPageInfos()
r.bookTitle = this.bookTitle r.bookTitle = this.bookTitle
r.bookPageUrl = this.bookPageUrl r.bookPageUrl = this.bookPageUrl
// for (item in this.pages) {
//// Blog.LOGE("item >>> ${item}")
// r.pages.add(item.getRealm())
// }
return r return r
} }
} }
class BookPageInfoJ : RealmObject { class BookPageInfoJ {
var chapterID : Int = 0 var chapterID : Int = 0
var contents : String? = "" var contents : String? = ""
var bookPageUrl : String? = "" var bookPageUrl : String? = ""
@ -58,13 +55,16 @@ class BookPageInfoJ : RealmObject {
class BookPageInfos : RealmObject { class BookPageInfos : RealmObject {
var bookTitle : String = "" var bookTitle : String = ""
@PrimaryKey @PrimaryKey
var bookPageUrl : String? = "" var bookPageUrl : String? = ""
var pages : RealmList<BookPageInfo> = realmListOf() var pages : RealmList<BookPageInfo> = realmListOf()
fun getTitleArray() : ArrayList<String> { fun getTitleArray() : ArrayList<String> {
var arrayList = ArrayList<String>() var arrayList = ArrayList<String>()
pages?.forEach { pages.forEach {
arrayList.add(it.getTitleItem())} arrayList.add(it.getTitleItem())}
return arrayList return arrayList
} }
@ -102,7 +102,7 @@ class BookPageInfo : RealmObject {
fun getTitleItem() : String { fun getTitleItem() : String {
var result = StringBuilder() var result = StringBuilder()
result.append(if (contents?.length ?: 0 > 10) { result.append(if ((contents?.length ?: 0) > 10) {
"S:[0] " "S:[0] "
} else { } else {
"[X] " "[X] "
@ -110,7 +110,7 @@ class BookPageInfo : RealmObject {
result.append(chapterTitle?: "") result.append(chapterTitle?: "")
result.append(if (lastPage ?: 0 >0) { result.append(if ((lastPage ?: 0) > 0) {
" [0] " " [0] "
} else { } else {
" [X] " " [X] "

View File

@ -7,7 +7,7 @@ import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
class LastInfo() : RealmObject { class LastInfo : RealmObject {
@PrimaryKey @PrimaryKey
var _id : String = "UniqLastId" var _id : String = "UniqLastId"
var pageUrl : String = "" var pageUrl : String = ""
@ -26,7 +26,7 @@ class LastInfo() : RealmObject {
displayOrientation = this@LastInfo.displayOrientation displayOrientation = this@LastInfo.displayOrientation
} }
} }
class HistoryItem() : RealmObject { class HistoryItem : RealmObject {
@PrimaryKey @PrimaryKey
var title : String = "" var title : String = ""
var pageUrl : String = "" var pageUrl : String = ""

View File

@ -3,7 +3,7 @@ package com.mime.dualscreenview.data.model
import io.realm.kotlin.types.RealmObject import io.realm.kotlin.types.RealmObject
import io.realm.kotlin.types.annotations.PrimaryKey import io.realm.kotlin.types.annotations.PrimaryKey
class ReaderConfig() : RealmObject { class ReaderConfig : RealmObject {
@PrimaryKey @PrimaryKey
var id : String? = "ReaderConfig" var id : String? = "ReaderConfig"
var textSize : Int? = 14 var textSize : Int? = 14

View File

@ -713,103 +713,103 @@ class SimpleFingerGestures : OnTouchListener {
} }
} }
abstract class OnSwipeTouchListener(val context: Context?) : View.OnTouchListener { //abstract class OnSwipeTouchListener(val context: Context?) : View.OnTouchListener {
companion object { // companion object {
private const val SWIPE_DISTANCE_THRESHOLD = 100 // private const val SWIPE_DISTANCE_THRESHOLD = 100
private const val SWIPE_VELOCITY_THRESHOLD = 100 // private const val SWIPE_VELOCITY_THRESHOLD = 100
}
private val gestureDetector: GestureDetector
abstract fun onSwipeLeft()
abstract fun onSwipeRight()
abstract fun onSwipeDown()
abstract fun onSwipeUp()
abstract fun onSingleTap(area : TouchArea)
abstract fun onDoubleTap(area : TouchArea)
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
if (event == null) {
return false
}
return gestureDetector.onTouchEvent(event!!)
}
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
override fun onDown(e: MotionEvent): Boolean {
return true
}
override fun onDoubleTapEvent(e: MotionEvent): Boolean {
val width: Int = context?.resources?.displayMetrics?.widthPixels ?: 0
val height: Int = context?.resources?.displayMetrics?.heightPixels ?: 0
var touchArea : TouchArea = TouchArea.Center
if(width > 0 && height > 0) {
val centerAreaSize = width * 0.4
var sideAreaSize = (width - centerAreaSize) * 0.5
if(e.x < sideAreaSize) {
touchArea = TouchArea.DoubleLeft
} else if(e.x > sideAreaSize && e.x < width - sideAreaSize) {
} else {
touchArea = TouchArea.DoubleRight
}
}
onDoubleTap(touchArea)
return super.onDoubleTapEvent(e)
}
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
val width: Int = context?.resources?.displayMetrics?.widthPixels ?: 0
val height: Int = context?.resources?.displayMetrics?.heightPixels ?: 0
var touchArea : TouchArea = TouchArea.Center
if(width > 0 && height > 0) {
val centerAreaSize = width * 0.4
var sideAreaSize = (width - centerAreaSize) * 0.5
if(e.x < sideAreaSize) {
touchArea = TouchArea.Left
} else if(e.x > sideAreaSize && e.x < width - sideAreaSize) {
} else {
touchArea = TouchArea.Right
}
}
onSingleTap(touchArea)
return super.onSingleTapConfirmed(e)
}
// override fun onSingleTapUp(e: MotionEvent): Boolean {
//
// return super.onSingleTapUp(e)
// } // }
// private val gestureDetector: GestureDetector
override fun onFling( // abstract fun onSwipeLeft()
e1: MotionEvent, // abstract fun onSwipeRight()
e2: MotionEvent, // abstract fun onSwipeDown()
velocityX: Float, // abstract fun onSwipeUp()
velocityY: Float // abstract fun onSingleTap(area : TouchArea)
): Boolean { // abstract fun onDoubleTap(area : TouchArea)
Blog.LOGE("e1.pointerCount >> ${e1.pointerCount}") //
Blog.LOGE("e2.pointerCount >> ${e2.pointerCount}") // override fun onTouch(v: View?, event: MotionEvent?): Boolean {
val distanceX = e2.x - (e1?.x ?: 0f) // if (event == null) {
val distanceY = e2.y - (e1?.y ?: 0f) // return false
if (Math.abs(distanceX) > Math.abs(distanceY) // }
&& Math.abs(distanceX) > SWIPE_DISTANCE_THRESHOLD // return gestureDetector.onTouchEvent(event!!)
&& Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { // }
if (distanceX > 0) onSwipeRight() else onSwipeLeft() //
return true //
} else if (Math.abs(distanceY) > Math.abs(distanceX) // private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
&& Math.abs(distanceY) > SWIPE_DISTANCE_THRESHOLD //
&& Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) { // override fun onDown(e: MotionEvent): Boolean {
if (distanceY > 0) onSwipeDown() else onSwipeUp() // return true
return true // }
} else { //
// override fun onDoubleTapEvent(e: MotionEvent): Boolean {
} // val width: Int = context?.resources?.displayMetrics?.widthPixels ?: 0
return false // val height: Int = context?.resources?.displayMetrics?.heightPixels ?: 0
} // var touchArea : TouchArea = TouchArea.Center
} // if(width > 0 && height > 0) {
init { // val centerAreaSize = width * 0.4
gestureDetector = GestureDetector(context, GestureListener()) // var sideAreaSize = (width - centerAreaSize) * 0.5
} // if(e.x < sideAreaSize) {
} // touchArea = TouchArea.DoubleLeft
// } else if(e.x > sideAreaSize && e.x < width - sideAreaSize) {
//
// } else {
// touchArea = TouchArea.DoubleRight
// }
// }
// onDoubleTap(touchArea)
// return super.onDoubleTapEvent(e)
// }
//
// override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
// val width: Int = context?.resources?.displayMetrics?.widthPixels ?: 0
// val height: Int = context?.resources?.displayMetrics?.heightPixels ?: 0
// var touchArea : TouchArea = TouchArea.Center
// if(width > 0 && height > 0) {
// val centerAreaSize = width * 0.4
// var sideAreaSize = (width - centerAreaSize) * 0.5
// if(e.x < sideAreaSize) {
// touchArea = TouchArea.Left
// } else if(e.x > sideAreaSize && e.x < width - sideAreaSize) {
//
// } else {
// touchArea = TouchArea.Right
// }
// }
// onSingleTap(touchArea)
// return super.onSingleTapConfirmed(e)
// }
//
//// override fun onSingleTapUp(e: MotionEvent): Boolean {
////
//// return super.onSingleTapUp(e)
//// }
//
// override fun onFling(
// e1: MotionEvent?,
// e2: MotionEvent,
// velocityX: Float,
// velocityY: Float
// ): Boolean {
//Blog.LOGE("e1.pointerCount >> ${e1?.pointerCount}")
// Blog.LOGE("e2.pointerCount >> ${e2.pointerCount}")
// val distanceX = e2.x - (e1?.x ?: 0f)
// val distanceY = e2.y - (e1?.y ?: 0f)
// if (Math.abs(distanceX) > Math.abs(distanceY)
// && Math.abs(distanceX) > SWIPE_DISTANCE_THRESHOLD
// && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
// if (distanceX > 0) onSwipeRight() else onSwipeLeft()
// return true
// } else if (Math.abs(distanceY) > Math.abs(distanceX)
// && Math.abs(distanceY) > SWIPE_DISTANCE_THRESHOLD
// && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
// if (distanceY > 0) onSwipeDown() else onSwipeUp()
// return true
// } else {
//
// }
// return false
// }
// }
// init {
// gestureDetector = GestureDetector(context, GestureListener())
// }
//}

View File

@ -76,6 +76,7 @@ open class BaseWebContentsViewer {
fun loadLastInfo(lastInfo: LastInfo) { fun loadLastInfo(lastInfo: LastInfo) {
lastInfo?.let { last -> lastInfo?.let { last ->
Blog.LOGE("last.pageUrl >>> ${last.pageUrl}")
currentContentsProvider = WebContentsManger.getBaseWebContentsBy(last.contentsName) currentContentsProvider = WebContentsManger.getBaseWebContentsBy(last.contentsName)
// HistoryManager.getBooPageInfo(last.pageUrl,{ page -> // HistoryManager.getBooPageInfo(last.pageUrl,{ page ->
// if(page != null){ // if(page != null){
@ -85,7 +86,7 @@ open class BaseWebContentsViewer {
// webview.loadUrl(last.pageUrl) // webview.loadUrl(last.pageUrl)
// } // }
// } else { // } else {
if (last.pageUrl.startsWith("http")) { if (last.pageUrl.startsWith("https://")) {
webview.loadUrl(last.pageUrl) webview.loadUrl(last.pageUrl)
} else { } else {
try { try {

View File

@ -4,7 +4,7 @@ import com.mime.dualscreenview.webcontents.BaseWebContents
object Booktoki : BaseWebContents() { object Booktoki : BaseWebContents() {
override var lastNumber : Int = 348 override var lastNumber : Int = 349
override fun getWebcontentsName(): String { override fun getWebcontentsName(): String {
return "Booktoki" return "Booktoki"
@ -84,12 +84,12 @@ object Booktoki : BaseWebContents() {
"fail load" "fail load"
} }
} }
// "if(document.getElementsByClassName(\"hd_pops\") != null && document.getElementsByClassName(\"hd_pops\").length > 0) document.getElementsByClassName(\"hd_pops\")[0].remove();" +
// "if(document.getElementsByClassName(\"hd_pops\") != null && document.getElementsByClassName(\"hd_pops\").length > 0) document.getElementsByClassName(\"hd_pops\")[0].remove();" +
// "if(document.getElementById(\"main-banner-view\") != null) document.getElementById(\"main-banner-view\").remove();" +
// "if(document.getElementsByClassName(\"board-tail-banner\") != null && document.getElementsByClassName(\"board-tail-banner\").length > 0)document.getElementsByClassName(\"board-tail-banner\")[0].remove();" +
// "if(document.getElementById(\"id_mbv\") != null)document.getElementById(\"id_mbv\").remove();"
override fun onLoadedJs(): String { override fun onLoadedJs(): String {
return "if(document.getElementsByClassName(\"hd_pops\") != null && document.getElementsByClassName(\"hd_pops\").length > 0) document.getElementsByClassName(\"hd_pops\")[0].remove();" + return ""
"if(document.getElementsByClassName(\"hd_pops\") != null && document.getElementsByClassName(\"hd_pops\").length > 0) document.getElementsByClassName(\"hd_pops\")[0].remove();" +
"if(document.getElementById(\"main-banner-view\") != null) document.getElementById(\"main-banner-view\").remove();" +
"if(document.getElementsByClassName(\"board-tail-banner\") != null && document.getElementsByClassName(\"board-tail-banner\").length > 0)document.getElementsByClassName(\"board-tail-banner\")[0].remove();" +
"if(document.getElementById(\"id_mbv\") != null)document.getElementById(\"id_mbv\").remove();"
} }
} }

View File

@ -1,9 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { plugins {
id 'com.android.application' version '7.4.2' apply false id 'com.android.application' version '8.5.2' apply false
id 'com.android.library' version '7.4.2' apply false id 'com.android.library' version '8.5.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'io.realm.kotlin' version '1.6.0' apply false id 'io.realm.kotlin' version '1.16.0' apply false
} }

View File

@ -21,4 +21,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies, # resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library # thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
android.useNewApkCreator=false #android.useNewApkCreator=false
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false