...
This commit is contained in:
parent
f53ac1b089
commit
96b26b8c37
@ -33,7 +33,6 @@ import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.location.Location
|
||||
import android.net.Uri
|
||||
import android.net.http.SslError
|
||||
import android.os.Build
|
||||
@ -91,6 +90,7 @@ import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_FIRST_LAUNCH
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.widgetHostId
|
||||
import rasel.lunar.launcher.helpers.PrefHelper
|
||||
import rasel.lunar.launcher.helpers.ViewPagerAdapter
|
||||
import rasel.lunar.launcher.home.LauncherHome
|
||||
import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
|
||||
@ -113,17 +113,23 @@ import rasel.lunar.launcher.workers.ClienGetter
|
||||
import rasel.lunar.launcher.workers.ContactInfoGetter
|
||||
import rasel.lunar.launcher.workers.DCGetter
|
||||
import rasel.lunar.launcher.workers.DotaxGetter
|
||||
import rasel.lunar.launcher.workers.DotaxGetter.Companion.COMIC2_WORK_TAG
|
||||
import rasel.lunar.launcher.workers.FmKoreaGetter
|
||||
import rasel.lunar.launcher.workers.FmKoreaGetter.Companion.COMIC_WORK_TAG
|
||||
import rasel.lunar.launcher.workers.LocationGetter
|
||||
import rasel.lunar.launcher.workers.NewsFeedsGetter
|
||||
import rasel.lunar.launcher.workers.NewsFeedsGetter.Companion.FEDDS_WORK_TAG
|
||||
import rasel.lunar.launcher.workers.OpenWeatherGetter
|
||||
import rasel.lunar.launcher.workers.RecentCallGetter
|
||||
import rasel.lunar.launcher.workers.RecentSmsGetter
|
||||
import rasel.lunar.launcher.workers.RecentSmsGetter.Companion.SMS_WORK_TAG
|
||||
import rasel.lunar.launcher.workers.RedditGetter
|
||||
import rasel.lunar.launcher.workers.RedditGetter.Companion.REDDIT_WORK_TAG
|
||||
import rasel.lunar.launcher.workers.RuliWebGetter
|
||||
import rasel.lunar.launcher.workers.TheQooGetter
|
||||
import rasel.lunar.launcher.workers.WorkersDb
|
||||
import rasel.lunar.launcher.workers.YoutubeGetter
|
||||
import rasel.lunar.launcher.workers.YoutubeGetter.Companion.YT_WORK_TAG
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
@ -142,18 +148,8 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
lateinit var viewPager: ViewPager2
|
||||
|
||||
companion object {
|
||||
|
||||
private var mWorkManager: WorkManager? = null
|
||||
val SMS_WORK_TAG = "RecentSmsGetter"
|
||||
val CALL_WORK_TAG = "MissedCallGetter"
|
||||
val FEDDS_WORK_TAG = "NewsFeedsGetter"
|
||||
val YT_WORK_TAG = "YoutubeGetter"
|
||||
val COMIC_WORK_TAG = "ComicGetter"
|
||||
val COMIC2_WORK_TAG = "ComicGetter2"
|
||||
val REDDIT_WORK_TAG = "RedditGetter"
|
||||
val shortTimePeriod = 20L
|
||||
val longTimePeriod = 60L
|
||||
val midTimePeriod = 30L
|
||||
|
||||
var isOpendFold = false
|
||||
val qDayPeriod = 60L * 8L
|
||||
|
||||
@ -167,7 +163,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
SMS_WORK_TAG,
|
||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<RecentSmsGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<RecentSmsGetter>(PrefHelper.longTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(SMS_WORK_TAG)
|
||||
.build())
|
||||
}, 500, TimeUnit.MILLISECONDS)
|
||||
@ -176,7 +172,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
RecentCallGetter.TAG,
|
||||
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<RecentCallGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<RecentCallGetter>(PrefHelper.longTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(RecentCallGetter.TAG)
|
||||
.build())
|
||||
}, 500, TimeUnit.MILLISECONDS)
|
||||
@ -205,10 +201,10 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}, 5, TimeUnit.SECONDS)
|
||||
|
||||
}
|
||||
fun doGetWheaterByLocationInfo() {
|
||||
fun runWeatherGetter() {
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.enqueue(OneTimeWorkRequest.from(OpenWeatherGetter::class.java))
|
||||
}, 5, TimeUnit.SECONDS)
|
||||
}, 200L, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
|
||||
fun getCal() {
|
||||
@ -223,7 +219,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
FEDDS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<NewsFeedsGetter>(shortTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<NewsFeedsGetter>(PrefHelper.shortTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(FEDDS_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -232,7 +228,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
YT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<YoutubeGetter>(longTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<YoutubeGetter>(PrefHelper.longTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(YT_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -241,7 +237,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
REDDIT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<RedditGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<RedditGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(REDDIT_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -250,7 +246,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<FmKoreaGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<FmKoreaGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(COMIC_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -259,7 +255,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<DotaxGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<DotaxGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(COMIC2_WORK_TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -268,7 +264,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
ClienGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<ClienGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<ClienGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(ClienGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -277,7 +273,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(DCGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
DCGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<DCGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<DCGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(DCGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -286,7 +282,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
RuliWebGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<RuliWebGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<RuliWebGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(RuliWebGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -295,7 +291,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
TheQooGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<TheQooGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<TheQooGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(TheQooGetter.TAG)
|
||||
.build())
|
||||
}, delay, TimeUnit.SECONDS)
|
||||
@ -304,7 +300,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(ArcaGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
ArcaGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<ArcaGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<ArcaGetter>(PrefHelper.midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(ArcaGetter.TAG)
|
||||
.build())
|
||||
|
||||
@ -316,7 +312,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
mWorkManager?.cancelAllWorkByTag(LocationGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
LocationGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<LocationGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
PeriodicWorkRequestBuilder<LocationGetter>(PrefHelper.shortTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(LocationGetter.TAG)
|
||||
.build())
|
||||
}, weatherDelay, TimeUnit.SECONDS)
|
||||
@ -369,7 +365,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
// }
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressLint("NewApi", "MissingPermission")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
mWorkManager = WorkManager.getInstance(this)
|
||||
@ -627,137 +623,136 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
startActivity(mapIntent)
|
||||
}
|
||||
|
||||
fun doWebSavor(url : String, callBack :CommadCallabck?) {
|
||||
if (true)return
|
||||
this.callBack = callBack
|
||||
|
||||
binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE }
|
||||
BLog.LOGE("binding.otherCheck before ThreadRun")
|
||||
binding.searcher01.bringToFront()
|
||||
binding.searcher01.alpha = 1f
|
||||
binding.searcher01.webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||
if (url?.contains("missav") == true && isF) {
|
||||
BLog.LOGE("binding.otherCheck before reload")
|
||||
view?.loadUrl(url!!)
|
||||
isF = true
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||
BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}")
|
||||
super.onPageStarted(view, url, favicon)
|
||||
}
|
||||
override fun onReceivedError(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?,
|
||||
error: WebResourceError?
|
||||
) {
|
||||
|
||||
}
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
handler?.proceed()
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
autoScrollDown(view,url)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
WebView.setWebContentsDebuggingEnabled(false)
|
||||
binding.searcher01.apply {
|
||||
setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정
|
||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결
|
||||
try {
|
||||
settings.apply {
|
||||
userAgentString = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
|
||||
javaScriptEnabled = true // 자바스크립트 사용 가능하도록 설정
|
||||
loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드
|
||||
useWideViewPort = true // 화면에 맞게 페이지 확대/축소
|
||||
domStorageEnabled = true // DOM 저장소 사용 가능하도록 설정
|
||||
setSupportMultipleWindows(true)
|
||||
javaScriptCanOpenWindowsAutomatically = true // 팝업창 차단 해제
|
||||
cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
|
||||
textZoom = 100 // system 에 의한 글꼴 변형 방지
|
||||
defaultTextEncodingName = "UTF-8" // 인코딩 설정
|
||||
allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부
|
||||
layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정
|
||||
}
|
||||
} catch (ignore: NoSuchMethodError) {
|
||||
|
||||
}.apply {
|
||||
loadUrl(url) // 웹페이지 연결
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun autoScrollDown(webView: WebView?, url: String?) {
|
||||
webView?.let { webView ->
|
||||
val ramdomTimeSec =
|
||||
800L.plus(Math.abs(Random(System.currentTimeMillis()).nextLong().rem(489L)))
|
||||
BLog.LOGE("ramdomTime >>> ${ramdomTimeSec}")
|
||||
if (((webView?.scrollY ?: 0) + (webView?.height
|
||||
?: 0)) < webView?.contentHeight ?: 0
|
||||
) {
|
||||
webView?.postDelayed({
|
||||
webView?.scrollY = (binding.searcher01.scrollY) + (binding.searcher01.height.toFloat() * 0.4).toInt()
|
||||
autoScrollDown(webView, url)
|
||||
}, ramdomTimeSec)
|
||||
} else {
|
||||
webView?.postDelayed({
|
||||
binding.viewPager.bringToFront()
|
||||
binding.searcher01.alpha = 0f
|
||||
if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
val fileName = url?.toUri()?.path?.replace("/","_")?.replace(".","_")
|
||||
val path = File(Environment.getExternalStorageDirectory(),"bums")
|
||||
if (path.exists() == false) {
|
||||
path.mkdirs()
|
||||
}
|
||||
val file = File(path, fileName.plus(".pdf"))
|
||||
|
||||
BLog.LOGE("file >>> ${file.absolutePath}")
|
||||
try {
|
||||
PDFPrint.generatePDFFromWebView(file,webView, object : PDFPrint.OnPDFPrintListener {
|
||||
override fun onSuccess(file: File?) {
|
||||
BLog.LOGE("file >>>> ${file!!.absolutePath}")
|
||||
val shareIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
this.`package` = "com.synology.dsdrive"
|
||||
val imageUri = FileProvider.getUriForFile(
|
||||
this@LauncherActivity,
|
||||
"rasel.lunar.launcher.debug.fileprovider", //(use your app signature + ".provider" )
|
||||
file
|
||||
)
|
||||
putExtra(Intent.EXTRA_STREAM, imageUri)
|
||||
type = "pdf"
|
||||
}
|
||||
this@LauncherActivity.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
override fun onError(exception: java.lang.Exception?) {
|
||||
Toast.makeText(this@LauncherActivity,
|
||||
"Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
exception?.printStackTrace()
|
||||
}
|
||||
} )
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}, ramdomTimeSec)
|
||||
}
|
||||
}
|
||||
}
|
||||
// fun doWebSavor(url : String, callBack :CommadCallabck?) {
|
||||
// if (true)return
|
||||
// this.callBack = callBack
|
||||
//
|
||||
// binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE }
|
||||
// BLog.LOGE("binding.otherCheck before ThreadRun")
|
||||
// binding.searcher01.bringToFront()
|
||||
// binding.searcher01.alpha = 1f
|
||||
// binding.searcher01.webViewClient = object : WebViewClient() {
|
||||
// override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||
// if (url?.contains("missav") == true && isF) {
|
||||
// BLog.LOGE("binding.otherCheck before reload")
|
||||
// view?.loadUrl(url!!)
|
||||
// isF = true
|
||||
// return false
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||
// BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}")
|
||||
// super.onPageStarted(view, url, favicon)
|
||||
// }
|
||||
// override fun onReceivedError(
|
||||
// view: WebView?,
|
||||
// request: WebResourceRequest?,
|
||||
// error: WebResourceError?
|
||||
// ) {
|
||||
//
|
||||
// }
|
||||
// override fun onReceivedSslError(
|
||||
// view: WebView?,
|
||||
// handler: SslErrorHandler?,
|
||||
// error: SslError?
|
||||
// ) {
|
||||
// handler?.proceed()
|
||||
// }
|
||||
//
|
||||
// override fun onPageFinished(view: WebView?, url: String?) {
|
||||
// super.onPageFinished(view, url)
|
||||
// autoScrollDown(view,url)
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// WebView.setWebContentsDebuggingEnabled(false)
|
||||
// binding.searcher01.apply {
|
||||
// setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정
|
||||
// setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결
|
||||
// try {
|
||||
// settings.apply {
|
||||
// userAgentString = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
|
||||
// javaScriptEnabled = true // 자바스크립트 사용 가능하도록 설정
|
||||
// loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드
|
||||
// useWideViewPort = true // 화면에 맞게 페이지 확대/축소
|
||||
// domStorageEnabled = true // DOM 저장소 사용 가능하도록 설정
|
||||
// setSupportMultipleWindows(true)
|
||||
// javaScriptCanOpenWindowsAutomatically = true // 팝업창 차단 해제
|
||||
// cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
|
||||
// textZoom = 100 // system 에 의한 글꼴 변형 방지
|
||||
// defaultTextEncodingName = "UTF-8" // 인코딩 설정
|
||||
// allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부
|
||||
// layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정
|
||||
// }
|
||||
// } catch (ignore: NoSuchMethodError) {
|
||||
//
|
||||
// }.apply {
|
||||
// loadUrl(url) // 웹페이지 연결
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// fun autoScrollDown(webView: WebView?, url: String?) {
|
||||
// webView?.let { webView ->
|
||||
// val ramdomTimeSec =
|
||||
// 800L.plus(Math.abs(Random(System.currentTimeMillis()).nextLong().rem(489L)))
|
||||
// BLog.LOGE("ramdomTime >>> ${ramdomTimeSec}")
|
||||
// if (((webView?.scrollY ?: 0) + (webView?.height
|
||||
// ?: 0)) < webView?.contentHeight ?: 0
|
||||
// ) {
|
||||
// webView?.postDelayed({
|
||||
// webView?.scrollY = (binding.searcher01.scrollY) + (binding.searcher01.height.toFloat() * 0.4).toInt()
|
||||
// autoScrollDown(webView, url)
|
||||
// }, ramdomTimeSec)
|
||||
// } else {
|
||||
// webView?.postDelayed({
|
||||
// binding.viewPager.bringToFront()
|
||||
// binding.searcher01.alpha = 0f
|
||||
// if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
// val fileName = url?.toUri()?.path?.replace("/","_")?.replace(".","_")
|
||||
// val path = File(Environment.getExternalStorageDirectory(),"bums")
|
||||
// if (path.exists() == false) {
|
||||
// path.mkdirs()
|
||||
// }
|
||||
// val file = File(path, fileName.plus(".pdf"))
|
||||
//
|
||||
// BLog.LOGE("file >>> ${file.absolutePath}")
|
||||
// try {
|
||||
// PDFPrint.generatePDFFromWebView(file,webView, object : PDFPrint.OnPDFPrintListener {
|
||||
// override fun onSuccess(file: File?) {
|
||||
// BLog.LOGE("file >>>> ${file!!.absolutePath}")
|
||||
// val shareIntent: Intent = Intent().apply {
|
||||
// action = Intent.ACTION_SEND
|
||||
// this.`package` = "com.synology.dsdrive"
|
||||
// val imageUri = FileProvider.getUriForFile(
|
||||
// this@LauncherActivity,
|
||||
// "rasel.lunar.launcher.debug.fileprovider", //(use your app signature + ".provider" )
|
||||
// file
|
||||
// )
|
||||
// putExtra(Intent.EXTRA_STREAM, imageUri)
|
||||
// type = "pdf"
|
||||
// }
|
||||
// this@LauncherActivity.startActivity(shareIntent)
|
||||
// }
|
||||
//
|
||||
// override fun onError(exception: java.lang.Exception?) {
|
||||
// Toast.makeText(this@LauncherActivity,
|
||||
// "Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
// exception?.printStackTrace()
|
||||
// }
|
||||
// } )
|
||||
// } catch (e: IOException) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
// }, ramdomTimeSec)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
var callBack : CommadCallabck? = null
|
||||
var isF = false
|
||||
@ -796,8 +791,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
handler?.proceed()
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
lastedFinishedPageUrl = url ?: ""
|
||||
@ -810,9 +803,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
|
||||
" };getAll()"
|
||||
) { result ->
|
||||
(result as? String)?.let {
|
||||
|
||||
}
|
||||
(result as? String)?.let {}
|
||||
}
|
||||
} else if(url?.contains("translate.google.com") == true) {
|
||||
binding.searcher01.postDelayed({
|
||||
@ -821,9 +812,7 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
|
||||
" };getAll()"
|
||||
) { result ->
|
||||
(result as? String)?.let {
|
||||
|
||||
}
|
||||
(result as? String)?.let {}
|
||||
}
|
||||
}, 6000L)
|
||||
} else {
|
||||
@ -833,20 +822,10 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
|
||||
" };getAll()"
|
||||
) { result ->
|
||||
(result as? String)?.let {
|
||||
|
||||
}
|
||||
(result as? String)?.let {}
|
||||
}
|
||||
// if (!isF) {
|
||||
// binding.searcher01.post {
|
||||
// binding.searcher01.loadUrl("https://missav.com/dm11/ko")
|
||||
// isF = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (isF) this@LauncherActivity.callBack?.collectComplete()
|
||||
// binding.searcher01.post { binding.searcher01.visibility = View.GONE }
|
||||
// }
|
||||
}
|
||||
}
|
||||
WebView.setWebContentsDebuggingEnabled(false)
|
||||
@ -919,7 +898,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
fun jGuruMain(doc: Document) {
|
||||
// BLog.LOGE("SimpleDateFormat D MM yy => ${SimpleDateFormat("d MMM yy", Locale.US).format(Date())}")
|
||||
var temp = arrayListOf<RssData>()
|
||||
val prevUrl = doc.getElementsByClass("prev").get(0).getElementsByAttribute("href").get(0).attr("href")
|
||||
doc.getElementsByClass("column").forEach {
|
||||
@ -938,9 +916,6 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
var itemC = 0
|
||||
WorkersDb.insertBulkInteface(temp)
|
||||
callBack?.onConsoleLog("Stored data :: ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))} set in ${itemC}")
|
||||
// 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()
|
||||
//// }
|
||||
binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) }
|
||||
this@LauncherActivity.callBack?.collectComplete()
|
||||
}
|
||||
@ -960,39 +935,26 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}.apply {
|
||||
// listTags.sortByDescending { it.pubDate() }
|
||||
// Toast.makeText(this@LauncherActivity,
|
||||
// "Stored data :: ${listTags.size}tags", Toast.LENGTH_SHORT).show()
|
||||
binding.searcher01?.post { binding.searcher01.loadData("<html></html>",null,null) }
|
||||
this@LauncherActivity.callBack?.collectComplete()
|
||||
}
|
||||
}
|
||||
|
||||
inner class MyJavaScriptInterface(val webView: WebView) {
|
||||
|
||||
|
||||
@JavascriptInterface
|
||||
fun sendValueFromHtml(result: String) {
|
||||
// BLog.LOGE("binding.otherCheck start with ${result}")
|
||||
if (lastedFinishedPageUrl.contains(jGuruMain)) {
|
||||
var htmlString = result.replace("\\u003","<")
|
||||
val doc: Document = Jsoup.parse(htmlString)
|
||||
if (lastedFinishedPageUrl?.contains("page") == true || lastedFinishedPageUrl?.equals(
|
||||
jGuruMain
|
||||
) == true
|
||||
) {
|
||||
if (lastedFinishedPageUrl?.contains("page") == true || lastedFinishedPageUrl?.equals(jGuruMain) == true) {
|
||||
jGuruMain(doc)
|
||||
} else if (lastedFinishedPageUrl?.contains("/most-watched-rank") == true) {
|
||||
jGuruToday(doc)
|
||||
} else if (lastedFinishedPageUrl?.contains("/tags/") == true) {
|
||||
jGuruTag(doc)
|
||||
}
|
||||
} else if (lastedFinishedPageUrl?.contains("youtube") == true) {
|
||||
// val doc: Document = Jsoup.parse(result)
|
||||
// ytChannel(doc)
|
||||
} else if (lastedFinishedPageUrl?.contains("missav")==true) {
|
||||
} else if (lastedFinishedPageUrl?.contains("missav")==true) {
|
||||
val doc: Document = Jsoup.parse(result)
|
||||
// BLog.LOGE("missav >>> ${doc}")
|
||||
var temp = arrayListOf<RssData>()
|
||||
doc.getElementsByClass("thumbnail group").forEach { miss_li ->
|
||||
if (miss_li.getElementsByTag("img").size > 0 && miss_li.getElementsByTag("img").get(0).attr("data-src").length > 10 &&
|
||||
@ -1012,32 +974,8 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}.apply {
|
||||
WorkersDb.insertBulkData(temp)
|
||||
// BLog.LOGE("temp >>> ${temp.size}")
|
||||
// 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 if(lastedFinishedPageUrl?.contains("https://translate.google.com") == true){
|
||||
} else if(lastedFinishedPageUrl?.contains("https://translate.google.com") == true){
|
||||
callBackHandler.removeCallbacks(postNext)
|
||||
val doc: Document = Jsoup.parse(result)
|
||||
doc.getElementsByTag("span").forEach { span ->
|
||||
|
||||
@ -20,13 +20,21 @@ package rasel.lunar.launcher
|
||||
|
||||
import android.app.Application
|
||||
import android.content.ComponentCallbacks2
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import rasel.lunar.launcher.helpers.PrefHelper
|
||||
|
||||
|
||||
internal class LunarLauncher : Application() {
|
||||
companion object {
|
||||
var appContext : Context? = null
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
// Picasso.get().setIndicatorsEnabled(true)
|
||||
appContext = this
|
||||
PrefHelper.inject(getSharedPreferences(PrefHelper.D_PREFIX, Context.MODE_PRIVATE))
|
||||
}
|
||||
override fun onTrimMemory(level: Int) {
|
||||
super.onTrimMemory(level)
|
||||
@ -34,4 +42,4 @@ internal class LunarLauncher : Application() {
|
||||
if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) SQLiteDatabase.releaseMemory()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -26,14 +26,12 @@ import android.view.ViewGroup
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.realm.kotlin.ext.query
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import rasel.lunar.launcher.databinding.ContactItemBinding
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import rasel.lunar.launcher.utils.JamoUtils
|
||||
import rasel.lunar.launcher.workers.RecentCallGetter
|
||||
import rasel.lunar.launcher.workers.WorkersDb
|
||||
import java.util.Date
|
||||
|
||||
|
||||
@ -64,22 +62,11 @@ internal class ContactAdapter (
|
||||
holder.view.root.apply {
|
||||
/* on click - open app */
|
||||
setOnClickListener {
|
||||
|
||||
ContactMenu().show(fragmentManager, item.id.toString())
|
||||
}
|
||||
|
||||
/* on long click - open app menu */
|
||||
setOnLongClickListener {
|
||||
WorkersDb.getRealm().writeBlocking {
|
||||
if (item.id!=null && item.id?.length ?: 0 > 0) {
|
||||
val result = query<SimpleContact>().query("id == $0", item.id).find()
|
||||
if(result.size > 0){
|
||||
var contact = result.first()
|
||||
contact.touchCount = contact.touchCount + 1
|
||||
contact.lastedTouchDateTime = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
}
|
||||
// BLog.LOGE("item.id.toString() >> ${item.id.toString()}")
|
||||
ContactMenu().show(fragmentManager, item.id.toString())
|
||||
true
|
||||
|
||||
@ -50,6 +50,8 @@ import com.google.android.material.button.MaterialButtonToggleGroup
|
||||
import com.google.gson.Gson
|
||||
import io.realm.kotlin.ext.query
|
||||
import io.realm.kotlin.query.Sort
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
@ -63,6 +65,7 @@ import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||
import rasel.lunar.launcher.LauncherActivity.Companion.refreshDeviceData
|
||||
import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds
|
||||
import rasel.lunar.launcher.R
|
||||
import rasel.lunar.launcher.apps.ContactMenu
|
||||
import rasel.lunar.launcher.databinding.FeedsBinding
|
||||
import rasel.lunar.launcher.feeds.rss.RssAdapter
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_HEIGHTS
|
||||
@ -71,6 +74,7 @@ import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_WIDGETS
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.SEPARATOR
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.requestCreateWidget
|
||||
import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget
|
||||
import rasel.lunar.launcher.helpers.PrefHelper
|
||||
import rasel.lunar.launcher.home.LauncherHome.Companion.home
|
||||
import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
|
||||
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
|
||||
@ -83,6 +87,7 @@ import rasel.lunar.launcher.model.jGuruTag
|
||||
import rasel.lunar.launcher.model.dateFormat
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import rasel.lunar.launcher.utils.FeedParseManager
|
||||
import rasel.lunar.launcher.utils.JamoUtils
|
||||
import rasel.lunar.launcher.utils.RssList.jGuruMain
|
||||
import rasel.lunar.launcher.utils.USAGT
|
||||
@ -94,6 +99,7 @@ import rasel.lunar.launcher.workers.WorkersDb
|
||||
import java.net.URLEncoder
|
||||
import java.nio.charset.Charset
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Base64
|
||||
import java.util.Date
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
@ -176,11 +182,10 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
mMainHandler.removeCallbacks(hideConsole)
|
||||
binding.consoleLog.post {
|
||||
binding.consoleLog.visibility = View.VISIBLE
|
||||
binding.consoleLog.text = str
|
||||
binding.consoleLog.text = binding.consoleLog.text.toString() + "\n" + str
|
||||
}
|
||||
mMainHandler.postDelayed(hideConsole,10000L)
|
||||
// BLog.LOGE("consoleLog >>>> ${str}")
|
||||
|
||||
BLog.LOGE("consoleLog >>>> ${str}")
|
||||
}
|
||||
|
||||
fun openOpera(schemeString : String) {
|
||||
@ -225,20 +230,39 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
builder.setPositiveButton(android.R.string.ok,
|
||||
DialogInterface.OnClickListener { dialog, which ->
|
||||
dialog.dismiss()
|
||||
// BLog.LOGE("input.text.toString() >>>> ${input.text.toString()}")
|
||||
consoleLog("input.text.toString() >>>> ${input.text.toString()}")
|
||||
if (input.text.toString().trim().contains(" ")) {
|
||||
val cmd = input.text.toString().trim().split(" ")
|
||||
when(cmd[0]) {
|
||||
"so"-> {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
consoleLog("${cmd[0]} Start ${cmd[1]}")
|
||||
String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9rciVzLnNvZ2lybC5zby8=".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} }
|
||||
consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
|
||||
consoleLog("${cmd[0]} END ${cmd[1]}")
|
||||
}
|
||||
}
|
||||
"s" -> {
|
||||
home?.queryInfos(keyword = cmd[1])
|
||||
}
|
||||
"jf" -> {
|
||||
consoleLog("on Cmd JF")
|
||||
GlobalScope.launch { excuteGetterMostByUrl("https://javmost.to/search/movie/${cmd[1]}") }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
consoleLog("${cmd[0]} Start ${cmd[1]}")
|
||||
String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9qYXZtb3N0LnRvL3NlYXJjaC9tb3ZpZS8lcw==".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} }
|
||||
consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
|
||||
consoleLog("${cmd[0]} END ${cmd[1]}")
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
consoleLog("on Cmd JF with SO")
|
||||
consoleLog("${cmd[0]} Start ${cmd[1]}")
|
||||
String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9rcjcwLnNvZ2lybC5zby8/cz0lcw==".toByteArray())),cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} }
|
||||
consoleLog("current j req() ${WorkersDb.getRealm().query<RssData>("category == $0", RssDataType.GURU.name).find().size}")
|
||||
consoleLog("${cmd[0]} END ${cmd[1]}")
|
||||
}
|
||||
}
|
||||
"mgn"-> {
|
||||
// lActivity?.doWebParseStart("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}") {}
|
||||
GlobalScope.launch {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
var temp = arrayListOf<CiliMagnet>()
|
||||
consoleLog("this >>>> cili ${cmd[0]} -> ${cmd[1]}")
|
||||
Jsoup.connect("https://cili.site/search?q=${URLEncoder.encode(cmd[1], Charset.defaultCharset().name())}").get().let { cili ->
|
||||
@ -254,8 +278,6 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
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 ->
|
||||
@ -278,52 +300,20 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
}
|
||||
binding.expandRss.isChecked = false
|
||||
} else {
|
||||
when (input.text.toString()) {
|
||||
"loc_ck" -> {
|
||||
FeedsResult().show(parentFragmentManager, "")
|
||||
}
|
||||
"loc_on" -> {
|
||||
PrefHelper.location(!PrefHelper.isLocationOn())
|
||||
consoleLog("PrefHelper.isLocationOn() >>> ${PrefHelper.isLocationOn()}")
|
||||
}
|
||||
"cal" ->{
|
||||
getCal()
|
||||
}
|
||||
"so" -> GlobalScope.launch {
|
||||
"https://kr69.sogirl.so".getJ().let { doc ->
|
||||
// BLog.LOGE("ogirl >>> ${doc.title()}")
|
||||
doc.getElementsByTag("article").forEach { article ->
|
||||
// BLog.LOGE("ogirl article >>> ${article.text()}")
|
||||
val title = article.getElementsByTag("a").get(0).attr("title")
|
||||
val href = article.getElementsByTag("a").get(0).attr("href")
|
||||
val img = article.getElementsByTag("img").get(0).attr("data-src")
|
||||
WorkersDb.getRealm().writeBlocking {
|
||||
if (query<RssData>("originPage == $0", href).find().size == 0) {
|
||||
RssData().apply {
|
||||
this.originPage = href
|
||||
this.title = title
|
||||
this.description = "Sogirl"
|
||||
this.thumbnail = img
|
||||
this.pubDate = Date().time
|
||||
this.category = RssDataType.GURU.name
|
||||
this.chosung =
|
||||
JamoUtils.split(title).joinToString("")
|
||||
copyToRealm(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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")
|
||||
urls.forEach { mostUrl ->
|
||||
GlobalScope.launch {
|
||||
excuteGetterMostByUrl(mostUrl)
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
"ojs" -> home?.queryInfos(arrayListOf<RssDataType>().apply {
|
||||
addAll(RssDataType.values())
|
||||
remove(RssDataType.GURU)
|
||||
@ -340,8 +330,6 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
addAll(RssDataType.values())
|
||||
remove(RssDataType.REDDIT)
|
||||
})
|
||||
|
||||
|
||||
"req" -> {
|
||||
refreshFeeds()
|
||||
refreshDeviceData()
|
||||
@ -379,7 +367,6 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
refresh.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
"jjp" -> {
|
||||
// lActivity?.doWebParseStart("https://projectjav.com") {}
|
||||
}
|
||||
@ -402,10 +389,6 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
.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" -> {
|
||||
@ -497,72 +480,6 @@ internal class Feeds : Fragment() , CommadCallabck {
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private val resultReceiver: ResultReceiver = object : ResultReceiver(Handler(Looper.getMainLooper())) {
|
||||
// override fun onReceiveResult(resultCode: Int, resultData: Bundle) {
|
||||
// when (val items = resultData.getSerializable(RSS_ITEMS) as List<Rss>?) {
|
||||
// null -> resumeService()
|
||||
// else -> {
|
||||
// binding.feedsRss.apply {
|
||||
// if(rss.adapter != null) {
|
||||
// (rss.adapter as RssAdapter).items.addAll(items)
|
||||
// }
|
||||
// refresh.visibility = View.GONE
|
||||
// loading.visibility = View.GONE
|
||||
// rss.visibility = View.VISIBLE
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private fun systemInfo() {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
package rasel.lunar.launcher.feeds
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.gson.Gson
|
||||
import io.realm.kotlin.ext.query
|
||||
import rasel.lunar.launcher.BuildConfig
|
||||
import rasel.lunar.launcher.apps.DismissCalback
|
||||
import rasel.lunar.launcher.databinding.FeedsResultMenuBinding
|
||||
import rasel.lunar.launcher.databinding.SearchMenuBinding
|
||||
import rasel.lunar.launcher.model.LocationLog
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import rasel.lunar.launcher.workers.WorkersDb
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
internal class FeedsResult : BottomSheetDialogFragment() {
|
||||
|
||||
private lateinit var binding: FeedsResultMenuBinding
|
||||
private lateinit var searchWord: String
|
||||
private lateinit var packageManager: PackageManager
|
||||
private lateinit var appInfo: ApplicationInfo
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = FeedsResultMenuBinding.inflate(inflater, container, false)
|
||||
|
||||
/* get package name from fragment's tag */
|
||||
searchWord = tag.toString()
|
||||
WorkersDb.getRealm().query<LocationLog>().find()?.let {
|
||||
if (it.size > 0) {
|
||||
binding.logs.text = it.map {
|
||||
BLog.LOGE("LocLog >> ${it.toString()}")
|
||||
SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(Date(it.time))
|
||||
it.mAddressLines.joinToString(" , ")
|
||||
}.joinToString( " , ")
|
||||
}
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
var mDismissCalback : DismissCalback? = null
|
||||
|
||||
fun show(manager: FragmentManager, tag: String?, dismissCalback : DismissCalback?) {
|
||||
this.mDismissCalback = dismissCalback
|
||||
this.show(manager, tag)
|
||||
}
|
||||
|
||||
override fun show(manager: FragmentManager, tag: String?) {
|
||||
super.show(manager, tag)
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
BLog.LOGE("dismiss()")
|
||||
mDismissCalback?.invoke()
|
||||
super.dismiss()
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
BLog.LOGE("onDismiss(dialog: DialogInterface)")
|
||||
mDismissCalback?.invoke()
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package rasel.lunar.launcher.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
object PrefHelper {
|
||||
val D_PREFIX = "rasel.lunar.launcher.helpers"
|
||||
val BOOL_PRE = D_PREFIX.plus(".BOOL.")
|
||||
val LONG_PRE = D_PREFIX.plus(".LONG.")
|
||||
fun inject(SharedPreferences : SharedPreferences) {
|
||||
this.sharedPreferences = SharedPreferences
|
||||
}
|
||||
var sharedPreferences : SharedPreferences? = null
|
||||
|
||||
fun location(boolean: Boolean) {
|
||||
sharedPreferences?.edit()?.putBoolean(BOOL_PRE.plus("location"), boolean)?.apply()
|
||||
}
|
||||
|
||||
fun isLocationOn() = sharedPreferences?.getBoolean(BOOL_PRE.plus("location") , false) ?: false
|
||||
|
||||
var shortTimePeriod : Long
|
||||
get() {
|
||||
return sharedPreferences?.getLong(LONG_PRE.plus("shortTimePeriod"), 20L) ?: 20L
|
||||
}
|
||||
set(value) {
|
||||
sharedPreferences?.edit()?.putLong(LONG_PRE.plus("shortTimePeriod"),value)?.apply()
|
||||
}
|
||||
var longTimePeriod : Long
|
||||
get() {
|
||||
return sharedPreferences?.getLong(LONG_PRE.plus("longTimePeriod"), 60L) ?: 60L
|
||||
}
|
||||
set(value) {
|
||||
sharedPreferences?.edit()?.putLong(LONG_PRE.plus("longTimePeriod"),value)?.apply()
|
||||
}
|
||||
var midTimePeriod : Long
|
||||
get() {
|
||||
return sharedPreferences?.getLong(LONG_PRE.plus("midTimePeriod"), 30L) ?: 30L
|
||||
}
|
||||
set(value) {
|
||||
sharedPreferences?.edit()?.putLong(LONG_PRE.plus("midTimePeriod"),value)?.apply()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
typealias BLOCK = ()->Unit
|
||||
inline fun Boolean.letTrue(block: BLOCK) {
|
||||
if (this) {
|
||||
block.invoke()
|
||||
} else {
|
||||
// elseblock.invoke()
|
||||
}
|
||||
}
|
||||
@ -181,6 +181,7 @@ internal class LauncherHome : Fragment() {
|
||||
// BLog.LOGE("${this} ::::: onCreate >>>> ")
|
||||
}
|
||||
var mWeatherResult : RealmResults<WeatherForcast>? = null
|
||||
var musicJob : Job? = null
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
// BLog.LOGE("${this} ::::: onCreateView >>>> ")
|
||||
binding = LauncherHomeBinding.inflate(inflater, container, false)
|
||||
@ -234,8 +235,8 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlobalScope.launch {
|
||||
musicJob?.cancel()
|
||||
musicJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
WorkersDb.getRealm().apply {
|
||||
query<CurrentPlayItem>().find().asFlow().collect { changes: ResultsChange<CurrentPlayItem> ->
|
||||
binding.currentMusic?.postDelayed({
|
||||
@ -262,7 +263,7 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
musicJob?.start()
|
||||
// BLog.LOGE("onCreateView()")
|
||||
binding.nextBtn.setOnClickListener {
|
||||
val mAudioManager =
|
||||
|
||||
@ -79,20 +79,12 @@ internal class RssItemAdapter (
|
||||
}
|
||||
}
|
||||
private var rssDataItemLis: ArrayList<RssDataInterface> = arrayListOf()
|
||||
val mLongClickListener = View.OnLongClickListener { v ->
|
||||
(v?.tag as? Int)?.let { idx ->
|
||||
val rss = rssDataItemLis[idx]
|
||||
lActivity?.doWebSavor(rss.originPage(),null)
|
||||
// when (rss.category()) {
|
||||
// RssDataType.GURU ,RssDataType.Most , RssDataType.TAGS-> { openOpera(rss.originPage()) }
|
||||
// RssDataType.REDDIT -> { openReddit(rss.originPage()) }
|
||||
// RssDataType.Dotax -> { openDotax(rss.originPage()) }
|
||||
// RssDataType.YOUTUBE -> { openYouTube(rss.originPage()) }
|
||||
// else -> { openNews(rss.originPage()) }
|
||||
// }
|
||||
}
|
||||
true
|
||||
}
|
||||
// val mLongClickListener = View.OnLongClickListener { v ->
|
||||
// (v?.tag as? Int)?.let { idx ->
|
||||
// val rss = rssDataItemLis[idx]
|
||||
// }
|
||||
// true
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +127,7 @@ internal class RssItemAdapter (
|
||||
|
||||
holder.view.root.tag = position
|
||||
holder.view.root.setOnClickListener(dateViewClick)
|
||||
holder.view.root.setOnLongClickListener(mLongClickListener)
|
||||
// holder.view.root.setOnLongClickListener(mLongClickListener)
|
||||
}
|
||||
|
||||
var layoutManager : LinearLayoutManager? = null
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package rasel.lunar.launcher.model
|
||||
|
||||
import android.location.Address
|
||||
import android.os.Bundle
|
||||
import io.realm.kotlin.ext.realmAnyListOf
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
import java.util.Locale
|
||||
|
||||
class LocationLog : RealmObject {
|
||||
var mFeatureName: String? = null
|
||||
var mAddressLines: RealmList<String> = realmListOf()
|
||||
var mAdminArea: String? = null
|
||||
var mSubAdminArea: String? = null
|
||||
var mLocality: String? = null
|
||||
var mSubLocality: String? = null
|
||||
var mThoroughfare: String? = null
|
||||
var mSubThoroughfare: String? = null
|
||||
var mPremises: String? = null
|
||||
var mPostalCode: String? = null
|
||||
var mCountryCode: String? = null
|
||||
var mCountryName: String? = null
|
||||
var mLatitude = 0.0
|
||||
var mLongitude = 0.0
|
||||
var mHasLatitude = false
|
||||
var mHasLongitude = false
|
||||
var mPhone: String? = null
|
||||
var mUrl: String? = null
|
||||
var time : Long = 0L
|
||||
fun fillData(address: Address) {
|
||||
time = System.currentTimeMillis()
|
||||
mFeatureName = address.featureName
|
||||
mAddressLines.apply {
|
||||
for (i in 0..address.maxAddressLineIndex) {
|
||||
this.add(address.getAddressLine(i))
|
||||
}
|
||||
}
|
||||
mAdminArea = address.adminArea
|
||||
mSubAdminArea = address.subAdminArea
|
||||
mLocality = address.locality
|
||||
mSubLocality = address.subLocality
|
||||
mThoroughfare = address.thoroughfare
|
||||
mSubThoroughfare = address.subThoroughfare
|
||||
mPremises = address.premises
|
||||
mPostalCode = address.postalCode
|
||||
mCountryCode = address.countryCode
|
||||
mCountryName = address.countryName
|
||||
mLatitude = address.latitude
|
||||
mLongitude = address.longitude
|
||||
mPhone = address.phone
|
||||
mUrl = address.url
|
||||
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val buffer = StringBuffer()
|
||||
buffer.append(mFeatureName).append("|").append("\n")
|
||||
buffer.append(mAddressLines.joinToString(" , ")).append("|").append("\n")
|
||||
buffer.append(mAdminArea).append("|").append("\n")
|
||||
buffer.append(mSubAdminArea).append("|").append("\n")
|
||||
buffer.append(mLocality).append("|").append("\n")
|
||||
buffer.append(mSubLocality).append("|").append("\n")
|
||||
buffer.append(mThoroughfare).append("|").append("\n")
|
||||
buffer.append(mSubThoroughfare).append("|").append("\n")
|
||||
buffer.append(mPremises).append("|").append("\n")
|
||||
buffer.append(mPostalCode).append("|").append("\n")
|
||||
buffer.append(mCountryCode).append("|").append("\n")
|
||||
buffer.append(mCountryName).append("|").append("\n")
|
||||
buffer.append(mLatitude).append("|").append("\n")
|
||||
buffer.append(mLongitude).append("|").append("\n")
|
||||
buffer.append(mPhone).append("|").append("\n")
|
||||
buffer.append(mUrl).append("|").append("\n")
|
||||
return buffer.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,101 @@
|
||||
package rasel.lunar.launcher.utils
|
||||
|
||||
import io.realm.kotlin.ext.query
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
|
||||
import rasel.lunar.launcher.model.MostItem
|
||||
import rasel.lunar.launcher.model.RssData
|
||||
import rasel.lunar.launcher.model.RssDataType
|
||||
import rasel.lunar.launcher.model.dateFormat
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
import rasel.lunar.launcher.workers.WorkersDb
|
||||
import java.nio.charset.Charset
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Base64
|
||||
import java.util.Date
|
||||
|
||||
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"
|
||||
fun String.getJ() = Jsoup.connect("https://kr69.sogirl.so/").userAgent(USAGT).get()
|
||||
fun String.getJ() = Jsoup.connect(this).userAgent(USAGT).get()
|
||||
object FeedParseManager {
|
||||
val parsers = listOf<SoInterface>(QVZTb2dpcmw,SkFWTW9zdA)
|
||||
fun parse(doc : Document, consoleLog : (String)-> Unit) {
|
||||
consoleLog("FeedParseManager START")
|
||||
try {
|
||||
parsers.filter { doc.title().contains(it.getName()) }.first()?.let {
|
||||
it.parse(doc,consoleLog)
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
consoleLog(e.message ?: "Exception")
|
||||
e.printStackTrace()
|
||||
}
|
||||
consoleLog("FeedParseManager END")
|
||||
}
|
||||
}
|
||||
interface SoInterface{
|
||||
fun getName() : String
|
||||
fun parse(doc : Document, consoleLog : (String)-> Unit)
|
||||
}
|
||||
object QVZTb2dpcmw : SoInterface {
|
||||
override fun getName(): String {
|
||||
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray()))
|
||||
}
|
||||
override fun parse(doc : Document, consoleLog : (String)-> Unit) {
|
||||
doc.getElementsByTag("article").forEach { article ->
|
||||
consoleLog("ogirl article >>> ${article.text()}")
|
||||
val title = article.getElementsByTag("a").get(0).attr("title")
|
||||
val href = article.getElementsByTag("a").get(0).attr("href")
|
||||
val img = article.getElementsByTag("img").get(0).attr("data-src")
|
||||
WorkersDb.getRealm().writeBlocking {
|
||||
if (query<RssData>("originPage == $0", href).find().size == 0) {
|
||||
RssData().apply {
|
||||
this.originPage = href
|
||||
this.title = title
|
||||
this.description = "Sogirl"
|
||||
this.thumbnail = img
|
||||
this.pubDate = Date().time
|
||||
this.category = RssDataType.GURU.name
|
||||
this.chosung =
|
||||
JamoUtils.split(title).joinToString("")
|
||||
copyToRealm(this)
|
||||
}
|
||||
consoleLog("title $title | href $href | img $img" )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
object SkFWTW9zdA : SoInterface {
|
||||
var dmy = SimpleDateFormat("dd-MM-yyyy")
|
||||
override fun getName(): String {
|
||||
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray()))
|
||||
}
|
||||
override fun parse(doc: Document, consoleLog: (String) -> Unit) {
|
||||
consoleLog("$lastedFinishedPageUrl >>> ${doc.title()}")
|
||||
doc.getElementsByClass("card").forEach { 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 ""
|
||||
if(card.getElementsByClass("card-block").size > 0) if(card.getElementsByClass("card-block").size > 0) {
|
||||
val link = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("href")
|
||||
val title = card.getElementsByClass("card-block").get(0).getElementsByTag("a").get(0).attr("title")
|
||||
val 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())
|
||||
}
|
||||
}
|
||||
consoleLog(" 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}")
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,9 @@ import rasel.lunar.launcher.model.Dotax
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
|
||||
class DotaxGetter : BaseGetter {
|
||||
companion object {
|
||||
val COMIC2_WORK_TAG = "ComicGetter2"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@ import rasel.lunar.launcher.model.getRssData
|
||||
import java.util.Date
|
||||
|
||||
class FmKoreaGetter : BaseGetter {
|
||||
companion object {
|
||||
val COMIC_WORK_TAG = "ComicGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
}
|
||||
|
||||
@ -2,13 +2,30 @@ package rasel.lunar.launcher.workers
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.location.Address
|
||||
import android.location.Geocoder
|
||||
import android.location.Location
|
||||
import android.os.Build
|
||||
import androidx.work.WorkerParameters
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.google.android.gms.location.Priority
|
||||
import com.google.android.gms.tasks.CancellationTokenSource
|
||||
import rasel.lunar.launcher.LauncherActivity.Companion.doGetWheaterByLocationInfo
|
||||
import okhttp3.ConnectionPool
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody
|
||||
import rasel.lunar.launcher.LauncherActivity.Companion.runWeatherGetter
|
||||
import rasel.lunar.launcher.helpers.PrefHelper
|
||||
import rasel.lunar.launcher.helpers.letTrue
|
||||
import rasel.lunar.launcher.model.LocationLog
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import java.io.IOException
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGetter(context, workerParams) {
|
||||
companion object {
|
||||
@ -29,7 +46,10 @@ class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGet
|
||||
BLog.LOGE("Location >>> (latitude)${it.longitude}/(longitude)${it.latitude}")
|
||||
longitude = it.longitude
|
||||
latitude = it.latitude
|
||||
doGetWheaterByLocationInfo()
|
||||
runWeatherGetter()
|
||||
PrefHelper.isLocationOn().letTrue {
|
||||
pushLocation(it)
|
||||
}
|
||||
}
|
||||
}.addOnFailureListener{
|
||||
BLog.LOGE("Location error >>> $it")
|
||||
@ -38,4 +58,60 @@ class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGet
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
|
||||
fun pushLocation(location: Location) {
|
||||
try {
|
||||
val geocoder = Geocoder(this.applicationContext, Locale.getDefault())
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
geocoder.getFromLocation(
|
||||
BigDecimal.valueOf(location.getLatitude()).setScale(6,RoundingMode.HALF_UP).toDouble(),
|
||||
BigDecimal.valueOf(location.getLongitude()).setScale(6,RoundingMode.HALF_UP).toDouble(),
|
||||
1) { addresses ->
|
||||
addresses.first()?.let {
|
||||
WorkersDb.push(LocationLog().apply {
|
||||
fillData(it)
|
||||
})
|
||||
// it.getAddressLine(0)?.let {
|
||||
// Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
// try {
|
||||
// //////-1002450229641
|
||||
// val url =
|
||||
// "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&text=남편의현위치는${it}"
|
||||
// //7068729507
|
||||
// // OkHttp 클라이언트 객체 생성
|
||||
// val client = OkHttpClient.Builder()
|
||||
// .connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
|
||||
// .build()
|
||||
//
|
||||
// // GET 요청 객체 생성
|
||||
// val builder: Request.Builder = Request.Builder().url(url)
|
||||
// .addHeader("Content-Type", "application/json").get()
|
||||
//
|
||||
// val request: Request = builder.build()
|
||||
//
|
||||
// BLog.LOGE("telegram before request ")
|
||||
// // OkHttp 클라이언트로 GET 요청 객체 전송
|
||||
// val response: Response = client.newCall(request).execute()
|
||||
// if (response.isSuccessful()) {
|
||||
// // 응답 받아서 처리
|
||||
// val body: ResponseBody? = response.body()
|
||||
// if (body != null) {
|
||||
//
|
||||
// }
|
||||
// } else BLog.LOGE("telegram Error Occurred")
|
||||
//
|
||||
// } catch (e: java.lang.Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 5, TimeUnit.SECONDS)
|
||||
// }
|
||||
}
|
||||
addresses.forEach { }
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,9 +8,11 @@ import rasel.lunar.launcher.home.adapters.RssFeedsParser
|
||||
import rasel.lunar.launcher.utils.RssList
|
||||
|
||||
class NewsFeedsGetter : BaseGetter {
|
||||
companion object {
|
||||
val FEDDS_WORK_TAG = "NewsFeedsGetter"
|
||||
}
|
||||
var feddsUrls = arrayListOf<String>()
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
|
||||
@ -27,6 +27,7 @@ import java.util.Date
|
||||
class RecentSmsGetter : BaseGetter {
|
||||
companion object {
|
||||
var dayRange = BaseGetter.defaultDay
|
||||
val SMS_WORK_TAG = "RecentSmsGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
|
||||
@ -9,6 +9,9 @@ import rasel.lunar.launcher.home.adapters.RssFeedsParser
|
||||
import rasel.lunar.launcher.utils.RssList.feedJsons
|
||||
|
||||
class RedditGetter : BaseGetter {
|
||||
companion object{
|
||||
val REDDIT_WORK_TAG = "RedditGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class RuliWebGetter : BaseGetter {
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
.get().let { ruli ->
|
||||
BLog.LOGE("test ${testUrl2} >> ${ruli.title()}")
|
||||
// BLog.LOGE("test ${testUrl2} >> ${ruli.title()}")
|
||||
ruli.getElementsByTag("tr").forEach { ruli_tr ->
|
||||
parseRuli(ruli_tr)
|
||||
}
|
||||
|
||||
@ -99,68 +99,68 @@ class TelegramBotGetter : BaseGetter {
|
||||
var fusedLocationProviderClient: FusedLocationProviderClient? = null
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun getLastLocation(context: Context) {
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
|
||||
BLog.LOGE("Location getLastLocation")
|
||||
fusedLocationProviderClient?.getLastLocation()?.addOnSuccessListener(object : OnSuccessListener<Location?> {
|
||||
override fun onSuccess(location: Location?) {
|
||||
if (location != null) {
|
||||
// Log the latitude and longitude
|
||||
BLog.LOGE("Location Latitude: " + location.getLatitude())
|
||||
BLog.LOGE("Location Longitude: " + location.getLongitude())
|
||||
|
||||
// Use Geocoder to get detailed location information
|
||||
try {
|
||||
val geocoder = Geocoder(context, Locale.getDefault())
|
||||
val addresses: List<Address>? = geocoder.getFromLocation(
|
||||
location.getLatitude(),
|
||||
location.getLongitude(),
|
||||
1
|
||||
)
|
||||
|
||||
addresses?.first()?.let {
|
||||
it.getAddressLine(0)?.let {
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
try {
|
||||
//////-1002450229641
|
||||
val url =
|
||||
"https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&text=남편의현위치는${it}"
|
||||
//7068729507
|
||||
// OkHttp 클라이언트 객체 생성
|
||||
val client = OkHttpClient.Builder()
|
||||
.connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
|
||||
.build()
|
||||
|
||||
// GET 요청 객체 생성
|
||||
val builder: Request.Builder = Request.Builder().url(url)
|
||||
.addHeader("Content-Type", "application/json").get()
|
||||
|
||||
val request: Request = builder.build()
|
||||
|
||||
BLog.LOGE("telegram before request ")
|
||||
// OkHttp 클라이언트로 GET 요청 객체 전송
|
||||
val response: Response = client.newCall(request).execute()
|
||||
if (response.isSuccessful()) {
|
||||
// 응답 받아서 처리
|
||||
val body: ResponseBody? = response.body()
|
||||
if (body != null) {
|
||||
|
||||
}
|
||||
} else BLog.LOGE("telegram Error Occurred")
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS)
|
||||
}
|
||||
}
|
||||
// Display location details on UI elements
|
||||
// Log detailed location information
|
||||
BLog.LOGE("Location Addresses: $addresses")
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
|
||||
// BLog.LOGE("Location getLastLocation")
|
||||
// fusedLocationProviderClient?.getLastLocation()?.addOnSuccessListener(object : OnSuccessListener<Location?> {
|
||||
// override fun onSuccess(location: Location?) {
|
||||
// if (location != null) {
|
||||
// // Log the latitude and longitude
|
||||
// BLog.LOGE("Location Latitude: " + location.getLatitude())
|
||||
// BLog.LOGE("Location Longitude: " + location.getLongitude())
|
||||
//
|
||||
// // Use Geocoder to get detailed location information
|
||||
// try {
|
||||
// val geocoder = Geocoder(context, Locale.getDefault())
|
||||
// val addresses: List<Address>? = geocoder.getFromLocation(
|
||||
// location.getLatitude(),
|
||||
// location.getLongitude(),
|
||||
// 1
|
||||
// )
|
||||
//
|
||||
// addresses?.first()?.let {
|
||||
// it.getAddressLine(0)?.let {
|
||||
// Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
// try {
|
||||
// //////-1002450229641
|
||||
// val url =
|
||||
// "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&text=남편의현위치는${it}"
|
||||
// //7068729507
|
||||
// // OkHttp 클라이언트 객체 생성
|
||||
// val client = OkHttpClient.Builder()
|
||||
// .connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
|
||||
// .build()
|
||||
//
|
||||
// // GET 요청 객체 생성
|
||||
// val builder: Request.Builder = Request.Builder().url(url)
|
||||
// .addHeader("Content-Type", "application/json").get()
|
||||
//
|
||||
// val request: Request = builder.build()
|
||||
//
|
||||
// BLog.LOGE("telegram before request ")
|
||||
// // OkHttp 클라이언트로 GET 요청 객체 전송
|
||||
// val response: Response = client.newCall(request).execute()
|
||||
// if (response.isSuccessful()) {
|
||||
// // 응답 받아서 처리
|
||||
// val body: ResponseBody? = response.body()
|
||||
// if (body != null) {
|
||||
//
|
||||
// }
|
||||
// } else BLog.LOGE("telegram Error Occurred")
|
||||
//
|
||||
// } catch (e: java.lang.Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 5, TimeUnit.SECONDS)
|
||||
// }
|
||||
// }
|
||||
// // Display location details on UI elements
|
||||
// // Log detailed location information
|
||||
// BLog.LOGE("Location Addresses: $addresses")
|
||||
// } catch (e: IOException) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
@ -53,7 +53,7 @@ class TheQooGetter : BaseGetter {
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
.get().let { ruli ->
|
||||
BLog.LOGE("test ${testUrl2} >> ${ruli.title()}")
|
||||
// BLog.LOGE("test ${testUrl2} >> ${ruli.title()}")
|
||||
ruli.getElementsByTag("tr").forEach { ruli_tr ->
|
||||
parseTQoo(ruli_tr)
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import io.realm.kotlin.RealmConfiguration
|
||||
import io.realm.kotlin.UpdatePolicy
|
||||
import io.realm.kotlin.ext.query
|
||||
import io.realm.kotlin.ext.realmListOf
|
||||
import io.realm.kotlin.migration.AutomaticSchemaMigration
|
||||
import io.realm.kotlin.migration.RealmMigration
|
||||
import io.realm.kotlin.types.BaseRealmObject
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import io.realm.kotlin.types.RealmObject
|
||||
@ -23,6 +25,7 @@ import rasel.lunar.launcher.model.Forecast
|
||||
import rasel.lunar.launcher.model.Forecastday
|
||||
import rasel.lunar.launcher.model.Hour
|
||||
import rasel.lunar.launcher.model.Location
|
||||
import rasel.lunar.launcher.model.LocationLog
|
||||
import rasel.lunar.launcher.model.NotificationItem
|
||||
import rasel.lunar.launcher.model.RssData
|
||||
import rasel.lunar.launcher.model.RssDataInterface
|
||||
@ -32,23 +35,34 @@ import rasel.lunar.launcher.model.TelegramData
|
||||
import rasel.lunar.launcher.model.TelegramFrom
|
||||
import rasel.lunar.launcher.model.TelegramMessage
|
||||
import rasel.lunar.launcher.model.WeatherForcast
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class CustMigration : AutomaticSchemaMigration {
|
||||
override fun migrate(migrationContext: AutomaticSchemaMigration.MigrationContext) {
|
||||
BLog.LOGE(migrationContext.oldRealm.configuration.schemaVersion.toString())
|
||||
|
||||
BLog.LOGE(migrationContext.newRealm.configuration.schemaVersion.toString())
|
||||
|
||||
}
|
||||
}
|
||||
object WorkersDb {
|
||||
|
||||
|
||||
|
||||
val clazz : Set<KClass<out BaseRealmObject>> = 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
|
||||
)
|
||||
WeatherForcast::class, Location::class, Current::class, Forecast::class, Condition::class, Forecastday::class, Day::class, Astro::class, Hour::class,
|
||||
LocationLog::class
|
||||
)
|
||||
|
||||
val schemaVersion : Long = 0L
|
||||
|
||||
private var pRealm : Realm? = null
|
||||
fun getRealm() : Realm {
|
||||
if (pRealm == null) {
|
||||
if (pRealm == null || pRealm?.isClosed() == true) {
|
||||
pRealm = Realm.open(RealmConfiguration.Builder(clazz as Set<KClass<out TypedRealmObject>>)
|
||||
.migration(CustMigration(),true)
|
||||
.schemaVersion(schemaVersion)
|
||||
.deleteRealmIfMigrationNeeded()
|
||||
.build())
|
||||
@ -159,4 +173,14 @@ object WorkersDb {
|
||||
}
|
||||
}
|
||||
|
||||
fun push(loc: LocationLog) {
|
||||
getRealm().writeBlocking {
|
||||
try {
|
||||
this.copyToRealm(loc, UpdatePolicy.ALL)
|
||||
} catch (e : Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,6 +14,9 @@ import rasel.lunar.launcher.model.others.Youtube
|
||||
import rasel.lunar.launcher.utils.RssList
|
||||
|
||||
class YoutubeGetter : BaseGetter {
|
||||
companion object {
|
||||
val YT_WORK_TAG = "YoutubeGetter"
|
||||
}
|
||||
var rssUrls = arrayListOf<String>()
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
|
||||
15
app/src/main/res/layout/feeds_result_menu.xml
Normal file
15
app/src/main/res/layout/feeds_result_menu.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:padding="@dimen/twelve"
|
||||
android:clickable="true"
|
||||
android:focusableInTouchMode="true">
|
||||
<TextView
|
||||
android:id="@+id/logs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -18,9 +18,8 @@
|
||||
android:id="@+id/input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword" />
|
||||
android:inputType="text" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
x
Reference in New Issue
Block a user