CarrotChat v2.8.80.240429版本的 MD5 值为:fdf98761f01e715a89df24b85b0d206e

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


package com.kinggrid.iapppdf.ui.viewer;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.print.PrintAttributes;
import android.print.PrintManager;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.view.ViewCompat;
import com.kinggrid.commonrequestauthority.AppRegister;
import com.kinggrid.commonrequestauthority.c;
import com.kinggrid.iapppdf.common.bitmaps.ByteBufferBitmap;
import com.kinggrid.iapppdf.common.cache.CacheManager;
import com.kinggrid.iapppdf.common.settings.AppSettings;
import com.kinggrid.iapppdf.common.settings.SettingsManager;
import com.kinggrid.iapppdf.common.settings.books.BookSettings;
import com.kinggrid.iapppdf.common.settings.types.BookRotationType;
import com.kinggrid.iapppdf.common.settings.types.PageAlign;
import com.kinggrid.iapppdf.common.settings.types.ToastPosition;
import com.kinggrid.iapppdf.company.common.BitmapUtil;
import com.kinggrid.iapppdf.company.common.CommonMethodAndStringUtil;
import com.kinggrid.iapppdf.company.common.CrashHandler;
import com.kinggrid.iapppdf.company.common.KinggridConstant;
import com.kinggrid.iapppdf.company.common.PDFPageToBMP;
import com.kinggrid.iapppdf.company.cut.ImagePiece;
import com.kinggrid.iapppdf.company.cut.ImageSplitter;
import com.kinggrid.iapppdf.company.imagecontrol.KGBase64;
import com.kinggrid.iapppdf.company.imagecontrol.PDFEditManager;
import com.kinggrid.iapppdf.company.signature.DigSignCallBack;
import com.kinggrid.iapppdf.core.DecodeServiceBase;
import com.kinggrid.iapppdf.core.Page;
import com.kinggrid.iapppdf.core.ViewState;
import com.kinggrid.iapppdf.core.codec.OutlineLink;
import com.kinggrid.iapppdf.core.models.DocumentModel;
import com.kinggrid.iapppdf.droids.mupdf.codec.MuPdfDocument;
import com.kinggrid.iapppdf.droids.mupdf.codec.MuPdfPage;
import com.kinggrid.iapppdf.droids.mupdf.codec.PageText;
import com.kinggrid.iapppdf.droids.mupdf.codec.cosobject.PdfBoolean;
import com.kinggrid.iapppdf.emdev.ui.AbstractActionActivity;
import com.kinggrid.iapppdf.emdev.ui.gl.GLConfiguration;
import com.kinggrid.iapppdf.emdev.ui.uimanager.IUIManager;
import com.kinggrid.iapppdf.emdev.utils.LayoutUtils;
import com.kinggrid.iapppdf.emdev.utils.LengthUtils;
import com.kinggrid.iapppdf.ui.viewer.stubs.ViewStub;
import com.kinggrid.iapppdf.ui.viewer.viewers.GLView;
import com.kinggrid.iapppdf.ui.viewer.viewers.Mode;
import com.kinggrid.iapppdf.ui.viewer.viewers.SelectRectView;
import com.kinggrid.iapppdf.ui.viewer.views.AdjustableSizeEditText;
import com.kinggrid.iapppdf.ui.viewer.views.AreaView;
import com.kinggrid.iapppdf.ui.viewer.views.HorizontalScrollViewAdapter;
import com.kinggrid.iapppdf.ui.viewer.views.LocateSignatureView;
import com.kinggrid.iapppdf.ui.viewer.views.MyCombox;
import com.kinggrid.iapppdf.ui.viewer.views.MyHorizontalScrollView;
import com.kinggrid.iapppdf.ui.viewer.views.MyPrintDocumentAdapter;
import com.kinggrid.iapppdf.ui.viewer.views.MyRectView;
import com.kinggrid.iappsignature.PFXUtil;
import com.kinggrid.iappsignature.SignatureTask;
import com.kinggrid.pdfservice.Annotation;
import com.kinggrid.pdfservice.Attachment;
import com.kinggrid.pdfservice.KGSignature;
import com.kinggrid.pdfservice.PageViewMode;
import com.kinggrid.pdfservice.SignaturePosition;
import com.kinggrid.signature.commen.FileUtils;
import com.kinggrid.signatureserver.SignatureInfo;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.bouncycastle.cms.CMSAttributeTableGenerator;
import org.json.JSONException;
import org.json.JSONObject;

@SuppressLint({"NewApi"})
public class IAppPDFActivity extends AbstractActionActivity<IAppPDFActivity, ViewerActivityController> {
    public static String anyoffice_username = null;
    public static SparseArray<ByteBufferBitmap> cacheThumnails = null;
    public static int delVertorFlag = 0;
    public static float densityCoefficient = 0.0f;
    public static Map<Long, HashMap<Integer, RectF>> docBounds = null;
    public static Map<Long, HashMap<Integer, Long>> docHandles = null;
    public static Map<Long, HashMap<Integer, Integer>> docRatotes = null;

    static b f28120e = null;
    public static byte[] fileData = null;
    public static String fileName = null;

    private static final String f28121h = "IAppPDFActivity";
    public static int insertVertorFlag = 0;
    public static boolean loadPDFReaderCache = true;
    public static int offset;
    public static HashMap<Integer, RectF> pageBounds;
    public static HashMap<Integer, Long> pageHandles;
    public static HashMap<Integer, Integer> pageRatotes;
    public static BookRotationType rotation;
    public static String signature_server_url;
    private HorizontalScrollViewAdapter A;
    private int B;
    private int C;
    private boolean D;
    private long E;
    private SelectRectView F;
    private LongTouchAnnotState G;
    private ProgressDialog H;
    private AreaView I;
    private float[] J;
    private OnSignatureListener K;
    private OnScrollChangeListener L;
    private LocateSignatureView M;
    private ImageView N;
    private PopupWindow O;
    private LinearLayout P;
    private PopupWindow Q;
    private String R;
    private LinkedList<PageText> S;
    private float T;
    public ArrayList<Annotation> annotationsList;
    public boolean canLockScreen;
    public String copyRight;
    public long currAnnotation;

    a f28122d;
    public DelDifUserListener delDifUserListener;

    MyRectView f28123f;
    public String field;

    MyRectView f28124g;

    private Context f28125i;
    public int insertPageNo;
    public int insertPos;
    public ProgressBar insert_progress;
    public boolean isEbenT9;
    public boolean isLocked;
    public boolean isLongTouchSelectState;
    public boolean isShowAnnotInfo;
    public boolean isSupportEbenT7Mode;
    public boolean isUseEbenSDK;
    public boolean isVectorSign;

    private Toast f28126j;
    public String jsondata;

    private Toast f28127k;
    protected String keySN;

    private PDFHandWriteView f28128l;

    private RelativeLayout f28129m;
    public Mode mode;
    public int msgLoadingStringId;
    public OnMuPdfExceptionListener mupdfExceptionListener;

    private Button f28130n;

    private LayoutInflater f28131o;
    public String offLineAuthUrl;
    public OnLocalSignatureListener onLocalSignatureListener;
    public LongTouchAnnotListener onLongTouchAnnotListener;
    public OnPageLongPressListener onPageLongPressListener;
    public SelectStateListener onSelectStateListener;

    private AdjustableSizeEditText f28132p;
    public PDFEditManager pdfEditManager;
    public int perforation_max_size;
    public String photo;

    private MyCombox f28133q;

    private String f28134r;
    public MyRectView rectView;

    private String f28135s;
    public String savePath;
    public float screenHeight;
    public float screenWidth;
    public String signatureField1;
    public String signatureField2;
    public int soundAnnotStyle;
    public OnSynchronizationOptionListener synchronizationOptionListener;

    private ViewGroup f28136t;
    public MyHorizontalScrollView thumnailView;
    public SparseArray<ByteBufferBitmap> thumnails;
    public OnTouchKGSignatureListener touchKGSignatureListener;
    public TouchReadOnlyListener touchReadOnlyListener;

    private OnPageChangeListener f28137u;

    private boolean f28138v;
    public OnVerifyKGSignatureCompleteListener verifyKGSignatureCompleteListener;
    public IView view;
    public OnViewTouchAddAnnotListener viewTouchAddAnnotListener;
    public OnViewTouchShowAnnotListener viewTouchShowAnnotListener;

    private RelativeLayout f28139w;

    private Resources f28140x;

    private String f28141y;

    private boolean f28142z;
    public boolean zoomEnable;
    public static final DisplayMetrics DM = new DisplayMetrics();
    public static PageViewMode pageViewMode = PageViewMode.VSCROLL;
    public static String userName = "admin";
    public static String companyName = "";
    public static String licType = "";
    public static String licTime = "";
    public static String signaturePath = String.valueOf(KinggridConstant.FILEDIR_PATH) + "/tempsignatures/";
    public static float actWidth = 0.0f;
    public static float actHeight = 0.0f;
    public static int rotate = 0;
    public static float imagezoom = 0.0f;
    public static boolean isSound = false;
    public static boolean isFinger = false;
    public static boolean isAnnotation = false;
    public static boolean insertAnnot = false;
    public static boolean isFieldEdit = false;
    public static boolean isSignEdit = true;
    public static boolean isSaveVector = true;
    public static int progressBarStatus = 0;
    public static CrashHandler crashHandler = null;
    public static boolean touchEnable = true;
    public static boolean isCyclePage = true;
    public static boolean isSvnFile = false;
    public static int goToPageDirection = 0;
    public static String[] fonts = null;
    public static int imageQuality = 100;

    public class ClearVectorThread implements Runnable {

        private float f28260b;

        private float f28261c;

        private float f28262d;

        private float f28263e;

        public ClearVectorThread(float f10, float f11, float f12, float f13) {
            this.f28260b = f10;
            this.f28261c = f11;
            this.f28262d = f12;
            this.f28263e = f13;
        }

        @Override
        public void run() {
            float[] insertXYForSinglePage;
            float[] insertXYForSinglePage2;
            synchronized (this) {
                long[] annotHandleListByRect = IAppPDFActivity.this.getAnnotHandleListByRect(this.f28260b, this.f28261c, this.f28262d, this.f28263e);
                Log.d("Kevin", "del_list currAnnotation : ");
                if (IAppPDFActivity.this.f28128l != null) {
                    IAppPDFActivity.this.f28128l.lockView();
                }
                int i10 = 0;
                for (int i11 = 0; i11 < annotHandleListByRect.length; i11++) {
                    long j10 = annotHandleListByRect[i11];
                    if (j10 != -1) {
                        IAppPDFActivity.delVertorFlag = 1;
                        if (IAppPDFActivity.this.pdfEditManager.getAnnotAuthor(j10).equals(IAppPDFActivity.userName)) {
                            String annotVerctorData = IAppPDFActivity.this.pdfEditManager.getAnnotVerctorData(annotHandleListByRect[i11]);
                            if (!TextUtils.isEmpty(annotVerctorData)) {
                                float[] annotRect = IAppPDFActivity.this.pdfEditManager.getAnnotRect(annotHandleListByRect[i11]);
                                Log.d("Kevin", "del_list currAnnotation : " + annotHandleListByRect[i11]);
                                if (!TextUtils.isEmpty(annotVerctorData)) {
                                    Log.d("Kevin", "del_list vector_data : " + annotVerctorData.length());
                                    if (!IAppPDFActivity.this.getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
                                        insertXYForSinglePage = IAppPDFActivity.this.getInsertXY(this.f28262d, this.f28261c, true, 0);
                                        insertXYForSinglePage2 = IAppPDFActivity.this.getInsertXY(this.f28263e, this.f28260b, true, 0);
                                    } else {
                                        insertXYForSinglePage = IAppPDFActivity.this.getInsertXYForSinglePage(this.f28262d, this.f28261c, true, 0);
                                        insertXYForSinglePage2 = IAppPDFActivity.this.getInsertXYForSinglePage(this.f28263e, this.f28260b, true, 0);
                                    }
                                    IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                                    float f10 = insertXYForSinglePage[0];
                                    float f11 = annotRect[0];
                                    float f12 = annotRect[3];
                                    String cutVertorInfo = iAppPDFActivity.cutVertorInfo(annotVerctorData, f10 - f11, f12 - insertXYForSinglePage[1], insertXYForSinglePage2[0] - f11, f12 - insertXYForSinglePage2[1]);
                                    if (!TextUtils.isEmpty(cutVertorInfo)) {
                                        if (IAppPDFActivity.progressBarStatus == 0) {
                                            IAppPDFActivity iAppPDFActivity2 = IAppPDFActivity.this;
                                            iAppPDFActivity2.pdfEditManager.updateVector("", cutVertorInfo, iAppPDFActivity2.insertPageNo, annotHandleListByRect[i11]);
                                        }
                                    } else {
                                        IAppPDFActivity.this.pdfEditManager.deleteOneSignature(annotHandleListByRect[i11]);
                                    }
                                }
                            } else {
                                IAppPDFActivity.this.pdfEditManager.deleteOneSignature(annotHandleListByRect[i11]);
                            }
                            i10++;
                        }
                    }
                }
                if (i10 != 0) {
                    Message message = new Message();
                    Bundle bundle = new Bundle();
                    bundle.putInt("pageNo", IAppPDFActivity.this.insertPageNo);
                    message.setData(bundle);
                    message.obj = IAppPDFActivity.this.f28128l;
                    message.what = KinggridConstant.VERTORDATA_CUT_FINISHED;
                    IAppPDFActivity.this.f28122d.sendMessage(message);
                } else if (annotHandleListByRect.length != 0) {
                    Message message2 = new Message();
                    message2.what = 2004;
                    message2.obj = IAppPDFActivity.this.f28128l;
                    IAppPDFActivity.this.f28122d.sendMessage(message2);
                }
            }
        }
    }

    public interface DelDifUserListener {
        void onDel();
    }

    public interface LongTouchAnnotListener {
        void onTouchBack(float f10, float f11);
    }

    public enum LongTouchAnnotState {
        NONE,
        DELETE,
        SELECTTEXT;

        public static LongTouchAnnotState[] valuesCustom() {
            LongTouchAnnotState[] valuesCustom = values();
            int length = valuesCustom.length;
            LongTouchAnnotState[] longTouchAnnotStateArr = new LongTouchAnnotState[length];
            System.arraycopy(valuesCustom, 0, longTouchAnnotStateArr, 0, length);
            return longTouchAnnotStateArr;
        }
    }

    public interface OnLocalSignatureListener {
        void onLocalSingatureFinish(String str, float f10, float f11, float f12, float f13, int i10);
    }

    public interface OnMuPdfExceptionListener {
        void onMuPdfFileDamageException();

        void onMuPdfFileFormatException();

        void onMuPdfPasswordException();
    }

    public interface OnPageChangeListener {
        void onPageChange(String str);
    }

    public interface OnPageLongPressListener {
        boolean onPageLongPress(float f10, float f11);
    }

    public interface OnScrollChangeListener {
        void onScrollToDocBottom();

        void onScrollToDocTop();
    }

    public interface OnSignatureListener {
        void onClickDelBtn(String str, long j10);

        void onDelete(boolean z10, int i10);
    }

    public interface OnSynchronizationOptionListener {
        void onDeleteAnnot(String str);

        void onFling(float f10, float f11, Rect rect);

        void onInsertHandwriteAnnot(int i10, String str, float f10, float f11, float f12, float f13, String str2, String str3, String str4, String str5);

        void onInsertTextAnnot(int i10, String str, float f10, float f11, String str2, String str3, String str4);

        void onInsertVectorAnnot(int i10, String str, float f10, float f11, float f12, float f13, String str2, String str3, String str4, boolean z10);

        void onScroll(int i10, int i11);

        void onScrollFinished(int i10, int i11, boolean z10);

        void onUpdataTextAnnotRect(String str, int i10, float f10, float f11);

        void onUpdateHandwriteAnnot(String str, int i10, float f10, float f11);

        void onUpdateTextAnnotContent(String str, String str2);
    }

    public interface OnTouchKGSignatureListener {
        void onTouchKGSignature(int i10, long j10);
    }

    public interface OnVerifyKGSignatureCompleteListener {
        void onResult(boolean z10, Map<String, String> map);
    }

    public interface OnViewTouchAddAnnotListener {
        void onTouch(float f10, float f11);
    }

    public interface OnViewTouchShowAnnotListener {
        void onTouchSoundAnnot(Annotation annotation);

        void onTouchTextAnnot(Annotation annotation);
    }

    public interface SelectStateListener {
        void onSelectState(boolean z10);
    }

    public class SignPosition {
        public int height;
        public int pageno;
        public float[] rect;

        public SignPosition() {
        }
    }

    public interface TouchReadOnlyListener {
        void onTouchBack();
    }

    public static class a extends Handler {

        WeakReference<IAppPDFActivity> f28266a;

        a(IAppPDFActivity iAppPDFActivity) {
            this.f28266a = new WeakReference<>(iAppPDFActivity);
        }

        @Override
        public void handleMessage(Message message) {
            boolean z10;
            IAppPDFActivity iAppPDFActivity = this.f28266a.get();
            int i10 = message.what;
            if (i10 != 2001) {
                if (i10 != 2004) {
                    if (i10 != 2101) {
                        if (i10 == 2102) {
                            iAppPDFActivity.f();
                            IAppPDFActivity.insertVertorFlag = 0;
                            iAppPDFActivity.showToastText(0, "插入手写批注失败!");
                            return;
                        }
                        switch (i10) {
                            case 43:
                                Uri fromFile = Uri.fromFile(new File((String) message.obj));
                                iAppPDFActivity.getController().afterCreate(iAppPDFActivity, fromFile);
                                iAppPDFActivity.getController().startDecoding("");
                                iAppPDFActivity.setIntent(new Intent("android.intent.action.VIEW", fromFile));
                                return;
                            case 44:
                                iAppPDFActivity.refreshDocument();
                                return;
                            case 45:
                                iAppPDFActivity.f();
                                iAppPDFActivity.saveDocument();
                                iAppPDFActivity.sendBroadcast(new Intent(KinggridConstant.BROADCAST_SAVESIGNFINISH));
                                return;
                            case 46:
                                iAppPDFActivity.h();
                                return;
                            case 47:
                                iAppPDFActivity.showToastText(0, "当前版本为只读版本...");
                                return;
                            case 48:
                                int i11 = message.arg1;
                                iAppPDFActivity.A = new HorizontalScrollViewAdapter(iAppPDFActivity.f28125i, iAppPDFActivity.thumnails);
                                iAppPDFActivity.A.setTextSize(i11);
                                iAppPDFActivity.thumnailView.hideProgressView();
                                iAppPDFActivity.thumnailView.initData(iAppPDFActivity.A);
                                return;
                            default:
                                return;
                        }
                    }
                    PDFHandWriteView pDFHandWriteView = (PDFHandWriteView) message.obj;
                    pDFHandWriteView.unLockView();
                    pDFHandWriteView.doClearHandwriteInfo();
                    iAppPDFActivity.isLocked = false;
                    if (!iAppPDFActivity.isSupportEbenT7Mode) {
                        iAppPDFActivity.unLockScreen();
                    }
                    int i12 = message.getData().getInt("pageNo");
                    boolean z11 = message.getData().getBoolean("isRefresh");
                    if (IAppPDFActivity.pageViewMode == PageViewMode.SINGLEH && IAppPDFActivity.goToPageDirection != 0) {
                        z10 = true;
                    } else {
                        z10 = false;
                    }
                    if (z11 && !z10) {
                        if (iAppPDFActivity.pdfEditManager == null) {
                            iAppPDFActivity.pdfEditManager = new PDFEditManager(iAppPDFActivity.getIntent(), iAppPDFActivity, iAppPDFActivity.getController());
                        }
                        iAppPDFActivity.pdfEditManager.refreshPage(i12);
                    }
                    iAppPDFActivity.f();
                    if (z10) {
                        iAppPDFActivity.getController().jumpToPage(iAppPDFActivity.getCurrentPageNo() + IAppPDFActivity.goToPageDirection, 0.0f, 0.0f, false);
                        IAppPDFActivity.goToPageDirection = 0;
                        return;
                    }
                    return;
                }
                Object obj = message.obj;
                if (obj != null) {
                    ((PDFHandWriteView) obj).unLockView();
                }
                IAppPDFActivity.delVertorFlag = 0;
                iAppPDFActivity.f();
                DelDifUserListener delDifUserListener = iAppPDFActivity.delDifUserListener;
                if (delDifUserListener != null) {
                    delDifUserListener.onDel();
                    return;
                } else {
                    Toast.makeText(iAppPDFActivity.f28125i, "你无权编辑其他用户添加的批注信息!", 0).show();
                    return;
                }
            }
            Object obj2 = message.obj;
            if (obj2 != null) {
                ((PDFHandWriteView) obj2).unLockView();
            }
            new PDFEditManager(iAppPDFActivity.getIntent(), iAppPDFActivity, iAppPDFActivity.getController()).refreshPage(message.getData().getInt("pageNo"));
            IAppPDFActivity.delVertorFlag = 0;
            iAppPDFActivity.f();
        }
    }

    class b extends Handler {
        b() {
        }

        @Override
        public void handleMessage(Message message) {
            super.handleMessage(message);
            int i10 = message.what;
            if (i10 != 40) {
                if (i10 == 41) {
                    CommonMethodAndStringUtil.replace(IAppPDFActivity.this.savePath, message.getData().getString("sign"), IAppPDFActivity.offset);
                    return;
                }
                return;
            }
            byte[] byteArray = message.getData().getByteArray("cert");
            IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
            if (iAppPDFActivity.pdfEditManager == null) {
                Intent intent = IAppPDFActivity.this.getIntent();
                IAppPDFActivity iAppPDFActivity2 = IAppPDFActivity.this;
                iAppPDFActivity.pdfEditManager = new PDFEditManager(intent, iAppPDFActivity2, iAppPDFActivity2.getController());
            }
            IAppPDFActivity.this.savePath = "mnt/sdcard/test" + System.currentTimeMillis() + ".pdf";
            IAppPDFActivity iAppPDFActivity3 = IAppPDFActivity.this;
            PDFEditManager pDFEditManager = iAppPDFActivity3.pdfEditManager;
            String str = iAppPDFActivity3.f28135s;
            IAppPDFActivity iAppPDFActivity4 = IAppPDFActivity.this;
            pDFEditManager.insertSignature(str, iAppPDFActivity4.field, iAppPDFActivity4.savePath, "123456", byteArray, 2, iAppPDFActivity4.keySN);
            IAppPDFActivity.this.pdfEditManager.refreshDocument();
        }
    }

    public IAppPDFActivity() {
        super(false, 4, 64, 256, 1024, 4096);
        this.copyRight = "";
        this.isVectorSign = false;
        this.signatureField1 = "Signature1";
        this.signatureField2 = "Signature2";
        this.photo = "photo";
        this.isLocked = false;
        this.canLockScreen = false;
        this.f28134r = "";
        this.f28122d = new a(this);
        this.field = this.signatureField2;
        this.isSupportEbenT7Mode = false;
        this.isEbenT9 = false;
        this.isUseEbenSDK = false;
        this.f28137u = null;
        this.f28138v = false;
        this.soundAnnotStyle = 0;
        this.insertPos = -100;
        this.f28142z = false;
        this.zoomEnable = true;
        this.offLineAuthUrl = "";
        this.mode = Mode.Viewing;
        this.perforation_max_size = 5;
        this.G = LongTouchAnnotState.DELETE;
        this.isLongTouchSelectState = false;
        this.f28123f = null;
        this.f28124g = null;
        this.J = null;
        this.T = 1.0f;
    }

    private void d() {
        if (!this.isSupportEbenT7Mode || this.isUseEbenSDK) {
            return;
        }
        PDFHandWriteView pDFHandWriteView = new PDFHandWriteView(this);
        this.f28128l = pDFHandWriteView;
        pDFHandWriteView.setCopyRight(this, this.copyRight);
        PDFHandWriteView pDFHandWriteView2 = this.f28128l;
        pDFHandWriteView2.setPenColor(pDFHandWriteView2.getPenColor());
        PDFHandWriteView pDFHandWriteView3 = this.f28128l;
        pDFHandWriteView3.setPenSize(pDFHandWriteView3.getPenWidth());
        PDFHandWriteView pDFHandWriteView4 = this.f28128l;
        pDFHandWriteView4.setPenType(pDFHandWriteView4.getPenType());
        this.f28128l.setSupportEbenT7Mode(true);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        layoutParams.leftMargin = (int) (DM.density * (-1.0f));
        this.f28136t.addView(this.f28128l, layoutParams);
    }

