package com.epson.cameracopy.ui;

import android.app.AlertDialog;


import android.content.ComponentName;
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.PointF;
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.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.epson.cameracopy.printlayout.ImageAndLayout;
import com.epson.cameracopy.printlayout.ManuscriptSize;
import com.epson.cameracopy.printlayout.PreviewView;
import com.epson.mobilephone.common.escpr.MediaInfo;
import com.epson.mobilephone.common.wifidirect.NfcTagUtils;

import epson.common.Constants;
import epson.common.DialogProgress;
import epson.common.DialogProgressViewModel;
import epson.common.ExternalFileUtils;
import epson.print.ActivityIACommon;
import epson.print.ActivityNfcPrinter;

import epson.print.CommonDefine;
import epson.print.EPImage;
import epson.print.EPImageList;
import epson.print.MyPrinter;
import epson.print.R;
import epson.print.Util.AsyncTaskExecutor;
import epson.print.Util.EPLog;
import epson.print.screen.PaperSourceInfo;
import epson.print.screen.PaperSourceSetting;
import epson.print.screen.PaperSourceSettingScr;
import epson.print.screen.PrintSetting;
import epson.print.service.EpsonService;
import epson.print.service.IEpsonService;
import epson.print.service.IEpsonServiceCallback;

import java.util.ArrayList;
import java.util.Deque;
import java.util.Locale;

