Skip to content

Commit 7369574

Browse files
authored
Merge branch 'MM2-0:main' into main
2 parents 94d1b43 + 2555185 commit 7369574

File tree

35 files changed

+270
-120
lines changed

35 files changed

+270
-120
lines changed

app/ui/src/main/java/de/mm20/launcher2/ui/common/FavoritesTagSelector.kt

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package de.mm20.launcher2.ui.common
22

33
import androidx.compose.animation.AnimatedContent
44
import androidx.compose.animation.EnterExitState
5+
import androidx.compose.animation.SharedTransitionScope
56
import androidx.compose.animation.core.animateFloat
67
import androidx.compose.foundation.ScrollState
78
import androidx.compose.foundation.horizontalScroll
@@ -48,6 +49,7 @@ fun FavoritesTagSelector(
4849
reverse: Boolean,
4950
onSelectTag: (String?) -> Unit,
5051
scrollState: ScrollState,
52+
compact: Boolean,
5153
expanded: Boolean,
5254
onExpand: (Boolean) -> Unit,
5355
) {
@@ -80,14 +82,26 @@ fun FavoritesTagSelector(
8082
.padding(start = 16.dp),
8183
selected = selectedTag == null,
8284
onClick = { onSelectTag(null) },
83-
leadingIcon = {
84-
Icon(
85-
imageVector = Icons.Rounded.Star,
86-
contentDescription = null,
87-
modifier = Modifier.size(FilterChipDefaults.IconSize),
88-
)
85+
leadingIcon = if (compact) null else {
86+
{
87+
Icon(
88+
imageVector = Icons.Rounded.Star,
89+
contentDescription = null,
90+
modifier = Modifier.size(FilterChipDefaults.IconSize),
91+
)
92+
}
8993
},
90-
label = { Text(stringResource(R.string.favorites)) }
94+
label = {
95+
if (compact) {
96+
Icon(
97+
imageVector = Icons.Rounded.Star,
98+
contentDescription = null,
99+
modifier = Modifier.size(FilterChipDefaults.IconSize),
100+
)
101+
} else {
102+
Text(stringResource(R.string.favorites))
103+
}
104+
}
91105
)
92106
for (tag in tags) {
93107
TagChip(
@@ -102,6 +116,7 @@ fun FavoritesTagSelector(
102116
onSelectTag(tag.tag)
103117
}
104118
},
119+
compact = compact,
105120
onLongClick = {
106121
sheetManager.showEditTagSheet(tag.tag)
107122
}
@@ -119,7 +134,7 @@ fun FavoritesTagSelector(
119134
}
120135
}
121136

122-
}
137+
}
123138

