diff --git a/app/build.gradle b/app/build.gradle index eff81eae..c8b6815f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,6 +56,6 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.32.19' + implementation 'com.simplemobiletools:commons:5.32.23' implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a' } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt index f7326de0..c2d3c57e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt @@ -188,7 +188,7 @@ class MainActivity : SimpleActivity() { private fun clearCallHistory() { ConfirmationDialog(this, "", R.string.clear_history_confirmation) { - RecentsHelper(this).removeAllRecentCalls { + RecentsHelper(this).removeAllRecentCalls(this) { runOnUiThread { recents_fragment?.refreshItems() } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/RecentsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/RecentsHelper.kt index e170becd..c02fca96 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/RecentsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/RecentsHelper.kt @@ -6,7 +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.activities.SimpleActivity import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels import com.simplemobiletools.dialer.models.RecentCall @@ -121,11 +121,15 @@ class RecentsHelper(private val context: Context) { } @SuppressLint("MissingPermission") - fun removeAllRecentCalls(callback: () -> Unit) { - ensureBackgroundThread { - val uri = Calls.CONTENT_URI - context.contentResolver.delete(uri, null, null) - callback() + fun removeAllRecentCalls(activity: SimpleActivity, callback: () -> Unit) { + activity.handlePermission(PERMISSION_WRITE_CALL_LOG) { + if (it) { + ensureBackgroundThread { + val uri = Calls.CONTENT_URI + context.contentResolver.delete(uri, null, null) + callback() + } + } } } }