Skip to content

Commit

Permalink
Fix voice input bug (#5739)
Browse files Browse the repository at this point in the history
* Fix voice input bug

* Add javadocs

---------

Co-authored-by: vtalos <v.talos23@gmail.com>
  • Loading branch information
karyotakisg and vtalos authored Jun 2, 2024
1 parent 18e03ed commit fe7a2f2
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,30 @@ private void startSpeechInput(String locale) {
}
}

/**
* Handles the result of the speech input by processing the spoken text.
* If the spoken text is not empty, it capitalizes the first letter of the spoken text
* and updates the appropriate field (caption or description) of the current
* UploadMediaDetail based on the selected voice icon.
* Finally, it notifies the adapter that the data set has changed.
*
* @param spokenText the text input received from speech recognition.
*/
public void handleSpeechResult(String spokenText) {
if (!spokenText.isEmpty()) {
String spokenTextCapitalized =
spokenText.substring(0, 1).toUpperCase() + spokenText.substring(1);
if (currentPosition < uploadMediaDetails.size()) {
UploadMediaDetail uploadMediaDetail = uploadMediaDetails.get(currentPosition);
if (selectedVoiceIcon == SelectedVoiceIcon.CAPTION) {
uploadMediaDetail.setCaptionText(spokenTextCapitalized);
} else {
uploadMediaDetail.setDescriptionText(spokenTextCapitalized);
switch (selectedVoiceIcon) {
case CAPTION:
uploadMediaDetail.setCaptionText(spokenTextCapitalized);
break;
case DESCRIPTION:
uploadMediaDetail.setDescriptionText(spokenTextCapitalized);
break;
}
notifyItemChanged(currentPosition);
notifyDataSetChanged();
}
}
}
Expand Down

0 comments on commit fe7a2f2

Please sign in to comment.