@@ -60,27 +60,35 @@ public class UploadMediaDetailAdapter extends
60
60
private Activity activity ;
61
61
private final ActivityResultLauncher <Intent > voiceInputResultLauncher ;
62
62
private SelectedVoiceIcon selectedVoiceIcon ;
63
+ boolean isVoiceRecognitionAvailable ;
63
64
64
65
private RowItemDescriptionBinding binding ;
65
66
66
67
public UploadMediaDetailAdapter (Fragment fragment , String savedLanguageValue ,
67
- RecentLanguagesDao recentLanguagesDao , ActivityResultLauncher <Intent > voiceInputResultLauncher ) {
68
+ RecentLanguagesDao recentLanguagesDao ,
69
+ ActivityResultLauncher <Intent > voiceInputResultLauncher ,
70
+ boolean isVoiceRecognitionAvailable ) {
68
71
uploadMediaDetails = new ArrayList <>();
69
72
selectedLanguages = new HashMap <>();
70
73
this .savedLanguageValue = savedLanguageValue ;
71
74
this .recentLanguagesDao = recentLanguagesDao ;
72
75
this .fragment = fragment ;
73
76
this .voiceInputResultLauncher = voiceInputResultLauncher ;
77
+ this .isVoiceRecognitionAvailable = isVoiceRecognitionAvailable ;
74
78
}
75
79
76
80
public UploadMediaDetailAdapter (Activity activity , final String savedLanguageValue ,
77
- List <UploadMediaDetail > uploadMediaDetails , RecentLanguagesDao recentLanguagesDao , ActivityResultLauncher <Intent > voiceInputResultLauncher ) {
81
+ List <UploadMediaDetail > uploadMediaDetails ,
82
+ RecentLanguagesDao recentLanguagesDao ,
83
+ ActivityResultLauncher <Intent > voiceInputResultLauncher ,
84
+ boolean isVoiceRecognitionAvailable ) {
78
85
this .uploadMediaDetails = uploadMediaDetails ;
79
86
selectedLanguages = new HashMap <>();
80
87
this .savedLanguageValue = savedLanguageValue ;
81
88
this .recentLanguagesDao = recentLanguagesDao ;
82
89
this .activity = activity ;
83
90
this .voiceInputResultLauncher = voiceInputResultLauncher ;
91
+ this .isVoiceRecognitionAvailable = isVoiceRecognitionAvailable ;
84
92
}
85
93
86
94
public void setCallback (Callback callback ) {
@@ -274,13 +282,15 @@ public void bind(int position) {
274
282
selectedVoiceIcon = SelectedVoiceIcon .CAPTION ;
275
283
startSpeechInput (descriptionLanguages .getText ().toString ());
276
284
});
285
+ captionInputLayout .setEndIconVisible (isVoiceRecognitionAvailable );
277
286
descInputLayout .setEndIconMode (TextInputLayout .END_ICON_CUSTOM );
278
287
descInputLayout .setEndIconDrawable (R .drawable .baseline_keyboard_voice );
279
288
descInputLayout .setEndIconOnClickListener (v -> {
280
289
currentPosition = position ;
281
290
selectedVoiceIcon = SelectedVoiceIcon .DESCRIPTION ;
282
291
startSpeechInput (descriptionLanguages .getText ().toString ());
283
292
});
293
+ descInputLayout .setEndIconVisible (isVoiceRecognitionAvailable );
284
294
285
295
if (position == 0 ) {
286
296
removeButton .setVisibility (View .GONE );
0 commit comments