This commit is contained in:
lunaticbum 2024-09-06 01:04:53 +09:00
parent 3813a4293b
commit 1ca2b360d7
6 changed files with 97 additions and 59 deletions

View File

@ -89,4 +89,5 @@ dependencies {
implementation ("io.realm.kotlin:library-base:2.1.0") implementation ("io.realm.kotlin:library-base:2.1.0")
implementation ("org.jsoup:jsoup:1.18.1") implementation ("org.jsoup:jsoup:1.18.1")
implementation ("org.apache.commons:commons-text:1.12.0") implementation ("org.apache.commons:commons-text:1.12.0")
implementation("com.squareup.okhttp:okhttp:2.7.5")
} }

View File

@ -52,11 +52,14 @@
android:stateNotNeeded="true" android:stateNotNeeded="true"
android:enableOnBackInvokedCallback="true" android:enableOnBackInvokedCallback="true"
android:largeHeap="true" android:largeHeap="true"
android:debuggable="false"
android:networkSecurityConfig="@xml/network_security_config"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
android:screenOrientation="nosensor" android:screenOrientation="nosensor"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
android:requestLegacyExternalStorage="true"> android:requestLegacyExternalStorage="true"
>
<activity <activity
android:name=".LauncherActivity" android:name=".LauncherActivity"

View File

@ -503,16 +503,17 @@ internal class LauncherActivity : AppCompatActivity() {
var callBack : (()->Unit)? = null var callBack : (()->Unit)? = null
var isF = false var isF = false
fun doWebParseStart(url : String, callBack : (()->Unit)?) { fun doWebParseStart(url : String, callBack : (()->Unit)?) {
isF = true isF = false
this.callBack = callBack this.callBack = callBack
binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE } binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE }
BLog.LOGE("binding.otherCheck before ThreadRun") BLog.LOGE("binding.otherCheck before ThreadRun")
binding.searcher01.webViewClient = object : WebViewClient() { binding.searcher01.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
if (!isF && url?.contains("missav") == true) { if (url?.contains("missav") == true && isF) {
BLog.LOGE("binding.otherCheck before reload")
view?.loadUrl(url!!) view?.loadUrl(url!!)
isF = true isF = true
return false
} }
return false return false
} }
@ -572,7 +573,7 @@ internal class LauncherActivity : AppCompatActivity() {
// } // }
// } // }
} }
// callBack?.invoke() if (isF) this@LauncherActivity.callBack?.invoke()
// binding.searcher01.post { binding.searcher01.visibility = View.GONE } // binding.searcher01.post { binding.searcher01.visibility = View.GONE }
// } // }
} }

View File

