Skip to content

Commit 616a0c2

Browse files
committed
#1846 feat: do not pulse the new key map button after it has been clicked
1 parent 7476b3b commit 616a0c2

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

base/src/main/java/io/github/sds100/keymapper/base/home/HomeKeyMapListScreen.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ fun HomeKeyMapListScreen(
152152

153153
var keyMapListBottomPadding by remember { mutableStateOf(100.dp) }
154154

155-
// Check if the list is empty to trigger pulsing animation
156-
val isListEmpty = state.listItems is State.Data &&
157-
(state.listItems as State.Data<List<KeyMapListItemModel>>).data.isEmpty()
158-
159155
HomeKeyMapListScreen(
160156
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
161157
snackbarState = snackbarState,
@@ -169,7 +165,7 @@ fun HomeKeyMapListScreen(
169165
modifier = Modifier
170166
.padding(bottom = fabBottomPadding)
171167
.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.End)),
172-
pulse = isListEmpty,
168+
pulse = state.showCreateKeyMapTapTarget,
173169
showFabText = viewModel.showFabText,
174170
text = stringResource(R.string.home_fab_new_key_map),
175171
onClick = viewModel::onNewKeyMapClick,

base/src/main/java/io/github/sds100/keymapper/base/home/KeyMapListState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import io.github.sds100.keymapper.common.utils.State
66
data class KeyMapListState(
77
val appBarState: KeyMapAppBarState,
88
val listItems: State<List<KeyMapListItemModel>>,
9+
val showCreateKeyMapTapTarget: Boolean,
910
)

base/src/main/java/io/github/sds100/keymapper/base/home/KeyMapListViewModel.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import io.github.sds100.keymapper.base.groups.GroupFamily
1717
import io.github.sds100.keymapper.base.groups.GroupListItemModel
1818
import io.github.sds100.keymapper.base.keymaps.KeyMap
1919
import io.github.sds100.keymapper.base.keymaps.PauseKeyMapsUseCase
20+
import io.github.sds100.keymapper.base.onboarding.OnboardingTapTarget
2021
import io.github.sds100.keymapper.base.onboarding.OnboardingUseCase
2122
import io.github.sds100.keymapper.base.onboarding.SetupAccessibilityServiceDelegate
2223
import io.github.sds100.keymapper.base.sorting.SortKeyMapsUseCase
@@ -120,6 +121,7 @@ class KeyMapListViewModel(
120121
isPaused = false,
121122
),
122123
listItems = State.Loading,
124+
showCreateKeyMapTapTarget = false
123125
)
124126
private val _state: MutableStateFlow<KeyMapListState> = MutableStateFlow(initialState)
125127
val state = _state.asStateFlow()
@@ -311,13 +313,22 @@ class KeyMapListViewModel(
311313
}
312314
}
313315

316+
val showCreateKeyMapTapTarget = combine(
317+
onboarding.showTapTarget(OnboardingTapTarget.CREATE_KEY_MAP),
318+
onboarding.showWhatsNew,
319+
) { showTapTarget, showWhatsNew ->
320+
// Only show the tap target if whats new is not showing.
321+
showTapTarget && !showWhatsNew
322+
}
323+
314324
coroutineScope.launch {
315325
combine(
316326
listItemStateFlow,
317327
appBarStateFlow,
318-
) { listState, appBarState ->
319-
Pair(listState, appBarState)
320-
}.collectLatest { (listState, appBarState) ->
328+
showCreateKeyMapTapTarget
329+
) { listState, appBarState, showCreateKeyMapTapTarget ->
330+
Triple(listState, appBarState, showCreateKeyMapTapTarget)
331+
}.collectLatest { (listState, appBarState, showCreateKeyMapTapTarget) ->
321332
listState.ifIsData { list ->
322333
if (list.isNotEmpty()) {
323334
showFabText = false
@@ -328,6 +339,7 @@ class KeyMapListViewModel(
328339
KeyMapListState(
329340
appBarState,
330341
listState,
342+
showCreateKeyMapTapTarget
331343
)
332344
}
333345
}
@@ -853,6 +865,8 @@ class KeyMapListViewModel(
853865
}
854866

855867
fun onNewKeyMapClick() {
868+
onboarding.completedTapTarget(OnboardingTapTarget.CREATE_KEY_MAP)
869+
856870
coroutineScope.launch {
857871
val groupUid = listKeyMaps.keyMapGroup.first().group?.uid
858872

base/src/main/java/io/github/sds100/keymapper/base/onboarding/OnboardingTapTarget.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ package io.github.sds100.keymapper.base.onboarding
22

33
enum class OnboardingTapTarget(
44
) {
5+
CREATE_KEY_MAP,
56
CHOOSE_ACTION,
67
}

base/src/main/java/io/github/sds100/keymapper/base/onboarding/OnboardingUseCase.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class OnboardingUseCaseImpl @Inject constructor(
102102
private fun getTapTargetKey(tapTarget: OnboardingTapTarget): Preferences.Key<Boolean> {
103103
return when (tapTarget) {
104104
OnboardingTapTarget.CHOOSE_ACTION -> Keys.shownTapTargetChooseAction
105+
OnboardingTapTarget.CREATE_KEY_MAP -> Keys.shownTapTargetCreateKeyMap
105106
}
106107
}
107108
}

base/src/main/java/io/github/sds100/keymapper/base/shortcuts/CreateKeyMapShortcutScreen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ private fun PreviewRootGroup() {
377377
isPaused = true,
378378
),
379379
listItems = State.Data(keyMapSampleList()),
380+
showCreateKeyMapTapTarget = false
380381
),
381382
showShortcutNameDialog = null,
382383
)
@@ -401,6 +402,7 @@ private fun PreviewChildGroup() {
401402
keyMapsEnabled = null,
402403
),
403404
listItems = State.Data(keyMapSampleList()),
405+
showCreateKeyMapTapTarget = false
404406
),
405407
showShortcutNameDialog = null,
406408
)
@@ -419,6 +421,7 @@ private fun PreviewEmpty() {
419421
isPaused = true,
420422
),
421423
listItems = State.Data(emptyList()),
424+
showCreateKeyMapTapTarget = false
422425
),
423426
showShortcutNameDialog = null,
424427
)

base/src/main/java/io/github/sds100/keymapper/base/shortcuts/CreateKeyMapShortcutViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class CreateKeyMapShortcutViewModel @Inject constructor(
6262
isPaused = false,
6363
),
6464
listItems = State.Loading,
65+
showCreateKeyMapTapTarget = false
6566
)
6667
private val _state: MutableStateFlow<KeyMapListState> = MutableStateFlow(initialState)
6768
val state = _state.asStateFlow()
@@ -156,7 +157,7 @@ class CreateKeyMapShortcutViewModel @Inject constructor(
156157
)
157158
}
158159

159-
return KeyMapListState(appBarState, listItemsState)
160+
return KeyMapListState(appBarState, listItemsState, showCreateKeyMapTapTarget = false)
160161
}
161162

162163
fun onKeyMapCardClick(uid: String) {

0 commit comments

Comments
 (0)