This commit is contained in:
lunaticbum 2024-09-06 18:13:00 +09:00
parent 1ca2b360d7
commit b963bbedaf
16 changed files with 538 additions and 241 deletions

View File

@ -52,7 +52,6 @@
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:networkSecurityConfig="@xml/network_security_config"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"

View File

@ -500,9 +500,9 @@ internal class LauncherActivity : AppCompatActivity() {
} }
} }
var callBack : (()->Unit)? = null var callBack : CommadCallabck? = null
var isF = false var isF = false
fun doWebParseStart(url : String, callBack : (()->Unit)?) { fun doWebParseStart(url : String, callBack :CommadCallabck?) {
isF = false isF = false
this.callBack = callBack this.callBack = callBack
binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE } binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE }
@ -573,7 +573,7 @@ internal class LauncherActivity : AppCompatActivity() {
// } // }
// } // }
} }
if (isF) this@LauncherActivity.callBack?.invoke() if (isF) this@LauncherActivity.callBack?.collectComplete()
// binding.searcher01.post { binding.searcher01.visibility = View.GONE } // binding.searcher01.post { binding.searcher01.visibility = View.GONE }
// } // }
} }
@ -640,7 +640,7 @@ internal class LauncherActivity : AppCompatActivity() {
} }
} }
}.apply { }.apply {
this@LauncherActivity.callBack?.invoke() this@LauncherActivity.callBack?.collectComplete()
WorkersDb.insertBulkInteface(temp) WorkersDb.insertBulkInteface(temp)
Toast.makeText(this@LauncherActivity, Toast.makeText(this@LauncherActivity,
"Stored rank data", Toast.LENGTH_LONG).show() "Stored rank data", Toast.LENGTH_LONG).show()
@ -666,12 +666,12 @@ internal class LauncherActivity : AppCompatActivity() {
}.apply { }.apply {
var itemC = 0 var itemC = 0
WorkersDb.insertBulkInteface(temp) WorkersDb.insertBulkInteface(temp)
// BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}") callBack?.onConsoleLog("Stored data :: ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}")
// Toast.makeText(this@LauncherActivity, // Toast.makeText(this@LauncherActivity,
// "Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}] \n set in ${itemC}", Toast.LENGTH_LONG).show() // "Stored data :: ${listItem.size} items :: [${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}] \n set in ${itemC}", Toast.LENGTH_LONG).show()
//// } //// }
binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) } binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) }
this@LauncherActivity.callBack?.invoke() this@LauncherActivity.callBack?.collectComplete()
} }
} }
@ -693,7 +693,7 @@ internal class LauncherActivity : AppCompatActivity() {
// Toast.makeText(this@LauncherActivity, // Toast.makeText(this@LauncherActivity,
// "Stored data :: ${listTags.size}tags", Toast.LENGTH_SHORT).show() // "Stored data :: ${listTags.size}tags", Toast.LENGTH_SHORT).show()
binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) } binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) }
this@LauncherActivity.callBack?.invoke() this@LauncherActivity.callBack?.collectComplete()
} }
} }
@ -745,6 +745,30 @@ internal class LauncherActivity : AppCompatActivity() {
// binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) } // binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) }
} }
} else if(lastedFinishedPageUrl?.contains("javmost")==true){
val doc: Document = Jsoup.parse(result)
callBack?.onConsoleLog("${lastedFinishedPageUrl} >>> ${doc.title()}")
doc.getElementsByClass("card").forEach { card ->
callBack?.onConsoleLog("${lastedFinishedPageUrl}_card >>> ${card}")
var model = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("src") else ""
var thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("alt") else ""
var title = ""
var date = ""
if(card.getElementsByClass("card-block").size > 0) if(card.getElementsByClass("card-block").size > 0) {
title = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("title")
date = card.getElementsByTag("span").get(0).text()
}
callBack?.onConsoleLog("" +
"model >>>>> ${model}\n" +
"thumb >>>>> ${thumb}\n" +
"title >>>>> ${title}\n" +
"date >>>>> ${date}" +
"")
}
} else {
val doc: Document = Jsoup.parse(result)
callBack?.onConsoleLog("lastedFinishedPageUrl >>> ${doc}")
} }
BLog.LOGE("binding.otherCheck after ThreadRun") BLog.LOGE("binding.otherCheck after ThreadRun")
} }
@ -791,4 +815,9 @@ fun beforeDay(date: Date): Long {
cal.add(Calendar.DAY_OF_YEAR, -2) cal.add(Calendar.DAY_OF_YEAR, -2)
cal.add(Calendar.HOUR, 8) cal.add(Calendar.HOUR, 8)
return cal.timeInMillis return cal.timeInMillis
}
interface CommadCallabck {
fun onConsoleLog(log : String)
fun collectComplete()
} }

View File

@ -31,6 +31,7 @@ internal class LunarLauncher : Application() {
} }
override fun onTrimMemory(level: Int) { override fun onTrimMemory(level: Int) {
super.onTrimMemory(level) super.onTrimMemory(level)
// Picasso.
if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) SQLiteDatabase.releaseMemory() if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) SQLiteDatabase.releaseMemory()
} }

View File

