mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-02-21 22:07:44 +01:00
show the count of item repeats at the Recents tab
This commit is contained in:
parent
4b04219976
commit
b661f73a75
@ -11,6 +11,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
|
import com.simplemobiletools.commons.helpers.mydebug
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
@ -125,8 +126,13 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
|||||||
private fun setupView(view: View, call: RecentCall) {
|
private fun setupView(view: View, call: RecentCall) {
|
||||||
view.apply {
|
view.apply {
|
||||||
item_recents_frame.isSelected = selectedKeys.contains(call.id)
|
item_recents_frame.isSelected = selectedKeys.contains(call.id)
|
||||||
|
var nameToShow = call.name
|
||||||
|
if (call.neighbourIDs.isNotEmpty()) {
|
||||||
|
nameToShow += " (${call.neighbourIDs.size + 1})"
|
||||||
|
}
|
||||||
|
|
||||||
item_recents_name.apply {
|
item_recents_name.apply {
|
||||||
text = call.name
|
text = nameToShow
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,14 @@ class RecentsHelper(private val context: Context) {
|
|||||||
val startTS = (cursor.getLongValue(Calls.DATE) / 1000L).toInt()
|
val startTS = (cursor.getLongValue(Calls.DATE) / 1000L).toInt()
|
||||||
val duration = cursor.getIntValue(Calls.DURATION)
|
val duration = cursor.getIntValue(Calls.DURATION)
|
||||||
val type = cursor.getIntValue(Calls.TYPE)
|
val type = cursor.getIntValue(Calls.TYPE)
|
||||||
val recentCall = RecentCall(id, number, name, photoUri, startTS, duration, type)
|
val neighbourIDs = ArrayList<Int>()
|
||||||
|
val recentCall = RecentCall(id, number, name, photoUri, startTS, duration, type, neighbourIDs)
|
||||||
|
|
||||||
|
// if we have 3 missed calls from the same number, show it just once
|
||||||
if ("$number$name" != previousRecentCallFrom) {
|
if ("$number$name" != previousRecentCallFrom) {
|
||||||
recentCalls.add(recentCall)
|
recentCalls.add(recentCall)
|
||||||
|
} else {
|
||||||
|
recentCalls.lastOrNull()?.neighbourIDs?.add(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
previousRecentCallFrom = "$number$name"
|
previousRecentCallFrom = "$number$name"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
package com.simplemobiletools.dialer.models
|
package com.simplemobiletools.dialer.models
|
||||||
|
|
||||||
data class RecentCall(var id: Int, var phoneNumber: String, var name: String, var photoUri: String, var startTS: Int, var duration: Int, var type: Int)
|
data class RecentCall(var id: Int, var phoneNumber: String, var name: String, var photoUri: String, var startTS: Int, var duration: Int, var type: Int,
|
||||||
|
var neighbourIDs: ArrayList<Int>)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user