Fix app grid displaying apps for different profile
This commit is contained in:
parent
fce264b4ae
commit
585b2b2955
@ -27,6 +27,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import de.mm20.launcher2.profiles.Profile
|
||||||
import de.mm20.launcher2.search.AppShortcut
|
import de.mm20.launcher2.search.AppShortcut
|
||||||
import de.mm20.launcher2.search.Application
|
import de.mm20.launcher2.search.Application
|
||||||
import de.mm20.launcher2.search.Article
|
import de.mm20.launcher2.search.Article
|
||||||
@ -177,9 +178,9 @@ fun SearchColumn(
|
|||||||
|
|
||||||
if (isSearchEmpty && profiles.size > 1) {
|
if (isSearchEmpty && profiles.size > 1) {
|
||||||
AppResults(
|
AppResults(
|
||||||
apps = when(selectedAppProfileIndex) {
|
apps = when(profiles.getOrNull(selectedAppProfileIndex)?.type) {
|
||||||
1 -> privateApps
|
Profile.Type.Private -> privateApps
|
||||||
2 -> workApps
|
Profile.Type.Work -> workApps
|
||||||
else -> apps
|
else -> apps
|
||||||
},
|
},
|
||||||
highlightedItem = bestMatch as? Application,
|
highlightedItem = bestMatch as? Application,
|
||||||
|
|||||||
@ -105,7 +105,7 @@ fun LazyListScope.AppResults(
|
|||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
|
|
||||||
val profileType = profiles[selectedProfileIndex].type
|
val profileType = profiles[selectedProfileIndex].type
|
||||||
if (showProfileLockControls && profileType != Profile.Type.Personal) {
|
if (profileType != Profile.Type.Personal) {
|
||||||
if (isProfileLocked) {
|
if (isProfileLocked) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -128,37 +128,38 @@ fun LazyListScope.AppResults(
|
|||||||
if (profileType == Profile.Type.Work) R.string.profile_work_profile_state_locked
|
if (profileType == Profile.Type.Work) R.string.profile_work_profile_state_locked
|
||||||
else R.string.profile_private_profile_state_locked
|
else R.string.profile_private_profile_state_locked
|
||||||
),
|
),
|
||||||
modifier = Modifier.padding(top = 8.dp, bottom = 32.dp),
|
modifier = Modifier.padding(top = 8.dp),
|
||||||
color = MaterialTheme.colorScheme.secondary,
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
)
|
)
|
||||||
Button(
|
if (showProfileLockControls) {
|
||||||
modifier = Modifier,
|
Button(
|
||||||
onClick = {
|
modifier = Modifier.padding(top = 32.dp),
|
||||||
onProfileLockChange?.invoke(
|
onClick = {
|
||||||
profiles[selectedProfileIndex],
|
onProfileLockChange?.invoke(
|
||||||
false
|
profiles[selectedProfileIndex],
|
||||||
|
false
|
||||||
|
)
|
||||||
|
},
|
||||||
|
contentPadding = ButtonDefaults.TextButtonWithIconContentPadding,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
if (profileType == Profile.Type.Work) Icons.Rounded.Work else Icons.Rounded.LockOpen,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(end = ButtonDefaults.IconSpacing)
|
||||||
|
.size(ButtonDefaults.IconSize)
|
||||||
)
|
)
|
||||||
},
|
Text(
|
||||||
contentPadding = ButtonDefaults.TextButtonWithIconContentPadding,
|
stringResource(
|
||||||
) {
|
if (profileType == Profile.Type.Work) R.string.profile_work_profile_action_unlock
|
||||||
Icon(
|
else R.string.profile_private_profile_action_unlock
|
||||||
if (profileType == Profile.Type.Work) Icons.Rounded.Work else Icons.Rounded.LockOpen,
|
)
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(end = ButtonDefaults.IconSpacing)
|
|
||||||
.size(ButtonDefaults.IconSize)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
stringResource(
|
|
||||||
if (profileType == Profile.Type.Work) R.string.profile_work_profile_action_unlock
|
|
||||||
else R.string.profile_private_profile_action_unlock
|
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else if (showProfileLockControls) {
|
||||||
FilledTonalButton(
|
FilledTonalButton(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(12.dp)
|
.padding(12.dp)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user