This commit is contained in:
lunaticbum 2024-10-16 15:59:59 +09:00
parent 8cd2ffc16d
commit 3f2a92b880
10 changed files with 315 additions and 24 deletions

View File

@ -6,6 +6,7 @@
android:required="false" /> android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
@ -24,6 +25,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" /> <uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALENDAR" /> <uses-permission android:name="android.permission.READ_CALENDAR" />
@ -31,6 +33,7 @@
<!-- Always include this permission --> <!-- Always include this permission -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- Include only if your app benefits from precise location access. --> <!-- Include only if your app benefits from precise location access. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

View File

@ -85,6 +85,7 @@ import rasel.lunar.launcher.databinding.LauncherActivityBinding
import rasel.lunar.launcher.databinding.RecommendedHourlyDressBinding import rasel.lunar.launcher.databinding.RecommendedHourlyDressBinding
import rasel.lunar.launcher.feeds.Feeds import rasel.lunar.launcher.feeds.Feeds
import rasel.lunar.launcher.feeds.WidgetHost import rasel.lunar.launcher.feeds.WidgetHost
import rasel.lunar.launcher.helpers.BluetoothManager
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPLICATION_THEME import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPLICATION_THEME
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_FIRST_LAUNCH import rasel.lunar.launcher.helpers.Constants.Companion.KEY_FIRST_LAUNCH
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR import rasel.lunar.launcher.helpers.Constants.Companion.KEY_STATUS_BAR
@ -433,9 +434,14 @@ internal class LauncherActivity : AppCompatActivity() {
super.onDestroy() super.onDestroy()
appWidgetHost?.stopListening() appWidgetHost?.stopListening()
} }
var blutoothManager : BluetoothManager? = null
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
blutoothManager = BluetoothManager(this)
blutoothManager?.register()
blutoothManager?.initBluetoothAdapter()
blutoothManager?.blueToothState()
blutoothManager?.getPairedDevices()
BLog.LOGE("LauncherActivity onStart()") BLog.LOGE("LauncherActivity onStart()")
statusBarView() statusBarView()
setBgColor() setBgColor()
@ -444,12 +450,14 @@ internal class LauncherActivity : AppCompatActivity() {
@RequiresApi(Build.VERSION_CODES.O_MR1) @RequiresApi(Build.VERSION_CODES.O_MR1)
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
blutoothManager?.getPairedDevices()
BLog.LOGE("LauncherActivity onResume") BLog.LOGE("LauncherActivity onResume")
} }
private fun welcomeDialog() { private fun welcomeDialog() {
var needAsk = if ( var needAsk = if (
this.checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED ||
@ -460,6 +468,7 @@ internal class LauncherActivity : AppCompatActivity() {
this.checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
) { ) {
true true
@ -490,6 +499,7 @@ internal class LauncherActivity : AppCompatActivity() {
/* phone permission */ /* phone permission */
if ( if (
this.checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED ||
@ -500,9 +510,12 @@ internal class LauncherActivity : AppCompatActivity() {
this.checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED ||
this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
) { ) {
this.requestPermissions(arrayOf( this.requestPermissions(arrayOf(
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.READ_CALENDAR, Manifest.permission.READ_CALENDAR,
Manifest.permission.WRITE_CALENDAR, Manifest.permission.WRITE_CALENDAR,
Manifest.permission.READ_CONTACTS, Manifest.permission.READ_CONTACTS,
@ -513,6 +526,7 @@ internal class LauncherActivity : AppCompatActivity() {
Manifest.permission.RECEIVE_MMS, Manifest.permission.RECEIVE_MMS,
Manifest.permission.RECEIVE_SMS, Manifest.permission.RECEIVE_SMS,
Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.CALL_PHONE, Manifest.permission.CALL_PHONE,
Manifest.permission.READ_SMS), 1) Manifest.permission.READ_SMS), 1)

View File

@ -282,7 +282,9 @@ internal class AppDrawer : Fragment() {
val chechHandler = Handler(Looper.getMainLooper()) val chechHandler = Handler(Looper.getMainLooper())
val cancelSearch = Runnable { lActivity?.viewPager?.currentItem = 1 } val cancelSearch = Runnable {
// lActivity?.viewPager?.currentItem = 1
}
fun registCancelSearch() { fun registCancelSearch() {
chechHandler.removeCallbacks(cancelSearch) chechHandler.removeCallbacks(cancelSearch)

View File

@ -18,17 +18,21 @@
package rasel.lunar.launcher.feeds package rasel.lunar.launcher.feeds
import android.Manifest
import android.app.Activity.RESULT_CANCELED import android.app.Activity.RESULT_CANCELED
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.ResultReceiver import android.speech.RecognitionListener
import android.speech.RecognizerIntent
import android.speech.SpeechRecognizer
import android.text.method.ScrollingMovementMethod import android.text.method.ScrollingMovementMethod
import android.view.ContextMenu import android.view.ContextMenu
import android.view.Gravity import android.view.Gravity
@ -52,7 +56,6 @@ import io.realm.kotlin.ext.query
import io.realm.kotlin.query.Sort import io.realm.kotlin.query.Sort
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -65,7 +68,6 @@ import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.LauncherActivity.Companion.refreshDeviceData import rasel.lunar.launcher.LauncherActivity.Companion.refreshDeviceData
import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds import rasel.lunar.launcher.LauncherActivity.Companion.refreshFeeds
import rasel.lunar.launcher.R import rasel.lunar.launcher.R
import rasel.lunar.launcher.apps.ContactMenu
import rasel.lunar.launcher.databinding.FeedsBinding import rasel.lunar.launcher.databinding.FeedsBinding
import rasel.lunar.launcher.feeds.rss.RssAdapter import rasel.lunar.launcher.feeds.rss.RssAdapter
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_HEIGHTS import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_HEIGHTS
@ -76,33 +78,22 @@ import rasel.lunar.launcher.helpers.Constants.Companion.requestCreateWidget
import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget import rasel.lunar.launcher.helpers.Constants.Companion.requestPickWidget
import rasel.lunar.launcher.helpers.PrefHelper import rasel.lunar.launcher.helpers.PrefHelper
import rasel.lunar.launcher.home.LauncherHome.Companion.home import rasel.lunar.launcher.home.LauncherHome.Companion.home
import rasel.lunar.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl
import rasel.lunar.launcher.home.LauncherHome.Companion.listTags import rasel.lunar.launcher.home.LauncherHome.Companion.listTags
import rasel.lunar.launcher.model.CiliMagnet import rasel.lunar.launcher.model.CiliMagnet
import rasel.lunar.launcher.model.MostItem
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.RssDataType import rasel.lunar.launcher.model.RssDataType
import rasel.lunar.launcher.model.jGuruTag import rasel.lunar.launcher.model.jGuruTag
import rasel.lunar.launcher.model.dateFormat
import rasel.lunar.launcher.model.getRssData
import rasel.lunar.launcher.utils.BLog import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.FeedParseManager import rasel.lunar.launcher.utils.FeedParseManager
import rasel.lunar.launcher.utils.JamoUtils
import rasel.lunar.launcher.utils.RssList.jGuruMain import rasel.lunar.launcher.utils.RssList.jGuruMain
import rasel.lunar.launcher.utils.USAGT
import rasel.lunar.launcher.utils.getJ import rasel.lunar.launcher.utils.getJ
import rasel.lunar.launcher.workers.BaseGetter
import rasel.lunar.launcher.workers.RecentCallGetter import rasel.lunar.launcher.workers.RecentCallGetter
import rasel.lunar.launcher.workers.RecentSmsGetter import rasel.lunar.launcher.workers.RecentSmsGetter
import rasel.lunar.launcher.workers.WorkersDb import rasel.lunar.launcher.workers.WorkersDb
import java.net.URLEncoder import java.net.URLEncoder
import java.nio.charset.Charset import java.nio.charset.Charset
import java.text.SimpleDateFormat
import java.util.Base64 import java.util.Base64
import java.util.Date
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
internal class Feeds : Fragment() , CommadCallabck { internal class Feeds : Fragment() , CommadCallabck {
@ -210,7 +201,7 @@ internal class Feeds : Fragment() , CommadCallabck {
override fun collectComplete() { override fun collectComplete() {
} }
var speechRecognizer : SpeechRecognizer? = null
/* start rss service if network is active and rss url is not empty */ /* start rss service if network is active and rss url is not empty */
private fun startService() { private fun startService() {
@ -304,6 +295,86 @@ internal class Feeds : Fragment() , CommadCallabck {
binding.expandRss.isChecked = false binding.expandRss.isChecked = false
} else { } else {
when (input.text.toString()) { when (input.text.toString()) {
"spe"->{
speechRecognizer?.stopListening()
speechRecognizer?.destroy()
speechRecognizer = null
}
"sps"->{
lActivity?.let { lActivity ->
if (lActivity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
lActivity.requestPermissions(arrayOf(Manifest.permission.RECORD_AUDIO), 1)
} else {
speechRecognizer = SpeechRecognizer.createSpeechRecognizer(lActivity)
val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
intent.putExtra(
RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
)
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true)
speechRecognizer?.setRecognitionListener(object : RecognitionListener {
override fun onReadyForSpeech(params: Bundle) {
consoleLog("onReadyForSpeech ")
}
override fun onBeginningOfSpeech() {
consoleLog("onBeginningOfSpeech ")
}
override fun onRmsChanged(rmsdB: Float) {}
override fun onBufferReceived(buffer: ByteArray) {}
override fun onEndOfSpeech() {
consoleLog("onEndOfSpeech ")
}
override fun onError(error: Int) {
consoleLog("onError ${error}")
}
override fun onResults(results: Bundle) {
val matches =
results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)
if (matches != null) {
val recognizedText = matches[0]
consoleLog("recognizedText ${recognizedText}")
}
}
override fun onPartialResults(partialResults: Bundle) {
consoleLog("recognizedText ${partialResults}")
}
override fun onEvent(eventType: Int, params: Bundle) {}
})
speechRecognizer?.startListening(intent)
}
}
}
"citys" -> {
val baseUrl = "https://www.worldcitydb.com/"
var nations = arrayListOf<String>()
CoroutineScope(Dispatchers.IO).launch {
"https://www.worldcitydb.com/search-by-country?lang=ko".getJ().let { doc ->
BLog.LOGE("it.title() >> ${doc.title()}")
doc.getElementsByTag("tr").forEach { table ->
table.children().forEach {
it.getElementsByTag("td").forEach { td ->
td.children().forEach {
if (it.tag().name.equals("a")) {
BLog.LOGE("TD>>A ${it}")
it.text()
}
}
}
}
}
}
}
}
"loc_ck" -> { "loc_ck" -> {
FeedsResult().show(parentFragmentManager, "") FeedsResult().show(parentFragmentManager, "")
} }

View File

@ -14,6 +14,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.gson.Gson import com.google.gson.Gson
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import io.realm.kotlin.query.Sort
import rasel.lunar.launcher.BuildConfig import rasel.lunar.launcher.BuildConfig
import rasel.lunar.launcher.apps.DismissCalback import rasel.lunar.launcher.apps.DismissCalback
import rasel.lunar.launcher.databinding.FeedsResultMenuBinding import rasel.lunar.launcher.databinding.FeedsResultMenuBinding
@ -36,7 +37,7 @@ internal class FeedsResult : BottomSheetDialogFragment() {
/* get package name from fragment's tag */ /* get package name from fragment's tag */
searchWord = tag.toString() searchWord = tag.toString()
WorkersDb.getRealm().query<LocationLog>().find()?.let { WorkersDb.getRealm().query<LocationLog>().sort("time", Sort.DESCENDING).find()?.let {
if (it.size > 0) { if (it.size > 0) {
binding.logs.text = it.map { binding.logs.text = it.map {
BLog.LOGE("LocLog >> ${it.toString()}") BLog.LOGE("LocLog >> ${it.toString()}")

View File

@ -0,0 +1,22 @@
package rasel.lunar.launcher.helpers;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice;
import java.lang.reflect.Method;
import rasel.lunar.launcher.utils.BLog;
public class BleHelper {
@SuppressLint("MissingPermission")
public static boolean isConnected(BluetoothDevice device) {
try {
Method m = device.getClass().getMethod("isConnected", (Class[]) null);
boolean connected = (boolean) m.invoke(device, (Object[]) null);
BLog.INSTANCE.LOGE("D >> " + device.getName() + " || isConnected >>> " + (connected ? "TRUE" : "FALSE"));
return connected;
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}

View File

@ -0,0 +1,172 @@
package rasel.lunar.launcher.helpers
import android.Manifest
import android.annotation.SuppressLint
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import okhttp3.ConnectionPool
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okhttp3.ResponseBody
import org.apache.commons.lang3.ObjectUtils.Null
import rasel.lunar.launcher.utils.BLog
import rasel.lunar.launcher.utils.BLog.LOGE
import java.util.concurrent.TimeUnit
class BluetoothManager {
enum class BLUETOOTH_STATE(val statestr: String) {
ENABLED("enabledBlutooth"),
DISABLED("disableBlutooth"),
NOT_SUPPORT("notSupport")
}
lateinit var context: Context
var blueToothAdapter:BluetoothAdapter? = null
constructor(context: Context) {
this.context = context
}
constructor() {
}
// init {
// this.context = context
// }
fun initBluetoothAdapter(){
if ( blueToothAdapter == null ){
val bluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as android.bluetooth.BluetoothManager
blueToothAdapter = bluetoothManager.getAdapter()
}
}
fun register(){
if (context == null) return
context.registerReceiver(bluetoothreceiver, addFilterAction())
}
fun unregister(){
if (context == null) return
context.unregisterReceiver(bluetoothreceiver)
}
//페어링된 디바이스 정보 가져오기
fun getPairedDevices() {
val bluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as android.bluetooth.BluetoothManager
blueToothAdapter = bluetoothManager.adapter
if (ActivityCompat.checkSelfPermission(context,Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) return
var pairedDevices = blueToothAdapter?.bondedDevices
if (pairedDevices?.size ?: 0 > 0) {
pairedDevices?.forEach { i ->
//bondState : 12 (페어링 등록된 상태)
//bondState : 10 (페어링 등록 안됨)
BLog.LOGE("getPairedDevices() / name : ${i.name}")
BLog.LOGE("getPairedDevices() / bondState : ${i.bondState}")
if(i.name.contains("SOUL") && isConnected(i)) {
sendToI()
}
}
}
}
fun sendToI() {
CoroutineScope(Dispatchers.IO).launch {
val url = "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&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) {
}
} else BLog.LOGE("telegram Error Occurred")
}
}
@SuppressLint("MissingPermission")
fun isConnected(device: BluetoothDevice): Boolean {
try {
val m = device.javaClass.getMethod("isConnected")
val connected = m.invoke(device) as Boolean
BLog.LOGE("D >> " + device.name + " || isConnected >>> " + (if (connected) "TRUE" else "FALSE"))
return connected
} catch (e: Exception) {
throw IllegalStateException(e)
}
}
//블루투스 상태(켜짐 / 꺼짐 / 지원 불가 기기)
fun blueToothState(): String {
if (blueToothAdapter != null) {
if (blueToothAdapter!!.isEnabled) {
return BLUETOOTH_STATE.ENABLED.statestr
} else {
return BLUETOOTH_STATE.DISABLED.statestr
}
}
return BLUETOOTH_STATE.NOT_SUPPORT.statestr
}
//add Receive action
private fun addFilterAction(): IntentFilter {
val stateFilter = IntentFilter()
stateFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED) //BluetoothAdapter.ACTION_STATE_CHANGED : 블루투스 상태변화 액션
stateFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)
stateFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED) //연결 확인
stateFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED) //연결 끊김 확인
/*
stateFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED)
stateFilter.addAction(BluetoothDevice.ACTION_FOUND) //기기 검색됨
stateFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED) //기기 검색 시작
stateFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED) //기기 검색 종료
stateFilter.addAction(BluetoothDevice.ACTION_PAIRING_REQUEST)
*/
return stateFilter
}
//BlueTooth Receiver
private var bluetoothreceiver = object : BroadcastReceiver(){
override fun onReceive(context: Context?, intent: Intent?) {
var state = intent?.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)
BLog.LOGE("onReceive() / state : ${state}")
val action = intent!!.action
BLog.LOGE("onReceive() / action : ${action}")
if (context == null) return
if (ActivityCompat.checkSelfPermission(context!!, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) return
val device: BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)!!
BLog.LOGE("onReceive() / device.name : ${device.name}")
BLog.LOGE("onReceive() / device.type : ${device.type}")
if(device.name.contains("SOUL") && isConnected(device)) {
sendToI()
}
}
}
}

View File

@ -36,6 +36,7 @@ import com.squareup.picasso.Picasso
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
import rasel.lunar.launcher.R import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.ListItemWithBinding import rasel.lunar.launcher.databinding.ListItemWithBinding
import rasel.lunar.launcher.model.RssData
import rasel.lunar.launcher.model.RssDataInterface import rasel.lunar.launcher.model.RssDataInterface
import rasel.lunar.launcher.model.RssDataType import rasel.lunar.launcher.model.RssDataType
import rasel.lunar.launcher.openDotax import rasel.lunar.launcher.openDotax
@ -56,8 +57,7 @@ internal class RssItemAdapter (
val emptyDate = " - " val emptyDate = " - "
val dateViewClick = View.OnClickListener { v -> val dateViewClick = View.OnClickListener { v ->
(v?.tag as? Int)?.let { idx -> (v?.tag as? RssData)?.let { rss ->
val rss = rssDataItemLis[idx]
when(rss.category()) { when(rss.category()) {
RssDataType.GURU,RssDataType.Most,RssDataType.REDDIT_nsfw -> { RssDataType.GURU,RssDataType.Most,RssDataType.REDDIT_nsfw -> {
v.findViewById<ShapeableImageView>(R.id.circle_preview)?.let { v.findViewById<ShapeableImageView>(R.id.circle_preview)?.let {
@ -125,7 +125,7 @@ internal class RssItemAdapter (
holder.view.circlePreview.setImageDrawable(null) holder.view.circlePreview.setImageDrawable(null)
} }
holder.view.root.tag = position holder.view.root.tag = rssData
holder.view.root.setOnClickListener(dateViewClick) holder.view.root.setOnClickListener(dateViewClick)
// holder.view.root.setOnLongClickListener(mLongClickListener) // holder.view.root.setOnLongClickListener(mLongClickListener)
} }

View File

@ -6,6 +6,8 @@ import io.realm.kotlin.ext.realmAnyListOf
import io.realm.kotlin.ext.realmListOf import io.realm.kotlin.ext.realmListOf
import io.realm.kotlin.types.RealmList import io.realm.kotlin.types.RealmList
import io.realm.kotlin.types.RealmObject import io.realm.kotlin.types.RealmObject
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale import java.util.Locale
class LocationLog : RealmObject { class LocationLog : RealmObject {
@ -28,8 +30,11 @@ class LocationLog : RealmObject {
var mPhone: String? = null var mPhone: String? = null
var mUrl: String? = null var mUrl: String? = null
var time : Long = 0L var time : Long = 0L
var timeString : String? = null
fun fillData(address: Address) { fun fillData(address: Address) {
time = System.currentTimeMillis() time = System.currentTimeMillis()
timeString = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())
mFeatureName = address.featureName mFeatureName = address.featureName
mAddressLines.apply { mAddressLines.apply {
for (i in 0..address.maxAddressLineIndex) { for (i in 0..address.maxAddressLineIndex) {

View File

@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_margin="100dp"
android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:padding="@dimen/twelve" android:padding="@dimen/twelve"
android:clickable="true" android:clickable="true"
@ -13,11 +14,11 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/logs" android:id="@+id/logs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="match_parent"/>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>