mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
fix #21, make grouping subsequent entries at the call log optional
This commit is contained in:
@ -35,6 +35,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupChangeDateTimeFormat()
|
||||
setupFontSize()
|
||||
setupDefaultTab()
|
||||
setupGroupSubsequentCalls()
|
||||
updateTextColors(settings_holder)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
@ -123,4 +124,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
TAB_CALL_HISTORY -> R.string.call_history_tab
|
||||
else -> R.string.last_used_tab
|
||||
})
|
||||
|
||||
private fun setupGroupSubsequentCalls() {
|
||||
settings_group_subsequent_calls.isChecked = config.groupSubsequentCalls
|
||||
settings_group_subsequent_calls_holder.setOnClickListener {
|
||||
settings_group_subsequent_calls.toggle()
|
||||
config.groupSubsequentCalls = settings_group_subsequent_calls.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,4 +35,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
}
|
||||
|
||||
fun getCustomSIM(number: String) = prefs.getString(REMEMBER_SIM_PREFIX + number, "")
|
||||
|
||||
var groupSubsequentCalls: Boolean
|
||||
get() = prefs.getBoolean(GROUP_SUBSEQUENT_CALLS, true)
|
||||
set(groupSubsequentCalls) = prefs.edit().putBoolean(GROUP_SUBSEQUENT_CALLS, groupSubsequentCalls).apply()
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.simplemobiletools.dialer.helpers
|
||||
// shared prefs
|
||||
const val SPEED_DIAL = "speed_dial"
|
||||
const val REMEMBER_SIM_PREFIX = "remember_sim_"
|
||||
const val GROUP_SUBSEQUENT_CALLS = "group_subsequent_calls"
|
||||
|
||||
const val CONTACTS_TAB_MASK = 1
|
||||
const val FAVORITES_TAB_MASK = 2
|
||||
|
@ -6,6 +6,7 @@ import android.provider.CallLog.Calls
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
||||
import com.simplemobiletools.dialer.models.RecentCall
|
||||
|
||||
@ -34,6 +35,9 @@ class RecentsHelper(private val context: Context) {
|
||||
|
||||
private fun getRecents(contacts: ArrayList<SimpleContact>, callback: (ArrayList<RecentCall>) -> Unit) {
|
||||
var recentCalls = ArrayList<RecentCall>()
|
||||
var previousRecentCallFrom = ""
|
||||
val contactsNumbersMap = HashMap<String, String>()
|
||||
val groupSubsequentCalls = context.config.groupSubsequentCalls
|
||||
val uri = Calls.CONTENT_URI
|
||||
val projection = arrayOf(
|
||||
Calls._ID,
|
||||
@ -52,8 +56,6 @@ class RecentsHelper(private val context: Context) {
|
||||
}
|
||||
|
||||
val sortOrder = "${Calls._ID} DESC LIMIT 100"
|
||||
var previousRecentCallFrom = ""
|
||||
val contactsNumbersMap = HashMap<String, String>()
|
||||
context.queryCursor(uri, projection, sortOrder = sortOrder, showErrors = true) { cursor ->
|
||||
val id = cursor.getIntValue(Calls._ID)
|
||||
val number = cursor.getStringValue(Calls.NUMBER)
|
||||
@ -92,7 +94,7 @@ class RecentsHelper(private val context: Context) {
|
||||
val recentCall = RecentCall(id, number, name, photoUri, startTS, duration, type, neighbourIDs, simID)
|
||||
|
||||
// if we have multiple missed calls from the same number, show it just once
|
||||
if ("$number$name" != previousRecentCallFrom) {
|
||||
if (!groupSubsequentCalls || "$number$name" != previousRecentCallFrom) {
|
||||
recentCalls.add(recentCall)
|
||||
} else {
|
||||
recentCalls.lastOrNull()?.neighbourIDs?.add(id)
|
||||
|
Reference in New Issue
Block a user