124139
if (editButton) {
125140
SmallFloatingActionButton(
@@ -147,20 +162,33 @@ fun FavoritesTagSelector(
147162
.padding(end = 8.dp),
148163
selected = selectedTag == null,
149164
onClick = { onSelectTag(null) },
150-
leadingIcon = {
151-
Icon(
152-
imageVector = Icons.Rounded.Star,
153-
contentDescription = null,
154-
modifier = Modifier.size(FilterChipDefaults.IconSize),
155-
)
165+
leadingIcon = if (compact) null else {
166+
{
167+
Icon(
168+
imageVector = Icons.Rounded.Star,
169+
contentDescription = null,
170+
modifier = Modifier.size(FilterChipDefaults.IconSize),
171+
)
172+
}
156173
},
157-
label = { Text(stringResource(R.string.favorites)) }
174+
label = {
175+
if (compact) {
176+
Icon(
177+
imageVector = Icons.Rounded.Star,
178+
contentDescription = null,
179+
modifier = Modifier.size(FilterChipDefaults.IconSize),
180+
)
181+
} else {
182+
Text(stringResource(R.string.favorites))
183+
}
184+
}
158185
)
159186
for (tag in tags) {
160187
TagChip(
161188
modifier = Modifier
162189
.padding(end = 8.dp),
163190
tag = tag,
191+
compact = compact,
164192
selected = selectedTag == tag.tag,
165193
onClick = {
166194
if (selectedTag == tag.tag) {

app/ui/src/main/java/de/mm20/launcher2/ui/common/FavoritesVM.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ abstract class FavoritesVM : ViewModel(), KoinComponent {
2727

2828
val showEditButton = settings.showEditButton.stateIn(viewModelScope, SharingStarted.Lazily, false)
2929
abstract val tagsExpanded: Flow<Boolean>
30+
abstract val compactTags: Flow<Boolean>
3031

3132
val pinnedTags = favoritesService.getFavorites(
3233
includeTypes = listOf("tag"),

app/ui/src/main/java/de/mm20/launcher2/ui/common/TagChip.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fun TagChip(
118118
horizontalArrangement = Arrangement.Center,
119119
) {
120120
val foregroundLayer = (icon as? StaticLauncherIcon)?.foregroundLayer
121-
AnimatedVisibility(foregroundLayer != null && (!compact || foregroundLayer is TextLayer)) {
121+
AnimatedVisibility(!compact || foregroundLayer is TextLayer) {
122122
if (foregroundLayer is TextLayer) {
123123
Text(
124124
text = foregroundLayer.text,
@@ -135,7 +135,7 @@ fun TagChip(
135135
)
136136
}
137137
}
138-
AnimatedVisibility(foregroundLayer != null && (!compact || foregroundLayer is VectorLayer)) {
138+
AnimatedVisibility(!compact || foregroundLayer is VectorLayer) {
139139
Text(
140140
tag.tag,
141141
style = MaterialTheme.typography.labelLarge,

app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import androidx.compose.ui.geometry.Size
2929
import androidx.compose.ui.graphics.Color
3030
import androidx.compose.ui.graphics.TransformOrigin
3131
import androidx.compose.ui.graphics.graphicsLayer
32+
import androidx.compose.ui.unit.IntOffset
3233
import androidx.core.view.WindowCompat
3334
import androidx.core.view.WindowInsetsControllerCompat
3435
import androidx.lifecycle.Lifecycle
@@ -254,7 +255,7 @@ abstract class SharedLauncherActivity(
254255
scaleY = 1f + s * (1 - p)
255256
}) {
256257
it.icon?.invoke(
257-
Offset(
258+
IntOffset(
258259
dX,
259260
dY
260261
)

app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/SearchColumn.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ fun SearchColumn(
105105

106106
val pinnedTags by favoritesVM.pinnedTags.collectAsState(emptyList())
107107
val selectedTag by favoritesVM.selectedTag.collectAsState(null)
108+
val compactTags by favoritesVM.compactTags.collectAsState(false)
108109
val favoritesEditButton by favoritesVM.showEditButton.collectAsState(false)
109110
val favoritesTagsExpanded by favoritesVM.tagsExpanded.collectAsState(false)
110111

@@ -168,6 +169,7 @@ fun SearchColumn(
168169
onExpandTags = {
169170
favoritesVM.setTagsExpanded(it)
170171
},
172+
compactTags = compactTags,
171173
editButton = favoritesEditButton
172174
)
173175
}

app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/apps/AppItem.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ import androidx.compose.runtime.setValue
5353
import androidx.compose.ui.Alignment
5454
import androidx.compose.ui.Modifier
5555
import androidx.compose.ui.draw.clip
56-
import androidx.compose.ui.geometry.Rect
5756
import androidx.compose.ui.graphics.Color
5857
import androidx.compose.ui.platform.LocalContext
5958
import androidx.compose.ui.res.pluralStringResource
6059
import androidx.compose.ui.res.stringResource
6160
import androidx.compose.ui.text.style.TextOverflow
61+
import androidx.compose.ui.unit.IntRect
6262
import androidx.compose.ui.unit.dp
6363
import androidx.compose.ui.unit.lerp
6464
import androidx.compose.ui.unit.roundToIntRect
@@ -485,19 +485,19 @@ fun AppItemGridPopup(
485485
app: Application,
486486
show: MutableTransitionState<Boolean>,
487487
animationProgress: Float,
488-
origin: Rect,
488+
origin: IntRect,
489489
onDismiss: () -> Unit
490490
) {
491491
AnimatedVisibility(
492492
show,
493493
enter = expandIn(
494494
animationSpec = tween(300),
495495
expandFrom = Alignment.TopEnd,
496-
) { origin.roundToIntRect().size },
496+
) { origin.size },
497497
exit = shrinkOut(
498498
animationSpec = tween(300),
499499
shrinkTowards = Alignment.TopEnd,
500-
) { origin.roundToIntRect().size },
500+
) { origin.size },
501501
) {
502502
AppItem(
503503
modifier = Modifier

app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/calendar/CalendarItem.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ import androidx.compose.runtime.collectAsState
3939
import androidx.compose.runtime.getValue
4040
import androidx.compose.ui.Alignment
4141
import androidx.compose.ui.Modifier
42-
import androidx.compose.ui.geometry.Rect
4342
import androidx.compose.ui.graphics.Color
4443
import androidx.compose.ui.graphics.toArgb
4544
import androidx.compose.ui.platform.LocalContext
4645
import androidx.compose.ui.res.stringResource
4746
import androidx.compose.ui.text.style.TextDecoration
4847
import androidx.compose.ui.text.style.TextOverflow
48+
import androidx.compose.ui.unit.IntRect
4949
import androidx.compose.ui.unit.dp
5050
import androidx.compose.ui.unit.roundToIntRect
5151
import de.mm20.launcher2.search.CalendarEvent
@@ -340,19 +340,19 @@ fun CalendarItemGridPopup(
340340
calendar: CalendarEvent,
341341
show: MutableTransitionState<Boolean>,
342342
animationProgress: Float,
343-
origin: Rect,
343+
origin: IntRect,
344344
onDismiss: () -> Unit
345345
) {
346346
AnimatedVisibility(
347347
show,
348348
enter = expandIn(
349349
animationSpec = tween(300),
350350
expandFrom = Alignment.Center,
351-
) { origin.roundToIntRect().size },
351+
) { origin.size },
352352
exit = shrinkOut(
353353
animationSpec = tween(300),
354354
shrinkTowards = Alignment.Center,
355-
) { origin.roundToIntRect().size },
355+
) { origin.size },
356356
) {
357357
CalendarItem(
358358
modifier = Modifier

app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/common/SearchableItemVM.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.content.Context
44
import android.util.Log
55
import android.widget.Toast
66
import androidx.appcompat.app.AppCompatActivity
7-
import androidx.compose.ui.geometry.Rect
7+
import androidx.compose.ui.unit.IntRect
88
import androidx.core.app.ActivityOptionsCompat
99
import de.mm20.launcher2.applications.AppRepository
1010
import de.mm20.launcher2.appshortcuts.AppShortcutRepository
@@ -33,7 +33,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
3333
import kotlinx.coroutines.flow.SharingStarted
3434
import kotlinx.coroutines.flow.combine
3535
import kotlinx.coroutines.flow.emptyFlow
36-
import kotlinx.coroutines.flow.first
3736
import kotlinx.coroutines.flow.flatMapLatest
3837
import kotlinx.coroutines.flow.flowOf
3938
import kotlinx.coroutines.flow.map
@@ -96,14 +95,15 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
9695
}
9796

9897
val children = searchable.flatMapLatest {
99-
when(it) {
98+
when (it) {
10099
is Application -> appShortcutRepository
101100
.findMany(
102101
componentName = it.componentName,
103102
user = it.user,
104103
manifest = true,
105104
dynamic = true,
106105
)
106+
107107
is AppShortcut -> {
108108
val packageName = it.componentName?.packageName ?: return@flatMapLatest flowOf(
109109
emptyList()
@@ -115,22 +115,23 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
115115
)
116116
.map { listOfNotNull(it) }
117117
}
118+
118119
else -> flowOf(
119120
emptyList()
120121
)
121122
}
122123
}
123124

124-
fun launch(context: Context, bounds: Rect? = null): Boolean {
125+
fun launch(context: Context, bounds: IntRect? = null): Boolean {
125126
val searchable = searchable.value ?: return false
126127
val view = (context as? AppCompatActivity)?.window?.decorView
127128
val options = if (bounds != null && view != null) {
128129
ActivityOptionsCompat.makeScaleUpAnimation(
129130
view,
130-
bounds.left.toInt(),
131-
bounds.top.toInt(),
132-
bounds.width.toInt(),
133-
bounds.height.toInt()
131+
bounds.left,
132+
bounds.top,
133+
bounds.width,
134+
bounds.height,
134135
)
135136
} else {
136137
ActivityOptionsCompat.makeBasic()
@@ -166,7 +167,7 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
166167
}
167168

168169
fun launchChild(context: Context, child: SavableSearchable) {
169-
if(child.launch(context, null)) {
170+
if (child.launch(context, null)) {
170171
favoritesService.reportLaunch(child)
171172
}
172173
}

0 commit comments

Comments
 (0)