This commit is contained in:
lunaticbum 2024-09-20 14:04:34 +09:00
parent 0fff1f5aa3
commit aa6fa8a79e
4 changed files with 38 additions and 17 deletions

View File

@ -5,7 +5,6 @@ import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.content.res.Configuration import android.content.res.Configuration
import android.graphics.Bitmap import android.graphics.Bitmap
import android.net.ConnectivityManager
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -16,11 +15,11 @@ import android.text.InputType
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.style.RelativeSizeSpan import android.text.style.RelativeSizeSpan
import android.util.Log import android.util.Log
import android.view.Gravity
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.view.View.GONE import android.view.View.GONE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import android.view.View.inflate
import android.webkit.JavascriptInterface import android.webkit.JavascriptInterface
import android.webkit.WebSettings import android.webkit.WebSettings
import android.webkit.WebView import android.webkit.WebView
@ -56,21 +55,15 @@ import com.mime.dualscreenview.view.PagedTextViewInterface
import com.mime.dualscreenview.view.TouchArea import com.mime.dualscreenview.view.TouchArea
import com.mime.dualscreenview.webcontents.BaseWebContentsViewer import com.mime.dualscreenview.webcontents.BaseWebContentsViewer
import com.mime.dualscreenview.webcontents.MainControllInterface import com.mime.dualscreenview.webcontents.MainControllInterface
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.GotoSomeWhere import com.mime.dualscreenview.webcontents.contentsinfo.GotoSomeWhere
import com.mime.dualscreenview.webcontents.contentsinfo.NewtokiOne import com.mime.dualscreenview.webcontents.contentsinfo.NewtokiOne
import com.mime.dualscreenview.webcontents.getT
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.isManaged
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import io.realm.kotlin.ext.realmListOf
import org.jsoup.Jsoup import org.jsoup.Jsoup
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
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import kotlin.random.Random import kotlin.random.Random
@ -431,8 +424,10 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
super.onPageStarted(view, url, favicon) super.onPageStarted(view, url, favicon)
} }
override fun onPageFinished(webView: WebView?, url: String?) { override fun onPageFinished(webView: WebView?, url: String?) {
super.onPageFinished(webView, url) super.onPageFinished(webView, url)
// val delayed = 3500L + Math.abs(Random.nextLong().rem(9999L))
finishedUrl = url ?: "" finishedUrl = url ?: ""
webView?.postDelayed({ webView?.postDelayed({
webView?.evaluateJavascript( webView?.evaluateJavascript(
@ -444,22 +439,29 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
} }
}, 11000L) }, delayed)
} }
} }
fun showToast(origin: String) { fun showToast(origin: String) {
runOnUiThread { runOnUiThread {
val toast = Toast(this)
toast.duration = Toast.LENGTH_SHORT
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( val view: View = inflate(this, com.mime.dualscreenview.R.layout.simple_toast,null)
baseContext, view.findViewById<TextView>(com.mime.dualscreenview.R.id.text).text = biggerText
biggerText, toast.setView(view)
Toast.LENGTH_SHORT toast.show()
).show() // Toast.makeText(
// baseContext,
// biggerText,
// Toast.LENGTH_SHORT
// ).show()
} }
} }
var delayed = 3500L + Math.abs(Random.nextLong().rem(9999L))
var finishedUrl : String? = null var finishedUrl : String? = null
inner class SaveHelper { inner class SaveHelper {
@JavascriptInterface @JavascriptInterface
@ -472,9 +474,10 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: view_padding.get(0)\n${contents}") // Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: view_padding.get(0)\n${contents}")
if (contents.length > 20) { if (contents.length > 20) {
Uri.parse(finishedUrl).path?.let { Uri.parse(finishedUrl).path?.let {
delayed = 3500L + Math.abs(Random.nextLong().rem(9999L))
HistoryManager.getBooPageInfoContentsSave(it, contents).apply { HistoryManager.getBooPageInfoContentsSave(it, contents).apply {
HistoryManager.getBookPageInfo(it) { book -> HistoryManager.getBookPageInfo(it) { book ->
showToast("saved ${book?.getTitleItem()} :: lenght = ${contents.length}") showToast("saved ${book?.getTitleItem()} \n:: lenght = ${contents.length} \n:: saveTarget = ${saveTarget.size}\n:: delayed >> ${delayed}")
} }
}.apply { }.apply {
HistoryManager.getBookInfos(it) { saveItem(it)} HistoryManager.getBookInfos(it) { saveItem(it)}

View File

@ -286,9 +286,7 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface {
} }
fun forceUpdateUI() { fun forceUpdateUI() {
// mPagedTextViewInterface?.onTouch(TouchArea.Center)
hiddenTextView?.doUpdate() hiddenTextView?.doUpdate()
// hanler?.postDelayed(touchTimeover, 3000L)
} }
override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) { override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) {

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="10dp"/>
<solid android:color="#44ffffff"/>
<stroke android:color="@color/white" android:width="1dp"/>
</shape>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/simple_bg"
android:layout_height="wrap_content">
<TextView
android:layout_gravity="center"
android:gravity="left"
android:id="@+id/text"
android:textColor="@color/black"
android:background="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>