    public static int getPDFSignatureLength() {
        return SignatureTask.getInstance().getLength();
    }

    public static int getPDFSignatureLengthMix() {
        return 4096;
    }

    public void h() {
        ProgressDialog progressDialog = this.H;
        if (progressDialog != null) {
            progressDialog.dismiss();
        }
    }

    private synchronized String m() {
        StringBuffer stringBuffer = new StringBuffer("");
        long[] fieldsIndocument = MuPdfDocument.getFieldsIndocument(((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getDocumentHandle());
        for (int i10 = 0; i10 < fieldsIndocument.length; i10++) {
            float[] fieldRect = MuPdfDocument.getFieldRect(fieldsIndocument[i10]);
            stringBuffer.append(String.valueOf(fieldRect[0] + fieldRect[1] + fieldRect[2] + fieldRect[3]) + MuPdfDocument.getFieldContent(fieldsIndocument[i10]));
            MuPdfDocument.getFieldType(fieldsIndocument[i10]);
        }
        if (stringBuffer.toString().equals("")) {
            return stringBuffer.toString();
        }
        return CommonMethodAndStringUtil.MD5EncodeUtil.md5String(stringBuffer.toString());
    }

    public static byte[] pdfSignature(byte[] bArr) {
        return SignatureTask.getInstance().sign(bArr);
    }

    protected static void sendDataToServer(String str) {
    }

    public static void setPDFSignatureRangeMix(int i10, byte[] bArr) {
        offset = i10;
        byte[] a10 = a(bArr, bArr.length);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("id", "bde");
            jSONObject.put(CMSAttributeTableGenerator.DIGEST, b(a10, a10.length));
            sendDataToServer(jSONObject.toString());
        } catch (JSONException e10) {
            e10.printStackTrace();
        }
    }

    public void addAttachment(byte[] bArr, String str) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.addAttachment(bArr, str);
    }

