properly handle the Show Recent Calls intent

This commit is contained in:
tibbi 2018-11-21 12:12:00 +01:00
parent 41d0a7b189
commit 44b6d1fc5a
2 changed files with 30 additions and 1 deletions

View file

@ -57,6 +57,15 @@
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:mimeType="vnd.android.cursor.dir/calls"/>
</intent-filter>
</activity>
<activity

View file

@ -370,7 +370,11 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
// selecting the proper tab sometimes glitches, add an extra selector to make sure we have it right
main_tabs_holder.onGlobalLayout {
Handler().postDelayed({
main_tabs_holder.getTabAt(config.lastUsedViewPagerPage)?.select()
if (intent?.action == Intent.ACTION_VIEW && intent.type == "vnd.android.cursor.dir/calls") {
main_tabs_holder.getTabAt(getRecentsTabIndex())?.select()
} else {
main_tabs_holder.getTabAt(config.lastUsedViewPagerPage)?.select()
}
invalidateOptionsMenu()
}, 100L)
}
@ -545,6 +549,22 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, recents_fragment, groups_fragment)
private fun getRecentsTabIndex(): Int {
var index = 0
if (config.showTabs and RECENTS_TAB_MASK == 0) {
return index
}
if (config.showTabs and CONTACTS_TAB_MASK != 0) {
index++
}
if (config.showTabs and FAVORITES_TAB_MASK != 0) {
index++
}
return index
}
private fun checkWhatsNewDialog() {
arrayListOf<Release>().apply {
add(Release(10, R.string.release_10))