Separate main and work profile apps
This commit is contained in:
parent
7f5e6f4060
commit
7bb7848cfa
@ -635,4 +635,7 @@
|
||||
<string name="icon_picker_default_icon">Default</string>
|
||||
<string name="icon_picker_suggestions">Suggestions</string>
|
||||
<string name="icon_picker_search_icon">Search icon</string>
|
||||
|
||||
<string name="apps_profile_main">Personal</string>
|
||||
<string name="apps_profile_work">Work</string>
|
||||
</resources>
|
||||
@ -5,14 +5,22 @@ import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Person
|
||||
import androidx.compose.material.icons.rounded.Work
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clipToBounds
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import de.mm20.launcher2.search.data.Searchable
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.component.LauncherCard
|
||||
import de.mm20.launcher2.ui.component.PartialLauncherCard
|
||||
import de.mm20.launcher2.ui.launcher.search.calculator.CalculatorItem
|
||||
@ -41,9 +49,12 @@ fun SearchColumn(
|
||||
|
||||
val showLabels by viewModel.showLabels.observeAsState(true)
|
||||
|
||||
var showWorkProfileApps by remember { mutableStateOf(false) }
|
||||
|
||||
val hideFavs by viewModel.hideFavorites.observeAsState(true)
|
||||
val favorites by viewModel.favorites.observeAsState(emptyList())
|
||||
val apps by viewModel.appResults.observeAsState(emptyList())
|
||||
val workApps by viewModel.workAppResults.observeAsState(emptyList())
|
||||
val appShortcuts by viewModel.appShortcutResults.observeAsState(emptyList())
|
||||
val contacts by viewModel.contactResults.observeAsState(emptyList())
|
||||
val files by viewModel.fileResults.observeAsState(emptyList())
|
||||
@ -69,10 +80,42 @@ fun SearchColumn(
|
||||
)
|
||||
}
|
||||
GridResults(
|
||||
items = apps.toImmutableList(),
|
||||
items = if (showWorkProfileApps && workApps.isNotEmpty()) workApps.toImmutableList() else apps.toImmutableList(),
|
||||
columns = columns,
|
||||
showLabels = showLabels,
|
||||
reverse = reverse
|
||||
reverse = reverse,
|
||||
before = if (workApps.isNotEmpty()) {
|
||||
{
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp)
|
||||
.padding(top = 8.dp, bottom = 4.dp),
|
||||
) {
|
||||
FilterChip(
|
||||
modifier = Modifier.padding(horizontal = 8.dp),
|
||||
selected = !showWorkProfileApps,
|
||||
onClick = { showWorkProfileApps = false },
|
||||
leadingIcon = {
|
||||
Icon(imageVector = Icons.Rounded.Person, contentDescription = null)
|
||||
},
|
||||
label = {
|
||||
Text(stringResource(R.string.apps_profile_main), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
)
|
||||
FilterChip(
|
||||
selected = showWorkProfileApps,
|
||||
onClick = { showWorkProfileApps = true },
|
||||
leadingIcon = {
|
||||
Icon(imageVector = Icons.Rounded.Work, contentDescription = null)
|
||||
},
|
||||
label = {
|
||||
Text(stringResource(R.string.apps_profile_work), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
} else null
|
||||
)
|
||||
ListResults(appShortcuts.toImmutableList(), reverse)
|
||||
val uc = unitConverter
|
||||
|
||||
@ -55,6 +55,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
val favorites = MutableLiveData<List<Searchable>>(emptyList())
|
||||
|
||||
val appResults = MutableLiveData<List<Application>>(emptyList())
|
||||
val workAppResults = MutableLiveData<List<Application>>(emptyList())
|
||||
val appShortcutResults = MutableLiveData<List<AppShortcut>>(emptyList())
|
||||
val fileResults = MutableLiveData<List<File>>(emptyList())
|
||||
val contactResults = MutableLiveData<List<Contact>>(emptyList())
|
||||
@ -133,7 +134,9 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
.withCustomLabels()
|
||||
.sorted()
|
||||
.collectWithHiddenItems(hiddenItemKeys) { results, hidden ->
|
||||
appResults.postValue(results)
|
||||
val (work, personal) = results.partition { it is LauncherApp && !it.isMainProfile }
|
||||
appResults.postValue(personal)
|
||||
workAppResults.postValue(work)
|
||||
hiddenItems.update {
|
||||
it.copy(apps = hidden)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user