@ -37,7 +37,13 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle import androidx.lifecycle.repeatOnLifecycle
import com.google.android.material.button.MaterialButtonToggleGroup import com.google.android.material.button.MaterialButtonToggleGroup
import com.squareup.okhttp.ConnectionPool
import com.squareup.okhttp.OkHttpClient
import com.squareup.okhttp.Request
import com.squareup.okhttp.Response
import com.squareup.okhttp.ResponseBody
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import io.realm.kotlin.query.Sort
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.jsoup.Jsoup import org.jsoup.Jsoup
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost
@ -57,18 +63,19 @@ import rasel.lunar.launcher.helpers.Constants.Companion.SEPARATOR
import rasel.lunar.launcher.helpers.Constants.Companion.requestCreateWidget import rasel.lunar.launcher.helpers.Constants.Companion.requestCreateWidget
import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget
import rasel.lunar.launcher.home.LauncherHome.Companion.home import rasel.lunar.launcher.home.LauncherHome.Companion.home
import rasel.lunar.launcher.home.LauncherHome.Companion.listItem
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
import rasel.lunar.launcher.model.RssTagItem
import rasel.lunar.launcher.model.RssData import rasel.lunar.launcher.model.RssData
import rasel.lunar.launcher.model.RssDataInterface import rasel.lunar.launcher.model.RssDataInterface
import rasel.lunar.launcher.model.RssDataType import rasel.lunar.launcher.model.RssDataType
import rasel.lunar.launcher.model.RssTagItem
import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.RssList.jGuruMain import rasel.lunar.launcher.utils.RssList.jGuruMain
import rasel.lunar.launcher.workers.WorkersDb import rasel.lunar.launcher.workers.WorkersDb
import java.net.URLEncoder import java.net.URLEncoder
import java.nio.charset.Charset import java.nio.charset.Charset
import java.util.* import java.util.*
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
internal class Feeds : Fragment() { internal class Feeds : Fragment() {
@ -150,6 +157,8 @@ internal class Feeds : Fragment() {
mapIntent.setPackage("com.opera.browser") mapIntent.setPackage("com.opera.browser")
lActivity?.startActivity(mapIntent) lActivity?.startActivity(mapIntent)
} }
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
/* start rss service if network is active and rss url is not empty */ /* start rss service if network is active and rss url is not empty */
private fun startService() { private fun startService() {
binding.feedsRss.rss.visibility = View.GONE binding.feedsRss.rss.visibility = View.GONE
@ -168,7 +177,8 @@ internal class Feeds : Fragment() {
if (input.text.toString().trim().contains(" ")) { if (input.text.toString().trim().contains(" ")) {
val cmd = input.text.toString().trim().split(" ") val cmd = input.text.toString().trim().split(" ")
when(cmd[0]) { when(cmd[0]) {
"miss"-> lActivity?.doWebParseStart("https://missav.com/ko/search/${input.text.toString().trim().split(" ")[1]}/") {} //lActivity?.doWebParseStart("https://missav.com/dm16/en") {}
"miss"-> lActivity?.doWebParseStart("https://missav.com/en/search/${input.text.toString().trim().split(" ")[1]}/") {}
"mgn"-> { "mgn"-> {
// lActivity?.doWebParseStart("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}") {} // lActivity?.doWebParseStart("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}") {}
GlobalScope.launch { GlobalScope.launch {
@ -212,34 +222,12 @@ internal class Feeds : Fragment() {
binding.feedsRss.apply { binding.feedsRss.apply {
rss.adapter = mRssAdapter rss.adapter = mRssAdapter
loading.visibility = View.VISIBLE loading.visibility = View.VISIBLE
if (listItem.size > 0) { mRssAdapter?.updateData(WorkersDb.getRealm()
listItem.sortByDescending { it.pubDate() } .query<RssData>("category == $0", RssDataType.GURU.name)
WorkersDb.getRealm() .sort("pubDate", Sort.DESCENDING).find())
.query<RssData>("category == '$0'", RssDataType.GURU.name)
.find()?.apply {
mRssAdapter?.updateData(listItem)
}
rss.visibility = View.VISIBLE rss.visibility = View.VISIBLE
loading.visibility = View.GONE loading.visibility = View.GONE
refresh.visibility = View.GONE refresh.visibility = View.GONE
} else {
refresh.visibility = View.VISIBLE
rss.visibility = View.GONE
refresh.setOnClickListener {
var call = {
if (listItem.size > 0) {
rss?.postDelayed({
listItem.sortByDescending { it.pubDate() }
mRssAdapter?.updateData(listItem)
loading.visibility = View.GONE
refresh.visibility = View.GONE
rss.visibility = View.VISIBLE
}, 500L)
}
}
}
}
} }
} }
@ -247,10 +235,48 @@ internal class Feeds : Fragment() {
lActivity?.doWebParseStart("https://projectjav.com") {} lActivity?.doWebParseStart("https://projectjav.com") {}
} }
"jmnew" -> { "jmnew" -> {
lActivity?.doWebParseStart("https://missav.com/dm511/ko/new") {} Executors.newSingleThreadScheduledExecutor().schedule({
try {
val url = "https://missav.com/"
// OkHttp 클라이언트 객체 생성
val client: OkHttpClient = OkHttpClient()
client.connectionPool = ConnectionPool(10, 300, TimeUnit.SECONDS)
client.setFollowSslRedirects(true)
// GET 요청 객체 생성
val builder: Request.Builder = Request.Builder().url(url).get()
// builder.addHeader("password", "BlahBlah")
val request: Request = builder.build()
// OkHttp 클라이언트로 GET 요청 객체 전송
val response: Response = client.newCall(request).execute()
if (response.isSuccessful()) {
// 응답 받아서 처리
val body: ResponseBody = response.body()
if (body != null) {
System.out.println("Response:" + body.string())
}
} else System.err.println("Error Occurred")
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
// try {
// Jsoup.connect("https://missav.com/").userAgent(USAGT).timeout(300000).get().apply {
// BLog.LOGE("https://missav.com/dm507/en/release >>>> ${this}")
// }
// }catch (e : Exception) {
// e.printStackTrace()
//
// }
}, 2, TimeUnit.SECONDS)
// lActivity?.doWebParseStart("https://missav.com/dm507/en/release") {}
} }
"jmiss" -> { "jmiss" -> {
lActivity?.doWebParseStart("https://missav.com/dm11/ko") {} lActivity?.doWebParseStart("https://missav.com/dm16/en") {}
} }
"jreq" -> { "jreq" -> {
lActivity?.doWebParseStart(jGuruMain) {} lActivity?.doWebParseStart(jGuruMain) {}

View File

@ -84,6 +84,7 @@ import rasel.lunar.launcher.qaccess.QuickAccess
import rasel.lunar.launcher.settings.SettingsActivity import rasel.lunar.launcher.settings.SettingsActivity
import rasel.lunar.launcher.todos.MissedCallsAdapter import rasel.lunar.launcher.todos.MissedCallsAdapter
import rasel.lunar.launcher.model.RssDataInterface import rasel.lunar.launcher.model.RssDataInterface
import rasel.lunar.launcher.model.RssDataType
import rasel.lunar.launcher.todos.NotificationItemAdapter import rasel.lunar.launcher.todos.NotificationItemAdapter
import rasel.lunar.launcher.todos.RssItemAdapter import rasel.lunar.launcher.todos.RssItemAdapter
import rasel.lunar.launcher.todos.SmsLogsAdapter import rasel.lunar.launcher.todos.SmsLogsAdapter
@ -118,7 +119,6 @@ internal class LauncherHome : Fragment() {
var callList = arrayListOf<RecentCall>() var callList = arrayListOf<RecentCall>()
var smsList = arrayListOf<RecentSms>() var smsList = arrayListOf<RecentSms>()
var listTags = arrayListOf<RssDataInterface>() var listTags = arrayListOf<RssDataInterface>()
var listItem = arrayListOf<RssDataInterface>()
} }
private var nReceiver: NotificationReceiver? = null private var nReceiver: NotificationReceiver? = null
@ -232,8 +232,9 @@ internal class LauncherHome : Fragment() {
registerReceiver(requireContext(),nReceiver, filter,RECEIVER_EXPORTED) registerReceiver(requireContext(),nReceiver, filter,RECEIVER_EXPORTED)
BLog.LOGE("onCreateView()") BLog.LOGE("onCreateView()")
mRssDataResult = WorkersDb.getRealm().query<RssData>().query("pubDate > $0",beforeDay(Date(),3)).sort("pubDate ", Sort.DESCENDING).find()
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().find() mRssDataResult = WorkersDb.getRealm().query<RssData>().query("pubDate > $0",beforeDay(Date(),3)).query("category != $0", RssDataType.GURU.name).sort("pubDate ", Sort.DESCENDING).find()
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
job = CoroutineScope(Dispatchers.Default).launch { job = CoroutineScope(Dispatchers.Default).launch {
mRssDataResult.asFlow().collect { changes: ResultsChange<RssData> -> mRssDataResult.asFlow().collect { changes: ResultsChange<RssData> ->
when (changes) { when (changes) {

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="false">
</base-config>
</network-security-config>