mirror of
https://github.com/FossifyOrg/Phone.git
synced 2026-04-19 14:57:22 -04:00
Clear missed calls notification when call log tab is selected
Closes https://github.com/FossifyOrg/Phone/issues/88
This commit is contained in:
@@ -32,6 +32,7 @@ import org.fossify.phone.adapters.ViewPagerAdapter
|
||||
import org.fossify.phone.databinding.ActivityMainBinding
|
||||
import org.fossify.phone.dialogs.ChangeSortingDialog
|
||||
import org.fossify.phone.dialogs.FilterContactSourcesDialog
|
||||
import org.fossify.phone.extensions.clearMissedCalls
|
||||
import org.fossify.phone.extensions.config
|
||||
import org.fossify.phone.extensions.launchCreateNewContactIntent
|
||||
import org.fossify.phone.fragments.ContactsFragment
|
||||
@@ -385,10 +386,6 @@ class MainActivity : SimpleActivity() {
|
||||
// open the Recents tab if we got here by clicking a missed call notification
|
||||
if (intent.action == Intent.ACTION_VIEW && config.showTabs and TAB_CALL_HISTORY > 0) {
|
||||
wantedTab = binding.mainTabsHolder.tabCount - 1
|
||||
|
||||
ensureBackgroundThread {
|
||||
clearMissedCalls()
|
||||
}
|
||||
}
|
||||
|
||||
binding.mainTabsHolder.getTabAt(wantedTab)?.select()
|
||||
@@ -432,6 +429,11 @@ class MainActivity : SimpleActivity() {
|
||||
binding.mainMenu.closeSearch()
|
||||
binding.viewPager.currentItem = it.position
|
||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||
|
||||
val lastPosition = binding.mainTabsHolder.tabCount - 1
|
||||
if (it.position == lastPosition && config.showTabs and TAB_CALL_HISTORY > 0) {
|
||||
clearMissedCalls()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -545,17 +547,6 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun clearMissedCalls() {
|
||||
try {
|
||||
// notification cancellation triggers MissedCallNotifier.clearMissedCalls() which, in turn,
|
||||
// should update the database and reset the cached missed call count in MissedCallNotifier.java
|
||||
// https://android.googlesource.com/platform/packages/services/Telecomm/+/master/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java#170
|
||||
telecomManager.cancelMissedCallsNotification()
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchSettings() {
|
||||
hideKeyboard()
|
||||
startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.media.AudioManager
|
||||
import android.net.Uri
|
||||
import android.os.PowerManager
|
||||
import org.fossify.commons.extensions.telecomManager
|
||||
import org.fossify.commons.helpers.ensureBackgroundThread
|
||||
import org.fossify.phone.helpers.Config
|
||||
import org.fossify.phone.models.SIMAccount
|
||||
|
||||
@@ -44,3 +45,15 @@ fun Context.areMultipleSIMsAvailable(): Boolean {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.clearMissedCalls() {
|
||||
ensureBackgroundThread {
|
||||
try {
|
||||
// notification cancellation triggers MissedCallNotifier.clearMissedCalls() which, in turn,
|
||||
// should update the database and reset the cached missed call count in MissedCallNotifier.java
|
||||
// https://android.googlesource.com/platform/packages/services/Telecomm/+/master/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java#170
|
||||
telecomManager.cancelMissedCallsNotification()
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user