/* renamed from: com.epson.cameracopy.ui.PrintPreviewActivity */
public class PrintPreviewActivity extends ActivityIACommon implements CommonDefine, View.OnClickListener, PreviewView.PrttargetScaleChangeListener, ReviewInvitationDialog.OnClickListener {
    static final /* synthetic */ boolean $assertionsDisabled = false;
    private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
    private static final String DIALOG_PROGRESS = "dialog_progress";
    private static final String KEY_PREVIEW_VIEW = "preview-view";
    private static final int MESSAGE_MANUSCRIPT_SCALE_TEXT_UPDATE = 8;
    public static final String PARAM_DISPLAY_SIZE_SET_MESSAGE = "display-sizeset-message";
    public static final String PARAM_IMAGE_LIST = "imageList";
    private static final int REQUEST_CODE_NFC_PRINTER_CHANGE = 4;
    private static final int REQUEST_CODE_ORG_PAPER_SIZE_SELECT = 3;
    private static final int REQUEST_CODE_PRINT = 1;
    private static final int REQUEST_CODE_SETTING = 2;
    private final int LOAD_ALL_IMAGE = 3;
    private final int OUT_OF_MEMORY_ERROR = 7;
    private final int PREVIEW_LOAD_DIALOG_DISMISS = 1;
    private final int PREVIEW_LOAD_DIALOG_SHOW = 0;
    private final PrintSetting.Kind PRINT_MODE_CAMERACOPY = PrintSetting.Kind.cameracopy;
    private final int START_PRINT = 5;
    private final int ZOOM_CONTROL = 2;
    private ArrayList<PaperSourceSetting> aPaperSourceSetting;
    boolean bAutoStartPrint = false;
    private Button backButton = null;
    private int currentColor = 0;
    private int currentLayout = 2;
    private int currentPaperSize = 0;
    private String currentPrinterName = "";
    private boolean enableShowWarning = true;
    private final 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 final ServiceConnection mEpsonConnection = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName componentName) {
            try {
                PrintPreviewActivity.mEpsonService.unregisterCallback(PrintPreviewActivity.mCallback);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            IEpsonService unused = PrintPreviewActivity.mEpsonService = null;
        }

        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            IEpsonService unused = PrintPreviewActivity.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
            if (PrintPreviewActivity.mEpsonService != null) {
                try {
                    PrintPreviewActivity.mEpsonService.registerCallback(PrintPreviewActivity.mCallback);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    private IEpsonService mEpsonService = null;
    Handler mHandler = new Handler(new Handler.Callback() {
        static final /* synthetic */ boolean $assertionsDisabled = false;

        static {
            Class<PrintPreviewActivity> cls = PrintPreviewActivity.class;
        }

        public boolean handleMessage(Message message) {
            int i = message.what;
            if (i == 3) {
                PrintPreviewActivity.this.startLoadtask();
            } else if (i == 5) {
                PrintPreviewActivity.this.disablePrintButton();
                PrintPreviewActivity.this.startPrint();
            } else if (i != 100) {
                switch (i) {
                    case 0:
                        PrintPreviewActivity.this.showProgressDialog();
                        break;
                    case 1:
                        PrintPreviewActivity.this.dismissProgressDialog();
                        break;
                    default:
                        switch (i) {
                            case 7:
                                if (PrintPreviewActivity.mImageList.size() <= 0) {
                                    PrintPreviewActivity.this.disablePrintButton();
                                }
                                PrintPreviewActivity printPreviewActivity = PrintPreviewActivity.this;
                                Toast.makeText(printPreviewActivity, printPreviewActivity.getString(R.string.file_size_notsupport), 1).show();
                                break;
                            case 8:
                                PrintPreviewActivity.this.updateManuscriptScaleText((message.obj).doubleValue());
                                return true;
                        }
                }
            } else {
                PrintPreviewActivity.this.updatePaperDisplay(message);
            }
            return true;
        }
    });
    private final EPImageList mImageList = new EPImageList();
    private boolean mIsRemotePrinter = false;
    ManuscriptSize mManuscriptSize;
    private DialogProgressViewModel mModelDialog;
    private Button mOriginalImageSizeButton;
    private PreviewView mPreviewView = null;
    int mPrintTargetPaperSizeId = -2;
    private TextView mPrintTargetSizeText;
    private ReviewInvitationViewModel mReviewInvitationViewModel;
    private TextView mScaleText;
    private ImageView paperMissmath = null;
    PaperSourceInfo paperSourceInfo = null;
    private TextView papersizeTextView = null;
    private Button printButton = null;
    private String printerId = "";
    private ImageButton printsettingButton = null;
    private AllReloadTask reloadTask = null;
    private Button rotateButton = null;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_camera_print_preview);
        mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
        mModelDialog.getDialogJob().observe(this, new Observer() {
            public final void onChanged(Object obj) {
                PrintPreviewActivity.lambda$onCreate$0(PrintPreviewActivity.this, (Deque) obj);
            }
        });
        mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
        mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
            public void onChanged(@Nullable Boolean bool) {
                if (bool.booleanValue()) {
                    PrintPreviewActivity.this.showStoreDialog();
                }
            }
        });
        setActionBar(R.string.print_title, true);
        ExternalFileUtils.getInstance(this).initPrintDir();
        getImageListFromIntent();
        EPImageList ePImageList = mImageList;
        if (ePImageList == null || ePImageList.size() != 1) {
            finish();
            return;
        }
        mPreviewView = (PreviewView) findViewById(R.id.previewImageView);
        papersizeTextView = (TextView) findViewById(R.id.paper_size_text);
        papersizeTextView.setOnClickListener(this);
        mPrintTargetSizeText = (TextView) findViewById(R.id.printtarget_size_text);
        mPrintTargetSizeText.setOnClickListener(this);
        mScaleText = (TextView) findViewById(R.id.scale_text);
        mScaleText.setOnClickListener(this);
        paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
        paperMissmath.setOnClickListener(this);
        mOriginalImageSizeButton = (Button) findViewById(R.id.paper_size_button);
        mOriginalImageSizeButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                PrintPreviewActivity.this.startOrgImageSizeActivity();
            }
        });
        rotateButton = (Button) findViewById(R.id.rotate_button);
        rotateButton.setOnClickListener(this);
        printButton = (Button) findViewById(R.id.print_button);
        printButton.setOnClickListener(this);
        mPreviewView.setImage(mImageList.get(0).loadImageFileName);
        loadPrinterSettingAndChangeView(true);
        updateManuscriptScaleText(1.0d);
        mPreviewView.setPrttargetScaleChangeListener(this);
        enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true);
        paperSourceInfo = PaperSourceInfo.getInstance(this);
        if (mEpsonService == null) {
            bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
        }
        if (bundle == null) {
            mHandler.sendEmptyMessageDelayed(3, 300);
            checkSizeSetMessage();
        }
    }

    public static /* synthetic */ void lambda$onCreate$0(PrintPreviewActivity printPreviewActivity, Deque deque) {
        String[] checkQueue = printPreviewActivity.mModelDialog.checkQueue();
        if (checkQueue != null) {
            String str = checkQueue[0];
            String str2 = checkQueue[1];
            if (str2.equals("do_show")) {
                printPreviewActivity.showDialog(str);
            }
            if (str2.equals("do_dismiss")) {
                printPreviewActivity.dismissDialog(str);
            }
        }
    }

    private void showStoreDialog() {
        ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
    }

    private void checkSizeSetMessage() {
        Intent intent = getIntent();
        if (intent != null && intent.getBooleanExtra(PARAM_DISPLAY_SIZE_SET_MESSAGE, false)) {
            Toast makeText = Toast.makeText(this, getString(R.string.manuscript_size_set_message), 1);
            makeText.setGravity(8, 0, 0);
            makeText.show();
        }
    }

    protected void startOrgImageSizeActivity() {
        startActivityForResult(new Intent(this, DocumentSizeSettingActivity.class), 3);
    }

    private void getImageListFromIntent() {
        mImageList.clear();
        Intent intent = getIntent();
        if (intent == null) {
            finish();
            return;
        }
        ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra("imageList");
        if (stringArrayListExtra == null) {
            finish();
            return;
        }
        for (int i = 0; i < stringArrayListExtra.size(); i++) {
            mImageList.add(stringArrayListExtra.get(i));
        }
        for (int i2 = 0; i2 < mImageList.size(); i2++) {
            if (!checkEPImage(mImageList.get(i2))) {
                mImageList.clear();
                finish();
                return;
            }
        }
    }

    private boolean checkEPImage(EPImage ePImage) {
        return ePImage != null && ePImage.srcWidth > 0 && ePImage.srcHeight > 0;
    }

    private void updateParaSizeText() {
        String string = getString(new MediaInfo.PaperSize().getStringId(this.currentPaperSize));
        TextView textView = papersizeTextView;
        textView.setText(getString(R.string.paper_size) + ": " + string);
    }

    private boolean updateManuscriptSize() {
        ManuscriptSize manuscriptSize = mManuscriptSize;
        mManuscriptSize = ManuscriptSize.load(this, mImageList.get(0).loadImageFileName);
        boolean z = manuscriptSize == null || !manuscriptSize.equals(mManuscriptSize);
        if (mManuscriptSize.displayLength()) {
            PointF documentSize = mManuscriptSize.getDocumentSize(this);
            mPrintTargetSizeText.setText(String.format(Locale.US, mManuscriptSize.getUnitType(this) == 2 ? "%s: %s (%.1f x %.1f %s)" : "%s: %s (%.0f x %.0f %s)", new Object[]{getString(R.string.document_size), mManuscriptSize.getSizeName(this), Float.valueOf(documentSize.x), Float.valueOf(documentSize.y), mManuscriptSize.getUnitStr(this)}));
        } else {
            mPrintTargetSizeText.setText(String.format(Locale.US, "%s: %s", new Object[]{getString(R.string.document_size), mManuscriptSize.getSizeName(this)}));
        }
        return z;
    }

    private void updateManuscriptScaleText(double d) {
        PointF physicalSize = mManuscriptSize.getPhysicalSize(this);
        mScaleText.setText(String.format(Locale.US, mManuscriptSize.getUnitType(this) == 2 ? "%s: %.0f%% (%.1f x %.1f %s)" : "%s: %.0f%% (%.0f x %.0f %s)", new Object[]{getString(R.string.magnification), Double.valueOf(100.0d * d), Double.valueOf((physicalSize.x) * d), Double.valueOf((physicalSize.y) * d), mManuscriptSize.getUnitStr(this)}));
    }

    private void loadPrinterSettingAndChangeView(boolean z) {
        boolean z2;
        boolean z3;
        PreviewView previewView;
        boolean isRemotePrinter = isRemotePrinter();
        boolean z4 = false;
        SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
        if (sharedPreferences != null) {
            String string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
            PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
            printSetting.loadSettings();
            printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
            boolean z5 = true;
            if (z || mIsRemotePrinter != isRemotePrinter) {
                mIsRemotePrinter = isRemotePrinter;
                z3 = true;
                z2 = true;
            } else {
                z3 = false;
                z2 = false;
            }
            if (z || !this.currentPrinterName.equalsIgnoreCase(string)) {
                currentPrinterName = string;
                z3 = true;
                z2 = true;
            }
            if (z || currentPaperSize != printSetting.paperSizeValue) {
                currentPaperSize = printSetting.paperSizeValue;
                PreviewView previewView2 = mPreviewView;
                if (previewView2 != null) {
                    previewView2.setPaperSize(this.currentPaperSize);
                }
                z3 = true;
                z2 = true;
            }
            if (z || currentLayout != printSetting.layoutValue) {
                currentLayout = printSetting.layoutValue;
                if (mPreviewView != null) {
                    if (this.currentLayout == 1) {
                        z4 = true;
                    }
                    mPreviewView.setBorderless(z4);
                }
                z3 = true;
                z2 = true;
            }
            if (z || currentColor != printSetting.colorValue) {
                currentColor = printSetting.colorValue;
                PreviewView previewView3 = mPreviewView;
                if (previewView3 != null) {
                    previewView3.setColor(this.currentColor);
                }
            } else {
                z5 = z2;
            }
            if (z3) {
                updateManuscriptSize();
                PreviewView previewView4 = mPreviewView;
                if (previewView4 != null) {
                    previewView4.printPostionResetRequest();
                    mPreviewView.setPrintTargetSize(mManuscriptSize.getPixelWidth(), mManuscriptSize.getPixelHeight());
                    mPreviewView.update();
                }
                updateParaSizeText();
            } else if (z5 && (previewView = mPreviewView) != null) {
                previewView.update();
            }
        } else if (mIsRemotePrinter != isRemotePrinter) {
            mIsRemotePrinter = isRemotePrinter;
        }
    }

    private void enablePrintButton() {
        printButton.setEnabled(true);
    }

    private void disablePrintButton() {
        printButton.setEnabled(false);
    }


    private boolean isPrinterChanged() {

        throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.ui.PrintPreviewActivity.isPrinterChanged():boolean");
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        switch (i) {
            case 1:
                enablePrintButton();
                ExternalFileUtils.getInstance(this).initPrintDir();
                mReviewInvitationViewModel.onPrintEnd(CameraPrintProgress.isPrintSuccess(i2));
                return;
            case 2:
                if (i2 == 3) {
                    enablePrintButton();
                    if (isPrinterChanged()) {
                        aPaperSourceSetting = null;
                        setPaperSizeDisplayForNoPapaerInfoPrinter();
                        startLoadtask();
                        return;
                    }
                    loadPrinterSettingAndChangeView(false);
                    return;
                }
                return;
            case 3:
                if (updateManuscriptSize()) {
                    mPreviewView.setPrintTargetSize(mManuscriptSize.getPixelWidth(), mManuscriptSize.getPixelHeight());
                    mPreviewView.update();
                    return;
                }
                return;
            case 4:
                if (i2 == -1) {
                    aPaperSourceSetting = null;
                    setPaperSizeDisplayForNoPapaerInfoPrinter();
                    bAutoStartPrint = true;
                    startLoadtask();
                    return;
                }
                return;
            default:
                return;
        }
    }

    protected void onRestart() {
        super.onRestart();
        PreviewView previewView = mPreviewView;
        if (previewView != null) {
            previewView.restoreBitmap();
        }
    }

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

    protected void onNewIntent(Intent intent) {
        NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
        super.onNewIntent(intent);
        String action = intent.getAction();
        AllReloadTask allReloadTask = reloadTask;
        if (allReloadTask != null && allReloadTask.getStatus() == AsyncTask.Status.FINISHED && "android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
            Intent intent2 = new Intent();
            intent2.setClass(this, ActivityNfcPrinter.class);
            intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
            intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
            startActivityForResult(intent2, 4);
        }
    }

    protected void onDestroy() {
        EPLog.v("ActivityImageViewSelect", "onDestroy");
        super.onDestroy();
        IEpsonService iEpsonService = mEpsonService;
        if (iEpsonService != null) {
            try {
                iEpsonService.cancelSearchPrinter();
                mEpsonService.unregisterCallback(mCallback);
                unbindService(mEpsonConnection);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    protected void onPause() {
        EPLog.d("ActivityImageViewSelect", "onPause");
        super.onPause();
        if (isFinishing()) {
            AllReloadTask allReloadTask = reloadTask;
            if (allReloadTask != null) {
                allReloadTask.cancel(false);
            }
            dismissProgressDialog();
            mHandler.removeMessages(3);
            mHandler.removeMessages(5);
            mHandler.removeMessages(0);
            mHandler.removeMessages(1);
            mHandler.removeMessages(100);
            mHandler.removeMessages(8);
            mPreviewView.setPrttargetScaleChangeListener((PreviewView.PrttargetScaleChangeListener) null);
            mPreviewView = null;
        }
        NfcTagUtils.disableForegroundDispatch(this);
        paperSourceInfo.stop();
    }

    protected void onStop() {
        if (isFinishing()) {
            new PrintSetting(this, PrintSetting.Kind.cameracopy).resetPrintSettings();
        }
        super.onStop();
    }

    private void check3GAndStartPrint() {
        mHandler.sendEmptyMessage(5);
    }

    private void startLoadtask() {
        reloadTask = new AllReloadTask();
        reloadTask.executeOnExecutor(new Void[0]);
    }

    private void showProgressDialog() {
        mModelDialog.doShow(DIALOG_PROGRESS);
    }

    private void dismissProgressDialog() {
        mModelDialog.doDismiss(DIALOG_PROGRESS);
    }

    private void startPrint() {
        ExternalFileUtils.getInstance(this).initPrintDir();
        ImageAndLayout imageAndLayout = mPreviewView.getImageAndLayout();
        imageAndLayout.setOrgFileName(mImageList.get(0).loadImageFileName);
        ArrayList arrayList = new ArrayList();
        arrayList.add(imageAndLayout);
        Intent intent = new Intent(this, CameraPrintProgress.class);
        intent.putExtra(CameraPrintProgress.KEY_IMAGE_AND_LAYOUT, arrayList);
        startActivityForResult(intent, 1);
    }

    private void updatePaperDisplay(Message message) {
        aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
        if (this.aPaperSourceSetting != null) {
            papersizeTextView.setTextColor(getResources().getColor(R.color.epson_blue));
            mPrintTargetSizeText.setTextColor(getResources().getColor(R.color.epson_blue));
            mScaleText.setTextColor(getResources().getColor(R.color.epson_blue));
            PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
            printSetting.loadSettings();
            if (this.paperSourceInfo.checkPaperMissmatch(printSetting, aPaperSourceSetting)) {
                paperMissmath.setVisibility(View.VISIBLE);
            } else {
                paperMissmath.setVisibility(4);
            }
        } else {
            setPaperSizeDisplayForNoPapaerInfoPrinter();
        }
    }

    private void setPaperSizeDisplayForNoPapaerInfoPrinter() {
        papersizeTextView.setTextColor(getResources().getColor(R.color.all_black));
        mPrintTargetSizeText.setTextColor(getResources().getColor(R.color.all_black));
        mScaleText.setTextColor(getResources().getColor(R.color.all_black));
        paperMissmath.setVisibility(4);
    }

    private boolean isRemotePrinter() {
        return MyPrinter.isRemotePrinter(this);
    }

    private void showDialog(String str) {
        DialogProgress newInstance = DialogProgress.newInstance(str, 0, getString(R.string.str_load));
        newInstance.setCancelable(false);
        newInstance.show(getSupportFragmentManager(), str);
    }

    private void dismissDialog(String str) {
        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
        if (dialogFragment != null) {
            dialogFragment.dismiss();
        }
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.icon_papermissmatch /*2131231117*/:
            case R.id.paper_size_text /*2131231310*/:
            case R.id.printtarget_size_text /*2131231374*/:
                if (this.aPaperSourceSetting != null) {
                    Intent intent = new Intent();
                    intent.setClass(this, PaperSourceSettingScr.class);
                    intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, aPaperSourceSetting);
                    intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.cameracopy.name());
                    startActivityForResult(intent, 2);
                    return;
                }
                callPrintSetting();
                return;
            case R.id.print_button /*2131231336*/:
                mIsRemotePrinter = isRemotePrinter();
                if (mIsRemotePrinter && enableShowWarning) {
                    AlertDialog.Builder cancelable = new AlertDialog.Builder(this).setCancelable(false);
                    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) {
                            PrintPreviewActivity.this.check3GAndStartPrint();
                        }
                    }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }).show();
                    return;
                } else if (this.currentPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
                    new AlertDialog.Builder(this).setCancelable(false).setTitle(R.string.printer_notselect_title).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }).show();
                    return;
                } else {
                    check3GAndStartPrint();
                    return;
                }
            case R.id.rotate_button /*2131231420*/:
                mPreviewView.rotateImageR90();
                mPreviewView.update();
                return;
            default:
                return;
        }
    }

    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.menu.print_menu, menu);
        return true;
    }

    private void setPreferencesDocumentMode() {
        SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
        edit.putInt(Constants.SOURCE_TYPE, 1);
        edit.commit();
    }

    public void callPrintSetting() {
        System.gc();
        Intent intent = new Intent(this, CameraPrintSettingActivity.class);
        intent.setAction("android.intent.action.VIEW");
        startActivityForResult(intent, 2);
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (keyEvent.getAction() == 0 && i == 84) {
            EPLog.e("key search", "diable");
            return true;
        } else if (keyEvent.getAction() != 0 || i != 4) {
            return false;
        } else {
            onBackPressed();
            return true;
        }
    }

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

    protected void onRestoreInstanceState(Bundle bundle) {
        super.onRestoreInstanceState(bundle);
        mPreviewView.restoreInstanceState(bundle, KEY_PREVIEW_VIEW);
    }

    protected void onSaveInstanceState(Bundle bundle) {
        mPreviewView.saveInstanceState(bundle, KEY_PREVIEW_VIEW);
        super.onSaveInstanceState(bundle);
    }

    public void onPrttargetScaleChange(double d) {
        mHandler.sendMessage(mHandler.obtainMessage(8, Double.valueOf(d)));
    }

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

    /* renamed from: com.epson.cameracopy.ui.PrintPreviewActivity$AllReloadTask */
    public class AllReloadTask extends AsyncTaskExecutor<Void, Integer, Boolean> {
        public AllReloadTask() {
        }

        protected void onPreExecute() {
            PrintPreviewActivity.this.showProgressDialog();
        }

        protected Boolean doInBackground(Void... voidArr) {
            System.gc();
            int i = 0;
            do {
                try {
                    if (PrintPreviewActivity.mEpsonService != null) {
                        break;
                    } else if (isCancelled()) {
                        return false;
                    } else {
                        Thread.sleep(100);
                        i++;
                    }
                } catch (RemoteException e) {
                    e.printStackTrace();
                } catch (InterruptedException e2) {
                    e2.printStackTrace();
                }
            } while (i < 100);
            if (isCancelled()) {
                return false;
            }
            if (PrintPreviewActivity.mEpsonService != null) {
                if (PrintPreviewActivity.this.isRemotePrinter()) {
                    PrintPreviewActivity.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.cameracopy.name());
                } else {
                    PrintPreviewActivity.mEpsonService.updatePrinterSettings(PrintSetting.Kind.cameracopy.name());
                }
            }
            return true;
        }

        protected void onPostExecute(Boolean bool) {
            PrintPreviewActivity.this.loadPrinterSettingAndChangeView(false);
            PrintPreviewActivity.this.dismissProgressDialog();
            if (PrintPreviewActivity.this.bAutoStartPrint) {
                PrintPreviewActivity printPreviewActivity = PrintPreviewActivity.this;
                printPreviewActivity.onClick(printPreviewActivity.printButton);
                PrintPreviewActivity.this.bAutoStartPrint = false;
            }
        }
    }
}
