package epson.print;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.p000v4.app.FragmentActivity;
import android.view.Display;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.box.androidsdk.content.models.BoxFile;
import com.epson.iprint.prtlogger.NewLoggerController;
import com.epson.iprint.prtlogger.PrintLog;
import com.epson.mobilephone.common.ReviewInvitationDialog;
import com.epson.mobilephone.common.ReviewInvitationViewModel;
import com.epson.mobilephone.common.escpr.MediaInfo;
import com.epson.mobilephone.common.license.LicenseTopActivity;
import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import epson.common.Constants;
import epson.common.ExternalFileUtils;
import epson.common.Info_paper;
import epson.common.IprintLicenseInfo;
import epson.common.IprintUserSurveyInfo;
import epson.common.Utils;
import epson.print.Util.AsyncTaskExecutor;
import epson.print.Util.EPLog;
import epson.print.Util.Photo;
import epson.print.ecclient.EccErrorInfo;
import epson.print.gdconv.ConvertProgressActivity;
import epson.print.pdf.pdfRender;
import epson.print.screen.LocalDocumentParams;
import epson.print.screen.PaperSourceInfo;
import epson.print.screen.PaperSourceSetting;
import epson.print.screen.PaperSourceSettingScr;
import epson.print.screen.PrintProgress;
import epson.print.screen.PrintSetting;
import epson.print.screen.SettingScr;
import epson.print.service.EpsonService;
import epson.print.service.IEpsonService;
import epson.print.service.IEpsonServiceCallback;
import epson.print.widgets.CustomTitleAlertDialogBuilder;
import epson.server.utils.MyUtility;

