...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Lunar Launcher
|
||||
* Copyright (C) 2022 Md Rasel Hossain
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bums.lunatic.launcher.home
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.print.PDFPrint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.net.toUri
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import bums.lunatic.launcher.LauncherActivity.Companion.lActivity
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.databinding.RssViewerBinding
|
||||
import bums.lunatic.launcher.utils.BLog
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
internal class RssViewer : DialogFragment() {
|
||||
|
||||
private lateinit var binding: RssViewerBinding
|
||||
private lateinit var packageName: String
|
||||
private lateinit var packageManager: PackageManager
|
||||
private lateinit var defAppName: String
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.FilterFullScreenDialog)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (dialog != null) {
|
||||
// val metrics = resources.displayMetrics
|
||||
// val screenHeight = metrics.heightPixels
|
||||
// val bottomSheet =
|
||||
// dialog!!.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
|
||||
// bottomSheet.layoutParams.height = (screenHeight * 0.95).toInt()
|
||||
// val behavior = BottomSheetBehavior.from(bottomSheet)
|
||||
// behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
// behavior.skipCollapsed = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = RssViewerBinding.inflate(inflater, container, false)
|
||||
binding.webview.loadUrl(tag!!)
|
||||
binding.webview.setDesktopMode(false)
|
||||
binding.pdfPrint.setOnClickListener { pdfPring() }
|
||||
return binding.root
|
||||
}
|
||||
|
||||
fun pdfPring() {
|
||||
val fileName = tag?.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,binding.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(
|
||||
lActivity!!,
|
||||
"bums.lunatic.launcher.fileprovider", //(use your app signature + ".provider" )
|
||||
file
|
||||
)
|
||||
putExtra(Intent.EXTRA_STREAM, imageUri)
|
||||
type = "pdf"
|
||||
}
|
||||
lActivity!!.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
override fun onError(exception: java.lang.Exception?) {
|
||||
Toast.makeText(lActivity!!,
|
||||
"Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
exception?.printStackTrace()
|
||||
}
|
||||
} )
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
// (requireDialog() as BottomSheetDialog).dismissWithAnimation = true
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,14 +28,13 @@ import androidx.core.net.toUri
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import bums.lunatic.launcher.LauncherActivity.Companion.lActivity
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.databinding.ListItemWithBinding
|
||||
import bums.lunatic.launcher.home.RssViewer
|
||||
import bums.lunatic.launcher.model.RssData
|
||||
import bums.lunatic.launcher.model.RssDataInterface
|
||||
import bums.lunatic.launcher.model.RssDataType
|
||||
import bums.lunatic.launcher.openDotax
|
||||
import bums.lunatic.launcher.openNews
|
||||
import bums.lunatic.launcher.openOpera
|
||||
import bums.lunatic.launcher.openReddit
|
||||
import bums.lunatic.launcher.openYouTube
|
||||
import bums.lunatic.launcher.utils.BLog
|
||||
@@ -43,12 +42,13 @@ import bums.lunatic.launcher.workers.WorkersDb
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.google.gson.Gson
|
||||
import com.squareup.picasso.Picasso
|
||||
import com.wuadam.awesomewebview.AwesomeWebView
|
||||
import io.realm.kotlin.UpdatePolicy
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
internal class RssItemAdapter (
|
||||
|
||||
internal class RssItemAdapter (
|
||||
private val context: Context) : RecyclerView.Adapter<RssHolder>() {
|
||||
companion object {
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
@@ -74,16 +74,39 @@ internal class RssItemAdapter (
|
||||
} else {
|
||||
if (RssDataType.REDDIT_NSFW.equals(rss.category())) {
|
||||
openReddit(rss.originPage())
|
||||
// RssViewer().apply {
|
||||
// show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
// }
|
||||
} else {
|
||||
openOpera(rss.originPage())
|
||||
RssViewer().apply {
|
||||
show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
}
|
||||
// openOpera(rss.originPage())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RssDataType.REDDIT -> { openReddit(rss.originPage()) }
|
||||
RssDataType.DOTAX -> { openDotax(rss.originPage()) }
|
||||
RssDataType.YOUTUBE -> { openYouTube(rss.originPage()) }
|
||||
else -> { openNews(rss.originPage()) }
|
||||
RssDataType.REDDIT -> {
|
||||
RssViewer().apply {
|
||||
show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
}
|
||||
// openReddit(rss.originPage())
|
||||
}
|
||||
RssDataType.DOTAX -> {
|
||||
RssViewer().apply {
|
||||
AwesomeWebView.Builder(lActivity!!).show(rss.originPage!!)
|
||||
// show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
}
|
||||
// openDotax(rss.originPage())
|
||||
}
|
||||
RssDataType.YOUTUBE -> { openYouTube(rss.originPage())
|
||||
}
|
||||
else -> {
|
||||
RssViewer().apply {
|
||||
show(lActivity!!.supportFragmentManager,rss.originPage)
|
||||
}
|
||||
// openNews(rss.originPage())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ object RssList {
|
||||
)
|
||||
val newsFeeds = arrayListOf(
|
||||
"https://news.google.com/rss?hl=ko&gl=KR&ceid=KR:ko",
|
||||
"https://imnews.imbc.com/rss/google_news/narrativeNews.rss",
|
||||
// "https://imnews.imbc.com/rss/google_news/narrativeNews.rss",
|
||||
"http://www.hani.co.kr/rss",
|
||||
"http://biz.heraldcorp.com/common_prog/rssdisp.php?ct=010000000000.xml",
|
||||
"https://rss.inews24.com/rss/news_inews.xml",
|
||||
"https://rss.nocutnews.co.kr/category/it.xml",
|
||||
"https://rss.nocutnews.co.kr/news/news.xml",
|
||||
// "https://rss.inews24.com/rss/news_inews.xml",
|
||||
// "https://rss.nocutnews.co.kr/category/it.xml",
|
||||
// "https://rss.nocutnews.co.kr/news/news.xml",
|
||||
"https://rss.nocutnews.co.kr/news/top.xml",
|
||||
)
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ class ArcaGetter : BaseGetter {
|
||||
temp.clear()
|
||||
val urls = arrayListOf(
|
||||
"https://arca.live/b/singbung?mode=best",
|
||||
// "https://arca.live/b/headline",
|
||||
"https://arca.live/b/headline",
|
||||
// "https://arca.live/b/live",
|
||||
"https://arca.live/b/namuhotnow",
|
||||
"https://arca.live/b/society",
|
||||
// "https://arca.live/b/replay",
|
||||
// "https://arca.live/b/breaking"
|
||||
"https://arca.live/b/breaking"
|
||||
)
|
||||
urls.forEach {
|
||||
Jsoup.connect(it)
|
||||
|
||||
@@ -70,7 +70,7 @@ class ClienGetter : BaseGetter {
|
||||
RssDataType.CLIEN.isOn {
|
||||
try {
|
||||
temp.clear()
|
||||
val testUrl2 = arrayListOf("https://www.clien.net/service/group/community")
|
||||
val testUrl2 = arrayListOf("https://www.clien.net/service/group/community","https://www.clien.net/service/board/park","https://www.clien.net/service/board/news","https://www.clien.net/service/board/useful","https://www.clien.net/service/board/pds")
|
||||
testUrl2.forEach { url ->
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
|
||||
@@ -23,7 +23,7 @@ class DotaxGetter : BaseGetter {
|
||||
temp.clear()
|
||||
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"
|
||||
// "https://m.cafe.daum.net/dotax/_rec?page=3"
|
||||
)
|
||||
dotaxUrls?.forEach {
|
||||
Jsoup.connect(it).userAgent(USAGT).get()?.let { dotax ->
|
||||
|
||||
@@ -48,7 +48,7 @@ class TheQooGetter : BaseGetter {
|
||||
override fun realWork(): Result {
|
||||
RssDataType.THEQOO.isOn {
|
||||
try {
|
||||
val testUrl2 = arrayListOf("https://theqoo.net/hot")
|
||||
val testUrl2 = arrayListOf("https://theqoo.net/hot","https://theqoo.net/hot/category/512000937","https://theqoo.net/hot/category/24784","https://theqoo.net/hot/category/24788")
|
||||
testUrl2.forEach { url ->
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
|
||||
@@ -85,7 +85,9 @@ object WorkersDb {
|
||||
try {
|
||||
getRealm().writeBlocking {
|
||||
try {
|
||||
this.copyToRealm(it, UpdatePolicy.ERROR)
|
||||
if(query<RssData>("chosung == $0",it.chosung).find().size == 0) {
|
||||
this.copyToRealm(it, UpdatePolicy.ERROR)
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user