diff --git a/app/src/main/kotlin/bums/lunatic/launcher/feeds/Feeds.kt b/app/src/main/kotlin/bums/lunatic/launcher/feeds/Feeds.kt index 3d1c278..aaae800 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/feeds/Feeds.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/feeds/Feeds.kt @@ -225,6 +225,15 @@ internal class Feeds : Fragment() , CommadCallabck { if (input.text.toString().trim().contains(" ")) { val cmd = input.text.toString().trim().split(" ") 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" -> { if (cmd[1].trim().length > 2) { PrefHelper.carName = cmd[1].trim() diff --git a/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt b/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt index c26febb..f8a42de 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/receiver/NLService.kt @@ -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 { - 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
? = 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() -// } -// } - } - }) - } + } \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt b/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt index 2c75aae..e2ce181 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/utils/DataUtils.kt @@ -16,7 +16,7 @@ fun before30Min(date: Date): Long { } fun beforeDay(date: Date?, day: Int): Long { - val cal: Calendar = Calendar.getInstance() + val cal: Calendar = Calendar.getInstance() cal.setTime(date) cal.add(Calendar.DAY_OF_YEAR, Math.abs(day) * -1) return cal.timeInMillis @@ -75,11 +75,15 @@ fun getContactId(contentResolver: ContentResolver, phoneNumber: String?): String return contactName } - - - - - - +fun DoubleArray.inRange(src : Double) : Boolean { + try { + if (this.max() >= src && this.min() >= src) { + return true + } + } catch (e : Exception) { + + } + return false +} diff --git a/app/src/main/kotlin/bums/lunatic/launcher/utils/JsoupUtils.kt b/app/src/main/kotlin/bums/lunatic/launcher/utils/JsoupUtils.kt index d5a17a2..09eec4c 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/utils/JsoupUtils.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/utils/JsoupUtils.kt @@ -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" fun String.getJ() = Jsoup.connect(this).userAgent(USAGT).get() object FeedParseManager { - val parsers = listOf(QVZTb2dpcmw,SkFWTW9zdA) + val parsers = listOf(QVZTb2dpcmw,SkFWTW9zdA,Z2xvamF2) fun parse(doc : Document, consoleLog : (String)-> Unit) { consoleLog("FeedParseManager START") 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) } } catch (e : Exception) { @@ -35,6 +37,21 @@ interface SoInterface{ fun getName() : String 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 { override fun getName(): String { return String(Base64.getMimeDecoder().decode(this.javaClass.simpleName.plus("==").toByteArray())) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt index 9613733..56d032d 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt @@ -15,10 +15,12 @@ import android.widget.Toast import androidx.core.app.ActivityCompat import bums.lunatic.launcher.LauncherActivity.Companion.runWeatherGetter import bums.lunatic.launcher.helpers.PrefHelper +import bums.lunatic.launcher.helpers.PrefLong import bums.lunatic.launcher.helpers.PrefString import bums.lunatic.launcher.helpers.letTrue import bums.lunatic.launcher.model.LocationLog 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.longitude import com.google.android.gms.location.LocationServices @@ -42,9 +44,6 @@ import java.util.concurrent.TimeUnit class LocationUpdateService : Service(), LocationListener { 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) { try { val geocoder = Geocoder(context, Locale.getDefault()) @@ -58,7 +57,7 @@ class LocationUpdateService : Service(), LocationListener { writeBlocking { 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({ try { //////-1002450229641 @@ -108,7 +107,20 @@ class LocationUpdateService : Service(), LocationListener { 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 var checkGPS = false var checkNetwork = false @@ -156,7 +168,7 @@ class LocationUpdateService : Service(), LocationListener { .isProviderEnabled(LocationManager.GPS_PROVIDER) checkNetwork = locationManager!! .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) { val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this) fusedLocationClient.lastLocation.addOnSuccessListener { location ->