From b5ad079439abc01fa6ef4715854d958204ecaf5a Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Sat, 19 Jul 2025 10:54:22 +0900 Subject: [PATCH] ... --- app/src/main/AndroidManifest.xml | 277 +- .../extensions/my_extension/fdfdfdf.html | 3029 +++++++++++++++++ .../extensions/my_extension/messaging.js | 89 +- .../bums/lunatic/launcher/LauncherActivity.kt | 165 +- .../bums/lunatic/launcher/home/GeckoWeb.kt | 23 +- .../lunatic/launcher/home/LauncherHome.kt | 11 +- .../launcher/home/RssViewerActivity.kt | 2 +- .../launcher/home/adapters/RssItemAdapter.kt | 2 +- .../bums/lunatic/launcher/tokiz/BaseToki.kt | 1490 ++++++++ .../bums/lunatic/launcher/tokiz/Comics.kt | 182 + .../bums/lunatic/launcher/tokiz/Novels.kt | 1176 +------ .../bums/lunatic/launcher/tokiz/Webtoons.kt | 183 + .../launcher/tokiz/common/PrefManager.kt | 7 +- .../launcher/tokiz/data/HistoryManager.kt | 58 +- .../{BookPageInfo.kt => ContentsPageInfo.kt} | 36 +- .../launcher/tokiz/data/model/FakeSession.kt | 47 + .../launcher/tokiz/data/model/PageInfo.kt | 24 +- .../launcher/tokiz/dialog/DefaultList.kt | 4 +- .../lunatic/launcher/tokiz/view/BWebview.kt | 45 +- .../launcher/tokiz/view/PagedTextLayout.kt | 18 +- .../contentsinfo/BooktokiStruct.kt | 32 +- .../lunatic/launcher/workers/WorkersDb.kt | 17 +- app/src/main/res/layout/booktoki.xml | 39 +- app/src/main/res/layout/launcher_activity.xml | 47 +- app/src/main/res/layout/launcher_home.xml | 14 +- 25 files changed, 5442 insertions(+), 1575 deletions(-) create mode 100644 app/src/main/assets/extensions/my_extension/fdfdfdf.html create mode 100644 app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt create mode 100644 app/src/main/kotlin/bums/lunatic/launcher/tokiz/Comics.kt create mode 100644 app/src/main/kotlin/bums/lunatic/launcher/tokiz/Webtoons.kt rename app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/{BookPageInfo.kt => ContentsPageInfo.kt} (76%) create mode 100644 app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/FakeSession.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5e876b31..4f36f2d3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -79,11 +79,12 @@ android:requestLegacyExternalStorage="true" > + @@ -99,54 +100,54 @@ - - - - - + + + + + + + + + + - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + @@ -161,52 +162,52 @@ android:permission="android.permission.BIND_JOB_SERVICE" android:exported="false"/> - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/extensions/my_extension/fdfdfdf.html b/app/src/main/assets/extensions/my_extension/fdfdfdf.html new file mode 100644 index 00000000..0a769e4a --- /dev/null +++ b/app/src/main/assets/extensions/my_extension/fdfdfdf.html @@ -0,0 +1,3029 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NH멤버스 팟 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +본문 바로가기 + + + + + +
+ + + +
+
+
+
+
보유 포인트
+
+ + + + + + 48,004 + + + P + +
+
+
+
+
+ 8월 소멸 예정 포인트 +
+ +
+
소멸 포인트 복구불가 안내
+

소멸된 포인트는 복구되지 않으며, 포인트 내역에서 조회하실 수 있습니다.

+ +
+
+
+ + +
+
+
+ 당월 적립 포인트 +
+ +
+
적립포인트 유효기간 안내
+

제휴사를 통해 적립된 포인트 및 이벤트 참여로 적립된 포인트는 유효기간이 있으니, 참고하시기 바랍니다.

+ +
+
+
+
+ + + 0 + + + P +
+
+
+
+ +
+
+
+
+

이용내역

+ +
+
+ + + + + + + + + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+
+
+ + +
+
+ +
+ +
+ +
+ +
+ + + + +
+ +
+ + +
+ +
+
+
+ + + + +
+
+ + +
+ +
+ +
+
+
+
+
+ + + +
+
+
+
+

조회기간 선택

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ + 날짜 선택 +
+
+ + - + +
+ +
+ + 날짜 선택 +
+
+
+

최대 조회 기간은 1년이에요.

+
+
+ + +
+
+
+
+
+ + + + + + + + + + + + + +
+
+
+
+ +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ + + +
+
+
+
+

다른 방법으로 본인인증하기

+
+ +
+
+ + + + + + +
+
+ NH농협카드 / NHOnePASS 인증이란? +
+ + +
+ NH농협카드 인증이란? +

+ 본인 명의의 NH농협 신용카드 또는 체크카드를 통해 본인임을 확인하는 서비스
(법인카드, 가족카드, + 선불카드 이용불가)
인증방식 : 간편인증(올원페이 인증), 일반인증(ARS 인증), 홈페이지 인증 + 총3가지 방식 제공 +

+ NHOnePASS 인증이란? +

+ NH 스마트뱅킹에 등록한 간편비밀번호, 지문(FaceID), 인증서를 통해 편리하게 본인확인 및 로그인할 수 있는 + 서비스
※ NH스마트뱅킹 앱이 설치된 디바이스에서만 이용가능 +

