....
This commit is contained in:
parent
10ac465aba
commit
4d8b9b728b
@ -1191,9 +1191,7 @@ fun openReddit(schemeString : String) {
|
||||
var uri = schemeString.toUri()
|
||||
val gmmIntentUri = Uri.parse(schemeString)
|
||||
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
|
||||
if (uri != null && uri.host?.contains("facebook") == true) {
|
||||
|
||||
} else {
|
||||
if(schemeString.contains("reddit")) {
|
||||
mapIntent.setPackage("com.reddit.frontpage")
|
||||
}
|
||||
lActivity?.startActivity(mapIntent)
|
||||
|
||||
@ -84,6 +84,7 @@ import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.utils.BitmapConverter
|
||||
import bums.lunatic.launcher.utils.SimpleFingerGestures
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.utils.beforeOneDay
|
||||
import bums.lunatic.launcher.view.TableRadioGroup
|
||||
import bums.lunatic.launcher.workers.LocationGetter
|
||||
import bums.lunatic.launcher.workers.RecentCall
|
||||
@ -109,7 +110,6 @@ import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
import java.net.URLEncoder
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
|
||||
|
||||
internal class LauncherHome : Fragment() {
|
||||
@ -489,7 +489,7 @@ internal class LauncherHome : Fragment() {
|
||||
WorkersDb.getRealm().writeBlocking {
|
||||
delete(
|
||||
query<RssData>()
|
||||
.query("pubDate < $0", beforeDay())
|
||||
.query("pubDate < $0", beforeOneDay())
|
||||
.query("category != $0 AND category != $1 ", RssDataType.GURU.name, RssDataType.MOST.name)
|
||||
.query("vote != $0", true).find()
|
||||
)
|
||||
@ -510,11 +510,14 @@ internal class LauncherHome : Fragment() {
|
||||
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
infosJob?.start()
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun queryVotes() {
|
||||
@ -527,7 +530,7 @@ internal class LauncherHome : Fragment() {
|
||||
) {
|
||||
beforeQuery()
|
||||
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)}}
|
||||
updateQuery(rQ)
|
||||
}
|
||||
@ -742,7 +745,7 @@ internal class LauncherHome : Fragment() {
|
||||
binding.infoList.visibility = View.INVISIBLE
|
||||
binding.notiList.visibility = View.INVISIBLE
|
||||
|
||||
var dateParam = beforeDay(Date(), 30).toString()
|
||||
var dateParam = beforeDay(30).toString()
|
||||
if (binding.missedCalls.isSelected) {
|
||||
WorkersDb.getRealm().apply {
|
||||
val result = query<RecentCall>().query("callDayTime >= $0", dateParam)
|
||||
|
||||
@ -3,6 +3,9 @@ package bums.lunatic.launcher.home
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.print.PDFPrint
|
||||
import android.view.KeyEvent
|
||||
import android.view.KeyEvent.ACTION_UP
|
||||
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.ACTION_MOVE
|
||||
import android.view.View
|
||||
import android.webkit.CookieManager
|
||||
import android.widget.Toast
|
||||
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.model.RssData
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
import io.realm.kotlin.UpdatePolicy
|
||||
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.Builder
|
||||
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.objects.CustomMenu
|
||||
import kr.lunaticbum.utils.content.ContextUtil
|
||||
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) {
|
||||
var rssId : String = ""
|
||||
@ -245,6 +262,15 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene
|
||||
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 {
|
||||
if (ev?.device?.name?.contains("BLE-M3") == true) {
|
||||
@ -353,6 +379,82 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene
|
||||
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() {
|
||||
double = false
|
||||
if(hasYoutubePlayer) {
|
||||
@ -371,5 +473,14 @@ class RssViewerActivity : AwesomeWebViewActivity(), View.OnGenericMotionListene
|
||||
}
|
||||
}
|
||||
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.RssDataInterface
|
||||
import bums.lunatic.launcher.model.others.Reddit
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.utils.beforeOneDay
|
||||
import com.google.gson.Gson
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
@ -14,14 +13,13 @@ import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.net.URL
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
object RssFeedsParser {
|
||||
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 limitDateTime = beforeDay(Date(),3)
|
||||
var limitDateTime = beforeOneDay()
|
||||
fun getFeeds(url : String) : List<RssDataInterface> {
|
||||
var returnList = mutableListOf<RssDataInterface>()
|
||||
try {
|
||||
@ -34,7 +32,7 @@ object RssFeedsParser {
|
||||
|
||||
fun getReddit(url : String, nsfw : Boolean): List<RssDataInterface> {
|
||||
var returnList = mutableListOf<RssDataInterface>()
|
||||
var dateTime = beforeDay(Date(),3)
|
||||
var dateTime = beforeOneDay()
|
||||
try {
|
||||
var mReddit = Gson().fromJson(InputStreamReader(getInputStream(url)!!), Reddit::class.java)
|
||||
mReddit.data?.children?.forEach {
|
||||
|
||||
@ -4,43 +4,6 @@ import bums.lunatic.launcher.beforeDay
|
||||
import bums.lunatic.launcher.utils.JamoUtils
|
||||
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 {
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package bums.lunatic.launcher.model
|
||||
|
||||
import bums.lunatic.launcher.utils.JamoUtils
|
||||
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.annotations.Ignore
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
@ -308,15 +308,15 @@ open class Dotax(var pageLink : String,
|
||||
before = dayString.toInt()
|
||||
if (dateDesc.contains("년")) {
|
||||
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("월")) {
|
||||
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("주")) {
|
||||
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("일")) {
|
||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
||||
dateTime = if (isBefore) beforeDayBy(date, before) else afterDay(date, before)
|
||||
} else if (dateDesc.contains("시간")) {
|
||||
dateTime =
|
||||
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.utils.JamoUtils
|
||||
import bums.lunatic.launcher.utils.afterDay
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.utils.beforeDayBy
|
||||
import org.json.JSONObject
|
||||
import java.util.Date
|
||||
|
||||
@ -1621,15 +1621,15 @@ open class VideoRenderer : RssDataInterface {
|
||||
before = dayString.toInt()
|
||||
if (dateDesc.contains("년")) {
|
||||
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("월")) {
|
||||
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("주")) {
|
||||
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("일")) {
|
||||
dateTime = if (isBefore) beforeDay(date, before) else afterDay(date, before)
|
||||
dateTime = if (isBefore) beforeDayBy(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("분")) {
|
||||
|
||||
@ -15,15 +15,23 @@ fun before30Min(date: Date): Long {
|
||||
return cal.timeInMillis
|
||||
}
|
||||
|
||||
fun beforeDay(): Long {
|
||||
fun beforeOneDay(): Long {
|
||||
val cal: Calendar = Calendar.getInstance()
|
||||
cal.setTime(Date())
|
||||
cal.add(Calendar.DAY_OF_YEAR, -1)
|
||||
cal.add(Calendar.HOUR_OF_DAY, -6)
|
||||
cal.add(Calendar.HOUR_OF_DAY, -3)
|
||||
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()
|
||||
cal.setTime(date)
|
||||
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.getRssData
|
||||
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 org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import java.util.Date
|
||||
|
||||
class ArcaGetter : BaseGetter {
|
||||
companion object {
|
||||
@ -87,7 +86,7 @@ class ArcaGetter : BaseGetter {
|
||||
this.dateTiem = dateTime
|
||||
}.apply {
|
||||
// BLog.LOGE("parseArcaLi >>>> ${this}")
|
||||
if (this.pubDate() > beforeDay(Date(), 3)) {
|
||||
if (this.pubDate() > beforeOneDay()) {
|
||||
tempArray.add(this)
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import bums.lunatic.launcher.model.RssData
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.utils.beforeOneDay
|
||||
import java.util.Calendar
|
||||
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 now = Date()
|
||||
val limitDateTime = beforeDay(now,3)
|
||||
val commicsDateTime = beforeDay(now,1)
|
||||
|
||||
val limitDateTime = beforeOneDay()
|
||||
val commicsDateTime = beforeDay(1)
|
||||
val temp = arrayListOf<RssData>()
|
||||
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
|
||||
@ -60,7 +60,7 @@ class RecentCallGetter : BaseGetter {
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun realWork(): Result {
|
||||
|
||||
var dateParam = beforeDay(Date(),dayRange).toString()
|
||||
var dateParam = beforeDay(dayRange).toString()
|
||||
var managedCursor = lActivity?.contentResolver?.query(
|
||||
CallLog.Calls.CONTENT_URI, arrayOf(
|
||||
CallLog.Calls.NUMBER,
|
||||
|
||||
@ -22,7 +22,6 @@ import java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.util.Date
|
||||
|
||||
class RecentSmsGetter : BaseGetter {
|
||||
companion object {
|
||||
@ -38,7 +37,7 @@ class RecentSmsGetter : BaseGetter {
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun realWork(): Result {
|
||||
var dateParam = beforeDay(Date(),dayRange).toString()
|
||||
var dateParam = beforeDay(dayRange).toString()
|
||||
val managedCursor = lActivity?.contentResolver?.query(
|
||||
Telephony.Sms.CONTENT_URI, arrayOf(
|
||||
Telephony.Sms.THREAD_ID,
|
||||
@ -340,7 +339,7 @@ internal class MmsQueryHelper(
|
||||
|
||||
fun convertData(cursor: Cursor?) {
|
||||
cursor ?: return
|
||||
val dateTime = beforeDay(Date(), dayRange)
|
||||
val dateTime = beforeDay(dayRange)
|
||||
cursor.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
|
||||
@ -27,7 +27,7 @@ import bums.lunatic.launcher.model.TelegramMessage
|
||||
import bums.lunatic.launcher.model.WeatherForcast
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
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.RealmConfiguration
|
||||
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.types.BaseRealmObject
|
||||
import io.realm.kotlin.types.TypedRealmObject
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.reflect.KClass
|
||||
@ -201,7 +200,7 @@ object WorkersDb {
|
||||
category: Collection<String>? = arrayListOf(),
|
||||
noLimit: Boolean = false) : RealmQuery<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 {
|
||||
if (JamoUtils.CHOSUNG.contains(keyword.split("")[0])) {
|
||||
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.FileProvider
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.ReportFragment.Companion.reportFragment
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
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.enums.Position
|
||||
import kr.lunaticbum.awesomewebview.helpers.BitmapHelper
|
||||
@ -95,6 +99,7 @@ import kotlin.math.abs
|
||||
|
||||
open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
Handler.Callback {
|
||||
var mediaUrls = arrayListOf<String>()
|
||||
protected var key: Int = 0
|
||||
|
||||
protected var rtl: Boolean = false
|
||||
@ -791,8 +796,19 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
|
||||
webView!!.setOnLongClickListener(OnLongClickListener {
|
||||
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
|
||||
) {
|
||||
if (!showMenuSavePhoto) {
|
||||
@ -807,19 +823,17 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
builder?.setItems(
|
||||
items
|
||||
) { dialog, which ->
|
||||
PermissionHelper.CheckPermissions(
|
||||
this@AwesomeWebViewActivity,
|
||||
object : CheckPermissionListener {
|
||||
override fun onAllGranted(sync: Boolean) {
|
||||
LogUtil.e("hitTestResult.extra >>> ${dialog} ,${which}")
|
||||
val url = hitTestResult.extra
|
||||
// 下载图片到本地
|
||||
CookieSyncManager.createInstance(this@AwesomeWebViewActivity)
|
||||
LogUtil.e("hitTestResult.extra >>> ${hitTestResult.extra}")
|
||||
CookieSyncManager.createInstance(applicationContext)
|
||||
CookieSyncManager.getInstance().sync()
|
||||
val cookieManager =
|
||||
CookieManager.getInstance()
|
||||
val cookie =
|
||||
cookieManager.getCookie(webView!!.url)
|
||||
DownPicUtil.downPic(
|
||||
File(Environment.getExternalStorageDirectory(),"bums").path,
|
||||
url,
|
||||
webView!!.settings.userAgentString,
|
||||
webView!!.url,
|
||||
@ -828,7 +842,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
override fun onDownFinish(path: String) {
|
||||
if (showToastPhotoSavedOrFailed) {
|
||||
Toast.makeText(
|
||||
this@AwesomeWebViewActivity,
|
||||
applicationContext,
|
||||
resources.getString(
|
||||
stringResPhotoSavedTo
|
||||
) + path,
|
||||
@ -847,7 +861,7 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
override fun onError() {
|
||||
if (showToastPhotoSavedOrFailed) {
|
||||
Toast.makeText(
|
||||
this@AwesomeWebViewActivity,
|
||||
applicationContext,
|
||||
resources.getString(
|
||||
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()
|
||||
dialog?.show()
|
||||
return@OnLongClickListener true
|
||||
@ -874,27 +878,27 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
false
|
||||
})
|
||||
|
||||
webView!!.setOnTouchListener(object : OnTouchListener {
|
||||
private var xDown = 0f
|
||||
private var yDown = 0f
|
||||
private var timeDown: Long = 0
|
||||
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||
if (v === webView && event.action == MotionEvent.ACTION_DOWN) {
|
||||
xDown = event.x
|
||||
yDown = event.y
|
||||
timeDown = System.currentTimeMillis()
|
||||
} else if (v === webView && event.action == MotionEvent.ACTION_UP) {
|
||||
if (abs((xDown - event.x).toDouble()) < 50 && abs(
|
||||
(yDown - event.y).toDouble()
|
||||
) < 50 && System.currentTimeMillis() - timeDown < 200
|
||||
) {
|
||||
// https://stackoverflow.com/a/5125620
|
||||
handler.sendEmptyMessageDelayed(MSG_CLICK_ON_WEBVIEW, 500)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
// webView!!.setOnTouchListener(object : OnTouchListener {
|
||||
// private var xDown = 0f
|
||||
// private var yDown = 0f
|
||||
// private var timeDown: Long = 0
|
||||
// override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||
// if (v === webView && event.action == MotionEvent.ACTION_DOWN) {
|
||||
// xDown = event.x
|
||||
// yDown = event.y
|
||||
// timeDown = System.currentTimeMillis()
|
||||
// } else if (v === webView && event.action == MotionEvent.ACTION_UP) {
|
||||
// if (abs((xDown - event.x).toDouble()) < 50 && abs(
|
||||
// (yDown - event.y).toDouble()
|
||||
// ) < 50 && System.currentTimeMillis() - timeDown < 200
|
||||
// ) {
|
||||
// // https://stackoverflow.com/a/5125620
|
||||
// handler.sendEmptyMessageDelayed(MSG_CLICK_ON_WEBVIEW, 500)
|
||||
// }
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
// })
|
||||
|
||||
val settings = webView!!.settings
|
||||
|
||||
@ -1239,6 +1243,10 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
open protected fun onHtml(value: String?) {
|
||||
|
||||
}
|
||||
|
||||
protected fun buildWebView(): WebView {
|
||||
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) {
|
||||
val viewId = v.id
|
||||
if (viewId == R.id.close) {
|
||||
@ -1443,16 +1453,23 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
if (path.exists() == false) {
|
||||
path.mkdirs()
|
||||
}
|
||||
|
||||
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?) {
|
||||
LogUtil.e("file.absolutePath >>> ${file?.absolutePath ?: "fail"}")
|
||||
}
|
||||
|
||||
override fun onError(exception: java.lang.Exception?) {
|
||||
LogUtil.e("generatePDFFromWebView >>> fail")
|
||||
exception?.printStackTrace()
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
hideMenu()
|
||||
} else if (viewId == R.id.menuFind) {
|
||||
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)
|
||||
return File.createTempFile(new_name, if (isVideo) ".mp4" else ".jpg", sd_directory)
|
||||
}
|
||||
|
||||
var hasYoutubePlayer = false
|
||||
open fun webviewOnPageFinished(){}
|
||||
inner class MyWebViewClient : WebViewClient() {
|
||||
@ -1865,11 +1883,15 @@ open class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener,
|
||||
ByteArrayInputStream("".toByteArray())
|
||||
)
|
||||
}
|
||||
|
||||
val url = request.url.toString()
|
||||
if(!hasYoutubePlayer) {
|
||||
hasYoutubePlayer = url.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)
|
||||
.contains("ads".toLowerCase(Locale.ROOT))) {
|
||||
LogUtil.e("shouldInterceptRequest request url contains ads >>> ${request.url.toString()}")
|
||||
|
||||
@ -8,6 +8,8 @@ import android.os.AsyncTask;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -28,26 +30,42 @@ public class DownPicUtil {
|
||||
* @param url
|
||||
*/
|
||||
public static void downPic(String url, DownFinishListener downFinishListener){
|
||||
downPic(url, null, null, null, downFinishListener);
|
||||
downPic(null, url, null, null, null, downFinishListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the pic
|
||||
* @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();
|
||||
File file = new File(filePath + File.separator + Environment.DIRECTORY_DOWNLOADS);
|
||||
if(!file.exists()){
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
loadPic(file.getPath(), url, userAgent, referer, cookie, downFinishListener);
|
||||
|
||||
loadPic(file.getPath(), url, userAgent, referer, cookie, downFinishListener, false);
|
||||
} 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>(){
|
||||
String fileName;
|
||||
InputStream is;
|
||||
@ -130,7 +148,9 @@ public class DownPicUtil {
|
||||
|
||||
// 提取文件格式真实拓展名
|
||||
String extension = FormatHelper.getExtension(picFile);
|
||||
|
||||
if (isMp4) {
|
||||
extension = "mp4";
|
||||
}
|
||||
// 提取不包含拓展名的原文件名
|
||||
String[] extensions = fileName.split("\\.");
|
||||
int splitLength = extensions.length;
|
||||
|
||||
@ -46,33 +46,12 @@ public class PermissionHelper {
|
||||
|
||||
public static void CheckPermissions(final Context context, final CheckPermissionListener checkPermissionListener, String... permissionName) {
|
||||
|
||||
if (hasPermissions(context, permissionName)) {
|
||||
// if (hasPermissions(context, permissionName)) {
|
||||
if (checkPermissionListener != null) {
|
||||
checkPermissionListener.onAllGranted(true);
|
||||
}
|
||||
}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);
|
||||
// }else {
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .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) {
|
||||
PrintAttributes printAttributes = new PrintAttributes.Builder()
|
||||
.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)
|
||||
.build();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user