Stick Squad 3 v1.2.5.9版本的 MD5 值为:375cf7f77a7075270cd68d1397368279

以下内容为反编译后的 AIRWindowSurfaceView.java 源代码,内容仅作参考


package com.adobe.air;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.ResultReceiver;
import android.provider.Settings;
import android.text.ClipboardManager;
import android.text.util.Linkify;
import android.view.ContextMenu;
import android.view.Display;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.adobe.air.AndroidLocale;
import com.adobe.air.gestures.AIRGestureListener;
import com.adobe.air.utils.AIRLogger;
import com.adobe.air.utils.Utils;
import com.adobe.flashruntime.air.VideoViewAIR;
import com.adobe.flashruntime.shared.VideoView;

public class AIRWindowSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
    static final int CURSOR_POS_END_DOCUMENT = 3;
    static final int CURSOR_POS_END_LINE = 1;
    static final int CURSOR_POS_START_DOCUMENT = 2;
    static final int CURSOR_POS_START_LINE = 0;
    static final int ID_COPY = 3;
    static final int ID_COPY_ALL = 4;
    static final int ID_CUT = 1;
    static final int ID_CUT_ALL = 2;
    static final int ID_PASTE = 5;
    static final int ID_SELECT_ALL = 0;
    static final int ID_START_SELECTING = 7;
    static final int ID_STOP_SELECTING = 8;
    static final int ID_SWITCH_INPUT_METHOD = 6;
    private static final String LOG_TAG = "AIRWindowSurfaceView";
    static final int LONG_PRESS_DELAY = 500;
    static final int MAX_MOVE_ACTION_ALLOWED = 4;
    static final int POST_TOUCH_MESSAGE_AFTER_DELAY = 0;
    private static final int kDefaultBitsPerPixel = 32;
    private static final int kMotionEventButtonSecondary = 2;
    private static final int kMotionEventToolTypeEraser = 4;
    private static final int kMotionEventToolTypeStylus = 2;
    private static final int kTouchActionBegin = 2;
    private static final int kTouchActionEnd = 4;
    private static final int kTouchActionHoverBegin = 16;
    private static final int kTouchActionHoverEnd = 32;
    private static final int kTouchActionHoverMove = 8;
    private static final int kTouchActionMove = 1;
    private static final int kTouchMetaStateIsEraser = 67108864;
    private static final int kTouchMetaStateIsPen = 33554432;
    private static final int kTouchMetaStateMask = 234881024;
    private static final int kTouchMetaStateSideButton1 = 134217728;
    private boolean inTouch;
    public final int kMultitouchGesture;
    public final int kMultitouchNone;
    public final int kMultitouchRaw;
    private final float kSampleSize;
    private AndroidActivityWrapper mActivityWrapper;
    private int mBoundHeight;
    private int mBoundWidth;
    private boolean mContextMenuVisible;
    private int mCurrentOrientation;
    private int mCurrentSurfaceFormat;
    private boolean mDispatchUserTriggeredSkDeactivate;
    private float mDownX;
    private float mDownY;
    private boolean mEatTouchRelease;
    protected FlashEGL mFlashEGL;
    private AndroidStageText mFocusedStageText;
    private AndroidWebView mFocusedWebView;
    private GestureDetector mGestureDetector;
    private AIRGestureListener mGestureListener;
    private boolean mHideSoftKeyboardOnWindowFocusChange;
    private boolean mHoverInProgress;
    private int mHoverMetaState;
    private HoverTimeoutHandler mHoverTimeoutHandler;
    private int mHt;
    private AndroidInputConnection mInputConnection;
    InputMethodReceiver mInputMethodReceiver;
    private boolean mIsFullScreen;
    private float mLastTouchedXCoord;
    private float mLastTouchedYCoord;
    private CheckLongPress mLongPressCheck;
    private boolean mMaliWorkaround;
    private MetaKeyState mMetaAltState;
    private MetaKeyState mMetaShiftState;
    private int mMultitouchMode;
    private boolean mNeedsCompositingSurface;
    private Paint mPaint;
    private Paint mPaintScaled;
    private AndroidStageText mResizedStageText;
    private AndroidWebView mResizedWebView;
    private ScaleGestureDetector mScaleGestureDetector;
    private int mScaledTouchSlop;
    private int mSkipHeightFromTop;
    private boolean mSurfaceChangedForSoftKeyboard;
    protected SurfaceHolder mSurfaceHolder;
    private boolean mSurfaceValid;
    private Rect mTextBoxBounds;
    private boolean mTrackBallPressed;
    private VideoView mVideoView;
    private int mVisibleBoundHeight;
    private int mVisibleBoundWidth;
    private int mWd;
    private boolean mWindowHasFocus;

    public enum MetaKeyState {
        INACTIVE,
        ACTIVE,
        PRESSED,
        LOCKED
    }

    private native void nativeCutText(boolean z);

    private native void nativeDeleteTextLine();

    public native void nativeDispatchFullScreenEvent(boolean z);

    private native void nativeDispatchSelectionChangeEvent(boolean z);

    private native void nativeForceReDraw();

    private native int nativeGetMultitouchMode();

    private native String nativeGetSelectedText();

    private native Rect nativeGetTextBoxBounds();

    private native void nativeInsertText(String str);

    private native boolean nativeIsEditable();

    private native boolean nativeIsFullScreenInteractive();

    private native boolean nativeIsMultiLineTextField();

    private native boolean nativeIsPasswordField();

    private native boolean nativeIsTextFieldInSelectionMode();

    private native boolean nativeIsTextFieldSelectable();

    private native void nativeMoveCursor(int i);

    private native void nativeOnFormatChangeListener(int i);

    private native void nativeOnSizeChangedListener(int i, int i2, boolean z);

    private native boolean nativePerformWindowPanning(int i, int i2);

    private native void nativeSelectAllText();

    public native void nativeSetKeyboardVisible(boolean z);

    private native void nativeSurfaceCreated();

    public native void nativeDispatchUserTriggeredSkDeactivateEvent();

    public native ExtractedText nativeGetTextContent();

    public native int nativeGetTextContentLength();

    public native boolean nativeIsTextSelected();

    public native boolean nativeOnDoubleClickListener(float f, float f2);

    public native boolean nativeOnKeyListener(int i, int i2, int i3, boolean z, boolean z2, boolean z3);

    public native void nativeShowOriginalRect();

    public class HoverTimeoutHandler extends Handler {
        static final int INTERVAL = 500;
        private AIRWindowSurfaceView mAIRWindowSurfaceView;
        private long mLastMove;

        public HoverTimeoutHandler(AIRWindowSurfaceView aIRWindowSurfaceView) {
            this.mAIRWindowSurfaceView = aIRWindowSurfaceView;
        }

        @Override
        public void handleMessage(Message message) {
            if (System.currentTimeMillis() - this.mLastMove >= 500) {
                AIRWindowSurfaceView.this.mHoverInProgress = false;
                Entrypoints.registerTouchCallback(0, new TouchEventData(32, this.mAIRWindowSurfaceView.mLastTouchedXCoord, this.mAIRWindowSurfaceView.mLastTouchedYCoord, 0.0f, 0, 0.0f, 0.0f, true, null, this.mAIRWindowSurfaceView.mHoverMetaState), null);
            } else {
                AIRWindowSurfaceView.this.mHoverTimeoutHandler.sendEmptyMessageDelayed(0, 500L);
            }
        }

        public void setLastMove(long j) {
            this.mLastMove = j;
        }
    }

    public AIRWindowSurfaceView(Context context, AndroidActivityWrapper androidActivityWrapper) {
        super(context);
        this.kMultitouchNone = 0;
        this.kMultitouchRaw = 1;
        this.kMultitouchGesture = 2;
        this.kSampleSize = 4.0f;
        this.mWd = 0;
        this.mHt = 0;
        this.mSurfaceValid = false;
        this.mSkipHeightFromTop = 0;
        this.mSurfaceHolder = null;
        this.mFlashEGL = null;
        this.mBoundHeight = 0;
        this.mBoundWidth = 0;
        this.mVisibleBoundWidth = 0;
        this.mVisibleBoundHeight = 0;
        this.mMultitouchMode = 0;
        this.mPaint = null;
        this.mPaintScaled = null;
        this.mMaliWorkaround = false;
        this.mHoverInProgress = false;
        this.mHoverMetaState = 0;
        this.mCurrentOrientation = 0;
        this.mEatTouchRelease = false;
        this.mContextMenuVisible = false;
        this.mLongPressCheck = null;
        this.mIsFullScreen = false;
        this.mSurfaceChangedForSoftKeyboard = false;
        this.mDispatchUserTriggeredSkDeactivate = true;
        this.mHideSoftKeyboardOnWindowFocusChange = false;
        this.mTrackBallPressed = false;
        this.mWindowHasFocus = true;
        this.mNeedsCompositingSurface = false;
        this.mCurrentSurfaceFormat = -1;
        this.mFocusedWebView = null;
        this.mResizedWebView = null;
        this.mFocusedStageText = null;
        this.mResizedStageText = null;
        this.inTouch = false;
        this.mMetaShiftState = MetaKeyState.INACTIVE;
        this.mMetaAltState = MetaKeyState.INACTIVE;
        this.mHoverTimeoutHandler = new HoverTimeoutHandler(this);
        this.mInputMethodReceiver = new InputMethodReceiver();
        this.mSurfaceHolder = getHolder();
        this.mActivityWrapper = androidActivityWrapper;
        setSurfaceFormat(false);
        this.mGestureListener = new AIRGestureListener(context, this);
        this.mGestureDetector = new GestureDetector(context, this.mGestureListener, null, false);
        this.mScaleGestureDetector = new ScaleGestureDetector(context, this.mGestureListener);
        setWillNotDraw(false);
        setClickable(true);
        setEnabled(true);
        setFocusable(true);
        setFocusableInTouchMode(true);
        this.mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        this.mSurfaceHolder.addCallback(this);
        setZOrderMediaOverlay(true);
        this.mActivityWrapper.registerPlane(this, 3);
    }

    public AndroidActivityWrapper getActivityWrapper() {
        return this.mActivityWrapper;
    }

    public View returnThis() {
        return this;
    }

    @Override
    public void onWindowFocusChanged(boolean z) {
        this.mWindowHasFocus = z;
        if (this.mLongPressCheck != null) {
            removeCallbacks(this.mLongPressCheck);
        }
        if (this.mHideSoftKeyboardOnWindowFocusChange) {
            InputMethodManager inputMethodManager = getInputMethodManager();
            if (inputMethodManager != null) {
                inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
            }
            this.mHideSoftKeyboardOnWindowFocusChange = false;
        }
        if (z) {
            this.mContextMenuVisible = false;
        }
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        boolean z = false;
        if (!AllowOSToHandleKeys(i)) {
            int unicodeChar = keyEvent.getUnicodeChar();
            if (this.mMetaShiftState == MetaKeyState.ACTIVE || this.mMetaShiftState == MetaKeyState.LOCKED || this.mMetaAltState == MetaKeyState.ACTIVE || this.mMetaAltState == MetaKeyState.LOCKED) {
                unicodeChar = GetMetaKeyCharacter(keyEvent);
            }
            HandleMetaKeyAction(keyEvent);
            if (!this.mTrackBallPressed && this.mLongPressCheck != null) {
                removeCallbacks(this.mLongPressCheck);
            }
            if (this.mActivityWrapper.isApplicationLaunched() && !HandleShortCuts(i, keyEvent)) {
                z = nativeOnKeyListener(keyEvent.getAction(), i, unicodeChar, keyEvent.isAltPressed(), keyEvent.isShiftPressed(), keyEvent.isSymPressed());
                if (this.mInputConnection != null) {
                    this.mInputConnection.updateIMEText();
                }
            }
        }
        return z;
    }

    @Override
    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        if (AllowOSToHandleKeys(i)) {
            return false;
        }
        int unicodeChar = keyEvent.getUnicodeChar();
        if (this.mMetaShiftState == MetaKeyState.ACTIVE || this.mMetaShiftState == MetaKeyState.LOCKED || this.mMetaAltState == MetaKeyState.ACTIVE || this.mMetaAltState == MetaKeyState.LOCKED) {
            unicodeChar = GetMetaKeyCharacter(keyEvent);
        }
        if (this.mLongPressCheck != null) {
            removeCallbacks(this.mLongPressCheck);
        }
        if (i == 23) {
            this.mTrackBallPressed = false;
        }
        if (!this.mActivityWrapper.isApplicationLaunched()) {
            return false;
        }
        boolean nativeOnKeyListener = nativeOnKeyListener(keyEvent.getAction(), i, unicodeChar, keyEvent.isAltPressed(), keyEvent.isShiftPressed(), keyEvent.isSymPressed());
        if (this.mInputConnection != null) {
            this.mInputConnection.updateIMEText();
        }
        if (!nativeOnKeyListener && keyEvent.getKeyCode() == 4 && keyEvent.isTracking() && !keyEvent.isCanceled()) {
            this.mActivityWrapper.getActivity().moveTaskToBack(false);
            return true;
        }
        return nativeOnKeyListener;
    }

    public boolean onGenericMotionEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 9 || motionEvent.getAction() == 10 || motionEvent.getAction() == 7) {
            return onTouchEvent(motionEvent);
        }
        return false;
    }

    @Override
    public void onFocusChanged(boolean z, int i, Rect rect) {
        AIRLogger.d(LOG_TAG, "*** *** onFocusChanged: AIR");
        if (z && this.mFocusedStageText != null && !this.inTouch) {
            this.mDispatchUserTriggeredSkDeactivate = true;
            forceSoftKeyboardDown();
        }
        super.onFocusChanged(z, i, rect);
    }

    @Override
    public boolean onTouchEvent(MotionEvent motionEvent) {
        boolean z;
        int i;
        boolean z2;
        int i2;
        int i3;
        boolean z3;
        boolean z4;
        boolean z5;
        RelativeLayout overlaysLayout;
        boolean z6 = true;
        this.inTouch = true;
        int action = motionEvent.getAction() & 255;
        boolean z7 = action == 9 || action == 10 || action == 7;
        if (!hasFocus() && !z7 && (overlaysLayout = this.mActivityWrapper.getOverlaysLayout(false)) != null) {
            requestFocus();
            overlaysLayout.clearFocus();
            int childCount = overlaysLayout.getChildCount();
            for (int i4 = 0; i4 < childCount; i4++) {
                View childAt = overlaysLayout.getChildAt(i4);
                if (childAt != null) {
                    childAt.clearFocus();
                }
            }
        }
        if (action == 5 || action == 0) {
            for (int i5 = 0; i5 < motionEvent.getPointerCount(); i5++) {
                this.mGestureListener.setDownTouchPoint(motionEvent.getX(i5), motionEvent.getY(i5), motionEvent.getPointerId(i5));
            }
        }
        if (action == 0) {
            this.mGestureListener.mayStartNewTransformGesture();
        }
        if (action == 5) {
            this.mGestureListener.setCouldBeTwoFingerTap(1);
            this.mGestureListener.setPrimaryPointOfTwoFingerTap(motionEvent.getX(0), motionEvent.getY(0), motionEvent.getPointerId(0));
            this.mGestureListener.setSecondaryPointOfTwoFingerTap(motionEvent.getX(1), motionEvent.getY(1), motionEvent.getPointerId(1));
        } else if (action == 6 && this.mGestureListener.getCouldBeTwoFingerTap() == 1) {
            this.mGestureListener.setCouldBeTwoFingerTap(2);
        } else if (action == 1 && this.mGestureListener.getCouldBeTwoFingerTap() == 2) {
            this.mGestureListener.setCouldBeTwoFingerTap(3);
        } else if (action != 2) {
            this.mGestureListener.setCouldBeTwoFingerTap(0);
        }
        if (this.mActivityWrapper.isApplicationLaunched()) {
            int pointerCount = motionEvent.getPointerCount();
            boolean z8 = false;
            int i6 = 0;
            while (i6 < pointerCount) {
                float x = motionEvent.getX(i6);
                float y2 = this.mSkipHeightFromTop + motionEvent.getY(i6);
                this.mLastTouchedXCoord = x;
                this.mLastTouchedYCoord = y2;
                int i7 = 1;
                int action2 = motionEvent.getAction();
                int pointerId = motionEvent.getPointerId(i6);
                int metaState = motionEvent.getMetaState();
                if (Build.VERSION.SDK_INT >= 14) {
                    metaState &= -234881025;
                    int toolType = motionEvent.getToolType(i6);
                    if (toolType == 4) {
                        metaState |= 67108864;
                    } else if (toolType == 2) {
                        metaState |= 33554432;
                    }
                    if ((motionEvent.getButtonState() & 2) != 0) {
                        i = metaState | 134217728;
                        if (!z8) {
                            i2 = 3;
                            i3 = 4;
                            z3 = z8;
                            z4 = false;
                        } else {
                            if (motionEvent.getPointerCount() == 1 || pointerId == motionEvent.getPointerId((65280 & action2) >> 8)) {
                                action2 &= 255;
                                switch (action2) {
                                    case 0:
                                    case 5:
                                        i2 = action2;
                                        i3 = 2;
                                        z3 = z8;
                                        z4 = false;
                                        break;
                                    case 1:
                                    case 6:
                                        z2 = z8;
                                        this.mGestureListener.endTwoFingerGesture();
                                        this.mGestureListener.setCheckForSwipe(true);
                                        i2 = action2;
                                        i3 = 4;
                                        z3 = z2;
                                        z4 = false;
                                        break;
                                    case 2:
                                    case 4:
                                    case 8:
                                    default:
                                        this.mHoverTimeoutHandler.setLastMove(System.currentTimeMillis());
                                        i2 = action2;
                                        i3 = 1;
                                        z3 = z8;
                                        z4 = false;
                                        break;
                                    case 3:
                                        z2 = true;
                                        this.mGestureListener.endTwoFingerGesture();
                                        this.mGestureListener.setCheckForSwipe(true);
                                        i2 = action2;
                                        i3 = 4;
                                        z3 = z2;
                                        z4 = false;
                                        break;
                                    case 7:
                                        i7 = 8;
                                        if (Build.VERSION.SDK_INT < 14) {
                                            this.mHoverTimeoutHandler.setLastMove(System.currentTimeMillis());
                                            this.mHoverMetaState = i;
                                            if (!this.mHoverInProgress) {
                                                this.mHoverTimeoutHandler.sendEmptyMessageDelayed(0, 500L);
                                                z4 = true;
                                                this.mHoverInProgress = true;
                                                i2 = action2;
                                                i3 = 8;
                                                z3 = z8;
                                                break;
                                            }
                                        }
                                        break;
                                    case 9:
                                        i2 = action2;
                                        i3 = 16;
                                        z3 = z8;
                                        z4 = false;
                                        break;
                                    case 10:
                                        i2 = action2;
                                        i3 = 32;
                                        z3 = z8;
                                        z4 = false;
                                        break;
                                }
                            }
                            z4 = false;
                            i2 = action2;
                            i3 = i7;
                            z3 = z8;
                        }
                        if (IsTouchEventHandlingAllowed(i3, x, y2)) {
                            float size = motionEvent.getSize(i6);
                            boolean z9 = pointerId == 0;
                            int historySize = motionEvent.getHistorySize();
                            float[] fArr = new float[(historySize + 1) * 3];
                            int i8 = 0;
                            int i9 = 0;
                            while (true) {
                                int i10 = i8;
                                if (i9 < historySize) {
                                    int i11 = i10 + 1;
                                    fArr[i10] = motionEvent.getHistoricalX(i6, i9);
                                    int i12 = i11 + 1;
                                    fArr[i11] = motionEvent.getHistoricalY(i6, i9);
                                    i8 = i12 + 1;
                                    fArr[i12] = motionEvent.getHistoricalPressure(i6, i9);
                                    i9++;
                                } else {
                                    float pressure = motionEvent.getPressure(i6);
                                    fArr[i10] = x;
                                    fArr[i10 + 1] = y2;
                                    fArr[i10 + 2] = pressure;
                                    int i13 = i & (-2);
                                    int i14 = 0;
                                    switch (i3) {
                                        case 1:
                                        case 2:
                                            i14 = 1;
                                            break;
                                        case 8:
                                            i14 = 8;
                                            if (Build.VERSION.SDK_INT < 14 && z4) {
                                                i14 = 24;
                                                break;
                                            }
                                            break;
                                    }
                                    if (i14 != 0) {
                                        z6 = z6 && Entrypoints.registerTouchCallback(0, new TouchEventData(i14, x, y2, pressure, pointerId, size, size, z9, fArr, i13), null);
                                    }
                                    if (i3 != 8 && i3 != 1) {
                                        if (i2 == 3) {
                                            i13 |= 1;
                                        }
                                        z5 = z6 && Entrypoints.registerTouchCallback(0, new TouchEventData(i3, x, y2, pressure, pointerId, size, size, z9, null, i13), null);
                                        i6++;
                                        z6 = z5;
                                        z8 = z3;
                                    }
                                }
                            }
                        }
                        z5 = z6;
                        i6++;
                        z6 = z5;
                        z8 = z3;
                    }
                }
                i = metaState;
                if (!z8) {
                }
                if (IsTouchEventHandlingAllowed(i3, x, y2)) {
                }
                z5 = z6;
                i6++;
                z6 = z5;
                z8 = z3;
            }
            z = z6;
        } else {
            z = false;
        }
        if (z) {
            if (this.mScaleGestureDetector.onTouchEvent(motionEvent)) {
                z = true;
                boolean z10 = !z && this.mGestureDetector.onTouchEvent(motionEvent);
                this.inTouch = false;
                return z10;
            }
        }
        z = false;
        if (z) {
        }
        this.inTouch = false;
        return z10;
    }

    @Override
    public void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
    }

    public void setMultitouchMode(int i) {
        this.mMultitouchMode = i;
    }

    public int getMultitouchMode() {
        return this.mMultitouchMode;
    }

    @Override
    public void surfaceCreated(SurfaceHolder surfaceHolder) {
        this.mActivityWrapper.planeStepCascade();
        if (this.mIsFullScreen) {
            setFullScreen();
        }
        if (this.mActivityWrapper.isStarted() || this.mActivityWrapper.isResumed() || (Build.MANUFACTURER.equalsIgnoreCase("SAMSUNG") && Build.MODEL.equalsIgnoreCase("GT-I9300"))) {
            nativeSurfaceCreated();
        }
    }

    @Override
    public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
        Display defaultDisplay = ((WindowManager) this.mActivityWrapper.getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        this.mBoundHeight = defaultDisplay.getHeight();
        this.mBoundWidth = defaultDisplay.getWidth();
        this.mVisibleBoundHeight = i3;
        this.mVisibleBoundWidth = i2;
        nativeOnFormatChangeListener(i);
        if (!this.mSurfaceValid) {
            this.mSurfaceValid = true;
            this.mActivityWrapper.onSurfaceInitialized();
            setMultitouchMode(nativeGetMultitouchMode());
        }
        if (this.mSurfaceValid) {
            int i4 = getResources().getConfiguration().orientation;
            if (i4 == this.mCurrentOrientation) {
                if ((i4 == 1 || i4 == 2) && i3 < this.mHt) {
                    if (i3 != 0) {
                        if (nativePerformWindowPanning(i4, this.mHt - i3)) {
                            this.mSurfaceChangedForSoftKeyboard = true;
                            return;
                        }
                    } else {
                        return;
                    }
                }
            } else {
                showSoftKeyboard(false);
                nativeDispatchUserTriggeredSkDeactivateEvent();
                this.mDispatchUserTriggeredSkDeactivate = false;
            }
            boolean z = this.mCurrentOrientation != i4;
            this.mCurrentOrientation = i4;
            this.mWd = i2;
            this.mHt = i3;
            nativeOnSizeChangedListener(this.mWd, this.mHt, z);
            OrientationManager orientationManager = OrientationManager.getOrientationManager();
            if (orientationManager.mDispatchOrientationChangePending) {
                orientationManager.nativeOrientationChanged(orientationManager.mBeforeOrientation, orientationManager.mAfterOrientation);
                orientationManager.mDispatchOrientationChangePending = false;
            }
            nativeForceReDraw();
            forceSoftKeyboardDown();
        }
    }

    public void forceSoftKeyboardDown() {
        nativeShowOriginalRect();
        setScrollTo(0);
        if (this.mDispatchUserTriggeredSkDeactivate && this.mSurfaceChangedForSoftKeyboard) {
            nativeDispatchUserTriggeredSkDeactivateEvent();
        }
        nativeSetKeyboardVisible(false);
        this.mDispatchUserTriggeredSkDeactivate = true;
        this.mSurfaceChangedForSoftKeyboard = false;
    }

    public boolean isSurfaceValid() {
        return this.mSurfaceValid;
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
        this.mSurfaceValid = false;
        if (this.mFlashEGL != null) {
            this.mFlashEGL.DestroyWindowSurface();
        }
        this.mActivityWrapper.onSurfaceDestroyed();
        this.mActivityWrapper.planeBreakCascade();
    }

    public class InputMethodReceiver extends ResultReceiver {
        public InputMethodReceiver() {
            super(AIRWindowSurfaceView.this.getHandler());
        }

        @Override
        protected void onReceiveResult(int i, Bundle bundle) {
            if (i != 1 && i != 3) {
                AIRWindowSurfaceView.this.nativeSetKeyboardVisible(true);
            } else {
                AIRWindowSurfaceView.this.nativeShowOriginalRect();
            }
        }
    }

    public void showSoftKeyboard(boolean z, View view) {
        AIRLogger.d(LOG_TAG, "showSoftKeyboard show: " + z);
        InputMethodManager inputMethodManager = getInputMethodManager();
        if (!z) {
            if (this.mSurfaceChangedForSoftKeyboard) {
                this.mDispatchUserTriggeredSkDeactivate = false;
            }
            inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
            if (this.mInputConnection != null) {
                this.mInputConnection.Reset();
            }
            nativeSetKeyboardVisible(false);
            return;
        }
        inputMethodManager.showSoftInput(view, 0, this.mInputMethodReceiver);
    }

    public void showSoftKeyboard(boolean z) {
        showSoftKeyboard(z, this);
    }

    public void updateFocusedStageWebView(AndroidWebView androidWebView, boolean z) {
        if (z) {
            this.mFocusedWebView = androidWebView;
        } else if (this.mFocusedWebView == androidWebView) {
            this.mFocusedWebView = null;
        }
    }

    public boolean isStageWebViewInFocus() {
        if (this.mFocusedWebView != null) {
            return this.mFocusedWebView.isInTextEditingMode();
        }
        return false;
    }

    public long panStageWebViewInFocus() {
        if (this.mFocusedWebView == null) {
            return 0L;
        }
        this.mResizedWebView = this.mFocusedWebView;
        return this.mFocusedWebView.updateViewBoundsWithKeyboard(this.mHt);
    }

    public void updateFocusedStageText(AndroidStageText androidStageText, boolean z) {
        if (z) {
            this.mFocusedStageText = androidStageText;
        } else if (this.mFocusedStageText == androidStageText) {
            this.mFocusedStageText = null;
        }
    }

    public boolean isStageTextInFocus() {
        return this.mFocusedStageText != null;
    }

    public long panStageTextInFocus() {
        if (this.mFocusedStageText == null) {
            return 0L;
        }
        this.mResizedStageText = this.mFocusedStageText;
        return this.mFocusedStageText.updateViewBoundsWithKeyboard(this.mHt);
    }

    private boolean IsIMEInFullScreen() {
        return getInputMethodManager().isFullscreenMode();
    }

    public boolean setScrollTo(final int i) {
        this.mSkipHeightFromTop = i;
        final RelativeLayout overlaysLayout = this.mActivityWrapper.getOverlaysLayout(false);
        if (overlaysLayout != null) {
            post(new Runnable() {
                @Override
                public void run() {
                    if (i == 0 && AIRWindowSurfaceView.this.mResizedWebView != null) {
                        AIRWindowSurfaceView.this.mResizedWebView.resetGlobalBounds();
                        AIRWindowSurfaceView.this.mResizedWebView = null;
                    }
                    if (i == 0 && AIRWindowSurfaceView.this.mResizedStageText != null) {
                        AIRWindowSurfaceView.this.mResizedStageText.resetGlobalBounds();
                        AIRWindowSurfaceView.this.mResizedStageText = null;
                    }
                    overlaysLayout.setPadding(0, -i, 0, 0);
                    overlaysLayout.requestLayout();
                }
            });
            return true;
        }
        return true;
    }

    private void setSurfaceFormatImpl(boolean z, final int i) {
        if (z) {
            post(new Runnable() {
                @Override
                public void run() {
                    AIRWindowSurfaceView.this.mSurfaceHolder.setFormat(i);
                    AIRWindowSurfaceView.this.mCurrentSurfaceFormat = i;
                }
            });
        } else {
            this.mSurfaceHolder.setFormat(i);
            this.mCurrentSurfaceFormat = i;
        }
    }

    public void setSurfaceFormat(boolean z) {
        if (!this.mActivityWrapper.useRGB565()) {
            if (!this.mNeedsCompositingSurface && !this.mActivityWrapper.needsCompositingSurface()) {
                AndroidActivityWrapper androidActivityWrapper = this.mActivityWrapper;
                if (AndroidActivityWrapper.isGingerbread()) {
                    setSurfaceFormatImpl(z, 2);
                    return;
                }
            }
            setSurfaceFormatImpl(z, 1);
            return;
        }
        if (this.mNeedsCompositingSurface) {
            setSurfaceFormatImpl(z, 1);
        } else {
            setSurfaceFormatImpl(z, 4);
        }
    }

    public void setCompositingHint(boolean z) {
        this.mNeedsCompositingSurface = z;
        if (z && this.mCurrentSurfaceFormat == 1) {
            return;
        }
        if (z || this.mCurrentSurfaceFormat != 2) {
            setSurfaceFormat(true);
        }
    }

    public void draw(int i, int i2, int i3, int i4, Bitmap bitmap) {
        Canvas lockCanvas;
        Rect rect;
        if (this.mSurfaceValid) {
            Rect rect2 = new Rect(i, i2, i + i3, i2 + i4);
            int i5 = this.mSkipHeightFromTop;
            if (i5 != 0) {
                Rect rect3 = new Rect(0, i5, this.mWd, this.mHt);
                if (Rect.intersects(rect2, rect3)) {
                    Rect rect4 = new Rect(rect2);
                    rect4.intersect(rect3);
                    rect4.top -= i5;
                    rect4.bottom -= i5;
                    if (this.mIsFullScreen) {
                        rect4.union(new Rect(0, rect4.bottom, this.mWd, this.mHt));
                    }
                    Canvas lockCanvas2 = this.mSurfaceHolder.lockCanvas(rect4);
                    if (!this.mIsFullScreen && rect4.bottom > this.mHt - i5) {
                        rect4.bottom = this.mHt - i5;
                    }
                    rect = rect4;
                    lockCanvas = lockCanvas2;
                } else {
                    return;
                }
            } else {
                lockCanvas = this.mSurfaceHolder.lockCanvas(rect2);
                rect = rect2;
            }
            try {
                synchronized (this.mSurfaceHolder) {
                    lockCanvas.clipRect(rect);
                    if (i5 != 0 && this.mIsFullScreen) {
                        lockCanvas.drawColor(-16777216);
                    }
                    if (this.mMaliWorkaround) {
                        this.mPaint = null;
                        lockCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
                    } else if (this.mPaint == null && this.mCurrentSurfaceFormat != 4) {
                        this.mPaint = new Paint();
                        this.mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
                        this.mPaint.setFilterBitmap(false);
                    }
                    lockCanvas.drawBitmap(bitmap, 0.0f, -i5, this.mPaint);
                }
                if (lockCanvas != null) {
                    this.mSurfaceHolder.unlockCanvasAndPost(lockCanvas);
                }
            } catch (Exception e) {
                if (lockCanvas != null) {
                    this.mSurfaceHolder.unlockCanvasAndPost(lockCanvas);
                }
            } catch (Throwable th) {
                if (lockCanvas != null) {
                    this.mSurfaceHolder.unlockCanvasAndPost(lockCanvas);
                }
                throw th;
            }
            if (this.mInputConnection != null) {
                this.mInputConnection.updateIMEText();
            }
        }
    }

    public void drawScaled(int i, int i2, int i3, int i4, Bitmap bitmap, int i5, int i6, int i7, int i8, boolean z, int i9) {
        Canvas canvas;
        Throwable th;
        Rect rect;
        if (this.mSurfaceValid) {
            Canvas canvas2 = null;
            try {
                Rect rect2 = new Rect(i5, i6, i5 + i7, i6 + i8);
                Rect rect3 = z ? new Rect(0, 0, this.mWd, this.mHt) : new Rect(i5, i6, i5 + i7, i6 + i8);
                if (this.mSkipHeightFromTop != 0) {
                    int i10 = this.mSkipHeightFromTop;
                    Rect rect4 = new Rect(0, i10, this.mWd, this.mHt);
                    if (!Rect.intersects(rect2, rect4)) {
                        if (0 != 0) {
                            this.mSurfaceHolder.unlockCanvasAndPost(null);
                            return;
                        }
                        return;
                    }
                    rect = new Rect(rect2);
                    rect.intersect(rect4);
                    rect.top -= i10;
                    rect.bottom -= i10;
                    if (!z) {
                        rect3 = rect;
                    }
                    if (!z && rect.bottom > this.mHt - i10) {
                        rect.bottom = this.mHt - i10;
                    }
                } else {
                    rect = rect2;
                }
                Rect rect5 = new Rect(i, i2, i + i3, i2 + i4);
                canvas = this.mSurfaceHolder.lockCanvas(rect3);
                try {
                    synchronized (this.mSurfaceHolder) {
                        if (z) {
                            canvas.drawRGB(Color.red(i9), Color.green(i9), Color.blue(i9));
                        }
                        if (this.mMaliWorkaround) {
                            this.mPaint = null;
                            canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                        } else if (this.mPaintScaled == null && this.mCurrentSurfaceFormat != 4) {
                            this.mPaintScaled = new Paint();
                            this.mPaintScaled.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
                        }
                        canvas.drawBitmap(bitmap, rect5, rect, this.mPaintScaled);
                    }
                    if (canvas != null) {
                        this.mSurfaceHolder.unlockCanvasAndPost(canvas);
                    }
                } catch (Exception e) {
                    canvas2 = canvas;
                    if (canvas2 != null) {
                        this.mSurfaceHolder.unlockCanvasAndPost(canvas2);
                    }
                    if (this.mInputConnection == null) {
                    }
                } catch (Throwable th2) {
                    th = th2;
                    if (canvas != null) {
                        this.mSurfaceHolder.unlockCanvasAndPost(canvas);
                    }
                    throw th;
                }
            } catch (Exception e2) {
            } catch (Throwable th3) {
                canvas = null;
                th = th3;
            }
            if (this.mInputConnection == null) {
                this.mInputConnection.updateIMEText();
            }
        }
    }

    public void drawBitmap(int i, int i2, int i3, int i4, Bitmap bitmap) {
        draw(i, i2, i3, i4, bitmap);
    }

    public void drawBitmap(int i, int i2, int i3, int i4, Bitmap bitmap, int i5, int i6, int i7, int i8, boolean z, int i9) {
        drawScaled(i, i2, i3, i4, bitmap, i5, i6, i7, i8, z, i9);
    }

    public boolean getIsFullScreen() {
        return this.mIsFullScreen;
    }

    private static boolean supportsSystemUiVisibilityAPI() {
        return Build.VERSION.SDK_INT >= 11;
    }

    private static boolean supportsSystemUiFlags() {
        return Build.VERSION.SDK_INT >= 14;
    }

    private boolean hasStatusBar(Window window) {
        Rect rect = new Rect();
        window.getDecorView().getWindowVisibleDisplayFrame(rect);
        return rect.top > 0;
    }

    private void DoSetOnSystemUiVisibilityChangeListener() {
        setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int i) {
                this.setOnSystemUiVisibilityChangeListener(null);
                if (this.getIsFullScreen()) {
                    this.nativeDispatchFullScreenEvent(true);
                } else {
                    this.nativeDispatchFullScreenEvent(false);
                }
            }
        });
    }

    public void setFullScreen() {
        if (!this.mIsFullScreen) {
            this.mIsFullScreen = true;
            this.mActivityWrapper.setIsFullScreen(this.mIsFullScreen);
            if (supportsSystemUiVisibilityAPI()) {
                if (supportsSystemUiFlags()) {
                }
                DoSetOnSystemUiVisibilityChangeListener();
                setSystemUiVisibility(1);
            }
            this.mActivityWrapper.planeBreakCascade();
        }
        Activity activity = this.mActivityWrapper.getActivity();
        if (activity != null) {
            Window window = activity.getWindow();
            if (!supportsSystemUiVisibilityAPI() || hasStatusBar(window)) {
                window.setFlags(1024, 1024);
            }
        }
    }

    public void clearFullScreen() {
        this.mIsFullScreen = false;
        this.mActivityWrapper.setIsFullScreen(this.mIsFullScreen);
        if (supportsSystemUiVisibilityAPI()) {
            if (supportsSystemUiFlags()) {
            }
            DoSetOnSystemUiVisibilityChangeListener();
            setSystemUiVisibility(0);
        }
        Activity activity = this.mActivityWrapper.getActivity();
        if (activity != null) {
            activity.getWindow().clearFlags(1024);
        }
        this.mActivityWrapper.planeBreakCascade();
    }

    public int getBoundWidth() {
        return this.mBoundWidth;
    }

    public int getBoundHeight() {
        return this.mBoundHeight;
    }

    public int getVisibleBoundWidth() {
        return this.mVisibleBoundWidth;
    }

    public int getVisibleBoundHeight() {
        return this.mVisibleBoundHeight;
    }

    public int getColorDepth() {
        if (this.mCurrentSurfaceFormat == 4) {
            return 16;
        }
        Activity activity = this.mActivityWrapper.getActivity();
        if (activity == null) {
            return 32;
        }
        Display defaultDisplay = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        PixelFormat pixelFormat = new PixelFormat();
        PixelFormat.getPixelFormatInfo(defaultDisplay.getPixelFormat(), pixelFormat);
        return pixelFormat.bitsPerPixel;
    }

    public int getAppSpecifiedPixelFormat() {
        return this.mActivityWrapper.useRGB565() ? 16 : 32;
    }

    public void showActionScript2Warning() {
        Activity activity = this.mActivityWrapper.getActivity();
        if (activity != null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            TextView textView = new TextView(activity);
            textView.setText("Your application is attempting to run ActionScript2.0, which is not supported on smart phone profile. \nSee the Adobe Developer Connection for more info www.adobe.com/devnet");
            Linkify.addLinks(textView, 1);
            builder.setView(textView);
            builder.setTitle("Action Script 2.0");
            builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            builder.show();
        }
    }

    public boolean IsLandScape() {
        return this.mCurrentOrientation == 2;
    }

    @Override
    public boolean onCheckIsTextEditor() {
        return true;
    }

    @Override
    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        if (this.mActivityWrapper.isApplicationLaunched() && nativeIsEditable()) {
            editorInfo.imeOptions |= 1073741824;
            editorInfo.imeOptions |= 6;
            editorInfo.inputType |= 1;
            if (nativeIsPasswordField()) {
                editorInfo.inputType |= 128;
            }
            if (nativeIsMultiLineTextField()) {
                editorInfo.inputType |= 131072;
            }
            this.mInputConnection = new AndroidInputConnection(this);
            editorInfo.initialSelStart = -1;
            editorInfo.initialSelEnd = -1;
            editorInfo.initialCapsMode = 0;
        } else {
            this.mInputConnection = null;
        }
        return this.mInputConnection;
    }

    public void RestartInput() {
        this.mMetaShiftState = MetaKeyState.INACTIVE;
        this.mMetaAltState = MetaKeyState.INACTIVE;
        InputMethodManager inputMethodManager = getInputMethodManager();
        if (inputMethodManager != null) {
            inputMethodManager.restartInput(this);
        }
        if (this.mInputConnection != null) {
            this.mInputConnection.Reset();
        }
    }

    public InputMethodManager getInputMethodManager() {
        return (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    }

    @Override
    public boolean performLongClick() {
        Rect nativeGetTextBoxBounds;
        if (!this.mWindowHasFocus || (nativeGetTextBoxBounds = nativeGetTextBoxBounds()) == null) {
            return false;
        }
        if ((this.mLastTouchedXCoord <= nativeGetTextBoxBounds.left || this.mLastTouchedXCoord >= nativeGetTextBoxBounds.right || this.mLastTouchedYCoord <= nativeGetTextBoxBounds.top || this.mLastTouchedYCoord >= nativeGetTextBoxBounds.bottom) && !this.mTrackBallPressed) {
            return false;
        }
        this.mTrackBallPressed = false;
        return super.performLongClick();
    }

    @Override
    public void onCreateContextMenu(ContextMenu contextMenu) {
        super.onCreateContextMenu(contextMenu);
        if (!this.mIsFullScreen || nativeIsFullScreenInteractive()) {
            ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            MenuHandler menuHandler = new MenuHandler();
            boolean nativeIsEditable = nativeIsEditable();
            boolean nativeIsTextFieldSelectable = nativeIsTextFieldSelectable();
            if (nativeIsTextFieldSelectable || nativeIsEditable) {
                if (nativeIsTextFieldSelectable) {
                    boolean z = nativeGetTextContentLength() > 0;
                    if (z) {
                        contextMenu.add(0, 0, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_SELECT_ALL)).setOnMenuItemClickListener(menuHandler).setAlphabeticShortcut('a');
                        if (nativeIsTextFieldInSelectionMode()) {
                            contextMenu.add(0, 8, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_STOP_SELECTING_TEXT)).setOnMenuItemClickListener(menuHandler);
                        } else {
                            contextMenu.add(0, 7, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_SELECT_TEXT)).setOnMenuItemClickListener(menuHandler);
                        }
                    }
                    if (!nativeIsPasswordField() && z) {
                        boolean nativeIsTextSelected = nativeIsTextSelected();
                        if (nativeIsEditable) {
                            if (nativeIsTextSelected) {
                                contextMenu.add(0, 1, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_CUT_STRING)).setOnMenuItemClickListener(menuHandler).setAlphabeticShortcut('x');
                            } else {
                                contextMenu.add(0, 2, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_CUT_ALL_STRING)).setOnMenuItemClickListener(menuHandler);
                            }
                        }
                        if (nativeIsTextSelected) {
                            contextMenu.add(0, 3, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_COPY_STRING)).setOnMenuItemClickListener(menuHandler).setAlphabeticShortcut('c');
                        } else {
                            contextMenu.add(0, 4, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_COPY_ALL_STRING)).setOnMenuItemClickListener(menuHandler);
                        }
                    }
                }
                if (nativeIsEditable) {
                    if (clipboardManager != null && clipboardManager.hasText()) {
                        contextMenu.add(0, 5, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_PASTE_STRING)).setOnMenuItemClickListener(menuHandler).setAlphabeticShortcut('v');
                    }
                    contextMenu.add(0, 6, 0, AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_INPUT_METHOD_STRING)).setOnMenuItemClickListener(menuHandler);
                }
                this.mEatTouchRelease = true;
                this.mContextMenuVisible = true;
                contextMenu.setHeaderTitle(AndroidLocale.GetLocalizedString(AndroidLocale.STRING_ID.IDA_CONTEXT_MENU_TITLE_STRING));
            }
        }
    }

    private void postCheckLongPress() {
        if (this.mLongPressCheck == null) {
            this.mLongPressCheck = new CheckLongPress();
        }
        postDelayed(this.mLongPressCheck, 500L);
    }

    public class CheckLongPress implements Runnable {
        CheckLongPress() {
        }

        @Override
        public void run() {
            AIRWindowSurfaceView.this.performLongClick();
        }
    }

    private class MenuHandler implements MenuItem.OnMenuItemClickListener {
        private MenuHandler() {
        }

        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            return AIRWindowSurfaceView.this.onTextBoxContextMenuItem(menuItem.getItemId());
        }
    }

    public boolean onTextBoxContextMenuItem(int i) {
        ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
        switch (i) {
            case 0:
                nativeSelectAllText();
                break;
            case 1:
                String nativeGetSelectedText = nativeGetSelectedText();
                if (nativeGetSelectedText != null) {
                    nativeCutText(false);
                    if (nativeIsPasswordField()) {
                        nativeGetSelectedText = Utils.ReplaceTextContentWithStars(nativeGetSelectedText);
                    }
                    clipboardManager.setText(nativeGetSelectedText);
                }
                SetSelectionMode(false);
                break;
            case 2:
                CharSequence charSequence = nativeGetTextContent().text;
                if (charSequence != null) {
                    nativeCutText(true);
                    if (nativeIsPasswordField()) {
                        charSequence = Utils.ReplaceTextContentWithStars(charSequence.toString());
                    }
                    clipboardManager.setText(charSequence);
                    break;
                }
                break;
            case 3:
                String nativeGetSelectedText2 = nativeGetSelectedText();
                if (nativeGetSelectedText2 != null) {
                    if (nativeIsPasswordField()) {
                        nativeGetSelectedText2 = Utils.ReplaceTextContentWithStars(nativeGetSelectedText2);
                    }
                    clipboardManager.setText(nativeGetSelectedText2);
                }
                SetSelectionMode(false);
                break;
            case 4:
                CharSequence charSequence2 = nativeGetTextContent().text;
                if (charSequence2 != null) {
                    if (nativeIsPasswordField()) {
                        charSequence2 = Utils.ReplaceTextContentWithStars(charSequence2.toString());
                    }
                    clipboardManager.setText(charSequence2);
                    break;
                }
                break;
            case 5:
                CharSequence text = clipboardManager.getText();
                if (text != null) {
                    nativeInsertText(text.toString());
                }
                SetSelectionMode(false);
                break;
            case 6:
                InputMethodManager inputMethodManager = getInputMethodManager();
                if (inputMethodManager != null) {
                    inputMethodManager.showInputMethodPicker();
                    break;
                }
                break;
            case 7:
                SetSelectionMode(true);
                break;
            case 8:
                SetSelectionMode(false);
                break;
            default:
                return false;
        }
        if (this.mInputConnection != null) {
            this.mInputConnection.updateIMEText();
        }
        return true;
    }

    private boolean IsTouchEventHandlingAllowed(int i, float f, float f2) {
        boolean IsPointInTextBox = IsPointInTextBox(f, f2, i);
        if (i == 2) {
            this.mDownX = f;
            this.mDownY = f2;
            this.mEatTouchRelease = false;
            if (!IsPointInTextBox) {
                return true;
            }
            postCheckLongPress();
            return true;
        }
        if (i == 1) {
            if (!IsPointInTextBox) {
                return true;
            }
            if (!IsTouchMove(f, f2)) {
                return false;
            }
            if (this.mLongPressCheck == null) {
                return true;
            }
            removeCallbacks(this.mLongPressCheck);
            return true;
        }
        if (i != 4 || this.mLongPressCheck == null) {
            return true;
        }
        removeCallbacks(this.mLongPressCheck);
        return true;
    }

    private boolean IsTouchMove(float f, float f2) {
        float f3 = this.mDownX - f;
        float f4 = this.mDownY - f2;
        return ((float) Math.sqrt((double) ((f3 * f3) + (f4 * f4)))) >= ((float) this.mScaledTouchSlop);
    }

    private boolean IsPointInTextBox(float f, float f2, int i) {
        boolean z;
        if (i == 2) {
            this.mTextBoxBounds = nativeGetTextBoxBounds();
        }
        if (this.mTextBoxBounds != null && ((int) f) > this.mTextBoxBounds.left && ((int) f) < this.mTextBoxBounds.right && ((int) f2) > this.mTextBoxBounds.top && ((int) f2) < this.mTextBoxBounds.bottom) {
            z = true;
        } else {
            z = false;
        }
        if (i == 4) {
            this.mTextBoxBounds = null;
        }
        return z;
    }

    private void HandleMetaKeyAction(KeyEvent keyEvent) {
        switch (keyEvent.getKeyCode()) {
            case 57:
            case 58:
                if (keyEvent.getRepeatCount() == 0) {
                    this.mMetaAltState = GetMetaKeyState(this.mMetaAltState, keyEvent.isAltPressed(), false);
                    return;
                }
                return;
            case 59:
            case 60:
                if (keyEvent.getRepeatCount() == 0) {
                    this.mMetaShiftState = GetMetaKeyState(this.mMetaShiftState, keyEvent.isShiftPressed(), false);
                    return;
                }
                return;
            default:
                this.mMetaShiftState = GetMetaKeyState(this.mMetaShiftState, keyEvent.isShiftPressed(), true);
                this.mMetaAltState = GetMetaKeyState(this.mMetaAltState, keyEvent.isAltPressed(), true);
                return;
        }
    }

    private MetaKeyState GetMetaKeyState(MetaKeyState metaKeyState, boolean z, boolean z2) {
        if (z2) {
            switch (metaKeyState) {
                case INACTIVE:
                case PRESSED:
                    return z ? MetaKeyState.PRESSED : MetaKeyState.INACTIVE;
                case ACTIVE:
                    return z ? MetaKeyState.PRESSED : MetaKeyState.INACTIVE;
                case LOCKED:
                    return MetaKeyState.LOCKED;
                default:
                    return MetaKeyState.INACTIVE;
            }
        }
        if (z) {
            switch (metaKeyState) {
                case INACTIVE:
                case PRESSED:
                    return MetaKeyState.ACTIVE;
                case ACTIVE:
                    return MetaKeyState.LOCKED;
                default:
                    return MetaKeyState.INACTIVE;
            }
        }
        return MetaKeyState.INACTIVE;
    }

    int GetMetaKeyCharacter(KeyEvent keyEvent) {
        int i = 0;
        if (this.mMetaShiftState == MetaKeyState.LOCKED || this.mMetaShiftState == MetaKeyState.ACTIVE) {
            i = 1;
        }
        if (this.mMetaAltState == MetaKeyState.LOCKED || this.mMetaAltState == MetaKeyState.ACTIVE) {
            i |= 2;
        }
        return keyEvent.getUnicodeChar(i);
    }

    private boolean AllowOSToHandleKeys(int i) {
        switch (i) {
            case 24:
            case 25:
            case 26:
                return true;
            default:
                return false;
        }
    }

    public void HideSoftKeyboardOnWindowFocusChange() {
        this.mHideSoftKeyboardOnWindowFocusChange = true;
    }

    private boolean HandleShortCuts(int i, KeyEvent keyEvent) {
        if (i == 23) {
            if (this.mTrackBallPressed || this.mContextMenuVisible) {
                return true;
            }
            this.mTrackBallPressed = true;
            postCheckLongPress();
            return false;
        }
        if (!keyEvent.isAltPressed()) {
            return false;
        }
        switch (i) {
            case 19:
                nativeMoveCursor(2);
                return true;
            case 20:
                nativeMoveCursor(3);
                return true;
            case 21:
                nativeMoveCursor(0);
                return true;
            case 22:
                nativeMoveCursor(1);
                return true;
            case 67:
                nativeDeleteTextLine();
                return true;
            default:
                return false;
        }
    }

    public void setInputConnection(AndroidInputConnection androidInputConnection) {
        this.mInputConnection = androidInputConnection;
    }

    public void setFlashEGL(FlashEGL flashEGL) {
        this.mFlashEGL = flashEGL;
    }

    public boolean IsPasswordVisibleSettingEnabled() {
        try {
            return Settings.System.getInt(getContext().getContentResolver(), "show_password") == 1;
        } catch (Exception e) {
            return false;
        }
    }

    public boolean IsTouchUpHandlingAllowed() {
        return !this.mEatTouchRelease;
    }

    public void SetSelectionMode(boolean z) {
        nativeDispatchSelectionChangeEvent(z);
    }

    @Override
    public boolean onKeyPreIme(int i, KeyEvent keyEvent) {
        if (i == 4 && keyEvent.getAction() == 0) {
            DispatchSoftKeyboardEventOnBackKey();
            return false;
        }
        return false;
    }

    public void DispatchSoftKeyboardEventOnBackKey() {
        if ((this.mIsFullScreen && !this.mSurfaceChangedForSoftKeyboard) || this.mFlashEGL != null || IsIMEInFullScreen() || (!this.mSurfaceChangedForSoftKeyboard && !nativeIsEditable())) {
            nativeDispatchUserTriggeredSkDeactivateEvent();
            if (!this.mSurfaceChangedForSoftKeyboard && !nativeIsEditable()) {
                nativeShowOriginalRect();
            }
        }
    }

    public boolean IsSurfaceChangedForSoftKeyboard() {
        return this.mSurfaceChangedForSoftKeyboard;
    }

    public int getKeyboardHeight() {
        return this.mHt - getVisibleBoundHeight();
    }

    public void SetSurfaceChangedForSoftKeyboard(boolean z) {
        this.mSurfaceChangedForSoftKeyboard = z;
    }

    public VideoView getVideoView() {
        if (this.mVideoView == null) {
            this.mVideoView = new VideoViewAIR(getContext(), this.mActivityWrapper);
        }
        return this.mVideoView;
    }

    @Override
    public boolean gatherTransparentRegion(Region region) {
        int[] iArr = new int[2];
        getLocationInWindow(iArr);
        region.op(iArr[0], iArr[1], this.mVisibleBoundWidth, this.mVisibleBoundHeight, Region.Op.REPLACE);
        return false;
    }
}