diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 70a20eb8..bb8c208c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -63,6 +63,7 @@ android:theme="@style/Theme.LunarLauncher.Starting" android:launchMode="singleInstance" android:screenOrientation="portrait" + android:excludeFromRecents="true" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|screenLayout|layoutDirection" android:windowSoftInputMode="adjustResize" android:exported="true"> diff --git a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt index ea3ff8f6..c4515a4c 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/LauncherActivity.kt @@ -32,16 +32,15 @@ import android.net.Uri import android.net.http.SslError import android.os.Build import android.os.Bundle -import android.provider.CallLog -import android.provider.ContactsContract import android.provider.Settings import android.telephony.TelephonyManager -import android.util.Log import android.view.View import android.view.WindowInsets import android.view.WindowManager import android.webkit.JavascriptInterface import android.webkit.SslErrorHandler +import android.webkit.WebResourceError +import android.webkit.WebResourceRequest import android.webkit.WebSettings import android.webkit.WebView import android.webkit.WebViewClient @@ -83,12 +82,21 @@ import rasel.lunar.launcher.home.LauncherHome import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl import rasel.lunar.launcher.home.LauncherHome.Companion.listItem import rasel.lunar.launcher.home.LauncherHome.Companion.listTags +import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet import rasel.lunar.launcher.home.RssItem import rasel.lunar.launcher.home.RssTagItem import rasel.lunar.launcher.utils.BLog +import rasel.lunar.launcher.utils.ComicsGetter +import rasel.lunar.launcher.utils.ComicsGetter2 import rasel.lunar.launcher.utils.MissedCallGetter import rasel.lunar.launcher.utils.NewsFeedsGetter import rasel.lunar.launcher.utils.RecentSmsGetter +import rasel.lunar.launcher.utils.RedditGetter +import rasel.lunar.launcher.utils.RssList.jGuruMain +import rasel.lunar.launcher.utils.RssList.jGuruRanks +import rasel.lunar.launcher.utils.YoutubeGetter +import rasel.lunar.launcher.utils.beforeDay +import rasel.lunar.launcher.utils.make0H import java.text.SimpleDateFormat import java.util.Date import java.util.Locale @@ -103,15 +111,21 @@ internal class LauncherActivity : AppCompatActivity() { lateinit var viewPager: ViewPager2 companion object { - val TEST_PAG = "https://jav.guru/" + private var mWorkManager: WorkManager? = null - val TEST_PAG2 = "https://torrentsee246.com/topic/index?category1=129&category2=132" 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 = 60L + val longTimePeriod = 60L + val midTimePeriod = 60L var isOpendFold = false + var rssSetTouchCount = 0 @JvmStatic var lActivity: LauncherActivity? = null @JvmStatic var appWidgetManager: AppWidgetManager? = null @@ -122,7 +136,7 @@ internal class LauncherActivity : AppCompatActivity() { mWorkManager?.enqueueUniquePeriodicWork( SMS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(30, TimeUnit.MINUTES) + PeriodicWorkRequestBuilder(longTimePeriod, TimeUnit.MINUTES) .addTag(SMS_WORK_TAG) .build()) }, 2, TimeUnit.SECONDS) @@ -133,7 +147,7 @@ internal class LauncherActivity : AppCompatActivity() { mWorkManager?.enqueueUniquePeriodicWork( CALL_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(30, TimeUnit.MINUTES) + PeriodicWorkRequestBuilder(longTimePeriod, TimeUnit.MINUTES) .addTag(CALL_WORK_TAG) .build()) }, 2, TimeUnit.SECONDS) @@ -143,12 +157,53 @@ internal class LauncherActivity : AppCompatActivity() { mWorkManager?.cancelAllWorkByTag(FEDDS_WORK_TAG) mWorkManager?.enqueueUniquePeriodicWork( FEDDS_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, - PeriodicWorkRequestBuilder(30, TimeUnit.MINUTES) + PeriodicWorkRequestBuilder(shortTimePeriod, TimeUnit.MINUTES) .addTag(FEDDS_WORK_TAG) .build()) }, 2, TimeUnit.SECONDS) } + fun refreshYoutube() { + Executors.newSingleThreadScheduledExecutor().schedule({ + mWorkManager?.cancelAllWorkByTag(YT_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + YT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(longTimePeriod, TimeUnit.MINUTES) + .addTag(YT_WORK_TAG) + .build()) + }, 2, TimeUnit.SECONDS) + } + fun refreshReddit() { + Executors.newSingleThreadScheduledExecutor().schedule({ + mWorkManager?.cancelAllWorkByTag(REDDIT_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + REDDIT_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(midTimePeriod, TimeUnit.MINUTES) + .addTag(REDDIT_WORK_TAG) + .build()) + }, 2, TimeUnit.SECONDS) + } + fun refreshComics() { + Executors.newSingleThreadScheduledExecutor().schedule({ + mWorkManager?.cancelAllWorkByTag(COMIC_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + COMIC_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(shortTimePeriod, TimeUnit.MINUTES) + .addTag(COMIC_WORK_TAG) + .build()) + refreshComics2() + }, 2, TimeUnit.SECONDS) + } + fun refreshComics2() { + Executors.newSingleThreadScheduledExecutor().schedule({ + mWorkManager?.cancelAllWorkByTag(COMIC2_WORK_TAG) + mWorkManager?.enqueueUniquePeriodicWork( + COMIC2_WORK_TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE, + PeriodicWorkRequestBuilder(shortTimePeriod, TimeUnit.MINUTES) + .addTag(COMIC2_WORK_TAG) + .build()) + }, 2, TimeUnit.SECONDS) + } fun workmanager() : WorkManager? { if (mWorkManager == null && lActivity != null) { mWorkManager = WorkManager.getInstance(lActivity!!) @@ -213,6 +268,9 @@ internal class LauncherActivity : AppCompatActivity() { refreshSms() refreshCalls() refreshFeeds() + refreshYoutube() + refreshReddit() + refreshComics() } override fun onDestroy() { @@ -225,6 +283,12 @@ internal class LauncherActivity : AppCompatActivity() { BLog.LOGE("LauncherActivity onStart()") statusBarView() setBgColor() + + if (listItem.size < 2) { + lActivity?.doWebParseStart(jGuruRanks) { + + } + } } override fun onResume() { super.onResume() @@ -398,15 +462,28 @@ internal class LauncherActivity : AppCompatActivity() { } var callBack : (()->Unit)? = null - fun doWebPare(url : String, callBack : (()->Unit)?) { + fun doWebParseStart(url : String, callBack : (()->Unit)?) { this.callBack = callBack + binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE } BLog.LOGE("binding.otherCheck before ThreadRun") binding.searcher01.webViewClient = object : WebViewClient() { + + override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { + view?.loadUrl(url!!) + 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? + ) { + super.onReceivedError(view, request, error) + } override fun onReceivedSslError( view: WebView?, handler: SslErrorHandler?, @@ -432,6 +509,7 @@ internal class LauncherActivity : AppCompatActivity() { } } } else { + //if (url?.contains("guru", true) == true) view?.evaluateJavascript( "function getAll() {\n" + " MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" + @@ -443,15 +521,22 @@ internal class LauncherActivity : AppCompatActivity() { } } callBack?.invoke() + binding.searcher01.post { binding.searcher01.visibility = View.GONE } + } } WebView.setWebContentsDebuggingEnabled(false) binding.searcher01.apply { +// Jsoup.connect("https://missav.com/dm11/ko").userAgent() +// .timeout(30000).get()?.apply { +// BLog.LOGE("Jsoup.connect(missAv).get() ${this}") +// } this.addJavascriptInterface(MyJavaScriptInterface(this),"MyJavaScriptInterface") 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 // 화면에 맞게 페이지 확대/축소 @@ -471,13 +556,47 @@ internal class LauncherActivity : AppCompatActivity() { var maxDate : Long = Long.MIN_VALUE var minDate : Long = Long.MAX_VALUE - val triple = 1000L * 60L * 60L * 24L * 3L + val triple = 1000L * 60L * 60L * 24L * 2L val simpldateFormat = SimpleDateFormat("d MMM, yy", Locale.US) + fun jGuruToday(doc: Document) { + doc.getElementsByTag("li").forEach { + if (it.getElementsByTag("img").size > 0) { + var title = it.getElementsByTag("a").get(0).attr("title") + var model = title.replace("[", "").split("]")[0] + var pageLink = it.getElementsByTag("a").get(0).attr("href") + var imgg = it.getElementsByTag("img").get(0).attr("src") + var actor = if (it.getElementsByClass("wpptax").size > 0 )it.getElementsByClass("wpptax").get(0).text() else "" + if (pageLink.length > 0 && imgg.length > 0 && title.length > 0 && model.length > 0) { + listItem.add( + RssItem( + model = model, + title = title, + pageLink = pageLink, + image = imgg, + tags = actor, + date = beforeDay(Date(),3) + 360000 + ) + ) + } + } + }.apply { + this@LauncherActivity.callBack?.invoke() + var idx = 0 + listItem?.forEach { + if(it.date > beforeDay(Date(),3) && idx < 10) { + it.date = it.date + (10000L * idx) + rssSet.put(it.pageLink,it) + idx += 1 + } + } + Toast.makeText(this@LauncherActivity, + "Stored rank data", Toast.LENGTH_LONG).show() + binding.searcher01?.post { binding.searcher01.loadUrl(jGuruMain) } + } + } fun jGuruMain(doc: Document) { -// BLog.LOGE("do default parsing") // BLog.LOGE("SimpleDateFormat D MM yy => ${SimpleDateFormat("d MMM yy", Locale.US).format(Date())}") val prevUrl = doc.getElementsByClass("prev").get(0).getElementsByAttribute("href").get(0).attr("href") -// BLog.LOGE("doc.getElementsByClass(prev).get(0).html() ${prevUrl}") doc.getElementsByClass("column").forEach { var title = it.getElementsByAttribute("title").get(0).text() var model = title.replace("[","").split("]")[0] @@ -486,21 +605,30 @@ internal class LauncherActivity : AppCompatActivity() { var tags = it.getElementsByClass("tags").get(0).text() var date = it.getElementsByClass("date").get(0).text() var regDate = simpldateFormat.parse(date).time + minDate = Math.min(minDate,regDate) maxDate = Math.max(maxDate,regDate) - listItem.add(RssItem(model = model, title = title, pageLink = pageLink, image = imgg, tags = tags, date = simpldateFormat.parse(date).time)) + listItem.add(RssItem(model = model, title = title, pageLink = pageLink, image = imgg, tags = tags, date = make0H(simpldateFormat.parse(date)))) }.apply { - - BLog.LOGE("listItem.size >>> ${listItem.size}") - if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && ((maxDate - minDate) < triple)) { +// if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && ((maxDate - minDate) < triple)) { +// listItem.sortByDescending { it.date } +// binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L) +//// } else { + var itemC = 0 listItem.sortByDescending { it.date } - binding.searcher01.postDelayed({binding.searcher01.loadUrl(prevUrl)}, 5000L) - } else { - listItem.sortByDescending { it.date } - BLog.LOGE("Stored data :: ${listItem.size}items ${simpldateFormat.format(Date(minDate))} ~ ${simpldateFormat.format(Date(maxDate))}") + listItem?.forEach { + if(it.date > beforeDay(Date(),1)) { + if (itemC < 10) { + it.date = it.date + (10000L * itemC) + rssSet.put(it.pageLink, it) + } + itemC = itemC + 1 + } + } + BLog.LOGE("Stored data :: ${listItem.size}items ${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))}]", 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() +// } this@LauncherActivity.callBack?.invoke() } } @@ -532,20 +660,25 @@ internal class LauncherActivity : AppCompatActivity() { @JavascriptInterface fun sendValueFromHtml(result: String) { - if (lastedFinishedPageUrl.contains(TEST_PAG)) { + if (lastedFinishedPageUrl.contains(jGuruMain)) { var htmlString = result.replace("\\u003","<") val doc: Document = Jsoup.parse(htmlString) if (lastedFinishedPageUrl?.contains("page") == true || lastedFinishedPageUrl?.equals( - TEST_PAG + 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) { + val doc: Document = Jsoup.parse(result) + BLog.LOGE("missav >>> ${doc}") } BLog.LOGE("binding.otherCheck after ThreadRun") } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt index 3cad22ba..0b11aef1 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt @@ -124,6 +124,9 @@ internal class AppDrawer : Fragment() { binding.searchNmap.setOnClickListener { openSearchApps("nmap://search?query=${getInputText()}&appname=${BuildConfig.APPLICATION_ID}","com.nhn.android.nmap") } + binding.searchYoutube.setOnClickListener { + openSearchApps("https://www.youtube.com/results?search_query=${getInputText()}","com.google.android.youtube") + } binding.searchGoogleMap.setOnClickListener { openSearchApps("geo:0,0?q=${getInputText()}","com.google.android.apps.maps") } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt index 3a5359e6..6edae365 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt @@ -18,7 +18,6 @@ package rasel.lunar.launcher.feeds -import android.R.attr.* import android.app.Activity.RESULT_CANCELED import android.app.Activity.RESULT_OK import android.appwidget.AppWidgetManager @@ -36,13 +35,10 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle -import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.button.MaterialButtonToggleGroup import kotlinx.coroutines.* -import rasel.lunar.launcher.LauncherActivity.Companion.TEST_PAG import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetHost import rasel.lunar.launcher.LauncherActivity.Companion.appWidgetManager -import rasel.lunar.launcher.LauncherActivity.Companion.isOpendFold import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.R import rasel.lunar.launcher.databinding.FeedsBinding @@ -57,6 +53,7 @@ import rasel.lunar.launcher.home.LauncherHome.Companion.listItem import rasel.lunar.launcher.home.LauncherHome.Companion.listTags import rasel.lunar.launcher.home.RssItem import rasel.lunar.launcher.home.RssTagItem +import rasel.lunar.launcher.utils.RssList.jGuruMain import java.util.* @@ -162,7 +159,7 @@ internal class Feeds : Fragment() { refresh.visibility = View.VISIBLE rss.visibility = View.GONE refresh.setOnClickListener { - lActivity?.doWebPare(TEST_PAG) { + var call = { if (listItem.size > 0) { rss?.postDelayed( { mRssAdapter?.updateData(listItem) @@ -172,6 +169,7 @@ internal class Feeds : Fragment() { },500L) } } + } } } @@ -192,7 +190,7 @@ internal class Feeds : Fragment() { refresh.visibility = View.VISIBLE rss2.visibility = View.GONE refresh.setOnClickListener { - lActivity?.doWebPare(TEST_PAG.plus("tags")) { + lActivity?.doWebParseStart(jGuruMain.plus("tags")) { if (listTags.size > 0) { rss2?.postDelayed( { mRssAdapter2?.updateData(listTags) diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt index d208326e..e5d1064d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -39,14 +39,22 @@ import androidx.core.content.ContextCompat.RECEIVER_EXPORTED import androidx.core.content.ContextCompat.registerReceiver import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager +import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import com.google.gson.Gson +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import org.json.JSONArray import org.json.JSONObject +import org.jsoup.Jsoup 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.lActivity +import rasel.lunar.launcher.LauncherActivity.Companion.refreshComics +import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds +import rasel.lunar.launcher.LauncherActivity.Companion.refreshReddit +import rasel.lunar.launcher.LauncherActivity.Companion.refreshYoutube import rasel.lunar.launcher.LauncherActivity.Companion.workmanager import rasel.lunar.launcher.R import rasel.lunar.launcher.databinding.LauncherHomeBinding @@ -76,6 +84,8 @@ import rasel.lunar.launcher.utils.beforeDay import java.util.Calendar import java.util.Date import java.util.Locale +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit internal class LauncherHome : Fragment() { @@ -98,7 +108,6 @@ internal class LauncherHome : Fragment() { var rssList = arrayListOf() - } private var nReceiver: NotificationReceiver? = null @@ -139,15 +148,20 @@ internal class LauncherHome : Fragment() { batteryReceiver = BatteryReceiver(binding.batteryProgress) mMissedCallsAdapter = MissedCallsAdapter(callList, requireContext()) mSmsLogsAdapter = SmsLogsAdapter(smsList, requireContext()) - mRssAdapter = RssItemAdapter(rssList, requireContext()) + mRssAdapter = RssItemAdapter(requireContext()) binding.mainList.adapter = mMissedCallsAdapter binding.smsList.adapter = mSmsLogsAdapter binding.infoList.adapter = mRssAdapter + val decoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + binding.mainList.addItemDecoration(decoration) + binding.smsList.addItemDecoration(decoration) + binding.infoList.addItemDecoration(decoration) binding.missedCalls.isChecked = true binding.smsList.visibility = View.GONE binding.infoList.visibility = View.GONE binding.favAppsGroup.visibility = View.GONE + binding.mainList.layoutManager = LinearLayoutManager(requireContext()) binding.smsList.layoutManager = LinearLayoutManager(requireContext()) binding.infoList.layoutManager = LinearLayoutManager(requireContext()) @@ -223,11 +237,26 @@ internal class LauncherHome : Fragment() { chooseAdpater() } -// binding.otherCheck.setOnLongClickListener { -// listItem.clear() -// lActivity?.doWebPare(TEST_PAG, null) -// true -// } + binding.otherCheck.setOnLongClickListener { + synchronized(rssSet) { + val now = Date() + var keys = arrayListOf() + rssSet.forEach { t, u -> + if (u.pubDate() <= beforeDay(now,3)) { + keys.add(t) + } + }.apply { + keys.forEach { rssSet.remove(it) } + }.apply { + refreshYoutube() + refreshComics() + refreshFeeds() + refreshReddit() + } + } + true + } + // binding.summaryChoose.setOnCheckedChangeListener { group, checkedId -> // chooseAdpater() // } @@ -236,7 +265,7 @@ internal class LauncherHome : Fragment() { //// lActivity?.sendBroadcast(i) //// BLog.LOGE("intent >>> ${i.action}") } - +// https://www.youtube.com/results?search_query=sds fun chooseAdpater () { @@ -252,8 +281,8 @@ internal class LauncherHome : Fragment() { }.apply { callList.sortByDescending { it.date } Handler(Looper.getMainLooper()).post { - mMissedCallsAdapter.updateData(callList) binding.mainList.visibility = View.VISIBLE + mMissedCallsAdapter.updateData(callList) } } } catch (e : Exception) { @@ -265,8 +294,8 @@ internal class LauncherHome : Fragment() { smsList.sortByDescending { it.rcvDate } binding.smsList.visibility = View.VISIBLE Handler(Looper.getMainLooper()).post { - mSmsLogsAdapter.updateData(smsList) binding.smsList.visibility = View.VISIBLE + mSmsLogsAdapter.updateData(smsList) } } catch (e : Exception) { @@ -274,19 +303,26 @@ internal class LauncherHome : Fragment() { } } else if(binding.otherCheck.isChecked) { try { - rssList.clear() - rssSet.forEach { k,v -> - if(v.pubDate() > beforeDay(Date(),3)) { - rssList.add(v) - } else { - rssSet.remove(k,v) - } - }.apply { - rssList.sortByDescending{ it.pubDate() } - binding.infoList.visibility = View.VISIBLE - Handler(Looper.getMainLooper()).post { - mRssAdapter.updateData(rssList) - binding.infoList.visibility = View.VISIBLE + GlobalScope.launch { + (rssSet.clone() as? HashMap)?.let { temMap -> + synchronized(binding.infoList) { + var tempList = arrayListOf() + temMap.forEach { k,v -> + if(v.pubDate() > beforeDay(Date(),3)) { + tempList.add(v) + } else { + + } + }.apply { + tempList.sortByDescending { it.pubDate() } + rssList.clear() + rssList.addAll(tempList) + Handler(Looper.getMainLooper()).post { + binding.infoList.visibility = View.VISIBLE + mRssAdapter.updateData(rssList) + } + } + } } } }catch (e : Exception){} @@ -311,6 +347,7 @@ internal class LauncherHome : Fragment() { /* show weather */ WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather) } + } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/Reddit.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/Reddit.kt index cd76ff4a..8cf9d9ea 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/model/Reddit.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/Reddit.kt @@ -4,6 +4,8 @@ import rasel.lunar.launcher.todos.Image import rasel.lunar.launcher.todos.RssDataItem import rasel.lunar.launcher.todos.RssDataType import rasel.lunar.launcher.todos.Source +import rasel.lunar.launcher.utils.beforeDay +import java.sql.Date class Reddit { @@ -255,6 +257,9 @@ class Data : RssDataItem { } override fun originPage(): String { + if (post_hint?.contains("video") == true && (permalink?.length ?: 0 > 3)) { + return "https://www.reddit.com".plus(permalink) + } return url ?: "" } @@ -263,6 +268,7 @@ class Data : RssDataItem { } override fun pubDate(): Long { +// return beforeDay(java.util.Date(),2) if (created_utc != null) { return created_utc!!.toLong() * 1000L } else if (created != null) { diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt index b5eba46e..9118f3bc 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssDataItem.kt @@ -7,6 +7,8 @@ enum class RssDataType { GURU, TAGS, REDDIT, + Dotax, + FmKorae, } interface RssDataItem { diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssFeedsParser.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssFeedsParser.kt index 481ab836..6f416fa2 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssFeedsParser.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssFeedsParser.kt @@ -41,8 +41,8 @@ object RssFeedsParser { // BLog.LOGE("getReddit >>>>> link ${URLDecoder.decode(url,"utf-8")} , itemSize = ${Gson().toJson(it)}") if(((it.data?.created_utc ?: 0).toLong() * 1000L > dateTime)) { // BLog.LOGE("getReddit >>>>> link ${URLDecoder.decode(url,"utf-8")} , itemSize = ${Gson().toJson(it)}") - (it.data as? RssDataItem)?.let { - returnList.add(it) + (it.data as? RssDataItem)?.let { rss -> + returnList.add(rss) } } } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt index 63bdb8cc..0aa837e8 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt @@ -19,63 +19,54 @@ package rasel.lunar.launcher.todos import android.annotation.SuppressLint -import android.content.ClipData -import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.net.Uri -import android.text.Html import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.core.content.ContextCompat.startActivity +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.net.toUri import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView -import com.google.gson.Gson import com.squareup.picasso.Picasso import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.R -import rasel.lunar.launcher.databinding.ListItemBinding import rasel.lunar.launcher.databinding.ListItemWithBinding import rasel.lunar.launcher.home.RssItem -import rasel.lunar.launcher.home.RssTagItem -import rasel.lunar.launcher.utils.BLog -import rasel.lunar.launcher.utils.Hashids -import rasel.lunar.launcher.utils.RecentSmsLog import java.text.SimpleDateFormat import java.util.Date internal class RssItemAdapter ( - private val smsList: ArrayList, private val context: Context) : RecyclerView.Adapter() { - + private var rssDataItemLis: ArrayList = arrayListOf() override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): RssTag { val binding = ListItemWithBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false) return RssTag(binding) } override fun getItemCount(): Int { - return smsList.size + return rssDataItemLis.size } val dateFormat = SimpleDateFormat("hh:mm / yy - MM - dd") @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: RssTag, position: Int) { - val todo = smsList[position] + val todo = rssDataItemLis[position] holder.view.date.text = "${dateFormat.format(Date(todo.pubDate()))}" // holder.view.desc.visibility = View.GONE - + holder.view.date.setOnClickListener { } when(todo.category()) { RssDataType.YOUTUBE -> { if(todo.thumbnailUrl()?.length ?: 0 > 6) { Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview) holder.view.circlePreview.visibility = View.VISIBLE } + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,280) holder.view.title.text = "${todo.title()}" holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT) @@ -83,15 +74,30 @@ internal class RssItemAdapter ( holder.view.desc.visibility = View.VISIBLE 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.setOnLongClickListener { + + openYouTube(todo.originPage()) + + true + } } RssDataType.NewsFeed -> { - holder.view.desc.text = "" + holder.view.desc.text = todo.category().name holder.view.circlePreview.visibility = View.GONE holder.view.title.text = if(todo.title().length > 30)todo.title().substring(0,30).plus("...") else todo.title() - holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.LEFT) - holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.LEFT) + holder.view.title.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.root.setOnClickListener { openNews(todo.originPage()) } + holder.view.root.setOnClickListener { + + } + holder.view.root.setOnLongClickListener { + openNews(todo.originPage()) + true + } } RssDataType.NO_DATA -> {} else -> { @@ -102,45 +108,85 @@ internal class RssItemAdapter ( if (todo.pubDate() > 1000L) { holder.view.date.text = dateFormat.format(Date(todo.pubDate())) } + + if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU)) { + holder.view.circlePreview.visibility = View.GONE + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,360) + } else if( todo.category().equals(RssDataType.Dotax)) { + holder.view.circlePreview.setImageResource(R.drawable.daum) + holder.view.circlePreview.visibility = View.VISIBLE + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) + } else if( todo.category().equals(RssDataType.REDDIT)) { + holder.view.circlePreview.setImageResource(R.drawable.reddit) + holder.view.circlePreview.visibility = View.VISIBLE + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) + } else if( todo.category().equals(RssDataType.FmKorae)) { + holder.view.circlePreview.setImageResource(R.drawable.fmk) + holder.view.circlePreview.visibility = View.VISIBLE + holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,120) + } + if(todo.thumbnailUrl()?.length ?: 0 > 6) { Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview) } - holder.view.circlePreview.visibility = View.GONE - holder.view.desc.text = todo.description() + + holder.view.desc.text = todo.description().plus(" ").plus(todo.category().name) holder.view.desc.visibility = View.VISIBLE holder.view.date.visibility = View.VISIBLE - holder.view.root.setOnClickListener { +// holder.view.date.setOnTouchListener { v,e -> +// if (holder.view.date.equals(v)) { +// when(e.action) { +// MotionEvent.ACTION_DOWN -> {holder.view.circlePreview.visibility = View.VISIBLE} +// MotionEvent.ACTION_UP -> {holder.view.circlePreview.visibility = View.GONE} +// MotionEvent.ACTION_UP -> {holder.view.circlePreview.visibility = View.GONE} +// } +// } +// false +// } + + holder.view.date.setOnClickListener { holder.view.circlePreview.visibility = View.VISIBLE holder.view.circlePreview.postDelayed({ holder.view.circlePreview.visibility = View.GONE - },500L) + },1000L) + } + holder.view.root.setOnLongClickListener { + if ( todo.category().equals(RssDataType.GURU)) { + openOpera(todo.originPage()) + } else if( todo.category().equals(RssDataType.REDDIT)) { + openReddit(todo.originPage()) + } else if( todo.category().equals(RssDataType.Dotax)) { + openDotax(todo.originPage()) + }else if( todo.category().equals(RssDataType.FmKorae)) { + openNews(todo.originPage()) + } + true } } } - - holder.view.root.setOnLongClickListener { - when(todo.category()) { - RssDataType.YOUTUBE -> { - openYouTube(todo.originPage()) - } - RssDataType.NewsFeed -> { - openNews(todo.originPage()) - } - RssDataType.NO_DATA -> {} - else -> { - - } - } -// val clipBoard = -// lActivity!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager -// clipBoard.setPrimaryClip(ClipData.newPlainText("", todo.thumbnailUrl())) - true - } - } + fun openOpera(schemeString : String) { + val gmmIntentUri = Uri.parse(schemeString) + val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) + mapIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) + mapIntent.setPackage("com.opera.browser") + lActivity?.startActivity(mapIntent) + } + + fun updateData(newList: List) { - DiffUtil.calculateDiff(RssItemDiffUtil(smsList, newList)).dispatchUpdatesTo(this) + try { + DiffUtil.calculateDiff(RssItemDiffUtil(rssDataItemLis, newList)).apply { + + }.dispatchUpdatesTo(this).apply { + notifyItemRangeChanged(0,10) + } + rssDataItemLis.clear() + rssDataItemLis.addAll(newList) + }catch ( e : Exception) { + e.printStackTrace() + } } fun openNews(schemeString : String) { val gmmIntentUri = Uri.parse(schemeString) @@ -156,18 +202,41 @@ internal class RssItemAdapter ( mapIntent.setPackage("com.google.android.youtube") lActivity?.startActivity(mapIntent) } + + fun openReddit(schemeString : String) { + val gmmIntentUri = Uri.parse(schemeString) + val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) + mapIntent.setPackage("com.reddit.frontpage") + lActivity?.startActivity(mapIntent) + } + + fun openDotax(schemeString : String) { + val gmmIntentUri = Uri.parse(schemeString) + val mapIntent = Intent(Intent.ACTION_VIEW) + mapIntent.setPackage("net.daum.android.cafe") + mapIntent.setData(gmmIntentUri) + lActivity?.startActivity(mapIntent) + } } + +//fun dp2px(dp: Float): Float { +// val resources: Resources = this.getResources() +// val metrics = resources.displayMetrics +// val px = dp * (metrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT) +// return px +//} + internal class RssTag(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root) internal class RssItemDiffUtil( - private val oldList: List, private val newList: List + var oldList: List, var newList: List ) : DiffUtil.Callback() { override fun getOldListSize(): Int = oldList.size override fun getNewListSize(): Int = newList.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = - oldList[oldItemPosition].originPage() == newList[newItemPosition].originPage() + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition].originPage() == if (newList.size > newItemPosition) newList[newItemPosition].originPage() else "" override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = - oldList[oldItemPosition].originPage() == newList[newItemPosition].originPage() + oldList[oldItemPosition].originPage() == if (newList.size > newItemPosition) newList[newItemPosition].originPage() else "" } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt b/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt index 87e586d3..13ba6c70 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt @@ -15,13 +15,16 @@ import org.json.JSONObject import org.jsoup.Jsoup import org.jsoup.nodes.Document import rasel.lunar.launcher.LauncherActivity.Companion.lActivity +import rasel.lunar.launcher.LauncherActivity.Companion.rssSetTouchCount import rasel.lunar.launcher.home.LauncherHome.Companion.missedCalls import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet import rasel.lunar.launcher.home.LauncherHome.Companion.smsList import rasel.lunar.launcher.home.MissedCall +import rasel.lunar.launcher.home.RssItem import rasel.lunar.launcher.todos.Root import rasel.lunar.launcher.todos.RssDataItem +import rasel.lunar.launcher.todos.RssDataType import rasel.lunar.launcher.todos.RssFeedsParser import rasel.lunar.launcher.utils.RssList.feedJsons import java.io.BufferedReader @@ -131,6 +134,13 @@ class MissedCallGetter : Worker { } +fun before30Min(date: Date): Long { + val cal: Calendar = Calendar.getInstance() + cal.setTime(date) + cal.add(Calendar.MINUTE, -30) + return cal.timeInMillis +} + fun beforeDay(date: Date?, day: Int): Long { val cal: Calendar = Calendar.getInstance() cal.setTime(date) @@ -138,6 +148,13 @@ fun beforeDay(date: Date?, day: Int): Long { return cal.timeInMillis } +fun make0H(date: Date?): Long { + val cal: Calendar = Calendar.getInstance() + cal.setTime(date) + cal.set(Calendar.HOUR, 1) + return cal.timeInMillis +} + fun afterDay(date: Date?, day: Int): Long { val cal: Calendar = Calendar.getInstance() cal.setTime(date) @@ -487,9 +504,65 @@ fun getContactId(contentResolver: ContentResolver, phoneNumber: String?): String return contactName } - class NewsFeedsGetter : Worker { var feddsUrls = arrayListOf() + + var limitDateTime = beforeDay(Date(),3) + constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { + + } + + @SuppressLint("RestrictedApi") + override fun doWork(): Result { + rssSetTouchCount += 1 + val temp = arrayListOf() + feddsUrls.clear() + feddsUrls.addAll(RssList.newsFeeds) + feddsUrls.addAll(RssList.getFeedUrls()) + + for(url in feddsUrls) { + for (it in RssFeedsParser.getFeeds(url)) { + if (it.pubDate() >= limitDateTime) { + temp.add(it) + } + } + } + + + return temp.forEach { synchronized(rssSet){ + rssSet.put(it.originPage(), it) + } }.run { + rssSetTouchCount -= 1 + Result.success() } + } + + +} +class RedditGetter : Worker { + var limitDateTime = beforeDay(Date(),3) + constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { + + } + + @SuppressLint("RestrictedApi") + override fun doWork(): Result { + rssSetTouchCount += 1 + val temp = arrayListOf() + for (url in feedJsons) { + for (it in RssFeedsParser.getReddit(url)) { + if (it.pubDate() >= limitDateTime) { + temp.add(it) + } + } + } + return temp.forEach { synchronized(rssSet){ + rssSet.put(it.originPage(), it) + } }.run { + rssSetTouchCount -= 1 + Result.success() } + } +} +class YoutubeGetter : Worker { var rssUrls = arrayListOf() var limitDateTime = beforeDay(Date(),3) constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { @@ -498,30 +571,19 @@ class NewsFeedsGetter : Worker { @SuppressLint("RestrictedApi") override fun doWork(): Result { - feddsUrls.clear() - feddsUrls.addAll(RssList.newsFeeds) - feddsUrls.addAll(RssList.getFeedUrls()) + rssSetTouchCount += 1 rssUrls.clear() rssUrls.addAll(RssList.youtubeUrls) - + val temp = arrayListOf() for (url in rssUrls) { ytChannel(Jsoup.connect(url).get()) } - for(url in feddsUrls) { - for (it in RssFeedsParser.getFeeds(url)) { - if (it.pubDate() >= limitDateTime) { - rssSet.put(it.originPage(), it) - } - } - } - for (url in feedJsons) { - for (it in RssFeedsParser.getReddit(url)) { - if (it.pubDate() >= limitDateTime) { - rssSet.put(it.originPage(), it) - } - } - } - return Result.success() + + return temp.forEach { synchronized(rssSet){ + rssSet.put(it.originPage(), it) + } }.run { + rssSetTouchCount -= 1 + Result.success() } } fun ytChannel(doc: Document) { @@ -571,4 +633,193 @@ class NewsFeedsGetter : Worker { } } } +class ComicsGetter : Worker { + var limitDateTime = beforeDay(Date(),3) + constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { + } + + @SuppressLint("RestrictedApi") + override fun doWork(): Result { + rssSetTouchCount += 1 + val temp = arrayListOf() + val now = Date() + try { + val fmkoreaUrls = arrayListOf("https://www.fmkorea.com", +// "https://www.fmkorea.com/index.php?mid=best&page=2", +// "https://www.fmkorea.com/index.php?mid=best&page=3" + ) + fmkoreaUrls.forEach { Jsoup.connect(it).get().let { fmkorea -> +// BLog.LOGE("fmkorea >>> ${fmkorea.title()}") + fmkorea.getElementsByTag("li").forEach { fmkorea_li -> + if (fmkorea_li.getElementsByClass("title").text().length > 0 && fmkorea_li.getElementsByTag("a").size > 0 &&fmkorea_li.getElementsByTag("a").get(0).attr("href").length > 0) { +// BLog.LOGE("fmkorea_li >>> ${fmkorea_li}") + val title = fmkorea_li.getElementsByClass("title").text() + val tumb = "https://".plus( + fmkorea_li.getElementsByClass("thumb").attr("data-original") + ) + val pageUrl = "https://www.fmkorea.com".plus( + fmkorea_li.getElementsByTag("a").get(0).attr("href") + ) + val desc = fmkorea_li.getElementsByClass("category").text() + val date = fmkorea_li.getElementsByClass("regdate").text() + FmKorea(pageUrl, desc, date, title, tumb).apply { + if(desc?.contains("유머") == true|| desc?.contains("음악") == true|| desc?.contains("영화")== true || + desc?.contains("TV")== true || desc?.contains("미스터리")== true || desc?.contains("역사")== true) { + if (this.pubDate() > before30Min(now)) { + temp.add(this) + } + } + } + + } + } + } } + } catch (e : Exception) {e.printStackTrace()} + + return temp.forEach { synchronized(rssSet){ + rssSet.put(it.originPage(), it) + } }.run { + rssSetTouchCount -= 1 + Result.success() } + } +} +class ComicsGetter2 : Worker { + var limitDateTime = beforeDay(Date(),3) + constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { + + } + + @SuppressLint("RestrictedApi") + override fun doWork(): Result { + rssSetTouchCount += 1 + val temp = arrayListOf() + val now = Date() + try { + val dotaxUrls = arrayListOf("https://m.cafe.daum.net/dotax", +// "https://m.cafe.daum.net/dotax/_rec?page=2", +// "https://m.cafe.daum.net/dotax/_rec?page=3" + ) + dotaxUrls?.forEach { + Jsoup.connect(it)?.get()?.let { dotax -> + BLog.LOGE("dotax_li >>> ${dotax.title()}") + dotax.getElementsByTag("li").forEach { dotax_li -> + if (dotax_li.getElementsByTag("a").size > 0 && dotax_li.getElementsByClass("board_name") + .html().contains("웃긴") + ) { + val pageLink = dotax_li.getElementsByTag("a").get(0).attr("href") + val desc = dotax_li.getElementsByClass("board_name").text() + val dateTime = dotax_li.getElementsByClass("sr_only").text() + val title = dotax_li.getElementsByClass("txt_detail").text() + val thumbnail = dotax_li.getElementsByClass("article_thumb").text() + if (pageLink.length > 0 && desc.length > 0 && dateTime.length > 0 && title.length > 0) { + Dotax(pageLink, desc, dateTime, title, thumbnail).apply { + BLog.LOGE("dotax_li >>> ${Gson().toJson(this)}") + if(this.pubDate() > before30Min(now)) { + temp.add(this) + } + } + } + } + } + } + } + } catch (e : Exception) {e.printStackTrace()} + return temp.forEach { synchronized(rssSet){ + rssSet.put(it.originPage(), it) + } }.run { + rssSetTouchCount -= 1 + Result.success() } + } +} + +open class Dotax(var pageLink : String, + var desc : String, + var dateTime : String, + var title : String, + var thumbnail : String) : RssDataItem { + var updateDateTime = 0L + override fun title(): String { + return title + } + + override fun thumbnailUrl(): String { + return thumbnail + } + + override fun originPage(): String { + return "https://m.cafe.daum.net".plus(pageLink) + } + + override fun description(): String { + return desc + } + override fun pubDate(): Long { + var date = Date() + var dateTime = date.time + var before = 0 + if (updateDateTime == 0L) { + try { + var targetDate = this.dateTime ?: "" + if (targetDate?.length ?: 0 > 1) { + var dateDesc = targetDate + var isBefore = dateDesc.contains("전") + val dayString = dateDesc.replace("[^0-9]".toRegex(), "") + before = dayString.toInt() + if (dateDesc.contains("년")) { + before = 365 * before + dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before) + } else if (dateDesc.contains("월")) { + before = 30 * before + dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before) + } else if (dateDesc.contains("주")) { + before = 7 * before + dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before) + } else if (dateDesc.contains("일")) { + dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before) + } else if (dateDesc.contains("시간")) { + dateTime = + if (isBefore) dateTime.minus(before.times(1000L * 60L * 60L)) else dateTime.plus( + before.times(1000L * 60L * 60L) + ) + } else if (dateDesc.contains("분")) { + dateTime = + if (isBefore) dateTime.minus(before.times(1000L * 60L)) else dateTime.plus( + before.times(1000L * 60L) + ) + } + else if (dateDesc.contains("초")) { + dateTime = + if (isBefore) dateTime.minus(before.times(1000L)) else dateTime.plus( + before.times(1000L) + ) + } + } + + } catch (e: Exception) { + + } finally { + updateDateTime = dateTime + } + } else { + dateTime = updateDateTime + } + + return dateTime + } + override fun category(): RssDataType { + return RssDataType.Dotax + } +} +data class FmKorea(var apageLink : String, + var adesc : String, + var adateTime : String, + var atitle : String, + var athumbnail : String) : Dotax(apageLink, adesc, adateTime, atitle, athumbnail) { + override fun originPage(): String { + return pageLink + } + override fun category(): RssDataType { + return RssDataType.FmKorae + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/rasel/lunar/launcher/utils/RssList.kt b/app/src/main/kotlin/rasel/lunar/launcher/utils/RssList.kt index 9da47058..4d8bbd90 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/utils/RssList.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/utils/RssList.kt @@ -1,16 +1,15 @@ package rasel.lunar.launcher.utils -import android.widget.Toast import org.jsoup.nodes.Document -import rasel.lunar.launcher.LauncherActivity.Companion.TEST_PAG -import rasel.lunar.launcher.home.LauncherHome.Companion.listItem -import rasel.lunar.launcher.home.RssItem import java.net.URLEncoder -import java.text.SimpleDateFormat -import java.util.Date -import java.util.Locale object RssList { + + val TEST_PAG2 = "https://torrentsee246.com/topic/index?category1=129&category2=132" + val jGuruMain = "https://jav.guru/" + val jGuruRanks ="https://jav.guru/most-watched-rank/" + + val youtubeUrls = arrayListOf( "https://www.youtube.com/@zzanbro", "https://www.youtube.com/@sungsikyung", @@ -45,6 +44,7 @@ object RssList { "여행", "음반", "도끼", + "힙합", ) } diff --git a/app/src/main/res/drawable/daum.png b/app/src/main/res/drawable/daum.png new file mode 100644 index 00000000..6caa4e12 Binary files /dev/null and b/app/src/main/res/drawable/daum.png differ diff --git a/app/src/main/res/drawable/fmk.png b/app/src/main/res/drawable/fmk.png new file mode 100644 index 00000000..ab686372 Binary files /dev/null and b/app/src/main/res/drawable/fmk.png differ diff --git a/app/src/main/res/drawable/reddit.png b/app/src/main/res/drawable/reddit.png new file mode 100644 index 00000000..6c55dfac Binary files /dev/null and b/app/src/main/res/drawable/reddit.png differ diff --git a/app/src/main/res/drawable/youtube.png b/app/src/main/res/drawable/youtube.png new file mode 100644 index 00000000..2db89d20 Binary files /dev/null and b/app/src/main/res/drawable/youtube.png differ diff --git a/app/src/main/res/layout/app_drawer.xml b/app/src/main/res/layout/app_drawer.xml index 927e89d5..ed5d1fd4 100644 --- a/app/src/main/res/layout/app_drawer.xml +++ b/app/src/main/res/layout/app_drawer.xml @@ -82,6 +82,10 @@ android:src="@drawable/namuwiki" android:id="@+id/search_namuwiki" style="@style/SearchIcons"/> + + android:layout_height="wrap_content"/>