    public void addBlankPage(int i10) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.addBlankPage(i10);
    }

    public void cancelSelect(boolean z10, boolean z11) {
        if (z11 && !this.S.isEmpty()) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            this.pdfEditManager.insertQuadpoints(this.insertPageNo, userName, this.S);
        }
        if (z10) {
            if (!this.S.isEmpty() && !z11) {
                getController().getDocumentModel().getPageByDocIndex(this.insertPageNo).setSelectPageText(this.S);
            }
            refreshPage(this.insertPageNo);
        }
        this.mode = Mode.Viewing;
        this.F.reset();
        this.F.setVisibility(8);
    }

    public void clearCacheInfo() {
        CacheManager.clear();
    }

    public void clearDocumentInfo() {
        pageBounds.clear();
        docBounds.clear();
    }

    public void clearPDFReadSettings() {
        SettingsManager.deleteAllBookSettings();
    }

    public void closeAreaHandwrite() {
        AreaView areaView = this.I;
        if (areaView == null) {
            return;
        }
        this.f28136t.removeView(areaView);
    }

    public void closeDocument() {
        long documentHandle = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getDocumentHandle();
        Iterator<Long> it = pageHandles.values().iterator();
        while (it.hasNext()) {
            MuPdfPage.free(documentHandle, it.next().longValue());
        }
        pageHandles.clear();
    }

    public void currentPageChanged(String str, String str2) {
        if (LengthUtils.isEmpty(str)) {
            return;
        }
        AppSettings current = AppSettings.current();
        if (!this.isEbenT9) {
            if (current.isPageInTitle()) {
                OnPageChangeListener onPageChangeListener = this.f28137u;
                if (onPageChangeListener != null) {
                    onPageChangeListener.onPageChange(str.substring(0, str.indexOf(CookieSpec.PATH_DELIM)));
                }
                if (IUIManager.instance.isTitleVisible(this)) {
                    getWindow().setTitle("(" + str + ") " + str2);
                    return;
                }
                return;
            }
            if (current.getPageNumberToastPosition() == ToastPosition.Invisible) {
                return;
            }
            Toast toast = this.f28126j;
            if (toast != null) {
                toast.setText(str);
            } else {
                this.f28126j = Toast.makeText(this, str, 0);
            }
            this.f28126j.setGravity(current.getPageNumberToastPosition().position, 0, 0);
            this.f28126j.show();
        }
    }

    public String cutVertorInfo(String str, float f10, float f11, float f12, float f13) {
        int i10;
        String[] split = str.split("Q \n");
        char c10 = 0;
        String str2 = "";
        int i11 = 0;
        while (i11 < split.length) {
            String[] split2 = split[i11].split("\n");
            int i12 = 0;
            while (true) {
                if (i12 >= split2.length) {
                    i10 = i11;
                    break;
                }
                String str3 = split2[i12];
                System.out.println("每行数据:" + str3);
                if (str3 != null && !"".equals(str3) && str3.indexOf(" m") > 0) {
                    double parseDouble = Double.parseDouble(str3.split(" ")[c10]);
                    double parseDouble2 = Double.parseDouble(str3.split(" ")[1]);
                    double d10 = f10;
                    i10 = i11;
                    if (d10 >= parseDouble) {
                        if (parseDouble >= f12 && f11 >= parseDouble2 && parseDouble2 >= f13) {
                            break;
                        }
                    }
                    if (d10 <= parseDouble) {
                        if (parseDouble <= f12 && f11 <= parseDouble2 && parseDouble2 <= f13) {
                            break;
                        }
                    }
                    if (d10 >= parseDouble) {
                        if (parseDouble >= f12 && f11 <= parseDouble2 && parseDouble2 <= f13) {
                            break;
                        }
                    }
                    if (d10 <= parseDouble && parseDouble <= f12 && f11 >= parseDouble2 && parseDouble2 >= f13) {
                        break;
                    }
                } else {
                    i10 = i11;
                }
                if (i12 == split2.length - 1) {
                    str2 = String.valueOf(str2) + split[i10] + "Q \n";
                }
                i12++;
                i11 = i10;
                c10 = 0;
            }
            i11 = i10 + 1;
            c10 = 0;
        }
        return str2;
    }

    public void deleteAllAnnotations(int i10) {
        a(i10, -1);
    }

    public void deleteAnnotInField(String str) {
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        for (int i10 = 0; i10 < pageCount; i10++) {
            long pageHandle = pDFEditManager.getPageHandle(i10);
            for (long j10 : MuPdfDocument.getAnnotSignatures(pageHandle, str)) {
                float[] annotRect = pDFEditManager.getAnnotRect(j10);
                long annoByRect = MuPdfDocument.getAnnoByRect(pageHandle, annotRect[1], annotRect[3], annotRect[0], annotRect[2]);
                if (annoByRect != -1) {
                    pDFEditManager.deleteOneSignature(annoByRect);
                }
            }
        }
    }

    public void deleteAnnotWithId(String str) {
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        for (int i10 = 0; i10 < pageCount; i10++) {
            long[] allAnnotations = MuPdfDocument.getAllAnnotations(pDFEditManager.getPageHandle(i10));
            for (int i11 = 0; i11 < allAnnotations.length; i11++) {
                if (str.equals(pDFEditManager.getAnnotId(allAnnotations[i11]))) {
                    pDFEditManager.deleteOneSignature(allAnnotations[i11]);
                }
            }
        }
    }

    public void deleteAnnotationInPage(int i10, int i11) {
        a(i10, i11);
    }

    public void deleteAttachment(int i10) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.deleteAttachment(i10);
    }

    protected void deletePhotos(File[] fileArr) {
        if (fileArr != null && fileArr.length > 0) {
            for (File file : fileArr) {
                file.delete();
            }
        }
    }

    public void deleteSignature(long j10) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (this.pdfEditManager.isLastSignature(MuPdfDocument.getSignature(j10))) {
            int deleteSignature = this.pdfEditManager.deleteSignature(j10);
            OnSignatureListener onSignatureListener = this.K;
            if (onSignatureListener != null) {
                if (deleteSignature == 0) {
                    onSignatureListener.onDelete(true, 0);
                    return;
                } else {
                    if (deleteSignature == -1) {
                        onSignatureListener.onDelete(false, -1);
                        return;
                    }
                    return;
                }
            }
            return;
        }
        OnSignatureListener onSignatureListener2 = this.K;
        if (onSignatureListener2 != null) {
            onSignatureListener2.onDelete(false, 1);
        }
    }

    public void doAddAnnotationRectOrSignEditView(float f10, float f11) {
        String str;
        long j10 = this.currAnnotation;
        if (j10 != -1) {
            if ((MuPdfDocument.getAnnotFlag(j10) & 128) == 128) {
                TouchReadOnlyListener touchReadOnlyListener = this.touchReadOnlyListener;
                if (touchReadOnlyListener != null) {
                    touchReadOnlyListener.onTouchBack();
                    return;
                } else {
                    Toast.makeText(this.f28125i, "该对象为只读状态,无法移动或删除!", 0).show();
                    return;
                }
            }
            String annotSubType = this.pdfEditManager.getAnnotSubType(this.currAnnotation);
            String annotAuthor = this.pdfEditManager.getAnnotAuthor(this.currAnnotation);
            String annotInfo = this.pdfEditManager.getAnnotInfo(this.currAnnotation);
            if (!TextUtils.isEmpty(annotInfo)) {
                str = this.pdfEditManager.parseAnnotInfo2String(annotInfo)[1];
            } else {
                str = "";
            }
            Log.d("tbz", "author_Name1 = " + str);
            if (!annotAuthor.equals(userName) && !str.equals(userName)) {
                DelDifUserListener delDifUserListener = this.delDifUserListener;
                if (delDifUserListener != null) {
                    delDifUserListener.onDel();
                    return;
                } else {
                    Toast.makeText(this.f28125i, "你无权编辑其他用户添加的批注信息!", 0).show();
                    return;
                }
            }
            float[] annotRect = this.pdfEditManager.getAnnotRect(this.currAnnotation);
            if (!annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT) && !annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SOUND)) {
                a(this.pdfEditManager, this.insertPageNo, annotRect, !annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_HIGHLIGHT));
            } else if (!this.isEbenT9) {
                a(this.pdfEditManager, this.insertPageNo, annotRect);
            }
        }
    }

    public boolean doAddSignatureRect(float f10, float f11) {
        float[] insertXYForSinglePage;
        String str;
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            insertXYForSinglePage = getInsertXY(f10, f11, true, 0);
        } else {
            insertXYForSinglePage = getInsertXYForSinglePage(f10, f11, true, 0);
        }
        float f12 = insertXYForSinglePage[0];
        if (f12 == -1.0f) {
            return false;
        }
        PDFEditManager pDFEditManager = this.pdfEditManager;
        int i10 = this.insertPageNo;
        long[] signatureInRect = pDFEditManager.getSignatureInRect(i10, f12, pDFEditManager.getPageBounds(i10).height() - insertXYForSinglePage[1]);
        Log.d("tbz", "signaturhandle = " + signatureInRect[1]);
        if (signatureInRect[1] == -1) {
            return false;
        }
        long annotInField = this.pdfEditManager.getAnnotInField(signatureInRect[0], this.insertPageNo);
        String annotInfo = this.pdfEditManager.getAnnotInfo(annotInField);
        String str2 = null;
        if (!TextUtils.isEmpty(annotInfo)) {
            str2 = this.pdfEditManager.parseAnnotInfo2String(annotInfo)[3];
        }
        Log.d("tbz", "key_sn = " + str2);
        if (TextUtils.isEmpty(str2)) {
            KGBase64 kGBase64 = new KGBase64();
            kGBase64.setBase64Table(c.f27372a);
            str = new String(kGBase64.decode(this.pdfEditManager.getAnnotContactInfo(annotInField)));
        } else {
            str = "";
        }
        Log.d("tbz", "contact_info = " + str);
        String str3 = this.keySN;
        if (str3 != null && (str3.equals(str2) || str.contains(this.keySN))) {
            a(this.pdfEditManager, this.insertPageNo, this.pdfEditManager.getAnnotRect(annotInField), false);
            this.D = true;
            this.E = signatureInRect[0];
        } else {
            Toast.makeText(this.f28125i, "你无权编辑其他用户添加的批注信息!", 0).show();
        }
        return true;
    }

    public void doAddTextToPDFAndRemoveView() {
        AdjustableSizeEditText adjustableSizeEditText = this.f28132p;
        if (adjustableSizeEditText != null && adjustableSizeEditText.getVisibility() == 0) {
            String obj = this.f28132p.getText().toString();
            if (!obj.equals(this.f28134r)) {
                new PDFEditManager(getIntent(), this, getController()).setFieldEditContent(((Long) this.f28132p.getTag()).longValue(), obj, this.insertPageNo);
            }
            this.f28136t.removeView(this.f28132p);
        }
        MyCombox myCombox = this.f28133q;
        if (myCombox != null && myCombox.getVisibility() == 0) {
            this.f28136t.removeView(this.f28133q);
        }
    }

    public void doCloseHandwriteInfo(View view, PDFHandWriteView pDFHandWriteView) {
        this.isLocked = false;
        unLockScreen();
        if (pDFHandWriteView != null) {
            pDFHandWriteView.doClearHandwriteInfo();
        }
        if (!this.isSupportEbenT7Mode) {
            this.f28136t.removeView(view);
        }
    }

    public void doCloseSoundAnnot(String str) {
        if (!str.equals("")) {
            File file = new File(str);
            if (file.exists()) {
                file.delete();
            }
        }
    }

    public void doDeletePostilByErase(float f10, float f11, float f12, float f13) {
        ClearVectorThread clearVectorThread = new ClearVectorThread(f10, f11, f12, f13);
        showVectorDialog();
        new Thread(clearVectorThread).start();
    }

    public void doDeleteSoundAnnot(Annotation annotation, String str) {
        if (annotation != null) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            long annotHandle = this.pdfEditManager.getAnnotHandle(Integer.parseInt(annotation.getPageNo()), Float.parseFloat(annotation.getX()), Float.parseFloat(annotation.getY()));
            if (this.pdfEditManager.existFieldInDocument(annotHandle)) {
                this.pdfEditManager.deleteOneSignature(annotHandle);
                this.pdfEditManager.refreshPage(getCurrentPageNo());
                if (!TextUtils.isEmpty(str)) {
                    File file = new File(str);
                    if (file.exists()) {
                        file.delete();
                    }
                }
            }
        }
    }

    public void doDeleteTextAnnotation(Annotation annotation) {
        if (annotation != null) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            long annotHandle = this.pdfEditManager.getAnnotHandle(Integer.parseInt(annotation.getPageNo()), Float.parseFloat(annotation.getX()), Float.parseFloat(annotation.getY()));
            if (this.pdfEditManager.existFieldInDocument(annotHandle)) {
                this.pdfEditManager.deleteOneSignature(annotHandle);
                this.pdfEditManager.refreshPage(getCurrentPageNo());
            }
        }
    }

    public boolean doFormField(float f10, float f11) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        lockScreen();
        int height = ((MuPdfPage) ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPage(this.insertPageNo)).getHeight();
        long fieldInRect = pDFEditManager.getFieldInRect(this.insertPageNo, f10, height - f11);
        if (fieldInRect != -1) {
            a(pDFEditManager, height, pDFEditManager.getFieldRect(fieldInRect), fieldInRect);
            return true;
        }
        return false;
    }

    public void doSaveBDESign(PDFHandWriteView pDFHandWriteView) {
        if (!pDFHandWriteView.isEmpty() && FileUtils.savePdfWriteImage(pDFHandWriteView, FileUtils.getPdfWriteImagePath())) {
            this.f28135s = FileUtils.getPdfWriteImagePath();
            getCertificate();
        }
    }

    public void doSaveDigSignByField(final String str, final String str2, final String str3, final Bitmap bitmap, final DigSignCallBack digSignCallBack) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (this.pdfEditManager.existFieldInDocument(this.pdfEditManager.hasFieldInDocument(str3))) {
            g();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    IAppPDFActivity.this.lockScreen();
                    SignatureTask.getInstance().setMode(SignatureTask.SignMode.SOF);
                    PFXUtil.getInstance(IAppPDFActivity.this.f28125i).setPFXInfo(str, str2);
                    if (SignatureTask.getInstance().sign("123".getBytes()) != null) {
                        String path = IAppPDFActivity.this.getIntent().getData().getPath();
                        Message message = new Message();
                        message.what = 44;
                        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
                        if (FileUtils.saveImage(bitmap, pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null)) {
                            IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                            iAppPDFActivity.pdfEditManager.insertSignature(pdfWriteImagePath, str3, path, "123456", null, 1, iAppPDFActivity.keySN);
                            digSignCallBack.onFinish(true, null);
                            IAppPDFActivity.this.f28122d.sendMessage(message);
                        } else {
                            digSignCallBack.onFinish(false, "盖章图片保存失败");
                        }
                    } else {
                        digSignCallBack.onFinish(false, "签名失败");
                    }
                    IAppPDFActivity.this.f28122d.sendEmptyMessage(46);
                    IAppPDFActivity.this.unLockScreen();
                }
            }).start();
        } else {
            digSignCallBack.onFinish(false, "该文档没有签名域");
        }
    }

    public void doSaveDigSignByPos(final String str, final String str2, final String str3, final int i10, final float f10, final float f11, final float f12, final float f13, final DigSignCallBack digSignCallBack) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        g();
        new Thread(new Runnable() {
            @Override
            public void run() {
                IAppPDFActivity.this.lockScreen();
                SignatureTask.getInstance().setMode(SignatureTask.SignMode.SOF);
                PFXUtil.getInstance(IAppPDFActivity.this.f28125i).setPFXInfo(str, str2);
                if (SignatureTask.getInstance().sign("123".getBytes()) != null) {
                    Message message = new Message();
                    message.what = 44;
                    IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                    iAppPDFActivity.pdfEditManager.insertSignatureSM2(str3, i10, f10, f11, f12, f13, iAppPDFActivity.getIntent().getData().getPath(), "123456", null, 1, "", IAppPDFActivity.this.keySN);
                    digSignCallBack.onFinish(true, null);
                    IAppPDFActivity.this.f28122d.sendMessage(message);
                } else {
                    digSignCallBack.onFinish(false, "签名失败");
                }
                IAppPDFActivity.this.f28122d.sendEmptyMessage(46);
                IAppPDFActivity.this.unLockScreen();
            }
        }).start();
    }

    public void doSaveDigitallySign(final String str, final String str2, final String str3, final String str4) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (this.pdfEditManager.existFieldInDocument(this.pdfEditManager.hasFieldInDocument(str2)) && new File(str).exists()) {
            g();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    IAppPDFActivity.this.lockScreen();
                    SignatureTask.getInstance().setDebug(true);
                    SignatureTask.getInstance().setMode(SignatureTask.SignMode.BLE);
                    if (SignatureTask.getInstance().getLMSignData("test".getBytes(), str3, str4) != null) {
                        String path = IAppPDFActivity.this.getIntent().getData().getPath();
                        Message message = new Message();
                        message.what = 44;
                        IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                        iAppPDFActivity.pdfEditManager.insertSignature(str, str2, path, "123456", null, 1, iAppPDFActivity.keySN);
                        IAppPDFActivity.this.f28122d.sendMessage(message);
                    } else {
                        Log.e(IAppPDFActivity.f28121h, "getP7SignatureDataByKey is null");
                    }
                    IAppPDFActivity.this.f28122d.sendEmptyMessage(46);
                    IAppPDFActivity.this.unLockScreen();
                }
            }).start();
        }
    }

    public void doSaveHandwriteInfo(boolean z10, boolean z11, PDFHandWriteView pDFHandWriteView) {
        Message message = new Message();
        if (pDFHandWriteView != null && !pDFHandWriteView.isEmpty()) {
            insertVertorFlag = 1;
            if ((this.isSupportEbenT7Mode || this.isVectorSign) && pDFHandWriteView.getPenType() == 0) {
                a(z10, pDFHandWriteView);
            } else {
                a(z10, z11, pDFHandWriteView);
            }
            Bundle bundle = new Bundle();
            bundle.putInt("pageNo", this.insertPageNo);
            bundle.putBoolean("isRefresh", z10);
            message.obj = pDFHandWriteView;
            message.setData(bundle);
            message.what = KinggridConstant.VERTORDATA_INSERT_FINISHED;
            this.f28122d.sendMessage(message);
        }
    }

    public void doSaveImageSignByHandle(Bitmap bitmap, String str) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.setActWAndH();
        if (this.pdfEditManager.existFieldInDocument(this.pdfEditManager.hasFieldInDocument(str))) {
            String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
            FileUtils.saveImage(bitmap, pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null);
            this.pdfEditManager.insertImageInField(pdfWriteImagePath, str, false);
        }
    }

    public void doSaveKGSignatureByPos(final String str, final String str2, final String str3, final String str4, final float f10, final float f11, final float f12, final float f13, final int i10, final SignatureInfo signatureInfo) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        g();
        new Thread(new Runnable() {
            @Override
            public void run() {
                IAppPDFActivity.this.lockScreen();
                try {
                    HashMap hashMap = new HashMap();
                    SignatureInfo signatureInfo2 = signatureInfo;
                    if (signatureInfo2 != null) {
                        hashMap.put("actWidth", String.valueOf(signatureInfo2.getWidth()));
                        hashMap.put("actHeight", String.valueOf(signatureInfo.getHeight()));
                        hashMap.put("CompName", signatureInfo.getCompName());
                        hashMap.put("KeySerial", signatureInfo.getKeySN());
                        hashMap.put("SealSerial", signatureInfo.getSignSN());
                        hashMap.put("KeyName", signatureInfo.getFileName());
                    } else {
                        hashMap.put("actWidth", null);
                        hashMap.put("actHeight", null);
                        hashMap.put("CompName", null);
                        hashMap.put("KeySerial", null);
                        hashMap.put("SealSerial", null);
                        hashMap.put("KeyName", null);
                    }
                    hashMap.put("bProtectDoc", "1");
                    hashMap.put("bEffect", "1");
                    hashMap.put("bCertSign", "0");
                    hashMap.put("AppName", "iAppPDF(V3.1.0.316)");
                    hashMap.put("UserName", IAppPDFActivity.userName);
                    hashMap.put("CreateTime", DateFormat.format("yyyy_MM_dd_HH_mm_ss", System.currentTimeMillis()).toString());
                    hashMap.put("strMd5", str3);
                    hashMap.put("doffSign", "0");
                    hashMap.put("DateCheck", "0");
                    hashMap.put("noConnection", "0");
                    new KGBase64();
                    IAppPDFActivity.this.pdfEditManager.insertKGSignatureByPos(str4, i10, f12, f13, f10, f11, IAppPDFActivity.userName, hashMap, str, str2);
                    Message message = new Message();
                    message.what = 44;
                    IAppPDFActivity.this.f28122d.sendMessage(message);
                } catch (Exception e10) {
                    e10.printStackTrace();
                }
                IAppPDFActivity.this.f28122d.sendEmptyMessage(46);
                IAppPDFActivity.this.unLockScreen();
            }
        }).start();
    }

    public boolean doSavePDFHandWriteViewImage(PDFHandWriteView pDFHandWriteView, String str) {
        if (pDFHandWriteView.isEmpty()) {
            return false;
        }
        return FileUtils.savePdfWriteImage(pDFHandWriteView, str);
    }

    public void doSavePerforationDivSeal(Bitmap bitmap, float f10) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        int pageCount = getPageCount();
        boolean z10 = true;
        if (pageCount >= 2) {
            List<ImagePiece> split = ImageSplitter.split(bitmap, 2, 1, String.valueOf(signaturePath) + userName + "_");
            Bitmap bitmap2 = split.get(0).getBitmap();
            Bitmap bitmap3 = split.get(1).getBitmap();
            String filePath = split.get(0).getFilePath();
            String filePath2 = split.get(1).getFilePath();
            if (!new File(filePath).exists() || !new File(filePath2).exists()) {
                z10 = false;
            }
            if (z10) {
                String formatDateTimeToPDF = CommonMethodAndStringUtil.formatDateTimeToPDF(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                float zoom = ((GLView) this.view).getBase().getZoomModel().getZoom();
                for (int i10 = 0; i10 < pageCount; i10++) {
                    RectF pageBounds2 = this.pdfEditManager.getPageBounds(i10);
                    actWidth = pageBounds2.width();
                    actHeight = pageBounds2.height();
                    float width = (actWidth / this.view.getWidth()) / zoom;
                    float width2 = bitmap2.getWidth() * width;
                    float height = bitmap2.getHeight() * width;
                    float width3 = bitmap3.getWidth() * width;
                    float height2 = bitmap3.getHeight() * width;
                    float f11 = actWidth - width2;
                    if (i10 == 0) {
                        this.pdfEditManager.insertImageByPosBat(filePath, i10, f11, f10, width2, height, userName, formatDateTimeToPDF, null);
                    } else if (i10 == pageCount - 1) {
                        this.pdfEditManager.insertImageByPosBat(filePath2, i10, 0.0f, f10, width3, height2, userName, formatDateTimeToPDF, null);
                    } else {
                        int i11 = i10;
                        this.pdfEditManager.insertImageByPosBat(filePath, i11, f11, f10, width2, height, userName, formatDateTimeToPDF, null);
                        this.pdfEditManager.insertImageByPosBat(filePath2, i11, 0.0f, f10, width3, height2, userName, formatDateTimeToPDF, null);
                    }
                }
            } else {
                Log.e(f28121h, "保存失败");
            }
            bitmap2.recycle();
            bitmap3.recycle();
            refreshDocument();
            return;
        }
        Toast.makeText(this.f28125i, "页数不够,无法盖骑缝章,请在两页以上的文档重试", 1).show();
    }

    public void doSavePerforationSideSeal(Bitmap bitmap, float f10) {
        int i10;
        int i11;
        int i12;
        boolean z10;
        int i13;
        int i14;
        int i15;
        int pageCount = getPageCount();
        if (pageCount >= 2) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            String formatDateTimeToPDF = CommonMethodAndStringUtil.formatDateTimeToPDF(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            String str = String.valueOf(signaturePath) + userName + "_";
            int i16 = this.perforation_max_size;
            if (pageCount <= i16 + 1) {
                i16 = pageCount;
            }
            List<ImagePiece> split = ImageSplitter.split(bitmap, i16, 1, str);
            int i17 = this.perforation_max_size;
            int i18 = 0;
            if (pageCount > i17 + 1) {
                int i19 = pageCount % i17;
                if (i19 != 0 && i19 <= 1) {
                    if (i19 == 1) {
                        if ((pageCount / i17) - 1 < 1) {
                            i15 = 1;
                        } else {
                            i15 = (pageCount / i17) - 1;
                        }
                    } else {
                        i10 = i19;
                    }
                } else {
                    i15 = pageCount / i17;
                }
                i11 = i15;
                i10 = i19;
                i12 = 0;
                while (i12 < i11) {
                    int i20 = i10;
                    int i21 = 0;
                    while (i21 < split.size()) {
                        int i22 = (this.perforation_max_size * i12) + i21;
                        File file = new File(split.get(i21).getFilePath());
                        Bitmap bitmap2 = split.get(i21).getBitmap();
                        if (!file.exists()) {
                            z10 = FileUtils.saveImage(bitmap2, file.getAbsolutePath(), Bitmap.CompressFormat.JPEG, null);
                        } else {
                            z10 = true;
                        }
                        if (z10) {
                            i13 = i12;
                            i14 = i21;
                            a(userName, i22, file, f10, bitmap2.getWidth(), bitmap2.getHeight(), formatDateTimeToPDF);
                        } else {
                            i13 = i12;
                            i14 = i21;
                            Log.e(f28121h, String.valueOf(file.getAbsolutePath()) + "保存失败");
                        }
                        i21 = i14 + 1;
                        i12 = i13;
                    }
                    i12++;
                    i10 = i20;
                }
                if (i10 != 1) {
                    List<ImagePiece> split2 = ImageSplitter.split(bitmap, this.perforation_max_size + i10, 1, str);
                    while (true) {
                        int i23 = this.perforation_max_size;
                        if (i18 >= i23 + i10) {
                            break;
                        }
                        int i24 = (i23 * i11) + i18;
                        Bitmap bitmap3 = split2.get(i18).getBitmap();
                        a(userName, i24, new File(split2.get(i18).getFilePath()), f10, bitmap3.getWidth(), bitmap3.getHeight(), formatDateTimeToPDF);
                        i18++;
                        i10 = i10;
                    }
                } else if (i10 > 1) {
                    List<ImagePiece> split3 = ImageSplitter.split(bitmap, i10, 1, str);
                    while (i18 < i10) {
                        int i25 = (this.perforation_max_size * i11) + i18;
                        Bitmap bitmap4 = split3.get(i18).getBitmap();
                        a(userName, i25, new File(split3.get(i18).getFilePath()), f10, bitmap4.getWidth(), bitmap4.getHeight(), formatDateTimeToPDF);
                        i18++;
                        i10 = i10;
                    }
                }
                refreshDocument();
                return;
            }
            i10 = 0;
            i11 = 1;
            i12 = 0;
            while (i12 < i11) {
            }
            if (i10 != 1) {
            }
            refreshDocument();
            return;
        }
        Toast.makeText(this.f28125i, "页数不够,无法盖骑缝章,请在两页或两页以上的文档重试", 1).show();
    }

    public void doSaveSignByFieldName(PDFHandWriteView pDFHandWriteView, String str) {
        if (this.f28142z) {
            Toast.makeText(this.f28125i, "当前版本为只读版本...", 0).show();
            return;
        }
        if (pDFHandWriteView.isEmpty()) {
            return;
        }
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.setActWAndH();
        long hasFieldInDocument = this.pdfEditManager.hasFieldInDocument(str);
        if (this.pdfEditManager.existFieldInDocument(hasFieldInDocument)) {
            if ((this.isSupportEbenT7Mode || this.isVectorSign) && pDFHandWriteView.getPenType() == 0) {
                a(pDFHandWriteView, hasFieldInDocument, str);
            } else {
                a(pDFHandWriteView, str);
            }
        }
    }

    public void doSaveSignByFieldNameInPage(PDFHandWriteView pDFHandWriteView, String str, int i10) {
        if (this.f28142z) {
            Toast.makeText(this.f28125i, "当前版本为只读版本...", 0).show();
            return;
        }
        if (pDFHandWriteView.isEmpty()) {
            return;
        }
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.setActWAndH();
        if (MuPdfDocument.hasField(this.pdfEditManager.getPageHandle(i10 - 1), str) == 0) {
            long hasFieldInDocument = this.pdfEditManager.hasFieldInDocument(str);
            if ((this.isSupportEbenT7Mode || this.isVectorSign) && pDFHandWriteView.getPenType() == 0) {
                a(pDFHandWriteView, hasFieldInDocument, str, i10);
                return;
            } else {
                a(pDFHandWriteView, str, i10);
                return;
            }
        }
        Log.d("tbz", "no field in page");
    }

    public void doSaveSignByPosition(PDFHandWriteView pDFHandWriteView, ArrayList<SignaturePosition> arrayList, float f10) {
        if (pDFHandWriteView.isEmpty()) {
            return;
        }
        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
        if (FileUtils.savePdfWriteImage(pDFHandWriteView, pdfWriteImagePath)) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            this.pdfEditManager.insertImageByPos(pdfWriteImagePath, f10, arrayList);
            this.pdfEditManager.refreshDocument();
        }
    }

    public void doSaveSignByServer(PDFHandWriteView pDFHandWriteView, String str) {
        if (pDFHandWriteView.isEmpty()) {
            return;
        }
        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
        if (FileUtils.savePdfWriteImage(pDFHandWriteView, pdfWriteImagePath)) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            this.pdfEditManager.insertImageInField(pdfWriteImagePath, str, true);
        }
    }

    public void doSaveSignByText(PDFHandWriteView pDFHandWriteView, String str, float f10) {
        if (pDFHandWriteView.isEmpty()) {
            return;
        }
        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
        if (FileUtils.savePdfWriteImage(pDFHandWriteView, pdfWriteImagePath)) {
            insertSignatureInText(pdfWriteImagePath, str, f10);
        }
    }

    public void doSaveSoundAnnot(Annotation annotation, float f10, float f11) {
        if (this.f28142z) {
            Message message = new Message();
            message.what = 47;
            this.f28122d.sendMessage(message);
            return;
        }
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.insertSoundByPosNew(String.valueOf(KinggridConstant.FILEDIR_PATH) + "/tempsounds/" + annotation.getUnType(), this.insertPageNo, f10, f11, annotation.getAuthorName(), annotation.getSoundData(), (int) annotation.getSoundRate(), (int) annotation.getSoundChannels(), (int) annotation.getSoundBitspersample());
    }

    public void doSaveTFDigitallySign(final String str, final int i10, final float f10, final float f11, final float f12, final float f13, final String str2, final String str3) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        g();
        new Thread(new Runnable() {
            @Override
            public void run() {
                IAppPDFActivity.this.lockScreen();
                SignatureTask.getInstance().setDebug(true);
                SignatureTask.getInstance().setMode(SignatureTask.SignMode.TF);
                if (SignatureTask.getInstance().getLMSignData("test".getBytes(), str3, str2) != null) {
                    String path = IAppPDFActivity.this.getIntent().getData().getPath();
                    Message message = new Message();
                    message.what = 44;
                    IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                    iAppPDFActivity.pdfEditManager.insertSignatureSM2(str, i10, f10, f11, f12, f13, path, "123456", null, 1, "", iAppPDFActivity.keySN);
                    IAppPDFActivity.this.f28122d.sendMessage(message);
                } else {
                    Log.e(IAppPDFActivity.f28121h, "getTFSignData is null");
                }
                IAppPDFActivity.this.f28122d.sendEmptyMessage(46);
                IAppPDFActivity.this.unLockScreen();
            }
        }).start();
    }

    public void doSaveTextAnnot(Annotation annotation, float f10, float f11) {
        if (this.f28142z) {
            Toast.makeText(this.f28125i, "当前版本为只读版本...", 0).show();
            return;
        }
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (annotation != null) {
            this.pdfEditManager.insertAnnotByPos(annotation.getAuthorName(), annotation.getAnnoContent(), this.insertPageNo, f10, f11, new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis())));
        }
    }

    public void doUpdateTextAnnotation(Annotation annotation) {
        if (annotation != null) {
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            if (this.pdfEditManager.existFieldInDocument(this.pdfEditManager.getAnnotHandle(Integer.parseInt(annotation.getPageNo()), Float.parseFloat(annotation.getX()), Float.parseFloat(annotation.getY())))) {
                this.pdfEditManager.updateAnnotContent(annotation.getAnnotHandle(), annotation.getAnnoContent());
            }
        }
    }

    public void encryptionDocument(String str) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.encryptionDocument(str);
    }

    public void fling(float f10, float f11, Rect rect) {
        this.view.startFling(f10, f11, rect);
        this.view.redrawView();
    }

    protected ArrayList<String> getAllFieldContent() {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        ArrayList<String> arrayList = new ArrayList<>();
        for (long j10 : MuPdfDocument.getFieldsIndocument(muPdfDocument.getDocumentHandle())) {
            arrayList.add(pDFEditManager.getFieldContent(j10));
        }
        return arrayList;
    }

    public long getAnnotHandleByRect(float f10, float f11, float f12, float f13) {
        float[] insertXYForSinglePage;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            insertXYForSinglePage = getInsertXY(f12, f10, true, 0);
        } else {
            insertXYForSinglePage = getInsertXYForSinglePage(f12, f10, true, 0);
        }
        if (insertXYForSinglePage[0] == -1.0f) {
            return -1L;
        }
        if (this.pdfEditManager != null) {
            float width = (((f13 - f12) * actWidth) / this.view.getView().getWidth()) / getController().getZoomModel().getZoom();
            float width2 = (((f11 - f10) * actWidth) / this.view.getView().getWidth()) / getController().getZoomModel().getZoom();
            PDFEditManager pDFEditManager = this.pdfEditManager;
            int i10 = this.insertPageNo;
            float f14 = insertXYForSinglePage[1];
            float f15 = insertXYForSinglePage[0];
            this.currAnnotation = pDFEditManager.getAnnotHandleByRect(i10, f14, f14 + width2, f15, f15 + width);
        }
        return this.currAnnotation;
    }

    public long[] getAnnotHandleListByRect(float f10, float f11, float f12, float f13) {
        float[] insertXYForSinglePage;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            insertXYForSinglePage = getInsertXY(f12, f10, true, 0);
        } else {
            insertXYForSinglePage = getInsertXYForSinglePage(f12, f10, true, 0);
        }
        if (insertXYForSinglePage[0] == -1.0f || this.pdfEditManager == null) {
            return null;
        }
        float width = (((f13 - f12) * actWidth) / this.view.getView().getWidth()) / getController().getZoomModel().getZoom();
        float width2 = (((f11 - f10) * actWidth) / this.view.getView().getWidth()) / getController().getZoomModel().getZoom();
        PDFEditManager pDFEditManager = this.pdfEditManager;
        int i10 = this.insertPageNo;
        float f14 = insertXYForSinglePage[1];
        float f15 = insertXYForSinglePage[0];
        return pDFEditManager.getAnnotHandleListByRect(i10, f14, f14 + width2, f15, f15 + width);
    }

    protected int getAnnotationCount(String str) {
        int pageCount = getController().getDocumentModel().getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        int i10 = 0;
        for (int i11 = 0; i11 < pageCount; i11++) {
            i10 += MuPdfDocument.getAnnotations(this.pdfEditManager.getPageHandle(i11), str).length;
        }
        return i10;
    }

    protected ArrayList<Annotation> getAnnotationList(int i10) {
        return getAnnotationList(userName, i10);
    }

    protected ArrayList<Annotation> getAnnotationNewList(int i10) {
        return getAnnotationNewList(userName, i10);
    }

    protected ArrayList<Annotation> getAnnotationsForList(String str, String str2) {
        long[] annotations;
        String str3;
        ArrayList<Annotation> arrayList = new ArrayList<>();
        int pageCount = getController().getDocumentModel().getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        for (int i10 = 0; i10 < pageCount; i10++) {
            long pageHandle = this.pdfEditManager.getPageHandle(i10);
            if (str.equals("")) {
                if (str2.equals("")) {
                    annotations = MuPdfDocument.getAllAnnotations(pageHandle);
                } else {
                    annotations = MuPdfDocument.getAllAnnotationsBySubType(pageHandle, str2);
                }
            } else {
                annotations = MuPdfDocument.getAnnotations(pageHandle, str);
            }
            Log.v(f28121h, "getAnnotationsForList length = " + annotations.length);
            for (int i11 = 0; i11 < annotations.length; i11++) {
                String annotSubType = MuPdfDocument.getAnnotSubType(annotations[i11]);
                String annotInfo = MuPdfDocument.getAnnotInfo(annotations[i11]);
                Log.d("Kevin", "List getAnnotInfo : " + annotInfo + " , " + annotSubType);
                if (TextUtils.isEmpty(annotInfo)) {
                    str3 = "";
                } else {
                    if (this.pdfEditManager == null) {
                        this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
                    }
                    str3 = this.pdfEditManager.parseAnnotInfo2String(annotInfo)[1];
                }
                if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_POSTIL) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SIGN) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_STAMP) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SOUND)) {
                    Annotation annotation = new Annotation();
                    if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT)) {
                        annotation.setAnnoContent(MuPdfDocument.getAnnotText(annotations[i11]));
                    }
                    if (!str3.equals("")) {
                        annotation.setAuthorName(str3);
                    } else {
                        annotation.setAuthorName(MuPdfDocument.getAnnotAuthor(annotations[i11]));
                    }
                    annotation.setPageNo(String.valueOf(i10 + 1));
                    annotation.setStyleName(annotSubType);
                    annotation.setCreateTime(CommonMethodAndStringUtil.formatDateTime(MuPdfDocument.getAnnotCreateTime(annotations[i11])));
                    annotation.setAnnotId(MuPdfDocument.getAnnotId(annotations[i11]));
                    arrayList.add(annotation);
                }
            }
        }
        return arrayList;
    }

    public List<Attachment> getAttachments() {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        return this.pdfEditManager.getAttachments();
    }

    public byte[] getByteFromRange(int[] iArr) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(4096);
        try {
            FileInputStream fileInputStream = new FileInputStream(getIntent().getData().getPath());
            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(4096);
            byte[] bArr = new byte[4096];
            while (true) {
                int read = fileInputStream.read(bArr);
                if (read == -1) {
                    break;
                }
                byteArrayOutputStream2.write(bArr, 0, read);
            }
            fileInputStream.close();
            byteArrayOutputStream2.close();
            byte[] byteArray = byteArrayOutputStream2.toByteArray();
            byteArrayOutputStream.write(byteArray, iArr[0], iArr[1]);
            byteArrayOutputStream.write(byteArray, iArr[2], iArr[3]);
            byteArrayOutputStream.close();
        } catch (FileNotFoundException e10) {
            e10.printStackTrace();
        } catch (IOException e11) {
            e11.printStackTrace();
        }
        return byteArrayOutputStream.toByteArray();
    }

    protected void getCertificate() {
    }

    protected boolean getCheckFieldState(String str) {
        String str2;
        try {
            str2 = new String(str.getBytes(), "UTF-8");
        } catch (Exception e10) {
            e10.printStackTrace();
            str2 = null;
        }
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        long hasFieldInDocument = pDFEditManager.hasFieldInDocument(str2);
        if (hasFieldInDocument != 1) {
            return this.pdfEditManager.getCheckFieldState(hasFieldInDocument);
        }
        return false;
    }

    public float[] getCriticalPointXY(float f10, float f11, float f12, float f13) {
        float[] fArr = new float[2];
        float f14 = f12 / 2.0f;
        if (f10 - f14 <= 0.0f) {
            f10 = f14;
        } else {
            float f15 = f10 + f14;
            float f16 = actWidth;
            if (f15 >= f16) {
                f10 = f16 - f14;
            }
        }
        float f17 = f13 / 2.0f;
        if (f11 - f17 <= 0.0f) {
            f11 = f17;
        } else {
            float f18 = f11 + f17;
            float f19 = actHeight;
            if (f18 >= f19) {
                f11 = f19 - f17;
            }
        }
        fArr[0] = f10;
        fArr[1] = f11;
        return fArr;
    }

    public OutlineLink getCurrentOutline() {
        return getController().getCurrentOutline();
    }

    public int getCurrentPageNo() {
        return getController().getDocumentModel().getCurrentDocPageIndex();
    }

    public String getDocumentHash() {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        try {
            return this.pdfEditManager.getHash();
        } catch (IOException e10) {
            e10.printStackTrace();
            return null;
        }
    }

    public String getDocumentHex() {
        return CommonMethodAndStringUtil.MD5EncodeUtil.md5String(String.valueOf(l()) + m());
    }

    protected String getFieldContent(String str) {
        String str2;
        try {
            str2 = new String(str.getBytes(), "UTF-8");
        } catch (Exception e10) {
            e10.printStackTrace();
            str2 = null;
        }
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        long hasFieldInDocument = pDFEditManager.hasFieldInDocument(str2);
        if (hasFieldInDocument == 1) {
            return null;
        }
        return this.pdfEditManager.getFieldContent(hasFieldInDocument);
    }

    public Handler getHandler() {
        return this.f28122d;
    }

    public float[] getInsertXY(float f10, float f11, boolean z10, int i10) {
        float[] fArr = new float[2];
        int currentViewPageIndex = getController().getDocumentModel().getCurrentViewPageIndex();
        float zoom = getController().getZoomModel().getZoom();
        Page currentPageObject = getController().getDocumentModel().getCurrentPageObject();
        int pageCount = getController().getDocumentModel().getPageCount();
        if (currentPageObject == null) {
            fArr[0] = -1.0f;
            fArr[1] = -1.0f;
            return fArr;
        }
        RectF bounds = currentPageObject.getBounds(zoom);
        float f12 = bounds.top;
        float f13 = bounds.bottom;
        if (this.view.getView().getScrollY() + f11 < ((int) bounds.top)) {
            int i11 = currentViewPageIndex - 1;
            this.insertPageNo = i11;
            if (i11 < 0) {
                this.insertPageNo = 0;
            }
            RectF bounds2 = getController().getDocumentModel().getPageByDocIndex(this.insertPageNo).getBounds(zoom);
            f12 = bounds2.top;
            f13 = bounds2.bottom;
        } else if (this.view.getView().getScrollY() + f11 > f13) {
            this.insertPageNo = currentViewPageIndex + 1;
            Log.d("Kevin", "insertPageNo : " + this.insertPageNo);
            if (this.insertPageNo == pageCount) {
                this.insertPageNo = pageCount - 1;
            }
            RectF bounds3 = getController().getDocumentModel().getPageByDocIndex(this.insertPageNo).getBounds(zoom);
            f12 = bounds3.top;
            f13 = bounds3.bottom;
        } else {
            this.insertPageNo = currentViewPageIndex;
        }
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        RectF pageBounds2 = this.pdfEditManager.getPageBounds(this.insertPageNo);
        actWidth = pageBounds2.width();
        actHeight = pageBounds2.height();
        rotate = this.pdfEditManager.getPageRotate(this.insertPageNo);
        float f14 = f13 - f12;
        fArr[0] = (((this.view.getView().getScrollX() + f10) + 4.0f) * actHeight) / f14;
        fArr[1] = ((((this.view.getView().getScrollY() + f11) + 4.0f) - f12) * actHeight) / f14;
        return fArr;
    }

    public float[] getInsertXYForSinglePage(float f10, float f11, boolean z10, int i10) {
        float[] fArr = new float[2];
        this.insertPageNo = getController().getDocumentModel().getCurrentViewPageIndex();
        float zoom = getController().getZoomModel().getZoom();
        Page currentPageObject = getController().getDocumentModel().getCurrentPageObject();
        if (currentPageObject == null) {
            fArr[0] = -1.0f;
            fArr[1] = -1.0f;
            return fArr;
        }
        RectF bounds = currentPageObject.getBounds(zoom);
        Log.d("Kevin", "rectF : " + bounds.toString());
        float f12 = bounds.left;
        float f13 = bounds.right;
        float j10 = j();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        RectF pageBounds2 = this.pdfEditManager.getPageBounds(this.insertPageNo);
        actWidth = pageBounds2.width();
        actHeight = pageBounds2.height();
        rotate = this.pdfEditManager.getPageRotate(this.insertPageNo);
        Log.d("Kevin", "rectF : " + actWidth + "       h : " + actHeight);
        if (this.view.getView().getScrollX() == 0) {
            fArr[0] = (actWidth * ((f10 - f12) + 4.0f)) / (f13 - f12);
        } else {
            fArr[0] = (actWidth * (((f10 + this.view.getView().getScrollX()) - f12) + 4.0f)) / (f13 - f12);
        }
        fArr[1] = (actWidth * ((f11 + this.view.getView().getScrollY()) + 4.0f)) / (f13 - f12);
        Log.d("Kevin", " x : " + this.view.getView().getScrollX() + "       y : " + this.view.getView().getScrollY() + "     delta : " + (j10 * zoom));
        return fArr;
    }

    public LongTouchAnnotState getLongTouchAnnotState() {
        return this.G;
    }

    public float getLongTouchTime() {
        return this.T;
    }

    public float getOffsetX() {
        return getController().getBookSettings().offsetX;
    }

    public float getOffsetY() {
        return getController().getBookSettings().offsetY;
    }

    public OnPageChangeListener getOnPageChangeListener() {
        return this.f28137u;
    }

    public OnScrollChangeListener getOnScrollChangeListener() {
        return this.L;
    }

    public OnSignatureListener getOnSignatureListener() {
        return this.K;
    }

    public List<OutlineLink> getOutlineList() {
        return ((DecodeServiceBase) getController().getDecodeService()).getOutline();
    }

    public LinkedList<PageText> getPageAllText() {
        LinkedList<PageText> pageAllText = ((MuPdfPage) ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPage(this.insertPageNo)).getPageAllText();
        Iterator<PageText> it = pageAllText.iterator();
        while (it.hasNext()) {
            PageText next = it.next();
            if (next.getScreen_rect() == null || next.getScreen_rect().isEmpty()) {
                next.setScreen_rect(getScreenRectByDocumentRect(next.getCodeRectF()));
            }
        }
        return pageAllText;
    }

    public synchronized ByteBufferBitmap getPageBitmap(int i10, int i11, int i12) {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        Page pageObject = getController().getDocumentModel().getPageObject(i12);
        ViewState viewState = ViewState.get(getController().getDocumentController());
        RectF bounds = pageObject.getBounds(1.0f);
        RectF rectF = new RectF(0.0f, 0.0f, 1.0f, 1.0f);
        float f10 = i10;
        float f11 = i11;
        if (bounds.width() / f10 > bounds.height() / f11) {
            i11 = (int) (bounds.height() * (f10 / bounds.width()));
        } else {
            i10 = (int) (bounds.width() * (f11 / bounds.height()));
        }
        if (i12 < pageCount) {
            return ((MuPdfPage) muPdfDocument.getPage(i12)).renderBitmap(viewState, i10, i11, rectF);
        }
        return null;
    }

    public int getPageCount() {
        return getController().getDocumentModel().getPageCount();
    }

    public synchronized Bitmap getPageScaleBitmap(int i10, int i11) {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        Page currentPageObject = getController().getDocumentModel().getCurrentPageObject();
        ViewState viewState = ViewState.get(getController().getDocumentController());
        RectF bounds = currentPageObject.getBounds(1.0f);
        RectF rectF = new RectF(0.0f, 0.0f, 1.0f, 1.0f);
        if (i10 < pageCount) {
            return ((MuPdfPage) muPdfDocument.getPage(i10)).renderBitmap(viewState, ((int) bounds.width()) * i11, ((int) bounds.height()) * i11, rectF).toBitmap().getBitmap();
        }
        return null;
    }

    public float getPageZoom() {
        return getController().getBookSettings().getZoom();
    }

    protected synchronized void getPagesImage(final String str) {
        File file = new File(str);
        if (!file.exists()) {
            file.mkdirs();
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) IAppPDFActivity.this.getController().getDecodeService()).document;
                int pageCount = muPdfDocument.getPageCount();
                Page currentPageObject = IAppPDFActivity.this.getController().getDocumentModel().getCurrentPageObject();
                ViewState viewState = ViewState.get(IAppPDFActivity.this.getController().getDocumentController());
                RectF bounds = currentPageObject.getBounds(1.0f);
                RectF rectF = new RectF(0.0f, 0.0f, 1.0f, 1.0f);
                for (int i10 = 1; i10 <= pageCount; i10++) {
                    byte[] createBMPBuffer = new PDFPageToBMP().createBMPBuffer(((MuPdfPage) muPdfDocument.getPage(i10 - 1)).renderBitmap(viewState, (int) bounds.width(), (int) bounds.height(), rectF).toBitmap().getBitmap());
                    try {
                        FileOutputStream fileOutputStream = new FileOutputStream(String.valueOf(str) + i10 + ".bmp");
                        fileOutputStream.write(createBMPBuffer);
                        fileOutputStream.flush();
                        fileOutputStream.close();
                    } catch (IOException e10) {
                        e10.printStackTrace();
                    }
                }
                IAppPDFActivity.this.sendBroadcast(new Intent("com.kinggrid.pages.bmp.save"));
            }
        }).start();
    }

    protected int getRadioFieldState(String str, int i10) {
        try {
            new String(str.getBytes(), "UTF-8");
        } catch (Exception e10) {
            e10.printStackTrace();
        }
        int i11 = -1;
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        long[] fieldsInPage = MuPdfDocument.getFieldsInPage(pDFEditManager.getPageHandle(i10), str);
        if (fieldsInPage != null) {
            for (int i12 = 0; i12 < fieldsInPage.length; i12++) {
                boolean checkFieldState = this.pdfEditManager.getCheckFieldState(fieldsInPage[i12]);
                if (checkFieldState) {
                    i11 = i12;
                }
                Log.d("tbz", "field index = " + i12 + ", state = " + checkFieldState);
            }
        }
        return i11;
    }

    protected int getResId(String str, String str2) {
        return this.f28140x.getIdentifier(str, str2, this.f28141y);
    }

    public RectF getScreenRectByDocumentRect(RectF rectF) {
        float[] fArr = new float[4];
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        RectF pageBounds2 = this.pdfEditManager.getPageBounds(this.insertPageNo);
        actWidth = pageBounds2.width();
        actHeight = pageBounds2.height();
        float zoom = ((GLView) this.view).getBase().getZoomModel().getZoom();
        Page pageByDocIndex = getController().getDocumentModel().getPageByDocIndex(this.insertPageNo);
        if (pageByDocIndex == null) {
            return null;
        }
        RectF bounds = pageByDocIndex.getBounds(zoom);
        float f10 = bounds.top;
        float f11 = bounds.bottom;
        float f12 = bounds.left;
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            fArr[0] = ((rectF.left * (f11 - f10)) / actHeight) - ((GLView) this.view).getScrollX();
        } else if (((GLView) this.view).getScrollX() == 0) {
            fArr[0] = (((rectF.left * (f11 - f10)) / actHeight) + j()) - ((GLView) this.view).getScrollX();
        } else {
            fArr[0] = ((rectF.left * (f11 - f10)) / actHeight) - (this.view.getView().getScrollX() - f12);
        }
        float f13 = f11 - f10;
        float scrollY = (((rectF.top * f13) / actHeight) - ((GLView) this.view).getScrollY()) + f10;
        fArr[1] = scrollY;
        float f14 = (rectF.right - rectF.left) * f13;
        float f15 = actHeight;
        fArr[2] = (f14 / f15) + fArr[0];
        fArr[3] = (((rectF.bottom - rectF.top) * f13) / f15) + scrollY;
        return new RectF(fArr[0], fArr[1], fArr[2], fArr[3]);
    }

    public String getSelectText() {
        StringBuilder sb2 = new StringBuilder();
        LinkedList<PageText> linkedList = this.S;
        for (PageText pageText : (PageText[]) linkedList.toArray(new PageText[linkedList.size()])) {
            sb2.append(pageText.getCodeValue());
        }
        return sb2.toString();
    }

    public SelectRectView getSelectView() {
        return this.F;
    }

    protected List<SignPosition> getSignPositionInField(String str) {
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        ArrayList arrayList = new ArrayList();
        for (int i10 = 0; i10 < pageCount; i10++) {
            long pageHandle = this.pdfEditManager.getPageHandle(i10);
            int height = (int) this.pdfEditManager.getPageBounds(i10).height();
            for (long j10 : MuPdfDocument.getAnnotSignatures(pageHandle, str)) {
                float[] annotRect = MuPdfDocument.getAnnotRect(j10);
                SignPosition signPosition = new SignPosition();
                signPosition.pageno = i10 + 1;
                signPosition.height = height;
                signPosition.rect = annotRect;
                arrayList.add(signPosition);
            }
        }
        return arrayList;
    }

    protected List<SignPosition> getSignPositionInText(String str) {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        ArrayList arrayList = new ArrayList();
        for (int i10 = 0; i10 < pageCount; i10++) {
            MuPdfPage muPdfPage = (MuPdfPage) muPdfDocument.getPage(i10);
            int height = muPdfPage.getHeight();
            List<? extends RectF> searchText1 = muPdfPage.searchText1(str);
            for (int i11 = 0; i11 < searchText1.size(); i11++) {
                SignPosition signPosition = new SignPosition();
                signPosition.pageno = i10 + 1;
                signPosition.height = height;
                float[] fArr = new float[4];
                signPosition.rect = fArr;
                fArr[0] = searchText1.get(i11).left;
                signPosition.rect[1] = searchText1.get(i11).top;
                signPosition.rect[2] = searchText1.get(i11).right;
                signPosition.rect[3] = searchText1.get(i11).bottom;
                arrayList.add(signPosition);
            }
        }
        return arrayList;
    }

    public ArrayList<KGSignature> getSignatures(int i10) {
        Object obj;
        String str;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        ArrayList<KGSignature> arrayList = new ArrayList<>();
        String str2 = "adbe.pkcs7.detached";
        long j10 = 0;
        char c10 = 0;
        if (i10 != -1) {
            Object obj2 = "adbe.pkcs7.detached";
            long[] signatureFieldInPage = this.pdfEditManager.getSignatureFieldInPage(i10);
            if (signatureFieldInPage != null) {
                int i11 = 0;
                while (i11 < signatureFieldInPage.length) {
                    long signature = MuPdfDocument.getSignature(signatureFieldInPage[i11]);
                    if (signature != 0) {
                        obj = obj2;
                        if (this.pdfEditManager.getSignatureSubfilter(signature).equals(obj)) {
                            KGSignature kGSignature = new KGSignature();
                            kGSignature.setFieldHandle(signatureFieldInPage[i11]);
                            kGSignature.setSignatureHandle(signature);
                            kGSignature.setPageNo(i11 + 1);
                            float[] a10 = a(i10, this.pdfEditManager.getFieldRect(signatureFieldInPage[i11]));
                            kGSignature.setX(a10[c10]);
                            kGSignature.setY(a10[1]);
                            kGSignature.setWidth(a10[2] - a10[c10]);
                            kGSignature.setHeight(a10[3] - a10[1]);
                            String annotInfo = this.pdfEditManager.getAnnotInfo(this.pdfEditManager.getAnnotInField(signatureFieldInPage[i11], i10));
                            if (!TextUtils.isEmpty(annotInfo)) {
                                kGSignature.setKeySN(this.pdfEditManager.parseAnnotInfo2String(annotInfo)[3]);
                            }
                            int[] signatureByteRange = this.pdfEditManager.getSignatureByteRange(signature);
                            byte[] signatureContent = this.pdfEditManager.getSignatureContent(signature);
                            byte[] byteFromRange = getByteFromRange(signatureByteRange);
                            byte[] digest = SignatureTask.getInstance().digest(byteFromRange, byteFromRange.length);
                            int verifySignature = verifySignature(byteFromRange, signatureContent);
                            int verifySignature2 = verifySignature(digest, signatureContent);
                            if (verifySignature == 0 || verifySignature2 == 0) {
                                kGSignature.setCertInfo(SignatureTask.getSignatureCertficateInfo(signatureContent));
                                kGSignature.setVaild(true);
                            }
                            arrayList.add(kGSignature);
                        }
                    } else {
                        obj = obj2;
                    }
                    i11++;
                    obj2 = obj;
                    c10 = 0;
                }
            }
        } else {
            int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
            int i12 = 0;
            while (i12 < pageCount) {
                long[] signatureFieldInPage2 = this.pdfEditManager.getSignatureFieldInPage(i12);
                if (signatureFieldInPage2 != null) {
                    int i13 = 0;
                    while (i13 < signatureFieldInPage2.length) {
                        long signature2 = MuPdfDocument.getSignature(signatureFieldInPage2[i13]);
                        if (signature2 != j10 && this.pdfEditManager.getSignatureSubfilter(signature2).equals(str2)) {
                            KGSignature kGSignature2 = new KGSignature();
                            kGSignature2.setFieldHandle(signatureFieldInPage2[i13]);
                            kGSignature2.setSignatureHandle(signature2);
                            kGSignature2.setPageNo(i12 + 1);
                            str = str2;
                            float[] a11 = a(i12, this.pdfEditManager.getFieldRect(signatureFieldInPage2[i13]));
                            kGSignature2.setX(a11[0]);
                            kGSignature2.setY(a11[1]);
                            kGSignature2.setWidth(a11[2] - a11[0]);
                            kGSignature2.setHeight(a11[3] - a11[1]);
                            String annotInfo2 = this.pdfEditManager.getAnnotInfo(this.pdfEditManager.getAnnotInField(signatureFieldInPage2[i13], i12));
                            if (!TextUtils.isEmpty(annotInfo2)) {
                                kGSignature2.setKeySN(this.pdfEditManager.parseAnnotInfo2String(annotInfo2)[3]);
                            }
                            int[] signatureByteRange2 = this.pdfEditManager.getSignatureByteRange(signature2);
                            byte[] signatureContent2 = this.pdfEditManager.getSignatureContent(signature2);
                            byte[] byteFromRange2 = getByteFromRange(signatureByteRange2);
                            byte[] digest2 = SignatureTask.getInstance().digest(byteFromRange2, byteFromRange2.length);
                            int verifySignature3 = verifySignature(byteFromRange2, signatureContent2);
                            int verifySignature4 = verifySignature(digest2, signatureContent2);
                            if (verifySignature3 == 0 || verifySignature4 == 0) {
                                kGSignature2.setCertInfo(SignatureTask.getSignatureCertficateInfo(signatureContent2));
                                kGSignature2.setVaild(true);
                            }
                            arrayList.add(kGSignature2);
                        } else {
                            str = str2;
                        }
                        i13++;
                        str2 = str;
                        j10 = 0;
                    }
                }
                i12++;
                str2 = str2;
                j10 = 0;
            }
        }
        return arrayList;
    }

    public PDFHandWriteView getT7ModePDFHandwriteView() {
        return this.f28128l;
    }

    public ArrayList<String> getVectorData(String str) {
        long[] annotations;
        IAppPDFActivity iAppPDFActivity = this;
        String str2 = str;
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        ArrayList<String> arrayList = new ArrayList<>();
        if (iAppPDFActivity.pdfEditManager == null) {
            iAppPDFActivity.pdfEditManager = new PDFEditManager(getIntent(), iAppPDFActivity, getController());
        }
        for (int i10 = 0; i10 < pageCount; i10++) {
            long pageHandle = iAppPDFActivity.pdfEditManager.getPageHandle(i10);
            if (str2.equals("")) {
                annotations = MuPdfDocument.getAllAnnotationsBySubType(pageHandle, KinggridConstant.ANNOT_SUBTYPE_SIGN);
            } else {
                annotations = MuPdfDocument.getAnnotations(pageHandle, str2);
            }
            Log.v(f28121h, "getVectorData::length = " + annotations.length);
            int i11 = 0;
            while (i11 < annotations.length) {
                String annotSubType = MuPdfDocument.getAnnotSubType(annotations[i11]);
                Log.v(f28121h, "getVectorData::annotSubType = " + annotSubType);
                if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SIGN) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_STAMP)) {
                    String annotVerctorData = MuPdfDocument.getAnnotVerctorData(annotations[i11]);
                    Log.v(f28121h, "getVectorData::vector_data = " + annotVerctorData);
                    if (!TextUtils.isEmpty(annotVerctorData)) {
                        StringBuilder sb2 = new StringBuilder();
                        sb2.append(str2);
                        Log.d("Kevin", "getAnnotType : " + MuPdfDocument.getAnnotType(annotations[i11]));
                        sb2.append(";");
                        sb2.append(String.valueOf(i10 + 1));
                        sb2.append(";");
                        float[] annotRectToUser = MuPdfDocument.getAnnotRectToUser(pageHandle, annotations[i11]);
                        sb2.append(String.valueOf(annotRectToUser[0]));
                        sb2.append(";");
                        sb2.append(String.valueOf(annotRectToUser[1]));
                        sb2.append(";");
                        sb2.append(String.valueOf(annotRectToUser[2] - annotRectToUser[0]));
                        sb2.append(";");
                        sb2.append(String.valueOf(annotRectToUser[3] - annotRectToUser[1]));
                        sb2.append(";");
                        sb2.append(annotVerctorData);
                        arrayList.add(sb2.toString());
                    }
                }
                i11++;
                iAppPDFActivity = this;
                str2 = str;
            }
        }
        return arrayList;
    }

    public void gotoOutlineItem(OutlineLink outlineLink) {
        getController().gotoOutlineItem(outlineLink);
    }

    public boolean hasField(float f10, float f11) {
        float[] insertXYForSinglePage;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            insertXYForSinglePage = getInsertXY(f10, f11, true, 0);
        } else {
            insertXYForSinglePage = getInsertXYForSinglePage(f10, f11, true, 0);
        }
        float f12 = insertXYForSinglePage[0];
        if (f12 == -1.0f) {
            return false;
        }
        long annotHandle = this.pdfEditManager.getAnnotHandle(this.insertPageNo, f12, insertXYForSinglePage[1]);
        this.currAnnotation = annotHandle;
        return this.pdfEditManager.existFieldInDocument(annotHandle);
    }

    public boolean hasFieldInDocument(String str) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        return this.pdfEditManager.existFieldInDocument(this.pdfEditManager.hasFieldInDocument(str));
    }

    public boolean hasNewAnnot(String str, long j10) {
        Date date = new Date(j10);
        Iterator<Annotation> it = getAnnotationsForList(str, "").iterator();
        while (true) {
            boolean z10 = false;
            while (it.hasNext()) {
                try {
                    z10 = date.before(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(it.next().getCreateTime()));
                } catch (ParseException e10) {
                    e10.printStackTrace();
                }
            }
            return z10;
        }
    }

    public boolean hasNewAnnotInPage(int i10, String str, long j10) {
        long[] annotations;
        Date date = new Date(j10);
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        long pageHandle = this.pdfEditManager.getPageHandle(i10 - 1);
        if (str.equals("")) {
            annotations = MuPdfDocument.getAllAnnotations(pageHandle);
        } else {
            annotations = MuPdfDocument.getAnnotations(pageHandle, str);
        }
        boolean z10 = false;
        for (long j11 : annotations) {
            try {
                z10 = date.before(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(CommonMethodAndStringUtil.formatDateTime(MuPdfDocument.getAnnotCreateTime(j11))));
            } catch (ParseException e10) {
                e10.printStackTrace();
                z10 = false;
            }
        }
        return z10;
    }

    protected boolean hasSignatureInField(String str) {
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        for (int i10 = 0; i10 < pageCount; i10++) {
            for (long j10 : MuPdfDocument.getAnnotSignatures(this.pdfEditManager.getPageHandle(i10), str)) {
                float[] annotRect = MuPdfDocument.getAnnotRect(j10);
                if (this.pdfEditManager.getAnnotHandleByRect(i10, annotRect[1], annotRect[3], annotRect[0], annotRect[2]) != -1) {
                    return true;
                }
            }
        }
        return false;
    }

    public void hiddenViewFromPDF(View view) {
        this.f28136t.removeView(view);
    }

    public void initPDFView(ViewGroup viewGroup) {
        try {
            GLConfiguration.checkConfiguration();
            GLView gLView = new GLView(getController());
            this.view = gLView;
            LayoutUtils.fillInParent(viewGroup, gLView.getView());
            viewGroup.addView(this.view.getView());
            this.f28136t = viewGroup;
            this.F = new SelectRectView(this.f28125i);
            this.f28136t.addView(this.F, new LinearLayout.LayoutParams(-2, -2));
        } catch (Throwable unused) {
            Log.v(f28121h, "initPDFView method found error");
        }
        if (!this.f28142z) {
            a();
            d();
        }
    }

    public void insertHandWriteAnnotation(int i10, float f10, float f11, float f12, float f13, String str, String str2, String str3, String str4) {
        insertHandWriteAnnotation(i10, f10, f11, f12, f13, str, str2, str3, 1, str4);
    }

    protected void insertHandWriteAnnotationWithPNG(int i10, float f10, float f11, float f12, float f13, String str, Bitmap bitmap, String str2, String str3) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        RectF pageBounds2 = pDFEditManager.getPageBounds(i10);
        int width = (int) pageBounds2.width();
        int height = (int) pageBounds2.height();
        int pageRotate = this.pdfEditManager.getPageRotate(i10);
        if (pageRotate != 0) {
            if (pageRotate != 90) {
                if (pageRotate != 180) {
                    if (pageRotate == 270) {
                        this.pdfEditManager.insertImageByPosBatWithPNG(str, i10, (width - f11) - f13, (height - f10) - f12, f13, f12, bitmap.getWidth(), bitmap.getHeight(), str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), a(bitmap), 8);
                        return;
                    }
                    return;
                }
                this.pdfEditManager.insertImageByPosBatWithPNG(str, i10, (width - f10) - f12, f11, f12, f13, bitmap.getWidth(), bitmap.getHeight(), str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), a(bitmap), 8);
                return;
            }
            this.pdfEditManager.insertImageByPosBatWithPNG(str, i10, f11, f10, f13, f12, bitmap.getWidth(), bitmap.getHeight(), str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), a(bitmap), 8);
            return;
        }
        this.pdfEditManager.insertImageByPosBatWithPNG(str, i10, f10, (height - f13) - f11, f12, f13, bitmap.getWidth(), bitmap.getHeight(), str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), a(bitmap), 8);
    }

    public void insertImageByPosWithType(int i10, File file, float f10, float f11, float f12, float f13, String str) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.insertImageByPosWithType(i10, file, f10, f11, f12, f13, str);
    }

    public void insertLineByPos(float f10, float f11, float f12, float f13) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.insertLineByPos(getCurrentPageNo(), f10, f11, f12, f13, userName);
    }

    public void insertPhotoIntoPDF(String str, String str2) {
        if (new File(str).exists()) {
            if (progressBarStatus == 0) {
                String str3 = null;
                try {
                    str3 = new String(str2.getBytes(), "UTF-8");
                } catch (UnsupportedEncodingException e10) {
                    e10.printStackTrace();
                }
                PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
                this.pdfEditManager = pDFEditManager;
                if (pDFEditManager.hasFieldInDocument(str3) != 1) {
                    this.pdfEditManager.insertImageInField(str, str2, false);
                    return;
                } else {
                    Toast.makeText(this.f28125i, "该文档没有图片域,无法做图片插入操作!", 0).show();
                    return;
                }
            }
            return;
        }
        Log.d("Kevin", "图片文件不存在!");
    }

    public void insertRectByPos(float f10, float f11, float f12, float f13) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.insertRectByPos(getCurrentPageNo(), f10, f11, f12, f13, userName);
    }

    protected void insertSignatureInField(String str, float f10) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.insertImageInField(str, this.signatureField1, f10);
    }

    protected String insertSignatureInText(Bitmap bitmap, String str, float f10) {
        if (bitmap != null) {
            String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
            if (FileUtils.saveImage(bitmap, pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null)) {
                float width = bitmap.getWidth() * f10;
                float height = bitmap.getHeight() * f10;
                if (this.pdfEditManager == null) {
                    this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
                }
                this.pdfEditManager.insertImageInText(pdfWriteImagePath, str, width, height);
                return pdfWriteImagePath;
            }
        }
        return null;
    }

    protected void insertSoundAnnotation(String str, int i10, float f10, float f11, String str2, byte[] bArr, int i11, int i12, int i13, String str3) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        RectF pageBounds2 = pDFEditManager.getPageBounds(i10);
        int width = (int) pageBounds2.width();
        int height = (int) pageBounds2.height();
        int pageRotate = this.pdfEditManager.getPageRotate(i10);
        if (pageRotate != 0) {
            if (pageRotate != 90) {
                if (pageRotate != 180) {
                    if (pageRotate == 270) {
                        this.pdfEditManager.insertSoundByPosNewBat(str, i10, (width - f11) - 10.0f, (height - 9) - f10, str2, bArr, i11, i12, i13, CommonMethodAndStringUtil.formatDateTimeToPDF(str3));
                        return;
                    }
                    return;
                }
                this.pdfEditManager.insertSoundByPosNewBat(str, i10, (width - f10) - 10.0f, f11 + 9.0f, str2, bArr, i11, i12, i13, CommonMethodAndStringUtil.formatDateTimeToPDF(str3));
                return;
            }
            this.pdfEditManager.insertSoundByPosNewBat(str, i10, f11 + 9.0f, 10.0f + f10, str2, bArr, i11, i12, i13, CommonMethodAndStringUtil.formatDateTimeToPDF(str3));
            return;
        }
        this.pdfEditManager.insertSoundByPosNewBat(str, i10, f10 + 10.0f, (height - 9) - f11, str2, bArr, i11, i12, i13, CommonMethodAndStringUtil.formatDateTimeToPDF(str3));
    }

    protected void insertTextAnnotation(int i10, float f10, float f11, String str, String str2, String str3, String str4, String str5) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        RectF pageBounds2 = pDFEditManager.getPageBounds(i10);
        int width = (int) pageBounds2.width();
        int height = (int) pageBounds2.height();
        int pageRotate = this.pdfEditManager.getPageRotate(i10);
        if (pageRotate != 0) {
            if (pageRotate != 90) {
                if (pageRotate != 180) {
                    if (pageRotate == 270) {
                        this.pdfEditManager.insertAnnotByPosBat(str2, str, i10, (width - f11) - 10.0f, (height - 9) - f10, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), str4, str5);
                        return;
                    }
                    return;
                }
                this.pdfEditManager.insertAnnotByPosBat(str2, str, i10, (width - f10) - 10.0f, f11 + 9.0f, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), str4, str5);
                return;
            }
            this.pdfEditManager.insertAnnotByPosBat(str2, str, i10, f11 + 9.0f, f10 + 10.0f, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), str4, str5);
            return;
        }
        this.pdfEditManager.insertAnnotByPosBat(str2, str, i10, 10.0f + f10, (height - 9) - f11, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), str4, str5);
    }

    public void insertVectorAnnotation(int i10, float f10, float f11, float f12, float f13, String str, String str2, String str3, int i11, String str4) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        RectF pageBounds2 = pDFEditManager.getPageBounds(i10);
        int width = (int) pageBounds2.width();
        int height = (int) pageBounds2.height();
        int pageRotate = this.pdfEditManager.getPageRotate(i10);
        if (pageRotate != 0) {
            if (pageRotate != 90) {
                if (pageRotate != 180) {
                    if (pageRotate == 270) {
                        this.pdfEditManager.insertVectorByPosBat(str, i10, (width - f11) - f13, (height - f10) - f12, f13, f12, str2, "", CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
                        return;
                    }
                    return;
                }
                this.pdfEditManager.insertVectorByPosBat(str, i10, (width - f10) - f12, f11, f12, f13, str2, "", CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
                return;
            }
            this.pdfEditManager.insertVectorByPosBat(str, i10, f11, f10, f13, f12, str2, "", CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
            return;
        }
        this.pdfEditManager.insertVectorByPosBat(str, i10, f10, (height - f13) - f11, f12, f13, str2, "", CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
    }

    protected void insertVectorAnnotationForNew(int i10, float f10, float f11, float f12, float f13, String str, String str2, String str3, int i11, String str4) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.insertVectorByPosForNew(str, i10, f10, f11, f12, f13, str2, "", CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
    }

    protected boolean isDocumentModified() {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (this.pdfEditManager.isDocumentModified() == 0) {
            return false;
        }
        return true;
    }

    public void jumpToPage(int i10) {
        getController().jumpToPage(i10, 0.0f, 0.0f, false);
    }

    protected void loadFieldTemplates() {
    }

    public void lockScreen() {
        boolean z10 = false;
        if (getController().getBookSettings().rotation != BookRotationType.UNSPECIFIED) {
            this.canLockScreen = false;
            return;
        }
        this.canLockScreen = true;
        Display defaultDisplay = getWindowManager().getDefaultDisplay();
        if (defaultDisplay.getWidth() < defaultDisplay.getHeight()) {
            z10 = true;
        }
        if (z10) {
            SettingsManager.setBookRotation(getController().getBookSettings(), BookRotationType.PORTRAIT);
        } else {
            SettingsManager.setBookRotation(getController().getBookSettings(), BookRotationType.LANDSCAPE);
        }
    }

    public void movePennable(float f10, float f11, float f12, boolean z10) {
    }

    @Override
    @SuppressLint({"UseSparseArrays"})
    public void onCreateImpl(Bundle bundle) {
        boolean z10;
        pageRatotes = new HashMap<>();
        docRatotes = new HashMap();
        pageBounds = new HashMap<>();
        docBounds = new HashMap();
        pageHandles = new HashMap<>();
        docHandles = new HashMap();
        progressBarStatus = 0;
        Display defaultDisplay = getWindowManager().getDefaultDisplay();
        DisplayMetrics displayMetrics = DM;
        defaultDisplay.getMetrics(displayMetrics);
        this.screenHeight = displayMetrics.heightPixels;
        this.screenWidth = displayMetrics.widthPixels;
        densityCoefficient = displayMetrics.density;
        Log.v("tbz", "screen denisity is " + displayMetrics.density + "screen width = " + this.screenWidth + ", height = " + this.screenHeight);
        this.f28125i = this;
        this.f28140x = getResources();
        this.f28141y = getPackageName();
        a(getFilesDir() + "/iAppPDF");
        c();
        if (getIntent().hasExtra("NEEDCRASH")) {
            z10 = getIntent().getBooleanExtra("NEEDCRASH", false);
        } else {
            z10 = false;
        }
        if (!z10) {
            CrashHandler crashHandler2 = CrashHandler.getInstance();
            crashHandler = crashHandler2;
            crashHandler2.init(this.f28125i, String.valueOf(KinggridConstant.FILEDIR_PATH) + "/log/", "");
        }
        f28120e = new b();
        b();
        this.view = ViewStub.STUB;
        if (getIntent().hasExtra("ONLYREAD")) {
            this.f28142z = getIntent().getBooleanExtra("ONLYREAD", false);
        }
    }

    @Override
    public void onDestroyImpl(boolean z10) {
        this.view.onDestroy();
    }

    @Override
    protected void onPauseImpl(boolean z10) {
        IUIManager.instance.onPause(this);
    }

    @Override
    protected void onPostCreateImpl(Bundle bundle) {
        super.onPostCreateImpl(bundle);
    }

    @Override
    public void onResumeImpl() {
        IUIManager.instance.onResume(this);
    }

    @Override
    public void onStartImpl() {
        super.onStartImpl();
    }

    public void openAreaHandwrite(Context context) {
        if (this.f28142z) {
            Toast.makeText(context, "当前版本为只读版本...", 0).show();
            return;
        }
        AreaView areaView = this.I;
        if (areaView != null) {
            this.f28136t.removeView(areaView);
        }
        int height = this.view.getHeight();
        int width = this.view.getWidth();
        if (pageViewMode == PageViewMode.VSCROLL && getPageCount() == 1) {
            RectF bounds = ViewState.get(getController().getDocumentController()).getBounds(getController().getDocumentModel().getCurrentPageObject());
            if (bounds.height() < this.screenHeight) {
                height = (int) bounds.height();
            }
        }
        AreaView areaView2 = new AreaView(context, this.view.getView(), width, height);
        this.I = areaView2;
        this.f28136t.addView(areaView2);
    }

    public void openFingerAnnotation() {
        setAnnotOpeFalse();
        isFinger = true;
        if (!this.isEbenT9) {
            Toast.makeText(this, "请点击需要插入指纹批注的位置!", 0).show();
        }
    }

    public void openHandwriteAnnotation(View view, PDFHandWriteView pDFHandWriteView) {
        if (this.f28142z) {
            Toast.makeText(this.f28125i, "当前版本为只读版本...", 0).show();
            return;
        }
        if (!this.isSupportEbenT7Mode && !this.isUseEbenSDK && pDFHandWriteView != null) {
            pDFHandWriteView.setCopyRight(this, this.copyRight);
            if (pageViewMode == PageViewMode.VSCROLL) {
                pDFHandWriteView.setHandwriteBounds(k());
            }
            this.f28136t.addView(view);
            this.isLocked = true;
            lockScreen();
            float penWidth = pDFHandWriteView.getPenWidth();
            int penColor = pDFHandWriteView.getPenColor();
            int penType = pDFHandWriteView.getPenType();
            pDFHandWriteView.setPenColor(penColor);
            pDFHandWriteView.setPenSize(penWidth);
            pDFHandWriteView.setPenType(penType);
        }
    }

    public void openLocatePerforationSignature(Bitmap bitmap) {
        a(bitmap, 2, -1, false, a(0.0f, bitmap));
    }

    public void openLocateSignature(Bitmap bitmap) {
        a(bitmap, 0, false, a(4.0f, bitmap));
    }

    public void openPNGLocateSignature(Bitmap bitmap, RectF rectF) {
        if (rectF == null) {
            rectF = a(0.0f, bitmap);
        }
        a(bitmap, 0, true, rectF);
    }

    public void openSoundAnnotation() {
        setAnnotOpeFalse();
        isSound = true;
        if (!this.isEbenT9) {
            Toast.makeText(this, "请点击需要插入语音批注的位置!", 0).show();
        }
    }

    public void openTextAnnotation() {
        setAnnotOpeFalse();
        isAnnotation = true;
        if (!this.isEbenT9) {
            Toast.makeText(this, "请点击需要插入注释的位置!", 0).show();
        }
    }

    public synchronized Bitmap pageToBitmap(int i10) {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        Page currentPageObject = getController().getDocumentModel().getCurrentPageObject();
        ViewState viewState = ViewState.get(getController().getDocumentController());
        RectF bounds = currentPageObject.getBounds(1.0f);
        RectF rectF = new RectF(0.0f, 0.0f, 1.0f, 1.0f);
        if (i10 < pageCount) {
            return ((MuPdfPage) muPdfDocument.getPage(i10)).renderBitmap(viewState, (int) bounds.width(), (int) bounds.height(), rectF).toBitmap().getBitmap();
        }
        return null;
    }

    protected synchronized ArrayList<Bitmap> pagesToBitmaps() {
        ArrayList<Bitmap> arrayList;
        arrayList = new ArrayList<>();
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        Page currentPageObject = getController().getDocumentModel().getCurrentPageObject();
        ViewState viewState = ViewState.get(getController().getDocumentController());
        RectF bounds = currentPageObject.getBounds(1.0f);
        RectF rectF = new RectF(0.0f, 0.0f, 1.0f, 1.0f);
        for (int i10 = 1; i10 <= pageCount; i10++) {
            arrayList.add(((MuPdfPage) muPdfDocument.getPage(i10 - 1)).renderBitmap(viewState, (int) bounds.width(), (int) bounds.height(), rectF).toBitmap().getBitmap());
        }
        return arrayList;
    }

    public void printDocument(int i10, int i11) {
        ((PrintManager) getSystemService("print")).print("iAppPDF Document", new MyPrintDocumentAdapter(this, getPageCount()), new PrintAttributes.Builder().build());
    }

    public void printDocumentByShare() {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setPackage("com.dynamixsoftware.printershare");
        intent.setDataAndType(Uri.fromFile(new File(getIntent().getData().getPath())), "application/pdf");
        startActivity(intent);
    }

    public void refreshDocument() {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.refreshDocument();
    }

    protected void refreshPage(int i10) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.refreshPage(i10);
    }

    public void removeAnnotRect() {
        MyRectView myRectView = this.rectView;
        if (myRectView != null) {
            this.f28136t.removeView(myRectView);
            this.rectView = null;
        }
    }

    public void removeThumnailsView() {
        LinearLayout linearLayout = this.P;
        if (linearLayout != null && linearLayout.isShown()) {
            this.f28136t.removeView(this.P);
            this.P = null;
        }
    }

    public void reopenDocument(IAppPDFActivity iAppPDFActivity, Uri uri, String str) {
        getController().afterCreate(iAppPDFActivity, uri);
        getController().startDecoding(str);
    }

    public boolean saveAsDocument(String str) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (this.pdfEditManager.saveAsDocument(str) == -1) {
            return false;
        }
        Intent intent = new Intent(KinggridConstant.BROADCAST_SAVEAS);
        intent.putExtra("filePath", str);
        intent.setFlags(32);
        sendBroadcast(intent);
        return true;
    }

    public boolean saveDocument() {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.saveDocument();
        Intent intent = new Intent(KinggridConstant.BROADCAST_SAVE);
        intent.putExtra("success", "TRUE");
        intent.putExtra("userName", userName);
        intent.putExtra("fileName", fileName);
        intent.setFlags(32);
        sendBroadcast(intent);
        return true;
    }

    public void savePDFReadSettings() {
        SettingsManager.storeBookSettings(getController().getBookSettings());
    }

    public void scroll(int i10, int i11) {
        this.view.startPageScroll(0, i11);
    }

    public void scrollTo(int i10, int i11, boolean z10) {
        if (z10) {
            getController().getView().forceFinishScroll();
        }
        getController().getView().scrollTo(i10, i11);
    }

    public void searchText(String str) {
        DecodeServiceBase.isNeedHighlight = false;
        getController().searchText(str, "false");
    }

    public void selectText(float f10, float f11, float f12, float f13, LinkedList<PageText> linkedList, LinkedList<PageText> linkedList2, float f14, float f15) {
        if (this.F.getVisibility() != 0) {
            this.F.setVisibility(0);
        }
        Iterator<PageText> it = linkedList.iterator();
        while (it.hasNext()) {
            PageText next = it.next();
            if (!TextUtils.isEmpty(next.getCodeValue()) && !next.getCodeValue().equals(" ")) {
                float height = next.getCodeRectF().top + (next.getCodeRectF().height() / 2.0f);
                RectF rectF = new RectF(next.getCodeRectF().left, height - 5.0f, next.getCodeRectF().right, height + 5.0f);
                RectF rectF2 = new RectF(0.0f, f14, actWidth, f15);
                boolean contains = new RectF(rectF2).contains(rectF);
                boolean intersect = new RectF(rectF2).intersect(rectF);
                if (contains) {
                    linkedList2.add(next);
                } else if (intersect && (rectF.right <= f12 || rectF.bottom <= f13)) {
                    if (rectF.left >= f10 || rectF.top >= f11) {
                        linkedList2.add(next);
                    }
                }
            }
        }
    }

    public void setAllAnnotationsOnlyRead(boolean z10) {
        a(z10, "", "");
    }

    protected void setAllAnnotationsVisible(boolean z10) {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        for (int i10 = 0; i10 < pageCount; i10++) {
            MuPdfDocument.setAllAnnotVisibleInPage(muPdfDocument.getDocumentHandle(), i10, z10);
        }
    }

    protected void setAllFieldVisibleInPage(String str, boolean z10) {
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = muPdfDocument.getPageCount();
        for (int i10 = 0; i10 < pageCount; i10++) {
            MuPdfDocument.setAllFieldVisibleInPage(muPdfDocument.getDocumentHandle(), i10, str, z10);
        }
    }

    public void setAnnotOpeFalse() {
        isSound = false;
        isAnnotation = false;
        isFinger = false;
    }

    public void setAnnotationsOnlyRead(boolean z10, String str) {
        a(z10, str, "");
    }

    protected void setAnnotationsVisible(boolean z10, String str) {
        String str2;
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        for (int i10 = 0; i10 < pageCount; i10++) {
            long[] annotations = MuPdfDocument.getAnnotations(this.pdfEditManager.getPageHandle(i10), str);
            for (int i11 = 0; i11 < annotations.length; i11++) {
                String annotInfo = MuPdfDocument.getAnnotInfo(annotations[i11]);
                if (TextUtils.isEmpty(annotInfo)) {
                    str2 = "";
                } else {
                    str2 = this.pdfEditManager.parseAnnotInfo2String(annotInfo)[1];
                }
                if (str2.equals("")) {
                    str2 = MuPdfDocument.getAnnotAuthor(annotations[i11]);
                }
                if (!str2.equals("")) {
                    if (z10) {
                        MuPdfDocument.setAnnotFlag(annotations[i11], 0);
                    } else {
                        MuPdfDocument.setAnnotFlag(annotations[i11], 2);
                    }
                }
            }
            this.pdfEditManager.updatePage(i10);
        }
    }

    protected void setCheckFieldState(String str, int i10) {
        String str2;
        try {
            str2 = new String(str.getBytes(), "UTF-8");
        } catch (Exception e10) {
            e10.printStackTrace();
            str2 = null;
        }
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        long hasFieldInDocument = pDFEditManager.hasFieldInDocument(str2);
        if (hasFieldInDocument != 1) {
            this.pdfEditManager.setCheckFieldState(i10, hasFieldInDocument);
            return;
        }
        Log.d("Kevin", "checkbox field : " + str + " not found ");
    }

    public void setField(String str) {
        this.field = str;
    }

    protected void setFieldContent(String str, String str2) {
        String str3;
        try {
            str3 = new String(str.getBytes(), "UTF-8");
        } catch (Exception e10) {
            e10.printStackTrace();
            str3 = null;
        }
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        long hasFieldInDocument = pDFEditManager.hasFieldInDocument(str3);
        if (hasFieldInDocument != 1) {
            this.pdfEditManager.setFieldContent(hasFieldInDocument, str2);
            return;
        }
        Log.d("Kevin", "text field : " + str + " not found ");
    }

    public void setFont(String[] strArr) {
        fonts = strArr;
    }

    public void setLoadingText(int i10) {
        this.msgLoadingStringId = i10;
    }

    public void setLongTouchAnnotListener(LongTouchAnnotListener longTouchAnnotListener) {
        this.onLongTouchAnnotListener = longTouchAnnotListener;
    }

    public void setLongTouchAnnotState(LongTouchAnnotState longTouchAnnotState) {
        this.G = longTouchAnnotState;
    }

    public void setLongTouchTime(float f10) {
        this.T = f10;
    }

    public void setOnDelDifUserListener(DelDifUserListener delDifUserListener) {
        this.delDifUserListener = delDifUserListener;
    }

    public void setOnLocalSignatureListener(OnLocalSignatureListener onLocalSignatureListener) {
        this.onLocalSignatureListener = onLocalSignatureListener;
    }

    public void setOnMuPdfExceptionListener(OnMuPdfExceptionListener onMuPdfExceptionListener) {
        this.mupdfExceptionListener = onMuPdfExceptionListener;
    }

    public void setOnPageChangeListener(OnPageChangeListener onPageChangeListener) {
        this.f28137u = onPageChangeListener;
    }

    public void setOnPageLongPressListener(OnPageLongPressListener onPageLongPressListener) {
        this.onPageLongPressListener = onPageLongPressListener;
    }

    public void setOnScrollChangeListener(OnScrollChangeListener onScrollChangeListener) {
        this.L = onScrollChangeListener;
    }

    public void setOnSelectStateListener(SelectStateListener selectStateListener) {
        this.isLongTouchSelectState = true;
        this.onSelectStateListener = selectStateListener;
    }

    public void setOnSignatureListener(OnSignatureListener onSignatureListener) {
        this.K = onSignatureListener;
    }

    public void setOnSynchronizationOptionListener(OnSynchronizationOptionListener onSynchronizationOptionListener) {
        this.synchronizationOptionListener = onSynchronizationOptionListener;
    }

    public void setOnTouchKGSignatureListener(OnTouchKGSignatureListener onTouchKGSignatureListener) {
        this.touchKGSignatureListener = onTouchKGSignatureListener;
    }

    public void setOnTouchReadOnlyListener(TouchReadOnlyListener touchReadOnlyListener) {
        this.touchReadOnlyListener = touchReadOnlyListener;
    }

    public void setOnVerifyKGSignatureCompleteListener(OnVerifyKGSignatureCompleteListener onVerifyKGSignatureCompleteListener) {
        this.verifyKGSignatureCompleteListener = onVerifyKGSignatureCompleteListener;
    }

    public void setOnViewTouchAddAnnotListener(OnViewTouchAddAnnotListener onViewTouchAddAnnotListener) {
        this.viewTouchAddAnnotListener = onViewTouchAddAnnotListener;
    }

    public void setOnViewTouchShowAnnotListener(OnViewTouchShowAnnotListener onViewTouchShowAnnotListener) {
        this.viewTouchShowAnnotListener = onViewTouchShowAnnotListener;
    }

    public void setPageListenerFlag() {
        if (!this.f28138v) {
            this.f28138v = true;
        }
    }

    public void setPageZoom(float f10) {
        getController().getZoomModel().setZoom(f10);
        getController().getZoomModel().commit();
    }

    protected void setRadioFieldState(String str, int i10, int i11) {
        try {
            new String(str.getBytes(), "UTF-8");
        } catch (Exception e10) {
            e10.printStackTrace();
        }
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        long[] fieldsInPage = MuPdfDocument.getFieldsInPage(pDFEditManager.getPageHandle(i11), str);
        if (fieldsInPage != null) {
            this.pdfEditManager.setCheckFieldState(i11, fieldsInPage[i10]);
            return;
        }
        Log.d("Kevin", "radio field : " + str + " not found ");
    }

    public void setScreenLand() {
        SettingsManager.setBookRotation(getController().getBookSettings(), BookRotationType.LANDSCAPE);
    }

    public void setScreenPort() {
        SettingsManager.setBookRotation(getController().getBookSettings(), BookRotationType.PORTRAIT);
    }

    public void setSelectText(LinkedList<PageText> linkedList) {
        this.S = linkedList;
    }

    public void showAnnotInfo(String[] strArr, String str) {
    }

    public void showAnnotRect(Annotation annotation) {
        float j10;
        float f10;
        float f11;
        float f12;
        float f13;
        float f14;
        removeAnnotRect();
        float[] a10 = a(Integer.valueOf(annotation.getPageNo()).intValue() - 1, MuPdfDocument.getAnnotRect(annotation.getAnnotHandle()));
        float f15 = a10[0];
        float f16 = a10[1];
        float f17 = a10[2];
        float f18 = a10[3];
        String annotSubType = MuPdfDocument.getAnnotSubType(annotation.getAnnotHandle());
        if (!annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT) && !annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SOUND)) {
            f14 = f15;
            f12 = f16;
            f13 = f17;
            f11 = f18;
        } else {
            float f19 = 0.0f;
            if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
                float f20 = a10[0];
                if (f20 - 5.0f >= 0.0f) {
                    j10 = f20 - 5.0f;
                    f10 = a10[1];
                    if (f10 - 5.0f >= 0.0f) {
                        f19 = f10 - 5.0f;
                    }
                    float f21 = a10[2] + 5.0f;
                    f11 = a10[3] + 5.0f;
                    f12 = f19;
                    f13 = f21;
                    f14 = j10;
                }
                j10 = 0.0f;
                f10 = a10[1];
                if (f10 - 5.0f >= 0.0f) {
                }
                float f212 = a10[2] + 5.0f;
                f11 = a10[3] + 5.0f;
                f12 = f19;
                f13 = f212;
                f14 = j10;
            } else {
                if ((a10[0] - 5.0f) - j() >= 0.0f) {
                    j10 = (a10[0] - 5.0f) - j();
                    f10 = a10[1];
                    if (f10 - 5.0f >= 0.0f) {
                    }
                    float f2122 = a10[2] + 5.0f;
                    f11 = a10[3] + 5.0f;
                    f12 = f19;
                    f13 = f2122;
                    f14 = j10;
                }
                j10 = 0.0f;
                f10 = a10[1];
                if (f10 - 5.0f >= 0.0f) {
                }
                float f21222 = a10[2] + 5.0f;
                f11 = a10[3] + 5.0f;
                f12 = f19;
                f13 = f21222;
                f14 = j10;
            }
        }
        MyRectView myRectView = new MyRectView(this, f14, f12, f13, f11, false, ((GLView) this.view).getWidth(), ((GLView) this.view).getHeight());
        this.rectView = myRectView;
        this.f28136t.addView(myRectView);
    }

    public void showCertificateInfo(String[] strArr) {
    }

    public void showSignatureRect(KGSignature kGSignature) {
        float j10;
        removeAnnotRect();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        float[] a10 = a(kGSignature.getPageNo() - 1, this.pdfEditManager.getFieldRect(kGSignature.getFieldHandle()));
        float f10 = a10[0];
        float f11 = a10[1];
        float f12 = a10[2];
        float f13 = a10[3];
        float f14 = 0.0f;
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            float f15 = a10[0];
            if (f15 - 5.0f >= 0.0f) {
                j10 = f15 - 5.0f;
            }
            j10 = 0.0f;
        } else {
            if ((a10[0] - 5.0f) - j() >= 0.0f) {
                j10 = (a10[0] - 5.0f) - j();
            }
            j10 = 0.0f;
        }
        float f16 = j10;
        float f17 = a10[1];
        if (f17 - 5.0f >= 0.0f) {
            f14 = f17 - 5.0f;
        }
        MyRectView myRectView = new MyRectView(this, f16, f14, a10[2] + 5.0f, 5.0f + a10[3], false, this.view.getWidth(), this.view.getHeight());
        this.rectView = myRectView;
        this.f28136t.addView(myRectView);
    }

    public void showThumnailsView(final int i10, View view, View view2, int i11, final int i12, final boolean z10) {
        LinearLayout linearLayout = this.P;
        if (linearLayout != null && linearLayout.isShown()) {
            return;
        }
        float f10 = i10;
        int i13 = ((int) (this.screenWidth / f10)) + 2;
        Log.d("tbz", "count = " + i13);
        int currentDocPageIndex = getController().getDocumentModel().getCurrentDocPageIndex() - (i13 / 2);
        this.B = currentDocPageIndex;
        if (currentDocPageIndex < 0) {
            this.B = 0;
        }
        int i14 = i13 * 3;
        int i15 = this.B + i14;
        this.C = i15;
        if (i15 > getPageCount() - 1) {
            int pageCount = getPageCount() - 1;
            this.C = pageCount;
            if (pageCount - this.B < i14) {
                this.B = 0;
            }
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                iAppPDFActivity.thumnails = iAppPDFActivity.a(i10, iAppPDFActivity.B, IAppPDFActivity.this.C);
                Message message = new Message();
                message.what = 48;
                message.arg1 = i12;
                IAppPDFActivity.this.f28122d.sendMessage(message);
            }
        }).start();
        RectF bounds = getController().getDocumentModel().getCurrentPageObject().getBounds(1.0f);
        MyHorizontalScrollView myHorizontalScrollView = new MyHorizontalScrollView(this, this.B, (int) ((f10 * bounds.height()) / bounds.width()), i11);
        this.thumnailView = myHorizontalScrollView;
        myHorizontalScrollView.setOnItemClickListener(new MyHorizontalScrollView.OnItemClickListener() {
            @Override
            public void onClick(View view3, int i16) {
                IAppPDFActivity.this.jumpToPage(i16);
                if (z10) {
                    IAppPDFActivity.this.removeThumnailsView();
                }
            }
        });
        this.thumnailView.setOnCurrentItemChangeListener(new MyHorizontalScrollView.OnCurrentItemChangeListener() {
            @Override
            public void onCurrentItemChanged(boolean z11) {
                if (z11) {
                    if (IAppPDFActivity.this.C < IAppPDFActivity.this.getPageCount() - 1) {
                        IAppPDFActivity.this.C++;
                    }
                } else if (IAppPDFActivity.this.B > 0) {
                    IAppPDFActivity.this.B--;
                }
                Log.d("tbz", "firstThumnailIndex = " + IAppPDFActivity.this.B + ", lastThumnailIndex = " + IAppPDFActivity.this.C);
                for (final int i16 = IAppPDFActivity.this.B; i16 <= IAppPDFActivity.this.C; i16++) {
                    if (IAppPDFActivity.this.thumnails.get(i16) == null) {
                        if (IAppPDFActivity.progressBarStatus == 1) {
                            return;
                        }
                        final int i17 = i10;
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                IAppPDFActivity.this.thumnails.put(i16, IAppPDFActivity.this.b(i17, i16));
                                IAppPDFActivity.this.A.updateData(IAppPDFActivity.this.thumnails);
                            }
                        }).start();
                    }
                }
            }
        });
        this.thumnailView.showProgressView(view);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -2);
        LinearLayout linearLayout2 = new LinearLayout(this.f28125i);
        this.P = linearLayout2;
        linearLayout2.setOrientation(1);
        layoutParams.gravity = 80;
        this.P.setLayoutParams(layoutParams);
        LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-2, -2);
        layoutParams2.gravity = 5;
        view2.setLayoutParams(layoutParams2);
        this.P.addView(view2);
        this.P.addView(this.thumnailView);
        this.f28136t.addView(this.P);
    }

    public void showToastText(int i10, int i11, Object... objArr) {
        Toast.makeText(getApplicationContext(), getResources().getString(i11, objArr), i10).show();
    }

    public void showVectorDialog() {
        if (this.f28139w == null) {
            RelativeLayout relativeLayout = new RelativeLayout(this.f28125i);
            this.f28139w = relativeLayout;
            relativeLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
            layoutParams.addRule(13);
            ProgressBar progressBar = new ProgressBar(this.f28125i);
            this.insert_progress = progressBar;
            progressBar.setLayoutParams(layoutParams);
            this.f28139w.addView(this.insert_progress);
            this.f28136t.addView(this.f28139w);
        }
    }

    public void showVerifyOrDeleteBtn(final int i10, final long j10) {
        PopupWindow popupWindow = this.Q;
        if (popupWindow != null && popupWindow.isShowing()) {
            return;
        }
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
        LinearLayout linearLayout = new LinearLayout(this.f28125i);
        linearLayout.setLayoutParams(layoutParams);
        linearLayout.setOrientation(1);
        layoutParams.gravity = 17;
        float f10 = densityCoefficient;
        layoutParams.bottomMargin = (int) (f10 * (-3.0f));
        layoutParams.topMargin = (int) (f10 * (-3.0f));
        Button button = new Button(this.f28125i);
        button.setLayoutParams(layoutParams);
        button.setTextSize(18.0f);
        button.setTextColor(ViewCompat.MEASURED_STATE_MASK);
        button.setText("验证签章");
        float f11 = densityCoefficient;
        button.setPadding((int) (f11 * 16.0f), (int) (f11 * 8.0f), (int) (f11 * 16.0f), (int) (f11 * 8.0f));
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (IAppPDFActivity.this.Q.isShowing()) {
                    IAppPDFActivity.this.Q.dismiss();
                }
                IAppPDFActivity.this.pdfEditManager.verifyKGSignature(i10, j10);
            }
        });
        linearLayout.addView(button);
        String keySN = this.pdfEditManager.getKeySN(j10);
        Log.d("tbz", "annotKeySN = " + keySN);
        String str = this.keySN;
        if (str != null && keySN != null && str.equals(keySN)) {
            Button button2 = new Button(this.f28125i);
            button2.setLayoutParams(layoutParams);
            button2.setTextSize(18.0f);
            button2.setTextColor(ViewCompat.MEASURED_STATE_MASK);
            button2.setText("撤销签章");
            float f12 = densityCoefficient;
            button2.setPadding((int) (f12 * 16.0f), (int) (f12 * 8.0f), (int) (16.0f * f12), (int) (f12 * 8.0f));
            button2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (IAppPDFActivity.this.Q.isShowing()) {
                        IAppPDFActivity.this.Q.dismiss();
                    }
                    if (IAppPDFActivity.this.pdfEditManager.isLastKGSignature(j10)) {
                        IAppPDFActivity.this.pdfEditManager.deleteOneSignature(j10);
                        IAppPDFActivity.this.refreshPage(i10);
                    }
                }
            });
            linearLayout.addView(button2);
        }
        float[] a10 = a(i10, this.pdfEditManager.getAnnotRect(j10));
        PopupWindow popupWindow2 = new PopupWindow(linearLayout, -2, -2);
        this.Q = popupWindow2;
        popupWindow2.setBackgroundDrawable(new BitmapDrawable());
        this.Q.setOutsideTouchable(true);
        this.Q.setFocusable(true);
        this.Q.showAtLocation(this.f28136t, 51, (int) a10[2], (int) a10[3]);
    }

    public void showViewToPDF(View view) {
        this.f28136t.addView(view);
    }

    public void stopSearchText() {
        getController().closeSearch();
    }

    public void unLockScreen() {
        if (this.canLockScreen) {
            SettingsManager.setBookRotation(getController().getBookSettings(), BookRotationType.UNSPECIFIED);
            this.canLockScreen = false;
        }
    }

    public void update() {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        pDFEditManager.updateState();
    }

    public void updateAnnotRect(String str, int i10, float f10, float f11) {
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        for (int i11 = 0; i11 < pageCount; i11++) {
            long[] allAnnotations = MuPdfDocument.getAllAnnotations(pDFEditManager.getPageHandle(i11));
            for (int i12 = 0; i12 < allAnnotations.length; i12++) {
                if (str.equals(pDFEditManager.getAnnotId(allAnnotations[i12]))) {
                    pDFEditManager.updateSignatureRect(allAnnotations[i12], i10, f10, f11);
                }
            }
        }
    }

    public void updateTextAnnotContent(String str, String str2) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        for (int i10 = 0; i10 < pageCount; i10++) {
            long[] allAnnotations = MuPdfDocument.getAllAnnotations(this.pdfEditManager.getPageHandle(i10));
            for (int i11 = 0; i11 < allAnnotations.length; i11++) {
                if (str.equals(this.pdfEditManager.getAnnotId(allAnnotations[i11]))) {
                    this.pdfEditManager.updateAnnotContent(allAnnotations[i11], str2);
                }
            }
        }
    }

    public void verifySignature(int i10) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        long[] signatureFieldInPage = this.pdfEditManager.getSignatureFieldInPage(i10);
        if (signatureFieldInPage != null) {
            for (int i11 = 0; i11 < signatureFieldInPage.length; i11++) {
                long signature = MuPdfDocument.getSignature(signatureFieldInPage[i11]);
                if (signature != 0 && this.pdfEditManager.getSignatureSubfilter(signature).equals("adbe.pkcs7.detached")) {
                    int[] signatureByteRange = this.pdfEditManager.getSignatureByteRange(signature);
                    byte[] signatureContent = this.pdfEditManager.getSignatureContent(signature);
                    byte[] byteFromRange = getByteFromRange(signatureByteRange);
                    byte[] digest = SignatureTask.getInstance().digest(byteFromRange, byteFromRange.length);
                    int verifySignature = verifySignature(byteFromRange, signatureContent);
                    int verifySignature2 = verifySignature(digest, signatureContent);
                    if (verifySignature != 0 && verifySignature2 != 0) {
                        this.pdfEditManager.setSignatureInvalid(signatureFieldInPage[i11], 1);
                        if (i10 == -1) {
                            this.pdfEditManager.refreshDocument();
                        } else {
                            this.pdfEditManager.refreshPage(i10);
                        }
                    }
                }
            }
        }
    }

    public void windowToFullScreen() {
    }

    public void zoomChanged(float f10) {
        AppSettings current = AppSettings.current();
        if (current.getZoomToastPosition() != ToastPosition.Invisible && !this.isEbenT9) {
            String str = String.valueOf(String.format("%.2f", Float.valueOf(f10))) + "x";
            Toast toast = this.f28127k;
            if (toast != null) {
                toast.setText(str);
            } else {
                this.f28127k = Toast.makeText(this, str, 0);
            }
            this.f28127k.setGravity(current.getZoomToastPosition().position, 0, 0);
            this.f28127k.show();
        }
    }

    private void b() {
        RelativeLayout relativeLayout = new RelativeLayout(this.f28125i);
        this.f28129m = relativeLayout;
        relativeLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        this.f28129m.setVisibility(8);
        this.f28130n = new Button(this.f28125i);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
        layoutParams.topMargin = (int) (densityCoefficient * 88.0f);
        this.f28130n.setLayoutParams(layoutParams);
        this.f28130n.setBackgroundColor(-16776961);
        this.f28130n.setText("删除");
        this.f28130n.setTextColor(-1);
        this.f28129m.addView(this.f28130n);
        this.f28130n.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (IAppPDFActivity.this.D) {
                    if (IAppPDFActivity.this.K != null) {
                        OnSignatureListener onSignatureListener = IAppPDFActivity.this.K;
                        IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                        onSignatureListener.onClickDelBtn(iAppPDFActivity.keySN, iAppPDFActivity.E);
                    }
                    IAppPDFActivity.this.D = false;
                } else {
                    IAppPDFActivity iAppPDFActivity2 = IAppPDFActivity.this;
                    iAppPDFActivity2.pdfEditManager.deleteOneSignature(iAppPDFActivity2.currAnnotation);
                    IAppPDFActivity.this.pdfEditManager.refreshDocument();
                }
                IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.f28129m);
                IAppPDFActivity iAppPDFActivity3 = IAppPDFActivity.this;
                if (iAppPDFActivity3.f28123f != null) {
                    iAppPDFActivity3.f28136t.removeView(IAppPDFActivity.this.f28123f);
                }
                IAppPDFActivity iAppPDFActivity4 = IAppPDFActivity.this;
                if (iAppPDFActivity4.f28124g != null) {
                    iAppPDFActivity4.f28136t.removeView(IAppPDFActivity.this.f28124g);
                }
            }
        });
    }

    private void c() {
        String str = KinggridConstant.FILEDIR_PATH;
        File file = new File(str);
        if (!file.exists()) {
            file.mkdirs();
        }
        File file2 = new File(String.valueOf(str) + "/temppdf");
        if (!file2.exists()) {
            file2.mkdirs();
        }
        File file3 = new File(String.valueOf(str) + "/tempsignatures");
        if (!file3.exists()) {
            file3.mkdirs();
        }
        File file4 = new File(String.valueOf(str) + "/tempsounds");
        if (!file4.exists()) {
            file4.mkdirs();
        }
        File file5 = new File(String.valueOf(str) + "/tempphotos");
        if (!file5.exists()) {
            file5.mkdirs();
        }
        File file6 = new File(String.valueOf(str) + "/log");
        if (!file6.exists()) {
            file6.mkdirs();
        }
        File file7 = new File(String.valueOf(str) + "/commonsigns");
        if (file7.exists()) {
            return;
        }
        file7.mkdirs();
    }

    public void e() {
        BookSettings bookSettings = getController().getBookSettings();
        int i10 = bookSettings.getCurrentPage().docIndex + 1;
        RectF rectF = pageBounds.get(Integer.valueOf(i10));
        actWidth = rectF.right - rectF.left;
        actHeight = rectF.bottom - rectF.top;
        rotate = pageRatotes.get(Integer.valueOf(i10)).intValue();
        imagezoom = bookSettings.getZoom();
    }

    public void f() {
        RelativeLayout relativeLayout = this.f28139w;
        if (relativeLayout != null) {
            this.f28136t.removeView(relativeLayout);
            this.f28139w = null;
        }
    }

    private void g() {
        ProgressDialog progressDialog = new ProgressDialog(this);
        this.H = progressDialog;
        progressDialog.setMessage("签名需要一小会儿,请稍候...");
        this.H.setIndeterminate(true);
        this.H.setCancelable(false);
        this.H.show();
    }

    public void i() {
        if (this.f28129m.getVisibility() == 0) {
            this.f28129m.setVisibility(4);
        }
    }

    private float j() {
        return (this.view.getWidth() - (this.view.getHeight() * getController().getDocumentModel().getCurrentPageObject().getAspectRatio())) / 2.0f;
    }

    private List<Rect> k() {
        int i10;
        ArrayList arrayList = new ArrayList();
        DocumentModel documentModel = getController().getDocumentModel();
        Page currentPageObject = documentModel.getCurrentPageObject();
        ViewState viewState = ViewState.get(getController().getDocumentController());
        RectF bounds = viewState.getBounds(currentPageObject);
        int scrollY = this.view.getScrollY();
        float f10 = scrollY;
        int i11 = (int) (bounds.top - f10);
        int height = (int) (bounds.height() + i11);
        Point point = new Point();
        getWindowManager().getDefaultDisplay().getRealSize(point);
        float f11 = point.x;
        float f12 = point.y;
        if (i11 > 0) {
            int currentPageNo = getCurrentPageNo() - 1;
            while (true) {
                if (currentPageNo < 0) {
                    break;
                }
                RectF bounds2 = viewState.getBounds(documentModel.getPageObject(currentPageNo));
                int i12 = (int) (bounds2.top - f10);
                Log.d("tbz", "preTop = " + i12 + ", top = " + bounds2.top + ", scrollY = " + scrollY);
                if (i12 < 0) {
                    arrayList.add(new Rect(0, 0, (int) f11, ((int) bounds2.height()) + i12));
                    break;
                }
                arrayList.add(new Rect(0, i12, (int) f11, (int) (bounds2.height() + i12)));
                currentPageNo--;
            }
        } else {
            i11 = 0;
        }
        if (height < f12) {
            int currentPageNo2 = getCurrentPageNo();
            while (true) {
                currentPageNo2++;
                if (currentPageNo2 >= getPageCount()) {
                    i10 = 0;
                    break;
                }
                RectF bounds3 = viewState.getBounds(documentModel.getPageObject(currentPageNo2));
                int i13 = (int) (bounds3.bottom - f10);
                if (i13 > f12) {
                    i10 = 0;
                    arrayList.add(new Rect(0, ((int) bounds3.top) - scrollY, (int) f11, (int) f12));
                    break;
                }
                arrayList.add(new Rect(0, ((int) bounds3.top) - scrollY, (int) f11, i13));
            }
        } else {
            i10 = 0;
            height = (int) f12;
        }
        arrayList.add(i10, new Rect(i10, i11, (int) f11, height));
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            Log.d("tbz", "getPageBounds:r = " + ((Rect) it.next()));
        }
        return arrayList;
    }

    private synchronized String l() {
        String str = new String();
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        ArrayList arrayList = new ArrayList();
        int pageCount = muPdfDocument.getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        for (int i10 = 0; i10 < pageCount; i10++) {
            long pageHandle = this.pdfEditManager.getPageHandle(i10);
            long[] allAnnotations = MuPdfDocument.getAllAnnotations(pageHandle);
            for (int i11 = 0; i11 < allAnnotations.length; i11++) {
                String annotSubType = MuPdfDocument.getAnnotSubType(allAnnotations[i11]);
                Annotation annotation = new Annotation();
                if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT)) {
                    annotation.setAnnoContent(MuPdfDocument.getAnnotText(allAnnotations[i11]));
                } else {
                    annotation.setAnnoContent("");
                }
                annotation.setStyleName(annotSubType);
                float[] annotRectToUser = MuPdfDocument.getAnnotRectToUser(pageHandle, allAnnotations[i11]);
                annotation.setX(String.valueOf(annotRectToUser[0]));
                annotation.setY(String.valueOf(annotRectToUser[1]));
                annotation.setWidth(String.valueOf(annotRectToUser[2] - annotRectToUser[0]));
                annotation.setHeight(String.valueOf(annotRectToUser[3] - annotRectToUser[1]));
                arrayList.add(annotation);
            }
        }
        Log.v(f28121h, "annotationsList size = " + arrayList.size());
        for (int i12 = 0; i12 < arrayList.size(); i12++) {
            str = String.valueOf(str) + ((Annotation) arrayList.get(i12)).getX() + ((Annotation) arrayList.get(i12)).getY() + ((Annotation) arrayList.get(i12)).getWidth() + ((Annotation) arrayList.get(i12)).getHeight();
            if (((Annotation) arrayList.get(i12)).getStyleName().equals(KinggridConstant.ANNOT_SUBTYPE_TEXT)) {
                str = String.valueOf(str) + ((Annotation) arrayList.get(i12)).getAnnoContent();
            }
        }
        if (str.equals("")) {
            return str;
        }
        return CommonMethodAndStringUtil.MD5EncodeUtil.md5String(str);
    }

    @Override
    public ViewerActivityController createController() {
        return new ViewerActivityController(this);
    }

    public ArrayList<Annotation> getAnnotationList(String str, int i10) {
        return a(str, i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? "" : KinggridConstant.ANNOT_SUBTYPE_SOUND : KinggridConstant.ANNOT_SUBTYPE_SIGN : KinggridConstant.ANNOT_SUBTYPE_TEXT : KinggridConstant.ANNOT_SUBTYPE_STAMP);
    }

    protected ArrayList<Annotation> getAnnotationNewList(String str, int i10) {
        return getAnnotationsForList(str, i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? "" : KinggridConstant.ANNOT_SUBTYPE_SOUND : KinggridConstant.ANNOT_SUBTYPE_SIGN : KinggridConstant.ANNOT_SUBTYPE_TEXT : KinggridConstant.ANNOT_SUBTYPE_STAMP);
    }

    protected void insertHandWriteAnnotation(int i10, float f10, float f11, float f12, float f13, String str, String str2, String str3, int i11, String str4) {
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        this.pdfEditManager = pDFEditManager;
        RectF pageBounds2 = pDFEditManager.getPageBounds(i10);
        int width = (int) pageBounds2.width();
        int height = (int) pageBounds2.height();
        int pageRotate = this.pdfEditManager.getPageRotate(i10);
        if (pageRotate == 0) {
            this.pdfEditManager.insertImageByPosBat(str, i10, f10, (height - f13) - f11, f12, f13, str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
            return;
        }
        if (pageRotate == 90) {
            this.pdfEditManager.insertImageByPosBat(str, i10, f11, f10, f13, f12, str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
        } else if (pageRotate == 180) {
            this.pdfEditManager.insertImageByPosBat(str, i10, (width - f10) - f12, f11, f12, f13, str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
        } else {
            if (pageRotate != 270) {
                return;
            }
            this.pdfEditManager.insertImageByPosBat(str, i10, (width - f11) - f13, (height - f10) - f12, f13, f12, str2, CommonMethodAndStringUtil.formatDateTimeToPDF(str3), i11, str4);
        }
    }

    public void jumpToPage(int i10, float f10, float f11) {
        getController().jumpToPage(i10, f10, f11, false);
    }

    public void openLocateSignature(Bitmap bitmap, float f10) {
        a(bitmap, 0, false, a(f10, bitmap));
    }

    public void setAnnotationsOnlyRead(boolean z10, int i10) {
        a(z10, "", i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? "" : KinggridConstant.ANNOT_SUBTYPE_SOUND : KinggridConstant.ANNOT_SUBTYPE_SIGN : KinggridConstant.ANNOT_SUBTYPE_TEXT : KinggridConstant.ANNOT_SUBTYPE_STAMP);
    }

    public void closeAreaHandwrite(PDFHandWriteView pDFHandWriteView, boolean z10, EditText editText) {
        if (this.I == null) {
            return;
        }
        if (!pDFHandWriteView.isEmpty() && editText != null && editText.getText().length() != 0) {
            a(pDFHandWriteView, z10, true, editText);
        }
        this.f28136t.removeView(this.I);
    }

    public void openLocateSignature(Bitmap bitmap, float f10, int i10) {
        a(bitmap, 0, i10, false, a(f10, bitmap));
    }

    public void searchText(String str, boolean z10, int i10) {
        if (!TextUtils.isEmpty(str)) {
            DecodeServiceBase.isNeedHighlight = true;
            getController().setHeight(i10);
            if (z10) {
                getController().searchText(str, PdfBoolean.TRUE);
                return;
            } else {
                getController().searchText(str, "false");
                return;
            }
        }
        Log.e(f28121h, "search text is null");
    }

    public void openLocateSignature(Bitmap bitmap, float f10, boolean z10) {
        a(bitmap, 1, false, a(f10, bitmap));
    }

    private void a() {
        String str = "用户名:" + userName;
        final AppRegister appRegister = new AppRegister(this.f28125i, this.copyRight, "1", "", str, "http://" + this.offLineAuthUrl + "/WebAppServer/server.do") {
            @Override
            protected void onPostExecute(SparseArray<String> sparseArray) {
                String str2;
                String str3;
                super.onPostExecute(sparseArray);
                String[] split = sparseArray.valueAt(0).split(",");
                String str4 = "";
                if (split.length <= 0) {
                    str2 = "";
                } else {
                    str2 = split[0];
                }
                IAppPDFActivity.licType = str2;
                if (split.length <= 1) {
                    str3 = "";
                } else {
                    str3 = split[1];
                }
                IAppPDFActivity.companyName = str3;
                if (split.length > 2) {
                    str4 = split[2];
                }
                IAppPDFActivity.licTime = str4;
            }
        };
        appRegister.setDialogListener(new AppRegister.ProgressDialogListener() {
            @Override
            public void onExitDialog() {
                appRegister.closeDialog(IAppPDFActivity.this);
            }
        });
    }

    protected void insertSignatureInField(String str) {
        this.f28135s = str;
        getCertificate();
    }

    public void showToastText(int i10, String str) {
        Toast.makeText(getApplicationContext(), str, i10).show();
    }

    public void doSaveTFDigitallySign(final Bitmap bitmap, final String str, final String str2, final String str3) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        if (this.pdfEditManager.existFieldInDocument(this.pdfEditManager.hasFieldInDocument(str))) {
            g();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    IAppPDFActivity.this.lockScreen();
                    SignatureTask.getInstance().setDebug(true);
                    SignatureTask.getInstance().setMode(SignatureTask.SignMode.TF);
                    if (SignatureTask.getInstance().getLMSignData("test".getBytes(), str3, str2) != null) {
                        String path = IAppPDFActivity.this.getIntent().getData().getPath();
                        Message message = new Message();
                        message.what = 44;
                        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
                        if (FileUtils.saveImage(bitmap, pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null)) {
                            IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                            iAppPDFActivity.pdfEditManager.insertSignature(pdfWriteImagePath, str, path, "123456", null, 1, iAppPDFActivity.keySN);
                            IAppPDFActivity.this.f28122d.sendMessage(message);
                        }
                    } else {
                        Log.e(IAppPDFActivity.f28121h, "getTFSignData is null");
                    }
                    IAppPDFActivity.this.f28122d.sendEmptyMessage(46);
                    IAppPDFActivity.this.unLockScreen();
                }
            }).start();
        }
    }

    public void closeAreaHandwrite(PDFHandWriteView pDFHandWriteView, boolean z10) {
        if (this.I == null) {
            return;
        }
        if (!pDFHandWriteView.isEmpty()) {
            a(pDFHandWriteView, z10, false, (EditText) null);
        }
        this.f28136t.removeView(this.I);
    }

    private void a(String str) {
        File file = new File(str);
        if (file.exists()) {
            File[] listFiles = file.listFiles();
            for (File file2 : listFiles) {
                file2.delete();
            }
        }
    }

    protected void insertSignatureInText(String str, String str2, float f10) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(str, options);
        options.inJustDecodeBounds = false;
        float f11 = options.outWidth * f10;
        float f12 = options.outHeight * f10;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        this.pdfEditManager.insertImageInText(str, str2, f11, f12);
    }

    private float[] a(int i10, float[] fArr) {
        float[] fArr2 = new float[4];
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        RectF pageBounds2 = this.pdfEditManager.getPageBounds(i10);
        actWidth = pageBounds2.width();
        actHeight = pageBounds2.height();
        float zoom = ((GLView) this.view).getBase().getZoomModel().getZoom();
        Page pageByDocIndex = getController().getDocumentModel().getPageByDocIndex(i10);
        if (pageByDocIndex == null) {
            fArr2[0] = -1.0f;
            fArr2[1] = -1.0f;
            fArr2[2] = -1.0f;
            fArr2[3] = -1.0f;
            return fArr2;
        }
        RectF bounds = pageByDocIndex.getBounds(zoom);
        float f10 = bounds.top;
        float f11 = bounds.bottom;
        float f12 = bounds.left;
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            fArr2[0] = ((fArr[0] * (f11 - f10)) / actHeight) - ((GLView) this.view).getScrollX();
        } else if (((GLView) this.view).getScrollX() == 0) {
            fArr2[0] = (((fArr[0] * (f11 - f10)) / actHeight) + j()) - ((GLView) this.view).getScrollX();
        } else {
            fArr2[0] = ((fArr[0] * (f11 - f10)) / actHeight) - (this.view.getView().getScrollX() - f12);
        }
        float f13 = f11 - f10;
        float scrollY = (((fArr[1] * f13) / actHeight) - ((GLView) this.view).getScrollY()) + f10;
        fArr2[1] = scrollY;
        float f14 = (fArr[2] - fArr[0]) * f13;
        float f15 = actHeight;
        fArr2[2] = (f14 / f15) + fArr2[0];
        fArr2[3] = (((fArr[3] - fArr[1]) * f13) / f15) + scrollY;
        Log.d("rect", "result : " + fArr2[0] + "," + fArr2[1] + "," + fArr2[2] + "," + fArr2[3]);
        return fArr2;
    }

    private static String b(byte[] bArr, int i10) {
        StringBuffer stringBuffer = new StringBuffer();
        for (int i11 = 0; i11 < i10; i11++) {
            String hexString = Integer.toHexString(bArr[i11] & 255);
            if (hexString.length() == 1) {
                hexString = String.valueOf('0') + hexString;
            }
            stringBuffer.append(hexString.toUpperCase());
        }
        return stringBuffer.toString();
    }

    public int verifySignature(byte[] bArr, byte[] bArr2) {
        return SignatureTask.getInstance().verifyP7SignData(bArr2, bArr);
    }

    public synchronized ByteBufferBitmap b(int i10, int i11) {
        MuPdfDocument muPdfDocument;
        ViewState viewState;
        RectF bounds;
        muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        Page pageObject = getController().getDocumentModel().getPageObject(i11);
        viewState = ViewState.get(getController().getDocumentController());
        bounds = pageObject.getBounds(1.0f);
        return ((MuPdfPage) muPdfDocument.getPage(i11)).renderBitmap(viewState, i10, (int) ((i10 * bounds.height()) / bounds.width()), new RectF(0.0f, 0.0f, 1.0f, 1.0f));
    }

    public void b(View view, final RectF rectF) {
        PopupWindow popupWindow = this.O;
        if (popupWindow != null) {
            popupWindow.dismiss();
        }
        int i10 = (int) (densityCoefficient * 8.0f);
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setCornerRadius(2.0f);
        gradientDrawable.setStroke(2, -16776961);
        gradientDrawable.setColor(-1);
        TextView textView = new TextView(this.f28125i);
        textView.setText("取消");
        textView.setTextColor(ViewCompat.MEASURED_STATE_MASK);
        textView.setTextSize(18.0f);
        textView.setPadding(i10, i10, i10, i10);
        textView.setBackground(gradientDrawable);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                if (IAppPDFActivity.this.O != null) {
                    IAppPDFActivity.this.O.dismiss();
                }
            }
        });
        TextView textView2 = new TextView(this.f28125i);
        textView2.setText("单侧多页");
        textView2.setTextColor(ViewCompat.MEASURED_STATE_MASK);
        textView2.setTextSize(18.0f);
        textView2.setPadding(i10, i10, i10, i10);
        textView2.setBackground(gradientDrawable);
        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                if (IAppPDFActivity.this.O != null) {
                    IAppPDFActivity.this.O.dismiss();
                }
                IAppPDFActivity.this.a(rectF, true);
            }
        });
        TextView textView3 = new TextView(this.f28125i);
        textView3.setText("双侧对开");
        textView3.setTextColor(ViewCompat.MEASURED_STATE_MASK);
        textView3.setTextSize(18.0f);
        textView3.setPadding(i10, i10, i10, i10);
        textView3.setBackground(gradientDrawable);
        textView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                if (IAppPDFActivity.this.O != null) {
                    IAppPDFActivity.this.O.dismiss();
                }
                IAppPDFActivity.this.a(rectF, false);
            }
        });
        LinearLayout linearLayout = new LinearLayout(this.f28125i);
        linearLayout.setOrientation(1);
        linearLayout.setBackgroundColor(0);
        linearLayout.addView(textView);
        linearLayout.addView(textView2);
        linearLayout.addView(textView3);
        PopupWindow popupWindow2 = new PopupWindow(linearLayout, -2, -2);
        this.O = popupWindow2;
        popupWindow2.setBackgroundDrawable(new BitmapDrawable());
        this.O.showAsDropDown(view);
    }

    private void a(final PDFEditManager pDFEditManager, final int i10, float[] fArr) {
        float j10;
        final float f10 = fArr[2] - fArr[0];
        final float f11 = fArr[3] - fArr[1];
        float[] a10 = a(i10, fArr);
        if (getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            if ((a10[0] - 5.0f) - j() >= 0.0f) {
                j10 = (a10[0] - 5.0f) - j();
            }
            j10 = 0.0f;
        } else {
            float f12 = a10[0];
            if (f12 - 5.0f >= 0.0f) {
                j10 = f12 - 5.0f;
            }
            j10 = 0.0f;
        }
        final float f13 = j10;
        float f14 = a10[1];
        float f15 = f14 - 5.0f >= 0.0f ? f14 - 5.0f : 0.0f;
        float f16 = a10[2] + 5.0f;
        float f17 = a10[3] + 5.0f;
        MyRectView myRectView = new MyRectView(this, f13, f15, f16, f17, false, ((GLView) this.view).getWidth(), ((GLView) this.view).getHeight());
        this.f28124g = myRectView;
        this.f28136t.addView(myRectView);
        this.f28136t.addView(this.f28129m);
        this.f28129m.setVisibility(0);
        float f18 = f16 - 64.0f;
        if (f18 < 0.0f) {
            f18 = 2.0f;
        } else if (f16 > this.view.getWidth()) {
            f18 = this.view.getWidth() - 64;
        }
        float f19 = f15 - 144.0f;
        if (f19 < 0.0f) {
            f19 = (f17 - 96.0f) + 10.0f;
        }
        a(false, f18, f19);
        this.f28124g.setClickable(true);
        this.f28130n.bringToFront();
        final float f20 = f15;
        this.f28124g.setOnTouchListener(new View.OnTouchListener() {

            private int f28169f;

            private int f28170g;

            private int f28171h;

            private int f28172i = 0;

            int f28164a = 0;

            int f28165b = 0;

            int f28166c = 0;

            int f28167d = 0;

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                int action = motionEvent.getAction();
                if (action != 0) {
                    if (action != 1) {
                        if (action == 2) {
                            int rawX = (int) motionEvent.getRawX();
                            int rawY = (int) motionEvent.getRawY();
                            int i11 = rawX - this.f28171h;
                            int i12 = rawY - this.f28172i;
                            this.f28164a = view.getTop() + i12;
                            this.f28165b = view.getBottom() + i12;
                            this.f28166c = view.getLeft() + i11;
                            int right = view.getRight() + i11;
                            this.f28167d = right;
                            view.layout(this.f28166c, this.f28164a, right, this.f28165b);
                            this.f28171h = (int) motionEvent.getRawX();
                            this.f28172i = (int) motionEvent.getRawY();
                        }
                    } else {
                        IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.f28124g);
                        IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.f28129m);
                        IAppPDFActivity.this.i();
                        float[] insertXY = IAppPDFActivity.this.getInsertXY((this.f28171h + f13) - this.f28169f, (this.f28172i + f20) - this.f28170g, true, i10);
                        IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                        int i13 = iAppPDFActivity.insertPageNo;
                        int i14 = i10;
                        if (i13 == i14) {
                            float f21 = insertXY[0];
                            if (f21 <= 0.0f) {
                                insertXY[0] = 0.0f;
                            } else {
                                float f22 = f10;
                                float f23 = f21 + f22;
                                float f24 = IAppPDFActivity.actWidth;
                                if (f23 > f24) {
                                    insertXY[0] = f24 - f22;
                                }
                            }
                            float f25 = insertXY[1];
                            if (f25 <= 0.0f) {
                                insertXY[1] = 0.0f;
                            } else {
                                float f26 = f11;
                                float f27 = f25 + f26;
                                float f28 = IAppPDFActivity.actHeight;
                                if (f27 > f28) {
                                    insertXY[1] = f28 - f26;
                                }
                            }
                            pDFEditManager.updateAnnotRect(iAppPDFActivity.currAnnotation, i14, insertXY[0], insertXY[1]);
                        } else {
                            Toast.makeText(iAppPDFActivity, "批注只能在它所在页内移动!", 0).show();
                        }
                    }
                } else {
                    this.f28171h = (int) motionEvent.getRawX();
                    int rawY2 = (int) motionEvent.getRawY();
                    this.f28172i = rawY2;
                    this.f28169f = this.f28171h;
                    this.f28170g = rawY2;
                }
                return false;
            }
        });
    }

    @SuppressLint({"NewApi"})
    private void a(boolean z10, float f10, float f11) {
        if (z10) {
            return;
        }
        this.f28129m.setVisibility(0);
        this.f28129m.setX(f10);
        this.f28129m.setY(f11);
    }

    private void a(final PDFEditManager pDFEditManager, final int i10, float[] fArr, final boolean z10) {
        final float f10 = fArr[2] - fArr[0];
        final float f11 = fArr[3] - fArr[1];
        float[] a10 = a(i10, fArr);
        final float f12 = a10[0];
        final float f13 = a10[1];
        float f14 = a10[2];
        float f15 = a10[3];
        MyRectView myRectView = new MyRectView(this, f12, f13, f14, f15, true, ((GLView) this.view).getWidth(), ((GLView) this.view).getHeight());
        this.f28123f = myRectView;
        this.f28136t.addView(myRectView);
        this.f28136t.addView(this.f28129m);
        this.f28129m.setVisibility(0);
        float f16 = f14 - 64.0f;
        if (f16 < 0.0f) {
            f16 = 2.0f;
        } else if (f14 > this.view.getWidth()) {
            f16 = this.view.getWidth() - 64;
        }
        float f17 = f13 - 144.0f;
        if (f17 < 0.0f) {
            f17 = (f15 - 96.0f) + 10.0f;
        }
        a(false, f16, f17);
        this.f28123f.setClickable(true);
        this.f28130n.bringToFront();
        this.f28123f.setOnTouchListener(new View.OnTouchListener() {

            private int f28194g;

            private int f28195h;

            private int f28196i;

            private int f28197j;

            private int f28198k;

            private int f28199l = 0;

            int f28188a = 0;

            int f28189b = 0;

            int f28190c = 0;

            int f28191d = 0;

            boolean f28192e = false;

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                boolean z11;
                int action = motionEvent.getAction();
                if (action != 0) {
                    if (action != 1) {
                        if (action == 2 && z10) {
                            int rawX = (int) motionEvent.getRawX();
                            int rawY = (int) motionEvent.getRawY();
                            int i11 = rawX - this.f28196i;
                            int i12 = rawY - this.f28197j;
                            this.f28188a = view.getTop() + i12;
                            this.f28189b = view.getBottom() + i12;
                            this.f28190c = view.getLeft() + i11;
                            int right = view.getRight() + i11;
                            this.f28191d = right;
                            view.layout(this.f28190c, this.f28188a, right, this.f28189b);
                            this.f28196i = (int) motionEvent.getRawX();
                            this.f28197j = (int) motionEvent.getRawY();
                        }
                    } else {
                        this.f28198k = (int) motionEvent.getRawX();
                        this.f28199l = (int) motionEvent.getRawY();
                        Log.d("rect", "lastX1 : " + this.f28198k + ", lastY1 : " + this.f28199l);
                        float sqrt = (float) Math.sqrt((double) ((Math.abs(this.f28198k - this.f28194g) * Math.abs(this.f28198k - this.f28194g)) + (Math.abs(this.f28199l - this.f28195h) * Math.abs(this.f28199l - this.f28195h))));
                        if (sqrt >= 3.0d) {
                            z11 = true;
                        } else {
                            z11 = false;
                        }
                        this.f28192e = z11;
                        Log.d("rect", "d : " + sqrt);
                        IAppPDFActivity.this.f28123f.setVisibility(8);
                        IAppPDFActivity.this.i();
                        if (z10) {
                            float[] insertXY = IAppPDFActivity.this.getInsertXY((this.f28196i + f12) - this.f28194g, (this.f28197j + f13) - this.f28195h, true, i10);
                            IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                            int i13 = iAppPDFActivity.insertPageNo;
                            int i14 = i10;
                            if (i13 == i14) {
                                if (this.f28192e) {
                                    float f18 = insertXY[0];
                                    if (f18 <= 0.0f) {
                                        insertXY[0] = 0.0f;
                                    } else {
                                        float f19 = f10;
                                        float f20 = f18 + f19;
                                        float f21 = IAppPDFActivity.actWidth;
                                        if (f20 > f21) {
                                            insertXY[0] = f21 - f19;
                                        }
                                    }
                                    float f22 = insertXY[1];
                                    if (f22 <= 0.0f) {
                                        insertXY[1] = 0.0f;
                                    } else {
                                        float f23 = f11;
                                        float f24 = f22 + f23;
                                        float f25 = IAppPDFActivity.actHeight;
                                        if (f24 > f25) {
                                            insertXY[1] = f25 - f23;
                                        }
                                    }
                                    pDFEditManager.updateSignatureRect(iAppPDFActivity.currAnnotation, i14, insertXY[0], insertXY[1]);
                                    this.f28192e = false;
                                }
                            } else {
                                Toast.makeText(iAppPDFActivity, "批注只能在它所在页内移动!", 0).show();
                            }
                        }
                        IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.f28129m);
                        IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.f28123f);
                    }
                } else {
                    this.f28196i = (int) motionEvent.getRawX();
                    this.f28197j = (int) motionEvent.getRawY();
                    Log.d("rect", "lastX : " + this.f28196i + ", lastY : " + this.f28197j);
                    this.f28194g = this.f28196i;
                    this.f28195h = this.f28197j;
                }
                return false;
            }
        });
    }

    private synchronized void a(boolean z10, String str, String str2) {
        long[] annotations;
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        int pageCount = getController().getDocumentModel().getPageCount();
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        for (int i10 = 0; i10 < pageCount; i10++) {
            long pageHandle = this.pdfEditManager.getPageHandle(i10);
            if (str.equals("")) {
                if (str2.equals("")) {
                    annotations = MuPdfDocument.getAllAnnotations(pageHandle);
                } else {
                    annotations = MuPdfDocument.getAllAnnotationsBySubType(pageHandle, str2);
                }
            } else {
                annotations = MuPdfDocument.getAnnotations(pageHandle, str);
            }
            for (long j10 : annotations) {
                int annotFlag = MuPdfDocument.getAnnotFlag(j10);
                if (z10) {
                    if ((annotFlag & 128) == 0) {
                        MuPdfDocument.setAnnotFlag(j10, annotFlag | 128);
                        MuPdfDocument.updatePage(muPdfDocument.getDocumentHandle(), i10);
                    }
                } else if ((annotFlag & 128) == 128) {
                    MuPdfDocument.setAnnotFlag(j10, annotFlag ^ 128);
                    MuPdfDocument.updatePage(muPdfDocument.getDocumentHandle(), i10);
                }
            }
        }
    }

    private void a(PDFHandWriteView pDFHandWriteView, boolean z10, boolean z11, EditText editText) {
        boolean saveImage;
        RectF floatFrameRect = this.I.getFloatFrameRect();
        RectF adjustiveCoordinatesRect = pDFHandWriteView.getAdjustiveCoordinatesRect(1.0f);
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        e();
        float[] insertXY = getInsertXY(floatFrameRect.left - 4.0f, floatFrameRect.top - 4.0f, true, 0);
        float width = actWidth / this.view.getWidth();
        float width2 = floatFrameRect.width() * width;
        float height = floatFrameRect.height() * width;
        Log.d("tbz", "doSaveAreaHandwrite insertXY = " + insertXY[0] + ", " + insertXY[1]);
        boolean z12 = z10 ^ true;
        if (z11) {
            z12 = false;
        }
        if (pDFHandWriteView.getPenType() != 0) {
            z12 = false;
        }
        if (!this.isVectorSign && !this.isSupportEbenT7Mode) {
            z12 = false;
        }
        if (z12) {
            Log.d("tbz", "doSaveAreaHandwrite isSaveByVector");
            Log.d("tbz", "doSaveAreaHandwrite rotate = " + rotate);
            String vertorInfo = pDFHandWriteView.getVertorInfo(this.view.getWidth(), densityCoefficient, imagezoom, actWidth, adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.bottom, 0.0f, 0.0f, Math.max((adjustiveCoordinatesRect.width() * width) / width2, (adjustiveCoordinatesRect.height() * width) / height), 0);
            PDFEditManager pDFEditManager = this.pdfEditManager;
            int i10 = this.insertPageNo;
            float f10 = insertXY[0];
            float f11 = insertXY[1];
            float f12 = imagezoom;
            pDFEditManager.insertVectorByPos(vertorInfo, i10, f10, f11, width2 / f12, height / f12, userName, "");
            this.pdfEditManager.refreshPage(this.insertPageNo);
        } else {
            String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
            Bitmap exportToBitmapArea = pDFHandWriteView.exportToBitmapArea(adjustiveCoordinatesRect);
            if (z11 && editText != null) {
                Bitmap groupBitmap = BitmapUtil.groupBitmap(BitmapUtil.addWaterMark(exportToBitmapArea), BitmapUtil.getTextBitmap(editText));
                saveImage = FileUtils.saveImage(groupBitmap, pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null);
                BitmapUtil.recycle(groupBitmap);
                editText.setText("");
            } else {
                saveImage = FileUtils.saveImage(exportToBitmapArea, pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null);
            }
            if (saveImage) {
                if (z10) {
                    PDFEditManager pDFEditManager2 = this.pdfEditManager;
                    int i11 = this.insertPageNo;
                    float f13 = insertXY[0];
                    float f14 = insertXY[1];
                    float f15 = imagezoom;
                    pDFEditManager2.insertImageToSignature(pdfWriteImagePath, i11, f13, f14, width2 / f15, height / f15, userName);
                } else {
                    PDFEditManager pDFEditManager3 = this.pdfEditManager;
                    int i12 = this.insertPageNo;
                    float f16 = insertXY[0];
                    float f17 = insertXY[1];
                    float f18 = imagezoom;
                    pDFEditManager3.insertImageByPos(pdfWriteImagePath, i12, f16, f17, width2 / f18, height / f18, userName);
                }
            }
        }
        pDFHandWriteView.doClearHandwriteInfo();
    }

    private void a(PDFHandWriteView pDFHandWriteView, String str) {
        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
        if (FileUtils.savePdfWriteImage(pDFHandWriteView, pdfWriteImagePath)) {
            this.pdfEditManager.insertImageInField(pdfWriteImagePath, str, false);
        }
    }

    private void a(PDFHandWriteView pDFHandWriteView, long j10, String str) {
        float[] fieldRect = this.pdfEditManager.getFieldRect(j10);
        float f10 = fieldRect[2] - fieldRect[0];
        float f11 = fieldRect[3] - fieldRect[1];
        RectF adjustiveCoordinatesRect = pDFHandWriteView.getAdjustiveCoordinatesRect(1.0f);
        this.pdfEditManager.insertVector(str, pDFHandWriteView.getVertorInfo(this.view.getWidth(), densityCoefficient, getController().getZoomModel().getZoom(), actWidth, adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.bottom, 0.0f, 0.0f, Math.max(((adjustiveCoordinatesRect.width() * actWidth) / this.view.getWidth()) / f10, ((adjustiveCoordinatesRect.height() * actHeight) / this.view.getHeight()) / f11), 0));
        this.pdfEditManager.refreshDocument();
    }

    private void a(PDFHandWriteView pDFHandWriteView, long j10, String str, int i10) {
        float[] fieldRect = this.pdfEditManager.getFieldRect(j10);
        float f10 = fieldRect[2] - fieldRect[0];
        float f11 = fieldRect[3] - fieldRect[1];
        RectF adjustiveCoordinatesRect = pDFHandWriteView.getAdjustiveCoordinatesRect(1.0f);
        this.pdfEditManager.insertVectorInPage(str, pDFHandWriteView.getVertorInfo(this.view.getWidth(), densityCoefficient, getController().getZoomModel().getZoom(), actWidth, adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.bottom, 0.0f, 0.0f, Math.max(((adjustiveCoordinatesRect.width() * actWidth) / this.view.getWidth()) / f10, ((adjustiveCoordinatesRect.height() * actHeight) / this.view.getHeight()) / f11), 0), i10);
        this.pdfEditManager.refreshDocument();
    }

    private void a(PDFHandWriteView pDFHandWriteView, String str, int i10) {
        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
        if (FileUtils.savePdfWriteImage(pDFHandWriteView, pdfWriteImagePath)) {
            this.pdfEditManager.insertImageByFieldInPage(pdfWriteImagePath, str, false, i10);
        }
    }

    private static byte[] a(byte[] bArr, int i10) {
        MessageDigest messageDigest;
        try {
            messageDigest = MessageDigest.getInstance("SHA1");
        } catch (NoSuchAlgorithmException e10) {
            e10.printStackTrace();
            messageDigest = null;
        }
        messageDigest.update(bArr, 0, i10);
        return messageDigest.digest();
    }

    private synchronized ArrayList<Annotation> a(String str, String str2) {
        ArrayList<Annotation> arrayList;
        long[] annotations;
        int i10;
        String str3 = str2;
        synchronized (this) {
            MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
            arrayList = new ArrayList<>();
            int pageCount = muPdfDocument.getPageCount();
            if (this.pdfEditManager == null) {
                this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
            }
            for (int i11 = 0; i11 < pageCount; i11++) {
                long pageHandle = this.pdfEditManager.getPageHandle(i11);
                if (str.equals("")) {
                    if (str3.equals("")) {
                        annotations = MuPdfDocument.getAllAnnotations(pageHandle);
                    } else {
                        annotations = MuPdfDocument.getAllAnnotationsBySubType(pageHandle, str3);
                    }
                } else {
                    annotations = MuPdfDocument.getAnnotations(pageHandle, str);
                }
                Log.v(f28121h, "length = " + annotations.length);
                int i12 = 0;
                while (i12 < annotations.length) {
                    String annotSubType = MuPdfDocument.getAnnotSubType(annotations[i12]);
                    if (!str3.equals("")) {
                        if (annotSubType.equals(str3)) {
                        }
                        i10 = pageCount;
                        i12++;
                        str3 = str2;
                        pageCount = i10;
                    }
                    String annotInfo = MuPdfDocument.getAnnotInfo(annotations[i12]);
                    Log.d("Kevin", "getAnnotInfo : " + annotInfo + " , " + annotSubType);
                    String str4 = "";
                    if (!TextUtils.isEmpty(annotInfo)) {
                        if (this.pdfEditManager == null) {
                            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
                        }
                        str4 = this.pdfEditManager.parseAnnotInfo2String(annotInfo)[1];
                    }
                    if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_POSTIL) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SIGN) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_STAMP) || annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SOUND)) {
                        Annotation annotation = new Annotation();
                        if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_TEXT)) {
                            annotation.setAnnoContent(MuPdfDocument.getAnnotText(annotations[i12]));
                            i10 = pageCount;
                        } else if (annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_SOUND)) {
                            i10 = pageCount;
                            annotation.setSoundRate(MuPdfDocument.getAnnotSoundRate(annotations[i12]));
                            annotation.setSoundChannels(MuPdfDocument.getAnnotSoundChannels(annotations[i12]));
                            annotation.setSoundBitspersample(MuPdfDocument.getAnnotSoundBitspersample(annotations[i12]));
                            annotation.setSoundData(MuPdfDocument.getAnnotSoundRaw(annotations[i12]));
                        } else {
                            i10 = pageCount;
                            String annotVerctorData = MuPdfDocument.getAnnotVerctorData(annotations[i12]);
                            Log.v("Kevin", "vector = " + annotVerctorData);
                            if (!TextUtils.isEmpty(annotVerctorData)) {
                                annotation.setAnnoContent(annotVerctorData);
                            } else {
                                annotation.setAnnoContent(String.valueOf(signaturePath) + MuPdfDocument.getAnnotType(annotations[i12]));
                                annotation.annotSignature = null;
                            }
                        }
                        if (!str4.equals("")) {
                            annotation.setAuthorName(str4);
                        } else {
                            annotation.setAuthorName(MuPdfDocument.getAnnotAuthor(annotations[i12]));
                        }
                        annotation.setCurDateTime(CommonMethodAndStringUtil.formatDateTime(MuPdfDocument.getAnnotModifyTime(annotations[i12])));
                        annotation.setPageNo(String.valueOf(i11 + 1));
                        annotation.setStyleName(annotSubType);
                        annotation.setUnType(MuPdfDocument.getAnnotType(annotations[i12]));
                        Log.d("Kevin", "getAnnotType : " + MuPdfDocument.getAnnotType(annotations[i12]));
                        float[] annotRectToUser = MuPdfDocument.getAnnotRectToUser(pageHandle, annotations[i12]);
                        annotation.setX(String.valueOf(annotRectToUser[0]));
                        annotation.setY(String.valueOf(annotRectToUser[1]));
                        annotation.setWidth(String.valueOf(annotRectToUser[2] - annotRectToUser[0]));
                        annotation.setHeight(String.valueOf(annotRectToUser[3] - annotRectToUser[1]));
                        annotation.setAnnotHandle(annotations[i12]);
                        annotation.setAnnotId(MuPdfDocument.getAnnotId(annotations[i12]));
                        annotation.setAuthorId("");
                        annotation.setCreateTime(CommonMethodAndStringUtil.formatDateTime(MuPdfDocument.getAnnotCreateTime(annotations[i12])));
                        arrayList.add(annotation);
                        i12++;
                        str3 = str2;
                        pageCount = i10;
                    }
                    i10 = pageCount;
                    i12++;
                    str3 = str2;
                    pageCount = i10;
                }
            }
        }
        return arrayList;
    }

    private void a(boolean z10, boolean z11, PDFHandWriteView pDFHandWriteView) {
        float[] insertXYForSinglePage;
        float width;
        float height;
        float width2;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        Bitmap.CompressFormat compressFormat = z11 ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG;
        RectF adjustiveCoordinatesRect = pDFHandWriteView.getAdjustiveCoordinatesRect(1.0f);
        Bitmap exportToBitmapArea = pDFHandWriteView.exportToBitmapArea(adjustiveCoordinatesRect);
        Message message = new Message();
        String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
        if (FileUtils.saveImage(exportToBitmapArea, pdfWriteImagePath, compressFormat, null)) {
            float zoom = ((GLView) this.view).getBase().getZoomModel().getZoom();
            if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
                insertXYForSinglePage = getInsertXY(adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.top, true, 0);
                width = ((adjustiveCoordinatesRect.width() * actWidth) / this.view.getWidth()) / zoom;
                height = adjustiveCoordinatesRect.height() * actWidth;
                width2 = this.view.getWidth();
            } else {
                insertXYForSinglePage = getInsertXYForSinglePage(adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.top, true, 0);
                width = ((adjustiveCoordinatesRect.width() * actWidth) / (this.view.getWidth() - (j() * 2.0f))) / zoom;
                height = adjustiveCoordinatesRect.height() * actWidth;
                width2 = this.view.getWidth() - (j() * 2.0f);
            }
            float f10 = (height / width2) / zoom;
            if (insertXYForSinglePage[0] == -1.0f) {
                message.what = KinggridConstant.VERTORDATA_INSERT_ERROR;
                this.f28122d.sendMessage(message);
                return;
            }
            byte[] a10 = z11 ? a(exportToBitmapArea) : null;
            if (z11) {
                this.pdfEditManager.insertImageByPosWithPNG(pdfWriteImagePath, this.insertPageNo, insertXYForSinglePage[0], insertXYForSinglePage[1], width, f10, (int) adjustiveCoordinatesRect.width(), (int) adjustiveCoordinatesRect.height(), userName, a10, 8);
                return;
            }
            Log.v("tbz", "insertXY = " + insertXYForSinglePage[0] + "," + insertXYForSinglePage[1]);
            this.pdfEditManager.insertImageByPos(pdfWriteImagePath, this.insertPageNo, insertXYForSinglePage[0], insertXYForSinglePage[1], width, f10, userName);
            return;
        }
        message.what = KinggridConstant.VERTORDATA_INSERT_ERROR;
        this.f28122d.sendMessage(message);
    }

    private void a(boolean z10, PDFHandWriteView pDFHandWriteView) {
        Message message;
        char c10;
        float[] insertXYForSinglePage;
        float width;
        float height;
        String vertorInfo;
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        Message message2 = new Message();
        float zoom = ((GLView) this.view).getBase().getZoomModel().getZoom();
        RectF adjustiveCoordinatesRect = pDFHandWriteView.getAdjustiveCoordinatesRect(1.0f);
        if (!getController().getBookSettings().pageAlign.equals(PageAlign.HEIGHT)) {
            insertXYForSinglePage = getInsertXY(adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.top, true, 0);
            width = ((adjustiveCoordinatesRect.width() * actWidth) / this.view.getWidth()) / zoom;
            height = ((adjustiveCoordinatesRect.height() * actWidth) / this.view.getWidth()) / zoom;
            message = message2;
            c10 = 1;
            vertorInfo = pDFHandWriteView.getVertorInfo(this.view.getView().getWidth(), DM.density, getController().getZoomModel().getZoom(), actWidth, adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.bottom, adjustiveCoordinatesRect.right, adjustiveCoordinatesRect.top, 1.0f, rotate);
        } else {
            message = message2;
            c10 = 1;
            insertXYForSinglePage = getInsertXYForSinglePage(adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.top, true, 0);
            width = ((adjustiveCoordinatesRect.width() * actWidth) / (this.view.getWidth() - (j() * 2.0f))) / zoom;
            height = ((adjustiveCoordinatesRect.height() * actWidth) / (this.view.getWidth() - (j() * 2.0f))) / zoom;
            vertorInfo = pDFHandWriteView.getVertorInfo((int) (this.view.getView().getWidth() - (j() * 2.0f)), DM.density, getController().getZoomModel().getZoom(), actWidth, adjustiveCoordinatesRect.left, adjustiveCoordinatesRect.bottom, adjustiveCoordinatesRect.right, adjustiveCoordinatesRect.top, 1.0f, rotate);
        }
        float f10 = height;
        String str = vertorInfo;
        float f11 = width;
        Log.d("tbz", "vector_info = " + str);
        Log.d("tbz", "doSaveVectorHandwriteInfo insertXY = " + insertXYForSinglePage[0] + ", " + insertXYForSinglePage[c10]);
        float f12 = insertXYForSinglePage[0];
        if (f12 == -1.0f) {
            Message message3 = message;
            message3.what = KinggridConstant.VERTORDATA_INSERT_ERROR;
            this.f28122d.sendMessage(message3);
            return;
        }
        this.pdfEditManager.insertVectorByPos(str, this.insertPageNo, f12, insertXYForSinglePage[c10], f11, f10, userName, "");
    }

    private byte[] a(Bitmap bitmap) {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        byte[] bArr = new byte[width * height * 3];
        int i10 = 0;
        for (int i11 = 0; i11 < height; i11++) {
            for (int i12 = 0; i12 < width; i12++) {
                int pixel = bitmap.getPixel(i12, i11);
                if (pixel == 0) {
                    pixel = Color.rgb(255, 255, 255);
                }
                bArr[i10] = (byte) (pixel >> 16);
                bArr[i10 + 1] = (byte) (pixel >> 8);
                bArr[i10 + 2] = (byte) (pixel >> 0);
                i10 += 3;
            }
        }
        return bArr;
    }

    private void a(String str, String str2, int i10) {
        long[] annotations;
        int pageCount = ((MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document).getPageCount();
        PDFEditManager pDFEditManager = new PDFEditManager(getIntent(), this, getController());
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDocumentModel().decodeService).document;
        for (int i11 = 0; i11 < pageCount; i11++) {
            if (i10 == -1 || i10 == i11 + 1) {
                int i12 = i11 + 1;
                long open = MuPdfPage.open(muPdfDocument.getDocumentHandle(), i12);
                pageHandles.put(Integer.valueOf(i12), Long.valueOf(open));
                docHandles.put(Long.valueOf(muPdfDocument.getDocumentHandle()), pageHandles);
                if (str2.equals("")) {
                    if (str.equals("")) {
                        annotations = MuPdfDocument.getAllAnnotations(open);
                    } else if (str.equals(KinggridConstant.ANNOT_SUBTYPE_SIGN)) {
                        annotations = MuPdfDocument.getAllAnnotationsBySubType(open, KinggridConstant.ANNOT_SUBTYPE_STAMP);
                    } else {
                        annotations = MuPdfDocument.getAllAnnotationsBySubType(open, str);
                    }
                } else {
                    annotations = MuPdfDocument.getAnnotations(open, str2);
                }
                for (int i13 = 0; i13 < annotations.length; i13++) {
                    String annotSubType = MuPdfDocument.getAnnotSubType(annotations[i13]);
                    String annotInfo = MuPdfDocument.getAnnotInfo(annotations[i13]);
                    Log.d("Kevin", "getAnnotInfo : " + annotInfo + " , " + annotSubType);
                    if (str.equals("")) {
                        pDFEditManager.deleteOneSignature(annotations[i13]);
                    } else if (!str.equals(KinggridConstant.ANNOT_SUBTYPE_STAMP) && str.equals(annotSubType)) {
                        pDFEditManager.deleteOneSignature(annotations[i13]);
                    } else if (str.equals(KinggridConstant.ANNOT_SUBTYPE_STAMP) && annotSubType.equals(KinggridConstant.ANNOT_SUBTYPE_POSTIL)) {
                        pDFEditManager.deleteOneSignature(annotations[i13]);
                    } else if (!TextUtils.isEmpty(annotInfo)) {
                        String str3 = pDFEditManager.parseAnnotInfo2String(annotInfo)[0];
                        if (str3 != null && (str3.equals(str) || str3.equals(KinggridConstant.ANNOT_SUBTYPE_CONVERT2SIGNATURE) || str3.equals("Widget"))) {
                            pDFEditManager.deleteOneSignature(annotations[i13]);
                        }
                    }
                }
            }
        }
    }

    private void a(int i10, int i11) {
        String str = i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? "" : KinggridConstant.ANNOT_SUBTYPE_SOUND : KinggridConstant.ANNOT_SUBTYPE_SIGN : KinggridConstant.ANNOT_SUBTYPE_TEXT : KinggridConstant.ANNOT_SUBTYPE_STAMP;
        if (progressBarStatus == 0) {
            a(str, userName, i11);
        }
    }

    private void a(final PDFEditManager pDFEditManager, int i10, float[] fArr, final long j10) {
        float[] a10 = a(this.insertPageNo, fArr);
        int i11 = (int) (a10[3] - a10[1]);
        int i12 = (int) (a10[2] - a10[0]);
        float f10 = i10;
        float f11 = f10 - fArr[3];
        fArr[1] = f11;
        fArr[3] = f10 - f11;
        float[] a11 = a(this.insertPageNo, fArr);
        float f12 = a11[0];
        float f13 = a11[1];
        int fieldType = pDFEditManager.getFieldType(j10);
        if (fieldType == 1) {
            pDFEditManager.setCheckFieldState(this.insertPageNo, j10);
            pDFEditManager.refreshDocument();
            return;
        }
        if (fieldType == 2) {
            pDFEditManager.setCheckFieldState(this.insertPageNo, j10);
            pDFEditManager.refreshDocument();
            return;
        }
        if (fieldType != 3) {
            if (fieldType != 4) {
                return;
            }
            final String[] dataNameArr = pDFEditManager.getDataNameArr(j10);
            MyCombox myCombox = new MyCombox(this);
            this.f28133q = myCombox;
            myCombox.setWidth(i12 + 8);
            this.f28133q.setHeight(i11 + 8);
            this.f28133q.setTextSize(1, r7 / 2);
            this.f28133q.setTag(Integer.valueOf(dataNameArr.length));
            this.f28133q.init(this.f28125i, dataNameArr);
            this.f28133q.setX(f12 - 4.0f);
            this.f28133q.setY(f13 - 4.0f);
            this.f28136t.addView(this.f28133q);
            this.f28133q.setListViewOnClickListener(new MyCombox.ListViewItemClickListener() {
                @Override
                public void onItemClick(int i13) {
                    pDFEditManager.setFieldEditContent(j10, dataNameArr[i13], IAppPDFActivity.this.insertPageNo);
                    pDFEditManager.refreshDocument();
                }
            });
            return;
        }
        AdjustableSizeEditText adjustableSizeEditText = new AdjustableSizeEditText(this);
        this.f28132p = adjustableSizeEditText;
        adjustableSizeEditText.setWidth(i12 + 8);
        this.f28132p.setHeight(i11 + 8);
        this.f28132p.setTextSize(1, r7 / 2);
        this.f28132p.init();
        String fieldContent = TextUtils.isEmpty(pDFEditManager.getFieldContent(j10)) ? "" : pDFEditManager.getFieldContent(j10);
        this.f28134r = fieldContent;
        if (!TextUtils.isEmpty(fieldContent)) {
            this.f28132p.setText(this.f28134r);
        }
        this.f28132p.setX(f12 - 4.0f);
        this.f28132p.setY(f13 - 4.0f);
        this.f28132p.setTag(Long.valueOf(j10));
        this.f28136t.addView(this.f28132p);
        this.f28132p.setVisibility(0);
        this.f28132p.requestFocus();
        if (this.f28132p.getVisibility() == 0) {
            ((InputMethodManager) getSystemService("input_method")).showSoftInput(getCurrentFocus(), 2);
        }
    }

    private RectF a(float f10, Bitmap bitmap) {
        float width = this.view.getWidth() / f10;
        float width2 = (this.view.getWidth() - width) / 2.0f;
        float height = (((this.view.getHeight() * 2) / 3) - width) / 2.0f;
        float f11 = width2 + width;
        float f12 = width + height;
        if (f10 == 0.0f) {
            width2 = (this.view.getWidth() - bitmap.getWidth()) / 2;
            height = (((this.view.getHeight() * 2) / 3) - bitmap.getHeight()) / 2;
            f11 = width2 + bitmap.getWidth();
            f12 = height + bitmap.getHeight();
        }
        return new RectF(width2, height, f11, f12);
    }

    private void a(Bitmap bitmap, int i10, boolean z10, RectF rectF) {
        a(bitmap, i10, -1, z10, rectF);
    }

    private void a(Bitmap bitmap, final int i10, int i11, boolean z10, RectF rectF) {
        if (this.f28142z) {
            Toast.makeText(this.f28125i, "当前版本为只读版本...", 0).show();
            return;
        }
        LocateSignatureView locateSignatureView = this.M;
        if (locateSignatureView != null) {
            this.f28136t.removeView(locateSignatureView);
        }
        ImageView imageView = this.N;
        if (imageView != null) {
            this.f28136t.removeView(imageView);
        }
        int height = this.view.getHeight();
        int width = this.view.getWidth();
        if (pageViewMode == PageViewMode.VSCROLL && getPageCount() == 1) {
            RectF bounds = ViewState.get(getController().getDocumentController()).getBounds(getController().getDocumentModel().getCurrentPageObject());
            if (bounds.height() < this.screenHeight) {
                height = (int) bounds.height();
            }
        }
        this.M = new LocateSignatureView(this, this.view.getView(), width, height, rectF);
        ImageView imageView2 = new ImageView(this.f28125i);
        this.N = imageView2;
        imageView2.setScaleType(ImageView.ScaleType.FIT_CENTER);
        this.N.setImageBitmap(bitmap);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) rectF.width(), (int) rectF.height());
        layoutParams.leftMargin = (int) rectF.left;
        layoutParams.topMargin = (int) rectF.top;
        this.f28136t.addView(this.N, layoutParams);
        this.f28136t.addView(this.M);
        this.M.setLocatePosition(new LocateSignatureView.ILocatePosition() {
            @Override
            public void setLocatePosition(RectF rectF2, int i12) {
                if (i12 == 2) {
                    FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) IAppPDFActivity.this.N.getLayoutParams();
                    layoutParams2.leftMargin = (int) rectF2.left;
                    layoutParams2.topMargin = (int) rectF2.top;
                    layoutParams2.height = (int) rectF2.height();
                    layoutParams2.width = (int) rectF2.width();
                    IAppPDFActivity.this.N.setLayoutParams(layoutParams2);
                    return;
                }
                if (i12 == 1) {
                    int i13 = i10;
                    if (i13 == 0) {
                        IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                        iAppPDFActivity.a(iAppPDFActivity.N, rectF2);
                    } else if (i13 == 2) {
                        IAppPDFActivity iAppPDFActivity2 = IAppPDFActivity.this;
                        iAppPDFActivity2.b(iAppPDFActivity2.N, rectF2);
                    } else {
                        IAppPDFActivity iAppPDFActivity3 = IAppPDFActivity.this;
                        iAppPDFActivity3.a(iAppPDFActivity3.N, rectF2, i10);
                    }
                }
            }
        });
    }

    public void a(View view, RectF rectF) {
        a(view, rectF, 0);
    }

    public void a(View view, final RectF rectF, final int i10) {
        PopupWindow popupWindow = this.O;
        if (popupWindow != null) {
            popupWindow.dismiss();
        }
        int i11 = (int) (densityCoefficient * 8.0f);
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setCornerRadius(2.0f);
        gradientDrawable.setStroke(2, -16776961);
        gradientDrawable.setColor(-1);
        TextView textView = new TextView(this.f28125i);
        textView.setText("取消");
        textView.setTextColor(ViewCompat.MEASURED_STATE_MASK);
        textView.setTextSize(18.0f);
        textView.setPadding(i11, i11, i11, i11);
        textView.setBackground(gradientDrawable);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                IAppPDFActivity.this.O.dismiss();
                IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.M);
                IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.N);
            }
        });
        TextView textView2 = new TextView(this.f28125i);
        textView2.setText("确定");
        textView2.setTextColor(ViewCompat.MEASURED_STATE_MASK);
        textView2.setTextSize(18.0f);
        textView2.setPadding(i11, i11, i11, i11);
        textView2.setBackground(gradientDrawable);
        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                if (IAppPDFActivity.this.O != null) {
                    IAppPDFActivity.this.O.dismiss();
                }
                IAppPDFActivity iAppPDFActivity = IAppPDFActivity.this;
                if (iAppPDFActivity.pdfEditManager == null) {
                    Intent intent = IAppPDFActivity.this.getIntent();
                    IAppPDFActivity iAppPDFActivity2 = IAppPDFActivity.this;
                    iAppPDFActivity.pdfEditManager = new PDFEditManager(intent, iAppPDFActivity2, iAppPDFActivity2.getController());
                }
                IAppPDFActivity.this.e();
                IAppPDFActivity iAppPDFActivity3 = IAppPDFActivity.this;
                RectF rectF2 = rectF;
                float[] insertXY = iAppPDFActivity3.getInsertXY(rectF2.left - 4.0f, rectF2.top - 4.0f, true, 0);
                float width = IAppPDFActivity.actWidth / IAppPDFActivity.this.view.getWidth();
                float width2 = rectF.width() * width;
                float height = rectF.height() * width;
                Log.d("tbz", "actWidth = " + IAppPDFActivity.actWidth + ", view width = " + IAppPDFActivity.this.view.getWidth());
                StringBuilder sb2 = new StringBuilder("scale = ");
                sb2.append(width);
                Log.d("tbz", sb2.toString());
                Log.d("tbz", "area_rect_width = " + width2 + ", area_rect_height = " + height);
                String pdfWriteImagePath = FileUtils.getPdfWriteImagePath();
                IAppPDFActivity.this.N.setDrawingCacheEnabled(true);
                Bitmap drawingCache = IAppPDFActivity.this.N.getDrawingCache();
                if (drawingCache != null) {
                    boolean saveImage = FileUtils.saveImage(com.kinggrid.signature.commen.BitmapUtil.getSizedBitmap(drawingCache, (int) width2, (int) height), pdfWriteImagePath, Bitmap.CompressFormat.JPEG, null);
                    IAppPDFActivity.this.N.setDrawingCacheEnabled(false);
                    if (saveImage) {
                        if (i10 == 0) {
                            IAppPDFActivity iAppPDFActivity4 = IAppPDFActivity.this;
                            PDFEditManager pDFEditManager = iAppPDFActivity4.pdfEditManager;
                            int i12 = iAppPDFActivity4.insertPageNo;
                            float f10 = insertXY[0];
                            float f11 = insertXY[1];
                            float f12 = IAppPDFActivity.imagezoom;
                            pDFEditManager.insertImageByPos(pdfWriteImagePath, i12, f10, f11, width2 / f12, height / f12, IAppPDFActivity.userName, iAppPDFActivity4.keySN);
                        } else {
                            IAppPDFActivity iAppPDFActivity5 = IAppPDFActivity.this;
                            iAppPDFActivity5.onLocalSignatureListener.onLocalSingatureFinish(pdfWriteImagePath, width2, height, insertXY[0], insertXY[1], iAppPDFActivity5.insertPageNo);
                        }
                    }
                }
                IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.M);
                IAppPDFActivity.this.f28136t.removeView(IAppPDFActivity.this.N);
            }
        });
        LinearLayout linearLayout = new LinearLayout(this.f28125i);
        linearLayout.setOrientation(1);
        linearLayout.setBackgroundColor(0);
        linearLayout.addView(textView2);
        linearLayout.addView(textView);
        PopupWindow popupWindow2 = new PopupWindow(linearLayout, -2, -2);
        this.O = popupWindow2;
        popupWindow2.setBackgroundDrawable(new BitmapDrawable());
        this.O.showAsDropDown(view);
    }

    public SparseArray<ByteBufferBitmap> a(int i10, int i11, int i12) {
        SparseArray<ByteBufferBitmap> sparseArray = new SparseArray<>();
        MuPdfDocument muPdfDocument = (MuPdfDocument) ((DecodeServiceBase) getController().getDecodeService()).document;
        ViewState viewState = ViewState.get(getController().getDocumentController());
        RectF rectF = new RectF(0.0f, 0.0f, 1.0f, 1.0f);
        while (i11 <= i12) {
            RectF bounds = getController().getDocumentModel().getPageObject(i11).getBounds(1.0f);
            sparseArray.put(i11, ((MuPdfPage) muPdfDocument.getPage(i11)).renderBitmap(viewState, i10, (int) ((i10 * bounds.height()) / bounds.width()), rectF));
            i11++;
        }
        return sparseArray;
    }

    private void a(String str, int i10, File file, float f10, float f11, float f12, String str2) {
        if (i10 < getPageCount()) {
            RectF pageBounds2 = this.pdfEditManager.getPageBounds(i10);
            actWidth = pageBounds2.width();
            actHeight = pageBounds2.height();
            float width = (actWidth / this.view.getWidth()) / ((GLView) this.view).getBase().getZoomModel().getZoom();
            float f13 = f11 * width;
            float f14 = f12 * width;
            float f15 = actWidth - f11;
            if (file.exists()) {
                this.pdfEditManager.insertImageByPosBat(file.getAbsolutePath(), i10, f15, f10, f13, f14, str, str2, null);
                return;
            }
            Log.e(f28121h, String.valueOf(file.getAbsolutePath()) + "不存在");
        }
    }

    public void a(RectF rectF, boolean z10) {
        if (this.pdfEditManager == null) {
            this.pdfEditManager = new PDFEditManager(getIntent(), this, getController());
        }
        e();
        float[] insertXY = getInsertXY(rectF.left - 4.0f, rectF.top - 4.0f, true, 0);
        this.N.setDrawingCacheEnabled(true);
        Bitmap drawingCache = this.N.getDrawingCache();
        if (drawingCache != null) {
            if (z10) {
                doSavePerforationSideSeal(drawingCache, insertXY[1]);
            } else {
                doSavePerforationDivSeal(drawingCache, insertXY[1]);
            }
        }
    }
}