...
This commit is contained in:
parent
5929aee345
commit
87263747f3
@ -97,6 +97,7 @@ import rasel.lunar.launcher.todos.NotificationItemAdapter
|
||||
import rasel.lunar.launcher.todos.RssItemAdapter
|
||||
import rasel.lunar.launcher.todos.SmsLogsAdapter
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import rasel.lunar.launcher.utils.JamoUtils
|
||||
import rasel.lunar.launcher.utils.RssList.jGuruMain
|
||||
import rasel.lunar.launcher.utils.SimpleFingerGestures
|
||||
import rasel.lunar.launcher.utils.beforeDay
|
||||
@ -122,7 +123,7 @@ internal class LauncherHome : Fragment() {
|
||||
companion object {
|
||||
var home : LauncherHome? = null
|
||||
var lastedFinishedPageUrl : String = ""
|
||||
var recentCalls = hashMapOf<String, RecentCall>()
|
||||
var recentCalls = arrayListOf<RecentCall>()
|
||||
var callList = arrayListOf<RecentCall>()
|
||||
var smsList = arrayListOf<RecentSms>()
|
||||
var listTags = arrayListOf<RssDataInterface>()
|
||||
@ -180,7 +181,7 @@ internal class LauncherHome : Fragment() {
|
||||
mRssAdapter = RssItemAdapter(requireContext())
|
||||
|
||||
val decoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)
|
||||
binding.mainList.addItemDecoration(decoration)
|
||||
|
||||
binding.notiList.addItemDecoration(decoration)
|
||||
binding.infoList.addItemDecoration(decoration)
|
||||
binding.missedCalls.isSelected = true
|
||||
@ -188,7 +189,7 @@ internal class LauncherHome : Fragment() {
|
||||
binding.infoList.visibility = View.GONE
|
||||
|
||||
binding.notiList.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.mainList.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.mainList.layoutManager = GridLayoutManager(requireContext(),2)
|
||||
binding.smsList.layoutManager = GridLayoutManager(requireContext(),2)
|
||||
binding.infoList.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
||||
@ -351,8 +352,13 @@ internal class LauncherHome : Fragment() {
|
||||
var rQ = WorkersDb.getRealm().query<RssData>().query("pubDate > $0", beforeDay(Date(),3))
|
||||
if(keyword.length > 0)
|
||||
keyword.split("").forEach {
|
||||
rQ = rQ.query("title CONTAINS $0 OR title CONTAINS $1", it.toUpperCase(), it.toLowerCase())
|
||||
if (Character.codePointAt(it, 0) in 0xAC00..0xD79D) {
|
||||
rQ = rQ.query("title CONTAINS $0 OR chosung CONTAINS $1 ", it, JamoUtils.splitOne(it))
|
||||
} else {
|
||||
rQ = rQ.query("title CONTAINS $0 OR title CONTAINS $1", it.toUpperCase(), it.toLowerCase())
|
||||
}
|
||||
}
|
||||
|
||||
category?.let {
|
||||
rQ = rQ.query("category == $0", it)
|
||||
}
|
||||
@ -571,18 +577,14 @@ internal class LauncherHome : Fragment() {
|
||||
if (recentCalls.size > 0) {
|
||||
try {
|
||||
callList.clear()
|
||||
recentCalls.forEach { t, u ->
|
||||
callList.add(u)
|
||||
}.apply {
|
||||
callList.sortByDescending { it.date }
|
||||
callList.addAll(recentCalls)
|
||||
callList.sortByDescending { it.date }
|
||||
// Handler(Looper.getMainLooper()).post {
|
||||
binding.mainList.visibility = View.VISIBLE
|
||||
mMissedCallsAdapter.updateData(callList)
|
||||
binding.recentSms.isSelected = false
|
||||
binding.otherCheck.isSelected = false
|
||||
binding.notice.isSelected = false
|
||||
// }
|
||||
}
|
||||
binding.mainList.visibility = View.VISIBLE
|
||||
mMissedCallsAdapter.updateData(callList)
|
||||
binding.recentSms.isSelected = false
|
||||
binding.otherCheck.isSelected = false
|
||||
binding.notice.isSelected = false
|
||||
} catch (e : Exception) {
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import io.realm.kotlin.types.annotations.Ignore
|
||||
import io.realm.kotlin.types.annotations.PrimaryKey
|
||||
import org.jsoup.select.Elements
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import rasel.lunar.launcher.utils.JamoUtils
|
||||
import rasel.lunar.launcher.utils.afterDay
|
||||
import rasel.lunar.launcher.utils.beforeDay
|
||||
import java.text.SimpleDateFormat
|
||||
@ -192,6 +193,9 @@ class RssData : RealmObject, RssDataInterface {
|
||||
var thumbnail : String? = null
|
||||
var pubDate : Long = 0L
|
||||
var category : String? = null
|
||||
|
||||
var chosung : String? = null
|
||||
|
||||
@Ignore
|
||||
var mRssDataType : RssDataType? = null
|
||||
override fun title(): String {
|
||||
@ -200,6 +204,8 @@ class RssData : RealmObject, RssDataInterface {
|
||||
if(title?.length ?: 0 > 30) title?.substring(0,30).plus("...") else title ?: ""
|
||||
}
|
||||
else -> title ?: ""
|
||||
}.apply {
|
||||
chosung = JamoUtils.split(this).joinToString { "" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.CallLog
|
||||
import android.provider.ContactsContract
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -32,6 +33,7 @@ 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.databinding.CalllogItemBinding
|
||||
import rasel.lunar.launcher.databinding.ListItemBinding
|
||||
import rasel.lunar.launcher.databinding.TodoDialogBinding
|
||||
import rasel.lunar.launcher.helpers.UniUtils.Companion.copyToClipboard
|
||||
@ -49,7 +51,7 @@ internal class MissedCallsAdapter(
|
||||
private val currentFragment = lActivity!!.supportFragmentManager.findFragmentById(R.id.mainFragmentsContainer)
|
||||
|
||||
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): MissedCallsHolder {
|
||||
val binding = ListItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
||||
val binding = CalllogItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
||||
return MissedCallsHolder(binding)
|
||||
}
|
||||
|
||||
@ -61,14 +63,26 @@ internal class MissedCallsAdapter(
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBindViewHolder(holder: MissedCallsHolder, position: Int) {
|
||||
val todo = callList[position]
|
||||
holder.view.itemText.text = "\u25CF ${if(todo.name.equals("unknown")) todo.number else { todo.name}} , ${todo.typeString} : ${todo.count} : ${todo.date}"
|
||||
holder.view.name.text = if(todo.name.equals("unknown")) todo.number else { todo.name}
|
||||
|
||||
when (todo.type) {
|
||||
// CallLog.Calls.INCOMING_TYPE -> { dir = "INCOMING_TYPE" }
|
||||
// CallLog.Calls.OUTGOING_TYPE -> { dir = "OUTGOING_TYPE" }
|
||||
CallLog.Calls.MISSED_TYPE -> { holder.view.root.isSelected = true }
|
||||
// CallLog.Calls.VOICEMAIL_TYPE -> { dir = "VOICEMAIL_TYPE" }
|
||||
// CallLog.Calls.REJECTED_TYPE -> { dir = "REJECTED_TYPE" }
|
||||
// CallLog.Calls.BLOCKED_TYPE -> { dir = "BLOCKED_TYPE" }
|
||||
// CallLog.Calls.ANSWERED_EXTERNALLY_TYPE -> { dir = "ANSWERED_EXTERNALLY_TYPE" }
|
||||
else -> { holder.view.root.isSelected = false }
|
||||
}
|
||||
// "\u25CF ${} , ${todo.typeString} : ${todo.count} : ${todo.date}"
|
||||
holder.view.type.text = todo.typeString
|
||||
/* multiline texts are enabled for TodoManager */
|
||||
holder.view.itemText.isSingleLine = false
|
||||
holder.view.date.text = todo.date
|
||||
/* launch edit or update dialog on item click */
|
||||
holder.view.itemText.setOnClickListener { updateDialog(position) }
|
||||
holder.view.root.setOnClickListener { updateDialog(position) }
|
||||
/* copy texts on long click */
|
||||
holder.view.itemText.setOnLongClickListener {
|
||||
holder.view.root.setOnLongClickListener {
|
||||
|
||||
// copyToClipboard(context, todo.name)
|
||||
var cId = getContactId(lActivity!!.contentResolver, todo.number)
|
||||
@ -85,7 +99,7 @@ internal class MissedCallsAdapter(
|
||||
|
||||
}
|
||||
|
||||
inner class MissedCallsHolder(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root)
|
||||
inner class MissedCallsHolder(var view: CalllogItemBinding) : RecyclerView.ViewHolder(view.root)
|
||||
|
||||
/* update dialog */
|
||||
private fun updateDialog(position: Int) {
|
||||
|
||||
@ -32,6 +32,7 @@ import rasel.lunar.launcher.R
|
||||
import rasel.lunar.launcher.databinding.ListItemBinding
|
||||
import rasel.lunar.launcher.databinding.SmsItemBinding
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
import rasel.lunar.launcher.utils.getContactName
|
||||
import rasel.lunar.launcher.workers.RecentSms
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
@ -55,10 +56,14 @@ internal class SmsLogsAdapter(
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBindViewHolder(holder: SmsLogHolder, position: Int) {
|
||||
val todo = smsList[position]
|
||||
var name = getContactName(lActivity!!.contentResolver,todo.person)
|
||||
if (name == null) {
|
||||
getContactName(lActivity!!.contentResolver,todo.addr)
|
||||
}
|
||||
if(todo.isMms) {
|
||||
var body = todo.mmsContents.get("text")?.joinToString("\n")?.replace("\n"," ")
|
||||
body = if (body?.length ?: 0 > 60) body?.substring(0,60).plus("...") else body
|
||||
holder.view.itemText.text = "\u25CF ${todo.person} ${todo.addr} : ${
|
||||
holder.view.itemText.text = "\u25CF ${if(name != null && name.length > 0) name else if(todo.person != null && todo.person.length > 0){todo.person} else todo.addr} : ${
|
||||
SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(
|
||||
Date(
|
||||
Math.max(
|
||||
@ -70,7 +75,7 @@ internal class SmsLogsAdapter(
|
||||
} : ${todo.type}"
|
||||
holder.view.contents.text = "${body}"
|
||||
} else {
|
||||
holder.view.itemText.text = "\u25CF ${todo.person} ${todo.addr} : ${
|
||||
holder.view.itemText.text = "\u25CF ${if(name != null && name.length > 0) name else if(todo.person != null && todo.person.length > 0){todo.person} else todo.addr} : ${
|
||||
SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(
|
||||
Date(
|
||||
Math.max(
|
||||
@ -80,9 +85,15 @@ internal class SmsLogsAdapter(
|
||||
)
|
||||
)
|
||||
} : ${todo.type}"
|
||||
|
||||
|
||||
|
||||
|
||||
holder.view.contents.text = "${todo.body}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* multiline texts are enabled for TodoManager */
|
||||
// holder.view.itemText.isSingleLine = false
|
||||
/* launch edit or update dialog on item click */
|
||||
@ -95,6 +106,7 @@ internal class SmsLogsAdapter(
|
||||
true
|
||||
}
|
||||
|
||||
holder.view.root.isActivated = if(holder.view.itemText.text.contains("#CMAS#")) true else false
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package rasel.lunar.launcher.utils
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import android.provider.ContactsContract
|
||||
import android.provider.ContactsContract.PhoneLookup
|
||||
|
||||
import java.util.Calendar
|
||||
@ -38,20 +39,21 @@ fun afterDay(date: Date?, day: Int): Long {
|
||||
|
||||
|
||||
fun getContactName(contentResolver: ContentResolver, phoneNumber: String?): String? {
|
||||
val cr = contentResolver
|
||||
val uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber))
|
||||
val cursor =
|
||||
cr.query(uri, arrayOf(PhoneLookup.DISPLAY_NAME), null, null, null)
|
||||
?: return null
|
||||
var contactName: String? = null
|
||||
if (cursor.moveToFirst()) {
|
||||
contactName = cursor.getString(cursor.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME))
|
||||
}
|
||||
if (phoneNumber != null && phoneNumber.length > 0) {
|
||||
val cr = contentResolver
|
||||
val uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber))
|
||||
val cursor =
|
||||
cr.query(uri, arrayOf(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME), null, null, null)
|
||||
?: return null
|
||||
if (cursor.moveToFirst()) {
|
||||
contactName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME))
|
||||
}
|
||||
|
||||
if (cursor != null && !cursor.isClosed) {
|
||||
cursor.close()
|
||||
if (cursor != null && !cursor.isClosed) {
|
||||
cursor.close()
|
||||
}
|
||||
}
|
||||
|
||||
return contactName
|
||||
}
|
||||
|
||||
|
||||
40
app/src/main/kotlin/rasel/lunar/launcher/utils/JamoUtils.kt
Normal file
40
app/src/main/kotlin/rasel/lunar/launcher/utils/JamoUtils.kt
Normal file
@ -0,0 +1,40 @@
|
||||
package rasel.lunar.launcher.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
|
||||
object JamoUtils {
|
||||
val CHOSUNG = listOf(
|
||||
"ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ",
|
||||
"ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ",
|
||||
)
|
||||
val JUNGSUNG = listOf(
|
||||
"ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ",
|
||||
"ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ",
|
||||
)
|
||||
val JONGSUNG = listOf(
|
||||
"", "ㄱ", "ㄲ", "ᆪ", "ᆫ", "ᆬ", "ᆭ", "ㄷ",
|
||||
"ㄹ", "ᆰ", "ᆱ", "ᆲ", "ᆳ", "ᆴ", "ᆵ", "ᆶ", "ㅁ", "ㅂ", "ᆹ", "ᆺ", "ᆻ", "ᆼ",
|
||||
"ᆽ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ",
|
||||
)
|
||||
|
||||
fun split(target: String): List<String> {
|
||||
return target.split("")
|
||||
.filter(String::isNotEmpty)
|
||||
.map(JamoUtils::splitOne)
|
||||
.toList()
|
||||
}
|
||||
|
||||
@SuppressLint("SuspiciousIndentation")
|
||||
fun splitOne(target: String): String {
|
||||
val codePoint = Character.codePointAt(target, 0)
|
||||
return if (codePoint in 0xAC00..0xD79D) {
|
||||
val startValue = codePoint - 0xAC00
|
||||
val jong = startValue % 28
|
||||
val jung = (startValue - jong) / 28 % 21
|
||||
val cho = ((startValue - jong) / 28 - jung) / 21
|
||||
CHOSUNG[cho]
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ class RecentCallGetter : BaseGetter {
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun realWork(): Result {
|
||||
|
||||
var dateParam = beforeDay(Date(),3).toString()
|
||||
var dateParam = beforeDay(Date(),7).toString()
|
||||
var managedCursor = lActivity?.contentResolver?.query(
|
||||
CallLog.Calls.CONTENT_URI, arrayOf(
|
||||
CallLog.Calls.NUMBER,
|
||||
@ -82,22 +82,14 @@ class RecentCallGetter : BaseGetter {
|
||||
CallLog.Calls.BLOCKED_TYPE -> { dir = "BLOCKED_TYPE" }
|
||||
CallLog.Calls.ANSWERED_EXTERNALLY_TYPE -> { dir = "ANSWERED_EXTERNALLY_TYPE" }
|
||||
}
|
||||
var missed: RecentCall = if (recentCalls.containsKey(phNumber)) {
|
||||
recentCalls.get(phNumber)!!.apply {
|
||||
count = count + 1
|
||||
}
|
||||
} else {
|
||||
RecentCall(
|
||||
1,
|
||||
callerName,
|
||||
phNumber,
|
||||
dircode,
|
||||
dir,
|
||||
SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(callDayTime)
|
||||
)
|
||||
}
|
||||
// BLog.LOGE("missed put >>> ${missed.toJson()}")
|
||||
recentCalls.put(phNumber, missed)
|
||||
recentCalls.add(RecentCall(
|
||||
1,
|
||||
callerName,
|
||||
phNumber,
|
||||
dircode,
|
||||
dir,
|
||||
SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(callDayTime)
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ class RecentSmsGetter : BaseGetter {
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun realWork(): Result {
|
||||
var dateParam = beforeDay(Date(),3).toString()
|
||||
var dateParam = beforeDay(Date(),7).toString()
|
||||
val managedCursor = lActivity?.contentResolver?.query(
|
||||
Telephony.Sms.CONTENT_URI, arrayOf(
|
||||
Telephony.Sms.THREAD_ID,
|
||||
@ -301,7 +301,7 @@ internal class MmsQueryHelper(
|
||||
|
||||
fun convertData(cursor: Cursor?) {
|
||||
cursor ?: return
|
||||
val dateTime = beforeDay(Date(),3)
|
||||
val dateTime = beforeDay(Date(),7)
|
||||
cursor.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
|
||||
6
app/src/main/res/color/sms_board.xml
Normal file
6
app/src/main/res/color/sms_board.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="#CCBB5555" android:state_selected="true"/>
|
||||
<item android:color="#CCBBBB55" android:state_activated="true"/>
|
||||
<item android:color="#44000000" />
|
||||
</selector>
|
||||
@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="15dp"/>
|
||||
<solid android:color="#44000000"/>
|
||||
|
||||
<solid android:color="#22CCCCCC"/>
|
||||
<stroke android:color="@color/sms_board" android:width="2dp"/>
|
||||
</shape>
|
||||
37
app/src/main/res/layout/calllog_item.xml
Normal file
37
app/src/main/res/layout/calllog_item.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/sms_bg"
|
||||
android:layout_margin="5dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="@dimen/zero"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/twelve"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="@dimen/zero"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/twelve"
|
||||
app:layout_constraintTop_toBottomOf="@id/name"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/type"
|
||||
android:layout_width="@dimen/zero"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/twelve"
|
||||
app:layout_constraintTop_toBottomOf="@id/date"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
x
Reference in New Issue
Block a user