-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
445: Stores spoken keyboard prompts to Recents #530
Closed
cinadia
wants to merge
1
commit into
willowtreeapps:main
from
cinadia:445-custom-phrases-not-added-to-recents-list
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/willowtree/vocable/keyboard/KeyboardFragmentViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.willowtree.vocable.keyboard | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.willowtree.vocable.PhrasesUseCase | ||
import com.willowtree.vocable.utils.locale.LocalesWithText | ||
import kotlinx.coroutines.launch | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
import java.util.Locale | ||
|
||
class KeyboardFragmentViewModel : ViewModel(), KoinComponent { | ||
|
||
private val phrasesUseCase: PhrasesUseCase by inject() | ||
|
||
fun addNewPhrase(phraseStr: String, categoryId: String) { | ||
viewModelScope.launch { | ||
phrasesUseCase.addPhraseSpokenNow( | ||
LocalesWithText(mapOf(Pair(Locale.getDefault().toString(), phraseStr))), | ||
categoryId | ||
) | ||
} | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You exposed a flaw in how our categories are set up, nice! We don't actually want to be storing phrases under the "RECENTS" category, instead we determine RECENTS by just looking at the most recently used phrases PhrasesUseCase#getPhrasesForCategory().
Totally understand how you got here, and we should clean up the API to not allow creating a phrase with "Recent" as the category, could you create a ticket on the board to track that? Up to you whether or not you tackle that, but we should get it written down.
As far as the defect at hand, I don't think we actually want just anything spoken from the keyboard to be saved, and this is corroborated by how the iOS app works. Instead, Android is currently missing functionality where a user can save a phrase directly from the keyboard. Download the Vocable iOS app to your Mac and poke around to see what I mean. Once you feel comfortable, I think we should discard the current bug as "won't-fix" and write up an enhancement to match iOS's functionality here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new issue for the API cleanup: #534
As for saving phrases directly from the keyboard, on iOS they're stored under the "My Sayings" category, but on Android the "My Sayings" category is depricated. Would you like to bring it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated #445 to reflect adding the My Sayings enhancement. Can probably close this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cinadia Agreed!