// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/interfaces/IKeyboardManager.java
// public interface IKeyboardManager {
//     boolean isKeyboardShowing();
//     void setKeyboardShowing(boolean isShowing);
//     void openKeyboard(View view);
//     void closeKeyboard(View view);
//     void closeKeyboard(Activity activity);
//     ViewTreeObserver.OnGlobalLayoutListener attach(final Activity activity, IPanelLayout target, OnKeyboardListener listener);
//     void detach(Activity activity, ViewTreeObserver.OnGlobalLayoutListener l);
// }
// 
// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/interfaces/IPanelLayout.java
// public interface IPanelLayout {
//     IMEPanelLayout getPanel();
//     void changeHeight(int panelHeight);
//     int getHeight();
//     void openPanel();
//     void closePanel();
//     void addOnPanelListener(OnPanelListener listener);
//     boolean isVisible();
//     void setHide();
//     void handleShow();
// }
// 
// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/utils/StatusBarHeightUtil.java
// public class StatusBarHeightUtil {
//     private static boolean INIT = false;
//     private static int STATUS_BAR_HEIGHT = 50;
// 
//     private final static String STATUS_BAR_DEF_PACKAGE = "android";
//     private final static String STATUS_BAR_DEF_TYPE = "dimen";
//     private final static String STATUS_BAR_NAME = "status_bar_height";
// 
//     public static synchronized int getStatusBarHeight(final Context context) {
//         if (!INIT) {
//             int resourceId = context.getResources().
//                     getIdentifier(STATUS_BAR_NAME, STATUS_BAR_DEF_TYPE, STATUS_BAR_DEF_PACKAGE);
//             if (resourceId > 0) {
//                 STATUS_BAR_HEIGHT = context.getResources().getDimensionPixelSize(resourceId);
//                 INIT = true;
//             }
//         }
// 
//         return STATUS_BAR_HEIGHT;
//     }
// }
// 
// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/utils/ViewUtil.java
// public class ViewUtil {
// 
//     public static boolean refreshHeight(final View view, final int aimHeight) {
//         if (view.isInEditMode()) {
//             return false;
//         }
// 
//         if (view.getHeight() == aimHeight) {
//             return false;
//         }
// 
//         if (Math.abs(view.getHeight() - aimHeight) ==
//                 StatusBarHeightUtil.getStatusBarHeight(view.getContext())) {
//             return false;
//         }
// 
//         final int validPanelHeight = KeyboardManagerImpl.getValidPanelHeight(view.getContext());
//         ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
//         if (layoutParams == null) {
//             layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
//                     validPanelHeight);
//             view.setLayoutParams(layoutParams);
//         } else {
//             layoutParams.height = validPanelHeight;
//             view.requestLayout();
//         }
// 
//         return true;
//     }
// 
//     public static boolean isFullScreen(final Activity activity) {
//         return (activity.getWindow().getAttributes().flags &
//                 WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
//     }
// 
//     @TargetApi(Build.VERSION_CODES.KITKAT)
//     public static boolean isTranslucentStatus(final Activity activity) {
//         //noinspection SimplifiableIfStatement
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//             return (activity.getWindow().getAttributes().flags &
//                     WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0;
//         }
//         return false;
//     }
// 
//     @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
//     public static boolean isFitsSystemWindows(final Activity activity){
//         //noinspection SimplifiableIfStatement
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//             return ((ViewGroup)activity.findViewById(android.R.id.content)).getChildAt(0).
//                     getFitsSystemWindows();
//         }
// 
//         return false;
//     }
// }


import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import org.nicky.libeasyemoji.EasyInput.interfaces.IKeyboardManager;
import org.nicky.libeasyemoji.EasyInput.interfaces.IPanelLayout;
import org.nicky.libeasyemoji.EasyInput.utils.StatusBarHeightUtil;
import org.nicky.libeasyemoji.EasyInput.utils.ViewUtil;
package org.nicky.libeasyemoji.EasyInput;




/**
 * Created by nickyang on 2017/3/22.
 */

