From 90e28a9b45754920a51c0953b8062896b475deb3 Mon Sep 17 00:00:00 2001 From: lunaticbum <> Date: Mon, 26 Aug 2024 14:34:32 +0900 Subject: [PATCH] ... --- app/src/main/AndroidManifest.xml | 1 + .../com/mime/dualscreenview/BaseAppication.kt | 3 +- .../com/mime/dualscreenview/activity/Intro.kt | 495 +++++++----------- .../mime/dualscreenview/common/PrefManager.kt | 29 + .../dualscreenview/data/HistoryManager.kt | 88 ++-- .../dualscreenview/view/PagedTextLayout.kt | 13 +- .../mime/dualscreenview/view/PagedTextView.kt | 11 +- .../webcontents/BaseWebContents.kt | 82 +-- .../webcontents/BaseWebContentsViewer.kt | 85 +-- app/src/main/res/layout/intro.xml | 313 +++++------ 10 files changed, 495 insertions(+), 625 deletions(-) create mode 100644 app/src/main/java/com/mime/dualscreenview/common/PrefManager.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 83a28de..77c4bc0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ 4) currentPath else "") + } + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) Blog.LOGD(log= "onConfigurationChanged ${this::class.java.name} >> newConfig ${newConfig}") @@ -99,11 +98,13 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { } var contentsSaver : WebView? = null + lateinit var binding : IntroBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Blog.LOGD(log= "onCreate ${this::class.java.name} >> savedInstanceState ${savedInstanceState}") - setContentView(R.layout.intro) - findViewById(R.id.menu_web)?.let { + binding = IntroBinding.inflate(layoutInflater) + setContentView(binding.root) + binding.menuWeb.let { it.setOnLongClickListener { onTouch(TouchArea.Center) return@setOnLongClickListener false @@ -111,19 +112,19 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { mBaseWebContentsViewer = BaseWebContentsViewer(it,this) } - paged_layer = findViewById(R.id.paged_layer) - textview_title = findViewById(R.id.textview_title) + paged_layer = binding.pagedLayer + textview_title = binding.textviewTitle - findViewById(R.id.btn_list).setOnClickListener { v -> + binding.btnList.setOnClickListener { v -> mBaseWebContentsViewer?.webview?.url?.let { Uri.parse(it).path?.let { - HistoryManager.getBooInfo(it, { + HistoryManager.getBookInfos(it, { it?.let { showList(it) } }) } } } - findViewById(R.id.hidden_web)?.let { v-> + binding.hiddenWeb?.let { v-> contentsSaver = v contentsSaver?.webViewClient = saveClient contentsSaver?.settings?.textZoom = 100 @@ -141,46 +142,19 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { // switcvhOrient() // } - findViewById(R.id.btn_setting).setOnClickListener { v-> -// var intent = Intent() -// var findIntent = Intent(Intent.ACTION_MAIN,null) -// var list = packageManager.queryIntentActivities(findIntent,0) -// list.forEach { -// Blog.LOGE("activityInfo ============START================") -// val pm = applicationContext.packageManager -// var ai = try { -// pm.getApplicationInfo(it.activityInfo.packageName, 0) -// } catch (e: NameNotFoundException) { -// null -// } -// val applicationName = -// (if (ai != null) pm.getApplicationLabel(ai) else "(unknown)") as String -// Blog.LOGE("applicationName ============:: ${applicationName} ::================") -// Blog.LOGE("it.activityInfo.processName ::=> ${it.activityInfo.processName}") -// Blog.LOGE("it.activityInfo.targetActivity ::=> ${it.activityInfo.targetActivity}") -// Blog.LOGE("it.activityInfo.name ::=> ${it.activityInfo.name}") -// Blog.LOGE("it.activityInfo.packageName ::=> ${it.activityInfo.packageName}") -// Blog.LOGE("it.resolvePackageName ::=> ${it.resolvePackageName}") -// Blog.LOGE("activityInfo ============END================") -// } -// -// -// var startIntene = Intent(Intent.ACTION_MAIN) -// startIntene.setComponent(ComponentName("com.samsung.android.app.interpreter","com.samsung.android.app.interpreter.interpretation.view.InterpretationActivity")) -// startActivity(startIntene) + binding.btnSetting.setOnClickListener { v-> startActivity(Intent(this@Intro, Settings::class.java)) } - findViewById(R.id.btn_history).setOnClickListener { v-> + binding.btnHistory.setOnClickListener { v-> var realm = openRealm() - realm.query()?.find()?.let { + realm.query().find().let { showHistory(realm.copyFromRealm(it)) } } - - findViewById(R.id.btn_home).setOnClickListener { v-> - paged_layer?.visibility = GONE + binding.btnHome.setOnClickListener { v-> + paged_layer.visibility = GONE mBaseWebContentsViewer.loadContents(Booktoki) } @@ -189,10 +163,10 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { fun loadLastInfo(){ val realm = openRealm() - try { lastInfo = realm?.query()?.find()?.last()?.copyFromRealm() + try { lastInfo = realm.query().find().last()?.copyFromRealm() try { if (lastInfo != null) { - HistoryManager.getBooPageInfo(Uri.parse(lastInfo!!.pageUrl!!).path!!) { + HistoryManager.getBookPageInfo(Uri.parse(lastInfo!!.pageUrl!!).path!!) { it?.let { currentBooinfo = it paged_layer.text = it!!.contents!! @@ -208,7 +182,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) } it?.pathUrl?.let { - HistoryManager.getBooInfo(it) { + HistoryManager.getBookInfos(it) { saveItem(it) } } @@ -245,6 +219,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { }} catch (e : Exception) { } } + fun reloadLastInfo() { val configuration: Configuration = getResources().getConfiguration() if(lastInfo != null && lastInfo?.displayOrientation != configuration.orientation) { @@ -258,15 +233,9 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { var infos : BookPageInfos? = null realm.writeBlocking { try { - var infosj : BookPageInfosJ? = null - infosj = Gson().fromJson(jsonString, BookPageInfosJ::class.java) - Blog.LOGE("onBookInfos" , "onBookInfos 2 >> ${infosj}") - Blog.LOGE("onBookInfos" , "onBookInfos 2 - 1 >> ${infosj?.pages}") -// realm.createObjectFromJson - Blog.LOGE("onBookInfos" , "onBookInfos 2 - 1 >> ${infosj?.getR()}") - HistoryManager.getBooInfo(infosj.bookPageUrl!!){ + HistoryManager.getBookInfos(infosj.bookPageUrl!!){ if (it != null) { infos = copyToRealm(it!!, UpdatePolicy.ALL) @@ -275,8 +244,9 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { infos!!.pages.add(item.getRealm()) } } - Blog.LOGE("onBookInfos", "onBookInfos 3 >> ${realm.query().find().size}") - Blog.LOGE("onBookInfos", "onBookInfos 4 >> ${realm.query().find().size}") + if (infos != null) { + infos = this.copyFromRealm(infos!!) + } } else { infos = infosj?.getR() if (infos != null) { @@ -284,25 +254,24 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { for (item in infosj.pages) { infos?.pages?.add(item.getRealm()) } - Blog.LOGE("onBookInfos", "onBookInfos 3 >> ${realm.query().find().size}") - Blog.LOGE("onBookInfos", "onBookInfos 4 >> ${realm.query().find().size}") + } + if (infos != null) { + infos = this.copyFromRealm(infos!!) } } } - if (infos != null) { - infos = this.copyFromRealm(infos!!) - } + } catch (e :Exception) { e.printStackTrace() - } - } - - infos?.bookPageUrl?.let { - HistoryManager.getBooInfo(it){ - it?.let { - Blog.LOGE("onBookInfos" , "onBookInfos it >> ${it}") - runOnUiThread { - showList(it) + } finally { + infos?.bookPageUrl?.let { + HistoryManager.getBookInfos(it){ + it?.let { + Blog.LOGE("onBookInfos" , "onBookInfos it >> ${it}") + runOnUiThread { + showList(it) + } + } } } } @@ -376,7 +345,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { builderInner.setPositiveButton("Ok", DialogInterface.OnClickListener { dialog, which -> - reloadTo(item.makeLastInfo()) + contentsLoad(item.pageUrl) dialog.dismiss() }) builderInner.setNeutralButton("삭제", @@ -456,62 +425,88 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { override fun onPageFinished(webView: WebView?, url: String?) { super.onPageFinished(webView, url) isLoading = false - var ramdomTimeSec = 1000L + Random(System.currentTimeMillis()).nextLong().rem(3999) - Blog.LOGE("ramdomTime >>> ${ramdomTimeSec}") - webView?.postDelayed( { - Blog.LOGE("saveClient >>> ${isLoading} ${url}") - var findContents = Booktoki.getFindContentsJs() - webView?.evaluateJavascript(findContents){ result: String? -> - result?.let { string: String -> - Blog.LOGE("saveClient contents >>> ${string.length}") - if (string.length > 10) { - Blog.LOGE("saveClient it.length >>> ${string.length}") - var contents = string.replace("\\\"","\"") - contents = (contents.replace("\\n", System.getProperty("line.separator"))) - contents = (contents.replace("\\n", System.getProperty("line.separator"))) + webView?.postDelayed({ autoScrollDown(webView, url) },(1300L + Random(System.currentTimeMillis()).nextLong().rem(1286L))) + } + fun showToast(origin: String) { + runOnUiThread { + val biggerText = SpannableStringBuilder(origin) + biggerText.setSpan(RelativeSizeSpan(1.6f), 0, origin.length, 0) + Toast.makeText( + baseContext, + biggerText, + Toast.LENGTH_SHORT + ).show() + } + } - Blog.LOGE("saveClient contents >>> ${contents.length}") - Uri.parse(url)?.let { - it.path?.let { - HistoryManager.getBooPageInfoContentsSave(it, contents.replace(Char(0x20).toString()," ")) - HistoryManager.getBooPageInfo(it) { info -> - runOnUiThread { - info?.let { - var origin = info.getTitleItem() - val biggerText = SpannableStringBuilder(origin) - biggerText.setSpan(RelativeSizeSpan(1.6f), 0, origin.length, 0) - Toast.makeText(baseContext,biggerText, Toast.LENGTH_SHORT).apply { - setGravity(Gravity.CENTER, 0, 0) - }.show() + fun autoScrollDown(webView: WebView?, url: String?) { + webView?.let { webView -> + val ramdomTimeSec = + 800L.plus(Random(System.currentTimeMillis()).nextLong().rem(789L)) + Blog.LOGE("ramdomTime >>> ${ramdomTimeSec}") + if (((webView?.scrollY ?: 0) + (webView?.height + ?: 0)) < webView?.contentHeight ?: 0 + ) { + webView?.postDelayed({ + webView?.pageDown(false) + autoScrollDown(webView, url) + }, ramdomTimeSec) + } else { + webView?.postDelayed({ + var findContents = Booktoki.getFindContentsJs() + webView?.evaluateJavascript(findContents) { result: String? -> + result?.let { string: String -> + if (string.length > 10) { + val contents = string.replace("\\\"", "\"") + .replace("\\n", System.getProperty("line.separator")) + .replace("\\n", System.getProperty("line.separator")) + Uri.parse(url)?.let { + it.path?.let { + HistoryManager.getBooPageInfoContentsSave(it, contents.replace(Char(0x20).toString(), " ")) + HistoryManager.getBookPageInfo(it) { info -> + info?.let { showToast(info.getTitleItem()) } } } } } - + var ramdomTime = 2000L.plus(Random(System.currentTimeMillis()).nextLong().rem(1785L)) + Blog.LOGE("afterNextPageTime >>> ${ramdomTime}") + contentsSaver?.postDelayed({ saveItem(null) }, ramdomTime) } } - var ramdomTime = 8000L + Random(System.currentTimeMillis()).nextLong().rem(7999) - Blog.LOGE("ramdomTime >>> ${ramdomTime}") - contentsSaver?.postDelayed( { saveItem(null) }, ramdomTime) - } - }},ramdomTimeSec) + }, ramdomTimeSec) + } + } } } var saveTarget : ArrayList = arrayListOf() private fun saveItem(infos: BookPageInfos?) { Blog.LOGE("saveItem >>> infos?.pages ${infos?.pages?.size ?: 0}") - var savedCount = Math.abs(Random(System.currentTimeMillis()).nextLong().rem(19) + 6L) + var savedCount = Math.abs(Random(System.currentTimeMillis()).nextLong().rem(9) + 6L) Blog.LOGE("saveItem >>> targetCount = ${savedCount}") + infos?.pages?.reversed()?.forEach { if ((it.contents?.length ?: 0) > 10) { } else { - if (saveTarget.size < savedCount.toInt()) { + if (savedCount.toInt() > 0) { saveTarget.add(it) + savedCount = savedCount - 1L } } } + if (savedCount > 0) { + HistoryManager.openRealm.query().find().forEach { + if ((it.contents?.length ?: 0) > 10) { + } else if(savedCount.toInt() > 0) { + saveTarget.add(HistoryManager.openRealm.copyFromRealm(it)) + savedCount = savedCount - 1 + } + } + } + + Blog.LOGE("saveItem >>> saveTarget ${saveTarget.count()}") if (isLoading == false) { try { @@ -578,117 +573,65 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { } } + + + fun moveToNext(pathUrl : String?) { + if (pathUrl != null && pathUrl.length > 6) { + HistoryManager.getNextPage(pathUrl!!) { + if(it != null && it!!.pathUrl?.length ?: 0 > 6) {contentsLoad(it.pathUrl!!)} + } + } + } + fun moveToPrev(pathUrl : String?) { + if (pathUrl != null && pathUrl.length > 6) { + HistoryManager.getPrevPage(pathUrl!!) { + if(it != null && it!!.pathUrl?.length ?: 0 > 6) {contentsLoad(it.pathUrl!!)} + } + } + } + + fun contentsLoad(pathUrl : String) { + HistoryManager.getBookPageInfo(pathUrl) { + it?.pathUrl?.let { + HistoryManager.getBookInfos(it) { saveItem(it) } + } + if (it != null) currentBooinfo = it + if (it != null && (it?.contents?.length ?: 0) > 10) { + paged_layer.visibility = VISIBLE + paged_layer.text = it!!.contents!! + if((it?.pathUrl?.length ?: 0) > 0) { + if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) { + mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!)) + } else { + mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) + } + HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) + } + applyReaderConfig() + } else { + if(it?.pathUrl?.length ?: 0 > 0) { + if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) { + paged_layer.visibility = GONE + mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!)) + } else { + paged_layer.visibility = GONE + mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) + } + HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!)) + } + } + } + } + + + + fun actionNextEvent(fast : Boolean = false) { if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && (paged_layer!!.current() < paged_layer!!.size() - 1) ) { paged_layer!!.doNext(fast) updateLastInfo(paged_layer!!) } 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 { - it.path?.let { - HistoryManager.getNextPage(it) { - 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!!) - } - it?.pathUrl?.let { - HistoryManager.getBooInfo(it) { - saveItem(it) - } - } - } - } else { - 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!! - ) - ) - paged_layer?.visibility = GONE - } else { - Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})") - mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) - paged_layer?.visibility = GONE - } - - } - } - it?.pathUrl?.let { HistoryManager.getBooInfo(it) { saveItem(it) } } - } - } - } - } -// onNextClickAction?.let { it() } + moveToNext(currentBooinfo?.pathUrl ?: mBaseWebContentsViewer.webview.url?.toUri()?.path) } } @@ -709,21 +652,20 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { 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) + var typeface = typesfacez.get(getIndex(typesfacez as PairArray,it.font ?: "")) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + paged_layer?.setTypeface(resources.getFont(typeface.second)) + } paged_layer.setPadding( it.padding ?: 1, it.padding ?: 1, it.padding ?: 1, it.padding ?: 1) - - var typeface = typesfacez.get(getIndex(typesfacez as PairArray,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) + paged_layer.setTextSize(it.textSize?.toFloat()?: 14f) + paged_layer.setLineSpacing(it.lineSpace?.toFloat() ?: 1f) + paged_layer.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f) } } } @@ -735,84 +677,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { paged_layer!!.doPrev(fast) 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 { - Uri.parse(mBaseWebContentsViewer.webview.url)?.let { - it.path?.let { - HistoryManager.getPrevPage(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!! - ) - ) - if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith( - "http" - ) - ) { - mBaseWebContentsViewer.webview.loadUrl( - lastInfo!!.pageUrl!!.replace( - Uri.parse(lastInfo!!.pageUrl)!!.path!!, - it?.pathUrl!! - ) - ) - } else { - mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!) - } - } - } - } - } - } -// onPrevClickAction?.let{ it() } + moveToPrev(currentBooinfo?.pathUrl ?: mBaseWebContentsViewer.webview.url?.toUri()?.path) } } @@ -862,21 +727,21 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { contents = (contents.replace("\\n", System.getProperty("line.separator"))) mPagedTextViewInterface = this@Intro if(lastInfo != null && mBaseWebContentsViewer.webview.url?.endsWith(lastInfo!!.pageUrl) ?: false) { - this@Intro.findViewById(R.id.progress)?.visibility = VISIBLE - paged_layer?.postDelayed({ - this@Intro.findViewById(R.id.progress)?.visibility = GONE + binding.progress.visibility = VISIBLE + paged_layer.postDelayed({ + binding.progress.visibility = GONE },1000) } + applyReaderConfig() runOnUiThread { text = contents visibility = VISIBLE } - applyReaderConfig() forceUpdateUI() mBaseWebContentsViewer.webview.url?.let { Uri.parse(it)?.let { it.path?.let { - HistoryManager.getBooPageInfo(it){ + HistoryManager.getBookPageInfo(it){ currentBooinfo = it currentChapter = it?.chapterNum ?: 0 currentPage = it?.chapterNum ?: 0 @@ -912,7 +777,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { builder.setNegativeButton( "Cancel" ) { dialog, which -> dialog.cancel() } - builder.show() } var testRegex = """[^0-9]""".toRegex(); @@ -947,7 +811,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { lastInfo.displayOrientation = configuration?.orientation ?: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT saveLastInfo(lastInfo) } - findViewById(R.id.progress).visibility = GONE + binding.progress.visibility = GONE } fun saveLastInfo(lastInfo: LastInfo) { @@ -980,6 +844,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface { this.query()?.find()?.last()?.let{ it.displayOrientation = configuration.orientation it.title = currentTitle +// it.pageUrl = currentBooinfo?.pathUrl ?: mBaseWebContentsViewer.webview.url?.toUri()?.path ?: "" it.chapter = currentChapter it.pageIndex = pagedTextLayout.current() this@Intro.lastInfo = copyFromRealm(it) diff --git a/app/src/main/java/com/mime/dualscreenview/common/PrefManager.kt b/app/src/main/java/com/mime/dualscreenview/common/PrefManager.kt new file mode 100644 index 0000000..e57c6b2 --- /dev/null +++ b/app/src/main/java/com/mime/dualscreenview/common/PrefManager.kt @@ -0,0 +1,29 @@ +package com.mime.dualscreenview.common + +import android.content.Context +import android.content.SharedPreferences +import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki + +object PrefManager { + private val mainName = "Main_Pref_" + private val domainKey = "Last_Domain_" + private lateinit var main : SharedPreferences + fun init(context: Context) { + main = context.getSharedPreferences(mainName,Context.MODE_PRIVATE) + } + + fun save(key : String, value : String?) { + main.edit().putString(key,value).apply() + } + fun load(key : String) : String? { + return main.getString(key, "") + } + + fun getLastDomain() : String { + return main.getString(domainKey, Booktoki.getLastedDoamin()) ?: Booktoki.getLastedDoamin() + } + fun putLastDomain(domain : String) { + Blog.LOGE("domain >>> ${domain}") + main.edit().putString(domainKey,domain).apply() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mime/dualscreenview/data/HistoryManager.kt b/app/src/main/java/com/mime/dualscreenview/data/HistoryManager.kt index 23e3d3b..79bf644 100644 --- a/app/src/main/java/com/mime/dualscreenview/data/HistoryManager.kt +++ b/app/src/main/java/com/mime/dualscreenview/data/HistoryManager.kt @@ -9,7 +9,6 @@ import com.mime.dualscreenview.data.model.ReaderConfig import io.realm.kotlin.Realm import io.realm.kotlin.RealmConfiguration import io.realm.kotlin.UpdatePolicy -import io.realm.kotlin.log.LogLevel import io.realm.kotlin.types.BaseRealmObject import io.realm.kotlin.types.TypedRealmObject import kotlin.reflect.KClass @@ -54,11 +53,15 @@ object HistoryManager { } } - fun getBooInfo(url : String ,callback : (BookPageInfos?)->Unit) { + fun getBookInfos(aUrl : String, callback : (BookPageInfos?)->Unit) { + var url : String = aUrl openRealm.apply{ - Blog.LOGE("get ${url}" ) - Blog.LOGE("get ${this.query(BookPageInfo::class).count().find()}" ) - var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find() + if (url.startsWith("//")) { + while (url.startsWith("//")) { + url = url.replace("//","/").trim() + } + } + var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0 || bookPageUrl == $1","${url}","${url}").find() if (bookPageInfo != null && bookPageInfo.count() > 0) { Blog.LOGE("get ${bookPageInfo}" ) this.query(BookPageInfos::class,"bookPageUrl == $0",bookPageInfo.first().bookPageUrl).find().first().let { @@ -71,10 +74,14 @@ object HistoryManager { } } - fun getBooPageInfo(url : String ,callback : (BookPageInfo?)->Unit) { + fun getBookPageInfo(aUrl : String, callback : (BookPageInfo?)->Unit) { + var url : String = aUrl openRealm.apply{ - Blog.LOGE("get ${url}" ) - Blog.LOGE("get ${this.query(BookPageInfo::class).count().find()}" ) + if (url.startsWith("//")) { + while (url.startsWith("//")) { + url = url.replace("//","/").trim() + } + } var result = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find() if (result.size > 0) { var bookPageInfo = result?.first() @@ -85,10 +92,10 @@ object HistoryManager { } } - fun getBooPageInfoContentsSave(url : String, contents : String) { + fun getBooPageInfoContentsSave(aUrl : String, contents : String) { + var url : String = aUrl openRealm.writeBlocking { - Blog.LOGE("get ${url}") - Blog.LOGE("get ${query(BookPageInfo::class).count().find()}") + Blog.LOGE("getBooPageInfoContentsSave ${url}") val result = query(BookPageInfo::class).query("pathUrl == $0", "${url}").find() if (result.size > 0) { result.first().contents = contents @@ -100,42 +107,55 @@ object HistoryManager { - fun getNextPage(url : String ,callback : (BookPageInfo?)->Unit) { + fun getNextPage(aUrl : String ,callback : (BookPageInfo?)->Unit) { + var url : String = aUrl openRealm.apply{ - Blog.LOGE("getNextPage ${url}" ) - Blog.LOGE("getNextPage ${this.query(BookPageInfo::class).count().find()}" ) - var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()?.first() - Blog.LOGE("getNextPage 1 ${bookPageInfo}" ) - if (bookPageInfo != null) { - Blog.LOGE("getNextPage 2 ${bookPageInfo.chapterNum}" ) - Blog.LOGE("getNextPage 2 ${bookPageInfo.bookPageUrl}" ) - var results = this.query(BookPageInfo::class).query("chapterNum == $0",bookPageInfo.chapterNum + 1).query("bookPageUrl == $0","${bookPageInfo.bookPageUrl}").find() - if(results.size > 0) { - results.first().let { - Blog.LOGE("getNextPage 2 ${it.pathUrl}" ) - callback.invoke(it) - - } + if (url.startsWith("//")) { + while (url.startsWith("//")) { + url = url.replace("//","/").trim() } } + var bookPageInfo = + this.query(BookPageInfo::class).query("pathUrl == $0", url).find() + if (bookPageInfo.size > 0) { + Blog.LOGE("getNextPage 2 => chapterNum : ${bookPageInfo.first().chapterNum} , bookPageInfo.bookPageUrl : ${bookPageInfo.first().bookPageUrl}" ) + var results = this.query(BookPageInfo::class).query("chapterNum == $0",bookPageInfo.first().chapterNum + 1).query("bookPageUrl == $0","${bookPageInfo.first().bookPageUrl}").find() + if(results.size > 0) { + results.first().let { + Blog.LOGE("getNextPage 2 nextBook pathUrl : ${it.pathUrl}" ) + callback.invoke(it) + } + } else {callback.invoke(null)} + } else {callback.invoke(null)} } } - fun getPrevPage(url : String ,callback : (BookPageInfo?)->Unit) { + fun getPrevPage(aUrl : String ,callback : (BookPageInfo?)->Unit) { + var url : String = aUrl openRealm.apply{ Blog.LOGE("getPrevPage ${url}" ) - Blog.LOGE("getPrevPage ${this.query(BookPageInfo::class).count().find()}" ) - var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find()?.first() - Blog.LOGE("getNextPage ${bookPageInfo}" ) - if (bookPageInfo != null) { - Blog.LOGE("getNextPage 2 ${bookPageInfo.chapterNum}" ) - Blog.LOGE("getNextPage 2 ${bookPageInfo.bookPageUrl}" ) - var results = this.query(BookPageInfo::class).query("chapterNum == $0 && bookPageUrl == $1",bookPageInfo.chapterNum - 1,"${bookPageInfo.bookPageUrl}").find() + if (url.startsWith("//")) { + while (url.startsWith("//")) { + url = url.replace("//","/").trim() + } + } + Blog.LOGE("getPrevPage ${url}" ) + var bookPageInfo = + this.query(BookPageInfo::class).query("pathUrl == $0", url).find() + Blog.LOGE("getPrevPage ${bookPageInfo}" ) + if (bookPageInfo.size > 0) { + Blog.LOGE("getPrevPage 2 ${bookPageInfo?.first()?.chapterNum}" ) + Blog.LOGE("getPrevPage 2 ${bookPageInfo?.first()?.bookPageUrl}" ) + var results = this.query(BookPageInfo::class).query("chapterNum == $0",bookPageInfo.first().chapterNum - 1).query("bookPageUrl == $0","${bookPageInfo.first().bookPageUrl}").find() if(results.size > 0) { results.first()?.let { callback.invoke(it) } + } else { + callback.invoke(null) } + } else { + callback.invoke(null) } } } diff --git a/app/src/main/java/com/mime/dualscreenview/view/PagedTextLayout.kt b/app/src/main/java/com/mime/dualscreenview/view/PagedTextLayout.kt index e6a6c03..948650a 100644 --- a/app/src/main/java/com/mime/dualscreenview/view/PagedTextLayout.kt +++ b/app/src/main/java/com/mime/dualscreenview/view/PagedTextLayout.kt @@ -37,14 +37,21 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface { var hiddenTextView : PagedTextView? = null var guideLine : Guideline? = null var pageList: ArrayList? = null + var summaryText : String = "" var text : String = "" set(new) { Blog.LOGE("field >> ${field}") Blog.LOGE("new >> ${new}") field = new - Blog.LOGE("field >> ${field}") - hiddenTextView?.setTxtF(field) - hiddenTextView?.visibility = VISIBLE + val summary = new.replace(" " ,"").replace("\n" ,"").substring(0,Math.min(30,new.length)) + if (summary.equals(summaryText)) { + + } else { + Blog.LOGE("field >> ${field}") + hiddenTextView?.setTxtF(field) + hiddenTextView?.visibility = VISIBLE + } + summaryText = summary } private val hanler = Handler() diff --git a/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt b/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt index d6342c5..60c855f 100644 --- a/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt +++ b/app/src/main/java/com/mime/dualscreenview/view/PagedTextView.kt @@ -7,6 +7,7 @@ import android.os.Build import android.text.Layout import android.text.StaticLayout import android.util.AttributeSet +import android.util.TypedValue import androidx.appcompat.widget.AppCompatTextView import androidx.core.view.marginBottom import androidx.core.view.marginLeft @@ -86,8 +87,15 @@ class PagedTextView : AppCompatTextView { super.setText(text, type) } + + + override fun setTextSize(size: Float) { + setTextSize(TypedValue.COMPLEX_UNIT_SP, size) + } + override fun setTextSize(unit: Int, size: Float) { super.setTextSize(unit, size) + paint.textSize = TypedValue.applyDimension(unit, size, context.resources.getDisplayMetrics()) needPaginate = true } @@ -111,6 +119,7 @@ class PagedTextView : AppCompatTextView { override fun setTypeface(tf: Typeface?) { if (typeface != null && tf != typeface) { needPaginate = true + paint.typeface = tf } super.setTypeface(tf) } @@ -230,7 +239,7 @@ class PagedTextView : AppCompatTextView { .setUseLineSpacingFromFallbacks() .setBreakStrategy(breakStrategy) .setHyphenationFrequency(hyphenationFrequency) - .setJustificationMode() +// .setJustificationMode() .setMaxLines(maxLines) .build() } diff --git a/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContents.kt b/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContents.kt index f0e45b9..68054b9 100644 --- a/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContents.kt +++ b/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContents.kt @@ -10,14 +10,14 @@ import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents abstract class BaseWebContents : ContentsInfoInterface { open var lastNumber : Int = 221 var completeAction : ActionByBool? = null - val definedActionCount = 5 - var completeActionCount = 0 - set(value) { - field = value - if(field == definedActionCount && completeAction != null) { - completeAction?.invoke(true) - } - } +// val definedActionCount = 5 +// var completeActionCount = 0 +// set(value) { +// field = value +// if(field == definedActionCount && completeAction != null) { +// completeAction?.invoke(true) +// } +// } fun findListItem(webview: WebView, callBakItems : DidFindContents) { webview.evaluateJavascript(getContentsList()) { result -> @@ -25,16 +25,15 @@ abstract class BaseWebContents : ContentsInfoInterface { } } - fun doOnloaded(webview: WebView, findContents : DidFindContents, findTitle : DidFindContents, findNextButton : DidFindContents, - findPrevButton : DidFindContents, completeAction : ActionByBool) { - completeActionCount = 0 + fun doOnloaded(webview: WebView, findContents : DidFindContents, completeAction : ActionByBool) { +// completeActionCount = 0 this.completeAction = completeAction - webview.evaluateJavascript(getTitleJs()) { result : String? -> - result?.let { resultString -> - findTitle.invoke(resultString) - } - completeActionCount = completeActionCount + 1 - } +// webview.evaluateJavascript(getTitleJs()) { result : String? -> +// result?.let { resultString -> +// findTitle.invoke(resultString) +// } +// completeActionCount = completeActionCount + 1 +// } webview.evaluateJavascript(getFindContentsJs()) { result : String? -> result?.let { resultString -> checkCorrectContents(resultString)?.let { contents -> @@ -45,37 +44,38 @@ abstract class BaseWebContents : ContentsInfoInterface { } } } ?: findContents.invoke(null) - completeActionCount = completeActionCount + 1 - } - webview.evaluateJavascript("document.getElementById('${getNextButtonJs()}')") { result : String? -> - result?.let { resultString -> - Log.e("BaseWebContents", "getNextButtonJs() >> ${resultString}") - if(resultString != null && !"null".equals(resultString)) { - findNextButton.invoke(resultString) - } else { - findNextButton.invoke(null) - } - } - completeActionCount = completeActionCount + 1 +// completeActionCount = completeActionCount + 1 } +// webview.evaluateJavascript("document.getElementById('${getNextButtonJs()}')") { result : String? -> +// result?.let { resultString -> +// Log.e("BaseWebContents", "getNextButtonJs() >> ${resultString}") +// if(resultString != null && !"null".equals(resultString)) { +// findNextButton.invoke(resultString) +// } else { +// findNextButton.invoke(null) +// } +// } +// completeActionCount = completeActionCount + 1 +// } - webview.evaluateJavascript("document.getElementById('${getPrevButtonJs()}')") { result : String? -> - result?.let { resultString -> - Log.e("BaseWebContents", "getPrevButtonJs() >> ${resultString}") - if(resultString != null && !"null".equals(resultString)) { - findPrevButton.invoke(resultString) - }else { - findPrevButton.invoke(null) - } - } - completeActionCount = completeActionCount + 1 - } +// webview.evaluateJavascript("document.getElementById('${getPrevButtonJs()}')") { result : String? -> +// result?.let { resultString -> +// Log.e("BaseWebContents", "getPrevButtonJs() >> ${resultString}") +// if(resultString != null && !"null".equals(resultString)) { +// findPrevButton.invoke(resultString) +// }else { +// findPrevButton.invoke(null) +// } +// } +// completeActionCount = completeActionCount + 1 +// } webview.evaluateJavascript(onLoadedJs()) { Log.e("BaseWebContents", "onLoadedJs() >> ${it}") - completeActionCount = completeActionCount + 1 +// completeActionCount = completeActionCount + 1 } + completeAction?.invoke(true) } } diff --git a/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt b/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt index 0eadca0..272b538 100644 --- a/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt +++ b/app/src/main/java/com/mime/dualscreenview/webcontents/BaseWebContentsViewer.kt @@ -6,7 +6,9 @@ import android.net.Uri import android.net.http.SslError import android.util.Log import android.webkit.* +import androidx.core.net.toUri import com.mime.dualscreenview.common.Blog +import com.mime.dualscreenview.common.PrefManager import com.mime.dualscreenview.data.HistoryManager import com.mime.dualscreenview.data.model.LastInfo import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki @@ -76,32 +78,16 @@ open class BaseWebContentsViewer { fun loadLastInfo(lastInfo: LastInfo) { lastInfo?.let { last -> - Blog.LOGE("last.pageUrl >>> ${last.pageUrl}") currentContentsProvider = WebContentsManger.getBaseWebContentsBy(last.contentsName) -// HistoryManager.getBooPageInfo(last.pageUrl,{ page -> -// if(page != null){ -// if(page.contents?.length ?: 0 > 0) { -// mainControllInterface?.onLoadedContents(page.contents!!) -// } else { -// webview.loadUrl(last.pageUrl) -// } -// } else { if (last.pageUrl.startsWith("https://")) { webview.loadUrl(last.pageUrl) } else { try { - var uri = Uri.parse(webview.url) - uri.path?.let { - webview.loadUrl(uri.toString().replace(it,last.pageUrl)) - } + webview.loadUrl(PrefManager.getLastDomain().plus("/").plus(last.pageUrl)) } catch (e : Exception) { - webview.loadUrl(Booktoki.getLastedDoamin().plus("/").plus(last.pageUrl)) + webview.loadUrl(PrefManager.getLastDomain()) } - } - -// } -// }) } } @@ -126,48 +112,7 @@ open class BaseWebContentsViewer { super.onPageStarted(view, url, favicon) mainControllInterface?.onStartLoad() } - var alertDialogs : ArrayList = arrayListOf() - // override fun onReceivedError( -// view: WebView?, -// request: WebResourceRequest?, -// error: WebResourceError? -// ) { -// super.onReceivedError(view, request, error) -// if (error != null && error.errorCode < 0) { -// -// webview.postDelayed({ -// val builder = AlertDialog.Builder(webview.context) -// -// -// builder.setTitle("로딩 에러").setMessage("${currentContentsProvider?.getWebcontentsName()} ${currentContentsProvider?.lastNumber?.inc()} 여기로 다시 시도?!!") -// builder.setPositiveButton( -// "오키 ${currentContentsProvider?.lastNumber?.inc()} 레고!" -// ) { dialog, id -> -// dialog.dismiss() -// currentContentsProvider?.lastNumber = currentContentsProvider?.lastNumber!!.inc() -// loadContents(currentContentsProvider!!) -// } -// -// builder.setNegativeButton( -// "포기하자" -// ) { dialog, id -> -// dialog.dismiss() -// } -// builder.setNeutralButton( -// "같은 주소로 다시 도전" -// ) { dialog, id -> -// loadContents(currentContentsProvider!!) -// dialog.dismiss() -// } -// alertDialogs.add(builder.create()) -// -// alertDialogs.last()?.show() -// -// },500) -// } -// -// } -// + override fun onReceivedSslError( view: WebView?, handler: SslErrorHandler?, @@ -189,6 +134,9 @@ open class BaseWebContentsViewer { override fun onPageFinished(view: WebView?, url: String?) { super.onPageFinished(view, url) view?.let { + url?.toUri()?.let { + PrefManager.putLastDomain(it.scheme.plus("::/").plus(it.host)) + } if(url?.contains("/list/") ?: false && url?.contains("agit") ?: false){ findListItem { @@ -199,24 +147,13 @@ open class BaseWebContentsViewer { Blog.LOGE("onPageFinished", url ?: "") } } + currentContentsProvider?.doOnloaded(it , { result -> result?.let { mainControllInterface.onLoadedContents(it) } - } , { - it?.let { mainControllInterface.onFindTitle(it.replace("\"","")) } - }, {btn -> - mainControllInterface?.showNextBtn (btn != null){ - webview?.evaluateJavascript("if(document.getElementById('${currentContentsProvider!!.getNextButtonJs()}') != null) document.getElementById('${currentContentsProvider!!.getNextButtonJs()}').click()") { - } - } - },{btn -> - mainControllInterface?.showPrevBtn(btn != null) { - webview?.evaluateJavascript("if(document.getElementById('${currentContentsProvider!!.getPrevButtonJs()}') != null) document.getElementById('${currentContentsProvider!!.getPrevButtonJs()}').click()") { - } - } - }, { complete -> + } , { complete -> if(complete) { mainControllInterface?.completePageLoad(LastInfo().apply { - this.pageUrl = url ?: currentContentsProvider?.getLastedDoamin() ?: "" + this.pageUrl = url?.toUri()?.path ?: currentContentsProvider?.getLastedDoamin() ?: "" this.contentsName = currentContentsProvider?.getWebcontentsName() ?: "" this.pageIndex = 0 }) diff --git a/app/src/main/res/layout/intro.xml b/app/src/main/res/layout/intro.xml index 71afd37..33d13a9 100644 --- a/app/src/main/res/layout/intro.xml +++ b/app/src/main/res/layout/intro.xml @@ -1,181 +1,182 @@ - - - + + tools:context=".activity.Intro"> + + - + - + - + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + android:text="@string/display_the_second_screen" + android:visibility="visible" + android:src="@drawable/angle_left" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintHorizontal_chainStyle="spread" + /> - + - + - + - + - - \ No newline at end of file + + \ No newline at end of file