@@ -65,6 +65,7 @@ public class ReactChatInputManager extends ViewGroupManager<ChatInputView> {
6565 private ChatInputView chatInput ;
6666 private Map <String , RCTMember > idList = new HashMap ();
6767 private Dialog dialog ;
68+ private TimerTipView timerTipView ;
6869
6970 @ Override
7071 public String getName () {
@@ -104,22 +105,7 @@ protected ChatInputView createViewInstance(final ThemedReactContext reactContext
104105 mContext .registerReceiver (RCTChatInputReceiver , intentFilter );
105106
106107 final Activity activity = reactContext .getCurrentActivity ();
107- Log .w (TAG , "SDK_INT:" + Build .VERSION .SDK_INT );
108- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
109- final String permission = Manifest .permission .RECORD_AUDIO ;
110- Log .w (TAG , "checkCallingOrSelfPermission:" + activity .checkCallingOrSelfPermission (permission ));
111- Log .w (TAG , "checkSelfPermission:" + activity .checkSelfPermission (permission ));
112- Log .w (TAG , "checkCallingPermission:" + activity .checkCallingPermission (permission ));
113- if (activity .checkCallingPermission (permission ) != PackageManager .PERMISSION_GRANTED ) {
114108
115- if (ActivityCompat .shouldShowRequestPermissionRationale (activity , permission )) {
116- Log .w (TAG , "shouldShowRequestPermissionRationale:true" );
117- } else {
118- Log .w (TAG , "shouldShowRequestPermissionRationale:false" );
119- }
120- activity .requestPermissions (new String []{permission }, 100 );
121- }
122- }
123109 chatInput = new ChatInputView (activity , null );
124110// chatInput.setMenuContainerHeight(666);
125111 // Use default layout
@@ -169,7 +155,7 @@ public void onShowKeyboard(int inputHeight, int showType) {
169155
170156 chatInput .setRecordVoiceListener (new RecordVoiceListener () {
171157
172- TimerTipView view ;
158+
173159 Handler handler = new Handler () {
174160 @ Override
175161 public void handleMessage (Message msg ) {
@@ -189,12 +175,12 @@ public void onStartRecord() {
189175 @ Override
190176 public void onFinishRecord (String voiceFile , boolean isTooLong , int duration ) {
191177 if (TextUtils .isEmpty (voiceFile )) {
192- view .updateStatus (0 , 2 , 0 );
178+ timerTipView .updateStatus (0 , 2 , 0 );
193179 handler .sendEmptyMessageDelayed (1 , 500 );
194180 return ;
195181 }
196182 if (isTooLong ) {
197- view .updateStatus (0 , 3 , 0 );
183+ timerTipView .updateStatus (0 , 3 , 0 );
198184 handler .sendEmptyMessageDelayed (1 , 500 );
199185 } else {
200186 hideDialog ();
@@ -213,7 +199,7 @@ public void onCancelRecord() {
213199
214200 @ Override
215201 public void onRecording (boolean cancelAble , int dbSize , int time ) {
216- view .updateStatus (dbSize , cancelAble ? 1 : 0 , time );
202+ timerTipView .updateStatus (dbSize , cancelAble ? 1 : 0 , time );
217203 }
218204
219205 void hideDialog () {
@@ -227,7 +213,7 @@ void showDialog() {
227213 dialog = new Dialog (reactContext .getCurrentActivity (), R .style .Theme_audioDialog );
228214 dialog .setCanceledOnTouchOutside (false );
229215// dialog.setCancelable(false);
230- view = new TimerTipView (reactContext );
216+ timerTipView = new TimerTipView (reactContext );
231217 dialog .setOnKeyListener (new DialogInterface .OnKeyListener () {
232218 @ Override
233219 public boolean onKey (DialogInterface dialog , int keyCode , KeyEvent event ) {
@@ -237,9 +223,9 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
237223 return false ;
238224 }
239225 });
240- dialog .setContentView (view );
226+ dialog .setContentView (timerTipView );
241227 }
242- view .updateStatus (0 , 0 , 0 );
228+ timerTipView .updateStatus (0 , 0 , 0 );
243229 dialog .show ();
244230 }
245231 });
@@ -259,6 +245,24 @@ public void onTextChanged(String changeText) {
259245 return chatInput ;
260246 }
261247
248+ void requestPermission (Activity activity ) {
249+ final String permission = Manifest .permission .RECORD_AUDIO ;
250+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
251+
252+ Log .w (TAG , "checkCallingOrSelfPermission:" + activity .checkCallingOrSelfPermission (permission ));
253+ Log .w (TAG , "checkSelfPermission:" + activity .checkSelfPermission (permission ));
254+ Log .w (TAG , "checkCallingPermission:" + activity .checkCallingPermission (permission ));
255+ if (activity .checkSelfPermission (permission ) != PackageManager .PERMISSION_GRANTED ) {
256+
257+ if (ActivityCompat .shouldShowRequestPermissionRationale (activity , permission )) {
258+ Log .w (TAG , "shouldShowRequestPermissionRationale:true" );
259+ } else {
260+ Log .w (TAG , "shouldShowRequestPermissionRationale:false" );
261+ }
262+ // activity.requestPermissions(new String[]{permission}, 100);
263+ }
264+ }
265+ }
262266
263267 @ ReactProp (name = "menuContainerHeight" )
264268 public void setMenuContainerHeight (ChatInputView chatInputView , int height ) {
0 commit comments