@@ -183,6 +183,11 @@ public class EnterEmojiLayout extends EnterLayout {
183183 "coding_emoji_43" ,
184184 }};
185185 protected final View rootView ;
186+ protected int rootViewHigh = 0 ;
187+ protected ViewGroup mInputBox ;//文本输入框所在的布局容器
188+ protected RippleBackground voiceLayout ;
189+ protected InputType mInputType ;
190+ protected boolean isSoftKeyBoard = false ;
186191 PageChangeListener pageChange = new PageChangeListener ();
187192 private CheckBox checkBoxEmoji ;
188193 private View emojiKeyboardLayout ;
@@ -193,20 +198,63 @@ public class EnterEmojiLayout extends EnterLayout {
193198 private View selectMonkey ;
194199 private MyImageGetter myImageGetter ;
195200 private Activity mActivity ;
196- protected int rootViewHigh = 0 ;
197- protected ViewGroup mInputBox ;//文本输入框所在的布局容器
198- protected RippleBackground voiceLayout ;
199201 private boolean firstLayout = true ;
200202 private int contentViewHeight ;
201203 private WindowManager mWindowManager ;
202204 private WindowManager .LayoutParams mWindowLp ;
203205 private ImageView mWindowView ;
204206 private int statusBarHeight ;
205- protected InputType mInputType ;
206207 private FrameLayout mPanelLayout ;
208+ private View .OnClickListener checkBoxEmojiOnClicked = new View .OnClickListener () {
209+ @ Override
210+ public void onClick (View v ) {
211+ content .requestFocus ();
212+ if (checkBoxEmoji .isChecked ()) {
213+ rootViewHigh = rootView .getHeight ();
207214
208- protected boolean isSoftKeyBoard = false ;
215+ final int bottomHigh = Global .dpToPx (100 ); // 底部虚拟按键高度,nexus5是73dp,以防万一,所以设大一点
216+ int rootParentHigh = rootView .getRootView ().getHeight ();
217+ //rootParentHigh - rootViewHigh > bottomHigh
218+ if (isSoftKeyBoard ) {
219+ // 说明键盘已经弹出来了,等键盘消失后再设置 emoji keyboard 可见
220+ if (commonEnterRoot != null ) {
221+ toggleInputTypeWithCloseSoftkeyboard (InputType .Emoji );
222+ } else {
223+ //兼容没有使用common_enter_emoji的输入控件
224+ Global .popSoftkeyboard (mActivity , content , false );
225+ mInputType = InputType .Emoji ;
226+ }
209227
228+ // 魅族手机的 rootView 无论输入法是否弹出高度都是不变的,只好搞个延时做这个事
229+ rootView .postDelayed (new Runnable () {
230+ @ Override
231+ public void run () {
232+ rootView .setLayoutParams (rootView .getLayoutParams ());
233+ }
234+ }, 50 );
235+
236+ } else {
237+ if (commonEnterRoot != null ) {
238+ toggleNoTextInput (InputType .Emoji );
239+ } else {
240+ //兼容没有使用common_enter_emoji的输入控件
241+ emojiKeyboardLayout .setVisibility (View .VISIBLE );
242+ }
243+
244+ rootViewHigh = 0 ;
245+ }
246+ } else {
247+ if (commonEnterRoot != null ) {
248+ toggleSoftkeyboardWithCloseNoTextInput (InputType .Emoji );
249+ } else {
250+ //兼容没有使用common_enter_emoji的输入控件
251+ Global .popSoftkeyboard (mActivity , content , true );
252+ emojiKeyboardLayout .setVisibility (View .GONE );
253+ }
254+
255+ }
256+ }
257+ };
210258
211259 public EnterEmojiLayout (final FragmentActivity activity , View .OnClickListener sendTextOnClick , Type type , EmojiType emojiType ) {
212260 super (activity , sendTextOnClick , type );
@@ -257,16 +305,13 @@ public void onGlobalLayout() {
257305 if (mInputType !=null ){
258306 switch (mInputType ){
259307 case Text :
260- voiceLayout .setVisibility (View .GONE );
261- emojiKeyboardLayout .setVisibility (View .GONE );
308+ setInputStyle (View .GONE , View .GONE );
262309 break ;
263310 case Voice :
264- voiceLayout .setVisibility (View .VISIBLE );
265- emojiKeyboardLayout .setVisibility (View .GONE );
311+ setInputStyle (View .GONE , View .VISIBLE );
266312 break ;
267313 case Emoji :
268- emojiKeyboardLayout .setVisibility (View .VISIBLE );
269- voiceLayout .setVisibility (View .GONE );
314+ setInputStyle (View .VISIBLE , View .GONE );
270315 break ;
271316 }
272317 }
@@ -342,9 +387,19 @@ public boolean onTouch(View v, MotionEvent event) {
342387 return false ;
343388 }
344389 });
390+ }
345391
392+ public EnterEmojiLayout (FragmentActivity activity , View .OnClickListener sendTextOnClick ) {
393+ this (activity , sendTextOnClick , Type .Default , EmojiType .Default );
394+ }
346395
347-
396+ private void setInputStyle (int emojiKeyboard , int voiceKeyboard ) {
397+ if (emojiKeyboardLayout != null ) {
398+ emojiKeyboardLayout .setVisibility (emojiKeyboard );
399+ }
400+ if (voiceLayout != null ) {
401+ voiceLayout .setVisibility (voiceKeyboard );
402+ }
348403 }
349404
350405 private void dropTempWindow (){
@@ -407,8 +462,6 @@ private void moveTempWindow(int y){
407462 mWindowManager .updateViewLayout (mWindowView , mWindowLp );
408463 }
409464
410-
411-
412465 protected int getContentViewHeight (Activity activity ){
413466 Rect rect = new Rect ();
414467 Window window = activity .getWindow ();
@@ -419,57 +472,6 @@ protected int getContentViewHeight(Activity activity){
419472 return rect .bottom - rect .top ;
420473 }
421474
422-
423- private View .OnClickListener checkBoxEmojiOnClicked = new View .OnClickListener () {
424- @ Override
425- public void onClick (View v ) {
426- content .requestFocus ();
427- if (checkBoxEmoji .isChecked ()) {
428- rootViewHigh = rootView .getHeight ();
429-
430- final int bottomHigh = Global .dpToPx (100 ); // 底部虚拟按键高度,nexus5是73dp,以防万一,所以设大一点
431- int rootParentHigh = rootView .getRootView ().getHeight ();
432- //rootParentHigh - rootViewHigh > bottomHigh
433- if (isSoftKeyBoard ) {
434- // 说明键盘已经弹出来了,等键盘消失后再设置 emoji keyboard 可见
435- if (commonEnterRoot !=null ){
436- toggleInputTypeWithCloseSoftkeyboard (InputType .Emoji );
437- }else {
438- //兼容没有使用common_enter_emoji的输入控件
439- Global .popSoftkeyboard (mActivity , content , false );
440- }
441-
442- // 魅族手机的 rootView 无论输入法是否弹出高度都是不变的,只好搞个延时做这个事
443- rootView .postDelayed (new Runnable () {
444- @ Override
445- public void run () {
446- rootView .setLayoutParams (rootView .getLayoutParams ());
447- }
448- }, 50 );
449-
450- } else {
451- if (commonEnterRoot !=null ){
452- toggleNoTextInput (InputType .Emoji );
453- }else {
454- //兼容没有使用common_enter_emoji的输入控件
455- emojiKeyboardLayout .setVisibility (View .VISIBLE );
456- }
457-
458- rootViewHigh = 0 ;
459- }
460- } else {
461- if (commonEnterRoot !=null ){
462- toggleSoftkeyboardWithCloseNoTextInput (InputType .Emoji );
463- }else {
464- //兼容没有使用common_enter_emoji的输入控件
465- Global .popSoftkeyboard (mActivity , content , true );
466- emojiKeyboardLayout .setVisibility (View .GONE );
467- }
468-
469- }
470- }
471- };
472-
473475 private View getCurrentNoTextInput (){
474476 if (mInputType !=null && mInputType != InputType .Text ){
475477 switch (mInputType ){
@@ -559,7 +561,6 @@ public void onAnimationEnd(Animator animation) {
559561 animEnterLayoutStatusChanaged (true );
560562 }
561563 }
562-
563564 }
564565
565566 @ Override
@@ -571,8 +572,6 @@ public void animEnterLayoutStatusChanaged(boolean isOpen) {
571572 }
572573 }
573574
574-
575-
576575 @ Override
577576 protected void onEnterLayoutDropDown (int bottom ) {
578577 super .onEnterLayoutDropDown (bottom );
@@ -583,15 +582,6 @@ protected void onEnterLayoutPopUp(int bottom) {
583582 super .onEnterLayoutPopUp (bottom );
584583 }
585584
586-
587-
588-
589-
590-
591- public EnterEmojiLayout (FragmentActivity activity , View .OnClickListener sendTextOnClick ) {
592- this (activity , sendTextOnClick , Type .Default , EmojiType .Default );
593- }
594-
595585 public boolean isEnterPanelShowing () {
596586 return mEnterLayoutStatus && (emojiKeyboardLayout .getVisibility () == View .VISIBLE || voiceLayout .getVisibility () == View .VISIBLE );
597587 }
0 commit comments