public class RootLayoutChangeHandler {
    private final View mIMELayoutView;
    private int mOldHeight = -1;
    private final int mStatusBarHeight;
    private final boolean mIsTranslucentStatus;
    private IKeyboardManager mKeyboardManager;
    IPanelLayout mPanelManager;

// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/interfaces/IKeyboardManager.java
// public interface IKeyboardManager {
//     boolean isKeyboardShowing();
//     void setKeyboardShowing(boolean isShowing);
//     void openKeyboard(View view);
//     void closeKeyboard(View view);
//     void closeKeyboard(Activity activity);
//     ViewTreeObserver.OnGlobalLayoutListener attach(final Activity activity, IPanelLayout target, OnKeyboardListener listener);
//     void detach(Activity activity, ViewTreeObserver.OnGlobalLayoutListener l);
// }
// 
// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/interfaces/IPanelLayout.java
// public interface IPanelLayout {
//     IMEPanelLayout getPanel();
//     void changeHeight(int panelHeight);
//     int getHeight();
//     void openPanel();
//     void closePanel();
//     void addOnPanelListener(OnPanelListener listener);
//     boolean isVisible();
//     void setHide();
//     void handleShow();
// }
// 
// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/utils/StatusBarHeightUtil.java
// public class StatusBarHeightUtil {
//     private static boolean INIT = false;
//     private static int STATUS_BAR_HEIGHT = 50;
// 
//     private final static String STATUS_BAR_DEF_PACKAGE = "android";
//     private final static String STATUS_BAR_DEF_TYPE = "dimen";
//     private final static String STATUS_BAR_NAME = "status_bar_height";
// 
//     public static synchronized int getStatusBarHeight(final Context context) {
//         if (!INIT) {
//             int resourceId = context.getResources().
//                     getIdentifier(STATUS_BAR_NAME, STATUS_BAR_DEF_TYPE, STATUS_BAR_DEF_PACKAGE);
//             if (resourceId > 0) {
//                 STATUS_BAR_HEIGHT = context.getResources().getDimensionPixelSize(resourceId);
//                 INIT = true;
//             }
//         }
// 
//         return STATUS_BAR_HEIGHT;
//     }
// }
// 
// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/utils/ViewUtil.java
// public class ViewUtil {
// 
//     public static boolean refreshHeight(final View view, final int aimHeight) {
//         if (view.isInEditMode()) {
//             return false;
//         }
// 
//         if (view.getHeight() == aimHeight) {
//             return false;
//         }
// 
//         if (Math.abs(view.getHeight() - aimHeight) ==
//                 StatusBarHeightUtil.getStatusBarHeight(view.getContext())) {
//             return false;
//         }
// 
//         final int validPanelHeight = KeyboardManagerImpl.getValidPanelHeight(view.getContext());
//         ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
//         if (layoutParams == null) {
//             layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
//                     validPanelHeight);
//             view.setLayoutParams(layoutParams);
//         } else {
//             layoutParams.height = validPanelHeight;
//             view.requestLayout();
//         }
// 
//         return true;
//     }
// 
//     public static boolean isFullScreen(final Activity activity) {
//         return (activity.getWindow().getAttributes().flags &
//                 WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
//     }
// 
//     @TargetApi(Build.VERSION_CODES.KITKAT)
//     public static boolean isTranslucentStatus(final Activity activity) {
//         //noinspection SimplifiableIfStatement
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//             return (activity.getWindow().getAttributes().flags &
//                     WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0;
//         }
//         return false;
//     }
// 
//     @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
//     public static boolean isFitsSystemWindows(final Activity activity){
//         //noinspection SimplifiableIfStatement
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//             return ((ViewGroup)activity.findViewById(android.R.id.content)).getChildAt(0).
//                     getFitsSystemWindows();
//         }
// 
//         return false;
//     }
// }


// Path: libeasyemoji/src/main/java/org/nicky/libeasyemoji/EasyInput/RootLayoutChangeHandler.java
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import org.nicky.libeasyemoji.EasyInput.interfaces.IKeyboardManager;
import org.nicky.libeasyemoji.EasyInput.interfaces.IPanelLayout;
import org.nicky.libeasyemoji.EasyInput.utils.StatusBarHeightUtil;
import org.nicky.libeasyemoji.EasyInput.utils.ViewUtil;

package org.nicky.libeasyemoji.EasyInput;




/**
 * Created by nickyang on 2017/3/22.
 */

public class RootLayoutChangeHandler {
    private final View mIMELayoutView;
    private int mOldHeight = -1;
    private final int mStatusBarHeight;
    private final boolean mIsTranslucentStatus;
    private IKeyboardManager mKeyboardManager;
    IPanelLayout mPanelManager;

    public RootLayoutChangeHandler(final View imeLayout, IPanelLayout panelManager, IKeyboardManager keyboardManager){