....
This commit is contained in:
parent
10ac465aba
commit
4d8b9b728b
@ -1191,9 +1191,7 @@ fun openReddit(schemeString : String) {
|
|||||||
var uri = schemeString.toUri()
|
var uri = schemeString.toUri()
|
||||||
val gmmIntentUri = Uri.parse(schemeString)
|
val gmmIntentUri = Uri.parse(schemeString)
|
||||||
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
|
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
|
||||||
if (uri != null && uri.host?.contains("facebook") == true) {
|
if(schemeString.contains("reddit")) {
|
||||||
|
|
||||||
} else {
|
|
||||||
mapIntent.setPackage("com.reddit.frontpage")
|
mapIntent.setPackage("com.reddit.frontpage")
|
||||||
}
|
}
|
||||||
lActivity?.startActivity(mapIntent)
|
lActivity?.startActivity(mapIntent)
|
||||||
|
|||||||
@ -84,6 +84,7 @@ import bums.lunatic.launcher.utils.Blog
|
|||||||
import bums.lunatic.launcher.utils.BitmapConverter
|
import bums.lunatic.launcher.utils.BitmapConverter
|
||||||
import bums.lunatic.launcher.utils.SimpleFingerGestures
|
import bums.lunatic.launcher.utils.SimpleFingerGestures
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
import bums.lunatic.launcher.utils.beforeDay
|
||||||
|
import bums.lunatic.launcher.utils.beforeOneDay
|
||||||
import bums.lunatic.launcher.view.TableRadioGroup
|
import bums.lunatic.launcher.view.TableRadioGroup
|
||||||
import bums.lunatic.launcher.workers.LocationGetter
|
import bums.lunatic.launcher.workers.LocationGetter
|
||||||
import bums.lunatic.launcher.workers.RecentCall
|
import bums.lunatic.launcher.workers.RecentCall
|
||||||
@ -109,7 +110,6 @@ import java.math.BigDecimal
|
|||||||
import java.math.RoundingMode
|
import java.math.RoundingMode
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
|
|
||||||
internal class LauncherHome : Fragment() {
|
internal class LauncherHome : Fragment() {
|
||||||
@ -489,7 +489,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
WorkersDb.getRealm().writeBlocking {
|
WorkersDb.getRealm().writeBlocking {
|
||||||
delete(
|
delete(
|
||||||
query<RssData>()
|
query<RssData>()
|
||||||
.query("pubDate < $0", beforeDay())
|
.query("pubDate < $0", beforeOneDay())
|
||||||
.query("category != $0 AND category != $1 ", RssDataType.GURU.name, RssDataType.MOST.name)
|
.query("category != $0 AND category != $1 ", RssDataType.GURU.name, RssDataType.MOST.name)
|
||||||
.query("vote != $0", true).find()
|
.query("vote != $0", true).find()
|
||||||
)
|
)
|
||||||
@ -510,11 +510,14 @@ internal class LauncherHome : Fragment() {
|
|||||||
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
|
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infosJob?.start()
|
infosJob?.start()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun queryVotes() {
|
fun queryVotes() {
|
||||||
@ -527,7 +530,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
) {
|
) {
|
||||||
beforeQuery()
|
beforeQuery()
|
||||||
var rQ = WorkersDb.getRealm().query<RssData>().query("read < $0", nomoreShowCount).distinct("originPage").distinct("title")
|
var rQ = WorkersDb.getRealm().query<RssData>().query("read < $0", nomoreShowCount).distinct("originPage").distinct("title")
|
||||||
if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3))
|
if (!noLimit) rQ.query("pubDate > $0", beforeOneDay())
|
||||||
((filter?.size ?: 0) > 0).letTrue {filter!!.forEach {rQ = rQ.query("category != $0", it.name)}}
|
((filter?.size ?: 0) > 0).letTrue {filter!!.forEach {rQ = rQ.query("category != $0", it.name)}}
|
||||||
updateQuery(rQ)
|
updateQuery(rQ)
|
||||||
}
|
}
|
||||||
@ -742,7 +745,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
binding.infoList.visibility = View.INVISIBLE
|
binding.infoList.visibility = View.INVISIBLE
|
||||||
binding.notiList.visibility = View.INVISIBLE
|
binding.notiList.visibility = View.INVISIBLE
|
||||||
|
|
||||||
var dateParam = beforeDay(Date(), 30).toString()
|
var dateParam = beforeDay(30).toString()
|
||||||
if (binding.missedCalls.isSelected) {
|
if (binding.missedCalls.isSelected) {
|
||||||
WorkersDb.getRealm().apply {
|
WorkersDb.getRealm().apply {
|
||||||
val result = query<RecentCall>().query("callDayTime >= $0", dateParam)
|
val result = query<RecentCall>().query("callDayTime >= $0", dateParam)
|
||||||
|
|||||||
@ -3,6 +3,9 @@ package bums.lunatic.launcher.home
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Environment
|
||||||
|
import android.print.PDFPrint
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.KeyEvent.ACTION_UP
|
import android.view.KeyEvent.ACTION_UP
|
||||||
import android.view.KeyEvent.KEYCODE_BUTTON_A
|
import android.view.KeyEvent.KEYCODE_BUTTON_A
|
||||||
@ -18,21 +21,35 @@ import android.view.KeyEvent.KEYCODE_DPAD_UP
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.MotionEvent.ACTION_MOVE
|
import android.view.MotionEvent.ACTION_MOVE
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.webkit.CookieManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.view.contains
|
||||||
|
import androidx.core.view.drawToBitmap
|
||||||
import bums.lunatic.launcher.LauncherActivity.Companion.lActivity
|
import bums.lunatic.launcher.LauncherActivity.Companion.lActivity
|
||||||
import bums.lunatic.launcher.model.RssData
|
import bums.lunatic.launcher.model.RssData
|
||||||
import bums.lunatic.launcher.utils.Blog
|
import bums.lunatic.launcher.utils.Blog
|
||||||
import bums.lunatic.launcher.workers.WorkersDb
|
import bums.lunatic.launcher.workers.WorkersDb
|
||||||
import io.realm.kotlin.UpdatePolicy
|
import io.realm.kotlin.UpdatePolicy
|
||||||
import io.realm.kotlin.ext.query
|
import io.realm.kotlin.ext.query
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kr.lunaticbum.awesomewebview.AwesomeWebView
|
import kr.lunaticbum.awesomewebview.AwesomeWebView
|
||||||
import kr.lunaticbum.awesomewebview.AwesomeWebView.Builder
|
import kr.lunaticbum.awesomewebview.AwesomeWebView.Builder
|
||||||
import kr.lunaticbum.awesomewebview.AwesomeWebViewActivity
|
import kr.lunaticbum.awesomewebview.AwesomeWebViewActivity
|
||||||
|
import kr.lunaticbum.awesomewebview.helpers.DownPicUtil
|
||||||
|
import kr.lunaticbum.awesomewebview.helpers.DownPicUtil.DownFinishListener
|
||||||
import kr.lunaticbum.awesomewebview.listeners.BroadCastManager
|
import kr.lunaticbum.awesomewebview.listeners.BroadCastManager
|
||||||
import kr.lunaticbum.awesomewebview.objects.CustomMenu
|
import kr.lunaticbum.awesomewebview.objects.CustomMenu
|
||||||
import kr.lunaticbum.utils.content.ContextUtil
|
import kr.lunaticbum.utils.content.ContextUtil
|
||||||
import kr.lunaticbum.utils.log.LogUtil
|
import kr.lunaticbum.utils.log.LogUtil
|
||||||
|
import org.jsoup.Jsoup
|
||||||
|
import org.jsoup.UnsupportedMimeTypeException
|
||||||
|
import org.jsoup.nodes.Element
|
||||||
|
import java.io.File
|
||||||
|
import java.lang.Exception
|
||||||
|
import java.net.URL
|
||||||
|
|
||||||
class RssViewBuilder(context: Context) : AwesomeWebView.Builder(context) {
|
class RssViewBuilder(context: Context) : AwesomeWebView.Builder(context) {
|
||||||
var rssId : String = ""
|
var rssId : String = ""
|
||||||
@ -245,6 +262,15 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene
|
|||||||
webView?.scrollTo(webView?.scrollX ?: 0, (webView?.scrollY ?: 0) + getUnit())
|
webView?.scrollTo(webView?.scrollX ?: 0, (webView?.scrollY ?: 0) + getUnit())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var pdfListner : PDFPrint.OnPDFPrintListener? = object : PDFPrint.OnPDFPrintListener {
|
||||||
|
override fun onSuccess(file: File?) {
|
||||||
|
LogUtil.e("file.absolutePath >>> ${file?.absolutePath}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(exception: Exception?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun dispatchGenericMotionEvent(ev: MotionEvent?): Boolean {
|
override fun dispatchGenericMotionEvent(ev: MotionEvent?): Boolean {
|
||||||
if (ev?.device?.name?.contains("BLE-M3") == true) {
|
if (ev?.device?.name?.contains("BLE-M3") == true) {
|
||||||
@ -353,6 +379,82 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene
|
|||||||
return@forEachIndexed}
|
return@forEachIndexed}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onHtml(value: String?) {
|
||||||
|
val agent = webView!!.settings.userAgentString
|
||||||
|
val current = webView!!.url
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
mediaUrls.forEach {
|
||||||
|
try {
|
||||||
|
LogUtil.e("try Jsoup.parse ${it}")
|
||||||
|
Jsoup.parse(URL(it), 3000)?.let {
|
||||||
|
try {
|
||||||
|
LogUtil.e("onit Jsoup.parse ${it.title()}")
|
||||||
|
it.getElementsByTag("video")?.forEach {
|
||||||
|
it.attribute("src").value?.let {
|
||||||
|
var url = if (it.startsWith("http")) {
|
||||||
|
it
|
||||||
|
} else {
|
||||||
|
"https:".plus(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
val cookieManager =
|
||||||
|
CookieManager.getInstance()
|
||||||
|
val cookie =
|
||||||
|
cookieManager.getCookie(current)
|
||||||
|
DownPicUtil.downMp4(
|
||||||
|
File(
|
||||||
|
Environment.getExternalStorageDirectory(),
|
||||||
|
"bums"
|
||||||
|
).path,
|
||||||
|
url,
|
||||||
|
agent,
|
||||||
|
current,
|
||||||
|
cookie,
|
||||||
|
object : DownFinishListener {
|
||||||
|
override fun onDownFinish(path: String) {
|
||||||
|
if (showToastPhotoSavedOrFailed) {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
resources.getString(
|
||||||
|
stringResPhotoSavedTo
|
||||||
|
) + path,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
// 最后通知图库更新
|
||||||
|
applicationContext.sendBroadcast(
|
||||||
|
Intent(
|
||||||
|
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
|
||||||
|
Uri.parse("file://$path")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError() {
|
||||||
|
if (showToastPhotoSavedOrFailed) {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
resources.getString(
|
||||||
|
stringResPhotoSaveFailed
|
||||||
|
),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e : UnsupportedMimeTypeException) {
|
||||||
|
|
||||||
|
} catch (e : Exception){}
|
||||||
|
}
|
||||||
|
} catch (e : UnsupportedMimeTypeException) {
|
||||||
|
|
||||||
|
} catch (e : Exception){}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun webviewOnPageFinished() {
|
override fun webviewOnPageFinished() {
|
||||||
double = false
|
double = false
|
||||||
if(hasYoutubePlayer) {
|
if(hasYoutubePlayer) {
|
||||||
@ -371,5 +473,14 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
registCancelSearch()
|
registCancelSearch()
|
||||||
|
|
||||||
|
if (webView?.url?.contains("dcinside") == true){
|
||||||
|
webView?.evaluateJavascript("try{document.querySelector('#div_adnmore_area').hidden = true;}catch(e){}",null)
|
||||||
|
} else if(webView?.url?.contains("fmkorea") == true) {
|
||||||
|
webView?.postDelayed({
|
||||||
|
webView?.evaluateJavascript("try{document.querySelector('.m_rd_nav_side').hidden = true;}catch(e){}",null)
|
||||||
|
webView?.evaluateJavascript("try{document.querySelector(\"[class*='bd bd_mobile ']\").remove();}catch(e){}",null)
|
||||||
|
},500L)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,8 +4,7 @@ import android.util.Xml
|
|||||||
import bums.lunatic.launcher.model.NewsData
|
import bums.lunatic.launcher.model.NewsData
|
||||||
import bums.lunatic.launcher.model.RssDataInterface
|
import bums.lunatic.launcher.model.RssDataInterface
|
||||||
import bums.lunatic.launcher.model.others.Reddit
|
import bums.lunatic.launcher.model.others.Reddit
|
||||||
import bums.lunatic.launcher.utils.Blog
|
import bums.lunatic.launcher.utils.beforeOneDay
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import org.xmlpull.v1.XmlPullParser
|
import org.xmlpull.v1.XmlPullParser
|
||||||
import org.xmlpull.v1.XmlPullParserException
|
import org.xmlpull.v1.XmlPullParserException
|
||||||
@ -14,14 +13,13 @@ import java.io.InputStream
|
|||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
object RssFeedsParser {
|
object RssFeedsParser {
|
||||||
var parseDateFormat: SimpleDateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH)
|
var parseDateFormat: SimpleDateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH)
|
||||||
var parseDateFormat2: SimpleDateFormat = SimpleDateFormat("E, dd MM yyyy HH:mm:ss ZZ", Locale.ENGLISH)
|
var parseDateFormat2: SimpleDateFormat = SimpleDateFormat("E, dd MM yyyy HH:mm:ss ZZ", Locale.ENGLISH)
|
||||||
var limitDateTime = beforeDay(Date(),3)
|
var limitDateTime = beforeOneDay()
|
||||||
fun getFeeds(url : String) : List<RssDataInterface> {
|
fun getFeeds(url : String) : List<RssDataInterface> {
|
||||||
var returnList = mutableListOf<RssDataInterface>()
|
var returnList = mutableListOf<RssDataInterface>()
|
||||||
try {
|
try {
|
||||||
@ -34,7 +32,7 @@ object RssFeedsParser {
|
|||||||
|
|
||||||
fun getReddit(url : String, nsfw : Boolean): List<RssDataInterface> {
|
fun getReddit(url : String, nsfw : Boolean): List<RssDataInterface> {
|
||||||
var returnList = mutableListOf<RssDataInterface>()
|
var returnList = mutableListOf<RssDataInterface>()
|
||||||
var dateTime = beforeDay(Date(),3)
|
var dateTime = beforeOneDay()
|
||||||
try {
|
try {
|
||||||
var mReddit = Gson().fromJson(InputStreamReader(getInputStream(url)!!), Reddit::class.java)
|
var mReddit = Gson().fromJson(InputStreamReader(getInputStream(url)!!), Reddit::class.java)
|
||||||
mReddit.data?.children?.forEach {
|
mReddit.data?.children?.forEach {
|
||||||
|
|||||||
@ -4,43 +4,6 @@ import bums.lunatic.launcher.beforeDay
|
|||||||
import bums.lunatic.launcher.utils.JamoUtils
|
import bums.lunatic.launcher.utils.JamoUtils
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
class MissD : RssDataInterface {
|
|
||||||
var link : String? = null
|
|
||||||
|
|
||||||
var title : String? = null
|
|
||||||
|
|
||||||
var thumb : String? = null
|
|
||||||
|
|
||||||
var desc : String? = null
|
|
||||||
|
|
||||||
override fun title(): String {
|
|
||||||
return title ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun thumbnailUrl(): String {
|
|
||||||
return thumb ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun originPage(): String {
|
|
||||||
return link ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun description(): String {
|
|
||||||
return desc ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun pubDate(): Long {
|
|
||||||
return beforeDay(Date())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun category(): RssDataType {
|
|
||||||
return RssDataType.GURU
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getCho(): String? {
|
|
||||||
return JamoUtils.split(title!!).joinToString("")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MostItem : JGuru , RssDataInterface {
|
class MostItem : JGuru , RssDataInterface {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package bums.lunatic.launcher.model
|
|||||||
|
|
||||||
import bums.lunatic.launcher.utils.JamoUtils
|
import bums.lunatic.launcher.utils.JamoUtils
|
||||||
import bums.lunatic.launcher.utils.afterDay
|
import bums.lunatic.launcher.utils.afterDay
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
import bums.lunatic.launcher.utils.beforeDayBy
|
||||||
import io.realm.kotlin.types.RealmObject
|
import io.realm.kotlin.types.RealmObject
|
||||||
import io.realm.kotlin.types.annotations.Ignore
|
import io.realm.kotlin.types.annotations.Ignore
|
||||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||||
@ -308,15 +308,15 @@ open class Dotax(var pageLink : String,
|
|||||||
before = dayString.toInt()
|
before = dayString.toInt()
|
||||||
if (dateDesc.contains("년")) {
|
if (dateDesc.contains("년")) {
|
||||||
before = 365 * before
|
before = 365 * before
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("월")) {
|
} else if (dateDesc.contains("월")) {
|
||||||
before = 30 * before
|
before = 30 * before
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("주")) {
|
} else if (dateDesc.contains("주")) {
|
||||||
before = 7 * before
|
before = 7 * before
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("일")) {
|
} else if (dateDesc.contains("일")) {
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("시간")) {
|
} else if (dateDesc.contains("시간")) {
|
||||||
dateTime =
|
dateTime =
|
||||||
if (isBefore) dateTime.minus(before.times(1000L * 60L * 60L)) else dateTime.plus(
|
if (isBefore) dateTime.minus(before.times(1000L * 60L * 60L)) else dateTime.plus(
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import bums.lunatic.launcher.model.RssDataInterface
|
|||||||
import bums.lunatic.launcher.model.RssDataType
|
import bums.lunatic.launcher.model.RssDataType
|
||||||
import bums.lunatic.launcher.utils.JamoUtils
|
import bums.lunatic.launcher.utils.JamoUtils
|
||||||
import bums.lunatic.launcher.utils.afterDay
|
import bums.lunatic.launcher.utils.afterDay
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
import bums.lunatic.launcher.utils.beforeDayBy
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
@ -1621,15 +1621,15 @@ open class VideoRenderer : RssDataInterface {
|
|||||||
before = dayString.toInt()
|
before = dayString.toInt()
|
||||||
if (dateDesc.contains("년")) {
|
if (dateDesc.contains("년")) {
|
||||||
before = 365 * before
|
before = 365 * before
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("월")) {
|
} else if (dateDesc.contains("월")) {
|
||||||
before = 30 * before
|
before = 30 * before
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("주")) {
|
} else if (dateDesc.contains("주")) {
|
||||||
before = 7 * before
|
before = 7 * before
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("일")) {
|
} else if (dateDesc.contains("일")) {
|
||||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||||
} else if (dateDesc.contains("시간")) {
|
} else if (dateDesc.contains("시간")) {
|
||||||
dateTime = if (isBefore)dateTime.minus(before.times(1000L * 60L * 60L)) else dateTime.plus(before.times(1000L * 60L * 60L))
|
dateTime = if (isBefore)dateTime.minus(before.times(1000L * 60L * 60L)) else dateTime.plus(before.times(1000L * 60L * 60L))
|
||||||
} else if (dateDesc.contains("분")) {
|
} else if (dateDesc.contains("분")) {
|
||||||
|
|||||||
@ -15,15 +15,23 @@ fun before30Min(date: Date): Long {
|
|||||||
return cal.timeInMillis
|
return cal.timeInMillis
|
||||||
}
|
}
|
||||||
|
|
||||||
fun beforeDay(): Long {
|
fun beforeOneDay(): Long {
|
||||||
val cal: Calendar = Calendar.getInstance()
|
val cal: Calendar = Calendar.getInstance()
|
||||||
cal.setTime(Date())
|
cal.setTime(Date())
|
||||||
cal.add(Calendar.DAY_OF_YEAR, -1)
|
cal.add(Calendar.DAY_OF_YEAR, -1)
|
||||||
cal.add(Calendar.HOUR_OF_DAY, -6)
|
cal.add(Calendar.HOUR_OF_DAY, -3)
|
||||||
return cal.timeInMillis
|
return cal.timeInMillis
|
||||||
}
|
}
|
||||||
|
|
||||||
fun beforeDay(date: Date?, day: Int): Long {
|
fun beforeDay(day: Int): Long {
|
||||||
|
val cal: Calendar = Calendar.getInstance()
|
||||||
|
cal.setTime(Date())
|
||||||
|
cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1)
|
||||||
|
return cal.timeInMillis
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun beforeDayBy(date : Date, day: Int): Long {
|
||||||
val cal: Calendar = Calendar.getInstance()
|
val cal: Calendar = Calendar.getInstance()
|
||||||
cal.setTime(date)
|
cal.setTime(date)
|
||||||
cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1)
|
cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1)
|
||||||
|
|||||||
@ -7,11 +7,10 @@ import bums.lunatic.launcher.model.RssDataInterface
|
|||||||
import bums.lunatic.launcher.model.RssDataType
|
import bums.lunatic.launcher.model.RssDataType
|
||||||
import bums.lunatic.launcher.model.getRssData
|
import bums.lunatic.launcher.model.getRssData
|
||||||
import bums.lunatic.launcher.model.getT
|
import bums.lunatic.launcher.model.getT
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
import bums.lunatic.launcher.utils.beforeOneDay
|
||||||
import bums.lunatic.launcher.workers.WorkersDb.blockKeyword
|
import bums.lunatic.launcher.workers.WorkersDb.blockKeyword
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class ArcaGetter : BaseGetter {
|
class ArcaGetter : BaseGetter {
|
||||||
companion object {
|
companion object {
|
||||||
@ -87,7 +86,7 @@ class ArcaGetter : BaseGetter {
|
|||||||
this.dateTiem = dateTime
|
this.dateTiem = dateTime
|
||||||
}.apply {
|
}.apply {
|
||||||
// BLog.LOGE("parseArcaLi >>>> ${this}")
|
// BLog.LOGE("parseArcaLi >>>> ${this}")
|
||||||
if (this.pubDate() > beforeDay(Date(), 3)) {
|
if (this.pubDate() > beforeOneDay()) {
|
||||||
tempArray.add(this)
|
tempArray.add(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import androidx.work.Worker
|
|||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import bums.lunatic.launcher.model.RssData
|
import bums.lunatic.launcher.model.RssData
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
import bums.lunatic.launcher.utils.beforeDay
|
||||||
|
import bums.lunatic.launcher.utils.beforeOneDay
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
@ -22,9 +23,9 @@ open abstract class BaseGetter : Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
|
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
|
||||||
val now = Date()
|
|
||||||
val limitDateTime = beforeDay(now,3)
|
val limitDateTime = beforeOneDay()
|
||||||
val commicsDateTime = beforeDay(now,1)
|
val commicsDateTime = beforeDay(1)
|
||||||
val temp = arrayListOf<RssData>()
|
val temp = arrayListOf<RssData>()
|
||||||
|
|
||||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class RecentCallGetter : BaseGetter {
|
|||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun realWork(): Result {
|
override fun realWork(): Result {
|
||||||
|
|
||||||
var dateParam = beforeDay(Date(),dayRange).toString()
|
var dateParam = beforeDay(dayRange).toString()
|
||||||
var managedCursor = lActivity?.contentResolver?.query(
|
var managedCursor = lActivity?.contentResolver?.query(
|
||||||
CallLog.Calls.CONTENT_URI, arrayOf(
|
CallLog.Calls.CONTENT_URI, arrayOf(
|
||||||
CallLog.Calls.NUMBER,
|
CallLog.Calls.NUMBER,
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import java.io.BufferedReader
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class RecentSmsGetter : BaseGetter {
|
class RecentSmsGetter : BaseGetter {
|
||||||
companion object {
|
companion object {
|
||||||
@ -38,7 +37,7 @@ class RecentSmsGetter : BaseGetter {
|
|||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun realWork(): Result {
|
override fun realWork(): Result {
|
||||||
var dateParam = beforeDay(Date(),dayRange).toString()
|
var dateParam = beforeDay(dayRange).toString()
|
||||||
val managedCursor = lActivity?.contentResolver?.query(
|
val managedCursor = lActivity?.contentResolver?.query(
|
||||||
Telephony.Sms.CONTENT_URI, arrayOf(
|
Telephony.Sms.CONTENT_URI, arrayOf(
|
||||||
Telephony.Sms.THREAD_ID,
|
Telephony.Sms.THREAD_ID,
|
||||||
@ -340,7 +339,7 @@ internal class MmsQueryHelper(
|
|||||||
|
|
||||||
fun convertData(cursor: Cursor?) {
|
fun convertData(cursor: Cursor?) {
|
||||||
cursor ?: return
|
cursor ?: return
|
||||||
val dateTime = beforeDay(Date(), dayRange)
|
val dateTime = beforeDay(dayRange)
|
||||||
cursor.use {
|
cursor.use {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import bums.lunatic.launcher.model.TelegramMessage
|
|||||||
import bums.lunatic.launcher.model.WeatherForcast
|
import bums.lunatic.launcher.model.WeatherForcast
|
||||||
import bums.lunatic.launcher.utils.Blog
|
import bums.lunatic.launcher.utils.Blog
|
||||||
import bums.lunatic.launcher.utils.JamoUtils
|
import bums.lunatic.launcher.utils.JamoUtils
|
||||||
import bums.lunatic.launcher.utils.beforeDay
|
import bums.lunatic.launcher.utils.beforeOneDay
|
||||||
import io.realm.kotlin.Realm
|
import io.realm.kotlin.Realm
|
||||||
import io.realm.kotlin.RealmConfiguration
|
import io.realm.kotlin.RealmConfiguration
|
||||||
import io.realm.kotlin.UpdatePolicy
|
import io.realm.kotlin.UpdatePolicy
|
||||||
@ -36,7 +36,6 @@ import io.realm.kotlin.migration.AutomaticSchemaMigration
|
|||||||
import io.realm.kotlin.query.RealmQuery
|
import io.realm.kotlin.query.RealmQuery
|
||||||
import io.realm.kotlin.types.BaseRealmObject
|
import io.realm.kotlin.types.BaseRealmObject
|
||||||
import io.realm.kotlin.types.TypedRealmObject
|
import io.realm.kotlin.types.TypedRealmObject
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
@ -201,7 +200,7 @@ object WorkersDb {
|
|||||||
category: Collection<String>? = arrayListOf(),
|
category: Collection<String>? = arrayListOf(),
|
||||||
noLimit: Boolean = false) : RealmQuery<RssData>{
|
noLimit: Boolean = false) : RealmQuery<RssData>{
|
||||||
var rQ = getRealm().query<RssData>()
|
var rQ = getRealm().query<RssData>()
|
||||||
if (!noLimit) rQ.query("pubDate > $0", beforeDay(Date(), 3))
|
if (!noLimit) rQ.query("pubDate > $0", beforeOneDay())
|
||||||
keyword?.isNotEmpty()?.letTrue {
|
keyword?.isNotEmpty()?.letTrue {
|
||||||
if (JamoUtils.CHOSUNG.contains(keyword.split("")[0])) {
|
if (JamoUtils.CHOSUNG.contains(keyword.split("")[0])) {
|
||||||
rQ = rQ.query("title CONTAINS $0 OR chosung CONTAINS $1 ", keyword, keyword)
|
rQ = rQ.query("title CONTAINS $0 OR chosung CONTAINS $1 ", keyword, keyword)
|
||||||
|
|||||||
@ -58,9 +58,13 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.lifecycle.ReportFragment.Companion.reportFragment
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kr.lunaticbum.awesomewebview.databinding.AwesomeWebViewBinding
|
import kr.lunaticbum.awesomewebview.databinding.AwesomeWebViewBinding
|
||||||
import kr.lunaticbum.awesomewebview.enums.Position
|
import kr.lunaticbum.awesomewebview.enums.Position
|
||||||
import kr.lunaticbum.awesomewebview.helpers.BitmapHelper
|
import kr.lunaticbum.awesomewebview.helpers.BitmapHelper
|
||||||
@ -95,6 +99,7 @@ import kotlin.math.abs
|
|||||||
|
|
||||||
open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||||
Handler.Callback {
|
Handler.Callback {
|
||||||
|
var mediaUrls = arrayListOf<String>()
|
||||||
protected var key: Int = 0
|
protected var key: Int = 0
|
||||||
|
|
||||||
protected var rtl: Boolean = false
|
protected var rtl: Boolean = false
|
||||||
@ -791,8 +796,19 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
|
|
||||||
webView!!.setOnLongClickListener(OnLongClickListener {
|
webView!!.setOnLongClickListener(OnLongClickListener {
|
||||||
val hitTestResult = webView!!.hitTestResult
|
val hitTestResult = webView!!.hitTestResult
|
||||||
// 如果是图片类型或者是带有图片链接的类型
|
|
||||||
if (hitTestResult.type == HitTestResult.IMAGE_TYPE ||
|
LogUtil.e("hitTestResult.type >>> ${hitTestResult.type}")
|
||||||
|
LogUtil.e("hitTestResult.extra >>> ${hitTestResult.extra}")
|
||||||
|
if(hitTestResult.type==0) {
|
||||||
|
webView?.evaluateJavascript("document.getElementsByTagName('iframe')",
|
||||||
|
object : ValueCallback<String> {
|
||||||
|
override fun onReceiveValue(value: String?) {
|
||||||
|
val html = value?.replace("\\u003C", "<")
|
||||||
|
onHtml(html)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if (hitTestResult.type == HitTestResult.IMAGE_TYPE ||
|
||||||
hitTestResult.type == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
hitTestResult.type == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
||||||
) {
|
) {
|
||||||
if (!showMenuSavePhoto) {
|
if (!showMenuSavePhoto) {
|
||||||
@ -807,19 +823,17 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
builder?.setItems(
|
builder?.setItems(
|
||||||
items
|
items
|
||||||
) { dialog, which ->
|
) { dialog, which ->
|
||||||
PermissionHelper.CheckPermissions(
|
LogUtil.e("hitTestResult.extra >>> ${dialog} ,${which}")
|
||||||
this@AwesomeWebViewActivity,
|
|
||||||
object : CheckPermissionListener {
|
|
||||||
override fun onAllGranted(sync: Boolean) {
|
|
||||||
val url = hitTestResult.extra
|
val url = hitTestResult.extra
|
||||||
// 下载图片到本地
|
LogUtil.e("hitTestResult.extra >>> ${hitTestResult.extra}")
|
||||||
CookieSyncManager.createInstance(this@AwesomeWebViewActivity)
|
CookieSyncManager.createInstance(applicationContext)
|
||||||
CookieSyncManager.getInstance().sync()
|
CookieSyncManager.getInstance().sync()
|
||||||
val cookieManager =
|
val cookieManager =
|
||||||
CookieManager.getInstance()
|
CookieManager.getInstance()
|
||||||
val cookie =
|
val cookie =
|
||||||
cookieManager.getCookie(webView!!.url)
|
cookieManager.getCookie(webView!!.url)
|
||||||
DownPicUtil.downPic(
|
DownPicUtil.downPic(
|
||||||
|
File(Environment.getExternalStorageDirectory(),"bums").path,
|
||||||
url,
|
url,
|
||||||
webView!!.settings.userAgentString,
|
webView!!.settings.userAgentString,
|
||||||
webView!!.url,
|
webView!!.url,
|
||||||
@ -828,7 +842,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
override fun onDownFinish(path: String) {
|
override fun onDownFinish(path: String) {
|
||||||
if (showToastPhotoSavedOrFailed) {
|
if (showToastPhotoSavedOrFailed) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@AwesomeWebViewActivity,
|
applicationContext,
|
||||||
resources.getString(
|
resources.getString(
|
||||||
stringResPhotoSavedTo
|
stringResPhotoSavedTo
|
||||||
) + path,
|
) + path,
|
||||||
@ -847,7 +861,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
override fun onError() {
|
override fun onError() {
|
||||||
if (showToastPhotoSavedOrFailed) {
|
if (showToastPhotoSavedOrFailed) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@AwesomeWebViewActivity,
|
applicationContext,
|
||||||
resources.getString(
|
resources.getString(
|
||||||
stringResPhotoSaveFailed
|
stringResPhotoSaveFailed
|
||||||
),
|
),
|
||||||
@ -857,16 +871,6 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPartlyGranted(
|
|
||||||
permissionsDenied: List<String>,
|
|
||||||
sync: Boolean
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val dialog = builder?.create()
|
val dialog = builder?.create()
|
||||||
dialog?.show()
|
dialog?.show()
|
||||||
return@OnLongClickListener true
|
return@OnLongClickListener true
|
||||||
@ -874,27 +878,27 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
false
|
false
|
||||||
})
|
})
|
||||||
|
|
||||||
webView!!.setOnTouchListener(object : OnTouchListener {
|
// webView!!.setOnTouchListener(object : OnTouchListener {
|
||||||
private var xDown = 0f
|
// private var xDown = 0f
|
||||||
private var yDown = 0f
|
// private var yDown = 0f
|
||||||
private var timeDown: Long = 0
|
// private var timeDown: Long = 0
|
||||||
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
// override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||||
if (v === webView && event.action == MotionEvent.ACTION_DOWN) {
|
// if (v === webView && event.action == MotionEvent.ACTION_DOWN) {
|
||||||
xDown = event.x
|
// xDown = event.x
|
||||||
yDown = event.y
|
// yDown = event.y
|
||||||
timeDown = System.currentTimeMillis()
|
// timeDown = System.currentTimeMillis()
|
||||||
} else if (v === webView && event.action == MotionEvent.ACTION_UP) {
|
// } else if (v === webView && event.action == MotionEvent.ACTION_UP) {
|
||||||
if (abs((xDown - event.x).toDouble()) < 50 && abs(
|
// if (abs((xDown - event.x).toDouble()) < 50 && abs(
|
||||||
(yDown - event.y).toDouble()
|
// (yDown - event.y).toDouble()
|
||||||
) < 50 && System.currentTimeMillis() - timeDown < 200
|
// ) < 50 && System.currentTimeMillis() - timeDown < 200
|
||||||
) {
|
// ) {
|
||||||
// https://stackoverflow.com/a/5125620
|
// // https://stackoverflow.com/a/5125620
|
||||||
handler.sendEmptyMessageDelayed(MSG_CLICK_ON_WEBVIEW, 500)
|
// handler.sendEmptyMessageDelayed(MSG_CLICK_ON_WEBVIEW, 500)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
|
||||||
val settings = webView!!.settings
|
val settings = webView!!.settings
|
||||||
|
|
||||||
@ -1239,6 +1243,10 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open protected fun onHtml(value: String?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected fun buildWebView(): WebView {
|
protected fun buildWebView(): WebView {
|
||||||
return VideoEnabledWebView(this)
|
return VideoEnabledWebView(this)
|
||||||
}
|
}
|
||||||
@ -1405,6 +1413,8 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open protected var pdfListner : PDFPrint.OnPDFPrintListener? = null
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
val viewId = v.id
|
val viewId = v.id
|
||||||
if (viewId == R.id.close) {
|
if (viewId == R.id.close) {
|
||||||
@ -1443,16 +1453,23 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
if (path.exists() == false) {
|
if (path.exists() == false) {
|
||||||
path.mkdirs()
|
path.mkdirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
val file = File(path, fileName)
|
val file = File(path, fileName)
|
||||||
PDFPrint.generatePDFFromWebView(file,webView,object :PDFPrint.OnPDFPrintListener {
|
PDFPrint.generatePDFFromWebView(
|
||||||
|
file,
|
||||||
|
webView,
|
||||||
|
pdfListner ?: object : PDFPrint.OnPDFPrintListener {
|
||||||
override fun onSuccess(file: File?) {
|
override fun onSuccess(file: File?) {
|
||||||
LogUtil.e("file.absolutePath >>> ${file?.absolutePath ?: "fail"}")
|
LogUtil.e("file.absolutePath >>> ${file?.absolutePath ?: "fail"}")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(exception: java.lang.Exception?) {
|
override fun onError(exception: java.lang.Exception?) {
|
||||||
|
LogUtil.e("generatePDFFromWebView >>> fail")
|
||||||
exception?.printStackTrace()
|
exception?.printStackTrace()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
hideMenu()
|
hideMenu()
|
||||||
} else if (viewId == R.id.menuFind) {
|
} else if (viewId == R.id.menuFind) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) webView!!.showFindDialog(
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) webView!!.showFindDialog(
|
||||||
@ -1849,6 +1866,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||||
return File.createTempFile(new_name, if (isVideo) ".mp4" else ".jpg", sd_directory)
|
return File.createTempFile(new_name, if (isVideo) ".mp4" else ".jpg", sd_directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasYoutubePlayer = false
|
var hasYoutubePlayer = false
|
||||||
open fun webviewOnPageFinished(){}
|
open fun webviewOnPageFinished(){}
|
||||||
inner class MyWebViewClient : WebViewClient() {
|
inner class MyWebViewClient : WebViewClient() {
|
||||||
@ -1865,11 +1883,15 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
|||||||
ByteArrayInputStream("".toByteArray())
|
ByteArrayInputStream("".toByteArray())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val url = request.url.toString()
|
val url = request.url.toString()
|
||||||
if(!hasYoutubePlayer) {
|
if(!hasYoutubePlayer) {
|
||||||
hasYoutubePlayer = url.toLowerCase(Locale.ROOT)
|
hasYoutubePlayer = url.toLowerCase(Locale.ROOT)
|
||||||
.contains("https://www.youtube.com/s/player".toLowerCase(Locale.ROOT))
|
.contains("https://www.youtube.com/s/player".toLowerCase(Locale.ROOT))
|
||||||
}
|
}
|
||||||
|
if (url.contains("streamable.com")) {
|
||||||
|
mediaUrls.add(url)
|
||||||
|
}
|
||||||
if (url.toLowerCase(Locale.ROOT)
|
if (url.toLowerCase(Locale.ROOT)
|
||||||
.contains("ads".toLowerCase(Locale.ROOT))) {
|
.contains("ads".toLowerCase(Locale.ROOT))) {
|
||||||
LogUtil.e("shouldInterceptRequest request url contains ads >>> ${request.url.toString()}")
|
LogUtil.e("shouldInterceptRequest request url contains ads >>> ${request.url.toString()}")
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -28,26 +30,42 @@ public class DownPicUtil {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
public static void downPic(String url, DownFinishListener downFinishListener){
|
public static void downPic(String url, DownFinishListener downFinishListener){
|
||||||
downPic(url, null, null, null, downFinishListener);
|
downPic(null, url, null, null, null, downFinishListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the pic
|
* Download the pic
|
||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
public static void downPic(String url, String userAgent, String referer, String cookie, DownFinishListener downFinishListener){
|
public static void downPic(String path , String url, String userAgent, String referer, String cookie, DownFinishListener downFinishListener){
|
||||||
// 获取存储卡的目录
|
if(path == null) {
|
||||||
String filePath = Environment.getExternalStorageDirectory().getPath();
|
String filePath = Environment.getExternalStorageDirectory().getPath();
|
||||||
File file = new File(filePath + File.separator + Environment.DIRECTORY_DOWNLOADS);
|
File file = new File(filePath + File.separator + Environment.DIRECTORY_DOWNLOADS);
|
||||||
if(!file.exists()){
|
if (!file.exists()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
}
|
}
|
||||||
|
loadPic(file.getPath(), url, userAgent, referer, cookie, downFinishListener, false);
|
||||||
loadPic(file.getPath(), url, userAgent, referer, cookie, downFinishListener);
|
} else {
|
||||||
|
loadPic(path, url, userAgent, referer, cookie, downFinishListener, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadPic(final String filePath, final String url, final String userAgent, final String referer, final String cookie, final DownFinishListener downFinishListener) {
|
public static void downMp4(String path , String url, String userAgent, String referer, String cookie, DownFinishListener downFinishListener){
|
||||||
|
if(path == null) {
|
||||||
|
String filePath = Environment.getExternalStorageDirectory().getPath();
|
||||||
|
File file = new File(filePath + File.separator + Environment.DIRECTORY_DOWNLOADS);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
loadPic(file.getPath(), url, userAgent, referer, cookie, downFinishListener, true);
|
||||||
|
} else {
|
||||||
|
loadPic(path, url, userAgent, referer, cookie, downFinishListener, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void loadPic(final String filePath, final String url, final String userAgent, final String referer, final String cookie, final DownFinishListener downFinishListener, boolean isMp4) {
|
||||||
new AsyncTask<Void,Void,String>(){
|
new AsyncTask<Void,Void,String>(){
|
||||||
String fileName;
|
String fileName;
|
||||||
InputStream is;
|
InputStream is;
|
||||||
@ -130,7 +148,9 @@ public class DownPicUtil {
|
|||||||
|
|
||||||
// 提取文件格式真实拓展名
|
// 提取文件格式真实拓展名
|
||||||
String extension = FormatHelper.getExtension(picFile);
|
String extension = FormatHelper.getExtension(picFile);
|
||||||
|
if (isMp4) {
|
||||||
|
extension = "mp4";
|
||||||
|
}
|
||||||
// 提取不包含拓展名的原文件名
|
// 提取不包含拓展名的原文件名
|
||||||
String[] extensions = fileName.split("\\.");
|
String[] extensions = fileName.split("\\.");
|
||||||
int splitLength = extensions.length;
|
int splitLength = extensions.length;
|
||||||
|
|||||||
@ -46,33 +46,12 @@ public class PermissionHelper {
|
|||||||
|
|
||||||
public static void CheckPermissions(final Context context, final CheckPermissionListener checkPermissionListener, String... permissionName) {
|
public static void CheckPermissions(final Context context, final CheckPermissionListener checkPermissionListener, String... permissionName) {
|
||||||
|
|
||||||
if (hasPermissions(context, permissionName)) {
|
// if (hasPermissions(context, permissionName)) {
|
||||||
if (checkPermissionListener != null) {
|
if (checkPermissionListener != null) {
|
||||||
checkPermissionListener.onAllGranted(true);
|
checkPermissionListener.onAllGranted(true);
|
||||||
}
|
}
|
||||||
}else {
|
// }else {
|
||||||
// AndPermission.with(context)
|
|
||||||
// .runtime()
|
|
||||||
// .permission(permissionName)
|
|
||||||
// .onGranted(new Action<List<String>>() {
|
|
||||||
// @Override
|
|
||||||
// public void onAction(List<String> permissions) {
|
|
||||||
// // 权限申请成功回调。
|
|
||||||
// if (checkPermissionListener != null) {
|
|
||||||
// checkPermissionListener.onAllGranted(false);
|
|
||||||
// }
|
// }
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .onDenied(new Action<List<String>>() {
|
|
||||||
// @Override
|
|
||||||
// public void onAction(List<String> permissions) {
|
|
||||||
// if (checkPermissionListener != null) {
|
|
||||||
// checkPermissionListener.onPartlyGranted(permissions, false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,8 @@ public class PDFPrint {
|
|||||||
public static void generatePDFFromWebView(final File file, final WebView webView, final OnPDFPrintListener onPDFPrintListener) {
|
public static void generatePDFFromWebView(final File file, final WebView webView, final OnPDFPrintListener onPDFPrintListener) {
|
||||||
PrintAttributes printAttributes = new PrintAttributes.Builder()
|
PrintAttributes printAttributes = new PrintAttributes.Builder()
|
||||||
.setMediaSize(PrintAttributes.MediaSize.ISO_A4)
|
.setMediaSize(PrintAttributes.MediaSize.ISO_A4)
|
||||||
.setResolution(new PrintAttributes.Resolution("RESOLUTION_ID", "RESOLUTION_ID", 600, 600))
|
.setResolution(new PrintAttributes.Resolution("RESOLUTION_ID", "RESOLUTION_ID", PrintAttributes.MediaSize.ISO_A4.getWidthMils(), PrintAttributes.MediaSize.ISO_A4.getWidthMils()))
|
||||||
|
.setDuplexMode(PrintAttributes.DUPLEX_MODE_NONE)
|
||||||
.setMinMargins(PrintAttributes.Margins.NO_MARGINS)
|
.setMinMargins(PrintAttributes.Margins.NO_MARGINS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user