Restructure contacts search for plugins
This commit is contained in:
@@ -347,7 +347,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
|
||||
val missingContactsPermission = combine(
|
||||
permissionsManager.hasPermission(PermissionGroup.Contacts),
|
||||
contactSearchSettings.enabled
|
||||
contactSearchSettings.isProviderEnabled("local")
|
||||
) { perm, enabled -> !perm && enabled }
|
||||
|
||||
fun requestContactsPermission(context: AppCompatActivity) {
|
||||
@@ -355,7 +355,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
}
|
||||
|
||||
fun disableContactsSearch() {
|
||||
contactSearchSettings.setEnabled(false)
|
||||
contactSearchSettings.setProviderEnabled("local", false)
|
||||
}
|
||||
|
||||
val missingLocationPermission = combine(
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.mm20.launcher2.ui.launcher.search.contacts
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
@@ -78,9 +77,6 @@ import de.mm20.launcher2.ui.launcher.sheets.LocalBottomSheetManager
|
||||
import de.mm20.launcher2.ui.locals.LocalFavoritesEnabled
|
||||
import de.mm20.launcher2.ui.locals.LocalGridSettings
|
||||
import de.mm20.launcher2.ui.modifier.scale
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import androidx.core.net.toUri
|
||||
import de.mm20.launcher2.ktx.checkPermission
|
||||
import de.mm20.launcher2.ktx.getApplicationIconOrNull
|
||||
@@ -276,7 +272,7 @@ fun ContactItem(
|
||||
)
|
||||
}
|
||||
val apps = remember(contact) {
|
||||
contact.contactChannels.groupBy { it.packageName }
|
||||
contact.customActions.groupBy { it.packageName }
|
||||
}
|
||||
for ((i, app) in apps.entries.withIndex()) {
|
||||
val packageName = app.key
|
||||
|
||||
+2
-2
@@ -34,10 +34,10 @@ class ContactsSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
permissionsManager.requestPermission(activity, PermissionGroup.Contacts)
|
||||
}
|
||||
|
||||
val localContacts = settings.enabled
|
||||
val localContacts = settings.isProviderEnabled("local")
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
|
||||
fun setLocalContacts(enabled: Boolean) {
|
||||
settings.setEnabled(enabled)
|
||||
settings.setProviderEnabled("local", enabled)
|
||||
}
|
||||
}
|
||||
@@ -194,6 +194,7 @@ fun PluginSettingsScreen(pluginId: String) {
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.padding(bottom = 16.dp)
|
||||
) {
|
||||
Column {
|
||||
Row(
|
||||
@@ -248,47 +249,6 @@ fun PluginSettingsScreen(pluginId: String) {
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.horizontalScroll(rememberScrollState())
|
||||
.padding(bottom = 24.dp, start = 12.dp, end = 12.dp, top = 24.dp)
|
||||
) {
|
||||
for (type in types) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.padding(end = 4.dp)
|
||||
.background(
|
||||
MaterialTheme.colorScheme.tertiaryContainer,
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
)
|
||||
.padding(4.dp)
|
||||
) {
|
||||
Icon(
|
||||
when (type) {
|
||||
PluginType.FileSearch -> Icons.AutoMirrored.Rounded.InsertDriveFile
|
||||
PluginType.Weather -> Icons.Rounded.LightMode
|
||||
PluginType.LocationSearch -> Icons.Rounded.Place
|
||||
PluginType.Calendar -> Icons.Rounded.Today
|
||||
},
|
||||
null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||
)
|
||||
Text(
|
||||
when (type) {
|
||||
PluginType.FileSearch -> stringResource(R.string.plugin_type_filesearch)
|
||||
PluginType.Weather -> stringResource(R.string.plugin_type_weather)
|
||||
PluginType.LocationSearch -> stringResource(R.string.plugin_type_locationsearch)
|
||||
PluginType.Calendar -> stringResource(R.string.plugin_type_calendar)
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 4.dp),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ class SearchSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
|
||||
val hasContactsPermission = permissionsManager.hasPermission(PermissionGroup.Contacts)
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
val contacts = contactSearchSettings.enabled
|
||||
val contacts = contactSearchSettings.isProviderEnabled("local")
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
|
||||
fun setContacts(contacts: Boolean) {
|
||||
contactSearchSettings.setEnabled(contacts)
|
||||
contactSearchSettings.setProviderEnabled("local", contacts)
|
||||
}
|
||||
|
||||
val hasLocationPermission = permissionsManager.hasPermission(PermissionGroup.Location)
|
||||
|
||||
Reference in New Issue
Block a user