public class ActivityDocsPrintPreview extends ActivityIACommon implements CommonDefine, View.OnClickListener, ReviewInvitationDialog.OnClickListener {
    private static final int COMFIRM_REMOTEPRINT = 13;
    private static final int COMFIRM_REMOTEPRINT_PREVIEW = 12;
    private static final int CONFIRM_GDOC_COV = 5;
    private static final int CONVERT_AUTHENTICATE = 1;
    private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
    private static final int DIALOG_PASS = 2;
    private static final int EPS_ERR_NONE = 0;
    private static final int ERR_FILENAME_OVER_256_CHARACTERS = -1;
    private static final int GDOC_CONVERT_FAIL = 7;
    private static final int GDOC_CONVERT_INTERNET_PROBLEM = 11;
    private static final int GDOC_CONVERT_SIZEOVER_DOC = 8;
    private static final int GDOC_CONVERT_SIZEOVER_PPT = 10;
    private static final int GDOC_CONVERT_SIZEOVER_XLS = 9;
    private static final int NOAVAILABLE_NETWORK = 6;
    private static final int NOT_PRINTER_SELECTED = 4;
    public static final String PARAMS_KEY_DOC_PRINT_LOG = "print_log";
    private static final String PREFS_NAME = "PrintSetting";
    private static final int PRINT_GDOC_COV = 8;
    private static final int PRINT_LOCAL = 0;
    private static final int PRINT_REMOTE = 1;
    private static final int PRINT_RENDER_SERVER = 4;
    private static final int PRINT_SHOWPREVIEW = 2;
    private static final int REQUEST_CODE_LICENSE_CHECK = 3;
    private static final int RESULT_RUNTIMEPERMMISSION = 2;
    private static final String TAG = "ActivityDocsPrintPreview";
    private static final String confirmDlgShowPref = "ConfirmDlgShow";
    /* access modifiers changed from: private */
    public static final Object mConnect = new Object();
    private RelativeLayout.LayoutParams Relative_para;
    /* access modifiers changed from: private */
    public ArrayList<PaperSourceSetting> aPaperSourceSetting;
    boolean bAutoStartPrint = false;
    /* access modifiers changed from: private */
    public boolean confirmDlgShow = true;
    /* access modifiers changed from: private */
    public boolean disablePrintArea = false;
    /* access modifiers changed from: private */
    public String docFileName;
    /* access modifiers changed from: private */
    public String docFileName_org;
    /* access modifiers changed from: private */
    public boolean isBackKeyOK = true;
    boolean isCreateJobDone = false;
    boolean isEnableNFCTouch = false;
    private boolean isRemotePrinterOld = false;
    LoadRemotePreviewTask loadRemotePreviewTask = null;
    /* access modifiers changed from: private */
    public Bitmap mBitmap = null;
    /* access modifiers changed from: private */
    public IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
        public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
        }

        public void onGetInkState() throws RemoteException {
        }

        public void onGetStatusState() throws RemoteException {
        }

        public void onNotifyContinueable(int i) throws RemoteException {
        }

        public void onNotifyEndJob(int i) throws RemoteException {
        }

        public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
        }

        public void onNotifyProgress(int i, int i2) throws RemoteException {
        }
    };
    private int mColorMode;
    private PrintSetting mCurPrintSetting = null;
    private String mCurPrinterEmailAdress;
    private String mCurPrinterName;
    /* access modifiers changed from: private */
    public int mCurrentPageView;
    /* access modifiers changed from: private */
    public TextView mDisablePreviewMsg;
    /* access modifiers changed from: private */
    public int mEndPage;
    /* access modifiers changed from: private */
    public int mEndPageView;
    private ServiceConnection mEpsonConnection = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName componentName) {
            try {
                ActivityDocsPrintPreview.this.mEpsonService.unregisterCallback(ActivityDocsPrintPreview.this.mCallback);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            IEpsonService unused = ActivityDocsPrintPreview.this.mEpsonService = null;
        }

        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            IEpsonService unused = ActivityDocsPrintPreview.this.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
            if (ActivityDocsPrintPreview.this.mEpsonService != null) {
                try {
                    ActivityDocsPrintPreview.this.mEpsonService.registerCallback(ActivityDocsPrintPreview.this.mCallback);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    /* access modifiers changed from: private */
    public IEpsonService mEpsonService = null;
    /* access modifiers changed from: private */
    public ImageView mImageView;
    /* access modifiers changed from: private */
    public boolean mIsPortrait = true;
    private int mLayout;
    private int mLayoutMulti;
    /* access modifiers changed from: private */
    public LinearLayout mLn_zoomview;
    /* access modifiers changed from: private */
    public PrintProgress.ProgressParams mLocalPrintProgressParams;
    /* access modifiers changed from: private */
    public float mMoveX;
    /* access modifiers changed from: private */
    public Button mNext;
    /* access modifiers changed from: private */
    public TextView mPageNum;
    private Info_paper mPaperSize;
    /* access modifiers changed from: private */
    public pdfRender mPdfRender = null;
    /* access modifiers changed from: private */
    public Button mPre;
    /* access modifiers changed from: private */
    public volatile boolean mPreviewPaperAreaLandscape;
    /* access modifiers changed from: private */
    public Button mPrint;
    /* access modifiers changed from: private */
    public EPImageList mPrintImageList;
    /* access modifiers changed from: private */
    public PrintLog mPrintLog;
    private String mPrinterName;
    private View mProgress;
    /* access modifiers changed from: private */
    public EPImageList mRemotePreviewImageList = new EPImageList();
    private ReviewInvitationViewModel mReviewInvitationViewModel;
    /* access modifiers changed from: private */
    public RelativeLayout mRl_zoomview;
    /* access modifiers changed from: private */
    public TextView mSizeInfo;
    /* access modifiers changed from: private */
    public int mStartPage;
    /* access modifiers changed from: private */
    public int mStartPageView;
    /* access modifiers changed from: private */
    public float mStartX;
    final Handler mUiHandler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            if (ActivityDocsPrintPreview.this.isFinishing()) {
                int i = message.what;
                if (!(i == 4 || i == 6 || i == 13 || i == 22 || i == 39 || i == 50 || i == 100)) {
                    switch (i) {
                        case 0:
                        case 1:
                            break;
                        default:
                            switch (i) {
                                case 10:
                                case 11:
                                    break;
                                default:
                                    switch (i) {
                                        case 30:
                                        case 31:
                                        case 32:
                                        case 33:
                                            break;
                                    }
                            }
                    }
                }
                return true;
            }
            switch (message.what) {
                case 0:
                    EPLog.m305d(ActivityDocsPrintPreview.TAG, "handleMessage : CONVERTED_OK");
                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                    int unused = ActivityDocsPrintPreview.this.mCurrentPageView = message.getData().getInt(CommonDefine.CONVERTED_PAGE);
                    ActivityDocsPrintPreview.this.updatePageTextView();
                    ActivityDocsPrintPreview.this.updatePrevNextButtonView();
                    ActivityDocsPrintPreview activityDocsPrintPreview = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview.setNewImageView(activityDocsPrintPreview.mPdfRender.getConvertedPagePreview());
                    if (ActivityDocsPrintPreview.this.mCurrentPageView == 1) {
                        ActivityDocsPrintPreview activityDocsPrintPreview2 = ActivityDocsPrintPreview.this;
                        boolean unused2 = activityDocsPrintPreview2.mIsPortrait = !activityDocsPrintPreview2.mPdfRender.rotate();
                        ActivityDocsPrintPreview activityDocsPrintPreview3 = ActivityDocsPrintPreview.this;
                        activityDocsPrintPreview3.setOrentationView(activityDocsPrintPreview3.mIsPortrait);
                    }
                    ActivityDocsPrintPreview activityDocsPrintPreview4 = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview4.isEnableNFCTouch = true;
                    if (activityDocsPrintPreview4.bAutoStartPrint) {
                        ActivityDocsPrintPreview activityDocsPrintPreview5 = ActivityDocsPrintPreview.this;
                        activityDocsPrintPreview5.onClick(activityDocsPrintPreview5.mPrint);
                        EPLog.m305d(ActivityDocsPrintPreview.TAG, "onClick(mPrint)");
                        ActivityDocsPrintPreview.this.bAutoStartPrint = false;
                        break;
                    }
                    break;
                case 1:
                    ActivityDocsPrintPreview.this.showDialog(2);
                    break;
                case 4:
                    EPLog.m305d(ActivityDocsPrintPreview.TAG, "handleMessage : STAR_CONVERT");
                    ActivityDocsPrintPreview.this.enableProgressBar(true);
                    break;
                case 6:
                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                    ActivityDocsPrintPreview activityDocsPrintPreview6 = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview6.showErrorDialog(activityDocsPrintPreview6.getString(R.string.str_error_tile), ActivityDocsPrintPreview.this.getString(R.string.str_error_ms));
                    break;
                case 7:
                    if (ActivityDocsPrintPreview.this.mPdfRender != null) {
                        ActivityDocsPrintPreview.this.mPdfRender.setMIsPreviewCon(false);
                        ActivityDocsPrintPreview.this.mPdfRender.setPrintingStt(false);
                    }
                    ActivityDocsPrintPreview.this.cancelLoadRemotePreviewTask();
                    if (ActivityDocsPrintPreview.this.isCreateJobDone) {
                        try {
                            ActivityDocsPrintPreview.this.mEpsonService.EpsonConnectEndJob();
                            ActivityDocsPrintPreview.this.isCreateJobDone = false;
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                    }
                    ExternalFileUtils.getInstance(ActivityDocsPrintPreview.this).initTempViewDir();
                    ExternalFileUtils.getInstance(ActivityDocsPrintPreview.this).initTempCRDir();
                    ExternalFileUtils.getInstance(ActivityDocsPrintPreview.this).getPrintDir();
                    ExternalFileUtils.getInstance(ActivityDocsPrintPreview.this.getApplicationContext()).initTempCacheDirectory(ExternalFileUtils.TempCacheDirectory.GOOGLE_DRIVE_CONVERT);
                    ActivityDocsPrintPreview.this.finish();
                    break;
                case 10:
                    ActivityDocsPrintPreview.this.enableProgressBar(true);
                    if (ActivityDocsPrintPreview.this.mEpsonService != null) {
                        ActivityDocsPrintPreview.this.enableProgressBar(false);
                        int unused3 = ActivityDocsPrintPreview.this.mStartPageView = 1;
                        int unused4 = ActivityDocsPrintPreview.this.mCurrentPageView = 1;
                        int unused5 = ActivityDocsPrintPreview.this.mEndPageView = 1;
                        ActivityDocsPrintPreview.this.resetPageRange();
                        ActivityDocsPrintPreview activityDocsPrintPreview7 = ActivityDocsPrintPreview.this;
                        String unused6 = activityDocsPrintPreview7.docFileName = activityDocsPrintPreview7.docFileName_org;
                        ActivityDocsPrintPreview activityDocsPrintPreview8 = ActivityDocsPrintPreview.this;
                        activityDocsPrintPreview8.isEnableNFCTouch = false;
                        if (MyPrinter.isRemotePrinter(activityDocsPrintPreview8)) {
                            ActivityDocsPrintPreview activityDocsPrintPreview9 = ActivityDocsPrintPreview.this;
                            int unused7 = activityDocsPrintPreview9.printMode = (activityDocsPrintPreview9.remoteEnableShowPreview ? 2 : 0) | 1;
                            if (Utils.isECConvertFile(ActivityDocsPrintPreview.this.docFileName)) {
                                ActivityDocsPrintPreview activityDocsPrintPreview10 = ActivityDocsPrintPreview.this;
                                int unused8 = activityDocsPrintPreview10.printMode = activityDocsPrintPreview10.printMode | 4;
                            } else if (Utils.checkMimeType(ActivityDocsPrintPreview.this.docFileName, "application/pdf")) {
                                if (!ActivityDocsPrintPreview.this.mPdfRender.openPdfFile(ActivityDocsPrintPreview.this.docFileName, "", ActivityDocsPrintPreview.this)) {
                                    ActivityDocsPrintPreview activityDocsPrintPreview11 = ActivityDocsPrintPreview.this;
                                    int unused9 = activityDocsPrintPreview11.printMode = activityDocsPrintPreview11.printMode | 4;
                                }
                            } else if (Utils.isGConvertFile(ActivityDocsPrintPreview.this.docFileName)) {
                                ActivityDocsPrintPreview activityDocsPrintPreview12 = ActivityDocsPrintPreview.this;
                                int unused10 = activityDocsPrintPreview12.printMode = activityDocsPrintPreview12.printMode | 8;
                                ActivityDocsPrintPreview activityDocsPrintPreview13 = ActivityDocsPrintPreview.this;
                                int unused11 = activityDocsPrintPreview13.printMode = activityDocsPrintPreview13.printMode | 4;
                            } else {
                                ActivityDocsPrintPreview activityDocsPrintPreview14 = ActivityDocsPrintPreview.this;
                                Toast.makeText(activityDocsPrintPreview14, activityDocsPrintPreview14.getString(R.string.file_size_notsupport), 1).show();
                                ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                                return false;
                            }
                        } else {
                            int unused12 = ActivityDocsPrintPreview.this.printMode = 2;
                            if (Utils.isGConvertFile(ActivityDocsPrintPreview.this.docFileName)) {
                                ActivityDocsPrintPreview activityDocsPrintPreview15 = ActivityDocsPrintPreview.this;
                                int unused13 = activityDocsPrintPreview15.printMode = activityDocsPrintPreview15.printMode | 8;
                            } else if (!Utils.checkMimeType(ActivityDocsPrintPreview.this.docFileName, "application/pdf")) {
                                ActivityDocsPrintPreview activityDocsPrintPreview16 = ActivityDocsPrintPreview.this;
                                Toast.makeText(activityDocsPrintPreview16, activityDocsPrintPreview16.getString(R.string.file_size_notsupport), 1).show();
                                ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                                return false;
                            }
                        }
                        if ((ActivityDocsPrintPreview.this.printMode & 2) != 0) {
                            ActivityDocsPrintPreview.this.mDisablePreviewMsg.setVisibility(8);
                        } else {
                            ActivityDocsPrintPreview.this.mPageNum.setVisibility(4);
                            ActivityDocsPrintPreview.this.mPre.setVisibility(4);
                            ActivityDocsPrintPreview.this.mNext.setVisibility(4);
                            ActivityDocsPrintPreview.this.mImageView.setImageBitmap((Bitmap) null);
                            ActivityDocsPrintPreview.this.mDisablePreviewMsg.setVisibility(0);
                        }
                        ActivityDocsPrintPreview.this.mImageView.setImageBitmap((Bitmap) null);
                        ActivityDocsPrintPreview activityDocsPrintPreview17 = ActivityDocsPrintPreview.this;
                        activityDocsPrintPreview17.setOrentationView(activityDocsPrintPreview17.mIsPortrait);
                        if ((ActivityDocsPrintPreview.this.printMode & 8) == 0) {
                            new AsyncTaskExecutor<Void, Void, Void>() {
                                protected void onPreExecute() {
                                    super.onPreExecute();
                                    ActivityDocsPrintPreview.this.enableProgressBar(true);
                                }

                                protected Void doInBackground(Void... voidArr) {
                                    ActivityDocsPrintPreview.this.adjustPrintSettings();
                                    return null;
                                }

                                protected void onPostExecute(Void voidR) {
                                    super.onPostExecute(voidR);
                                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                                    ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(11);
                                }
                            }.executeOnExecutor(new Void[0]);
                            break;
                        } else {
                            new AsyncTaskExecutor<Void, Void, Boolean>() {
                                protected Boolean doInBackground(Void... voidArr) {
                                    MyUtility myUtility = new MyUtility();
                                    if (!epson.print.Util.Utils.getInstance().isNetworkAvailable(ActivityDocsPrintPreview.this) || myUtility.doNet(ActivityDocsPrintPreview.this) == "") {
                                        return false;
                                    }
                                    return true;
                                }

                                protected void onPostExecute(Boolean bool) {
                                    if (!ActivityDocsPrintPreview.this.isFinishing()) {
                                        super.onPostExecute(bool);
                                        if (!bool.booleanValue()) {
                                            ActivityDocsPrintPreview.this.showDialog(6);
                                        } else if (ActivityDocsPrintPreview.this.confirmDlgShow) {
                                            ActivityDocsPrintPreview.this.showDialog(5);
                                        } else {
                                            ActivityDocsPrintPreview.this.startConvertActivity();
                                        }
                                    }
                                }
                            }.executeOnExecutor(new Void[0]);
                            break;
                        }
                    } else {
                        ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessageDelayed(10, 100);
                        break;
                    }
                case 11:
                    if ((ActivityDocsPrintPreview.this.printMode & 4) == 0) {
                        ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(13);
                        break;
                    } else {
                        boolean unused14 = ActivityDocsPrintPreview.this.disablePrintArea = true;
                        if ((ActivityDocsPrintPreview.this.printMode & 2) != 0) {
                            if (!ActivityDocsPrintPreview.this.remoteEnableShowWarning) {
                                ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(30);
                                break;
                            } else {
                                ActivityDocsPrintPreview.this.showDialog(12);
                                break;
                            }
                        } else {
                            ActivityDocsPrintPreview.this.isEnableNFCTouch = true;
                            break;
                        }
                    }
                case 13:
                    if (!ActivityDocsPrintPreview.this.mPdfRender.openPdfFile(ActivityDocsPrintPreview.this.docFileName, ActivityDocsPrintPreview.this.pdfpass, ActivityDocsPrintPreview.this)) {
                        if (ActivityDocsPrintPreview.this.mPdfRender.canPrintableDoc()) {
                            ActivityDocsPrintPreview activityDocsPrintPreview18 = ActivityDocsPrintPreview.this;
                            int unused15 = activityDocsPrintPreview18.mEndPageView = activityDocsPrintPreview18.mPdfRender.totalPages();
                            ActivityDocsPrintPreview.this.resetPageRange();
                            if ((ActivityDocsPrintPreview.this.printMode & 2) != 2) {
                                ActivityDocsPrintPreview.this.isEnableNFCTouch = true;
                                break;
                            } else {
                                ActivityDocsPrintPreview.this.mPdfRender.startConvertPage(ActivityDocsPrintPreview.this.mCurrentPageView, 1, 0);
                                break;
                            }
                        } else {
                            Toast.makeText(ActivityDocsPrintPreview.this, R.string.str_error_ms_print, 1).show();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                            return false;
                        }
                    } else {
                        ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(1);
                        break;
                    }
                case 22:
                    ActivityDocsPrintPreview.this.mUiHandler.removeMessages(22);
                    if ((ActivityDocsPrintPreview.this.printMode & 4) != 0 && !ActivityDocsPrintPreview.this.isCreateJobDone) {
                        new PrintUploadTask().execute(new String[]{ActivityDocsPrintPreview.this.docFileName});
                        break;
                    } else {
                        new PreparePrintTask().executeOnExecutor(new Void[0]);
                        break;
                    }
                    break;
                case 30:
                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                    ActivityDocsPrintPreview activityDocsPrintPreview19 = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview19.loadRemotePreviewTask = new LoadRemotePreviewTask();
                    ActivityDocsPrintPreview.this.loadRemotePreviewTask.execute(new String[]{ActivityDocsPrintPreview.this.docFileName});
                    break;
                case 31:
                    EPLog.m305d(ActivityDocsPrintPreview.TAG, "handleMessage : CONVERTED_OK_EC");
                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                    int unused16 = ActivityDocsPrintPreview.this.mCurrentPageView = message.getData().getInt(CommonDefine.CONVERTED_PAGE);
                    ActivityDocsPrintPreview.this.updatePageTextView();
                    ActivityDocsPrintPreview.this.updatePrevNextButtonView();
                    ActivityDocsPrintPreview.this.setNewImageView((String) message.obj);
                    if (ActivityDocsPrintPreview.this.mBitmap != null) {
                        if (ActivityDocsPrintPreview.this.mBitmap.getWidth() > ActivityDocsPrintPreview.this.mBitmap.getHeight()) {
                            boolean unused17 = ActivityDocsPrintPreview.this.mIsPortrait = false;
                        } else {
                            boolean unused18 = ActivityDocsPrintPreview.this.mIsPortrait = true;
                        }
                        ActivityDocsPrintPreview activityDocsPrintPreview20 = ActivityDocsPrintPreview.this;
                        activityDocsPrintPreview20.setOrentationView(activityDocsPrintPreview20.mIsPortrait);
                    }
                    ActivityDocsPrintPreview activityDocsPrintPreview21 = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview21.isEnableNFCTouch = true;
                    if (activityDocsPrintPreview21.bAutoStartPrint) {
                        ActivityDocsPrintPreview activityDocsPrintPreview22 = ActivityDocsPrintPreview.this;
                        activityDocsPrintPreview22.onClick(activityDocsPrintPreview22.mPrint);
                        EPLog.m305d(ActivityDocsPrintPreview.TAG, "onClick(mPrint)");
                        ActivityDocsPrintPreview.this.bAutoStartPrint = false;
                        break;
                    }
                    break;
                case 32:
                    boolean unused19 = ActivityDocsPrintPreview.this.disablePrintArea = false;
                    ActivityDocsPrintPreview.this.resetPageRange();
                    ActivityDocsPrintPreview.this.updatePrevNextButtonView();
                    ActivityDocsPrintPreview.this.updatePageTextView();
                    break;
                case 33:
                    ActivityDocsPrintPreview.this.resetPageRangeBySettings();
                    if ((ActivityDocsPrintPreview.this.printMode & 4) == 0) {
                        if ((ActivityDocsPrintPreview.this.printMode & 2) == 0) {
                            ActivityDocsPrintPreview activityDocsPrintPreview23 = ActivityDocsPrintPreview.this;
                            activityDocsPrintPreview23.setOrentationView(activityDocsPrintPreview23.mIsPortrait);
                            break;
                        } else {
                            ActivityDocsPrintPreview.this.loadConfig();
                            ActivityDocsPrintPreview.this.mPdfRender.startConvertPage(1, 1, 0);
                            break;
                        }
                    } else if (ActivityDocsPrintPreview.this.isRemotePrintSettingsChanged()) {
                        if ((ActivityDocsPrintPreview.this.printMode & 2) == 0) {
                            ActivityDocsPrintPreview activityDocsPrintPreview24 = ActivityDocsPrintPreview.this;
                            activityDocsPrintPreview24.isCreateJobDone = false;
                            activityDocsPrintPreview24.setOrentationView(activityDocsPrintPreview24.mIsPortrait);
                            break;
                        } else {
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(30);
                            break;
                        }
                    }
                    break;
                case 39:
                    String string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_GENERAL_TITLE);
                    String string2 = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_GENERAL);
                    boolean unused20 = ActivityDocsPrintPreview.this.isBackKeyOK = true;
                    int i2 = message.arg1;
                    if (i2 != -1100) {
                        if (i2 != -1056) {
                            if (i2 != -1) {
                                switch (i2) {
                                    case EccErrorInfo.ECC_ERR_SVR_HTTP_NOT_FOUND /*-1209*/:
                                    case EccErrorInfo.ECC_ERR_SVR_BUSY /*-1208*/:
                                        string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_BUSY_TITLE);
                                        string2 = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_BUSY) + "0X" + Integer.toHexString(message.arg1).toUpperCase() + ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_BUSY2);
                                        break;
                                    case EccErrorInfo.ECC_ERR_SVR_PAGE_NOT_PREPARED /*-1207*/:
                                        new AlertDialog.Builder(ActivityDocsPrintPreview.this).setCancelable(false).setTitle(string).setMessage(ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_PAGE_NOT_PREPARED)).setNegativeButton(ActivityDocsPrintPreview.this.getString(R.string.f343ok), new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialogInterface, int i) {
                                                ActivityDocsPrintPreview.this.enableProgressBar(false);
                                                dialogInterface.cancel();
                                            }
                                        }).create().show();
                                        return false;
                                    case -1206:
                                        string = ActivityDocsPrintPreview.this.getString(R.string.epsonconnect_str_print_job_too_many_title);
                                        string2 = ActivityDocsPrintPreview.this.getString(R.string.epsonconnect_str_print_job_too_many);
                                        break;
                                    case -1205:
                                        string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_FILE_TOO_LONG_TITLE);
                                        try {
                                            string2 = String.format(ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_FILE_TOO_LONG_FORMAT), new Object[]{Integer.valueOf(ActivityDocsPrintPreview.this.mEpsonService.EpsonConnectGetRemotePrintMaxFileSize() / 1048576)});
                                            break;
                                        } catch (Exception e2) {
                                            e2.printStackTrace();
                                            break;
                                        }
                                    case -1204:
                                    case -1200:
                                        break;
                                    case -1203:
                                        string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_INVALID_ACCESSKEY_TITLE);
                                        string2 = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_INVALID_ACCESSKEY);
                                        break;
                                    case -1202:
                                        string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_REMOTE_INVALID_TITLE);
                                        string2 = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_REMOTE_INVALID);
                                        break;
                                    case -1201:
                                        string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_NOT_REGISTERED_TITLE);
                                        string2 = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_NOT_REGISTERED);
                                        break;
                                }
                            } else {
                                string = ActivityDocsPrintPreview.this.getString(R.string.epsonconnect_str_error_filename_too_long_title);
                                string2 = ActivityDocsPrintPreview.this.getString(R.string.epsonconnect_str_error_filename_too_long);
                            }
                        }
                        string = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_GENERAL_TITLE);
                        string2 = ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_GENERAL) + ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_GENERAL2) + "0X" + Integer.toHexString(message.arg1).toUpperCase() + ActivityDocsPrintPreview.this.getString(R.string.ECC_ERR_SVR_GENERAL3);
                    } else {
                        string = ActivityDocsPrintPreview.this.getString(R.string.EC_ERR_COMM_ERROR_TITLE);
                        string2 = ActivityDocsPrintPreview.this.getString(R.string.EC_ERR_COMM_ERROR);
                    }
                    ActivityDocsPrintPreview.this.showErrorDialog(string, string2);
                    break;
                case 50:
                    ActivityDocsPrintPreview.this.mLn_zoomview.invalidate();
                    ActivityDocsPrintPreview.this.mRl_zoomview.invalidate();
                    break;
                case 100:
                    ArrayList unused21 = ActivityDocsPrintPreview.this.aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
                    if (ActivityDocsPrintPreview.this.aPaperSourceSetting == null) {
                        ActivityDocsPrintPreview.this.mSizeInfo.setBackground(ActivityDocsPrintPreview.this.getResources().getDrawable(R.C2136drawable.text_view_boder));
                        ActivityDocsPrintPreview.this.mSizeInfo.setTextColor(ActivityDocsPrintPreview.this.getResources().getColor(R.color.epson_blue));
                        ActivityDocsPrintPreview.this.paperMissmath.setVisibility(8);
                        break;
                    } else {
                        ActivityDocsPrintPreview.this.mSizeInfo.setBackgroundColor(ActivityDocsPrintPreview.this.getResources().getColor(R.color.epson_blue));
                        ActivityDocsPrintPreview.this.mSizeInfo.setTextColor(ActivityDocsPrintPreview.this.getResources().getColor(R.color.all_white));
                        PrintSetting printSetting = new PrintSetting(ActivityDocsPrintPreview.this, PrintSetting.Kind.document);
                        printSetting.loadSettings();
                        if (!ActivityDocsPrintPreview.this.paperSourceInfo.checkPaperMissmatch(printSetting, ActivityDocsPrintPreview.this.aPaperSourceSetting)) {
                            ActivityDocsPrintPreview.this.paperMissmath.setVisibility(8);
                            break;
                        } else {
                            ActivityDocsPrintPreview.this.paperMissmath.setVisibility(0);
                            break;
                        }
                    }
            }
            return false;
        }
    });
    /* access modifiers changed from: private */
    public ImageView paperMissmath = null;
    private int paperSize;
    PaperSourceInfo paperSourceInfo = null;
    /* access modifiers changed from: private */
    public String pdfpass = "";
    /* access modifiers changed from: private */
    public int printMode = 2;
    private String printerId;
    /* access modifiers changed from: private */
    public boolean remoteEnableShowPreview = true;
    /* access modifiers changed from: private */
    public boolean remoteEnableShowWarning = true;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        NewLoggerController.stopLoggerIfNotAgreed(this);
        this.mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
        this.mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
        this.mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
            public void onChanged(@Nullable Boolean bool) {
                if (bool.booleanValue()) {
                    ActivityDocsPrintPreview.this.showStoreDialog();
                }
            }
        });
        Intent intent = getIntent();
        try {
            this.mPrintLog = (PrintLog) intent.getSerializableExtra("print_log");
        } catch (ClassCastException unused) {
        }
        epson.print.Util.Utils.getInstance();
        ExternalFileUtils.getInstance(this).initTempViewDir();
        ExternalFileUtils.getInstance(this).initTempCRDir();
        ExternalFileUtils.getInstance(this).initPrintDir();
        ExternalFileUtils.getInstance(getApplicationContext()).initTempCacheDirectory(ExternalFileUtils.TempCacheDirectory.GOOGLE_DRIVE_CONVERT);
        setContentView((int) R.layout.doc_print_preview);
        setActionBar((int) R.string.document_btn_label, true);
        this.mProgress = findViewById(R.id.progress);
        this.mPageNum = (TextView) findViewById(R.id.tv_page_num);
        this.mSizeInfo = (TextView) findViewById(R.id.tv_page_size);
        this.mPre = (Button) findViewById(R.id.btn_pre);
        this.mNext = (Button) findViewById(R.id.btn_next);
        this.mPrint = (Button) findViewById(R.id.btn_print);
        this.mLn_zoomview = (LinearLayout) findViewById(R.id.ln_zoomview);
        this.mRl_zoomview = (RelativeLayout) findViewById(R.id.rl_zoomview);
        this.mImageView = (ImageView) findViewById(R.id.zoomview);
        this.mDisablePreviewMsg = (TextView) findViewById(R.id.textViewNoPreviewMsg);
        this.paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
        this.mSizeInfo.setOnClickListener(this);
        this.mPrint.setOnClickListener(this);
        this.mPre.setOnClickListener(this);
        this.mPre.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()) {
                    case 0:
                        ActivityDocsPrintPreview.this.mPre.setBackgroundResource(R.C2136drawable.bt_left_hover);
                        return false;
                    case 1:
                        ActivityDocsPrintPreview.this.mPre.setBackgroundResource(R.C2136drawable.bt_left);
                        return false;
                    default:
                        return false;
                }
            }
        });
        this.mNext.setOnClickListener(this);
        this.mNext.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()) {
                    case 0:
                        ActivityDocsPrintPreview.this.mNext.setBackgroundResource(R.C2136drawable.bt_right_hover);
                        return false;
                    case 1:
                        ActivityDocsPrintPreview.this.mNext.setBackgroundResource(R.C2136drawable.bt_right_1);
                        return false;
                    default:
                        return false;
                }
            }
        });
        this.mImageView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View view, MotionEvent motionEvent) {
                Display defaultDisplay = ActivityDocsPrintPreview.this.getWindowManager().getDefaultDisplay();
                Point point = new Point();
                defaultDisplay.getSize(point);
                float f = (float) point.y;
                float f2 = (float) point.x;
                if ((ActivityDocsPrintPreview.this.printMode & 2) == 0) {
                    return true;
                }
                if (f > f2) {
                    f = f2;
                }
                switch (motionEvent.getAction()) {
                    case 0:
                        float unused = ActivityDocsPrintPreview.this.mStartX = motionEvent.getX();
                        float unused2 = ActivityDocsPrintPreview.this.mMoveX = 0.0f;
                        break;
                    case 1:
                        ActivityDocsPrintPreview activityDocsPrintPreview = ActivityDocsPrintPreview.this;
                        float unused3 = activityDocsPrintPreview.mMoveX = activityDocsPrintPreview.mStartX - motionEvent.getX();
                        break;
                }
                float f3 = f / 10.0f;
                if (ActivityDocsPrintPreview.this.mMoveX > f3) {
                    if (ActivityDocsPrintPreview.this.mCurrentPageView == ActivityDocsPrintPreview.this.mEndPageView) {
                        return true;
                    }
                    ActivityDocsPrintPreview activityDocsPrintPreview2 = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview2.onClick(activityDocsPrintPreview2.mNext);
                } else if (ActivityDocsPrintPreview.this.mMoveX >= f3 * -1.0f || ActivityDocsPrintPreview.this.mCurrentPageView == 1) {
                    return true;
                } else {
                    ActivityDocsPrintPreview activityDocsPrintPreview3 = ActivityDocsPrintPreview.this;
                    activityDocsPrintPreview3.onClick(activityDocsPrintPreview3.mPre);
                }
                return true;
            }
        });
        this.mPdfRender = new pdfRender(this, this.mUiHandler);
        if ("android.intent.action.VIEW".equals(intent.getAction()) || "android.intent.action.SEND".equals(intent.getAction())) {
            this.docFileName = getDocFileNameFromIntent(intent);
            String str = this.docFileName;
            if (str == null || str.length() == 0) {
                EPLog.m307e(TAG, "onCreate : Error ACTION_VIEW or ACTION_SEND");
                Toast.makeText(this, getString(R.string.file_size_notsupport), 1).show();
                finish();
                return;
            }
            setPrintLogForExternalApp(this.docFileName);
        } else {
            this.docFileName = intent.getStringExtra(CommonDefine.SEND_DOCUMENT_VIEW);
        }
        this.docFileName_org = this.docFileName;
        if (intent.getIntExtra("from", 3) == 4) {
            setTitle(getString(R.string.network_storage_title));
        } else {
            setTitle(getString(R.string.document_btn_label));
        }
        this.confirmDlgShow = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(confirmDlgShowPref, true);
        SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0);
        this.remoteEnableShowPreview = sharedPreferences.getBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
        this.remoteEnableShowWarning = sharedPreferences.getBoolean(Constants.ENABLE_SHOW_WARNING, true);
        this.paperSourceInfo = PaperSourceInfo.getInstance(this);
        if (bundle == null) {
            startLicenseCheckActivity();
        } else if (!IprintLicenseInfo.isAgreedCurrentVersion(getApplicationContext())) {
            finish();
        } else {
            onInitEnd();
        }
    }

    /* access modifiers changed from: private */
    public void showStoreDialog() {
        ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
    }

    private void startLicenseCheckActivity() {
        IprintLicenseInfo.beforeLicenseCheck(getApplicationContext());
        startActivityForResult(LicenseTopActivity.getStartIntent(getApplicationContext(), new IprintLicenseInfo(), new IprintUserSurveyInfo()), 3);
    }

    private void onInitEnd() {
        if (this.mEpsonService == null) {
            bindService(new Intent(this, EpsonService.class), this.mEpsonConnection, 1);
        }
        if (ActivityRequestPermissions.isRuntimePermissionSupported() && !this.docFileName.toLowerCase().startsWith(ExternalFileUtils.getInstance(this).getWorkingDir().toLowerCase())) {
            String[] strArr = {"android.permission.WRITE_EXTERNAL_STORAGE"};
            ActivityRequestPermissions.Permission permission = new ActivityRequestPermissions.Permission(strArr[0], new String[]{getString(R.string.permission_dialog_title), getString(R.string.permission_dialog_title)}, new String[]{ActivityRequestPermissions.DialogParameter.setMessage2((Context) this, getString(R.string.permission_dialog_message_storage)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) this, getString(R.string.permission_dialog_message_storage), getString(R.string.permission_function_storage))});
            if (!ActivityRequestPermissions.checkPermission(this, strArr)) {
                ActivityRequestPermissions.requestPermission((Activity) this, permission, 2);
                return;
            }
        }
        this.mUiHandler.sendEmptyMessage(10);
    }

    private void setPrintLogForExternalApp(String str) {
        if (this.mPrintLog == null) {
            this.mPrintLog = new PrintLog();
        }
        if (this.mPrintLog == null) {
            this.mPrintLog = new PrintLog();
        }
        if (this.mPrintLog.callerPackage == null) {
            this.mPrintLog.callerPackage = getCallingPackage();
        }
        if (this.mPrintLog.uiRoute <= 0) {
            this.mPrintLog.uiRoute = 4098;
        }
        if (this.mPrintLog.originalFileExtension == null) {
            this.mPrintLog.originalFileExtension = PrintLog.getFileExtension(str);
        }
    }

    private String getDocFileNameFromIntent(Intent intent) {
        Uri uri;
        if ("android.intent.action.VIEW".equals(intent.getAction())) {
            EPLog.m313i(TAG, "getDocFileNameFromIntent : Intent.ACTION_VIEW.equals(intent.getAction())");
            uri = intent.getData();
        } else if ("android.intent.action.SEND".equals(intent.getAction())) {
            EPLog.m313i(TAG, "getDocFileNameFromIntent : Intent.ACTION_SEND.equals(intent.getAction())");
            uri = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
        } else {
            uri = null;
        }
        if (uri == null) {
            return null;
        }
        EPLog.m313i(TAG, "getDocFileNameFromIntent : Call by Intent url =" + uri);
        if (uri.getScheme().equals("content")) {
            EPLog.m313i(TAG, "getDocFileNameFromIntent : content");
            ContentResolver contentResolver = getContentResolver();
            try {
                String type = intent.getType();
                if (type == null) {
                    EPLog.m318w(TAG, "getDocFileNameFromIntent : Not set Type");
                    String extention = Utils.getExtention(uri.getPath());
                    if (extention != null) {
                        type = Utils.getExtType(extention);
                        EPLog.m313i(TAG, "getDocFileNameFromIntent : fType = " + type);
                    }
                }
                String makeTempFileName = Utils.makeTempFileName(type);
                InputStream openInputStream = contentResolver.openInputStream(uri);
                File file = new File(ExternalFileUtils.getInstance(this).getTempCRDir(), makeTempFileName);
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                byte[] bArr = new byte[1024];
                while (true) {
                    int read = openInputStream.read(bArr);
                    if (read > 0) {
                        fileOutputStream.write(bArr, 0, read);
                    } else {
                        fileOutputStream.close();
                        return file.getPath();
                    }
                }
            } catch (IOException | SecurityException e) {
                EPLog.m307e(TAG, "getDocFileNameFromIntent : " + e.toString());
                Toast.makeText(getApplicationContext(), getString(R.string.file_size_notsupport), 1).show();
                finish();
                return null;
            }
        } else if (!uri.getScheme().equals(BoxFile.TYPE)) {
            return null;
        } else {
            String path = uri.getPath();
            return path.startsWith("/file:") ? path.substring(6) : path;
        }
    }

    protected void onDestroy() {
        super.onDestroy();
        Bitmap bitmap = this.mBitmap;
        if (bitmap != null) {
            bitmap.recycle();
            this.mBitmap = null;
        }
        if (this.mImageView != null) {
            this.mImageView = null;
        }
        IEpsonService iEpsonService = this.mEpsonService;
        if (iEpsonService != null) {
            try {
                iEpsonService.unregisterCallback(this.mCallback);
                unbindService(this.mEpsonConnection);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    public void onBackPressed() {
        if (this.isBackKeyOK) {
            this.mUiHandler.sendEmptyMessage(7);
        }
    }

    protected void onResume() {
        super.onResume();
        NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
        this.paperMissmath.setVisibility(8);
        this.paperSourceInfo.start(this, this.mUiHandler);
    }

    protected void onPause() {
        super.onPause();
        NfcTagUtils.disableForegroundDispatch(this);
        this.paperSourceInfo.stop();
    }

    protected void onNewIntent(Intent intent) {
        NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
        super.onNewIntent(intent);
        String action = intent.getAction();
        if (this.isEnableNFCTouch && "android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
            cancelLoadRemotePreviewTask();
            saveCurSettings();
            Intent intent2 = new Intent();
            intent2.setClass(this, ActivityNfcPrinter.class);
            intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
            intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
            startActivityForResult(intent2, 5);
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 255) {
            switch (i) {
                case 1:
                    switch (i2) {
                        case 100:
                            EPLog.m313i(TAG, "onActivityResult : CONVERT_OK");
                            this.docFileName = intent.getStringExtra(CommonDefine.DOWNLOAD_PATH);
                            new AsyncTaskExecutor<Void, Void, Void>() {
                                protected void onPreExecute() {
                                    super.onPreExecute();
                                    ActivityDocsPrintPreview.this.enableProgressBar(true);
                                }

                                protected Void doInBackground(Void... voidArr) {
                                    ActivityDocsPrintPreview.this.adjustPrintSettings();
                                    return null;
                                }

                                protected void onPostExecute(Void voidR) {
                                    super.onPostExecute(voidR);
                                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                                    ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(11);
                                }
                            }.executeOnExecutor(new Void[0]);
                            break;
                        case 101:
                            EPLog.m313i(TAG, "onActivityResult : CONVERT_FAIL");
                            showDialog(7);
                            break;
                        case 102:
                            EPLog.m313i(TAG, "onActivityResult : SIZE_ERROR");
                            showDialog(11);
                            break;
                        case 104:
                            EPLog.m313i(TAG, "onActivityResult : SIZE_ERROR");
                            showDialog(8);
                            break;
                        case 105:
                            EPLog.m313i(TAG, "onActivityResult : SIZE_ERROR");
                            showDialog(9);
                            break;
                        case 106:
                            EPLog.m313i(TAG, "onActivityResult : SIZE_ERROR");
                            showDialog(10);
                            break;
                        default:
                            EPLog.m313i(TAG, "onActivityResult : ELSE");
                            this.mUiHandler.sendEmptyMessage(7);
                            break;
                    }
                case 2:
                    if (i2 != -1) {
                        onBackPressed();
                        return;
                    } else {
                        this.mUiHandler.sendEmptyMessage(10);
                        return;
                    }
                case 3:
                    if (i2 != -1) {
                        finish();
                        return;
                    } else {
                        onInitEnd();
                        return;
                    }
                default:
                    switch (i) {
                        case 5:
                            if (i2 != -1) {
                                return;
                            }
                            if (this.isRemotePrinterOld != MyPrinter.isRemotePrinter(this)) {
                                Toast.makeText(this, R.string.nfc_connect_printpreview, 1).show();
                                WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, MyPrinter.getCurPrinter(this).getIp());
                                this.mUiHandler.sendEmptyMessage(10);
                                return;
                            }
                            new AsyncTaskExecutor<Void, Void, Void>() {
                                protected void onPreExecute() {
                                    super.onPreExecute();
                                    ActivityDocsPrintPreview.this.enableProgressBar(true);
                                }

                                protected Void doInBackground(Void... voidArr) {
                                    ActivityDocsPrintPreview.this.adjustPrintSettings();
                                    return null;
                                }

                                protected void onPostExecute(Void voidR) {
                                    super.onPostExecute(voidR);
                                    ActivityDocsPrintPreview.this.enableProgressBar(false);
                                    ActivityDocsPrintPreview activityDocsPrintPreview = ActivityDocsPrintPreview.this;
                                    activityDocsPrintPreview.bAutoStartPrint = true;
                                    activityDocsPrintPreview.mUiHandler.sendEmptyMessage(33);
                                }
                            }.executeOnExecutor(new Void[0]);
                            return;
                        case 6:
                            break;
                        default:
                            return;
                    }
            }
            if (i2 != 3) {
                return;
            }
            if (this.isRemotePrinterOld != MyPrinter.isRemotePrinter(this)) {
                this.mUiHandler.sendEmptyMessage(10);
            } else {
                this.mUiHandler.sendEmptyMessage(33);
            }
        } else {
            pdfRender pdfrender = this.mPdfRender;
            if (pdfrender != null) {
                pdfrender.setPrintingStt(false);
            }
            this.mPrint.setEnabled(true);
            this.mReviewInvitationViewModel.onPrintEnd(PrintProgress.isPrintSuccess(i2));
        }
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_next /*2131230873*/:
                nextPage();
                return;
            case R.id.btn_pre /*2131230876*/:
                prevPage();
                return;
            case R.id.btn_print /*2131230877*/:
                if (this.mPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
                    showDialog(4);
                    return;
                } else if ((this.printMode & 1) == 0 || !this.remoteEnableShowWarning) {
                    this.mUiHandler.sendEmptyMessage(22);
                    return;
                } else {
                    showDialog(13);
                    return;
                }
            case R.id.tv_page_size /*2131231601*/:
                if (this.aPaperSourceSetting != null) {
                    Intent intent = new Intent();
                    intent.setClass(this, PaperSourceSettingScr.class);
                    intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.document.name());
                    intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, this.aPaperSourceSetting);
                    startActivityForResult(intent, 6);
                    return;
                }
                callPrintSetting();
                return;
            default:
                return;
        }
    }

    private void prevPage() {
        if ((this.printMode & 4) != 0) {
            int i = this.mCurrentPageView;
            if (i > 1 && i > this.mStartPageView) {
                EPImage ePImage = this.mRemotePreviewImageList.get(i - 2);
                Message message = new Message();
                message.what = 31;
                message.obj = ePImage.loadImageFileName;
                message.getData().putInt(CommonDefine.CONVERTED_PAGE, this.mCurrentPageView - 1);
                this.mUiHandler.sendMessage(message);
                return;
            }
            return;
        }
        int i2 = this.mCurrentPageView;
        if (i2 > 1 && i2 > this.mStartPageView) {
            this.mPdfRender.startConvertPage(i2 - 1, 1, 0);
        }
    }

    private void nextPage() {
        if ((this.printMode & 4) == 0) {
            int i = this.mCurrentPageView;
            int i2 = this.mEndPageView;
            if (i < i2 && i < i2) {
                this.mPdfRender.startConvertPage(i + 1, 1, 0);
            }
        } else if (this.mCurrentPageView < this.mRemotePreviewImageList.size()) {
            EPImage ePImage = this.mRemotePreviewImageList.get(this.mCurrentPageView);
            Message message = new Message();
            message.what = 31;
            message.obj = ePImage.loadImageFileName;
            message.getData().putInt(CommonDefine.CONVERTED_PAGE, this.mCurrentPageView + 1);
            this.mUiHandler.sendMessage(message);
        } else {
            new LoadRemotePreviewNext().executeOnExecutor(new Void[0]);
        }
    }

    protected Dialog onCreateDialog(int i) {
        Dialog onCreateDialog = super.onCreateDialog(i);
        if (i != 2) {
            switch (i) {
                case 4:
                    return new AlertDialog.Builder(this).setCancelable(false).setTitle(R.string.printer_not_select).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }).create();
                case 5:
                    final AlertDialog create = new AlertDialog.Builder(this).create();
                    View inflate = LayoutInflater.from(this).inflate(R.layout.dlg_mes_checkbox, (ViewGroup) findViewById(R.id.layout_root));
                    create.setView(inflate);
                    create.setCancelable(false);
                    create.setTitle(getString(R.string.google_drive));
                    create.setMessage(getString(R.string.agreement_google_docs_convert));
                    CheckBox checkBox = (CheckBox) inflate.findViewById(R.id.checkBox1);
                    checkBox.setText(getString(R.string.not_display_next_time));
                    checkBox.setChecked(false);
                    checkBox.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View view) {
                            boolean unused = ActivityDocsPrintPreview.this.confirmDlgShow = !((CheckBox) view).isChecked();
                        }
                    });
                    create.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (!ActivityDocsPrintPreview.this.confirmDlgShow) {
                                SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(ActivityDocsPrintPreview.this).edit();
                                edit.putBoolean(ActivityDocsPrintPreview.confirmDlgShowPref, ActivityDocsPrintPreview.this.confirmDlgShow);
                                edit.commit();
                            }
                            create.dismiss();
                            ActivityDocsPrintPreview.this.startConvertActivity();
                        }
                    });
                    create.setButton(-2, getString(R.string.str_no), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create.dismiss();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create;
                case 6:
                    final AlertDialog create2 = new AlertDialog.Builder(this).create();
                    create2.setTitle(R.string.str_warnig);
                    create2.setMessage(getString(R.string.str_no_internet));
                    create2.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create2.dismiss();
                            ActivityDocsPrintPreview.this.startActivity(new Intent("android.settings.WIRELESS_SETTINGS"));
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create2;
                case 7:
                    final AlertDialog create3 = new AlertDialog.Builder(this).create();
                    create3.setTitle(getString(R.string.error));
                    create3.setMessage(getString(R.string.err_convert_gdocs));
                    create3.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create3.dismiss();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create3;
                case 8:
                    final AlertDialog create4 = new AlertDialog.Builder(this).create();
                    create4.setTitle(getString(R.string.err_title_file_size_gdocs));
                    create4.setMessage(String.format(getString(R.string.err_file_size_gdocs), new Object[]{2}));
                    create4.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create4.dismiss();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create4;
                case 9:
                    final AlertDialog create5 = new AlertDialog.Builder(this).create();
                    create5.setTitle(getString(R.string.err_title_file_size_gdocs));
                    create5.setMessage(String.format(getString(R.string.err_file_size_gdocs), new Object[]{20}));
                    create5.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create5.dismiss();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create5;
                case 10:
                    final AlertDialog create6 = new AlertDialog.Builder(this).create();
                    create6.setTitle(getString(R.string.err_title_file_size_gdocs));
                    create6.setMessage(String.format(getString(R.string.err_file_size_gdocs), new Object[]{10}));
                    create6.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create6.dismiss();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create6;
                case 11:
                    final AlertDialog create7 = new AlertDialog.Builder(this).create();
                    create7.setTitle(getString(R.string.error));
                    create7.setMessage(getString(R.string.network_error_mes));
                    create7.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            create7.dismiss();
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    });
                    return create7;
                case 12:
                    AlertDialog.Builder cancelable = new AlertDialog.Builder(this).setCancelable(false);
                    return cancelable.setMessage(getString(R.string.epsonconnect_str_remote_print_warning) + "\n\n" + getString(R.string.epsonconnect_str_remote_print_warning2)).setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(30);
                        }
                    }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                        }
                    }).create();
                case 13:
                    AlertDialog.Builder cancelable2 = new AlertDialog.Builder(this).setCancelable(false);
                    return cancelable2.setMessage(getString(R.string.epsonconnect_str_remote_print_warning) + "\n\n" + getString(R.string.epsonconnect_str_remote_print_warning2)).setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(22);
                        }
                    }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }).create();
                default:
                    return onCreateDialog;
            }
        } else {
            View inflate2 = LayoutInflater.from(this).inflate(R.layout.pdf_file_password, (ViewGroup) null);
            final EditText editText = (EditText) inflate2.findViewById(R.id.etPassword);
            return new AlertDialog.Builder(this).setIcon(R.C2136drawable.file).setTitle(getString(R.string.str_enter_pass)).setView(inflate2).setCancelable(false).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                    String unused = ActivityDocsPrintPreview.this.pdfpass = editText.getText().toString();
                    if (!ActivityDocsPrintPreview.this.mPdfRender.openPdfFile(ActivityDocsPrintPreview.this.docFileName, ActivityDocsPrintPreview.this.pdfpass, ActivityDocsPrintPreview.this)) {
                        ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(13);
                    } else {
                        ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(1);
                    }
                }
            }).setNegativeButton(getString(R.string.str_cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                    ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
                }
            }).create();
        }
    }

    /* access modifiers changed from: private */
    public void startConvertActivity() {
        startActivityForResult(ConvertProgressActivity.getStartIntent(this, this.docFileName), 1);
    }

    public void callPrintSetting() {
        cancelLoadRemotePreviewTask();
        saveCurSettings();
        SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
        edit.putInt(Constants.SOURCE_TYPE, 1);
        edit.commit();
        Intent intent = new Intent(this, SettingScr.class);
        intent.putExtra(PrintProgress.PARAM_DOCUMENT_MODE, true);
        if ((this.printMode & 4) != 0) {
            intent.putExtra("SHEETS", this.mEndPageView);
            intent.putExtra("PRINTAREA", this.disablePrintArea);
        } else {
            intent.putExtra("SHEETS", this.mPdfRender.totalPages());
        }
        intent.setAction("android.intent.action.VIEW");
        startActivityForResult(intent, 6);
    }

    private class PreparePrintTask extends AsyncTaskExecutor<Void, Void, Void> {
        private boolean mIsLandscape;
        EPImageList tmpList = new EPImageList();

        public PreparePrintTask() {
        }

        protected void onPreExecute() {
            ActivityDocsPrintPreview.this.enableProgressBar(true);
            ActivityDocsPrintPreview.this.mPrint.setEnabled(false);
            this.mIsLandscape = calcLandscape();
        }

        private boolean calcLandscape() {
            return (ActivityDocsPrintPreview.this.mLn_zoomview.getRight() - ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingRight()) - (ActivityDocsPrintPreview.this.mLn_zoomview.getLeft() + ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingLeft()) > (ActivityDocsPrintPreview.this.mLn_zoomview.getBottom() - ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingBottom()) - (ActivityDocsPrintPreview.this.mLn_zoomview.getTop() + ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingTop());
        }

        protected Void doInBackground(Void... voidArr) {
            if ((ActivityDocsPrintPreview.this.printMode & 4) != 0) {
                ActivityDocsPrintPreview.this.cancelLoadRemotePreviewTask();
            } else if ((ActivityDocsPrintPreview.this.printMode & 1) != 0) {
                OLD_setImageListForLocalPrinter();
            } else {
                setImageListForLocalPrinter2();
            }
            if ((ActivityDocsPrintPreview.this.printMode & 1) == 0) {
                return null;
            }
            SharedPreferences.Editor edit = ActivityDocsPrintPreview.this.getSharedPreferences("PrintSetting", 0).edit();
            if ((ActivityDocsPrintPreview.this.printMode & 4) != 0) {
                edit.putInt(Constants.SOURCE_TYPE, 1);
                this.tmpList.clear();
                EPImage ePImage = new EPImage();
                ePImage.loadImageFileName = ActivityDocsPrintPreview.this.docFileName_org;
                ePImage.setOrgName(ActivityDocsPrintPreview.this.docFileName_org);
                this.tmpList.add(ePImage);
            } else {
                edit.putInt(Constants.SOURCE_TYPE, 3);
                EPImage ePImage2 = this.tmpList.get(0);
                if (ActivityDocsPrintPreview.this.docFileName_org.lastIndexOf(47) > 0) {
                    ePImage2.webUrl = ActivityDocsPrintPreview.this.docFileName_org.substring(ActivityDocsPrintPreview.this.docFileName_org.lastIndexOf(47) + 1);
                } else {
                    ePImage2.webUrl = ActivityDocsPrintPreview.this.docFileName_org;
                }
            }
            edit.commit();
            return null;
        }

        private void setImageListForLocalPrinter2() {
            ExternalFileUtils.getInstance(ActivityDocsPrintPreview.this).initPrintDir();
            if (ActivityDocsPrintPreview.this.mPrintLog == null) {
                PrintLog unused = ActivityDocsPrintPreview.this.mPrintLog = new PrintLog();
            }
            ActivityDocsPrintPreview.this.mPrintLog.previewType = 2;
            ActivityDocsPrintPreview activityDocsPrintPreview = ActivityDocsPrintPreview.this;
            PrintProgress.ProgressParams unused2 = activityDocsPrintPreview.mLocalPrintProgressParams = new LocalDocumentParams(activityDocsPrintPreview.docFileName, ActivityDocsPrintPreview.this.docFileName_org, ActivityDocsPrintPreview.this.pdfpass, ActivityDocsPrintPreview.this.mPreviewPaperAreaLandscape, ActivityDocsPrintPreview.this.mStartPage, ActivityDocsPrintPreview.this.mEndPage, ActivityDocsPrintPreview.this.mPrintLog);
        }

        private void OLD_setImageListForLocalPrinter() {
            int i;
            int i2;
            ExternalFileUtils.getInstance(ActivityDocsPrintPreview.this).initPrintDir();
            for (int access$4000 = ActivityDocsPrintPreview.this.mStartPage; access$4000 <= ActivityDocsPrintPreview.this.mEndPage; access$4000++) {
                this.tmpList.add(ActivityDocsPrintPreview.this.mPdfRender.getDecodeJpegFilename(access$4000));
            }
            ActivityDocsPrintPreview.this.mPdfRender.startConvertPage(ActivityDocsPrintPreview.this.mStartPage, ActivityDocsPrintPreview.this.mEndPage, 1);
            while (!ActivityDocsPrintPreview.this.mPdfRender.RendererStart()) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if (this.tmpList.imageList.size() > 0) {
                EPImage ePImage = new EPImage(this.tmpList.imageList.get(0).getLoadImageFileName(), 0);
                i = ePImage.srcHeight;
                i2 = ePImage.srcWidth;
                EPLog.m313i(ActivityDocsPrintPreview.TAG, "Finish Renderer Page No.1 : srcWidth = " + i2 + " srcHeight = " + i);
            } else {
                i2 = 0;
                i = 0;
            }
            for (int i3 = 0; i3 < this.tmpList.imageList.size(); i3++) {
                EPImage ePImage2 = this.tmpList.get(i3);
                ePImage2.previewPaperRectLeft = ActivityDocsPrintPreview.this.mLn_zoomview.getLeft() + ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingLeft();
                ePImage2.previewPaperRectTop = ActivityDocsPrintPreview.this.mLn_zoomview.getTop() + ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingTop();
                ePImage2.previewPaperRectRight = ActivityDocsPrintPreview.this.mLn_zoomview.getRight() - ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingRight();
                ePImage2.previewPaperRectBottom = ActivityDocsPrintPreview.this.mLn_zoomview.getBottom() - ActivityDocsPrintPreview.this.mLn_zoomview.getPaddingBottom();
                ePImage2.previewImageRectLeft = (float) (ActivityDocsPrintPreview.this.mLn_zoomview.getLeft() + ActivityDocsPrintPreview.this.mImageView.getLeft());
                ePImage2.previewImageRectTop = (float) (ActivityDocsPrintPreview.this.mLn_zoomview.getTop() + ActivityDocsPrintPreview.this.mImageView.getTop());
                ePImage2.previewImageRectRight = (float) (ActivityDocsPrintPreview.this.mLn_zoomview.getLeft() + ActivityDocsPrintPreview.this.mImageView.getRight());
                ePImage2.previewImageRectBottom = (float) (ActivityDocsPrintPreview.this.mLn_zoomview.getTop() + ActivityDocsPrintPreview.this.mImageView.getBottom());
                ePImage2.previewWidth = (int) (ePImage2.previewImageRectRight - ePImage2.previewImageRectLeft);
                ePImage2.previewHeight = (int) (ePImage2.previewImageRectBottom - ePImage2.previewImageRectTop);
                if (ePImage2.previewPaperRectRight - ePImage2.previewPaperRectLeft > ePImage2.previewPaperRectBottom - ePImage2.previewPaperRectTop) {
                    ePImage2.isPaperLandScape = true;
                } else {
                    ePImage2.isPaperLandScape = false;
                }
                ePImage2.srcWidth = i2;
                ePImage2.srcHeight = i;
                ePImage2.setOrgName(ActivityDocsPrintPreview.this.docFileName_org);
            }
        }

        protected void onPostExecute(Void voidR) {
            super.onPostExecute(voidR);
            EPImageList unused = ActivityDocsPrintPreview.this.mPrintImageList = this.tmpList;
            ActivityDocsPrintPreview.this.enableProgressBar(false);
            ActivityDocsPrintPreview.this.check3GAndStartPrint();
        }
    }

    private void check3GAndStartPrint() {
        startPrintActivity();
    }

    private void startPrintActivity() {
        if ((this.printMode & 1) == 0) {
            PrintProgress.ProgressParams progressParams = this.mLocalPrintProgressParams;
            if (progressParams != null) {
                startActivityForResult(PrintProgress.getPdfPrintIntent(this, progressParams), 255);
                return;
            }
            return;
        }
        if (this.mPrintLog == null) {
            this.mPrintLog = new PrintLog();
        }
        PrintLog printLog = this.mPrintLog;
        printLog.previewType = 2;
        startActivityForResult(PrintProgress.getPrintIntent(this, this.mPrintImageList, true, false, printLog), 255);
    }

    public void invitationDialogClicked(boolean z) {
        this.mReviewInvitationViewModel.setStartStoreEnd();
    }

    private class LoadRemotePreviewTask extends AsyncTask<String, Void, Void> {
        CustomProDialog serverConnectDialog;

        private LoadRemotePreviewTask() {
        }

        protected void onPreExecute() {
            ActivityDocsPrintPreview.this.mRemotePreviewImageList.clear();
            ActivityDocsPrintPreview.this.updatePageTextView();
            ActivityDocsPrintPreview.this.loadConfig();
            ActivityDocsPrintPreview activityDocsPrintPreview = ActivityDocsPrintPreview.this;
            this.serverConnectDialog = new CustomProDialog(activityDocsPrintPreview, R.style.AppTheme_Translucent_Gray, R.layout.work_dialog_transparent, true);
            CustomProDialog customProDialog = this.serverConnectDialog;
            if (customProDialog != null) {
                customProDialog.setCancelable(false);
                this.serverConnectDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
                    public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                        if (i != 4 || ActivityDocsPrintPreview.this.loadRemotePreviewTask == null) {
                            return false;
                        }
                        ActivityDocsPrintPreview.this.loadRemotePreviewTask.cancel(true);
                        return false;
                    }
                });
                this.serverConnectDialog.show();
            }
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Code restructure failed: missing block: B:46:0x012f, code lost:
            if (r5[0] != 2) goto L_0x0133;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:47:0x0133, code lost:
            r0 = r9;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:51:0x013d, code lost:
            throw new java.lang.Exception();
         */
        /* JADX WARNING: Code restructure failed: missing block: B:62:0x014a, code lost:
            r0 = th;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:66:0x0152, code lost:
            r2 = r7;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:68:0x0154, code lost:
            r0 = e;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:69:0x0156, code lost:
            r0 = e;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:75:0x0164, code lost:
            r2 = r0;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:89:0x017b, code lost:
            r0 = new android.os.Message();
            r0.what = 39;
            r0.arg1 = r2;
            r1.this$0.mUiHandler.sendMessage(r0);
         */
        /* JADX WARNING: Code restructure failed: missing block: B:90:0x018e, code lost:
            r0 = e;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:91:0x018f, code lost:
            r6 = false;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:92:0x0190, code lost:
            r0.printStackTrace();
         */
        /* JADX WARNING: Code restructure failed: missing block: B:93:0x0194, code lost:
            r0 = e;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:94:0x0195, code lost:
            r6 = false;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:95:0x0196, code lost:
            r0.printStackTrace();
         */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Removed duplicated region for block: B:104:0x01b8  */
        /* JADX WARNING: Removed duplicated region for block: B:109:0x01cb  */
        /* JADX WARNING: Removed duplicated region for block: B:119:? A[RETURN, SYNTHETIC] */
        /* JADX WARNING: Removed duplicated region for block: B:68:0x0154 A[ExcHandler: RemoteException (e android.os.RemoteException), PHI: r6 
  PHI: (r6v11 boolean) = (r6v9 boolean), (r6v9 boolean), (r6v9 boolean), (r6v9 boolean), (r6v14 boolean), (r6v14 boolean) binds: [B:14:0x0072, B:63:0x014c, B:59:0x0147, B:60:?, B:44:0x012d, B:45:?] A[DONT_GENERATE, DONT_INLINE], Splitter:B:14:0x0072] */
        /* JADX WARNING: Removed duplicated region for block: B:69:0x0156 A[ExcHandler: InterruptedException (e java.lang.InterruptedException), PHI: r6 
  PHI: (r6v10 boolean) = (r6v9 boolean), (r6v9 boolean), (r6v9 boolean), (r6v9 boolean), (r6v14 boolean), (r6v14 boolean) binds: [B:14:0x0072, B:63:0x014c, B:59:0x0147, B:60:?, B:44:0x012d, B:45:?] A[DONT_GENERATE, DONT_INLINE], Splitter:B:14:0x0072] */
        /* JADX WARNING: Removed duplicated region for block: B:89:0x017b  */
        /* JADX WARNING: Removed duplicated region for block: B:90:0x018e A[ExcHandler: RemoteException (e android.os.RemoteException), Splitter:B:1:0x0003] */
        /* JADX WARNING: Removed duplicated region for block: B:93:0x0194 A[ExcHandler: InterruptedException (e java.lang.InterruptedException), Splitter:B:1:0x0003] */
        /* JADX WARNING: Removed duplicated region for block: B:98:0x019f  */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public Void doInBackground(String... r22) {
            /*
                r21 = this;
                r1 = r21
                r2 = 0
                epson.print.screen.PrintSetting r0 = new epson.print.screen.PrintSetting     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                epson.print.ActivityDocsPrintPreview r3 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                epson.print.screen.PrintSetting$Kind r4 = epson.print.screen.PrintSetting.Kind.document     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r0.<init>(r3, r4)     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r0.loadSettings()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r8 = r0.paperSizeValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r9 = r0.paperTypeValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r10 = r0.layoutValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r11 = r0.qualityValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r12 = r0.paperSourceValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r13 = r0.colorValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r14 = r0.brightnessValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r15 = r0.contrastValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r3 = r0.saturationValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r4 = r0.duplexValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                int r0 = r0.feedDirectionValue     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r6 = 1
                r19 = 1403(0x57b, float:1.966E-42)
                r20 = 1403(0x57b, float:1.966E-42)
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r5.EpsonConnectEndJob()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r7 = r22[r2]     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                boolean r5 = r5.checkJobNameLength(r7)     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                if (r5 == 0) goto L_0x016c
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r7 = r22[r2]     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                r16 = r3
                r17 = r0
                r18 = r4
                int r0 = r5.EpsonConnectCreateJob(r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20)     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0174 }
                if (r0 != 0) goto L_0x0166
                epson.print.ActivityDocsPrintPreview r3 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                r4 = 1
                r3.isCreateJobDone = r4     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                boolean r3 = r21.isCancelled()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                if (r3 != 0) goto L_0x015e
                epson.print.ActivityDocsPrintPreview r3 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                epson.print.service.IEpsonService r3 = r3.mEpsonService     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                r5 = r22[r2]     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                int r0 = r3.EpsonConnectUploadFile(r5, r4)     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                if (r0 != 0) goto L_0x0158
                r3 = 2
                int[] r5 = new int[r3]     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                r7 = r0
                r0 = 0
                r6 = 0
            L_0x0070:
                r8 = 5000(0x1388, double:2.4703E-320)
                java.lang.Thread.sleep(r8)     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                boolean r8 = r21.isCancelled()     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                if (r8 == r4) goto L_0x014c
                java.lang.Object r8 = epson.print.ActivityDocsPrintPreview.mConnect     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                monitor-enter(r8)     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                epson.print.ActivityDocsPrintPreview r9 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                epson.print.service.IEpsonService r9 = r9.mEpsonService     // Catch:{ all -> 0x0144 }
                int r7 = r9.EpsonConnectGetRenderingStatus(r5)     // Catch:{ all -> 0x0144 }
                if (r7 != 0) goto L_0x013e
                r9 = r5[r2]     // Catch:{ all -> 0x0144 }
                if (r9 == 0) goto L_0x0136
                r9 = r5[r2]     // Catch:{ all -> 0x0144 }
                r10 = 4
                if (r9 == r10) goto L_0x0136
                r9 = r5[r4]     // Catch:{ all -> 0x0144 }
                if (r0 != r9) goto L_0x009b
                monitor-exit(r8)     // Catch:{ all -> 0x0144 }
                goto L_0x0070
            L_0x009b:
                if (r6 != 0) goto L_0x0122
                if (r9 < r4) goto L_0x0122
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                int unused = r0.mCurrentPageView = r4     // Catch:{ all -> 0x0144 }
                java.io.File r0 = new java.io.File     // Catch:{ all -> 0x0144 }
                epson.print.ActivityDocsPrintPreview r10 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                epson.common.ExternalFileUtils r10 = epson.common.ExternalFileUtils.getInstance(r10)     // Catch:{ all -> 0x0144 }
                java.lang.String r10 = r10.getTempViewDir()     // Catch:{ all -> 0x0144 }
                java.lang.StringBuilder r11 = new java.lang.StringBuilder     // Catch:{ all -> 0x0144 }
                r11.<init>()     // Catch:{ all -> 0x0144 }
                java.lang.String r12 = "preview_"
                r11.append(r12)     // Catch:{ all -> 0x0144 }
                epson.print.ActivityDocsPrintPreview r12 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                int r12 = r12.mCurrentPageView     // Catch:{ all -> 0x0144 }
                r11.append(r12)     // Catch:{ all -> 0x0144 }
                java.lang.String r12 = ".jpg"
                r11.append(r12)     // Catch:{ all -> 0x0144 }
                java.lang.String r11 = r11.toString()     // Catch:{ all -> 0x0144 }
                r0.<init>(r10, r11)     // Catch:{ all -> 0x0144 }
                java.lang.String r0 = r0.getPath()     // Catch:{ all -> 0x0144 }
                epson.print.ActivityDocsPrintPreview r10 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                epson.print.service.IEpsonService r10 = r10.mEpsonService     // Catch:{ all -> 0x0144 }
                epson.print.ActivityDocsPrintPreview r11 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                int r11 = r11.mCurrentPageView     // Catch:{ all -> 0x0144 }
                int r7 = r10.EpsonConnectGetPreview(r11, r0)     // Catch:{ all -> 0x0144 }
                if (r7 != 0) goto L_0x011c
                epson.print.ActivityDocsPrintPreview r10 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                epson.print.EPImageList r10 = r10.mRemotePreviewImageList     // Catch:{ all -> 0x0144 }
                r10.add((java.lang.String) r0)     // Catch:{ all -> 0x0144 }
                android.os.Message r10 = new android.os.Message     // Catch:{ all -> 0x0144 }
                r10.<init>()     // Catch:{ all -> 0x0144 }
                r11 = 31
                r10.what = r11     // Catch:{ all -> 0x0144 }
                r10.obj = r0     // Catch:{ all -> 0x0144 }
                android.os.Bundle r0 = r10.getData()     // Catch:{ all -> 0x0144 }
                java.lang.String r11 = "CONVERTED_PAGE"
                r0.putInt(r11, r4)     // Catch:{ all -> 0x0144 }
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x0144 }
                r0.sendMessage(r10)     // Catch:{ all -> 0x0144 }
                epson.print.ActivityDocsPrintPreview$CustomProDialog r0 = r1.serverConnectDialog     // Catch:{ all -> 0x0144 }
                if (r0 == 0) goto L_0x011a
                epson.print.ActivityDocsPrintPreview$CustomProDialog r0 = r1.serverConnectDialog     // Catch:{ all -> 0x0144 }
                boolean r0 = r0.isShowing()     // Catch:{ all -> 0x0144 }
                if (r0 == 0) goto L_0x011a
                epson.print.ActivityDocsPrintPreview$CustomProDialog r0 = r1.serverConnectDialog     // Catch:{ all -> 0x0144 }
                r0.dismiss()     // Catch:{ all -> 0x0144 }
            L_0x011a:
                r6 = 1
                goto L_0x0122
            L_0x011c:
                java.lang.Exception r0 = new java.lang.Exception     // Catch:{ all -> 0x0144 }
                r0.<init>()     // Catch:{ all -> 0x0144 }
                throw r0     // Catch:{ all -> 0x0144 }
            L_0x0122:
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x0144 }
                int unused = r0.mEndPageView = r9     // Catch:{ all -> 0x0144 }
                java.lang.Void[] r0 = new java.lang.Void[r2]     // Catch:{ all -> 0x0144 }
                r1.publishProgress(r0)     // Catch:{ all -> 0x0144 }
                monitor-exit(r8)     // Catch:{ all -> 0x0144 }
                r0 = r5[r2]     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                if (r0 != r3) goto L_0x0133
                goto L_0x0199
            L_0x0133:
                r0 = r9
                goto L_0x0070
            L_0x0136:
                r2 = -1056(0xfffffffffffffbe0, float:NaN)
                java.lang.Exception r0 = new java.lang.Exception     // Catch:{ all -> 0x014a }
                r0.<init>()     // Catch:{ all -> 0x014a }
                throw r0     // Catch:{ all -> 0x014a }
            L_0x013e:
                java.lang.Exception r0 = new java.lang.Exception     // Catch:{ all -> 0x0144 }
                r0.<init>()     // Catch:{ all -> 0x0144 }
                throw r0     // Catch:{ all -> 0x0144 }
            L_0x0144:
                r0 = move-exception
                r2 = r7
            L_0x0146:
                monitor-exit(r8)     // Catch:{ all -> 0x014a }
                throw r0     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0148 }
            L_0x0148:
                goto L_0x0175
            L_0x014a:
                r0 = move-exception
                goto L_0x0146
            L_0x014c:
                java.lang.InterruptedException r0 = new java.lang.InterruptedException     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                r0.<init>()     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
                throw r0     // Catch:{ InterruptedException -> 0x0156, RemoteException -> 0x0154, Exception -> 0x0152 }
            L_0x0152:
                r2 = r7
                goto L_0x0175
            L_0x0154:
                r0 = move-exception
                goto L_0x0190
            L_0x0156:
                r0 = move-exception
                goto L_0x0196
            L_0x0158:
                java.lang.Exception r3 = new java.lang.Exception     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                r3.<init>()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                throw r3     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
            L_0x015e:
                java.lang.InterruptedException r3 = new java.lang.InterruptedException     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                r3.<init>()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                throw r3     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
            L_0x0164:
                r2 = r0
                goto L_0x0174
            L_0x0166:
                java.lang.Exception r3 = new java.lang.Exception     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                r3.<init>()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
                throw r3     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0164 }
            L_0x016c:
                r0 = -1
                java.lang.Exception r3 = new java.lang.Exception     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0173 }
                r3.<init>()     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0173 }
                throw r3     // Catch:{ InterruptedException -> 0x0194, RemoteException -> 0x018e, Exception -> 0x0173 }
            L_0x0173:
                r2 = -1
            L_0x0174:
                r6 = 0
            L_0x0175:
                boolean r0 = r21.isCancelled()
                if (r0 != 0) goto L_0x0199
                android.os.Message r0 = new android.os.Message
                r0.<init>()
                r3 = 39
                r0.what = r3
                r0.arg1 = r2
                epson.print.ActivityDocsPrintPreview r2 = epson.print.ActivityDocsPrintPreview.this
                android.os.Handler r2 = r2.mUiHandler
                r2.sendMessage(r0)
                goto L_0x0199
            L_0x018e:
                r0 = move-exception
                r6 = 0
            L_0x0190:
                r0.printStackTrace()
                goto L_0x0199
            L_0x0194:
                r0 = move-exception
                r6 = 0
            L_0x0196:
                r0.printStackTrace()
            L_0x0199:
                boolean r0 = r21.isCancelled()
                if (r0 == 0) goto L_0x01b8
                if (r6 != 0) goto L_0x01c1
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x01ab }
                epson.print.service.IEpsonService r0 = r0.mEpsonService     // Catch:{ RemoteException -> 0x01ab }
                r0.EpsonConnectCancel()     // Catch:{ RemoteException -> 0x01ab }
                goto L_0x01af
            L_0x01ab:
                r0 = move-exception
                r0.printStackTrace()
            L_0x01af:
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this
                android.os.Handler r0 = r0.mUiHandler
                r2 = 7
                r0.sendEmptyMessage(r2)
                goto L_0x01c1
            L_0x01b8:
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this
                android.os.Handler r0 = r0.mUiHandler
                r2 = 32
                r0.sendEmptyMessage(r2)
            L_0x01c1:
                epson.print.ActivityDocsPrintPreview$CustomProDialog r0 = r1.serverConnectDialog
                if (r0 == 0) goto L_0x01d0
                boolean r0 = r0.isShowing()
                if (r0 == 0) goto L_0x01d0
                epson.print.ActivityDocsPrintPreview$CustomProDialog r0 = r1.serverConnectDialog
                r0.dismiss()
            L_0x01d0:
                r0 = 0
                return r0
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityDocsPrintPreview.LoadRemotePreviewTask.doInBackground(java.lang.String[]):java.lang.Void");
        }

        protected void onProgressUpdate(Void... voidArr) {
            ActivityDocsPrintPreview.this.updatePrevNextButtonView();
            ActivityDocsPrintPreview.this.updatePageTextView();
        }
    }

    private void cancelLoadRemotePreviewTask() {
        LoadRemotePreviewTask loadRemotePreviewTask2 = this.loadRemotePreviewTask;
        if (loadRemotePreviewTask2 != null && !loadRemotePreviewTask2.isCancelled()) {
            synchronized (mConnect) {
                this.loadRemotePreviewTask.cancel(true);
            }
            this.loadRemotePreviewTask = null;
        }
    }

    private boolean checkJobNameLength(String str) {
        return new File(str).getName().length() <= 256;
    }

    private class LoadRemotePreviewNext extends AsyncTaskExecutor<Void, Void, Void> {
        private LoadRemotePreviewNext() {
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Code restructure failed: missing block: B:19:0x00a0, code lost:
            r5 = 0;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:25:0x00b5, code lost:
            r0 = move-exception;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:26:0x00b6, code lost:
            r0.printStackTrace();
         */
        /* JADX WARNING: Code restructure failed: missing block: B:28:0x00ba, code lost:
            return null;
         */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:21:0x00a1 */
        /* JADX WARNING: Removed duplicated region for block: B:25:0x00b5 A[Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }, ExcHandler: RemoteException (r0v6 'e' android.os.RemoteException A[CUSTOM_DECLARE, Catch:{  }]), Splitter:B:5:0x0017] */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public Void doInBackground(Void... r10) {
            /*
                r9 = this;
                java.lang.Object r10 = epson.print.ActivityDocsPrintPreview.mConnect
                monitor-enter(r10)
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x00bb }
                android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x00bb }
                r1 = 4
                r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x00bb }
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x00bb }
                int r0 = r0.mCurrentPageView     // Catch:{ all -> 0x00bb }
                r1 = 1
                int r0 = r0 + r1
                r2 = 0
                r3 = 0
                java.io.File r4 = new java.io.File     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                epson.common.ExternalFileUtils r5 = epson.common.ExternalFileUtils.getInstance(r5)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                java.lang.String r5 = r5.getTempViewDir()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                java.lang.StringBuilder r6 = new java.lang.StringBuilder     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                r6.<init>()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                java.lang.String r7 = "preview_"
                r6.append(r7)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                r6.append(r0)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                java.lang.String r7 = ".jpg"
                r6.append(r7)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                java.lang.String r6 = r6.toString()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                r4.<init>(r5, r6)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                java.lang.String r4 = r4.getPath()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                int r5 = r5.EpsonConnectGetPreview(r0, r4)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a0 }
                if (r5 != 0) goto L_0x009a
                epson.print.ActivityDocsPrintPreview r6 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                epson.print.EPImageList r6 = r6.mRemotePreviewImageList     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r6.add((java.lang.String) r4)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r6 = 2
                int[] r7 = new int[r6]     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                epson.print.ActivityDocsPrintPreview r8 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                epson.print.service.IEpsonService r8 = r8.mEpsonService     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                int r5 = r8.EpsonConnectGetRenderingStatus(r7)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                if (r5 != 0) goto L_0x0094
                epson.print.ActivityDocsPrintPreview r8 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r1 = r7[r1]     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                int unused = r8.mEndPageView = r1     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r1 = r7[r3]     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                if (r1 != r6) goto L_0x0078
                epson.print.ActivityDocsPrintPreview r1 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                android.os.Handler r1 = r1.mUiHandler     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r3 = 32
                r1.sendEmptyMessage(r3)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
            L_0x0078:
                android.os.Message r1 = new android.os.Message     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r1.<init>()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r3 = 31
                r1.what = r3     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                android.os.Bundle r3 = r1.getData()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                java.lang.String r6 = "CONVERTED_PAGE"
                r3.putInt(r6, r0)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r1.obj = r4     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                android.os.Handler r0 = r0.mUiHandler     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r0.sendMessage(r1)     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                goto L_0x00b9
            L_0x0094:
                java.lang.Exception r0 = new java.lang.Exception     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r0.<init>()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                throw r0     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
            L_0x009a:
                java.lang.Exception r0 = new java.lang.Exception     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                r0.<init>()     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
                throw r0     // Catch:{ RemoteException -> 0x00b5, Exception -> 0x00a1 }
            L_0x00a0:
                r5 = 0
            L_0x00a1:
                android.os.Message r0 = new android.os.Message     // Catch:{ all -> 0x00bb }
                r0.<init>()     // Catch:{ all -> 0x00bb }
                r1 = 39
                r0.what = r1     // Catch:{ all -> 0x00bb }
                r0.arg1 = r5     // Catch:{ all -> 0x00bb }
                epson.print.ActivityDocsPrintPreview r1 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ all -> 0x00bb }
                android.os.Handler r1 = r1.mUiHandler     // Catch:{ all -> 0x00bb }
                r1.sendMessage(r0)     // Catch:{ all -> 0x00bb }
                monitor-exit(r10)     // Catch:{ all -> 0x00bb }
                return r2
            L_0x00b5:
                r0 = move-exception
                r0.printStackTrace()     // Catch:{ all -> 0x00bb }
            L_0x00b9:
                monitor-exit(r10)     // Catch:{ all -> 0x00bb }
                return r2
            L_0x00bb:
                r0 = move-exception
                monitor-exit(r10)     // Catch:{ all -> 0x00bb }
                throw r0
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityDocsPrintPreview.LoadRemotePreviewNext.doInBackground(java.lang.Void[]):java.lang.Void");
        }
    }

    private class PrintUploadTask extends AsyncTask<String, Void, Void> {
        CustomProDialog serverConnectDialog;

        private PrintUploadTask() {
        }

        protected void onPreExecute() {
            ActivityDocsPrintPreview activityDocsPrintPreview = ActivityDocsPrintPreview.this;
            this.serverConnectDialog = new CustomProDialog(activityDocsPrintPreview, R.style.AppTheme_Translucent, R.layout.work_dialog_transparent, false);
            this.serverConnectDialog.setCancelable(false);
            this.serverConnectDialog.show();
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Code restructure failed: missing block: B:15:0x007a, code lost:
            r0 = r2;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:26:0x009c, code lost:
            r0 = move-exception;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:27:0x009d, code lost:
            r0.printStackTrace();
         */
        /* JADX WARNING: Code restructure failed: missing block: B:28:?, code lost:
            return null;
         */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Removed duplicated region for block: B:26:0x009c A[ExcHandler: RemoteException (r0v4 'e' android.os.RemoteException A[CUSTOM_DECLARE]), Splitter:B:3:0x0009] */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public Void doInBackground(String... r22) {
            /*
                r21 = this;
                r1 = r21
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this
                boolean r0 = r0.isCreateJobDone
                if (r0 != 0) goto L_0x00a0
                r0 = 0
                epson.print.screen.PrintSetting r2 = new epson.print.screen.PrintSetting     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                epson.print.ActivityDocsPrintPreview r3 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                epson.print.screen.PrintSetting$Kind r4 = epson.print.screen.PrintSetting.Kind.document     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r2.<init>(r3, r4)     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r2.loadSettings()     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r8 = r2.paperSizeValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r9 = r2.paperTypeValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r10 = r2.layoutValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r11 = r2.qualityValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r12 = r2.paperSourceValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r13 = r2.colorValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r14 = r2.brightnessValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r15 = r2.contrastValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r3 = r2.saturationValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r4 = r2.duplexValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                int r2 = r2.feedDirectionValue     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r6 = 1
                r19 = 1403(0x57b, float:1.966E-42)
                r20 = 1403(0x57b, float:1.966E-42)
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r5.EpsonConnectEndJob()     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r7 = r22[r0]     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                boolean r5 = r5.checkJobNameLength(r7)     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                if (r5 == 0) goto L_0x0082
                epson.print.ActivityDocsPrintPreview r5 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r7 = r22[r0]     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r16 = r3
                r17 = r2
                r18 = r4
                int r2 = r5.EpsonConnectCreateJob(r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20)     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                if (r2 != 0) goto L_0x007c
                epson.print.ActivityDocsPrintPreview r3 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                r4 = 1
                r3.isCreateJobDone = r4     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                epson.print.ActivityDocsPrintPreview r3 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                epson.print.service.IEpsonService r3 = r3.mEpsonService     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                r0 = r22[r0]     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                int r0 = r3.EpsonConnectUploadFile(r0, r4)     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                if (r0 != 0) goto L_0x0074
                epson.print.ActivityDocsPrintPreview r2 = epson.print.ActivityDocsPrintPreview.this     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                android.os.Handler r2 = r2.mUiHandler     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r3 = 22
                r2.sendEmptyMessage(r3)     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                goto L_0x00a0
            L_0x0074:
                java.lang.Exception r2 = new java.lang.Exception     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r2.<init>()     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                throw r2     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
            L_0x007a:
                r0 = r2
                goto L_0x0089
            L_0x007c:
                java.lang.Exception r0 = new java.lang.Exception     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                r0.<init>()     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
                throw r0     // Catch:{ RemoteException -> 0x009c, Exception -> 0x007a }
            L_0x0082:
                r0 = -1
                java.lang.Exception r2 = new java.lang.Exception     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                r2.<init>()     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
                throw r2     // Catch:{ RemoteException -> 0x009c, Exception -> 0x0089 }
            L_0x0089:
                android.os.Message r2 = new android.os.Message
                r2.<init>()
                r3 = 39
                r2.what = r3
                r2.arg1 = r0
                epson.print.ActivityDocsPrintPreview r0 = epson.print.ActivityDocsPrintPreview.this
                android.os.Handler r0 = r0.mUiHandler
                r0.sendMessage(r2)
                goto L_0x00a0
            L_0x009c:
                r0 = move-exception
                r0.printStackTrace()
            L_0x00a0:
                r0 = 0
                return r0
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityDocsPrintPreview.PrintUploadTask.doInBackground(java.lang.String[]):java.lang.Void");
        }

        protected void onPostExecute(Void voidR) {
            CustomProDialog customProDialog = this.serverConnectDialog;
            if (customProDialog != null && customProDialog.isShowing()) {
                this.serverConnectDialog.dismiss();
            }
        }
    }

    /* access modifiers changed from: private */
    public void adjustPrintSettings() {
        try {
            if ((this.printMode & 1) != 0) {
                this.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.document.name());
            } else {
                this.mEpsonService.updatePrinterSettings(PrintSetting.Kind.document.name());
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    private void saveCurSettings() {
        this.mCurPrinterName = MyPrinter.getCurPrinter(this).getName();
        this.mCurPrinterEmailAdress = MyPrinter.getCurPrinter(this).getEmailAddress();
        this.isRemotePrinterOld = MyPrinter.isRemotePrinter(this);
        this.mCurPrintSetting = new PrintSetting(this, PrintSetting.Kind.document);
        this.mCurPrintSetting.loadSettings();
    }

    /* access modifiers changed from: private */
    public boolean isRemotePrintSettingsChanged() {
        String emailAddress = MyPrinter.getCurPrinter(this).getEmailAddress();
        PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.document);
        printSetting.loadSettings();
        int i = printSetting.paperSizeValue;
        int i2 = printSetting.paperTypeValue;
        int i3 = printSetting.layoutValue;
        int i4 = printSetting.qualityValue;
        int i5 = printSetting.paperSourceValue;
        int i6 = printSetting.colorValue;
        int i7 = printSetting.duplexValue;
        int i8 = printSetting.brightnessValue;
        int i9 = printSetting.contrastValue;
        int i10 = printSetting.saturationValue;
        if (this.mCurPrinterEmailAdress.equals(emailAddress) && this.mCurPrintSetting.paperSizeValue == i && this.mCurPrintSetting.paperTypeValue == i2 && this.mCurPrintSetting.layoutValue == i3 && this.mCurPrintSetting.qualityValue == i4 && this.mCurPrintSetting.paperSourceValue == i5 && this.mCurPrintSetting.colorValue == i6 && this.mCurPrintSetting.duplexValue == i7 && this.mCurPrintSetting.brightnessValue == i8 && this.mCurPrintSetting.contrastValue == i9 && this.mCurPrintSetting.saturationValue == i10) {
            return false;
        }
        return true;
    }

    public boolean resetPageRangeBySettings() {
        String string = getSharedPreferences("PrintSetting", 0).getString(Constants.PRINTER_NAME, "");
        PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.document);
        printSetting.loadSettings();
        int i = printSetting.paperSizeValue;
        int i2 = printSetting.layoutValue;
        if (string.equals(this.mCurPrinterName) && this.mCurPrintSetting.paperSizeValue == i && this.mCurPrintSetting.layoutValue == i2) {
            return false;
        }
        printSetting.resetPageRange(1, this.mEndPageView);
        return true;
    }

    public void resetPageRange() {
        new PrintSetting(this, PrintSetting.Kind.document).resetPageRange(1, this.mEndPageView);
        this.mStartPage = 1;
        this.mEndPage = this.mEndPageView;
    }

    /* access modifiers changed from: private */
    public void loadConfig() {
        SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
        PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.document);
        printSetting.loadSettings();
        this.paperSize = printSetting.paperSizeValue;
        this.mColorMode = printSetting.colorValue;
        this.mLayout = printSetting.layoutValue;
        this.mLayoutMulti = printSetting.layoutMultiPageValue;
        this.mPaperSize = Info_paper.getInfoPaper(this, this.paperSize);
        MediaInfo.PaperSize paperSize2 = new MediaInfo.PaperSize();
        this.mSizeInfo.setText(getString(paperSize2.getStringId(this.paperSize)));
        paperSize2.destructor();
        this.mPrinterName = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
        this.printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
        this.mStartPage = printSetting.startValue;
        this.mEndPage = printSetting.endValue;
    }

    public void setNewImageView(String str) {
        if ((this.printMode & 2) != 0) {
            Bitmap bitmap = this.mBitmap;
            if (bitmap != null) {
                bitmap.recycle();
            }
            if (this.mColorMode == 1) {
                try {
                    this.mBitmap = Photo.createBitmapWithUri(str, 992, 1403, true);
                } catch (Exception e) {
                    e.printStackTrace();
                    this.mUiHandler.sendEmptyMessage(6);
                }
            } else {
                try {
                    this.mBitmap = Photo.createBitmapWithUri(str, 992, 1403, false);
                } catch (Exception e2) {
                    e2.printStackTrace();
                    this.mUiHandler.sendEmptyMessage(6);
                }
            }
            this.mImageView.setImageBitmap(this.mBitmap);
        }
    }

    public void setOrentationView(boolean z) {
        int i;
        loadConfig();
        Display defaultDisplay = getWindowManager().getDefaultDisplay();
        int paper_width = this.mPaperSize.getPaper_width();
        int paper_height = this.mPaperSize.getPaper_height();
        int i2 = this.mLayoutMulti;
        int i3 = 0;
        if (i2 != 0) {
            if (i2 == 65536) {
                Rect paperSize_2in1 = this.mPaperSize.getPaperSize_2in1();
                paper_height = paperSize_2in1.width();
                paper_width = paperSize_2in1.height();
                Rect printingArea_2in1 = this.mPaperSize.getPrintingArea_2in1();
                i3 = printingArea_2in1.width();
                i = printingArea_2in1.height();
            } else if (i2 == 131072 || i2 == 262144) {
                Rect paperSize_4in1 = this.mPaperSize.getPaperSize_4in1();
                paper_height = paperSize_4in1.width();
                paper_width = paperSize_4in1.height();
                Rect printingArea_4in1 = this.mPaperSize.getPrintingArea_4in1();
                i3 = printingArea_4in1.width();
                i = printingArea_4in1.height();
            } else {
                i = 0;
                int i4 = paper_height;
                paper_height = paper_width;
                paper_width = i4;
            }
            if (paper_height > paper_width) {
                int i5 = paper_height;
                paper_height = paper_width;
                paper_width = i5;
            } else {
                int i6 = i3;
                i3 = i;
                i = i6;
            }
        } else if (paper_width > paper_height) {
            i = 0;
        } else {
            i = 0;
            int i7 = paper_height;
            paper_height = paper_width;
            paper_width = i7;
        }
        this.mPreviewPaperAreaLandscape = !z;
        Point point = new Point();
        defaultDisplay.getSize(point);
        if (z) {
            int height = point.y - (this.mPrint.getHeight() * 4);
            double d = (double) paper_width;
            double d2 = (double) paper_height;
            int i8 = (int) ((((double) height) / d) * d2);
            if (i8 > (point.x * 4) / 5) {
                i8 = (point.x * 4) / 5;
                height = (int) ((((double) i8) / d2) * d);
            }
            this.Relative_para = new RelativeLayout.LayoutParams(i8, height);
        } else {
            int i9 = (point.x * 4) / 5;
            double d3 = (double) paper_width;
            double d4 = (double) paper_height;
            int i10 = (int) ((((double) i9) / d3) * d4);
            if (i10 > point.y - (this.mPrint.getHeight() * 4)) {
                i10 = point.y - (this.mPrint.getHeight() * 4);
                i9 = (int) ((((double) i10) / d4) * d3);
            }
            this.Relative_para = new RelativeLayout.LayoutParams(i9, i10);
        }
        this.Relative_para.addRule(13);
        this.mLn_zoomview.setLayoutParams(this.Relative_para);
        if (this.mLayout == 2) {
            if (this.mLayoutMulti == 0) {
                if (z) {
                    float f = ((float) this.Relative_para.width) / ((float) paper_height);
                    this.mLn_zoomview.setPadding((int) (((float) this.mPaperSize.getLeftMargin_border()) * f), (int) (((float) this.mPaperSize.getTopMargin_border()) * f), (int) (((float) this.mPaperSize.getRightMargin_border()) * f), (int) (((float) this.mPaperSize.getBottomMargin_border()) * f));
                } else {
                    float f2 = ((float) this.Relative_para.width) / ((float) paper_width);
                    this.mLn_zoomview.setPadding((int) (((float) this.mPaperSize.getTopMargin_border()) * f2), (int) (((float) this.mPaperSize.getRightMargin_border()) * f2), (int) (((float) this.mPaperSize.getBottomMargin_border()) * f2), (int) (((float) this.mPaperSize.getLeftMargin_border()) * f2));
                }
            } else if (z) {
                float f3 = ((float) this.Relative_para.width) / ((float) paper_height);
                int i11 = (int) (((float) ((paper_height - i) / 2)) * f3);
                int i12 = (int) (((float) ((paper_width - i3) / 2)) * f3);
                this.mLn_zoomview.setPadding(i11, i12, i11, i12);
            } else {
                float f4 = ((float) this.Relative_para.width) / ((float) paper_width);
                int i13 = (int) (((float) ((paper_width - i3) / 2)) * f4);
                int i14 = (int) (((float) ((paper_height - i) / 2)) * f4);
                this.mLn_zoomview.setPadding(i13, i14, i13, i14);
            }
        }
        this.mUiHandler.sendEmptyMessageDelayed(50, 200);
        if ((this.printMode & 2) == 0) {
            this.mDisablePreviewMsg.setLayoutParams(this.Relative_para);
        }
    }

    public void enableProgressBar(boolean z) {
        if (z) {
            this.mProgress.setVisibility(0);
            this.mPre.setEnabled(false);
            this.mNext.setEnabled(false);
            findViewById(R.id.toolbar).invalidate();
            this.isBackKeyOK = false;
            return;
        }
        this.mProgress.setVisibility(8);
        this.mPre.setEnabled(true);
        this.mNext.setEnabled(true);
        findViewById(R.id.toolbar).invalidate();
        this.isBackKeyOK = true;
    }

    public void updatePageTextView() {
        this.mPageNum.setText(this.mCurrentPageView + CommonDefine.SLASH + this.mEndPageView);
    }

    public void updatePrevNextButtonView() {
        if ((this.printMode & 2) != 0) {
            if (this.mCurrentPageView != this.mStartPageView) {
                this.mPre.setVisibility(0);
            } else {
                this.mPre.setVisibility(4);
            }
            if (this.disablePrintArea) {
                this.mNext.setVisibility(0);
            } else if (this.mCurrentPageView != this.mEndPageView) {
                this.mNext.setVisibility(0);
            } else {
                this.mNext.setVisibility(4);
            }
        }
    }

    public void showErrorDialog(String str, String str2) {
        new CustomTitleAlertDialogBuilder(this).setCancelable(false).setTitle(str).setMessage(str2).setNegativeButton(getString(R.string.f343ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
                ActivityDocsPrintPreview.this.mUiHandler.sendEmptyMessage(7);
            }
        }).create().show();
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        setOrentationView(this.mIsPortrait);
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) {
            callPrintSetting();
        }
        return super.onOptionsItemSelected(menuItem);
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.C2138menu.print_menu, menu);
        return true;
    }

    private class CustomProDialog extends Dialog {
        private boolean hasCancelButton;
        private int mLayoutId;

        public CustomProDialog(Context context, int i, int i2, boolean z) {
            super(context, i);
            this.mLayoutId = i2;
            this.hasCancelButton = z;
            setCancelable(false);
        }

        protected void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            requestWindowFeature(1);
            View inflate = getLayoutInflater().inflate(this.mLayoutId, (ViewGroup) null);
            ((Button) inflate.findViewById(R.id.close_btn)).setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    ((Button) CustomProDialog.this.findViewById(R.id.close_btn)).setEnabled(false);
                    if (ActivityDocsPrintPreview.this.loadRemotePreviewTask != null) {
                        ActivityDocsPrintPreview.this.loadRemotePreviewTask.cancel(true);
                    }
                }
            });
            ((TextView) inflate.findViewById(R.id.caution_tv)).setVisibility(4);
            setContentView(inflate);
            if (this.hasCancelButton) {
                ((Button) findViewById(R.id.close_btn)).setVisibility(0);
            } else {
                ((Button) findViewById(R.id.close_btn)).setVisibility(4);
            }
            ((TextView) findViewById(R.id.loading_tv)).setText(ActivityDocsPrintPreview.this.getString(R.string.epsonconnect_str_get_server_preview));
        }
    }
}
