From e1ec3c12d2c37b9997a40393de1445c204570fc3 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Sun, 25 Aug 2024 14:45:57 +0900 Subject: [PATCH] . --- .../rasel/lunar/launcher/apps/AppDrawer.kt | 7 +- .../rasel/lunar/launcher/apps/AppsAdapter.kt | 5 +- .../lunar/launcher/apps/ContactAdapter.kt | 4 +- .../rasel/lunar/launcher/home/LauncherHome.kt | 171 ++++++------------ .../launcher/todos/MissedCallsAdapter.kt | 24 +++ .../lunar/launcher/todos/SmsLogsAdapter.kt | 31 +++- .../rasel/lunar/launcher/utils/DataManager.kt | 53 ++---- app/src/main/res/layout/launcher_home.xml | 9 +- 8 files changed, 141 insertions(+), 163 deletions(-) diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt index 819865ac..2ef3ab45 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt @@ -364,11 +364,10 @@ internal class AppDrawer : Fragment() { // appsAdapter?.updateGravity(settingsPrefs!!.getInt(KEY_DRAW_ALIGN, Gravity.CENTER)) // } - contactAdapter?.updateData(contactList) - - openSearch() - setKeyboardPadding() +// openSearch() +// setKeyboardPadding() + contactList.sortBy { it.name } contactAdapter?.updateData(contactList) /* pop up the keyboard */ diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt index e3795231..4cb1fd95 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt @@ -96,11 +96,10 @@ internal class AppsAdapter( /* update app list */ fun updateData(newList: List) { val diffUtilResult = DiffUtil.calculateDiff(AppsDiffUtil(oldList, newList)) - +// + diffUtilResult.dispatchUpdatesTo(this) oldList.clear() oldList.addAll(newList) - diffUtilResult.dispatchUpdatesTo(this) - newList.size.let { appsCount.text = it.toString() appsSize = it diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/ContactAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/ContactAdapter.kt index 37ac76c5..c7438d7f 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/ContactAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/ContactAdapter.kt @@ -89,11 +89,9 @@ internal class ContactAdapter ( /* update app list */ fun updateData(newList: List) { val diffUtilResult = DiffUtil.calculateDiff(ContactDiffUtil(oldList, newList)) - + diffUtilResult.dispatchUpdatesTo(this) oldList.clear() oldList.addAll(newList) - diffUtilResult.dispatchUpdatesTo(this) - newList.size.let { appsSize = it } 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 e27e7ab6..8868d79e 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -35,6 +35,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.LiveData import androidx.recyclerview.widget.LinearLayoutManager +import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.OneTimeWorkRequest import androidx.work.OneTimeWorkRequestBuilder import androidx.work.PeriodicWorkRequestBuilder @@ -77,6 +78,11 @@ internal class LauncherHome : Fragment() { private lateinit var settingsPrefs: SharedPreferences private lateinit var batteryReceiver: BatteryReceiver private var shouldResume = true + companion object { + var missedCalls = hashMapOf() + var callList = arrayListOf() + var smsList = arrayListOf() + } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { @@ -84,68 +90,34 @@ internal class LauncherHome : Fragment() { fragManager = lActivity!!.supportFragmentManager settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0) batteryReceiver = BatteryReceiver(binding.batteryProgress) - + mMissedCallsAdapter = MissedCallsAdapter(callList, requireContext()) + mSmsLogsAdapter = SmsLogsAdapter(smsList, requireContext()) binding.favAppsGroup.visibility = View.GONE - - mWorkManager = WorkManager.getInstance(lActivity!!.application); + mWorkManager = WorkManager.getInstance(requireContext()) mWorkManager?.cancelAllWork() - mWorkManager?.enqueue(PeriodicWorkRequestBuilder(30, TimeUnit.MINUTES).addTag("RecentSmsGetter").build()) - mWorkManager?.enqueue(PeriodicWorkRequestBuilder(30, TimeUnit.MINUTES).addTag("MissedCallGetter").build()) - mSmsWorkInfo = mWorkManager?.getWorkInfosByTagLiveData("RecentSmsGetter"); - mSavedWorkInfo = mWorkManager?.getWorkInfosByTagLiveData("MissedCallGetter"); - getOutputWorkInfo().observeForever { - BLog.LOGE("getOutputWorkInfo.last() >>> ${it.size}") - BLog.LOGE("getOutputWorkInfo.last() >>> ${it.first().outputData.size()}") - BLog.LOGE("getOutputWorkInfo.last() >>> ${it.last().outputData.size()}") - it.last()?.outputData?.keyValueMap?.forEach { t, u -> - try { - if (u is String) { - Gson().fromJson(u,MissedCall::class.java)?.let { - callList.add(it) - } - } - } catch (e : Exception) { - } finally { - showTodoList() - } - } + + mWorkManager?.enqueue(PeriodicWorkRequestBuilder(30, TimeUnit.SECONDS).addTag("RecentSmsGetter").build()) + mWorkManager?.enqueueUniquePeriodicWork("MissedCallGetter",ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,PeriodicWorkRequestBuilder(30, TimeUnit.SECONDS).addTag("MissedCallGetter").build()) + mWorkManager?.getWorkInfosByTagLiveData("RecentSmsGetter")?.observeForever { + if (binding.recentSms.isChecked) chooseAdpater() + BLog.LOGE("smsList.size >>> ${smsList.size}") + it.clear() } - getSmsInfos().observeForever { - BLog.LOGE("getSmsInfos.last() >>> ${it.size}") - BLog.LOGE("getSmsInfos.last() >>> ${it.first().outputData.size()}") - BLog.LOGE("getSmsInfos.last() >>> ${it.last().outputData.size()}") - it.last()?.outputData?.keyValueMap?.forEach { t, u -> - try { - if (u is String) { - BLog.LOGE("getSmsInfos() u >>> ${u}") - Gson().fromJson(u,RecentSmsLog::class.java)?.let { - smsList.add(it) - BLog.LOGE("getSmsInfos() u -> it >>> ${it}") - } - } - } catch (e : Exception) { - - } finally { - showTodoList() - } - } + mWorkManager?.getWorkInfosByTagLiveData("MissedCallGetter")?.observeForever { + if (binding.missedCalls.isChecked) chooseAdpater() + it.clear() } BLog.LOGE("onCreateView()") return binding.root } - private var mSavedWorkInfo: LiveData>? = null - private var mSmsWorkInfo: LiveData>? = null - fun getOutputWorkInfo(): LiveData> { - return mSavedWorkInfo!! - } + lateinit var mMissedCallsAdapter : MissedCallsAdapter + lateinit var mSmsLogsAdapter : SmsLogsAdapter + - fun getSmsInfos(): LiveData> { - return mSmsWorkInfo!! - } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -155,7 +127,6 @@ internal class LauncherHome : Fragment() { todosGestures() BLog.LOGE("onViewCreated()") - // mWorkManager. /* refresh the to-do list after getting back from TodoManager */ fragManager.addOnBackStackChangedListener { @@ -168,62 +139,58 @@ internal class LauncherHome : Fragment() { false } } + binding.missedCalls.setOnClickListener { binding.missedCalls.isChecked = true BLog.LOGE("binding.missedCalls >> ${binding.missedCalls.isChecked}") - try { - BLog.LOGE("callList >>> ${callList.size}") - binding.notes.layoutManager = LinearLayoutManager(requireContext()) - binding.notes.adapter = MissedCallsAdapter(callList, requireContext()) - (binding.notes.adapter as? MissedCallsAdapter)?.notifyDataSetChanged() - } catch (e : Exception) { - - }} + chooseAdpater() + } binding.recentSms.setOnClickListener { binding.recentSms.isChecked = true - BLog.LOGE("binding.recentSms >> ${binding.recentSms.isChecked}") - try { - BLog.LOGE("callList >>> ${smsList.size}") - binding.notes.layoutManager = LinearLayoutManager(requireContext()) - binding.notes.adapter = SmsLogsAdapter(smsList, requireContext()) - (binding.notes.adapter as? SmsLogsAdapter)?.notifyDataSetChanged() - } catch (e : Exception) { - - } + chooseAdpater() } binding.summaryChoose.setOnCheckedChangeListener { group, checkedId -> - if (binding.missedCalls.isChecked) { - if (callList.size > 0 && isAdded && isResumed && isVisible) { - try { - BLog.LOGE("callList >>> ${callList.size}") - binding.notes.adapter = MissedCallsAdapter(callList, requireContext()) - binding.notes.invalidate() - } catch (e : Exception) { + chooseAdpater() + } + } + + + fun chooseAdpater () { + if (binding.missedCalls.isChecked) { + if (missedCalls.size > 0 && isAdded && isResumed && isVisible) { + try { + callList.clear() + BLog.LOGE("chooseAdpater callList >>> ${callList.size}") + BLog.LOGE("chooseAdpater callList missedCalls >>> ${missedCalls.values.size}") + binding.mainList.adapter = mMissedCallsAdapter + missedCalls.forEach { t, u -> + callList.add(u) + }.apply { + mMissedCallsAdapter.updateData(callList) } + } catch (e : Exception) { + } - } else if(binding.recentSms.isChecked){ - //binding.notes.adapter = TodoAdapter(null, requireContext()) - if (smsList.size > 0 && isAdded && isResumed && isVisible) { - try { - BLog.LOGE("callList >>> ${callList.size}") - binding.notes.adapter = SmsLogsAdapter(smsList, requireContext()) - binding.notes.invalidate() - } catch (e : Exception) { + } + } else if(binding.recentSms.isChecked){ + if (smsList.size > 0 && isAdded && isResumed && isVisible) { + try { + BLog.LOGE("chooseAdpater smsList >>> ${smsList.size}") + binding.mainList.adapter = mSmsLogsAdapter + mSmsLogsAdapter.updateData(smsList) + } catch (e : Exception) { - } } } } } - override fun onResume() { super.onResume() BLog.LOGE("onResume()") if (shouldResume) { /* register battery changes */ requireContext().registerReceiver(batteryReceiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED)) - /* time and date */ binding.time.textLocale = Locale.US binding.date.textLocale = Locale.US @@ -234,17 +201,15 @@ internal class LauncherHome : Fragment() { binding.time.format12Hour = timeFormat binding.date.format12Hour = dateFormat } - /* show weather */ WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather) - + chooseAdpater() } } private var mWorkManager: WorkManager? = null - var callList = arrayListOf() - var smsList = arrayListOf() + @@ -348,7 +313,7 @@ internal class LauncherHome : Fragment() { override fun onLongPress(targetView: View,fingers: Int): Boolean { if (view?.equals(binding.batteryProgress) ?: false) { lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java)) - } else if (view?.equals(binding.notes) ?: false) { + } else if (view?.equals(binding.mainList) ?: false) { when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) { false -> launchTodoManager() /* show authentication screen if lock is on */ @@ -450,7 +415,7 @@ internal class LauncherHome : Fragment() { /* gestures on to-do area */ @SuppressLint("ClickableViewAccessibility") private fun todosGestures() { - binding.notes.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.notes , mFingerGestureListener)) + binding.mainList.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.mainList , mFingerGestureListener)) // binding.notes.setOnTouchListener(object : SwipeTouchListener(requireContext()) { // /* open TodoManager on long click */ // override fun onLongClick() { @@ -507,29 +472,7 @@ internal class LauncherHome : Fragment() { // .addToBackStack("").commit() } - /* to-do list */ - private fun showTodoList() { - if (binding.missedCalls.isChecked) { - if (callList.size > 0 && isAdded && isResumed && isVisible) { - try { - BLog.LOGE("callList >>> ${callList.size}") - binding.notes.adapter = MissedCallsAdapter(callList, requireContext()) - } catch (e : Exception) { - } - } - } else if(binding.recentSms.isChecked){ - //binding.notes.adapter = TodoAdapter(null, requireContext()) - if (smsList.size > 0 && isAdded && isResumed && isVisible) { - try { - BLog.LOGE("callList >>> ${callList.size}") - binding.notes.adapter = SmsLogsAdapter(smsList, requireContext()) - } catch (e : Exception) { - - } - } - } - } /* get time format string */ private val timeFormat: String? get() { diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/MissedCallsAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/MissedCallsAdapter.kt index 5702a3e4..ad100721 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/MissedCallsAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/MissedCallsAdapter.kt @@ -24,6 +24,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialog import rasel.lunar.launcher.LauncherActivity.Companion.lActivity @@ -33,6 +34,7 @@ import rasel.lunar.launcher.databinding.TodoDialogBinding import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard import rasel.lunar.launcher.home.MissedCall import rasel.lunar.launcher.utils.BLog +import rasel.lunar.launcher.utils.RecentSmsLog import java.util.* import kotlin.collections.ArrayList @@ -110,4 +112,26 @@ internal class MissedCallsAdapter( // } } + fun updateData(newList: ArrayList) { + val diffUtilResult = DiffUtil.calculateDiff(MissedCallDiffUtil(callList, newList)) + diffUtilResult.dispatchUpdatesTo(this) +// callList.clear() +// callList.addAll(newList) + } + } + +internal class MissedCallDiffUtil( + private val oldList: List, private val newList: List +) : DiffUtil.Callback() { + + override fun getOldListSize(): Int = oldList.size + override fun getNewListSize(): Int = newList.size + + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition].date == newList[newItemPosition].date + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition] == newList[newItemPosition] +} + diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt index 04c0448f..2724c436 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/SmsLogsAdapter.kt @@ -24,10 +24,14 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialog import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.R +import rasel.lunar.launcher.apps.AppsAdapter.Companion.appsSize +import rasel.lunar.launcher.apps.AppsDiffUtil +import rasel.lunar.launcher.apps.Packages import rasel.lunar.launcher.databinding.ListItemBinding import rasel.lunar.launcher.databinding.TodoDialogBinding import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard @@ -51,14 +55,14 @@ internal class SmsLogsAdapter( } override fun getItemCount(): Int { - BLog.LOGE("smsList.size >>> ${smsList.size}") + BLog.LOGE("SmsLogsAdapter smsList.size >>> ${smsList.size}") return smsList.size } @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: SmsLogHolder, position: Int) { val todo = smsList[position] - BLog.LOGE("smsList >>> ${smsList[position]}") + BLog.LOGE("SmsLogsAdapter smsList >>> ${smsList[position]}") holder.view.itemText.text = "\u25CF ${todo.person} ${todo.addr} , ${todo.body} : ${todo.pstDate} : ${todo.type}" /* multiline texts are enabled for TodoManager */ @@ -75,6 +79,15 @@ internal class SmsLogsAdapter( inner class SmsLogHolder(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root) + fun updateData(newList: List) { + BLog.LOGE("SmsLogsAdapter smsList newList >> ${newList.size}") + val diffUtilResult = DiffUtil.calculateDiff(SmsDiffUtil(smsList, newList)) + diffUtilResult.dispatchUpdatesTo(this) + BLog.LOGE("SmsLogsAdapter smsList smsList >> ${smsList.size}") +// smsList.clear() +// smsList.addAll(newList) + } + /* update dialog */ private fun updateDialog(position: Int) { // val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog) @@ -113,3 +126,17 @@ internal class SmsLogsAdapter( } } + +internal class SmsDiffUtil( + private val oldList: List, private val newList: List +) : DiffUtil.Callback() { + + override fun getOldListSize(): Int = oldList.size + override fun getNewListSize(): Int = newList.size + + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition].rcvDate == newList[newItemPosition].rcvDate + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition].rcvDate == newList[newItemPosition].rcvDate +} diff --git a/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt b/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt index 4022efaf..693b2d60 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/utils/DataManager.kt @@ -7,8 +7,11 @@ import android.provider.Telephony import androidx.work.Data import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import com.google.gson.Gson import rasel.lunar.launcher.LauncherActivity.Companion.lActivity +import rasel.lunar.launcher.home.LauncherHome.Companion.missedCalls +import rasel.lunar.launcher.home.LauncherHome.Companion.smsList import rasel.lunar.launcher.home.MissedCall import java.text.SimpleDateFormat import java.util.Date @@ -16,29 +19,28 @@ import java.util.Date class MissedCallGetter : Worker { constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) { - } - @SuppressLint("RestrictedApi") override fun doWork(): Result { - var resultData = Data.Builder() + var dateParam = Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24)).time.toString() - lActivity?.contentResolver?.query( + var managedCursor =lActivity?.contentResolver?.query( CallLog.Calls.CONTENT_URI, arrayOf( CallLog.Calls.NUMBER, CallLog.Calls.TYPE, CallLog.Calls.DATE, CallLog.Calls.DURATION, CallLog.Calls.CACHED_NAME, - ), CallLog.Calls.DATE + "> ? AND " + CallLog.Calls.TYPE + " > ?", arrayOf(dateParam, "2"), CallLog.Calls.DATE + " desc")?.let { managedCursor -> + ), CallLog.Calls.DATE + "> ? AND " + CallLog.Calls.TYPE + " > ?", arrayOf(dateParam, "2"), CallLog.Calls.DATE + " desc") + if(managedCursor != null && managedCursor.isClosed == false) { try { val number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER) val type = managedCursor.getColumnIndex(CallLog.Calls.TYPE) val date = managedCursor.getColumnIndex(CallLog.Calls.DATE) val duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION) val name = managedCursor.getColumnIndex(CallLog.Calls.CACHED_NAME) - var missedCalls = hashMapOf() + missedCalls.clear() while (managedCursor.moveToNext()) { val phNumber = managedCursor.getString(number) // mobile number val callType = managedCursor.getString(type) // call type @@ -96,9 +98,7 @@ class MissedCallGetter : Worker { } - missedCalls.forEach { t, u -> - resultData.put(t, u.toJson()) - } + } catch (e: Exception) { @@ -106,7 +106,7 @@ class MissedCallGetter : Worker { managedCursor.close() } } - return Result.success(resultData.build()); + return Result.success() } } @@ -119,12 +119,13 @@ class RecentSmsGetter : Worker { } + @SuppressLint("RestrictedApi") override fun doWork(): Result { BLog.LOGE("phNumber == onStart") - var resultData = Data.Builder() + var resultData = workDataOf("" to "") var dateParam = Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 3)).time.toString() - lActivity?.contentResolver?.query( + val managedCursor = lActivity?.contentResolver?.query( Telephony.Sms.CONTENT_URI, arrayOf( Telephony.Sms.ADDRESS, Telephony.Sms.TYPE, @@ -132,22 +133,21 @@ class RecentSmsGetter : Worker { Telephony.Sms.DATE_SENT, Telephony.Sms.BODY, Telephony.Sms.PERSON, - ), Telephony.Sms.DATE + ">= ? OR " + Telephony.Sms.DATE_SENT + " >= ?", arrayOf(dateParam, dateParam), Telephony.Sms.DEFAULT_SORT_ORDER)?.let { managedCursor -> + ), Telephony.Sms.DATE + ">= ? OR " + Telephony.Sms.DATE_SENT + " >= ?", arrayOf(dateParam, dateParam), Telephony.Sms.DEFAULT_SORT_ORDER) + if (managedCursor != null && managedCursor.isClosed == false) { try { - BLog.LOGE("phNumber == onResult") val address = managedCursor.getColumnIndex(Telephony.Sms.ADDRESS) val type = managedCursor.getColumnIndex(Telephony.Sms.TYPE) val date = managedCursor.getColumnIndex(Telephony.Sms.DATE) val sendDate = managedCursor.getColumnIndex(Telephony.Sms.DATE_SENT) val bodyIdx = managedCursor.getColumnIndex(Telephony.Sms.BODY) val name = managedCursor.getColumnIndex(Telephony.Sms.PERSON) - var missedCalls = arrayListOf() while (managedCursor.moveToNext()) { val phNumber = managedCursor.getString(address) // mobile number val callType = managedCursor.getString(type) // call type val reciveDate = managedCursor.getString(date) // call date val sendedDate = managedCursor.getString(sendDate) // call date - val smsBody = managedCursor.getString(bodyIdx) + val smsBody = managedCursor.getString(bodyIdx).replace("\n"," ") val callerName = managedCursor.getString(name) var dir: String = "" @@ -161,14 +161,6 @@ class RecentSmsGetter : Worker { Telephony.Sms.MESSAGE_TYPE_FAILED -> {dir = "MESSAGE_TYPE_FAILED"} Telephony.Sms.MESSAGE_TYPE_QUEUED -> {dir = "MESSAGE_TYPE_QUEUED"} } - - BLog.LOGE("phNumber == ${phNumber}\n" + - " dir == ${dir}\n" + - " reciveDate == ${reciveDate}\n" + - " sendedDate == ${sendedDate}\n" + - " smsBody == ${smsBody}\n" + - " callerName == ${callerName}\n") - var log = RecentSmsLog( phNumber, dir, @@ -177,22 +169,17 @@ class RecentSmsGetter : Worker { smsBody, callerName ?: "" ) - BLog.LOGE("resultData put ${phNumber +"_"+ reciveDate} >>> ${log.toJson()}") - resultData.put(phNumber +"_"+ reciveDate, log.toJson()) + BLog.LOGE("RecentSmsGetter resultData put ${phNumber +"_"+ reciveDate} >>> ${log.toJson()}") + smsList.add(log) + } - - - - -// resultData.put() } catch (e: Exception) { } finally { managedCursor.close() } } - - return Result.success(resultData.build()); + return Result.success() } } diff --git a/app/src/main/res/layout/launcher_home.xml b/app/src/main/res/layout/launcher_home.xml index a170b675..ef7d0418 100644 --- a/app/src/main/res/layout/launcher_home.xml +++ b/app/src/main/res/layout/launcher_home.xml @@ -73,7 +73,7 @@ app:layout_constraintLeft_toLeftOf="parent" android:orientation="horizontal" app:layout_constraintRight_toRightOf="parent" - android:layout_height="wrap_content" + android:layout_height="40dp" app:layout_constraintTop_toBottomOf="@+id/batteryProgress" > + app:layout_constraintTop_toBottomOf="@+id/mainList" /> \ No newline at end of file