35
35
import java .util .ArrayList ;
36
36
import java .util .HashMap ;
37
37
import java .util .List ;
38
- import java .util .Locale ;
39
38
import java .util .Objects ;
40
39
import java .util .regex .Pattern ;
41
40
import timber .log .Timber ;
@@ -146,9 +145,9 @@ private void startSpeechInput(String locale) {
146
145
locale
147
146
);
148
147
try {
149
- if (activity == null ){
148
+ if (activity == null ) {
150
149
fragment .startActivityForResult (intent , REQUEST_CODE_FOR_VOICE_INPUT );
151
- }else {
150
+ } else {
152
151
activity .startActivityForResult (intent , REQUEST_CODE_FOR_VOICE_INPUT );
153
152
}
154
153
} catch (Exception e ) {
@@ -157,14 +156,18 @@ private void startSpeechInput(String locale) {
157
156
}
158
157
159
158
public void handleSpeechResult (String spokenText ) {
160
- if (currentPosition < uploadMediaDetails .size ()) {
161
- UploadMediaDetail uploadMediaDetail = uploadMediaDetails .get (currentPosition );
162
- if (selectedVoiceIcon == SelectedVoiceIcon .CAPTION ){
163
- uploadMediaDetail .setCaptionText (spokenText );
164
- }else {
165
- uploadMediaDetail .setDescriptionText (spokenText );
159
+ if (!spokenText .isEmpty ()) {
160
+ String spokenTextCapitalized =
161
+ spokenText .substring (0 , 1 ).toUpperCase () + spokenText .substring (1 );
162
+ if (currentPosition < uploadMediaDetails .size ()) {
163
+ UploadMediaDetail uploadMediaDetail = uploadMediaDetails .get (currentPosition );
164
+ if (selectedVoiceIcon == SelectedVoiceIcon .CAPTION ) {
165
+ uploadMediaDetail .setCaptionText (spokenTextCapitalized );
166
+ } else {
167
+ uploadMediaDetail .setDescriptionText (spokenTextCapitalized );
168
+ }
169
+ notifyItemChanged (currentPosition );
166
170
}
167
- notifyItemChanged (currentPosition );
168
171
}
169
172
}
170
173
@@ -555,12 +558,15 @@ public String convertIdeographicSpaceToLatinSpace(String source) {
555
558
}
556
559
557
560
public interface Callback {
561
+
558
562
void showAlert (int mediaDetailDescription , int descriptionInfo );
559
563
}
560
564
561
565
public interface EventListener {
566
+
562
567
void onPrimaryCaptionTextChange (boolean isNotEmpty );
563
568
}
569
+
564
570
enum SelectedVoiceIcon {
565
571
CAPTION ,
566
572
DESCRIPTION
0 commit comments