diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/common/SearchableItemVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/common/SearchableItemVM.kt index e3c07fa9..e88f5a9d 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/common/SearchableItemVM.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/common/SearchableItemVM.kt @@ -138,7 +138,7 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent { } val bundle = options.toBundle() if (searchable.launch(context, bundle)) { - favoritesService.reportLaunch(searchable) + reportUsage(searchable) return true } else if (searchable is Application || searchable is AppShortcut) { favoritesService.reset(searchable) @@ -168,7 +168,7 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent { fun launchChild(context: Context, child: SavableSearchable) { if (child.launch(context, null)) { - favoritesService.reportLaunch(child) + reportUsage(child) } } @@ -246,4 +246,8 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent { val mapTileServerUrl = locationSearchSettings.tileServer .map { it ?: LocationSearchSettings.DefaultTileServerUrl } .stateIn(viewModelScope, SharingStarted.Lazily, "") + + fun reportUsage(searchable: SavableSearchable) { + favoritesService.reportLaunch(searchable) + } } \ No newline at end of file diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/contacts/ContactItem.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/contacts/ContactItem.kt index 74194f5d..a696d42f 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/contacts/ContactItem.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/contacts/ContactItem.kt @@ -163,6 +163,7 @@ fun ContactItem( .fillMaxWidth(), secondaryAction = { IconButton(onClick = { + viewModel.reportUsage(contact) context.tryStartActivity( Intent(Intent.ACTION_SENDTO).apply { data = Uri.parse("smsto:${it.number}") @@ -180,6 +181,7 @@ fun ContactItem( expandedSection = if (it) 0 else -1 }, onContact = { + viewModel.reportUsage(contact) context.tryStartActivity( Intent(Intent.ACTION_DIAL).apply { data = Uri.parse("tel:${it.number}") @@ -208,6 +210,7 @@ fun ContactItem( expandedSection = if (it) 1 else -1 }, onContact = { + viewModel.reportUsage(contact) context.tryStartActivity( Intent(Intent.ACTION_SENDTO).apply { data = Uri.parse("mailto:${it.address}") @@ -231,6 +234,7 @@ fun ContactItem( secondaryAction = if (canNavigate) { { IconButton(onClick = { + viewModel.reportUsage(contact) context.tryStartActivity( Intent(Intent.ACTION_VIEW).apply { data = @@ -254,6 +258,7 @@ fun ContactItem( expandedSection = if (it) 2 else -1 }, onContact = { + viewModel.reportUsage(contact) context.tryStartActivity( Intent(Intent.ACTION_VIEW).apply { data = Uri.parse("geo:0,0?q=${it.address}") @@ -309,6 +314,7 @@ fun ContactItem( expandedSection = if (it) 3 + i else -1 }, onContact = { + viewModel.reportUsage(contact) context.tryStartActivity( Intent(Intent.ACTION_VIEW).apply { setDataAndType(