+ +
+ +
+
+
+ +
+
+ +
+
+ + +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ + + + + +
+
+
+
+ 회원가입을 중단하고 로그인 페이지로
이동하시겠어요? +
+ + +
+
+
+
+ + + +
+
+
+ +
+ 본인확인을 중단 하시겠어요? +
+ +
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/extensions/my_extension/messaging.js b/app/src/main/assets/extensions/my_extension/messaging.js index e4ad54dc..6a61aa69 100644 --- a/app/src/main/assets/extensions/my_extension/messaging.js +++ b/app/src/main/assets/extensions/my_extension/messaging.js @@ -45,20 +45,62 @@ port.onMessage.addListener(response => { else scrollByPercentUpDown(Number(isUpDown),100); } break; + case "ViewerTouch": { + if (document.querySelector(".show_viewer")) { + var area = response["area"] + var current = Number(document.querySelector("#mcv_currentPageNum").innerHTML) + var total = Number(document.querySelector("#mcv_totalPagesNum").innerHTML) + + if ("left" === area) { + if (current > 0) { + document.querySelector("#mcv_clickAreaRight").click() + } else { + document.querySelector("#goPrevBtn").click() + } + } else if ("right" === area) { + if (current < total) { + document.querySelector("#mcv_clickAreaLeft").click() + }else { + document.querySelector("#goNextBtn").click() + } + + } + } + } + break; case "onLoaded":{ } break; + case "saveContent":{ + sendMessage( + { + type: "SHOWVIEWER", + contents : document.documentElement.outerHTML + } + ); + + } default: port.postMessage(`Received: ${JSON.stringify(response)}`); break } }); -if(document.querySelector(".list-body")) { +if (document.location.href.search("reddit") > -1) { + if (document.querySelector('#xpromo-bottom-sheet')) { + document.querySelector('#xpromo-bottom-sheet').remove() + } +} +if (document.querySelector(".show_viewer") !== null) { + document.querySelector(".show_viewer").click(); + sendMessage({type: "SHOWVIEWER"}); +} +if(document.querySelector(".list-body") !== null) { var listBody = null try {listBody = document.querySelector(".list-body");}catch (e) {} getList(listBody.children) -} else if(document.querySelector("#novel_content")){ +} +if(document.querySelector("#novel_content") !== null){ var title = null var contents = null try {title = toonTitle(document.querySelector(".page-desc")); }catch (e) {} @@ -74,16 +116,18 @@ if(document.querySelector(".list-body")) { } ); } -} else if(document.querySelector("#html_encoder_div")) { +} +if(document.querySelector("#html_encoder_div")) { sendMessage( { type: "WebtoonContents", } ); -} else { - sendMessage({type:"MSG",msg:"connected has Nothings"}); - loadComplete() } +// else { +// sendMessage({type:"MSG",msg:"connected has Nothings"}); +// loadComplete() +// } function getList(children) { @@ -93,9 +137,29 @@ function getList(children) { for (i= 0; i < maxCount; i++) { var chapterNum = children[i].getElementsByClassName('wr-num')[0].textContent; var pageUrl = children[i].getElementsByClassName('wr-subject')[0].getElementsByTagName('a')[0].href; + var contentsType = location.hostname.search("book") > -1 ? "book" : location.hostname.search("mana") > -1 ? "comics" : location.hostname.search("new") > -1 ? "webtoon" : "web"; if (pageUrl != null && pageUrl.length > 0 && pageUrl.startsWith("http")) { - pageUrl = new URL(pageUrl).pathname; + var urlObj =URL.parse(pageUrl); + pageUrl = urlObj.protocol + '//' + urlObj.host + urlObj.pathname; + if (pageUrl) { + var paths = pageUrl.split('/') + if (paths.length > 0) { + var last = paths[paths.length - 1]; + if (last && Array.from(last).every(ch => ch >= '0' && ch <= '9')) { + + } else { + paths.pop(); + } + } + + var newP = paths.join('/'); + + pageUrl = URL.parse(newP).pathname + } + } else { + console.log("pageUrl.startsWith('http') == false" + pageUrl); } + var chapterTitle = children[i].getElementsByClassName('wr-subject')[0].getElementsByTagName('a')[0].innerText; if(chapterTitle.split('\n').length > 1) { chapterTitle = chapterTitle.split('\n')[1]; @@ -107,6 +171,7 @@ function getList(children) { 'chapterID': Number(chapterNum), 'chapterNum': Number(chapterNum), 'pathUrl': pageUrl, + 'contentsType': contentsType, 'bookPageUrl': bookPageUrl, 'chapterTitle': chapterTitle, 'bookTitle': bookTitle, @@ -121,6 +186,7 @@ function getList(children) { { type: "getListResult", bookInfos: { + 'contentsType': contentsType, bookTitle: bookTitle, bookPageUrl: new URL(location.href).pathname, pages: contentsArray , @@ -150,7 +216,7 @@ function scrollByPercent(current , max) { const moveAmount = pageHeight / max; window.scrollTo({ top: moveAmount * current, behavior: "smooth" }); } - +document.querySelector(".header__inner") function scrollByPercentUpDown(isToDown , max) { const pageHeight = Math.max( document.body.scrollHeight, @@ -161,7 +227,7 @@ function scrollByPercentUpDown(isToDown , max) { document.documentElement.clientHeight ); const currentScroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; - const moveAmount = Math.max(pageHeight / max,100); + const moveAmount = Math.max(pageHeight / max,150); window.scrollTo({ top: currentScroll + (moveAmount * isToDown) , behavior: "smooth" }); } @@ -172,6 +238,11 @@ function sendMessage(msg) { port.postMessage(JSON.stringify(msg)); } +function toast(msg) { + port.postMessage(JSON.stringify({type:"MSG",msg:msg})); +} + + function dssd() { } \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt index 70a59af0..ee8dd975 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt @@ -82,6 +82,8 @@ import bums.lunatic.launcher.home.RssViewBuilder import bums.lunatic.launcher.model.RssData import bums.lunatic.launcher.model.RssDataType import bums.lunatic.launcher.receiver.NLService +import bums.lunatic.launcher.tokiz.Comics +import bums.lunatic.launcher.tokiz.Webtoons import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.FeedParseManager import bums.lunatic.launcher.utils.getJ @@ -307,9 +309,10 @@ internal class LauncherActivity : CommonActivity() { var onExit = false var lastAction = MotionEvent.ACTION_HOVER_EXIT override fun dispatchKeyEvent(ev: KeyEvent): Boolean { - Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}") - if (ev?.device?.name?.contains("SM-031N Mouse") == true) { + val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) + Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name} , keyCode >> ${ev?.keyCode}") + if (ev?.device?.name?.contains("SM-031N Mouse") == true) { when(ev.action) { ACTION_UP -> { Blog.LOGE("dispatch dispatchKeyEvent>>> ${ev}") @@ -384,26 +387,42 @@ internal class LauncherActivity : CommonActivity() { } else { if(MotionEvent.ACTION_UP.equals(ev?.action ?: MotionEvent.ACTION_CANCEL) == true) { - when (ev.keyCode) { + return when (ev.keyCode) { KeyEvent.KEYCODE_VOLUME_DOWN -> { - - novels?.actionNextEvent() - return true + if(currentFragment is Novels){ currentFragment.actionNextEvent() } + true } - KeyEvent.KEYCODE_VOLUME_UP -> { - novels?.actionPrevEvent() - return true + if(currentFragment is Novels){ currentFragment.actionPrevEvent() } + true } - else -> return false + else -> false } } else { - return false + return when (ev.keyCode) { + KeyEvent.KEYCODE_VOLUME_DOWN -> { + true + } + KeyEvent.KEYCODE_VOLUME_UP -> { + true + } + else -> false + } } } return super.dispatchKeyEvent(ev) } + override fun dispatchTrackballEvent(event: MotionEvent?): Boolean { + Blog.LOGE("event >>> ${event?.device}") + return super.dispatchTrackballEvent(event`) + } + + @SuppressLint("RestrictedApi") + override fun dispatchKeyShortcutEvent(event: KeyEvent): Boolean { + Blog.LOGE("event >>> ${event.device}") + return super.dispatchKeyShortcutEvent(event) + } fun onClickCenterButton() { @@ -545,11 +564,7 @@ internal class LauncherActivity : CommonActivity() { "android.intent.extra.EXTRA_START_REASON" ).equals("startDockOrHome") ) { - if (binding.home.visibility == View.VISIBLE) { - switchAppDrawer() - } else { - } } else { intent?.extras?.keySet()?.forEach { try { @@ -576,8 +591,8 @@ internal class LauncherActivity : CommonActivity() { // } super.onNewIntent(intent) } - var home : LauncherHome? = null - var novels : Novels? = null + + @SuppressLint("NewApi", "MissingPermission") override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() @@ -599,74 +614,40 @@ internal class LauncherActivity : CommonActivity() { binding.tabs.setOnCheckedChangeListener { g, id -> - when(id) { - R.id.feeds -> { - if(binding.feeds.isChecked) { - if (home == null) { - home = binding.home.getFragment() - } - binding.home.visibility = View.VISIBLE - binding.booktoki.visibility = View.GONE - } else { - binding.home.visibility = View.GONE - if (novels == null) { - novels = binding.booktoki.getFragment() - - } else { - novels?.onResume() - } - binding.booktoki.visibility = View.VISIBLE - } - } - R.id.book ->{ - if(binding.book.isChecked) { - binding.home.visibility = View.GONE - if (novels == null) { - novels = binding.booktoki.getFragment() - } else { - novels?.onResume() - } - binding.booktoki.visibility = View.VISIBLE - } else { - if (home == null) { - home = binding.home.getFragment() - } - binding.home.visibility = View.VISIBLE - binding.booktoki.visibility = View.GONE - } - } - else -> {} - } + showContents(id) } /* handle navigation back events */ handleBackPress() - - val cn = ComponentName(this, NLService::class.java) - val n = applicationContext.getSystemService(NOTIFICATION_SERVICE) as NotificationManager - if (n.isNotificationListenerAccessGranted(cn)) { - } else { - val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS) - startActivity(intent) - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - if (!isExternalStorageManager()) { - try { - startActivityForResult(Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).apply { - addCategory("android.intent.category.DEFAULT") - data = Uri.parse(String.format("package:%s", applicationContext.packageName)) - }, 300) - } catch (e: Exception) { - startActivityForResult(Intent().apply { - action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION - }, 300) - } - } - } updateLocationService() - binding.book.isChecked = true + binding.feeds.isChecked = true } + fun showContents(id : Int) { + when(id) { + R.id.feeds -> { + supportFragmentManager.beginTransaction() + .replace(R.id.fragment_container, LauncherHome()) + .commit() + } + R.id.books ->{ + supportFragmentManager.beginTransaction() + .replace(R.id.fragment_container, Novels()) + .commit() + } + R.id.webtoons ->{ + supportFragmentManager.beginTransaction() + .replace(R.id.fragment_container, Webtoons()) + .commit() + } + R.id.comics ->{ + supportFragmentManager.beginTransaction() + .replace(R.id.fragment_container, Comics()) + .commit() + } + else -> {} + } + } private fun initGeckoRuntime() { if (sRuntime == null) { try { @@ -697,14 +678,14 @@ internal class LauncherActivity : CommonActivity() { super.onDestroy() } - var blutoothManager : BluetoothManager? = null +// var blutoothManager : BluetoothManager? = null override fun onStart() { super.onStart() - blutoothManager = BluetoothManager(this) - blutoothManager?.register() - blutoothManager?.initBluetoothAdapter() - blutoothManager?.blueToothState() - blutoothManager?.getPairedDevices() +// blutoothManager = BluetoothManager(this) +// blutoothManager?.register() +// blutoothManager?.initBluetoothAdapter() +// blutoothManager?.blueToothState() +// blutoothManager?.getPairedDevices() statusBarView() setBgColor() } @@ -713,7 +694,7 @@ internal class LauncherActivity : CommonActivity() { override fun onResume() { super.onResume() refreshFeeds() - blutoothManager?.getPairedDevices() +// blutoothManager?.getPairedDevices() Blog.LOGE("LauncherActivity onResume") } @@ -760,11 +741,17 @@ internal class LauncherActivity : CommonActivity() { private fun handleBackPress() { onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { - if (binding.booktoki.isVisible) { - finish() - } else { - finish() + val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) + when(currentFragment) { + is LauncherHome ->{ + currentFragment.doNextPage() + } } +// if (binding.ho.isVisible) { +// finish() +// } else { +// finish() +// } } }) } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt index d5758390..11173440 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt @@ -1,6 +1,8 @@ package bums.lunatic.launcher.home import android.content.Context +import android.content.Intent +import android.net.Uri import android.os.Handler import android.os.Looper import android.os.Message @@ -16,6 +18,7 @@ import android.view.KeyEvent.KEYCODE_BUTTON_X import android.view.KeyEvent.KEYCODE_BUTTON_Y import android.view.KeyEvent.KEYCODE_DPAD_DOWN import android.view.KeyEvent.KEYCODE_DPAD_UP +import android.widget.ProgressBar import bums.lunatic.launcher.LauncherActivity.Companion.getRuntime import bums.lunatic.launcher.tokiz.view.BWebview import bums.lunatic.launcher.tokiz.view.JxEvent @@ -47,7 +50,7 @@ class GeckoWeb : BWebview { constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { buildWeb() } - + var progress : ProgressBar? = null val mPortNam = "browser" val extPath = "resource://android/assets/extensions/my_extension/" val extId = "messaging@booktoki468.com" @@ -168,7 +171,7 @@ class GeckoWeb : BWebview { session: GeckoSession, mediaSession: MediaSession ) { - Blog.LOGE("onPlay") + Blog.LOGE("onPlay $mediaSession") super.onPlay(session, mediaSession) } @@ -184,7 +187,7 @@ class GeckoWeb : BWebview { session: GeckoSession, mediaSession: MediaSession ) { - Blog.LOGE("onStop") + Blog.LOGE("onStop $mediaSession") super.onStop(session, mediaSession) } @@ -275,8 +278,21 @@ class GeckoWeb : BWebview { super.onSessionStateChange(session, sessionState) } + override fun onProgressChange(session: GeckoSession, progress: Int) { + super.onProgressChange(session, progress) + this@GeckoWeb.progress?.setProgress(progress,true) + } override fun onPageStart(session: GeckoSession, url: String) { super.onPageStart(session, url) + if (url?.contains("reddit.app.link") == true) { + session.stop() + Uri.parse(url)?.let { uri -> + context.startActivity(Intent().apply { + action = Intent.ACTION_VIEW + data = uri + }) + } + } } override fun onPageStop(session: GeckoSession, success: Boolean) { @@ -325,6 +341,7 @@ class GeckoWeb : BWebview { // url이 현재 로드된 주소입니다. Blog.LOGE("GeckoView", "현재 주소: $url") Blog.LOGE("GeckoView", "현재 session: $session") + url?.let { url -> if (url.split("//").size > 1) { url.replace("//", "/").replace("https:/", "https://").let { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt index 07385aa9..793470fc 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt @@ -25,6 +25,7 @@ import android.os.Bundle import android.os.Handler import android.os.Looper import android.view.LayoutInflater +import android.view.PointerIcon import android.view.View import android.view.ViewGroup import android.widget.Toast @@ -261,7 +262,7 @@ internal class LauncherHome : Fragment() { binding.infoList.visibility = View.VISIBLE binding.infoList.adapter = mRssAdapter binding.infoList.setOnTouchListener { v,e -> - if (e.device.name?.contains("JX-12",true) == true) { + if (e.device.name?.contains("JX-12",true) == true|| e.device.name?.equals("J06",true) == true) { Blog.LOGE("touchEvent -> ${e}") return@setOnTouchListener mSimpleFingerGestures.onTouch(v,e) } else { @@ -270,6 +271,7 @@ internal class LauncherHome : Fragment() { } } queryInfos() + binding.geckoWeb.progress = binding.progressBar binding.geckoWeb.jxInteface = { jxEvent -> when(jxEvent) { JxEvent.SCROLL_UP -> binding.geckoWeb.sendScrollDown(false) @@ -285,6 +287,9 @@ internal class LauncherHome : Fragment() { } } } + val nullCursor = PointerIcon.getSystemIcon(context!!, PointerIcon.TYPE_NULL) + binding.root.setPointerIcon(nullCursor) + return binding.root } @@ -336,7 +341,7 @@ internal class LauncherHome : Fragment() { delete( query() .query("pubDate < $0", beforeDay(30)) - .query("category != $0 AND category != $1 ", RssDataType.GURU.name, RssDataType.MOST.name) +// .query("category != $0 AND category != $1 ", RssDataType.GURU.name, RssDataType.MOST.name) .query("vote != $0", true).find() ) } @@ -369,7 +374,7 @@ internal class LauncherHome : Fragment() { beforeQuery() var rQ = WorkersDb.getRealm().query().query("read < $0", nomoreShowCount).distinct("originPage", "title") if (!noLimit) rQ.query("pubDate > $0", beforeOneDay()) - ((filter?.size ?: 0) > 0).letTrue {filter!!.forEach {rQ = rQ.query("category != $0", it.name)}} +// ((filter?.size ?: 0) > 0).letTrue {filter!!.forEach {rQ = rQ.query("category != $0", it.name)}} updateQuery(rQ) } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt index a6298a9e..32681169 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewerActivity.kt @@ -116,7 +116,7 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene private val swipeTime = 300 // 스와이프 최대 시간(ms) private val clickThreshold = 30 // 클릭으로 인정할 최대 이동 거리(px) override fun onTouch(v: View?, event: MotionEvent): Boolean { - if(event.device.name.equals("JX-12",true)) { + if (event.device.name?.contains("JX-12",true) == true|| event.device.name?.equals("J06",true) == true) { when (event.action) { MotionEvent.ACTION_DOWN -> { startX = event.x diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt index 7f71f5bb..acde5756 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt @@ -220,7 +220,7 @@ internal class RssItemAdapter ( event: MotionEvent ): Boolean { Blog.LOGE("event.device.name >>> ${event.device.name}") - if (event.device.name?.contains("JX-12",true) == true) { + if (event.device.name?.contains("JX-12",true) == true|| event.device.name?.equals("J06",true) == true) { return true//mSimpleFingerGestures.onTouch(v,event) } else { return false diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt new file mode 100644 index 00000000..b39c8a87 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt @@ -0,0 +1,1490 @@ +package bums.lunatic.launcher.tokiz + +import android.content.DialogInterface +import android.content.Intent +import android.content.pm.ActivityInfo +import android.content.res.Configuration +import android.graphics.Bitmap +import android.net.Uri +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.os.Message +import android.text.InputType +import android.text.SpannableStringBuilder +import android.text.style.RelativeSizeSpan +import android.util.Log +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.PointerIcon +import android.view.View +import android.view.View.GONE +import android.view.View.OnTouchListener +import android.view.View.VISIBLE +import android.view.View.inflate +import android.view.ViewGroup +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.ArrayAdapter +import android.widget.EditText +import android.widget.TextView +import android.widget.Toast +import androidx.appcompat.app.AlertDialog +import androidx.core.net.toUri +import androidx.core.view.isVisible +import androidx.fragment.app.Fragment +import bums.lunatic.launcher.LauncherActivity.Companion.getRuntime +import bums.lunatic.launcher.R +import bums.lunatic.launcher.tokiz.common.PairArray +import bums.lunatic.launcher.tokiz.common.TouchArea +import bums.lunatic.launcher.tokiz.common.colorz +import bums.lunatic.launcher.tokiz.common.getIndex +import bums.lunatic.launcher.tokiz.common.typesfacez +import bums.lunatic.launcher.tokiz.data.HistoryManager +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsCollection +import bums.lunatic.launcher.tokiz.data.model.PageInfosJ +import bums.lunatic.launcher.tokiz.data.model.HistoryItem +import bums.lunatic.launcher.tokiz.data.model.LastInfo +import bums.lunatic.launcher.tokiz.data.model.PortMessage +import bums.lunatic.launcher.tokiz.data.model.ReaderConfig +import bums.lunatic.launcher.tokiz.dialog.DefaultList +import bums.lunatic.launcher.tokiz.view.JxEvent +import bums.lunatic.launcher.tokiz.view.PagedTextLayout +import bums.lunatic.launcher.tokiz.view.PagedTextViewInterface +import bums.lunatic.launcher.databinding.BooktokiBinding +import bums.lunatic.launcher.tokiz.data.model.FakeSession +import bums.lunatic.launcher.tokiz.data.model.FakeSessions +import bums.lunatic.launcher.utils.Blog +import com.google.gson.Gson +import io.realm.kotlin.Realm +import io.realm.kotlin.UpdatePolicy +import io.realm.kotlin.ext.copyFromRealm +import io.realm.kotlin.ext.query +import org.json.JSONException +import org.json.JSONObject +import org.mozilla.gecko.util.ThreadUtils +import org.mozilla.geckoview.GeckoResult +import org.mozilla.geckoview.GeckoSession +import org.mozilla.geckoview.MediaSession +import org.mozilla.geckoview.WebExtension +import org.mozilla.geckoview.WebExtension.MessageDelegate +import org.mozilla.geckoview.WebExtension.PortDelegate +import org.mozilla.geckoview.WebExtensionController.AddonManagerDelegate +import org.mozilla.geckoview.WebRequestError +import java.lang.System.currentTimeMillis +import java.net.URL +import java.text.SimpleDateFormat +import java.util.Date +import kotlin.collections.ArrayList +import kotlin.collections.List +import kotlin.collections.MutableList +import kotlin.collections.arrayListOf +import kotlin.collections.first +import kotlin.collections.isNotEmpty +import kotlin.collections.last +import kotlin.collections.sortBy +import kotlin.random.Random +import kotlin.text.contains +import kotlin.text.endsWith +import kotlin.text.equals +import kotlin.text.replace +import kotlin.text.split +import kotlin.text.startsWith +import kotlin.text.toInt +import kotlin.text.toRegex +import kotlin.text.trim + + +abstract class BaseToki : Fragment(), PagedTextViewInterface { + fun openRealm() : Realm = HistoryManager.openRealm + var lastInfo: LastInfo? = null + var currentPage: ContentsPageInfo? = null + var saveContinuation = false + val handle = object : Handler(Looper.getMainLooper()) { + override fun handleMessage(msg: Message) { + if (msg.what == 0) { + (msg.obj as? ReaderConfig)?.let { + } + } + } + } + + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + Blog.LOGD(log = "onConfigurationChanged ${this::class.java.name} >> newConfig ${newConfig}") + } + + var lastedUrl: String? = null + var canGoBack: Boolean? = null + protected lateinit var binding: BooktokiBinding + + var mPort: WebExtension.Port? = null + val mPortNam = "browser" + val extPath = "resource://android/assets/extensions/my_extension/" + val extId = "messaging@booktoki468.com" + var mExtension: WebExtension? = null + abstract val contentsType : String + abstract var lastNumber : Int + abstract val webcontentsName : String + abstract val afterDot : String + fun getLastedDoamin(): String { + return String.format("https://%s%d.%s", webcontentsName , lastNumber, afterDot) + } + val OnTouchListener = object : OnTouchListener { + + override fun onTouch(v: View?, event: MotionEvent): Boolean { + when (event.getAction()) { + MotionEvent.ACTION_DOWN -> { + handle.removeCallbacks(mActionUp) + handle.removeCallbacks(mActionDown) + if(!binding.pagedLayer.isVisible) { + + } + } + + MotionEvent.ACTION_UP -> { + handle.removeCallbacks(mActionUp) + handle.removeCallbacks(mActionDown) + } + } + return false + } + + var mActionDown: Runnable = object : Runnable { + override fun run() { + sendScrollDown(false) + handle.postDelayed(this, 150) + } + } + var mActionUp: Runnable = object : Runnable { + override fun run() { + sendScrollDown(true) + handle.postDelayed(this, 150) + } + } + } + + + + var mOnGenericMotionListener = object : View.OnGenericMotionListener{ + override fun onGenericMotion( + v: View?, + event: MotionEvent? + ): Boolean { + Blog.LOGE("event >>>> $event") + return true + } + } + + val addonManagerDelegate = object : AddonManagerDelegate { + override fun onReady(extension: WebExtension) { + Blog.LOGE("onReady ${extension.id} from WebExtension") + mExtension = extension + + } + + override fun onEnabling(extension: WebExtension) { + Blog.LOGE("onEnabling ${extension.id} from WebExtension") + } + + override fun onEnabled(extension: WebExtension) { + Blog.LOGE("onEnabled ${extension.id} from WebExtension") +// extension?.setMessageDelegate(messageDelegate, mPortNam) + mExtension = extension + + } + } + private fun aceptUrl(string: String): Boolean { + Blog.LOGE("string >>> ${string}, domain >>> ${getLastedDoamin()} :: isAcept ${string.contains(getLastedDoamin())}") + return string.contains(getLastedDoamin()) + } + val mediaDelegate = object : GeckoSession.MediaDelegate { + override fun onRecordingStatusChanged( + session: GeckoSession, + devices: Array + ) { + super.onRecordingStatusChanged(session, devices) + } + } + val mediaSessionDelegate = object : MediaSession.Delegate { + override fun onActivated( + session: GeckoSession, + mediaSession: MediaSession + ) { + super.onActivated(session, mediaSession) + } + + override fun onDeactivated( + session: GeckoSession, + mediaSession: MediaSession + ) { + super.onDeactivated(session, mediaSession) + } + + override fun onMetadata( + session: GeckoSession, + mediaSession: MediaSession, + meta: MediaSession.Metadata + ) { + super.onMetadata(session, mediaSession, meta) + } + + override fun onFeatures( + session: GeckoSession, + mediaSession: MediaSession, + features: Long + ) { + super.onFeatures(session, mediaSession, features) + } + + override fun onPlay( + session: GeckoSession, + mediaSession: MediaSession + ) { + super.onPlay(session, mediaSession) + } + + override fun onPause( + session: GeckoSession, + mediaSession: MediaSession + ) { + super.onPause(session, mediaSession) + } + + override fun onStop( + session: GeckoSession, + mediaSession: MediaSession + ) { + super.onStop(session, mediaSession) + } + + override fun onPositionState( + session: GeckoSession, + mediaSession: MediaSession, + state: MediaSession.PositionState + ) { + super.onPositionState(session, mediaSession, state) + } + + override fun onFullscreen( + session: GeckoSession, + mediaSession: MediaSession, + enabled: Boolean, + meta: MediaSession.ElementMetadata? + ) { + super.onFullscreen(session, mediaSession, enabled, meta) + } + } + val contentDelegate = object : GeckoSession.ContentDelegate { + + } + val progressDelegate = object : GeckoSession.ProgressDelegate { + override fun onProgressChange(session: GeckoSession, progress: Int) { + super.onProgressChange(session, progress) + } + override fun onSecurityChange( + session: GeckoSession, + securityInfo: GeckoSession.ProgressDelegate.SecurityInformation + ) { + Blog.LOGE("onSecurityChange $securityInfo from WebExtension") + super.onSecurityChange(session, securityInfo) + } + + override fun onSessionStateChange( + session: GeckoSession, + sessionState: GeckoSession.SessionState + ) { + Blog.LOGE("onSessionStateChange $sessionState from WebExtension") + super.onSessionStateChange(session, sessionState) + when(this@BaseToki) { + is Comics, is Webtoons -> { + onStateChange(sessionState) + } + else -> { + + } + } + } + + override fun onPageStart(session: GeckoSession, url: String) { + super.onPageStart(session, url) + binding.progress.visibility = VISIBLE + if (aceptUrl(url)) { + + } else { +// session.stop() + } + } + + + + override fun onPageStop(session: GeckoSession, success: Boolean) { + Blog.LOGE("onPageStop $success from WebExtension") + super.onPageStop(session, success) + if (success && mPort != null) { + if (mPort == null) { + // No extension registered yet, let's ignore this message + return + } + binding.menuWeb.postDelayed({ + Blog.LOGE("onPageStop $success from WebExtension ${mPort!!.name}") + val message: JSONObject = JSONObject() + try { + message.put("type", "getList") + message.put("event", "sadsadds") + message.put("tab", session.settings.screenId) + } catch (ex: JSONException) { + throw RuntimeException(ex) + } + + mPort!!.postMessage(message) + when(this@BaseToki) { + is Comics , is Webtoons -> { + lastInfo + } + else -> { + + } + } + binding.progress.visibility = GONE + }, 10L) + } + } + } + val navigationDelegate = object : GeckoSession.NavigationDelegate { + override fun onLoadError( + session: GeckoSession, + uri: String?, + error: WebRequestError + ): GeckoResult? { + error.printStackTrace() + Blog.LOGE("onLoadError >>> ${uri} ::>> ${error.category} , ${error.code}") + if (error.code == WebRequestError.ERROR_NET_RESET) { + session.loadUri("https://naver.com") + } + return super.onLoadError(session, uri, error) + } + + override fun onNewSession( + session: GeckoSession, + uri: String + ): GeckoResult? { + Blog.LOGE("GeckoView", "onNewSession: $session from WebExtension") + + + return super.onNewSession(session, uri) + } + + override fun onLocationChange( + session: GeckoSession, + url: String?, + perms: MutableList, + hasUserGesture: Boolean + ) { + if (url?.startsWith("about") ?: true) { + + } else { + // url이 현재 로드된 주소입니다. + Blog.LOGE("GeckoView", "현재 주소: $url") + Blog.LOGE("GeckoView", "현재 session: $session") + url?.let { url -> + if (url.split("//").size > 1) { + url.replace("//", "/").replace("https:/", "https://").let { + Blog.LOGE("url >> ${url} , it >>> ${it}") + lastedUrl = url + } + } else { + lastedUrl = url + } + } + completePageLoad(LastInfo().apply { + this.pageUrl = url?.toUri()?.path ?: getLastedDoamin() ?: "" + this.contentsName = webcontentsName ?: "" + this.contentsType = if (url?.contains("book",true) == true) {"book"} + else if(url?.contains("new",true) == true) {"webtoon"} + else if(url?.contains("mana",true) == true) {"comics"} + else "web" + this.pageIndex = 0 + }) + } + } + + override fun onCanGoBack(session: GeckoSession, canGoBack: Boolean) { + super.onCanGoBack(session, canGoBack) + this@BaseToki.canGoBack = canGoBack + if (canGoBack) { + + } + } + + } + val portDelegate: PortDelegate = object : PortDelegate { + + override fun onPortMessage( + message: Any, port: WebExtension.Port + ) { + Blog.LOGE("PortDelegate", "Received message from extension: $message") + if (message is String && message.contains("type")) { + try { + var lPortMessage = + Gson().fromJson(message, PortMessage::class.java) + when(lPortMessage.type) { + "getListResult" -> { + lPortMessage.bookInfos?.let { onBookInfos(it) } + } + "BookContents"->{ + lPortMessage?.book?.chapterTitle?.let { onFindTitle(it) } + lPortMessage?.book?.bookContents?.let { onLoadedContents(it) } + } + "NotRegistered" -> { + binding.pagedLayer.visibility = GONE + } + "WebtoonContents"-> { + binding.pagedLayer.visibility = GONE + } + "MSG" -> { + lPortMessage.msg?.let { Toast.makeText(requireContext(),it, Toast.LENGTH_SHORT).show() } + } + "SHOWVIEWER" -> { + binding.progress.visibility = GONE + } + else -> { + + } + } + binding.progress.visibility = GONE + } catch (e: Exception) { + e.printStackTrace() + } + + } + } + + + override fun onDisconnect(port: WebExtension.Port) { + // This port is not usable anymore. + if (port === mPort) { + mPort = null + } + } + } + val messageDelegate: MessageDelegate = object : MessageDelegate { + override fun onConnect(port: WebExtension.Port) { + mPort = port + mPort!!.setDelegate(portDelegate) + } + + override fun onMessage( + nativeApp: String, + message: Any, + sender: WebExtension.MessageSender + ): GeckoResult? { + Blog.LOGE( + "messageDelegate", + "onMessage from WebExtension: ${nativeApp} , $message , ${sender.webExtension.id}" + ) + return super.onMessage(nativeApp, message, sender) + } + + + } + fun processPageUrl(pageUrl: String): String { + if (pageUrl != null && pageUrl.isNotEmpty() && pageUrl.startsWith("http")) { + var workingUrl = pageUrl + val paths = workingUrl.split("/").toMutableList() + if (paths.isNotEmpty()) { + val last = paths.last() + if (last.isNotEmpty() && last.all { it in '0'..'9' }) { + Log.d("TAG", "only nums $last") + } else { + Log.d("TAG", "not only nums $last") + paths.removeAt(paths.size - 1) + } + } + workingUrl = paths.joinToString("/") + // URL이 정상적으로 파싱되는지 확인(try-catch 권장) + val path = try { + URL(workingUrl).path + } catch (e: Exception) { + Log.d("TAG", "Invalid URL: $workingUrl") + return pageUrl + } + return path + } else { + var workingUrl = pageUrl + val paths = workingUrl.split("/").toMutableList() + if (paths.isNotEmpty()) { + val last = paths.last() + if (last.isNotEmpty() && last.all { it in '0'..'9' }) { + Log.d("TAG", "only nums $last") + } else { + Log.d("TAG", "not only nums $last") + paths.removeAt(paths.size - 1) + } + } + workingUrl = paths.joinToString("/") + return workingUrl + } + } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + Blog.LOGD(log = "onCreate ${this::class.java.name} >> savedInstanceState ${savedInstanceState}") + binding = BooktokiBinding.inflate(inflater) + binding.menuWeb.let { + it.lastDomain = getLastedDoamin() + it.setOnLongClickListener { + onTouch(TouchArea.Center) + return@setOnLongClickListener false + } + it.setOnGenericMotionListener(mOnGenericMotionListener) + } + + binding.btnList.setOnClickListener { v -> + lastedUrl?.let { + Uri.parse(it).path?.let { + HistoryManager.getBookInfos(contentsType,processPageUrl(it), { + it?.let { + it.pages.sortBy { it.pathUrl } + Blog.LOGE("bind ing.btnList it >>> $it") + showList(it) + } + }) + } + } + } + + + binding.btnSetting.setOnClickListener { v -> + activity?.startActivity(Intent(requireContext(), Settings::class.java)) + } + binding.btnHistory.setOnClickListener { v -> + getHistory()?.let { + showHistory(it) + } + } + + binding.btnHome.setOnClickListener { v -> + binding.pagedLayer.visibility = GONE + goToHome() + } + getRuntime()?.apply { + val session: GeckoSession = GeckoSession() + session.open(this) + binding.menuWeb.setSession(session) + binding.menuWeb.jxInteface = { jxEvent -> + Blog.LOGE("jxEvent $jxEvent") + when(jxEvent) { + JxEvent.SCROLL_UP -> sendScrollDown(true) + JxEvent.SCROLL_DOWN -> sendScrollDown(false) + JxEvent.SWIPE_LEFT -> { + if (contentsType.equals("comics", true)) { + sendViewerTouch("left") + } else { + actionNextEvent() + } + } + JxEvent.SWIPE_RIGHT -> { + if (contentsType.equals("comics", true)) { + sendViewerTouch("right") + } else { + actionPrevEvent() + } + } + else -> {} + } + } + session.contentDelegate = contentDelegate + session.progressDelegate = progressDelegate + session.navigationDelegate = navigationDelegate + this.webExtensionController.setAddonManagerDelegate(addonManagerDelegate) + session.mediaDelegate = mediaDelegate + session.mediaSessionDelegate = mediaSessionDelegate + this.webExtensionController + .ensureBuiltIn(extPath, extId) + .accept( // Register message delegate for background script + { extension: WebExtension? -> + ThreadUtils.runOnUiThread( + Runnable { + if (extension != null) { + session.webExtensionController.setMessageDelegate( + extension, + messageDelegate, + mPortNam + ) + } + }) + }, + { e: Throwable? -> Log.e("MessageDelegate", "Error registering WebExtension", e) }) + } + val nullCursor = PointerIcon.getSystemIcon(context!!, PointerIcon.TYPE_NULL) + binding.root.setPointerIcon(nullCursor) + return binding.root + } + + + + private fun getHistory() : List? { + try { + var realm = openRealm() + return realm.query().query("contentsType == $0", contentsType).find()?.copyFromRealm() + }catch (e: Exception){ + e.printStackTrace() + } + return null + } + + + + override fun onStart() { + super.onStart() + } + + override fun onResume() { + super.onResume() + loadLastInfo() + } + + fun getLastinfo() : LastInfo? { + lastInfo = openRealm().query("contentsType == $0", contentsType).find().last()?.copyFromRealm() + Blog.LOGE("lastInfo >>> ${Gson().toJson(lastInfo)}") + return lastInfo + } + + fun loadLastInfo() { + var targetUrl = getLastedDoamin() + try { + applyReaderConfig() + getLastinfo()?.let { lastInfo -> + Blog.LOGE("lastInfo >>> ${lastInfo} path ::> ${lastInfo.pageUrl}") + HistoryManager.getBookPageInfo(contentsType, lastInfo.pageUrl) { + it?.let { + currentPage = it + Blog.LOGE("currentBooinfo :: ${currentPage} ${currentPage?.pathUrl}") + if ((currentPage?.pathUrl?.length ?: 0) > 1) { + HistoryManager.save( + historyItem = HistoryItem().putHistory( + currentPage, + currentPage?.pathUrl ?: getLastedDoamin() + ) + ) + currentPage?.pathUrl?.let { targetPath -> + if (targetPath.startsWith("http",true)) { + targetUrl = targetPath + } else { + targetUrl = getLastedDoamin() + targetPath + } + } + } + } + } + } ?: Blog.LOGE("lastInfo is Null") + } catch (e1: Exception) { + + } finally { + if ((lastedUrl?.contains(targetUrl) == true)) { + + } else { + contentsLoad(targetUrl) + } + } + } + + + fun onBookInfos(aInfos: ContentsCollection) { + Blog.LOGE("onBookInfos(aInfos: ${aInfos})") + activity?.runOnUiThread { + showList(aInfos) + } + } + + fun onBookInfos(jsonString: String) { + Blog.LOGE("onBookInfos", "jsonString >> ${jsonString}") + val realm = openRealm() + var infos: ContentsCollection? = null + realm.writeBlocking { + try { + var infosj: PageInfosJ? = null + infosj = Gson().fromJson(jsonString, PageInfosJ::class.java) + HistoryManager.getBookInfos(contentsType,infosj.bookPageUrl!!) { + if (it != null) { + + infos = copyToRealm(it!!, UpdatePolicy.ALL) + for (item in infosj.pages) { + if (infos!!.hasItem(item.getRealm()) == false) { + infos!!.pages.add(item.getRealm()) + } + } + if (infos != null) { + infos = this.copyFromRealm(infos!!) + } + } else { + infos = infosj?.getR() + if (infos != null) { + infos = copyToRealm(infos!!, UpdatePolicy.ALL) + for (item in infosj.pages) { + infos?.pages?.add(item.getRealm()) + } + } + if (infos != null) { + infos = this.copyFromRealm(infos!!) + } + } + } + + } catch (e: Exception) { + e.printStackTrace() + } finally { + infos?.bookPageUrl?.let { + HistoryManager.getBookInfos(contentsType,it) { + it?.let { + Blog.LOGE(s(), "onBookInfos it >> ${it}") + activity?.runOnUiThread { showList(it) } + } + } + } + } + } + } + + fun onBookInfos(infosj: PageInfosJ) { + Blog.LOGE("onBookInfos", "jsonString >> ${infosj}") + val realm = openRealm() + var infos: ContentsCollection? = null + realm.writeBlocking { + try { + infosj.bookPageUrl?.let { + infosj.bookPageUrl = processPageUrl(it) + } + infosj.pages?.forEach {item -> item.pathUrl?.let { + item.pathUrl?.let { + item.pathUrl = processPageUrl(it) + } + item.bookPageUrl?.let { + item.bookPageUrl = processPageUrl(it) + } + }} + HistoryManager.getBookInfos(contentsType,processPageUrl(infosj.bookPageUrl!!)) { + if (it != null) { + + infos = copyToRealm(it!!, UpdatePolicy.ALL) + + for (item in infosj.pages) { + if (infos!!.hasItem(item.getRealm()) == false) { + infos!!.pages.add(item.getRealm()) + } + } + if (infos != null) { + infos = this.copyFromRealm(infos!!) + } + } else { + infos = infosj?.getR() + if (infos != null) { + infos = copyToRealm(infos!!, UpdatePolicy.ALL) + for (item in infosj.pages) { + infos?.pages?.add(item.getRealm()) + } + } + if (infos != null) { + infos = this.copyFromRealm(infos!!) + } + } + } + + } catch (e: Exception) { + e.printStackTrace() + } finally { + infos?.bookPageUrl?.let { + HistoryManager.getBookInfos(contentsType,it) { + it?.let { + Blog.LOGE(s(), "onBookInfos it >> ${it}") + activity?.runOnUiThread { showList(it) } + } + } + } + } + } + } + + private fun s() = "onBookInfos" + + + fun showHistory(infos: List) { + + val builderSingle: AlertDialog.Builder = AlertDialog.Builder(requireContext()) + builderSingle.setTitle("${currentTitle} : ${currentChapter} -> Select One ") + val arrayAdapter = + ArrayAdapter(requireContext(), android.R.layout.select_dialog_singlechoice) + for (item in infos) { + arrayAdapter.addAll(item.title) + } + + builderSingle.setNegativeButton( + "cancel", + DialogInterface.OnClickListener { dialog, which -> dialog.dismiss() }) + + builderSingle.setAdapter( + arrayAdapter, + DialogInterface.OnClickListener { dialog, which -> + val strName = arrayAdapter.getItem(which) + val item = infos.get(which) + val builderInner: AlertDialog.Builder = AlertDialog.Builder(requireContext()) + builderInner.setMessage(strName) + builderInner.setTitle("${infos.get(which).title}로 이동 고고!?") + builderInner.setPositiveButton( + "Ok", + DialogInterface.OnClickListener { dialog, which -> + contentsLoad(item.pageUrl) + dialog.dismiss() + }) + builderInner.setNeutralButton( + "삭제", + DialogInterface.OnClickListener { dialog, which -> + var realm = openRealm() + realm?.writeBlocking { + this.query().query("title == '${item.title}'").find() + ?.last()?.let { + this.delete(it) + } + } + dialog.dismiss() + }) + builderInner.setNegativeButton( + "취소", + DialogInterface.OnClickListener { dialog, which -> + dialog.dismiss() + }) + builderInner.show() + }) + var ddddd = builderSingle.create() + ddddd.setOnShowListener { d -> + (d as? AlertDialog)?.let { + it.listView?.setSelection(currentChapter) + } + } + + ddddd.show() + } + + fun showList(infos: ContentsCollection) { + Blog.LOGE("showList infos >>>>${infos}") + if (infos != null && infos.pages.size ?: 0 > 0) { + var items: ArrayList = arrayListOf() + for (item in infos.pages) { + items.add(item) + } + + items.sortBy { it.chapterID } + + DefaultList.showDefaultList( + requireContext(), + "현제는 ${currentTitle} - ${currentChapter} -> 다른화를 골라", + items, + currentChapter, + { position -> + return@showDefaultList items?.get(position)?.chapterTitle ?: "" + }, + { position -> + items?.get(position)?.let { moveTo(it) } + }, { state -> + if (state < 0) { + saveContinuation = true + moveToNext(currentPage?.pathUrl ?: lastedUrl?.toUri()?.path) + } + }) + } + } + + val String.cleanTextContent: String + get() { + // strips off all non-ASCII characters + var text = this + text = text.replace("[^\\x00-\\x7F]".toRegex(), "") + + // erases all the ASCII control characters + text = text.replace("[\\p{Cntrl}&&[^\r\n\t]]".toRegex(), "") + + // removes non-printable characters from Unicode + text = text.replace("\\p{C}".toRegex(), "") + return text.trim() + } + + + var saveClient = object : WebViewClient() { + override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { + super.onPageStarted(view, url, favicon) + + } + + override fun onPageFinished(webView: WebView?, url: String?) { + super.onPageFinished(webView, url) +// val delayed = 3500L + Math.abs(Random.nextLong().rem(9999L)) + finishedUrl = url ?: "" + webView?.postDelayed({ + webView?.evaluateJavascript( + "function getAll() {\n" + + " MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" + + " };getAll()" + ) { result -> + (result as? String)?.let { + + } + } + }, delayed) + } + + + } + + fun showToast(origin: String) { + activity?.runOnUiThread { + val toast = Toast(requireContext()) + toast.duration = Toast.LENGTH_SHORT + val biggerText = SpannableStringBuilder(origin) + biggerText.setSpan(RelativeSizeSpan(1.6f), 0, origin.length, 0) + val view: View = inflate(requireContext(), R.layout.simple_toast, null) + view.findViewById(R.id.text).text = biggerText + toast.view = view + toast.show() +// Toast.makeText( +// baseContext, +// biggerText, +// Toast.LENGTH_SHORT +// ).show() + } + } + + var delayed = 3500L + Math.abs(Random.nextLong().rem(9999L)) + var finishedUrl: String? = null + + private fun moveTo(item: ContentsPageInfo?) { + Blog.LOGE("item >>> ${item}") + item?.pathUrl?.let { newPath -> + contentsLoad(newPath) + } + } + + + fun moveToNext(pathUrl: String?) { + if (pathUrl != null && pathUrl.length > 6) { + HistoryManager.getNextPage(contentsType,pathUrl) { + if (it != null && (it.pathUrl?.length ?: 0) > 6) { + moveTo(it) + } else { + showToast("다음 편이 없다요.") + } + } + } + } + + fun moveToPrev(pathUrl: String?) { + if (pathUrl != null && pathUrl.length > 6) { + HistoryManager.getPrevPage(contentsType,pathUrl) { + if (it != null && (it.pathUrl?.length ?: 0) > 6) { + moveTo(it) + } else { + showToast("이전 편이 없다요.") + } + } + } + } + + fun contentsLoad(pathUrl: String) { + fun applyCurrentBook(contentsPageInfo: ContentsPageInfo) { + applyReaderConfig() + contentsPageInfo.contents?.let { onLoadedContents(it) } + contentsPageInfo.chapterTitle?.let { onFindTitle(it) } + if (contentsPageInfo.pathUrl?.startsWith("http") == true) { + binding.menuWeb.loadUrl(pathUrl) + } else { + binding.menuWeb.loadUrl(getLastedDoamin() + contentsPageInfo.pathUrl!!) + } + HistoryManager.save(HistoryItem().putHistory(contentsPageInfo, contentsPageInfo.pathUrl!!)) + } + + if (currentPage?.pathUrl.equals(pathUrl)) { + applyCurrentBook(currentPage!!) + } else { + HistoryManager.getBookPageInfo(contentsType,pathUrl) { + Blog.LOGE("contentsLoad :::: pathUrl >> ${pathUrl} , book >> ${it}") + if (it != null && it.isValidBook()) { + currentPage = it + applyCurrentBook(it) + } else if(lastInfo != null){ + binding.pagedLayer.visibility = GONE + binding.menuWeb.loadUrl(getLastedDoamin() + lastInfo!!.pageUrl) + } else { + binding.menuWeb.loadUrl(getLastedDoamin()) + } + } + } + } + + + fun actionNextEvent(fast: Boolean = false) { + if (binding.pagedLayer.isVisible && binding.pagedLayer.size() > 0 && (binding.pagedLayer.current() < binding.pagedLayer!!.size() - 1)) { + binding.pagedLayer.doNext(fast) + updateLastInfo(binding.pagedLayer!!) + } else { + moveToNext(currentPage?.pathUrl ?: lastedUrl?.toUri()?.path) + } + } + + fun applyReaderConfig() { + var realm = HistoryManager.openRealm + realm.query().find().let { + if (it.isNotEmpty()) { + realm.copyFromRealm(it.first()).let { + activity?.runOnUiThread { + var typeface = + typesfacez.get(getIndex(typesfacez as PairArray, it.font ?: "")) + binding.pagedLayer.setTypeface(resources.getFont(typeface.second)) + val color = colorz.get(it.style ?: 0) + binding.pagedLayer.setColorStyle(color.second) + binding.pagedLayer.setTextSize(it.textSize?.toFloat() ?: 14f) + binding.pagedLayer.setLineSpacing(it.lineSpace?.toFloat() ?: 1f) + binding.pagedLayer.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f) + binding.pagedLayer.setPadding( + it.padding ?: 1, + it.padding ?: 1, + it.padding ?: 1, + it.padding ?: 1 + ) + binding.pagedLayer.invalidate() + } + } + } + } + } + + fun actionPrevEvent(fast: Boolean = false) { + if (binding.pagedLayer.isVisible && binding.pagedLayer.size() > 0 && binding.pagedLayer.current() > 0) { + binding.pagedLayer.doPrev(fast) + updateLastInfo(binding.pagedLayer) + } else { + moveToPrev(currentPage?.pathUrl ?: lastedUrl?.toUri()?.path) + } + } +// +// override fun onBackPressed() { +// +// +// +// if (binding.pagedLayer.isVisible) { +// didBackPress = false +// binding.pagedLayer.visibility = GONE +// onTouch(TouchArea.Center) +// return +// } +// +// if (canGoBack == true) { +// didBackPress = false +// canGoBack = false +// binding.menuWeb.session?.goBack() +// return +// } +// +// if (!didBackPress) { +// firstBackPress() +// return +// } else { +// Activity.finishAffinity() +// didBackPress = false +// super.onBackPressed() +// } +// } + + + + fun showAlert(alert: String) { + Log.i(TAG, "showAlert >> " + alert) + } + + + fun onStateChange(sessionState: GeckoSession.SessionState) { + var fakeSession : FakeSessions? = null + try { + fakeSession = Gson().fromJson(Gson().toJson(sessionState), FakeSessions::class.java) + Blog.LOGE("fakeSession >>> $fakeSession") + }catch (e: Exception){ + e.printStackTrace() + } + + if (sessionState.last().uri.length > 10) { + lastedUrl?.let { + Uri.parse(it)?.let { uri -> + uri.path?.let { + HistoryManager.getBookPageInfo(contentsType, it) { + it?.let { + this@BaseToki.currentPage = it + currentChapter = it?.chapterNum ?: 0 + HistoryManager.save(historyItem = HistoryItem().putHistory(it,lastedUrl!! )) + (currentPage?.pathUrl ?: lastedUrl?.toUri()?.path)?.let { + HistoryManager.setBookPageInfo(contentsType,it,binding.pagedLayer.current()) + } + val realm = openRealm() + realm.writeBlocking { + var q = this.query("contentsType == $0", contentsType).find() + if(q.size > 0) { + q.last()?.let { + it.title = currentTitle + it.chapter = currentChapter + it.pageIndex = 0 + it.contentsType = currentPage!!.contentsType + this@BaseToki.lastInfo = copyFromRealm(it) + } + } else { + LastInfo()?.let { + it.title = currentTitle + it.chapter = currentChapter + it.pageIndex = 0 + it.contentsType = currentPage!!.contentsType + it._id = if (lastedUrl?.contains("book",true) == true) {"book"} + else if(lastedUrl?.contains("new",true) == true) {"webtoon"} + else if(lastedUrl?.contains("mana",true) == true) {"comics"} + else "web" + copyToRealm(it) + this@BaseToki.lastInfo = it + } + } + } + + } + } + } + if (saveContinuation) { + binding.menuWeb.postDelayed({ + moveToNext( + currentPage?.pathUrl ?: lastedUrl?.toUri()?.path + ) + }, 10000) + } + } + } + } + + } + + fun onLoadedContents(aContents: String) { + Blog.LOGE("onLoadedContents ") + binding.pagedLayer.let { view -> + view.post { + if (aContents.length > 10) { + var contents = aContents.replace("\\\"", "\"") + contents = (contents.replace("\\n", System.getProperty("line.separator"))) + view.mPagedTextViewInterface = this@BaseToki + if (lastInfo != null && lastedUrl?.endsWith(lastInfo!!.pageUrl) == true) { + binding.progress.visibility = VISIBLE + binding.pagedLayer.postDelayed({ + binding.progress.visibility = GONE + }, 1000) + } + applyReaderConfig() + activity?.runOnUiThread { + view.text = contents + view.visibility = VISIBLE + } + view.forceUpdateUI() + lastedUrl?.let { + Uri.parse(it)?.let { uri -> + uri.path?.let { + HistoryManager.getBookPageInfo(contentsType,it) { + it?.let { + this@BaseToki.currentPage = it + currentChapter = it?.chapterNum ?: 0 + view.currentPage = it?.chapterNum ?: 0 + HistoryManager.save( + historyItem = HistoryItem().putHistory( + it, + lastedUrl!! + ) + ) + } + } + HistoryManager.getBooPageInfoContentsSave(contentsType,it, contents) + } + if (saveContinuation) { + binding.menuWeb.postDelayed({moveToNext(currentPage?.pathUrl ?: lastedUrl?.toUri()?.path)}, 10000) + + } + } + } + } + + } + } +// Log.i(TAG, "onLoadedContents >> " + aContents) + } + + var currentTitle: String = "" + var currentChapter: Int = 0 + + fun onFindTitle(contents: String) { + binding.textviewTitle.text = contents + binding.textviewTitle.setOnClickListener { + val builder = AlertDialog.Builder(requireContext()) + builder.setTitle("Title") + val input = EditText(requireContext()) + input.setText(lastedUrl ?: "") + input.inputType = InputType.TYPE_CLASS_TEXT + builder.setView(input) + builder.setPositiveButton( + "OK" + ) { dialog, which -> + var m_Text = input.text.toString() + contentsLoad(m_Text.trim()) + } + builder.setNegativeButton( + "Cancel" + ) { dialog, which -> dialog.cancel() } + builder.show() + } + var testRegex = """[^0-9]""".toRegex() + Blog.LOGI(TAG, "onFindTitle >> " + contents + " ::: ${testRegex.replace(contents, "")}") + if (contents.contains("-")) { + currentTitle = contents.split("-")[0] + try { + currentChapter = testRegex.replace(contents.split("-")[1], "").toInt() + } catch (e: Exception) { + currentChapter = 0 + } + } else if (testRegex.replace(contents, "").length > 0) { + currentChapter = testRegex.replace(contents, "").toInt() + currentTitle = contents.split(testRegex.replace(contents, ""))[0] + } else { + val dateFormat = "yyyyMMdd-HH" + val date = Date(currentTimeMillis()) + val simpleDateFormat = SimpleDateFormat(dateFormat) + currentTitle = simpleDateFormat.format(date) + } + + } + + fun onStartLoad() { + binding.progress.visibility = VISIBLE + } + + fun completePageLoad(lastInfo: LastInfo) { + saveLastInfo(lastInfo) + } + +// override fun onTouchEvent(event: MotionEvent?): Boolean { +// return super.onTouchEvent(event) +// if (saveContinuation) { +// saveContinuation = false +// } +// } + + fun saveLastInfo(lastInfo: LastInfo) { + val realm = openRealm() + if ((realm.query("contentsType == $0", contentsType)?.count()?.find() ?: 0) > 0) { + realm.writeBlocking { + this.query("contentsType == $0", contentsType)?.find()?.last()?.let { + it.pageUrl = lastInfo.pageUrl + it.title = currentTitle + it.chapter = currentChapter + it.pageIndex = lastInfo.pageIndex + it.contentsName = lastInfo.contentsName + it.displayOrientation = lastInfo.displayOrientation + it.contentsType = lastInfo.contentsType + this@BaseToki.lastInfo = copyFromRealm(it) + Blog.LOGE("lastInfo >>>> ${this@BaseToki.lastInfo}") + } + } + } else if ((lastInfo._id?.length ?: 0) > 3){ + realm.writeBlocking { + Blog.LOGE("lastInfo >>>> $lastInfo") + copyToRealm(lastInfo) + } + } +// Blog.LOGD(log = "Successfully opened realm: ${realm.configuration.name}") + } + + fun updateLastInfo(pagedTextLayout: PagedTextLayout) { + (currentPage?.pathUrl ?: lastedUrl?.toUri()?.path)?.let { + HistoryManager.setBookPageInfo(contentsType,it,binding.pagedLayer.current()) + } + val configuration: Configuration = getResources().configuration + val realm = openRealm() + realm.writeBlocking { + var q = this.query("contentsType == $0", contentsType) + if(q.count().find() > 0) { + q.find().last()?.let { + it.displayOrientation = configuration.orientation + it.title = currentTitle + it.chapter = currentChapter + it.pageIndex = pagedTextLayout.current() + this@BaseToki.lastInfo = copyFromRealm(it) + } + if (currentTitle.length > 0 && currentChapter > 0) { + this@BaseToki.lastInfo?.makeHistoryItem()?.let { + copyToRealm(it, UpdatePolicy.ALL) + } + } + } else { + + LastInfo().let { + it.title = currentTitle + it.chapter = currentChapter + it.pageIndex = 0 + + it._id = if (lastedUrl?.contains("book",true) == true) {"book"} + else if(lastedUrl?.contains("new",true) == true) {"webtoon"} + else if(lastedUrl?.contains("mana",true) == true) {"comics"} + else "web" + it.contentsType = currentPage?.contentsType ?: it._id + copyToRealm(it) + this@BaseToki.lastInfo = it + } + if (currentTitle.length > 0 && currentChapter > 0) { + this@BaseToki.lastInfo?.makeHistoryItem()?.let { + copyToRealm(it, UpdatePolicy.ALL) + } + } + } + } + val message: JSONObject = JSONObject() + try { + message.put("type", "scrollDown") + message.put("max", binding.pagedLayer.size()) + message.put("current",binding.pagedLayer.current()) + } catch (ex: JSONException) { + throw RuntimeException(ex) + } + mPort?.postMessage(message) + Blog.LOGD(log = "Successfully opened realm: ${realm.configuration.name}") + } + private fun sendViewerTouch(string: String) { + val message: JSONObject = JSONObject() + try { + message.put("type", "ViewerTouch") + message.put("area", string) + } catch (ex: JSONException) { + throw RuntimeException(ex) + } + Blog.LOGE(Gson().toJson(message)) + mPort?.postMessage(message) + } + fun sendScrollDown(isUp: Boolean) { + val message: JSONObject = JSONObject() + try { + message.put("type", "scrollDown") + message.put("isUpDown", if (isUp) +1 else -1) + } catch (ex: JSONException) { + throw RuntimeException(ex) + } + Blog.LOGE(Gson().toJson(message)) + mPort?.postMessage(message) + } + + +// override fun onKeyClick(keyCode: Int): Boolean { +// when (keyCode) { +// KeyEvent.KEYCODE_VOLUME_DOWN -> { +// actionNextEvent() +// } +// +// KeyEvent.KEYCODE_VOLUME_UP -> { +// actionPrevEvent() +// } +// +// KeyEvent.KEYCODE_VOLUME_MUTE -> { +// actionNextEvent() +// } +// +// } +// return super.onKeyClick(keyCode) +// } +// +// override fun dispatchTrackballEvent(ev: MotionEvent?): Boolean { +// Blog.LOGE("dispatchTrackballEvent ev?.device?.name >>> ${ev?.device?.name}") +// return super.dispatchTrackballEvent(ev) +// } +// +// @SuppressLint("RestrictedApi") +// override fun dispatchKeyShortcutEvent(ev: KeyEvent): Boolean { +// Blog.LOGE("dispatchKeyShortcutEvent ev?.device?.name >>> ${ev?.device?.name}") +// return super.dispatchKeyShortcutEvent(ev) +// } +// +// +// +// override fun dispatchGenericMotionEvent(ev: MotionEvent?): Boolean { +// Blog.LOGE("dispatchKeyShortcutEvent ev?.device?.name >>> ${ev?.device?.name}") +// return super.dispatchGenericMotionEvent(ev) +// } +// +// override fun dispatchKeyEvent(ev: KeyEvent): Boolean { +// Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}") +// if (ev?.device?.name?.contains("SM-031N Mouse") == true) { +// when (ev.action) { +// ACTION_UP -> { +// Blog.LOGE("dispatch dispatchKeyEvent>>> ${ev}") +// when (ev.keyCode) { +// KEYCODE_BUTTON_Y -> { +// actionPrevEvent() +// } +// +// KEYCODE_BUTTON_X -> { +// +// } +// +// KEYCODE_BUTTON_A -> { +// actionNextEvent() +// } +// +// KEYCODE_BUTTON_B -> { +// +// } +// +// KEYCODE_DPAD_DOWN -> { +// +// } +// +// KEYCODE_DPAD_UP -> { +// +// } +// +// KEYCODE_BUTTON_START -> { +// goToHome() +// } +// +// KEYCODE_BUTTON_SELECT -> { +// +// saveContinuation = !saveContinuation +// if (saveContinuation) { +// moveToNext(currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path) +// } +// } +// +// else -> {} +// } +// } +// +// else -> {} +// } +// return true +// } +// return super.dispatchKeyEvent(ev) +// } + + private fun goToHome() { + binding.menuWeb.loadUrl(getLastedDoamin()) + } + + + + + + companion object { + private const val TAG = "DualScreenStatus" + } + + + + +} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Comics.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Comics.kt new file mode 100644 index 00000000..da97dc79 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Comics.kt @@ -0,0 +1,182 @@ +package bums.lunatic.launcher.tokiz + +import android.content.DialogInterface +import android.content.Intent +import android.content.pm.ActivityInfo +import android.content.res.Configuration +import android.graphics.Bitmap +import android.graphics.Color +import android.net.Uri +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.os.Message +import android.text.InputType +import android.text.SpannableStringBuilder +import android.text.style.RelativeSizeSpan +import android.util.Log +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.View +import android.view.View.GONE +import android.view.View.OnTouchListener +import android.view.View.VISIBLE +import android.view.View.inflate +import android.view.ViewGroup +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.ArrayAdapter +import android.widget.EditText +import android.widget.TextView +import android.widget.Toast +import androidx.appcompat.app.AlertDialog +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.net.toUri +import androidx.core.view.isVisible +import androidx.fragment.app.Fragment +import bums.lunatic.launcher.LauncherActivity.Companion.getRuntime +import bums.lunatic.launcher.R +import bums.lunatic.launcher.tokiz.common.PairArray +import bums.lunatic.launcher.tokiz.common.TouchArea +import bums.lunatic.launcher.tokiz.common.colorz +import bums.lunatic.launcher.tokiz.common.getIndex +import bums.lunatic.launcher.tokiz.common.typesfacez +import bums.lunatic.launcher.tokiz.data.HistoryManager +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsCollection +import bums.lunatic.launcher.tokiz.data.model.PageInfosJ +import bums.lunatic.launcher.tokiz.data.model.HistoryItem +import bums.lunatic.launcher.tokiz.data.model.LastInfo +import bums.lunatic.launcher.tokiz.data.model.PortMessage +import bums.lunatic.launcher.tokiz.data.model.ReaderConfig +import bums.lunatic.launcher.tokiz.dialog.DefaultList +import bums.lunatic.launcher.tokiz.view.JxEvent +import bums.lunatic.launcher.tokiz.view.PagedTextLayout +import bums.lunatic.launcher.tokiz.view.PagedTextViewInterface +import bums.lunatic.launcher.databinding.BooktokiBinding +import bums.lunatic.launcher.utils.Blog +import com.google.gson.Gson +import io.realm.kotlin.Realm +import io.realm.kotlin.UpdatePolicy +import io.realm.kotlin.ext.copyFromRealm +import io.realm.kotlin.ext.query +import org.json.JSONException +import org.json.JSONObject +import org.mozilla.gecko.util.ThreadUtils +import org.mozilla.geckoview.GeckoResult +import org.mozilla.geckoview.GeckoSession +import org.mozilla.geckoview.MediaSession +import org.mozilla.geckoview.WebExtension +import org.mozilla.geckoview.WebExtension.MessageDelegate +import org.mozilla.geckoview.WebExtension.PortDelegate +import org.mozilla.geckoview.WebExtensionController.AddonManagerDelegate +import org.mozilla.geckoview.WebRequestError +import java.lang.System.currentTimeMillis +import java.text.SimpleDateFormat +import java.util.Date +import kotlin.collections.ArrayList +import kotlin.collections.List +import kotlin.collections.MutableList +import kotlin.collections.arrayListOf +import kotlin.collections.first +import kotlin.collections.isNotEmpty +import kotlin.collections.last +import kotlin.collections.sortBy +import kotlin.random.Random +import kotlin.text.contains +import kotlin.text.endsWith +import kotlin.text.equals +import kotlin.text.replace +import kotlin.text.split +import kotlin.text.startsWith +import kotlin.text.toInt +import kotlin.text.toRegex +import kotlin.text.trim + + +class Comics : BaseToki(), PagedTextViewInterface { + + override val contentsType = "comics" + override var lastNumber : Int = 468 + override val webcontentsName : String = "manatoki" + override val afterDot = "net" + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + super.onCreateView(inflater, container, savedInstanceState) + return binding.root + } + + override fun onStart() { + super.onStart() + } + + override fun onResume() { + super.onResume() + loadLastInfo() + } + + override fun onTouch(touchArea: TouchArea) { + Blog.LOGD(log = "onTouch ${touchArea}") + when (touchArea) { + TouchArea.Center -> { + + } + + TouchArea.Right -> { + actionNextEvent() + } + + TouchArea.Left -> { + actionPrevEvent() + } + + TouchArea.DoubleRight -> { + actionNextEvent(true) + } + + TouchArea.DoubleLeft -> { + actionPrevEvent(true) + } + else -> { + + } + } + + + } + + override fun onLongClick() { + Blog.LOGD(log = "onLongClick") + + } + + override fun onSwipeLeft(count: Int) { + Blog.LOGD(log = "onSwipeLeft ${count}") + actionNextEvent(count > 1) + + } + + override fun onSwipeRight(count: Int) { + Blog.LOGD(log = "onSwipeRight ${count}") + actionPrevEvent(count > 1) + } + + override fun onSwipeUp(touchCount: Int) { + + } + + override fun onSwipeDown(touchCount: Int) { + if (touchCount == 2) { + if (binding.pagedLayer.isVisible) { + binding.pagedLayer.visibility = GONE + } + } + } + + override fun onTimeoverTouch() { + + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Novels.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Novels.kt index e11ffda2..50bc6a31 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Novels.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Novels.kt @@ -40,9 +40,9 @@ import bums.lunatic.launcher.tokiz.common.colorz import bums.lunatic.launcher.tokiz.common.getIndex import bums.lunatic.launcher.tokiz.common.typesfacez import bums.lunatic.launcher.tokiz.data.HistoryManager -import bums.lunatic.launcher.tokiz.data.model.BookPageInfo -import bums.lunatic.launcher.tokiz.data.model.BookPageInfos -import bums.lunatic.launcher.tokiz.data.model.BookPageInfosJ +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsCollection +import bums.lunatic.launcher.tokiz.data.model.PageInfosJ import bums.lunatic.launcher.tokiz.data.model.HistoryItem import bums.lunatic.launcher.tokiz.data.model.LastInfo import bums.lunatic.launcher.tokiz.data.model.PortMessage @@ -51,8 +51,6 @@ import bums.lunatic.launcher.tokiz.dialog.DefaultList import bums.lunatic.launcher.tokiz.view.JxEvent import bums.lunatic.launcher.tokiz.view.PagedTextLayout import bums.lunatic.launcher.tokiz.view.PagedTextViewInterface -import bums.lunatic.launcher.tokiz.webcontents.contentsinfo.BooktokiStruct.getLastedDoamin -import bums.lunatic.launcher.tokiz.webcontents.contentsinfo.BooktokiStruct.getWebcontentsName import bums.lunatic.launcher.databinding.BooktokiBinding import bums.lunatic.launcher.utils.Blog import com.google.gson.Gson @@ -94,445 +92,21 @@ import kotlin.text.toRegex import kotlin.text.trim -class Novels : Fragment(), PagedTextViewInterface { - fun openRealm() : Realm = HistoryManager.openRealm - var lastInfo: LastInfo? = null - var currentBooinfo: BookPageInfo? = null - - val handle = object : Handler(Looper.getMainLooper()) { - override fun handleMessage(msg: Message) { - if (msg.what == 0) { - (msg.obj as? ReaderConfig)?.let { - } - } - } - } - - - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - Blog.LOGD(log = "onConfigurationChanged ${this::class.java.name} >> newConfig ${newConfig}") - } - - var lastedUrl: String? = null - var canGoBack: Boolean? = null - lateinit var binding: BooktokiBinding - - var mPort: WebExtension.Port? = null - val mPortNam = "browser" - val extPath = "resource://android/assets/extensions/my_extension/" - val extId = "messaging@booktoki468.com" - var mExtension: WebExtension? = null - - val OnTouchListener = object : OnTouchListener { - - override fun onTouch(v: View?, event: MotionEvent): Boolean { - when (event.getAction()) { - MotionEvent.ACTION_DOWN -> { - handle.removeCallbacks(mActionUp) - handle.removeCallbacks(mActionDown) - if(!binding.pagedLayer.isVisible) { - - } - } - - MotionEvent.ACTION_UP -> { - handle.removeCallbacks(mActionUp) - handle.removeCallbacks(mActionDown) - } - } - return false - } - - var mActionDown: Runnable = object : Runnable { - override fun run() { - sendScrollDown(false) - handle.postDelayed(this, 150) - } - } - var mActionUp: Runnable = object : Runnable { - override fun run() { - sendScrollDown(true) - handle.postDelayed(this, 150) - } - } - } - - - - var mOnGenericMotionListener = object : View.OnGenericMotionListener{ - override fun onGenericMotion( - v: View?, - event: MotionEvent? - ): Boolean { - Blog.LOGE("event >>>> $event") - return true - } - } - - val addonManagerDelegate = object : AddonManagerDelegate { - override fun onReady(extension: WebExtension) { - Blog.LOGE("onReady ${extension.id} from WebExtension") -// extension?.setMessageDelegate(messageDelegate, mPortNam) -// sRuntime!!.webExtensionController.enable(extension,EnableSource.USER) - mExtension = extension - - } - - override fun onEnabling(extension: WebExtension) { - Blog.LOGE("onEnabling ${extension.id} from WebExtension") - } - - override fun onEnabled(extension: WebExtension) { - Blog.LOGE("onEnabled ${extension.id} from WebExtension") -// extension?.setMessageDelegate(messageDelegate, mPortNam) - mExtension = extension - - } - } - val mediaDelegate = object : GeckoSession.MediaDelegate { - override fun onRecordingStatusChanged( - session: GeckoSession, - devices: Array - ) { - super.onRecordingStatusChanged(session, devices) - } - } - val mediaSessionDelegate = object : MediaSession.Delegate { - override fun onActivated( - session: GeckoSession, - mediaSession: MediaSession - ) { - super.onActivated(session, mediaSession) - } - - override fun onDeactivated( - session: GeckoSession, - mediaSession: MediaSession - ) { - super.onDeactivated(session, mediaSession) - } - - override fun onMetadata( - session: GeckoSession, - mediaSession: MediaSession, - meta: MediaSession.Metadata - ) { - super.onMetadata(session, mediaSession, meta) - } - - override fun onFeatures( - session: GeckoSession, - mediaSession: MediaSession, - features: Long - ) { - super.onFeatures(session, mediaSession, features) - } - - override fun onPlay( - session: GeckoSession, - mediaSession: MediaSession - ) { - super.onPlay(session, mediaSession) - } - - override fun onPause( - session: GeckoSession, - mediaSession: MediaSession - ) { - super.onPause(session, mediaSession) - } - - override fun onStop( - session: GeckoSession, - mediaSession: MediaSession - ) { - super.onStop(session, mediaSession) - } - - override fun onPositionState( - session: GeckoSession, - mediaSession: MediaSession, - state: MediaSession.PositionState - ) { - super.onPositionState(session, mediaSession, state) - } - - override fun onFullscreen( - session: GeckoSession, - mediaSession: MediaSession, - enabled: Boolean, - meta: MediaSession.ElementMetadata? - ) { - super.onFullscreen(session, mediaSession, enabled, meta) - } - } - - val contentDelegate = object : GeckoSession.ContentDelegate { - - } - val progressDelegate = object : GeckoSession.ProgressDelegate { - override fun onSecurityChange( - session: GeckoSession, - securityInfo: GeckoSession.ProgressDelegate.SecurityInformation - ) { - Blog.LOGE("onSecurityChange $securityInfo from WebExtension") - super.onSecurityChange(session, securityInfo) - } - - override fun onSessionStateChange( - session: GeckoSession, - sessionState: GeckoSession.SessionState - ) { - Blog.LOGE("onSessionStateChange $sessionState from WebExtension") - super.onSessionStateChange(session, sessionState) - } - - override fun onPageStart(session: GeckoSession, url: String) { - super.onPageStart(session, url) - binding.progress.visibility = VISIBLE - } - - override fun onPageStop(session: GeckoSession, success: Boolean) { - Blog.LOGE("onPageStop $success from WebExtension") - super.onPageStop(session, success) - if (success && mPort != null) { - if (mPort == null) { - // No extension registered yet, let's ignore this message - return - } - binding.menuWeb.postDelayed({ - Blog.LOGE("onPageStop $success from WebExtension ${mPort!!.name}") - val message: JSONObject = JSONObject() - try { - message.put("type", "getList") - message.put("event", "sadsadds") - message.put("tab", session.settings.screenId) - } catch (ex: JSONException) { - throw RuntimeException(ex) - } - - mPort!!.postMessage(message) -// binding.progress.visibility = GONE - }, 10L) -// completePageLoad(LastInfo().apply { -// this.pageUrl = lastedUrl?.toUri()?.path ?: getLastedDoamin() ?: "" -// this.contentsName = getWebcontentsName() ?: "" -// this.pageIndex = 0 -// }) - } - } - } - val navigationDelegate = object : GeckoSession.NavigationDelegate { - override fun onLoadError( - session: GeckoSession, - uri: String?, - error: WebRequestError - ): GeckoResult? { - error.printStackTrace() - Blog.LOGE("onLoadError >>> ${uri} ::>> ${error.category} , ${error.code}") - if (error.code == WebRequestError.ERROR_NET_RESET) { - session.loadUri("https://naver.com") - } - return super.onLoadError(session, uri, error) - } - - override fun onNewSession( - session: GeckoSession, - uri: String - ): GeckoResult? { - Blog.LOGE("GeckoView", "onNewSession: $session from WebExtension") - - - return super.onNewSession(session, uri) - } - - override fun onLocationChange( - session: GeckoSession, - url: String?, - perms: MutableList, - hasUserGesture: Boolean - ) { - if (url?.startsWith("about") ?: true) { - - } else { - // url이 현재 로드된 주소입니다. - Blog.LOGE("GeckoView", "현재 주소: $url") - Blog.LOGE("GeckoView", "현재 session: $session") - url?.let { url -> - if (url.split("//").size > 1) { - url.replace("//", "/").replace("https:/", "https://").let { - Blog.LOGE("url >> ${url} , it >>> ${it}") - lastedUrl = url - } - } else { - lastedUrl = url - } - } - completePageLoad(LastInfo().apply { - this.pageUrl = url?.toUri()?.path ?: getLastedDoamin() ?: "" - this.contentsName = getWebcontentsName() ?: "" - this.pageIndex = 0 - }) - } - } - - override fun onCanGoBack(session: GeckoSession, canGoBack: Boolean) { - super.onCanGoBack(session, canGoBack) - this@Novels.canGoBack = canGoBack - if (canGoBack) { - - } - } - - } - val portDelegate: PortDelegate = object : PortDelegate { - - override fun onPortMessage( - message: Any, port: WebExtension.Port - ) { - Blog.LOGE("PortDelegate", "Received message from extension: $message") - if (message is String && message.contains("type")) { - try { - var lPortMessage = - Gson().fromJson(message, PortMessage::class.java) - when(lPortMessage.type) { - "getListResult" -> { - lPortMessage.bookInfos?.let { onBookInfos(it) } - } - "BookContents"->{ - lPortMessage?.book?.chapterTitle?.let { onFindTitle(it) } - lPortMessage?.book?.bookContents?.let { onLoadedContents(it) } - } - "NotRegistered" -> { - binding.pagedLayer.visibility = GONE - } - "WebtoonContents"-> { - binding.pagedLayer.visibility = GONE - } - "MSG" -> { - lPortMessage.msg?.let { Toast.makeText(requireContext(),it, Toast.LENGTH_SHORT).show() } - } - else -> { - - } - } - binding.progress.visibility = GONE - } catch (e: Exception) { - e.printStackTrace() - } - - } - } - - - override fun onDisconnect(port: WebExtension.Port) { - // This port is not usable anymore. - if (port === mPort) { - mPort = null - } - } - } - val messageDelegate: MessageDelegate = object : MessageDelegate { - override fun onConnect(port: WebExtension.Port) { - mPort = port - mPort!!.setDelegate(portDelegate) - } - - override fun onMessage( - nativeApp: String, - message: Any, - sender: WebExtension.MessageSender - ): GeckoResult? { - Blog.LOGE( - "messageDelegate", - "onMessage from WebExtension: ${nativeApp} , $message , ${sender.webExtension.id}" - ) - return super.onMessage(nativeApp, message, sender) - } - - - } +class Novels : BaseToki(), PagedTextViewInterface { + override val contentsType = "book" + override var lastNumber : Int = 468 + override val webcontentsName : String = "booktoki" + override val afterDot = "com" override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - Blog.LOGD(log = "onCreate ${this::class.java.name} >> savedInstanceState ${savedInstanceState}") - binding = BooktokiBinding.inflate(inflater) - binding.menuWeb.let { - it.setOnLongClickListener { - onTouch(TouchArea.Center) - return@setOnLongClickListener false - } - it.setOnGenericMotionListener(mOnGenericMotionListener) - } - - binding.btnList.setOnClickListener { v -> - lastedUrl?.let { - Uri.parse(it).path?.let { - HistoryManager.getBookInfos(it, { - it?.let { - it.pages.sortBy { it.pathUrl } - showList(it) - } - }) - } - } - } - - - binding.btnSetting.setOnClickListener { v -> - activity?.startActivity(Intent(requireContext(), Settings::class.java)) - } - binding.btnHistory.setOnClickListener { v -> - var realm = openRealm() - realm.query().find().let { - showHistory(realm.copyFromRealm(it)) - } - } - binding.btnHome.setOnClickListener { v -> - binding.pagedLayer.visibility = GONE - goToHome() - } - getRuntime()?.apply { - val session: GeckoSession = GeckoSession() - session.open(this) - binding.menuWeb.setSession(session) - binding.menuWeb.jxInteface = { jxEvent -> - when(jxEvent) { - JxEvent.SCROLL_UP -> sendScrollDown(true) - JxEvent.SCROLL_DOWN -> sendScrollDown(false) - else -> {} - } - } - session.contentDelegate = contentDelegate - session.progressDelegate = progressDelegate - session.navigationDelegate = navigationDelegate - this.webExtensionController.setAddonManagerDelegate(addonManagerDelegate) - session.mediaDelegate = mediaDelegate - session.mediaSessionDelegate = mediaSessionDelegate - this.webExtensionController - .ensureBuiltIn(extPath, extId) - .accept( // Register message delegate for background script - { extension: WebExtension? -> - ThreadUtils.runOnUiThread( - Runnable { - if (extension != null) { - session.webExtensionController.setMessageDelegate( - extension, - messageDelegate, - mPortNam - ) - } - }) - }, - { e: Throwable? -> Log.e("MessageDelegate", "Error registering WebExtension", e) }) - loadLastInfo() - } + super.onCreateView(inflater, container, savedInstanceState) return binding.root } + override fun onStart() { super.onStart() } @@ -542,726 +116,6 @@ class Novels : Fragment(), PagedTextViewInterface { loadLastInfo() } - fun loadLastInfo() { - var targetUrl = getLastedDoamin() - val realm = openRealm() - try { - lastInfo = realm.query().find().last()?.copyFromRealm() - HistoryManager.openRealm.query()?.find()?.let { - if (it.size > 0) { - realm.copyFromRealm(it.first()).let { - applyReaderConfig() - } - } - } - lastInfo?.let { lastInfo -> - Blog.LOGE("lastInfo >>> ${lastInfo} path ::> ${lastInfo!!.pageUrl}") - HistoryManager.getBookPageInfo(lastInfo.pageUrl) { - it?.let { - currentBooinfo = it - Blog.LOGE("currentBooinfo :: ${currentBooinfo} ${currentBooinfo?.pathUrl}") - if ((currentBooinfo?.pathUrl?.length ?: 0) > 1) { - HistoryManager.save( - historyItem = HistoryItem().putHistory( - currentBooinfo, - currentBooinfo?.pathUrl ?: getLastedDoamin() - ) - ) - currentBooinfo?.pathUrl?.let { targetPath -> - if (targetPath.startsWith("http",true)) { - targetUrl = targetPath - } else { - targetUrl = getLastedDoamin() + targetPath - } - } - } - } - } - } ?: Blog.LOGE("lastInfo is Null") - } catch (e1: Exception) { - - } finally { - contentsLoad(targetUrl) - } - } - - - fun onBookInfos(aInfos: BookPageInfos) { - Blog.LOGE("onBookInfos(aInfos: ${aInfos})") - activity?.runOnUiThread { - showList(aInfos) - } - } - - fun onBookInfos(jsonString: String) { - Blog.LOGE("onBookInfos", "jsonString >> ${jsonString}") - val realm = openRealm() - var infos: BookPageInfos? = null - realm.writeBlocking { - try { - var infosj: BookPageInfosJ? = null - infosj = Gson().fromJson(jsonString, BookPageInfosJ::class.java) - HistoryManager.getBookInfos(infosj.bookPageUrl!!) { - if (it != null) { - - infos = copyToRealm(it!!, UpdatePolicy.ALL) - for (item in infosj.pages) { - if (infos!!.hasItem(item.getRealm()) == false) { - infos!!.pages.add(item.getRealm()) - } - } - if (infos != null) { - infos = this.copyFromRealm(infos!!) - } - } else { - infos = infosj?.getR() - if (infos != null) { - infos = copyToRealm(infos!!, UpdatePolicy.ALL) - for (item in infosj.pages) { - infos?.pages?.add(item.getRealm()) - } - } - if (infos != null) { - infos = this.copyFromRealm(infos!!) - } - } - } - - } catch (e: Exception) { - e.printStackTrace() - } finally { - infos?.bookPageUrl?.let { - HistoryManager.getBookInfos(it) { - it?.let { - Blog.LOGE(s(), "onBookInfos it >> ${it}") - activity?.runOnUiThread { showList(it) } - } - } - } - } - } - } - - fun onBookInfos(infosj: BookPageInfosJ) { - Blog.LOGE("onBookInfos", "jsonString >> ${infosj}") - val realm = openRealm() - var infos: BookPageInfos? = null - realm.writeBlocking { - try { - HistoryManager.getBookInfos(infosj.bookPageUrl!!) { - if (it != null) { - - infos = copyToRealm(it!!, UpdatePolicy.ALL) - for (item in infosj.pages) { - if (infos!!.hasItem(item.getRealm()) == false) { - infos!!.pages.add(item.getRealm()) - } - } - if (infos != null) { - infos = this.copyFromRealm(infos!!) - } - } else { - infos = infosj?.getR() - if (infos != null) { - infos = copyToRealm(infos!!, UpdatePolicy.ALL) - for (item in infosj.pages) { - infos?.pages?.add(item.getRealm()) - } - } - if (infos != null) { - infos = this.copyFromRealm(infos!!) - } - } - } - - } catch (e: Exception) { - e.printStackTrace() - } finally { - infos?.bookPageUrl?.let { - HistoryManager.getBookInfos(it) { - it?.let { - Blog.LOGE(s(), "onBookInfos it >> ${it}") - activity?.runOnUiThread { showList(it) } - } - } - } - } - } - } - - private fun s() = "onBookInfos" - - - fun showHistory(infos: List) { - - val builderSingle: AlertDialog.Builder = AlertDialog.Builder(requireContext()) - builderSingle.setTitle("${currentTitle} : ${currentChapter} -> Select One ") - val arrayAdapter = - ArrayAdapter(requireContext(), android.R.layout.select_dialog_singlechoice) - for (item in infos) { - arrayAdapter.addAll(item.title) - } - - builderSingle.setNegativeButton( - "cancel", - DialogInterface.OnClickListener { dialog, which -> dialog.dismiss() }) - - builderSingle.setAdapter( - arrayAdapter, - DialogInterface.OnClickListener { dialog, which -> - val strName = arrayAdapter.getItem(which) - val item = infos.get(which) - val builderInner: AlertDialog.Builder = AlertDialog.Builder(requireContext()) - builderInner.setMessage(strName) - builderInner.setTitle("${infos.get(which).title}로 이동 고고!?") - builderInner.setPositiveButton( - "Ok", - DialogInterface.OnClickListener { dialog, which -> - contentsLoad(item.pageUrl) - dialog.dismiss() - }) - builderInner.setNeutralButton( - "삭제", - DialogInterface.OnClickListener { dialog, which -> - var realm = openRealm() - realm?.writeBlocking { - this.query().query("title == '${item.title}'").find() - ?.last()?.let { - this.delete(it) - } - } - dialog.dismiss() - }) - builderInner.setNegativeButton( - "취소", - DialogInterface.OnClickListener { dialog, which -> - dialog.dismiss() - }) - builderInner.show() - }) - var ddddd = builderSingle.create() - ddddd.setOnShowListener { d -> - (d as? AlertDialog)?.let { - it.listView?.setSelection(currentChapter) - } - } - - ddddd.show() - } - - fun showList(infos: BookPageInfos) { - Blog.LOGE("showList infos >>>>${infos}") - if (infos != null && infos.pages.size ?: 0 > 0) { - var items: ArrayList = arrayListOf() - for (item in infos.pages) { - items.add(item) - } - - items.sortBy { it.chapterID } - - DefaultList.showDefaultList( - requireContext(), - "현제는 ${currentTitle} - ${currentChapter} -> 다른화를 골라", - items, - currentChapter, - { position -> - return@showDefaultList items?.get(position)?.chapterTitle ?: "" - }, - { position -> - items?.get(position)?.let { moveTo(it) } - }, { state -> - if (state < 0) { - saveContinuation = true - moveToNext(currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path) - } - }) - } - } - - val String.cleanTextContent: String - get() { - // strips off all non-ASCII characters - var text = this - text = text.replace("[^\\x00-\\x7F]".toRegex(), "") - - // erases all the ASCII control characters - text = text.replace("[\\p{Cntrl}&&[^\r\n\t]]".toRegex(), "") - - // removes non-printable characters from Unicode - text = text.replace("\\p{C}".toRegex(), "") - return text.trim() - } - - - var saveClient = object : WebViewClient() { - override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { - super.onPageStarted(view, url, favicon) - - } - - override fun onPageFinished(webView: WebView?, url: String?) { - super.onPageFinished(webView, url) -// val delayed = 3500L + Math.abs(Random.nextLong().rem(9999L)) - finishedUrl = url ?: "" - webView?.postDelayed({ - webView?.evaluateJavascript( - "function getAll() {\n" + - " MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" + - " };getAll()" - ) { result -> - (result as? String)?.let { - - } - } - }, delayed) - } - - - } - - fun showToast(origin: String) { - activity?.runOnUiThread { - val toast = Toast(requireContext()) - toast.duration = Toast.LENGTH_SHORT - val biggerText = SpannableStringBuilder(origin) - biggerText.setSpan(RelativeSizeSpan(1.6f), 0, origin.length, 0) - val view: View = inflate(requireContext(), R.layout.simple_toast, null) - view.findViewById(R.id.text).text = biggerText - toast.view = view - toast.show() -// Toast.makeText( -// baseContext, -// biggerText, -// Toast.LENGTH_SHORT -// ).show() - } - } - - var delayed = 3500L + Math.abs(Random.nextLong().rem(9999L)) - var finishedUrl: String? = null - - private fun moveTo(item: BookPageInfo?) { - Blog.LOGE("item >>> ${item}") - item?.pathUrl?.let { newPath -> - contentsLoad(newPath) - } - } - - - fun moveToNext(pathUrl: String?) { - if (pathUrl != null && pathUrl.length > 6) { - HistoryManager.getNextPage(pathUrl) { - if (it != null && (it.pathUrl?.length ?: 0) > 6) { - moveTo(it) - } else { - showToast("다음 편이 없다요.") - } - } - } - } - - fun moveToPrev(pathUrl: String?) { - if (pathUrl != null && pathUrl.length > 6) { - HistoryManager.getPrevPage(pathUrl) { - if (it != null && (it.pathUrl?.length ?: 0) > 6) { - moveTo(it) - } else { - showToast("이전 편이 없다요.") - } - } - } - } - - fun contentsLoad(pathUrl: String) { - - fun applyCurrentBook(bookPageInfo: BookPageInfo) { - applyReaderConfig() - bookPageInfo.contents?.let { onLoadedContents(it) } - bookPageInfo.chapterTitle?.let { onFindTitle(it) } - if (bookPageInfo.pathUrl?.startsWith("http") == true) { - binding.menuWeb.loadUrl(pathUrl) - } else { - binding.menuWeb.loadUrl(getLastedDoamin() + bookPageInfo.pathUrl!!) - } - HistoryManager.save(HistoryItem().putHistory(bookPageInfo, bookPageInfo.pathUrl!!)) - } - - if (currentBooinfo?.pathUrl.equals(pathUrl)) { - applyCurrentBook(currentBooinfo!!) - } else { - HistoryManager.getBookPageInfo(pathUrl) { - Blog.LOGE("contentsLoad :::: pathUrl >> ${pathUrl} , book >> ${it}") - if (it != null && it.isValidBook()) { - currentBooinfo = it - applyCurrentBook(it) - } else if(lastInfo != null){ - binding.pagedLayer.visibility = GONE - binding.menuWeb.loadUrl(getLastedDoamin() + lastInfo!!.pageUrl) - } else { - binding.menuWeb.loadUrl(getLastedDoamin()) - } - } - } - } - - - fun actionNextEvent(fast: Boolean = false) { - if (binding.pagedLayer.isVisible && binding.pagedLayer.size() > 0 && (binding.pagedLayer.current() < binding.pagedLayer!!.size() - 1)) { - binding.pagedLayer.doNext(fast) - updateLastInfo(binding.pagedLayer!!) - } else { - moveToNext(currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path) - } - } - - fun applyReaderConfig() { - var realm = HistoryManager.openRealm - realm.query().find().let { - if (it.isNotEmpty()) { - realm.copyFromRealm(it.first()).let { - activity?.runOnUiThread { - var typeface = - typesfacez.get(getIndex(typesfacez as PairArray, it.font ?: "")) - binding.pagedLayer.setTypeface(resources.getFont(typeface.second)) - val color = colorz.get(it.style ?: 0) - binding.pagedLayer.setColorStyle(color.second) - binding.pagedLayer.setTextSize(it.textSize?.toFloat() ?: 14f) - binding.pagedLayer.setLineSpacing(it.lineSpace?.toFloat() ?: 1f) - binding.pagedLayer.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f) - binding.pagedLayer.setPadding( - it.padding ?: 1, - it.padding ?: 1, - it.padding ?: 1, - it.padding ?: 1 - ) - binding.pagedLayer.invalidate() - } - } - } - } - } - - fun actionPrevEvent(fast: Boolean = false) { - if (binding.pagedLayer.isVisible && binding.pagedLayer.size() > 0 && binding.pagedLayer.current() > 0) { - binding.pagedLayer.doPrev(fast) - updateLastInfo(binding.pagedLayer) - } else { - moveToPrev(currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path) - } - } -// -// override fun onBackPressed() { -// -// -// -// if (binding.pagedLayer.isVisible) { -// didBackPress = false -// binding.pagedLayer.visibility = GONE -// onTouch(TouchArea.Center) -// return -// } -// -// if (canGoBack == true) { -// didBackPress = false -// canGoBack = false -// binding.menuWeb.session?.goBack() -// return -// } -// -// if (!didBackPress) { -// firstBackPress() -// return -// } else { -// Activity.finishAffinity() -// didBackPress = false -// super.onBackPressed() -// } -// } - - - - fun showAlert(alert: String) { - Log.i(TAG, "showAlert >> " + alert) - } - - - fun onLoadedContents(aContents: String) { - binding.pagedLayer.apply { - binding.pagedLayer.post { - if (aContents.length > 10) { - var contents = aContents.replace("\\\"", "\"") - contents = (contents.replace("\\n", System.getProperty("line.separator"))) -// contents = (contents.replace("\\n", System.getProperty("line.separator"))) - mPagedTextViewInterface = this@Novels - if (lastInfo != null && lastedUrl?.endsWith(lastInfo!!.pageUrl) == true) { - binding.progress.visibility = VISIBLE - binding.pagedLayer.postDelayed({ - binding.progress.visibility = GONE - }, 1000) - } - applyReaderConfig() - activity?.runOnUiThread { - text = contents - visibility = VISIBLE - } - forceUpdateUI() - lastedUrl?.let { - Uri.parse(it)?.let { - it.path?.let { - HistoryManager.getBookPageInfo(it) { - it?.let { - currentBooinfo = it - currentChapter = it?.chapterNum ?: 0 - currentPage = it?.chapterNum ?: 0 - HistoryManager.save( - historyItem = HistoryItem().putHistory( - it, - lastedUrl!! - ) - ) - } - } - } - HistoryManager.getBooPageInfoContentsSave(it!!.path!!, contents) - if (saveContinuation) { - binding.menuWeb.postDelayed({moveToNext(currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path)}, 10000) - - } - } - } - } - - } - } -// Log.i(TAG, "onLoadedContents >> " + aContents) - } - - var currentTitle: String = "" - var currentChapter: Int = 0 - - fun onFindTitle(contents: String) { - binding.textviewTitle.text = contents - binding.textviewTitle.setOnClickListener { - val builder = AlertDialog.Builder(requireContext()) - builder.setTitle("Title") - val input = EditText(requireContext()) - input.setText(lastedUrl ?: "") - input.inputType = InputType.TYPE_CLASS_TEXT - builder.setView(input) - builder.setPositiveButton( - "OK" - ) { dialog, which -> - var m_Text = input.text.toString() - contentsLoad(m_Text.trim()) - } - builder.setNegativeButton( - "Cancel" - ) { dialog, which -> dialog.cancel() } - builder.show() - } - var testRegex = """[^0-9]""".toRegex() - Blog.LOGI(TAG, "onFindTitle >> " + contents + " ::: ${testRegex.replace(contents, "")}") - if (contents.contains("-")) { - currentTitle = contents.split("-")[0] - try { - currentChapter = testRegex.replace(contents.split("-")[1], "").toInt() - } catch (e: Exception) { - currentChapter = 0 - } - } else if (testRegex.replace(contents, "").length > 0) { - currentChapter = testRegex.replace(contents, "").toInt() - currentTitle = contents.split(testRegex.replace(contents, ""))[0] - } else { - val dateFormat = "yyyyMMdd-HH" - val date = Date(currentTimeMillis()) - val simpleDateFormat = SimpleDateFormat(dateFormat) - currentTitle = simpleDateFormat.format(date) - } - - } - - fun onStartLoad() { - binding.progress.visibility = VISIBLE - } - - fun completePageLoad(lastInfo: LastInfo) { - val configuration: Configuration = getResources().configuration - if (this.lastInfo == null || !(this.lastInfo?.pageUrl.equals(lastInfo?.pageUrl)) || this.lastInfo?.displayOrientation != configuration?.orientation) { - lastInfo.displayOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - saveLastInfo(lastInfo) - } - } - -// override fun onTouchEvent(event: MotionEvent?): Boolean { -// return super.onTouchEvent(event) -// if (saveContinuation) { -// saveContinuation = false -// } -// } - - fun saveLastInfo(lastInfo: LastInfo) { - val realm = openRealm() - if ((realm.query()?.count()?.find() ?: 0) > 0) { - realm.writeBlocking { - this.query()?.find()?.last()?.let { - it.pageUrl = lastInfo.pageUrl - it.title = currentTitle - it.chapter = currentChapter - it.pageIndex = lastInfo.pageIndex - it.contentsName = lastInfo.contentsName - it.displayOrientation = lastInfo.displayOrientation - this@Novels.lastInfo = copyFromRealm(it) - } - } - } else { - realm.writeBlocking { - copyToRealm(lastInfo) - } - } - Blog.LOGD(log = "Successfully opened realm: ${realm.configuration.name}") - - } - - fun updateLastInfo(pagedTextLayout: PagedTextLayout) { - (currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path)?.let { - HistoryManager.setBookPageInfo(it,binding.pagedLayer.current()) - } - val configuration: Configuration = getResources().configuration - val realm = openRealm() - realm.writeBlocking { - this.query().find()?.last()?.let { - it.displayOrientation = configuration.orientation - it.title = currentTitle - it.chapter = currentChapter - it.pageIndex = pagedTextLayout.current() - this@Novels.lastInfo = copyFromRealm(it) - } - if (currentTitle.length > 0 && currentChapter > 0) { - this@Novels.lastInfo?.makeHistoryItem()?.let { - copyToRealm(it, UpdatePolicy.ALL) - } - } - } - val message: JSONObject = JSONObject() - try { - message.put("type", "scrollDown") - message.put("max", binding.pagedLayer.size()) - message.put("current",binding.pagedLayer.current()) - } catch (ex: JSONException) { - throw RuntimeException(ex) - } - mPort?.postMessage(message) - Blog.LOGD(log = "Successfully opened realm: ${realm.configuration.name}") - } - - fun sendScrollDown(isUp: Boolean) { - val message: JSONObject = JSONObject() - try { - message.put("type", "scrollDown") - message.put("isUpDown", if (isUp) +1 else -1) - } catch (ex: JSONException) { - throw RuntimeException(ex) - } - Blog.LOGE(Gson().toJson(message)) - mPort?.postMessage(message) - } - - -// override fun onKeyClick(keyCode: Int): Boolean { -// when (keyCode) { -// KeyEvent.KEYCODE_VOLUME_DOWN -> { -// actionNextEvent() -// } -// -// KeyEvent.KEYCODE_VOLUME_UP -> { -// actionPrevEvent() -// } -// -// KeyEvent.KEYCODE_VOLUME_MUTE -> { -// actionNextEvent() -// } -// -// } -// return super.onKeyClick(keyCode) -// } -// -// override fun dispatchTrackballEvent(ev: MotionEvent?): Boolean { -// Blog.LOGE("dispatchTrackballEvent ev?.device?.name >>> ${ev?.device?.name}") -// return super.dispatchTrackballEvent(ev) -// } -// -// @SuppressLint("RestrictedApi") -// override fun dispatchKeyShortcutEvent(ev: KeyEvent): Boolean { -// Blog.LOGE("dispatchKeyShortcutEvent ev?.device?.name >>> ${ev?.device?.name}") -// return super.dispatchKeyShortcutEvent(ev) -// } -// -// -// -// override fun dispatchGenericMotionEvent(ev: MotionEvent?): Boolean { -// Blog.LOGE("dispatchKeyShortcutEvent ev?.device?.name >>> ${ev?.device?.name}") -// return super.dispatchGenericMotionEvent(ev) -// } -// -// override fun dispatchKeyEvent(ev: KeyEvent): Boolean { -// Blog.LOGE("dispatch ev?.device?.name >>> ${ev?.device?.name}") -// if (ev?.device?.name?.contains("SM-031N Mouse") == true) { -// when (ev.action) { -// ACTION_UP -> { -// Blog.LOGE("dispatch dispatchKeyEvent>>> ${ev}") -// when (ev.keyCode) { -// KEYCODE_BUTTON_Y -> { -// actionPrevEvent() -// } -// -// KEYCODE_BUTTON_X -> { -// -// } -// -// KEYCODE_BUTTON_A -> { -// actionNextEvent() -// } -// -// KEYCODE_BUTTON_B -> { -// -// } -// -// KEYCODE_DPAD_DOWN -> { -// -// } -// -// KEYCODE_DPAD_UP -> { -// -// } -// -// KEYCODE_BUTTON_START -> { -// goToHome() -// } -// -// KEYCODE_BUTTON_SELECT -> { -// -// saveContinuation = !saveContinuation -// if (saveContinuation) { -// moveToNext(currentBooinfo?.pathUrl ?: lastedUrl?.toUri()?.path) -// } -// } -// -// else -> {} -// } -// } -// -// else -> {} -// } -// return true -// } -// return super.dispatchKeyEvent(ev) -// } - - private fun goToHome() { - contentsLoad(getLastedDoamin()) - } - - var saveContinuation = false override fun onTouch(touchArea: TouchArea) { Blog.LOGD(log = "onTouch ${touchArea}") when (touchArea) { @@ -1323,14 +177,4 @@ class Novels : Fragment(), PagedTextViewInterface { override fun onTimeoverTouch() { } - - - - companion object { - private const val TAG = "DualScreenStatus" - } - - - - } \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Webtoons.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Webtoons.kt new file mode 100644 index 00000000..f73e6736 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/Webtoons.kt @@ -0,0 +1,183 @@ +package bums.lunatic.launcher.tokiz + +import android.content.DialogInterface +import android.content.Intent +import android.content.pm.ActivityInfo +import android.content.res.Configuration +import android.graphics.Bitmap +import android.graphics.Color +import android.net.Uri +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.os.Message +import android.text.InputType +import android.text.SpannableStringBuilder +import android.text.style.RelativeSizeSpan +import android.util.Log +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.View +import android.view.View.GONE +import android.view.View.OnTouchListener +import android.view.View.VISIBLE +import android.view.View.inflate +import android.view.ViewGroup +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.ArrayAdapter +import android.widget.EditText +import android.widget.TextView +import android.widget.Toast +import androidx.appcompat.app.AlertDialog +import androidx.core.net.toUri +import androidx.core.view.isVisible +import androidx.fragment.app.Fragment +import bums.lunatic.launcher.LauncherActivity.Companion.getRuntime +import bums.lunatic.launcher.R +import bums.lunatic.launcher.tokiz.common.PairArray +import bums.lunatic.launcher.tokiz.common.TouchArea +import bums.lunatic.launcher.tokiz.common.colorz +import bums.lunatic.launcher.tokiz.common.getIndex +import bums.lunatic.launcher.tokiz.common.typesfacez +import bums.lunatic.launcher.tokiz.data.HistoryManager +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsCollection +import bums.lunatic.launcher.tokiz.data.model.PageInfosJ +import bums.lunatic.launcher.tokiz.data.model.HistoryItem +import bums.lunatic.launcher.tokiz.data.model.LastInfo +import bums.lunatic.launcher.tokiz.data.model.PortMessage +import bums.lunatic.launcher.tokiz.data.model.ReaderConfig +import bums.lunatic.launcher.tokiz.dialog.DefaultList +import bums.lunatic.launcher.tokiz.view.JxEvent +import bums.lunatic.launcher.tokiz.view.PagedTextLayout +import bums.lunatic.launcher.tokiz.view.PagedTextViewInterface +import bums.lunatic.launcher.databinding.BooktokiBinding +import bums.lunatic.launcher.utils.Blog +import com.google.gson.Gson +import io.realm.kotlin.Realm +import io.realm.kotlin.UpdatePolicy +import io.realm.kotlin.ext.copyFromRealm +import io.realm.kotlin.ext.query +import org.json.JSONException +import org.json.JSONObject +import org.mozilla.gecko.util.ThreadUtils +import org.mozilla.geckoview.GeckoResult +import org.mozilla.geckoview.GeckoSession +import org.mozilla.geckoview.MediaSession +import org.mozilla.geckoview.WebExtension +import org.mozilla.geckoview.WebExtension.MessageDelegate +import org.mozilla.geckoview.WebExtension.PortDelegate +import org.mozilla.geckoview.WebExtensionController.AddonManagerDelegate +import org.mozilla.geckoview.WebRequestError +import java.lang.System.currentTimeMillis +import java.text.SimpleDateFormat +import java.util.Date +import kotlin.collections.ArrayList +import kotlin.collections.List +import kotlin.collections.MutableList +import kotlin.collections.arrayListOf +import kotlin.collections.first +import kotlin.collections.isNotEmpty +import kotlin.collections.last +import kotlin.collections.sortBy +import kotlin.random.Random +import kotlin.text.contains +import kotlin.text.endsWith +import kotlin.text.equals +import kotlin.text.replace +import kotlin.text.split +import kotlin.text.startsWith +import kotlin.text.toInt +import kotlin.text.toRegex +import kotlin.text.trim + + +class Webtoons : BaseToki(), PagedTextViewInterface { + + override val contentsType = "webtoon" + override var lastNumber : Int = 468 + override val webcontentsName : String = "newtoki" + override val afterDot = "com" + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + super.onCreateView(inflater, container, savedInstanceState) + return binding.root + } + + + override fun onStart() { + super.onStart() + } + + override fun onResume() { + super.onResume() + loadLastInfo() + Blog.LOGE("binding.root >>> ${binding.root}") + } + + override fun onTouch(touchArea: TouchArea) { + Blog.LOGD(log = "onTouch ${touchArea}") + when (touchArea) { + TouchArea.Center -> { + + } + + TouchArea.Right -> { + actionNextEvent() + } + + TouchArea.Left -> { + actionPrevEvent() + } + + TouchArea.DoubleRight -> { + actionNextEvent(true) + } + + TouchArea.DoubleLeft -> { + actionPrevEvent(true) + } + else -> { + + } + } + + + } + + override fun onLongClick() { + Blog.LOGD(log = "onLongClick") + + } + + override fun onSwipeLeft(count: Int) { + Blog.LOGD(log = "onSwipeLeft ${count}") + actionNextEvent(count > 1) + + } + + override fun onSwipeRight(count: Int) { + Blog.LOGD(log = "onSwipeRight ${count}") + actionPrevEvent(count > 1) + } + + override fun onSwipeUp(touchCount: Int) { + + } + + override fun onSwipeDown(touchCount: Int) { + if (touchCount == 2) { + if (binding.pagedLayer.isVisible) { + binding.pagedLayer.visibility = GONE + } + } + } + + override fun onTimeoverTouch() { + + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/common/PrefManager.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/common/PrefManager.kt index bd4af4e5..9bbd3233 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/common/PrefManager.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/common/PrefManager.kt @@ -2,7 +2,6 @@ package bums.lunatic.launcher.tokiz.common import android.content.Context import android.content.SharedPreferences -import bums.lunatic.launcher.tokiz.webcontents.contentsinfo.BooktokiStruct import bums.lunatic.launcher.utils.Blog object PrefManager { @@ -20,9 +19,9 @@ object PrefManager { return main.getString(key, "") } - fun getLastDomain() : String { - return main.getString(domainKey, BooktokiStruct.getLastedDoamin()) ?: BooktokiStruct.getLastedDoamin() - } +// fun getLastDomain() : String { +// return main.getString(domainKey, BooktokiStruct.getLastedDoamin()) ?: BooktokiStruct.getLastedDoamin() +// } fun putLastDomain(domain : String) { Blog.LOGE("domain >>> ${domain}") main.edit().putString(domainKey,domain).apply() diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/HistoryManager.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/HistoryManager.kt index 2ea5d5d1..9140f3b4 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/HistoryManager.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/HistoryManager.kt @@ -1,7 +1,7 @@ package bums.lunatic.launcher.tokiz.data -import bums.lunatic.launcher.tokiz.data.model.BookPageInfo -import bums.lunatic.launcher.tokiz.data.model.BookPageInfos +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsCollection import bums.lunatic.launcher.tokiz.data.model.HistoryItem import bums.lunatic.launcher.tokiz.data.model.LastInfo import bums.lunatic.launcher.tokiz.data.model.ReaderConfig @@ -45,9 +45,9 @@ object HistoryManager { } } - fun getBookInfos(aUrl : String, callback : (BookPageInfos?)->Unit) { + fun getBookInfos(contentsType : String,aUrl : String, callback : (ContentsCollection?)->Unit) { var url : String = aUrl - Blog.LOGE("aUrl >>> ${aUrl}") + Blog.LOGE("aUrl >>> ${aUrl} , contentsType ${contentsType}") openRealm.apply{ if (url.startsWith("//")) { while (url.startsWith("//")) { @@ -55,15 +55,17 @@ object HistoryManager { } } Blog.LOGE("aUrl >>> ${url}") - var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0 || bookPageUrl == $0","${url}").find() - if (bookPageInfo != null && bookPageInfo.count() > 0) { - Blog.LOGE("get ${bookPageInfo}" ) - var pgs = this.query(BookPageInfos::class,"bookPageUrl == $0", bookPageInfo.first().bookPageUrl).find() + var contentsPageInfo = this.query(ContentsPageInfo::class).query("contentsType == $0", contentsType).query("pathUrl == $0 || bookPageUrl == $0","${url}").find() + if (contentsPageInfo != null && contentsPageInfo.count() > 0) { + Blog.LOGE("get ${contentsPageInfo}" ) + var pgs = this.query(ContentsCollection::class,"bookPageUrl == $0", contentsPageInfo.first().bookPageUrl).find() if (pgs.size > 0) { pgs.first().let { Blog.LOGE("get ${it} , ${it?.pages}") callback.invoke(this.copyFromRealm(it)) } + } else { + callback.invoke(null) } } else { callback.invoke(null) @@ -71,7 +73,7 @@ object HistoryManager { } } - fun getBookPageInfo(aUrl : String, callback : (BookPageInfo?)->Unit) { + fun getBookPageInfo(contentsType : String, aUrl : String, callback : (ContentsPageInfo?)->Unit) { var url : String = aUrl openRealm.apply{ if (url.startsWith("//")) { @@ -79,7 +81,7 @@ object HistoryManager { url = url.replace("//","/").trim() } } - var result = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find() + var result = this.query(ContentsPageInfo::class).query("contentsType == $0", contentsType).query("pathUrl == $0","${url}").find() if (result.size > 0) { var bookPageInfo = result?.first() if (bookPageInfo != null) { @@ -93,7 +95,7 @@ object HistoryManager { } } - fun setBookPageInfo(aUrl : String, page :Int) { + fun setBookPageInfo(contentsType : String,aUrl : String, page :Int) { var url : String = aUrl openRealm.writeBlocking { if (url.startsWith("//")) { @@ -101,7 +103,7 @@ object HistoryManager { url = url.replace("//","/").trim() } } - var result = this.query(BookPageInfo::class).query("pathUrl == $0","${url}").find() + var result = this.query(ContentsPageInfo::class).query("contentsType == $0", contentsType).query("pathUrl == $0","${url}").find() if (result.size > 0) { var bookPageInfo = result?.first() if (bookPageInfo != null) { @@ -111,13 +113,13 @@ object HistoryManager { } } - fun getBooPageInfoContentsSave(aUrl : String, contents : String) { + fun getBooPageInfoContentsSave(contentsType : String,aUrl : String, contents : String) { var url : String = if (aUrl.startsWith("//") || aUrl.startsWith("///") || aUrl.startsWith("////")) { aUrl.replace("////","/").replace("///","/").replace("//","/") } else aUrl openRealm.writeBlocking { Blog.LOGE("getBooPageInfoContentsSave ${url}") - val result = query(BookPageInfo::class).query("pathUrl == $0", "${url}").find() + val result = query(ContentsPageInfo::class).query("contentsType == $0", contentsType).query("pathUrl == $0", "${url}").find() if (result.size > 0) { result.first().contents = contents copyToRealm(result.first(), UpdatePolicy.ALL) @@ -128,7 +130,7 @@ object HistoryManager { - fun getNextPage(aUrl : String ,callback : (BookPageInfo?)->Unit) { + fun getNextPage(contentsType : String,aUrl : String ,callback : (ContentsPageInfo?)->Unit) { var url : String = aUrl openRealm.apply{ if (url.startsWith("//")) { @@ -136,11 +138,11 @@ object HistoryManager { 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() + var contentsPageInfo = + this.query(ContentsPageInfo::class).query("contentsType == $0", contentsType).query("pathUrl == $0", url).find() + if (contentsPageInfo.size > 0) { + Blog.LOGE("getNextPage 2 => chapterNum : ${contentsPageInfo.first().chapterNum} , bookPageInfo.bookPageUrl : ${contentsPageInfo.first().bookPageUrl}" ) + var results = this.query(ContentsPageInfo::class).query("chapterNum == $0",contentsPageInfo.first().chapterNum + 1).query("bookPageUrl == $0","${contentsPageInfo.first().bookPageUrl}").find() if(results.size > 0) { results.first().let { Blog.LOGE("getNextPage 2 nextBook pathUrl : ${it.pathUrl}" ) @@ -152,7 +154,7 @@ object HistoryManager { } - fun getPrevPage(aUrl : String ,callback : (BookPageInfo?)->Unit) { + fun getPrevPage(contentsType : String,aUrl : String ,callback : (ContentsPageInfo?)->Unit) { var url : String = aUrl openRealm.apply{ Blog.LOGE("getPrevPage ${url}" ) @@ -162,13 +164,13 @@ object HistoryManager { } } 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() + var contentsPageInfo = + this.query(ContentsPageInfo::class).query("contentsType == $0", contentsType).query("pathUrl == $0", url).find() + Blog.LOGE("getPrevPage ${contentsPageInfo}" ) + if (contentsPageInfo.size > 0) { + Blog.LOGE("getPrevPage 2 ${contentsPageInfo?.first()?.chapterNum}" ) + Blog.LOGE("getPrevPage 2 ${contentsPageInfo?.first()?.bookPageUrl}" ) + var results = this.query(ContentsPageInfo::class).query("chapterNum == $0",contentsPageInfo.first().chapterNum - 1).query("bookPageUrl == $0","${contentsPageInfo.first().bookPageUrl}").find() if(results.size > 0) { results.first()?.let { Blog.LOGE("getPrevPage 2 ${it.bookPageUrl}" ) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/BookPageInfo.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/ContentsPageInfo.kt similarity index 76% rename from app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/BookPageInfo.kt rename to app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/ContentsPageInfo.kt index a7a4928d..bfea2b39 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/BookPageInfo.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/ContentsPageInfo.kt @@ -7,7 +7,7 @@ import io.realm.kotlin.types.annotations.PrimaryKey class PortMessage { var type : String? = "" - var bookInfos : BookPageInfosJ? = null + var bookInfos : PageInfosJ? = null var book : BookContents? = null var msg : String? = null } @@ -16,11 +16,11 @@ class BookContents { var bookContents : String? = null } -class BookPageInfosJ { +class PageInfosJ { var bookTitle : String = "" var bookPageUrl : String = "" - - var pages : ArrayList = arrayListOf() + var contentsType : String? = "" + var pages : ArrayList = arrayListOf() fun getTitleArray() : ArrayList { var arrayList = ArrayList() @@ -28,15 +28,16 @@ class BookPageInfosJ { return arrayList } - fun getR() : BookPageInfos{ - var r = BookPageInfos() + fun getR() : ContentsCollection{ + var r = ContentsCollection() r.bookTitle = this.bookTitle r.bookPageUrl = this.bookPageUrl - + r.contentsType = this.contentsType return r } } -class BookPageInfoJ { + +class PageInfoJ { var chapterID : Int = 0 var contents : String? = "" var bookPageUrl : String? = "" @@ -45,9 +46,10 @@ class BookPageInfoJ { var chapterNum : Int = 0 var lastPage : Int? = 0 var pathUrl : String? = "" + var contentsType : String? = "" - fun getRealm() : BookPageInfo { - var r = BookPageInfo() + fun getRealm() : ContentsPageInfo { + var r = ContentsPageInfo() r.chapterID = this.chapterID r.contents = this.contents r.bookPageUrl = this.bookPageUrl ?: "" @@ -56,19 +58,20 @@ class BookPageInfoJ { r.chapterNum = this.chapterNum r.lastPage = this.lastPage r.pathUrl = this.pathUrl?.replace("'","") - + r.contentsType = this.contentsType return r } } -class BookPageInfos : RealmObject { +class ContentsCollection : RealmObject { var bookTitle : String = "" @PrimaryKey var bookPageUrl : String? = "" - var pages : RealmList = realmListOf() + var pages : RealmList = realmListOf() + var contentsType : String? = "" fun getTitleArray() : ArrayList { var arrayList = ArrayList() @@ -78,11 +81,11 @@ class BookPageInfos : RealmObject { } fun sort() { - val comparator : Comparator = compareBy { it.chapterID } + val comparator : Comparator = compareBy { it.chapterID } pages.sortWith(comparator) } - fun hasItem(item: BookPageInfo) : Boolean { + fun hasItem(item: ContentsPageInfo) : Boolean { var hasItem = false for (c in pages) { if (!hasItem) { @@ -94,7 +97,7 @@ class BookPageInfos : RealmObject { } -class BookPageInfo : RealmObject { +class ContentsPageInfo : RealmObject { var chapterID : Int = 0 var contents : String? = "" @@ -104,6 +107,7 @@ class BookPageInfo : RealmObject { var bookTitle : String? = "" var chapterNum : Int = 0 var lastPage : Int? = 0 + var contentsType : String? = "" fun isValidBook() = (pathUrl?.length ?: 0) > 1 diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/FakeSession.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/FakeSession.kt new file mode 100644 index 00000000..c258f391 --- /dev/null +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/FakeSession.kt @@ -0,0 +1,47 @@ +package bums.lunatic.launcher.tokiz.data.model +class FakeSessions : ArrayList{ + constructor(initialCapacity: Int) : super(initialCapacity) + constructor() : super() + constructor(c: MutableCollection) : super(c) +} +data class FakeSession (val scrolldata: ScrollData, val history: History ) +data class ScrollData( + val scroll: String, + val zoom: Zoom +) + +data class Zoom( + val resolution: Int, + val displaySize: DisplaySize +) + +data class DisplaySize( + val height: Int, + val width: Int +) + +data class History( + val entries: List, + val requestedIndex: Int, + val fromIdx: Int, + val index: Int +) + +data class HistoryEntry( + val persist: Boolean, + val cacheKey: Int, + val ID: Int, + val url: String, + val title: String, + val loadReplace: Boolean, + val docIdentifier: Long, + val loadReplace2: Boolean, + val partitionedPrincipalToInherit_base64: Map>, + val triggeringPrincipal_base64: Map>, + val principalToInherit_base64: Map>, + val resultPrincipalURI: String, + val hasUserInteraction: Boolean, + val originalURI: String, + val docshellUUID: String +) + diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/PageInfo.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/PageInfo.kt index d9e98607..9668a8d9 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/PageInfo.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/data/model/PageInfo.kt @@ -1,6 +1,7 @@ package bums.lunatic.launcher.tokiz.data.model import android.content.pm.ActivityInfo +import bums.lunatic.launcher.tokiz.data.model.LastInfo import io.realm.kotlin.types.RealmObject import io.realm.kotlin.types.annotations.PrimaryKey import java.text.SimpleDateFormat @@ -9,12 +10,17 @@ import java.util.Date class LastInfo : RealmObject { @PrimaryKey - var _id : String = "UniqLastId" + var _id : String = "" var pageUrl : String = "" var title : String = "" var chapter : Int = 0 var pageIndex : Int = 0 var contentsName : String = "" + var contentsType : String? = "" + set(value) { + _id = value ?: "" + field = value + } var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT fun makeHistoryItem() : HistoryItem = HistoryItem().apply { @@ -24,6 +30,7 @@ class LastInfo : RealmObject { pageIndex = this@LastInfo.pageIndex contentsName = this@LastInfo.contentsName displayOrientation = this@LastInfo.displayOrientation + contentsType = this@LastInfo.contentsType } } class HistoryItem : RealmObject { @@ -34,6 +41,7 @@ class HistoryItem : RealmObject { var pageIndex : Int = 0 var contentsName : String = "" var displayOrientation : Int = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + var contentsType : String? = "" fun makeLastInfo() = LastInfo().apply{ _id = "UniqLastId" @@ -43,13 +51,15 @@ class HistoryItem : RealmObject { pageIndex = this@HistoryItem.pageIndex contentsName = this@HistoryItem.contentsName displayOrientation = this@HistoryItem.displayOrientation + contentsType = this@HistoryItem.contentsType } - fun putHistory(bookPageInfo: BookPageInfo? , currentPath : String) : HistoryItem { - title = bookPageInfo?.bookTitle ?: SimpleDateFormat("YY-mm-DD-HH:mm").format(Date()) - pageUrl = bookPageInfo?.pathUrl ?: currentPath - chapter = bookPageInfo?.chapterNum ?: 0 - pageIndex = bookPageInfo?.lastPage ?: 0 - contentsName = bookPageInfo?.chapterTitle ?: "" + fun putHistory(contentsPageInfo: ContentsPageInfo?, currentPath : String) : HistoryItem { + title = contentsPageInfo?.bookTitle ?: SimpleDateFormat("YY-mm-DD-HH:mm").format(Date()) + pageUrl = contentsPageInfo?.pathUrl ?: currentPath + chapter = contentsPageInfo?.chapterNum ?: 0 + pageIndex = contentsPageInfo?.lastPage ?: 0 + contentsName = contentsPageInfo?.chapterTitle ?: "" + contentsType = contentsPageInfo?.contentsType ?: "" return this } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/dialog/DefaultList.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/dialog/DefaultList.kt index 1e62a393..0a7f9674 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/dialog/DefaultList.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/dialog/DefaultList.kt @@ -5,10 +5,10 @@ import android.content.Context import android.content.DialogInterface import android.widget.ArrayAdapter import androidx.appcompat.app.AlertDialog -import bums.lunatic.launcher.tokiz.data.model.BookPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo object DefaultList { - fun showDefaultList(context: Context, title : String, items : Collection, firstPosition : Int, choosedTitle : (Int)->String, chooedPositive : (Int)->Unit, saveCalback : (Int)->Unit ) { + fun showDefaultList(context: Context, title : String, items : Collection, firstPosition : Int, choosedTitle : (Int)->String, chooedPositive : (Int)->Unit, saveCalback : (Int)->Unit ) { val builderSingle: AlertDialog.Builder = AlertDialog.Builder(context) builderSingle.setTitle(title) val arrayAdapter = diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/BWebview.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/BWebview.kt index 66f000f6..1ed83611 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/BWebview.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/BWebview.kt @@ -2,12 +2,13 @@ package bums.lunatic.launcher.tokiz.view import android.annotation.SuppressLint import android.content.Context +import android.os.Build import android.util.AttributeSet import android.view.MotionEvent +import android.view.PointerIcon import android.view.View import androidx.core.view.isVisible import bums.lunatic.launcher.tokiz.common.TouchArea -import bums.lunatic.launcher.tokiz.webcontents.contentsinfo.BooktokiStruct import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.SimpleFingerGestures import org.mozilla.geckoview.GeckoView @@ -23,23 +24,37 @@ typealias JxInteface = (JxEvent)->Unit open class BWebview : GeckoView { @SuppressLint("ClickableViewAccessibility") constructor(context: Context?) : super(context) { - this.setOnTouchListener { v,e -> - if (e.device.name.contains("JX-12",true) == true) { - return@setOnTouchListener mSimpleFingerGestures.onTouch(v,e) + this.setOnTouchListener { v, event -> + if (event.device.name?.contains( + "JX-12", + true + ) == true || event.device.name?.equals("J06", true) == true + ) { + return@setOnTouchListener mSimpleFingerGestures.onTouch(v, event) } else { - return@setOnTouchListener super.onTouchEvent(e) + return@setOnTouchListener super.onTouchEvent(event) } } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + val nullCursor = PointerIcon.getSystemIcon(context!!, PointerIcon.TYPE_NULL) + this.setPointerIcon(nullCursor) + } } + + @SuppressLint("ClickableViewAccessibility") constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { - this.setOnTouchListener { v,e -> - if (e.device.name.contains("JX-12",true) == true) { - return@setOnTouchListener mSimpleFingerGestures.onTouch(v,e) + this.setOnTouchListener { v,event -> + if (event.device.name?.contains("JX-12",true) == true|| event.device.name?.equals("J06",true) == true) { + return@setOnTouchListener mSimpleFingerGestures.onTouch(v,event) } else { - return@setOnTouchListener super.onTouchEvent(e) + return@setOnTouchListener super.onTouchEvent(event) } } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + val nullCursor = PointerIcon.getSystemIcon(context!!, PointerIcon.TYPE_NULL) + this.setPointerIcon(nullCursor) + } } @@ -96,7 +111,7 @@ open class BWebview : GeckoView { gestureDistance: Double ): Boolean { Blog.LOGE("onPinch") - return false + return true } override fun onUnpinch( @@ -122,7 +137,7 @@ open class BWebview : GeckoView { fingers: Int ): Boolean { Blog.LOGE("onLongPress") - return false + return true } override fun onClick( @@ -131,7 +146,7 @@ open class BWebview : GeckoView { ): Boolean { Blog.LOGE("onClick") jxInteface?.invoke(JxEvent.ON_CLICK) - return false + return true } @@ -142,7 +157,7 @@ open class BWebview : GeckoView { var jxInteface : JxInteface? = null - + var lastDomain : String = "" fun loadUrl(url: String) { if (this.isVisible == false) { @@ -151,7 +166,7 @@ open class BWebview : GeckoView { Blog.LOGE("url >>>> ${url}") var nUrl = url if (url.startsWith("http") == false) { - nUrl = BooktokiStruct.getLastedDoamin().plus(url) + nUrl = lastDomain } nUrl?.let { url -> if (url.split("//").size > 1) { @@ -171,7 +186,7 @@ open class BWebview : GeckoView { override fun onTouchEvent(event: MotionEvent): Boolean { Blog.LOGE("event.device.name >>> ${event.device.name}") - if (event.device.name.contains("JX-12", true)) { + if (event.device.name?.contains("JX-12",true) == true || event.device.name?.equals("J06",true) == true) { Blog.LOGE("BWebview onTouchEvent $event") when (event.action) { MotionEvent.ACTION_DOWN -> { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/PagedTextLayout.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/PagedTextLayout.kt index 496e47b8..3fda96d7 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/PagedTextLayout.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/view/PagedTextLayout.kt @@ -243,8 +243,8 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface { } fun setPageBy(num : Int) { - currentPage = num - var realPage = if(isDualPage()) currentPage * 2 else currentPage + this@PagedTextLayout.currentPage = num + var realPage = if(isDualPage()) this@PagedTextLayout.currentPage * 2 else this@PagedTextLayout.currentPage Blog.LOGE("realPage = if(${pageList?.size} ?: 0 > ${realPage}) { realPage} else { ${(pageList?.size ?: 0) - 1 }}") realPage = if(pageList?.size ?: 0 > realPage) { realPage} else { (pageList?.size ?: 0) - 1 } currentPageTextView?.text = "${realPage + 1 }/${ pageList?.size ?: 0 + 1}" @@ -260,25 +260,25 @@ class PagedTextLayout : ConstraintLayout , PagedTextGenerateInterface { fun size(): Int = if(isDualPage()) Math.round((hiddenTextView?.size() ?:0) * 0.5f) else hiddenTextView?.size() ?: 0 fun getFastPageCount() = if(isDualPage()) 3 else 6 - fun current(): Int = currentPage + fun current(): Int = this@PagedTextLayout.currentPage fun doNext(fast : Boolean = false) { if (fast) { - setPageBy(if((currentPage + getFastPageCount()) >= 0) { - currentPage + getFastPageCount() + setPageBy(if((this@PagedTextLayout.currentPage + getFastPageCount()) >= 0) { + this@PagedTextLayout.currentPage + getFastPageCount() } else {size()}) } else { - setPageBy(currentPage.inc()) + setPageBy(this@PagedTextLayout.currentPage.inc()) } } fun doPrev(fast : Boolean = false) { if (fast) { - setPageBy(if((currentPage - getFastPageCount()) >= 0) { - currentPage - getFastPageCount() + setPageBy(if((this@PagedTextLayout.currentPage - getFastPageCount()) >= 0) { + this@PagedTextLayout.currentPage - getFastPageCount() } else {0}) } else { - setPageBy(if(currentPage > 0 )currentPage.dec() else 0) + setPageBy(if(this@PagedTextLayout.currentPage > 0 ) this@PagedTextLayout.currentPage.dec() else 0) } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/webcontents/contentsinfo/BooktokiStruct.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/webcontents/contentsinfo/BooktokiStruct.kt index e4c0f8de..fad8f96d 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/webcontents/contentsinfo/BooktokiStruct.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/webcontents/contentsinfo/BooktokiStruct.kt @@ -1,16 +1,16 @@ -package bums.lunatic.launcher.tokiz.webcontents.contentsinfo - - -object BooktokiStruct : BaseWebContents() { - - override var lastNumber : Int = 468 - - override fun getWebcontentsName(): String { - return "Booktoki" - } - - override fun getLastedDoamin(): String { - return String.format("https://booktoki%d.com", lastNumber) - } - -} \ No newline at end of file +//package bums.lunatic.launcher.tokiz.webcontents.contentsinfo +// +// +//object BooktokiStruct : BaseWebContents() { +// +// override var lastNumber : Int = 468 +// +// override fun getWebcontentsName(): String { +// return "Booktoki" +// } +// +// override fun getLastedDoamin(): String { +// return String.format("https://booktoki%d.com", lastNumber) +// } +// +//} \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt index ce92c122..60349d6a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -2,8 +2,8 @@ package bums.lunatic.launcher.workers import bums.lunatic.launcher.BuildConfig import bums.lunatic.launcher.apps.SimpleContact -import bums.lunatic.launcher.tokiz.data.model.BookPageInfo -import bums.lunatic.launcher.tokiz.data.model.BookPageInfos +import bums.lunatic.launcher.tokiz.data.model.ContentsPageInfo +import bums.lunatic.launcher.tokiz.data.model.ContentsCollection import bums.lunatic.launcher.tokiz.data.model.HistoryItem import bums.lunatic.launcher.tokiz.data.model.LastInfo import bums.lunatic.launcher.tokiz.data.model.ReaderConfig @@ -56,21 +56,12 @@ class CustMigration : AutomaticSchemaMigration { } object WorkersDb { - fun recommendApps() { - val cal = Calendar.getInstance() - cal.time = Date() - val weekOfYear = cal.get(Calendar.WEEK_OF_YEAR) - val weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH) - val dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) - getRealm().apply { -// this.query().query("weekOfYear == $0 OR weekOfMonth == $1 OR dayOfWeek == $2").limit() - } - } + val clazz : Set> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class, TelegramBotUpdate::class, TelegramData::class, TelegramMessage::class, TelegramChat::class, BotCommandEentitie::class, TelegramFrom::class, WeatherForcast::class, Location::class, Current::class, Forecast::class, Condition::class, Forecastday::class, Day::class, Astro::class, Hour::class, LocationLog::class, - LastInfo::class, HistoryItem::class, ReaderConfig::class, BookPageInfos::class, BookPageInfo::class + LastInfo::class, HistoryItem::class, ReaderConfig::class, ContentsCollection::class, ContentsPageInfo::class ) //,UserActionModel::class diff --git a/app/src/main/res/layout/booktoki.xml b/app/src/main/res/layout/booktoki.xml index 55c39a47..4058ab6f 100644 --- a/app/src/main/res/layout/booktoki.xml +++ b/app/src/main/res/layout/booktoki.xml @@ -1,25 +1,12 @@ - - - - - - - - - - - - - + > - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/launcher_activity.xml b/app/src/main/res/layout/launcher_activity.xml index 1d3922b4..0b380684 100644 --- a/app/src/main/res/layout/launcher_activity.xml +++ b/app/src/main/res/layout/launcher_activity.xml @@ -9,27 +9,18 @@ android:id="@+id/mainFragmentsContainer" > - - + app:layout_constraintBottom_toTopOf="@id/tabs"/> - - + + + - + \ No newline at end of file