This commit is contained in:
lunaticbum 2024-10-23 17:06:43 +09:00
parent 36b18d63fb
commit aa9a0a7b24
5 changed files with 57 additions and 82 deletions

View File

@ -225,6 +225,15 @@ internal class Feeds : Fragment() , CommadCallabck {
if (input.text.toString().trim().contains(" ")) { if (input.text.toString().trim().contains(" ")) {
val cmd = input.text.toString().trim().split(" ") val cmd = input.text.toString().trim().split(" ")
when(cmd[0]) { when(cmd[0]) {
"code"-> {
if (cmd[1].trim().length > 1) {
CoroutineScope(Dispatchers.IO).launch {
consoleLog("${cmd[0]} Start ${cmd[1]}")
String.format("https://glojav.us/search?q=",cmd[1]).getJ().let { doc -> FeedParseManager.parse(doc){consoleLog(it)} }
consoleLog("${cmd[0]} END ${cmd[1]}")
}
}
}
"car" -> { "car" -> {
if (cmd[1].trim().length > 2) { if (cmd[1].trim().length > 2) {
PrefHelper.carName = cmd[1].trim() PrefHelper.carName = cmd[1].trim()

View File

@ -175,72 +175,5 @@ class NLService : NotificationListenerService() {
} }
} }
var fusedLocationProviderClient: FusedLocationProviderClient? = null
@SuppressLint("MissingPermission")
private fun getLastLocation(context: Context) {
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
// BLog.LOGE("Location getLastLocation")
fusedLocationProviderClient?.getLastLocation()?.addOnSuccessListener(object :
OnSuccessListener<Location?> {
override fun onSuccess(location: Location?) {
// if (location != null) {
// // Log the latitude and longitude
// BLog.LOGE("Location Latitude: " + location.getLatitude())
// BLog.LOGE("Location Longitude: " + location.getLongitude())
//
// // Use Geocoder to get detailed location information
// try {
// val geocoder = Geocoder(context, Locale.getDefault())
// val addresses: List<Address>? = geocoder.getFromLocation(
// location.getLatitude(),
// location.getLongitude(),
// 1
// )
//
// addresses?.first()?.let {
// it.getAddressLine(0)?.let {
// Executors.newSingleThreadScheduledExecutor().schedule({
// try {
// //////-1002450229641
// val url =
// "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&text=남편의현위치는${it}"
// //7068729507
// // OkHttp 클라이언트 객체 생성
// val client = OkHttpClient.Builder()
// .connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
// .build()
//
// // GET 요청 객체 생성
// val builder: Request.Builder = Request.Builder().url(url)
// .addHeader("Content-Type", "application/json").get()
//
// val request: Request = builder.build()
//
// BLog.LOGE("telegram before request ")
// // OkHttp 클라이언트로 GET 요청 객체 전송
// val response: Response = client.newCall(request).execute()
// if (response.isSuccessful()) {
// // 응답 받아서 처리
// val body: ResponseBody? = response.body()
// if (body != null) {
//
// }
// } else BLog.LOGE("telegram Error Occurred")
//
// } catch (e: java.lang.Exception) {
// e.printStackTrace()
// }
// }, 5, TimeUnit.SECONDS)
// }
// }
// // Display location details on UI elements
// // Log detailed location information
// BLog.LOGE("Location Addresses: $addresses")
// } catch (e: IOException) {
// e.printStackTrace()
// }
// }
}
})
}
} }

View File

@ -75,11 +75,15 @@ fun getContactId(contentResolver: ContentResolver, phoneNumber: String?): String
return contactName return contactName
} }
fun DoubleArray.inRange(src : Double) : Boolean {
try {
if (this.max() >= src && this.min() >= src) {
return true
}
} catch (e : Exception) {
}
return false
}

View File

@ -17,11 +17,13 @@ import java.util.Date
val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15" val USAGT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15"
fun String.getJ() = Jsoup.connect(this).userAgent(USAGT).get() fun String.getJ() = Jsoup.connect(this).userAgent(USAGT).get()
object FeedParseManager { object FeedParseManager {
val parsers = listOf<SoInterface>(QVZTb2dpcmw,SkFWTW9zdA) val parsers = listOf<SoInterface>(QVZTb2dpcmw,SkFWTW9zdA,Z2xvamF2)
fun parse(doc : Document, consoleLog : (String)-> Unit) { fun parse(doc : Document, consoleLog : (String)-> Unit) {
consoleLog("FeedParseManager START") consoleLog("FeedParseManager START")
try { try {
parsers.filter { doc.title().contains(it.getName()) }.first()?.let {
consoleLog(doc.title())
parsers.filter { doc.title().contains(it.getName()) || doc.baseUri().contains(it.getName()) }.first()?.let {
it.parse(doc,consoleLog) it.parse(doc,consoleLog)
} }
} catch (e : Exception) { } catch (e : Exception) {
@ -35,6 +37,21 @@ interface SoInterface{
fun getName() : String fun getName() : String
fun parse(doc : Document, consoleLog : (String)-> Unit) fun parse(doc : Document, consoleLog : (String)-> Unit)
} }
object Z2xvamF2 : SoInterface {
override fun getName(): String {
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.toByteArray()))
}
override fun parse(doc : Document, consoleLog : (String)-> Unit) {
consoleLog(doc.html())
doc.getElementsByClass("group").forEach { group ->
// consoleLog("ogirl group >>> ${group.html()}")
consoleLog(group.getElementsByTag("img").attr("src"))
consoleLog(group.getElementsByTag("a").get(0).attr("href"))
consoleLog(group.getElementsByTag("a").get(0).attr("alt"))
}
}
}
object QVZTb2dpcmw : SoInterface { object QVZTb2dpcmw : SoInterface {
override fun getName(): String { override fun getName(): String {
return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray())) return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray()))

View File

@ -15,10 +15,12 @@ import android.widget.Toast
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import bums.lunatic.launcher.LauncherActivity.Companion.runWeatherGetter import bums.lunatic.launcher.LauncherActivity.Companion.runWeatherGetter
import bums.lunatic.launcher.helpers.PrefHelper import bums.lunatic.launcher.helpers.PrefHelper
import bums.lunatic.launcher.helpers.PrefLong
import bums.lunatic.launcher.helpers.PrefString import bums.lunatic.launcher.helpers.PrefString
import bums.lunatic.launcher.helpers.letTrue import bums.lunatic.launcher.helpers.letTrue
import bums.lunatic.launcher.model.LocationLog import bums.lunatic.launcher.model.LocationLog
import bums.lunatic.launcher.utils.BLog import bums.lunatic.launcher.utils.BLog
import bums.lunatic.launcher.utils.inRange
import bums.lunatic.launcher.workers.LocationGetter.Companion.latitude import bums.lunatic.launcher.workers.LocationGetter.Companion.latitude
import bums.lunatic.launcher.workers.LocationGetter.Companion.longitude import bums.lunatic.launcher.workers.LocationGetter.Companion.longitude
import com.google.android.gms.location.LocationServices import com.google.android.gms.location.LocationServices
@ -42,9 +44,6 @@ import java.util.concurrent.TimeUnit
class LocationUpdateService : Service(), LocationListener { class LocationUpdateService : Service(), LocationListener {
companion object { companion object {
private const val MIN_DISTANCE_CHANGE_FOR_UPDATES: Long = 200
private const val MIN_TIME_BW_UPDATES: Long = 30
fun pushLocation(context: Context, lat :Double, long : Double) { fun pushLocation(context: Context, lat :Double, long : Double) {
try { try {
val geocoder = Geocoder(context, Locale.getDefault()) val geocoder = Geocoder(context, Locale.getDefault())
@ -58,7 +57,7 @@ class LocationUpdateService : Service(), LocationListener {
writeBlocking { writeBlocking {
copyToRealm(loc) copyToRealm(loc)
} }
(list.size == 0 || (list.size > 0 && list.first().time < (System.currentTimeMillis() - (1000L * 60L * 5L)) )).letTrue { (list.size == 0 || (list.size > 0 && list.first().time < (System.currentTimeMillis() - (1000L * 60L * 5L))) && inRangeLocation(lat,long,50) == false).letTrue {
Executors.newSingleThreadScheduledExecutor().schedule({ Executors.newSingleThreadScheduledExecutor().schedule({
try { try {
//////-1002450229641 //////-1002450229641
@ -108,7 +107,20 @@ class LocationUpdateService : Service(), LocationListener {
e.printStackTrace() e.printStackTrace()
} }
} }
fun inRangeLocation(lat : Double, lon : Double, distance : Int) : Boolean {
var latRange = latitudeRange(lat, distance)
var lonRange = longitudeRange(lat, lon, distance)
if (latRange.inRange(lat) && lonRange.inRange(lon)) {
return true
} }
return false
}
}
protected var locationManager: LocationManager? = null protected var locationManager: LocationManager? = null
var checkGPS = false var checkGPS = false
var checkNetwork = false var checkNetwork = false
@ -156,7 +168,7 @@ class LocationUpdateService : Service(), LocationListener {
.isProviderEnabled(LocationManager.GPS_PROVIDER) .isProviderEnabled(LocationManager.GPS_PROVIDER)
checkNetwork = locationManager!! checkNetwork = locationManager!!
.isProviderEnabled(LocationManager.NETWORK_PROVIDER) .isProviderEnabled(LocationManager.NETWORK_PROVIDER)
locationManager?.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES.toFloat(), this) locationManager?.requestLocationUpdates(LocationManager.GPS_PROVIDER, PrefLong.locationTimePeriod.get(30), PrefLong.locationDistance.get(200).toFloat(), this)
if (locationManager != null) { if (locationManager != null) {
val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this) val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
fusedLocationClient.lastLocation.addOnSuccessListener { location -> fusedLocationClient.lastLocation.addOnSuccessListener { location ->