@ -394,7 +394,7 @@ internal class AppDrawer : Fragment() {
fun registCancelSearch() { fun registCancelSearch() {
BLog.LOGE("Called registCancelSearch") BLog.LOGE("Called registCancelSearch")
chechHandler.removeCallbacks(cancelSearch) chechHandler.removeCallbacks(cancelSearch)
chechHandler.postDelayed(cancelSearch, 3000L) chechHandler.postDelayed(cancelSearch, 8000L)
} }
fun clearCancelSearch() { fun clearCancelSearch() {

View File

@ -25,27 +25,40 @@ import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.net.Uri import android.net.Uri
import android.os.* import android.os.Bundle
import android.view.* import android.os.Handler
import android.os.Looper
import android.os.ResultReceiver
import android.text.method.ScrollingMovementMethod
import android.view.ContextMenu
import android.view.Gravity
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.LinearLayoutCompat.LayoutParams import androidx.appcompat.widget.LinearLayoutCompat.LayoutParams
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle import androidx.lifecycle.repeatOnLifecycle
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.PeriodicWorkRequestBuilder
import com.google.android.material.button.MaterialButtonToggleGroup import com.google.android.material.button.MaterialButtonToggleGroup
import com.squareup.okhttp.ConnectionPool import com.google.gson.Gson
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 io.realm.kotlin.query.Sort
import kotlinx.coroutines.* import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import org.jsoup.Jsoup import org.jsoup.Jsoup
import rasel.lunar.launcher.CommadCallabck
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost
import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
@ -63,22 +76,30 @@ 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.lastedFinishedPageUrl
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
import rasel.lunar.launcher.model.CiliMagnet
import rasel.lunar.launcher.model.MostItem
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.RssItem
import rasel.lunar.launcher.model.RssTagItem import rasel.lunar.launcher.model.RssTagItem
import rasel.lunar.launcher.model.dateFormat
import rasel.lunar.launcher.model.getRssData
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.RecentCallGetter
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.text.SimpleDateFormat
import java.util.Date
import java.util.concurrent.Executors import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
internal class Feeds : Fragment() { internal class Feeds : Fragment() , CommadCallabck {
private lateinit var binding: FeedsBinding private lateinit var binding: FeedsBinding
private val requestCodeString = "requestCode" private val requestCodeString = "requestCode"
@ -90,6 +111,7 @@ internal class Feeds : Fragment() {
mRssAdapter2 = RssAdapter(requireContext()) mRssAdapter2 = RssAdapter(requireContext())
binding.feedsRss.rss.adapter = mRssAdapter binding.feedsRss.rss.adapter = mRssAdapter
binding.feedsRss.rss2.adapter = mRssAdapter2 binding.feedsRss.rss2.adapter = mRssAdapter2
binding.consoleLog.movementMethod = ScrollingMovementMethod();
updateWidgets() updateWidgets()
return binding.root return binding.root
} }
@ -149,6 +171,18 @@ internal class Feeds : Fragment() {
} }
} }
} }
fun consoleLog(str : String) {
mMainHandler.removeCallbacks(hideConsole)
binding.consoleLog.post {
binding.consoleLog.visibility = View.VISIBLE
binding.consoleLog.text = str
}
mMainHandler.postDelayed(hideConsole,10000L)
BLog.LOGE("consoleLog >>>> ${str}")
}
fun openOpera(schemeString : String) { fun openOpera(schemeString : String) {
BLog.LOGE("openOpera ${schemeString}") BLog.LOGE("openOpera ${schemeString}")
val gmmIntentUri = Uri.parse(schemeString) val gmmIntentUri = Uri.parse(schemeString)
@ -158,15 +192,32 @@ internal class Feeds : Fragment() {
lActivity?.startActivity(mapIntent) lActivity?.startActivity(mapIntent)
} }
override fun onConsoleLog(log: String) {
consoleLog(log)
}
val mMainHandler = Handler(Looper.getMainLooper())
val hideConsole = {
binding.consoleLog.visibility = View.GONE
binding.consoleLog.text = ""
}
override fun collectComplete() {
}
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" 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() {
try {
System.gc()
}catch (e : Exception){e.printStackTrace()}
binding.feedsRss.rss.visibility = View.GONE binding.feedsRss.rss.visibility = View.GONE
binding.feedsRss.rss2.visibility = View.GONE binding.feedsRss.rss2.visibility = View.GONE
binding.feedsRss.loading.visibility = View.VISIBLE binding.feedsRss.loading.visibility = View.VISIBLE
binding.feedsRss.refresh.visibility = View.VISIBLE binding.feedsRss.refresh.visibility = View.VISIBLE
val builder: AlertDialog.Builder = AlertDialog.Builder(requireContext()) val builder: AlertDialog.Builder = AlertDialog.Builder(requireContext())
builder.setTitle("Title") builder.setTitle("Command Line")
val viewInflated: View = LayoutInflater.from(context) val viewInflated: View = LayoutInflater.from(context)
.inflate(R.layout.text_inpu_password, view as ViewGroup?, false) .inflate(R.layout.text_inpu_password, view as ViewGroup?, false)
val input = viewInflated.findViewById<View>(R.id.input) as EditText val input = viewInflated.findViewById<View>(R.id.input) as EditText
@ -177,45 +228,119 @@ 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]) {
//lActivity?.doWebParseStart("https://missav.com/dm16/en") {} "jf" -> {
"miss"-> lActivity?.doWebParseStart("https://missav.com/en/search/${input.text.toString().trim().split(" ")[1]}/") {} GlobalScope.launch { excuteGetterMostByUrl("https://javmost.to/search/movie/${cmd[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 {
///https://cili.site/!iAVJ var temp = arrayListOf<CiliMagnet>()
Jsoup.connect("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}").get().apply { consoleLog("this >>>> cili ${cmd[0]} -> ${cmd[1]}")
BLog.LOGE("this >>>> cili ${this}") Jsoup.connect("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}").get().let { cili ->
consoleLog("this >>>> cili ${cili.title()}")
cili.getElementsByTag("tr").forEach { cili_tr ->
CiliMagnet().let { ciliMgn ->
ciliMgn.link = if(cili_tr.getElementsByTag("a").size > 0)cili_tr.getElementsByTag("a").get(0).attr("href") else ""
ciliMgn.title = if(cili_tr.getElementsByTag("p").size > 0)cili_tr.getElementsByTag("p").text() else ""
ciliMgn.size = if(cili_tr.getElementsByClass("td-size").size > 0)cili_tr.getElementsByClass("td-size").text() else ""
if(ciliMgn.isValid() && temp.size < 8 ) {
Jsoup.connect(ciliMgn.getMagnetPageLink()).get().let { mgn_Page ->
consoleLog("magnet_page >>> ${mgn_Page.title()}")
if (mgn_Page.getElementsByClass("input-group magnet-box").size > 0) {
mgn_Page.getElementsByClass("input-group magnet-box")
.get(0)?.let { magnet_box ->
// BLog.LOGE("magnet_box >>> ${magnet_box}")
// if (magnet_box.getElementById("input-magnet").size > 0) {
magnet_box.getElementById(
"input-magnet"
)?.let { input_magnet ->
// BLog.LOGE("input_magnet >>> ${input_magnet}")
ciliMgn.magnetLink = input_magnet.attr("value").replace("&amp;","&")
}
}
}
}.apply {
temp.add(ciliMgn)
}
}
}
}.apply {
temp.forEach {
consoleLog("ciliResult >>> ${Gson().toJson(it)}")
}
}
} }
}.start() }.start()
} }
} }
binding.expandRss.isChecked = false
} else { } else {
when (input.text.toString()) { when (input.text.toString()) {
"ojs" -> home?.queryInfos(arrayListOf<RssDataType>().apply {
addAll(RssDataType.values())
remove(RssDataType.GURU)
remove(RssDataType.Most)
})
"onews" -> home?.queryInfos(arrayListOf<RssDataType>().apply {
addAll(RssDataType.values())
remove(RssDataType.NewsFeed)
})
"ored" -> home?.queryInfos(arrayListOf<RssDataType>().apply {
addAll(RssDataType.values())
remove(RssDataType.REDDIT)
})
"most" -> {
consoleLog("current j req() ${WorkersDb.getRealm()
.query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
val urls = arrayOf("https://javmost.to/latest-updates",
"https://javmost.to/latest-updates/page-2",
"https://javmost.to/latest-updates/page-3",
"https://javmost.to/latest-updates/page-4",
"https://javmost.to/latest-updates/page-5",
"https://javmost.to/latest-updates/page-6",
"https://javmost.to/latest-updates/page-7",
"https://javmost.to/latest-updates/page-8",
"https://javmost.to/latest-updates/page-9",
"https://javmost.to/latest-updates/page-10")
GlobalScope.launch {
urls.forEach { mostUrl ->
excuteGetterMostByUrl(mostUrl)
}
}.start()
}
"ytb" -> { "ytb" -> {
refreshYoutube() refreshYoutube()
consoleLog("excute refreshYoutube()")
} }
"reddit" -> { "reddit" -> {
refreshReddit() refreshReddit()
consoleLog("excute refreshReddit()")
} }
"fedd" -> { "fedd" -> {
refreshFeeds() refreshFeeds()
consoleLog("excute refreshFeeds()")
} }
"comic" -> { "comic" -> {
refreshComics() refreshComics()
consoleLog("excute refreshComics()")
} }
"taxi" -> { "taxi" -> {
consoleLog("before run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}")
home?.showAl() home?.showAl()
consoleLog("after run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}")
} }
"tax" -> { "tax" -> {
consoleLog("before run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}")
home?.hideAl() home?.hideAl()
consoleLog("after run State home?.binding?.alcholKatalkT?.isVisible >> ${home?.binding?.alcholKatalkT?.isVisible}")
} }
"jshow" -> { "jshow" -> {
@ -223,7 +348,7 @@ internal class Feeds : Fragment() {
rss.adapter = mRssAdapter rss.adapter = mRssAdapter
loading.visibility = View.VISIBLE loading.visibility = View.VISIBLE
mRssAdapter?.updateData(WorkersDb.getRealm() mRssAdapter?.updateData(WorkersDb.getRealm()
.query<RssData>("category == $0", RssDataType.GURU.name) .query<RssData>("category == $0 || category == $1", RssDataType.GURU.name, RssDataType.Most.name)
.sort("pubDate", Sort.DESCENDING).find()) .sort("pubDate", Sort.DESCENDING).find())
rss.visibility = View.VISIBLE rss.visibility = View.VISIBLE
loading.visibility = View.GONE loading.visibility = View.GONE
@ -232,59 +357,35 @@ internal class Feeds : Fragment() {
} }
"jjp" -> { "jjp" -> {
lActivity?.doWebParseStart("https://projectjav.com") {} // lActivity?.doWebParseStart("https://projectjav.com") {}
} }
"jmnew" -> { "jmnew" -> {
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") {} // lActivity?.doWebParseStart("https://missav.com/dm507/en/release") {}
} }
"jmiss" -> { "jmiss" -> {
lActivity?.doWebParseStart("https://missav.com/dm16/en") {} // lActivity?.doWebParseStart("https://missav.com/dm16/en") {}
} }
"jreq" -> { "jreq" -> {
lActivity?.doWebParseStart(jGuruMain) {} consoleLog("current j req() ${WorkersDb.getRealm()
.query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
lActivity?.doWebParseStart(jGuruMain,callBack = object : CommadCallabck {
override fun onConsoleLog(log: String) {
this@Feeds.consoleLog(log)
}
override fun collectComplete() {
consoleLog("excuted j req() ${WorkersDb.getRealm()
.query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
}
})
// {
// consoleLog("excuted j req() ${WorkersDb.getRealm()
// .query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
// }
} }
"jtag" -> { "jtag" -> {
// lActivity?.doWebPare(TEST_PAG.plus("tags")) { // lActivity?.doWebPare(TEST_PAG.plus("tags")) {
binding.feedsRss.apply { binding.feedsRss.apply {
rss2.adapter = mRssAdapter2 rss2.adapter = mRssAdapter2
@ -298,16 +399,22 @@ internal class Feeds : Fragment() {
refresh.visibility = View.VISIBLE refresh.visibility = View.VISIBLE
rss2.visibility = View.GONE rss2.visibility = View.GONE
refresh.setOnClickListener { refresh.setOnClickListener {
lActivity?.doWebParseStart(jGuruMain.plus("tags")) { lActivity?.doWebParseStart(jGuruMain.plus("tags"), callBack = object : CommadCallabck {
if (listTags.size > 0) { override fun onConsoleLog(log: String) {
rss2?.postDelayed({ this@Feeds.consoleLog(log)
mRssAdapter2?.updateData(listTags)
loading.visibility = View.GONE
refresh.visibility = View.GONE
rss2.visibility = View.VISIBLE
}, 500L)
} }
}
override fun collectComplete() {
if (listTags.size > 0) {
rss2?.postDelayed({
mRssAdapter2?.updateData(listTags)
loading.visibility = View.GONE
refresh.visibility = View.GONE
rss2.visibility = View.VISIBLE
}, 500L)
}
}
})
} }
} }
} }
@ -366,6 +473,53 @@ internal class Feeds : Fragment() {
} }
} }
var dmy = SimpleDateFormat("dd-MM-yyyy")
fun excuteGetterMostByUrl(mostUrl : String) {
Executors.newSingleThreadScheduledExecutor().schedule({
Jsoup.connect(mostUrl).userAgent(USAGT).get().let { doc ->
onConsoleLog("$lastedFinishedPageUrl >>> ${doc.title()}")
doc.getElementsByClass("card").forEach { card ->
onConsoleLog("${lastedFinishedPageUrl}_card >>> ${card}")
var thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("src") else ""
if (thumb.contains("No+Poster")) thumb = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("data-src") else thumb
var model = if(card.getElementsByTag("img").size > 0) card.getElementsByTag("img").get(0).attr("alt") else ""
var title = ""
var date = ""
var link = ""
if(card.getElementsByClass("card-block").size > 0) if(card.getElementsByClass("card-block").size > 0) {
link = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("href")
title = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("title")
date = card.getElementsByTag("span").get(0).text()
}
MostItem().let { ms ->
ms.model = model
ms.image = thumb
ms.pageLink = link
ms.title = title
try {
ms.date = dmy.parse(date).time
consoleLog("dateFormat.format(Date(ms.date)) ${dateFormat.format(Date(ms.date))}")
}catch (e : Exception) {e.printStackTrace()}
if (ms.isValid()) {
WorkersDb.insertData(ms.getRssData())
}
}
onConsoleLog("" +
"model >>>>> ${model}\n" +
"thumb >>>>> ${thumb}\n" +
"title >>>>> ${title}\n" +
"date >>>>> ${date}" +
"")
}
consoleLog("excuted j req() ${WorkersDb.getRealm()
.query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
}
}, 1500, TimeUnit.MILLISECONDS)
}
/* rss service's result receiver */ /* rss service's result receiver */
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private val resultReceiver: ResultReceiver = object : ResultReceiver(Handler(Looper.getMainLooper())) { private val resultReceiver: ResultReceiver = object : ResultReceiver(Handler(Looper.getMainLooper())) {
@ -443,39 +597,39 @@ internal class Feeds : Fragment() {
} }
private fun createWidget(appWidgetId: Int, height: Int?) { private fun createWidget(appWidgetId: Int, height: Int?) {
if (appWidgetId == -1) return // if (appWidgetId == -1) return
//
val appWidgetInfo = appWidgetManager!!.getAppWidgetInfo(appWidgetId) // val appWidgetInfo = appWidgetManager!!.getAppWidgetInfo(appWidgetId)
val params: LayoutParams? // val params: LayoutParams?
//
when (height) { // when (height) {
null -> { // null -> {
params = LayoutParams(LayoutParams.MATCH_PARENT, appWidgetInfo.minHeight) // params = ConstraintLayout.LayoutParams(LayoutParams.MATCH_PARENT, appWidgetInfo.minHeight)
val updatedIds = splitWidgetIds.plus("$appWidgetId") // val updatedIds = splitWidgetIds.plus("$appWidgetId")
val updatedHeights = splitWidgetHeights.plus("${appWidgetInfo.minHeight}") // val updatedHeights = splitWidgetHeights.plus("${appWidgetInfo.minHeight}")
saveWidgetData(updatedIds, updatedHeights) // saveWidgetData(updatedIds, updatedHeights)
} // }
else -> params = LayoutParams(LayoutParams.MATCH_PARENT, height) // else -> params = ConstraintLayout.LayoutParams(LayoutParams.MATCH_PARENT, height)
} // }
//
(appWidgetHost?.createView(lActivity!!.applicationContext, appWidgetId, appWidgetInfo) as WidgetHostView) // (appWidgetHost?.createView(lActivity!!.applicationContext, appWidgetId, appWidgetInfo) as WidgetHostView)
.apply { // .apply {
setAppWidget(appWidgetId, appWidgetInfo) // setAppWidget(appWidgetId, appWidgetInfo)
}.let { // }.let {
binding.widgetContainer.addView(it, params) // binding.widgetContainer.addView(it, params)
widgetMenu(it) // widgetMenu(it)
} // }
} }
private fun updateWidgets() { private fun updateWidgets() {
if (splitWidgetIds.size > 0) { // if (splitWidgetIds.size > 0) {
viewLifecycleOwner.lifecycleScope.launch { // viewLifecycleOwner.lifecycleScope.launch {
binding.widgetContainer.removeAllViews() // binding.widgetContainer.removeAllViews()
splitWidgetIds.indices.forEach { i: Int -> // splitWidgetIds.indices.forEach { i: Int ->
createWidget(splitWidgetIds[i]!!.int(), splitWidgetHeights[i]!!.int()) // createWidget(splitWidgetIds[i]!!.int(), splitWidgetHeights[i]!!.int())
} // }
} // }
} // }
} }
private fun widgetMenu(hostView: WidgetHostView) { private fun widgetMenu(hostView: WidgetHostView) {

View File

@ -32,6 +32,7 @@ import android.os.Looper
import android.provider.AlarmClock import android.provider.AlarmClock
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.View.OnScrollChangeListener
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.biometric.BiometricPrompt import androidx.biometric.BiometricPrompt
@ -39,11 +40,13 @@ import androidx.core.content.ContextCompat.RECEIVER_EXPORTED
import androidx.core.content.ContextCompat.registerReceiver import androidx.core.content.ContextCompat.registerReceiver
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LiveData
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import io.realm.kotlin.notifications.InitialResults
import io.realm.kotlin.notifications.ResultsChange import io.realm.kotlin.notifications.ResultsChange
import io.realm.kotlin.notifications.UpdatedResults import io.realm.kotlin.notifications.UpdatedResults
import io.realm.kotlin.query.RealmResults import io.realm.kotlin.query.RealmResults
@ -54,9 +57,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import org.jsoup.Jsoup
import rasel.lunar.launcher.LauncherActivity.Companion.CALL_WORK_TAG import rasel.lunar.launcher.LauncherActivity.Companion.CALL_WORK_TAG
import rasel.lunar.launcher.LauncherActivity.Companion.FEDDS_WORK_TAG
import rasel.lunar.launcher.LauncherActivity.Companion.SMS_WORK_TAG import rasel.lunar.launcher.LauncherActivity.Companion.SMS_WORK_TAG
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.LauncherActivity.Companion.refreshComics import rasel.lunar.launcher.LauncherActivity.Companion.refreshComics
@ -67,10 +68,7 @@ import rasel.lunar.launcher.LauncherActivity.Companion.workmanager
import rasel.lunar.launcher.R import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.LauncherHomeBinding import rasel.lunar.launcher.databinding.LauncherHomeBinding
import rasel.lunar.launcher.helpers.Constants.Companion.BOTTOM_SHEET_TAG import rasel.lunar.launcher.helpers.Constants.Companion.BOTTOM_SHEET_TAG
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_DATE_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_DATE_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TIME_FORMAT
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK import rasel.lunar.launcher.helpers.Constants.Companion.KEY_TODO_LOCK
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
import rasel.lunar.launcher.helpers.UniUtils.Companion.biometricPromptInfo import rasel.lunar.launcher.helpers.UniUtils.Companion.biometricPromptInfo
@ -91,8 +89,6 @@ import rasel.lunar.launcher.todos.SmsLogsAdapter
import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.SimpleFingerGestures import rasel.lunar.launcher.utils.SimpleFingerGestures
import rasel.lunar.launcher.utils.beforeDay import rasel.lunar.launcher.utils.beforeDay
import rasel.lunar.launcher.workers.ArcaGetter
import rasel.lunar.launcher.workers.DCGetter
import rasel.lunar.launcher.workers.RecentCall import rasel.lunar.launcher.workers.RecentCall
import rasel.lunar.launcher.workers.RecentSms import rasel.lunar.launcher.workers.RecentSms
import rasel.lunar.launcher.workers.WorkersDb import rasel.lunar.launcher.workers.WorkersDb
@ -100,13 +96,11 @@ import java.net.URLEncoder
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar import java.util.Calendar
import java.util.Date import java.util.Date
import java.util.Locale
import kotlin.properties.Delegates
internal class LauncherHome : Fragment() { internal class LauncherHome : Fragment() {
private lateinit var binding: LauncherHomeBinding lateinit var binding: LauncherHomeBinding
private lateinit var fragManager: FragmentManager private lateinit var fragManager: FragmentManager
private lateinit var settingsPrefs: SharedPreferences private lateinit var settingsPrefs: SharedPreferences
private lateinit var batteryReceiver: BatteryReceiver private lateinit var batteryReceiver: BatteryReceiver
@ -121,13 +115,13 @@ internal class LauncherHome : Fragment() {
var listTags = arrayListOf<RssDataInterface>() var listTags = arrayListOf<RssDataInterface>()
} }
private var nReceiver: NotificationReceiver? = null // private var nReceiver: NotificationReceiver? = null
//
class NotificationReceiver : BroadcastReceiver() { // class NotificationReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent) { // override fun onReceive(context: Context?, intent: Intent) {
BLog.LOGE("NotificationReceiver >>>> ${intent.extras?.keySet()}") // BLog.LOGE("NotificationReceiver >>>> ${intent.extras?.keySet()}")
} // }
} // }
val UPDATE_DELAY = 1000L val UPDATE_DELAY = 1000L
val commandHandler = Handler(Looper.getMainLooper()) val commandHandler = Handler(Looper.getMainLooper())
@ -160,9 +154,13 @@ internal class LauncherHome : Fragment() {
var lasted : RealmResults<RssData>? = null var lasted : RealmResults<RssData>? = null
var lastedNoti : RealmResults<NotificationItem>? = null var lastedNoti : RealmResults<NotificationItem>? = null
override fun onCreate(savedInstanceState: Bundle?) {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { super.onCreate(savedInstanceState)
home = this home = this
BLog.LOGE("${this} ::::: onCreate >>>> ")
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
BLog.LOGE("${this} ::::: onCreateView >>>> ")
binding = LauncherHomeBinding.inflate(inflater, container, false) binding = LauncherHomeBinding.inflate(inflater, container, false)
fragManager = lActivity!!.supportFragmentManager fragManager = lActivity!!.supportFragmentManager
settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0) settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0)
@ -180,8 +178,6 @@ internal class LauncherHome : Fragment() {
binding.smsList.visibility = View.GONE binding.smsList.visibility = View.GONE
binding.infoList.visibility = View.GONE binding.infoList.visibility = View.GONE
// binding.favAppsGroup.visibility = View.GONE
binding.notiList.layoutManager = LinearLayoutManager(requireContext()) binding.notiList.layoutManager = LinearLayoutManager(requireContext())
binding.mainList.layoutManager = LinearLayoutManager(requireContext()) binding.mainList.layoutManager = LinearLayoutManager(requireContext())
binding.smsList.layoutManager = GridLayoutManager(requireContext(),2) binding.smsList.layoutManager = GridLayoutManager(requireContext(),2)
@ -192,6 +188,14 @@ internal class LauncherHome : Fragment() {
binding.infoList.adapter = mRssAdapter binding.infoList.adapter = mRssAdapter
binding.notiList.adapter = mNotiAdapter binding.notiList.adapter = mNotiAdapter
try{binding.mainList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()}
binding.mainList.addOnScrollListener(onScrChanged)
try{binding.smsList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()}
binding.smsList.addOnScrollListener(onScrChanged)
try{binding.infoList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()}
binding.infoList.addOnScrollListener(onScrChanged)
try{binding.notiList.removeOnScrollListener(onScrChanged)}catch (e : Exception){e.printStackTrace()}
binding.notiList.addOnScrollListener(onScrChanged)
workmanager()?.getWorkInfosByTagLiveData(SMS_WORK_TAG)?.observeForever { workmanager()?.getWorkInfosByTagLiveData(SMS_WORK_TAG)?.observeForever {
commandHandler.removeCallbacks(smsUpdate) commandHandler.removeCallbacks(smsUpdate)
@ -205,75 +209,63 @@ internal class LauncherHome : Fragment() {
it.clear() it.clear()
} }
workmanager()?.getWorkInfosByTagLiveData(FEDDS_WORK_TAG)?.observeForever { // nReceiver = NotificationReceiver()
commandHandler.removeCallbacks(infoUpdate) // val filter = IntentFilter()
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY) // registerReceiver(requireContext(),nReceiver, filter,RECEIVER_EXPORTED)
it.clear()
}
workmanager()?.getWorkInfosByTagLiveData(FEDDS_WORK_TAG)?.observeForever {
commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear()
}
workmanager()?.getWorkInfosByTagLiveData(ArcaGetter.TAG)?.observeForever {
commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear()
}
workmanager()?.getWorkInfosByTagLiveData(DCGetter.TAG)?.observeForever {
commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate,UPDATE_DELAY)
it.clear()
}
nReceiver = NotificationReceiver()
val filter = IntentFilter()
// filter.addAction("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE")
registerReceiver(requireContext(),nReceiver, filter,RECEIVER_EXPORTED)
BLog.LOGE("onCreateView()") BLog.LOGE("onCreateView()")
mRssDataResult = WorkersDb.getRealm().query<RssData>().query("pubDate > $0",beforeDay(Date(),3)).query("category != $0", RssDataType.GURU.name).sort("pubDate ", Sort.DESCENDING).find() queryInfos()
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find() queryNotice()
job = CoroutineScope(Dispatchers.Default).launch { return binding.root
mRssDataResult.asFlow().collect { changes: ResultsChange<RssData> -> }
when (changes) {
// UpdatedResults means this change represents an update/insert/delete operation val hideListView = {
is UpdatedResults -> { // binding.notiList.visibility = View.GONE
if (mRssAdapter.itemCount != changes.list.size) { // binding.mainList.visibility = View.GONE
// BLog.LOGE("ResultsChange") // binding.infoList.visibility = View.GONE
lasted = changes.list // binding.smsList.visibility = View.GONE
commandHandler.removeCallbacks(infoUpdate) }
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
}
WorkersDb.getRealm().apply { write { val onScrChanged = object : RecyclerView.OnScrollListener() {
delete(query<RssData>().query("pubDate < $0",beforeDay(Date(),3)).find()) override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
}} super.onScrollStateChanged(recyclerView, newState)
} when (newState) {
else -> { RecyclerView.SCROLL_STATE_IDLE -> {
// types other than UpdatedResults are not changes -- ignore them commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5)
} }
RecyclerView.SCROLL_STATE_DRAGGING -> {
}
RecyclerView.SCROLL_STATE_SETTLING -> {
} }
} }
commandHandler.removeCallbacks(hideListView)
} }
job.start()
CoroutineScope(Dispatchers.Default).launch { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
mNotificationResult.asFlow().collect { changes: ResultsChange<NotificationItem> -> super.onScrolled(recyclerView, dx, dy)
commandHandler.removeCallbacks(hideListView)
}
}
private fun queryNotice() {
try { noticeJob?.cancel() } catch (e:Exception) {e.printStackTrace()}
mNotificationResult = null
try {
System.gc()
}catch (e : Exception){e.printStackTrace()}
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
noticeJob = CoroutineScope(Dispatchers.Default).launch {
mNotificationResult?.asFlow()?.collect { changes: ResultsChange<NotificationItem> ->
BLog.LOGE("changes >>> ${changes}") BLog.LOGE("changes >>> ${changes}")
when (changes) { when (changes) {
// UpdatedResults means this change represents an update/insert/delete operation
is UpdatedResults -> { is UpdatedResults -> {
// if (lasted?.size != changes.list.size) {
BLog.LOGE("ResultsChange onNotificationPosted") BLog.LOGE("ResultsChange onNotificationPosted")
lastedNoti = changes.list lastedNoti = changes.list
commandHandler.removeCallbacks(infoUpdate) commandHandler.removeCallbacks(infoUpdate)
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
// }
// WorkersDb.getRealm().apply { write {
// delete(query<NotificationItem>().query("pubDate < $0",beforeDay(Date(),3)).find())
// }}
} }
else -> { else -> {
@ -281,23 +273,73 @@ internal class LauncherHome : Fragment() {
} }
} }
} }
}.start() }
mNotiAdapter?.updateData(mNotificationResult) mNotificationResult?.let { mNotiAdapter?.updateData(it) }
mRssAdapter?.updateData(mRssDataResult)
return binding.root noticeJob.start()
} }
lateinit var job : Job
fun queryInfos(filter: Collection<RssDataType>? = arrayListOf(RssDataType.GURU,RssDataType.Most)) {
BLog.LOGE("${this} ::::: queryInfos >>>> ${filter}")
try { infosJob?.cancel() } catch (e:Exception) {e.printStackTrace()}
mRssDataResult = null
try {
System.gc()
}catch (e : Exception){e.printStackTrace()}
WorkersDb.getRealm().apply { writeBlocking {
delete(query<RssData>().query("pubDate < $0",beforeDay(Date(),3)).query("category != $0 || category != $1 ", RssDataType.GURU.name,RssDataType.Most.name).find())
}}
BLog.LOGE("${this} ::::: queryInfos after delete >>>> ")
var rQ = WorkersDb.getRealm().query<RssData>().sort("pubDate ", Sort.DESCENDING).query("pubDate > $0",beforeDay(Date(),3))
filter!!.forEach {
rQ = rQ.query("category != $0", it.name)
}
mRssDataResult = rQ.limit(1000).find()
BLog.LOGE("${this} ::::: queryInfos after query find >>>> ")
infosJob = CoroutineScope(Dispatchers.Default).launch {
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
commandHandler.removeCallbacks(infoUpdate)
when (changes) {
is InitialResults -> {
BLog.LOGE("${this} ::::: queryInfos after changes size >>>> ${changes.list.size}")
lasted = changes.list
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3)
}
is UpdatedResults -> {
// lasted = changes.list
// commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3)
}
else -> {
}
}
}
}
mRssDataResult?.let {
BLog.LOGE("${this} ::::: queryInfos updateData >>>> ")
// lasted = it
// commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3)
mRssAdapter.updateData(it)
}
infosJob.start()
}
lateinit var infosJob : Job
lateinit var noticeJob : Job
lateinit var mMissedCallsAdapter : MissedCallsAdapter lateinit var mMissedCallsAdapter : MissedCallsAdapter
lateinit var mSmsLogsAdapter : SmsLogsAdapter lateinit var mSmsLogsAdapter : SmsLogsAdapter
lateinit var mRssAdapter : RssItemAdapter lateinit var mRssAdapter : RssItemAdapter
lateinit var mNotiAdapter : NotificationItemAdapter lateinit var mNotiAdapter : NotificationItemAdapter
lateinit var mRssDataResult : RealmResults<RssData> var mRssDataResult : RealmResults<RssData>? = null
lateinit var mNotificationResult : RealmResults<NotificationItem> var mNotificationResult : RealmResults<NotificationItem>? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
/* handle gesture events */
BLog.LOGE("${this} ::::: onViewCreated >>>> ")
rootViewGestures() rootViewGestures()
batteryProgressGestures() batteryProgressGestures()
todosGestures() todosGestures()
@ -315,9 +357,6 @@ internal class LauncherHome : Fragment() {
false false
} }
} }
binding.mainList.setHasFixedSize(true)
binding.mainList.setItemViewCacheSize(10)
var checkListner = object : View.OnClickListener { var checkListner = object : View.OnClickListener {
@ -357,6 +396,7 @@ internal class LauncherHome : Fragment() {
} else { } else {
binding.otherCheck.isSelected = true binding.otherCheck.isSelected = true
views.remove(binding.infoList) views.remove(binding.infoList)
binding.infoList.scrollToPosition(0)
binding.infoList.visibility = View.VISIBLE binding.infoList.visibility = View.VISIBLE
} }
} }
@ -372,7 +412,6 @@ internal class LauncherHome : Fragment() {
} }
chechboxs.forEach { it.isSelected = false } chechboxs.forEach { it.isSelected = false }
views.forEach { it.visibility = View.GONE } views.forEach { it.visibility = View.GONE }
chooseAdpater() chooseAdpater()
} }
} }
@ -383,6 +422,7 @@ internal class LauncherHome : Fragment() {
binding.notice.setOnClickListener(checkListner) binding.notice.setOnClickListener(checkListner)
binding.otherCheck.setOnLongClickListener { binding.otherCheck.setOnLongClickListener {
queryInfos()
refreshYoutube() refreshYoutube()
refreshComics() refreshComics()
refreshFeeds() refreshFeeds()
@ -416,10 +456,11 @@ internal class LauncherHome : Fragment() {
} }
fun chooseAdpater () { fun chooseAdpater () {
binding.mainList.visibility = View.GONE commandHandler.removeCallbacks(hideListView)
binding.smsList.visibility = View.GONE binding.mainList.visibility = View.INVISIBLE
binding.infoList.visibility = View.GONE binding.smsList.visibility = View.INVISIBLE
binding.notiList.visibility = View.GONE binding.infoList.visibility = View.INVISIBLE
binding.notiList.visibility = View.INVISIBLE
if (binding.missedCalls.isSelected) { if (binding.missedCalls.isSelected) {
if (recentCalls.size > 0 && isAdded && isResumed && isVisible) { if (recentCalls.size > 0 && isAdded && isResumed && isVisible) {
try { try {
@ -462,11 +503,9 @@ internal class LauncherHome : Fragment() {
binding.recentSms.isSelected = false binding.recentSms.isSelected = false
binding.notice.isSelected = false binding.notice.isSelected = false
binding.infoList.visibility = View.VISIBLE binding.infoList.visibility = View.VISIBLE
if (lasted?.size ?: 0 > 0) { binding.otherCheck.text = "최근 정보[${lasted?.size ?: "-"}]"
binding.otherCheck.text = "최근 정보[${lasted!!.size}]" lasted?.let { mRssAdapter.updateData(it) }
mRssAdapter.updateData(lasted!!)
// binding.infoList.smoothScrollToPosition(0)
}
} }
} }
else if(binding.notice.isSelected) { else if(binding.notice.isSelected) {
@ -475,18 +514,16 @@ internal class LauncherHome : Fragment() {
binding.recentSms.isSelected = false binding.recentSms.isSelected = false
binding.otherCheck.isSelected = false binding.otherCheck.isSelected = false
binding.notiList.visibility = View.VISIBLE binding.notiList.visibility = View.VISIBLE
if (lastedNoti?.size ?: 0 > 0) { binding.notice.text = "알림 센터[${lastedNoti?.size ?: "-"}]"
binding.otherCheck.text = "알림 센터[${lastedNoti!!.size}]" lastedNoti?.let { mNotiAdapter.updateData(it) }
mNotiAdapter.updateData(lastedNoti!!)
// binding.notiList.smoothScrollToPosition(0)
}
} }
} }
commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5)
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
BLog.LOGE("onResume()") BLog.LOGE("${this} ::::: onResume >>>> ")
BLog.LOGE(SimpleDateFormat("yyyy년 M월 W주차, dd일 E요일").format(Date()))
if (shouldResume) { if (shouldResume) {
/* register battery changes */ /* register battery changes */
@ -502,7 +539,7 @@ internal class LauncherHome : Fragment() {
// binding.date.format12Hour = dateFormat // binding.date.format12Hour = dateFormat
// } // }
/* show weather */ /* show weather */
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather) // WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
} }
} }

View File

@ -0,0 +1,13 @@
package rasel.lunar.launcher.model
class CiliMagnet {
var link : String? = null
var title : String? = null
var size : String? = null
var magnetLink : String? = null
fun isValid() = (((link?.length ?: 0) > 0 && (title?.length ?: 0) > 0 && (size?.length
?: 0) > 0))
fun getMagnetPageLink() = "https://cili.site".plus(link)
}

View File

@ -5,6 +5,7 @@ enum class RssDataType {
YOUTUBE, YOUTUBE,
NewsFeed, NewsFeed,
GURU, GURU,
Most,
TAGS, TAGS,
REDDIT, REDDIT,
Dotax, Dotax,

View File

@ -1,6 +1,6 @@
package rasel.lunar.launcher.model package rasel.lunar.launcher.model
class RssItem : RssDataInterface { open class RssItem : RssDataInterface {
var model : String = "" var model : String = ""
var title : String = "" var title : String = ""
var pageLink : String = "" var pageLink : String = ""
@ -24,6 +24,8 @@ class RssItem : RssDataInterface {
this.date = date this.date = date
} }
constructor()
override fun title(): String { override fun title(): String {
return title return title
} }
@ -37,7 +39,7 @@ class RssItem : RssDataInterface {
} }
override fun description(): String { override fun description(): String {
return tags.plus(model) return tags.plus(", ").plus(model).plus(", ").plus(category())
} }
override fun pubDate(): Long { override fun pubDate(): Long {
@ -47,4 +49,37 @@ class RssItem : RssDataInterface {
override fun category(): RssDataType { override fun category(): RssDataType {
return RssDataType.GURU return RssDataType.GURU
} }
}
fun isValid() = (((pageLink.length ?:0) > 0) && ((title.length ?:0) > 0)&& ((image.length ?:0) > 0))
}
class MostItem : RssItem , RssDataInterface {
constructor() : super()
override fun title(): String {
return title
}
override fun thumbnailUrl(): String {
return image
}
override fun originPage(): String {
return pageLink
}
override fun description(): String {
return tags.plus(", ").plus(model).plus(", ").plus(category())
}
override fun pubDate(): Long {
return date
}
override fun category(): RssDataType {
return RssDataType.Most
}
}

View File

@ -25,7 +25,9 @@ import android.content.pm.PackageManager
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
@ -55,6 +57,9 @@ internal class NotificationItemAdapter (
override fun onBindViewHolder(holder: NotiHolder, position: Int) { override fun onBindViewHolder(holder: NotiHolder, position: Int) {
val todo = notiItems[position] val todo = notiItems[position]
try { try {
holder.view.circlePreview.visibility = View.VISIBLE
var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
val d: Drawable = context.packageManager.getApplicationIcon(todo.pkgName!!) val d: Drawable = context.packageManager.getApplicationIcon(todo.pkgName!!)
holder.view.circlePreview.setImageDrawable(d) holder.view.circlePreview.setImageDrawable(d)
holder.view.title.text = todo.tikerMsg holder.view.title.text = todo.tikerMsg

View File

@ -58,9 +58,8 @@ internal class RssItemAdapter (
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: RssTag, position: Int) { override fun onBindViewHolder(holder: RssTag, position: Int) {
val todo = rssDataItemLis[position] val todo = rssDataItemLis[position]
Picasso.get().cancelRequest(holder.view.circlePreview)
holder.view.date.text = "${dateFormat.format(Date(todo.pubDate()))}" holder.view.date.text = dateFormat.format(Date(todo.pubDate()))
// holder.view.desc.visibility = View.GONE
holder.view.date.setOnClickListener { } holder.view.date.setOnClickListener { }
when(todo.category()) { when(todo.category()) {
RssDataType.YOUTUBE -> { RssDataType.YOUTUBE -> {
@ -68,14 +67,14 @@ internal class RssItemAdapter (
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview) Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
} }
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,280) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,param.height)
holder.view.title.text = "${todo.title()}" holder.view.title.text = "${todo.title()}"
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
holder.view.desc.visibility = View.VISIBLE holder.view.desc.visibility = View.VISIBLE
holder.view.desc.text = if(todo.description().contains("게시자")) todo.description().split("게시자")[0] else todo.description() holder.view.desc.text = if(todo.description().contains("게시자")) todo.description().split("게시자")[0] else todo.description()
// holder.view.root.setOnClickListener { openYouTube(todo.originPage()) }
holder.view.root.setOnClickListener { holder.view.root.setOnClickListener {
} }
@ -111,29 +110,35 @@ internal class RssItemAdapter (
holder.view.date.text = dateFormat.format(Date(todo.pubDate())) holder.view.date.text = dateFormat.format(Date(todo.pubDate()))
} }
if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU)) { if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU) || todo.category().equals(RssDataType.Most)) {
holder.view.circlePreview.visibility = View.GONE holder.view.circlePreview.visibility = View.GONE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,360) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,param.height)
} else if( todo.category().equals(RssDataType.Dotax)) { } else if( todo.category().equals(RssDataType.Dotax)) {
holder.view.circlePreview.setImageResource(R.drawable.daum) holder.view.circlePreview.setImageResource(R.drawable.daum)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
} else if( todo.category().equals(RssDataType.REDDIT)) { } else if( todo.category().equals(RssDataType.REDDIT)) {
holder.view.circlePreview.setImageResource(R.drawable.reddit) holder.view.circlePreview.setImageResource(R.drawable.reddit)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
} else if( todo.category().equals(RssDataType.FmKorae) ) { } else if( todo.category().equals(RssDataType.FmKorae) ) {
holder.view.circlePreview.setImageResource(R.drawable.fmk) holder.view.circlePreview.setImageResource(R.drawable.fmk)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
} else if(todo.category().equals(RssDataType.DcInside)) { } else if(todo.category().equals(RssDataType.DcInside)) {
holder.view.circlePreview.setImageResource(R.drawable.dcinside) holder.view.circlePreview.setImageResource(R.drawable.dcinside)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
} else if(todo.category().equals(RssDataType.Arca)) { } else if(todo.category().equals(RssDataType.Arca)) {
holder.view.circlePreview.setImageResource(R.drawable.arca) holder.view.circlePreview.setImageResource(R.drawable.arca)
holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.visibility = View.VISIBLE
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) var param = holder.view.circlePreview.layoutParams
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
} }

View File

@ -30,7 +30,7 @@ object WorkersDb {
fun insertData(rssData: RssData) { fun insertData(rssData: RssData) {
getRealm().apply { getRealm().apply {
this.writeBlocking { this.writeBlocking {
this.copyToRealm(rssData) this.copyToRealm(rssData, UpdatePolicy.ALL)
} }
} }
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -7,6 +7,7 @@
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.button.MaterialButtonToggleGroup <com.google.android.material.button.MaterialButtonToggleGroup
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/expandableButtons" android:id="@+id/expandableButtons"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -31,7 +32,15 @@
/> />
</com.google.android.material.button.MaterialButtonToggleGroup> </com.google.android.material.button.MaterialButtonToggleGroup>
<TextView
app:layout_constraintTop_toBottomOf="@id/expandableButtons"
android:id="@+id/consoleLog"
android:maxHeight="300dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RelativeLayout <RelativeLayout
app:layout_constraintTop_toBottomOf="@id/consoleLog"
android:id="@+id/explayer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp"> android:layout_margin="10dp">
@ -50,10 +59,12 @@
</RelativeLayout> </RelativeLayout>
<ScrollView <ScrollView
app:layout_constraintTop_toBottomOf="@id/explayer"
android:layout_margin="10dp" android:layout_margin="10dp"
android:background="@drawable/base_bg" android:background="@drawable/base_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
android:fillViewport="true" android:fillViewport="true"
android:scrollbars="none"> android:scrollbars="none">
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
@ -63,4 +74,4 @@
android:orientation="vertical"/> android:orientation="vertical"/>
</ScrollView> </ScrollView>
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,19 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="5dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<!--rasel.lunar.launcher.view.CircleImageView-->
<ImageView <com.google.android.material.imageview.ShapeableImageView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@id/title"
app:shapeAppearanceOverlay="@style/roundedImageView"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="@id/date"
android:id="@+id/circle_preview" android:id="@+id/circle_preview"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:layout_width="120dp" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="0dp"/>
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"

View File

@ -7,7 +7,7 @@
android:id="@+id/colorInputLayout" android:id="@+id/colorInputLayout"
android:layout_width="@dimen/oneNinetySix" android:layout_width="@dimen/oneNinetySix"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/argb" android:hint="inpout text"
app:boxBackgroundColor="?attr/colorSurface" app:boxBackgroundColor="?attr/colorSurface"
app:endIconMode="clear_text" app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@ -23,5 +23,4 @@
android:inputType="textPassword" /> android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -15,4 +15,9 @@
<item name="sliderStyle">@style/Slider</item> <item name="sliderStyle">@style/Slider</item>
<item name="scrimBackground">@color/almost_transparent</item> <item name="scrimBackground">@color/almost_transparent</item>
</style> </style>
<style name="roundedImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">8dp</item>
</style>
</resources> </resources>