package com.epson.cameracopy.ui;

import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.epson.mobilephone.common.escpr.EscprError;
import com.epson.mobilephone.common.escpr.MediaInfo;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
import epson.common.Constants;
import epson.common.ExternalFileUtils;
import epson.common.Utils;
import epson.print.ActivityIACommon;

import epson.print.EPPrinterManager;
import epson.print.MyPrinter;
import epson.print.R;
import epson.print.Util.EPLog;
import epson.print.inkrpln.InkRplnRepository;
import epson.print.screen.PageRangeSetting;
import epson.print.screen.PrintProgress;
import epson.print.screen.PrintSetting;
import epson.print.screen.PrinterInfoDetail;
import epson.print.screen.SearchPrinterScr;
import epson.print.service.EpsonService;
import epson.print.service.IEpsonService;
import epson.print.service.IEpsonServiceCallback;
import epson.print.widgets.CustomTitleAlertDialogBuilder;
import epson.print.widgets.LongTapRepeatAdapter;
import java.io.File;
import java.util.ArrayList;

/* renamed from: com.epson.cameracopy.ui.CameraPrintSettingActivity */
public class CameraPrintSettingActivity extends ActivityIACommon implements View.OnClickListener {
    private static final String EXTRA_PRINTER = "myprinter";
    private static final String EXTRA_SIMPLEAP = "simpleap";
    private static final int REQUEST_CODE_INFO = 1;
    private static final int REQUEST_CODE_INK_REPLENISH_PROGRESS = 4;
    private static final int REQUEST_CODE_PAGE_RANGE = 2;
    private static final int REQUEST_CODE_PRINTER = 0;
    public static final String TAG = "CameraPrintSetting";
    private final int COLOR_VALUE_MAX = 50;
    private final int COLOR_VALUE_MIN = -50;
    private final int COPIES_MAX = 30;
    private final int COPIES_MIN = 1;
    private final int EPS_ERR_COMM_ERROR = -1100;
    private final int EPS_ERR_NONE = 0;
    private final int EPS_ERR_OPR_FAIL = -1000;
    private final int EPS_ERR_PRINTER_NOT_SET = EscprError.EPS_ERR_PRINTER_NOT_SET;
    private final int GET_ADVANCED = 64;
    private final int GET_COLOR = 6;
    private final int GET_DUPLEX = 32;
    private final int GET_LAYOUT = 3;
    private final int GET_PAPER_SIZE = 1;
    private final int GET_PAPER_SOURCE = 5;
    private final int GET_PAPER_TYPE = 2;
    private final int GET_QUALITY = 4;
    private final int GET_SUPPORTED_MEDIA = 0;
    private final int PROBE_PRINTER = 17;
    private final int SEARCH_BY_ID = 7;
    private final int SEARCH_ERROR = 16;
    private final int SETTING_DONE = 3;
    private final int SHOW_ERROR_DIALOG = 18;
    private String autoConnectSsid = null;
    private TextView brightness;
    private Button brightnessMinus;
    private Button brightnessPlus;
    private int brightnessValue;
    private int color;
    private TextView colorInfo;
    private int[] color_info = null;
    private TextView contrast;
    private Button contrastMinus;
    private Button contrastPlus;
    private int contrastValue;
    private TextView copies;
    private Button copiesMinus;
    private Button copiesPlus;
    private int copiesValue;
    private boolean disablePrintArea = false;
    private int duplex;
    private TextView duplexInfo;
    private int[] duplex_info = null;
    private boolean enableShowPreview = false;
    private int endValue;
    private int feedDirection;
    private TextView feedDirectionInfo;
    private int[] info = null;
    private boolean isDocumentSetting = true;
    boolean isInfoAvai = false;
    Boolean isNotLoading = true;
    private boolean isRetryAfterConnectSimpleAp = false;
    private boolean isTryConnectSimpleAp = false;
    private int lang = 1;
    private int layout;
    private TextView layoutInfo;
    private int[] layout_info = null;
    private final IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
        public void onGetInkState() throws RemoteException {
        }

        public void onGetStatusState() throws RemoteException {
        }

        public void onNotifyEndJob(int i) throws RemoteException {
        }

        public void onNotifyProgress(int i, int i2) throws RemoteException {
        }

        public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
            String unused = CameraPrintSettingActivity.this.printerIp = str2;
        }

        public void onNotifyContinueable(int i) throws RemoteException {
            EPLog.m313i("IEpsonServiceCallback", "onNotifyContinueable code = " + i);
            if (i == 0) {
                CameraPrintSettingActivity cameraPrintSettingActivity = CameraPrintSettingActivity.this;
                cameraPrintSettingActivity.isInfoAvai = true;
                int unused = cameraPrintSettingActivity.lang = cameraPrintSettingActivity.getPrinterLang();
                CameraPrintSettingActivity cameraPrintSettingActivity2 = CameraPrintSettingActivity.this;
                cameraPrintSettingActivity2.undoFlag = false;
                cameraPrintSettingActivity2.mHandler.sendEmptyMessage(0);
            }
        }

        public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
            EPLog.m313i("IEpsonServiceCallback", "onNotifyError errorCode = " + i2);
            CameraPrintSettingActivity cameraPrintSettingActivity = CameraPrintSettingActivity.this;
            cameraPrintSettingActivity.isInfoAvai = true;
            int unused = cameraPrintSettingActivity.lang = cameraPrintSettingActivity.getPrinterLang();
            CameraPrintSettingActivity cameraPrintSettingActivity2 = CameraPrintSettingActivity.this;
            cameraPrintSettingActivity2.undoFlag = false;
            cameraPrintSettingActivity2.mHandler.sendEmptyMessage(0);
        }
    };
    private final boolean mCameraCopy = true;
    private Context mContext = null;
    private final ServiceConnection mEpsonConnection = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName componentName) {
            EPLog.m316v("SettingScr", "onServiceDisconnected");
            try {
                CameraPrintSettingActivity.mEpsonService.unregisterCallback(CameraPrintSettingActivity.mCallback);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            IEpsonService unused = CameraPrintSettingActivity.mEpsonService = null;
        }

        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            IEpsonService unused = CameraPrintSettingActivity.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
            EPLog.m316v("SettingScr", "onServiceConnected");
            if (CameraPrintSettingActivity.mEpsonService != null) {
                try {
                    CameraPrintSettingActivity.mEpsonService.registerCallback(CameraPrintSettingActivity.mCallback);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    private IEpsonService mEpsonService = null;
    Handler mHandler = new Handler(new Handler.Callback() {

        public boolean handleMessage(android.os.Message r15) {

            throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.ui.CameraPrintSettingActivity.C08553.handleMessage(android.os.Message):boolean");
        }

        private int[] removeCddvdMedia(int[] iArr) {
            if (iArr == null) {
                return null;
            }
            ArrayList arrayList = new ArrayList();
            for (int valueOf : iArr) {
                arrayList.add(Integer.valueOf(valueOf));
            }
            for (Integer remove : new Integer[]{91, 92, 93}) {
                do {
                } while (arrayList.remove(remove));
            }
            int[] iArr2 = new int[arrayList.size()];
            for (int i = 0; i < arrayList.size(); i++) {
                iArr2[i] = ((Integer) arrayList.get(i)).intValue();
            }
            return iArr2;
        }
    });
    private MediaInfo.AbstractInfo mLookupTable;
    private MediaInfo.AbstractInfo mPaperSizeType;
    private boolean mPrinterSelectDone;
    private int mRemoteSrcType;
    private boolean mWaiteInkReplenProgress;
    private int paperSize;
    private TextView paperSizeInfo;
    private int paperSource;
    private TextView paperSourceInfo;
    private int paperType;
    private TextView paperTypeInfo;
    private int[] paper_size_info = null;
    private int[] paper_source_info = null;
    private int[] paper_type_info = null;
    private boolean printAll;
    private TextView printDateInfo;
    private int printdate;
    private MyPrinter printer = null;
    private String printerDeviceId;
    private String printerEmailAddress;
    private String printerId;
    private String printerIp;
    private int printerLocation;
    private TextView printerName;
    private String printerSerialNo;
    private View progressGetOption;
    private int quality;
    private TextView qualityInfo;
    private int[] quality_info = null;
    private TextView saturation;
    private Button saturationMinus;
    private Button saturationPlus;
    private int saturationValue;
    private int sheets = 1;
    private int sizeIndex = 0;
    private int startValue;
    private int typeIndex = 0;
    boolean undoFlag = true;

    static /* synthetic */ int access$1108(CameraPrintSettingActivity cameraPrintSettingActivity) {
        int i = cameraPrintSettingActivity.sizeIndex;
        cameraPrintSettingActivity.sizeIndex = i + 1;
        return i;
    }

    static /* synthetic */ int access$1608(CameraPrintSettingActivity cameraPrintSettingActivity) {
        int i = cameraPrintSettingActivity.typeIndex;
        cameraPrintSettingActivity.typeIndex = i + 1;
        return i;
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.setting_layout);
        setActionBar((int) R.string.str_btn_printer_settings, true);
        bindEpsonService();
        mContext = this;
        mRemoteSrcType = 2;
        isDocumentSetting = getIntent().getBooleanExtra(PrintProgress.PARAM_DOCUMENT_MODE, false);
        if (this.isDocumentSetting) {
            sheets = getIntent().getIntExtra("SHEETS", 1);
            disablePrintArea = getIntent().getBooleanExtra("PRINTAREA", false);
            mRemoteSrcType = 1;
        }
        sheets = 1;
        mRemoteSrcType = 2;
        printerName = (TextView) findViewById(R.id.printer_name);
        paperSizeInfo = (TextView) findViewById(R.id.paper_size_info);
        paperTypeInfo = (TextView) findViewById(R.id.paper_type_info);
        layoutInfo = (TextView) findViewById(R.id.layout_info);
        qualityInfo = (TextView) findViewById(R.id.quality_info);
        paperSourceInfo = (TextView) findViewById(R.id.paper_source_info);
        copies = (TextView) findViewById(R.id.copies);
        copiesMinus = (Button) findViewById(R.id.copies_minus_button);
        copiesPlus = (Button) findViewById(R.id.copies_plus_button);
        LongTapRepeatAdapter.bless(this.copiesMinus);
        LongTapRepeatAdapter.bless(this.copiesPlus);
        colorInfo = (TextView) findViewById(R.id.color_info);
        duplexInfo = (TextView) findViewById(R.id.duplex_info);
        feedDirectionInfo = (TextView) findViewById(R.id.feed_direction_info);
        printDateInfo = (TextView) findViewById(R.id.printdate_info);
        brightness = (TextView) findViewById(R.id.brightness);
        brightnessMinus = (Button) findViewById(R.id.brightness_minus_button);
        brightnessPlus = (Button) findViewById(R.id.brightness_plus_button);
        contrast = (TextView) findViewById(R.id.contrast);
        contrastMinus = (Button) findViewById(R.id.contrast_minus_button);
        contrastPlus = (Button) findViewById(R.id.contrast_plus_button);
        saturation = (TextView) findViewById(R.id.saturation);
        saturationMinus = (Button) findViewById(R.id.saturation_minus_button);
        saturationPlus = (Button) findViewById(R.id.saturation_plus_button);
        progressGetOption = findViewById(R.id.progressGetOption);
        enableShowPreview = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
        loadConfig();
        setClickListener();
        updatePrinterIcon();
        if (this.printerId != null) {
            undoFlag = false;
            if (loadSupportedMediaFile()) {
                mHandler.sendEmptyMessage(1);
            } else {
                mHandler.sendEmptyMessage(17);
            }
        } else {
            mHandler.sendEmptyMessage(1);
        }
    }

    private void updatePrinterIcon() {
        if (this.printerName.getText().equals(getString(R.string.str_lbl_title_scan))) {
            ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setVisibility(8);
            return;
        }
        ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setVisibility(0);
        switch (this.printerLocation) {
            case 1:
                ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setImageResource(R.C2136drawable.print_local);
                return;
            case 2:
                ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setImageResource(R.C2136drawable.print_remote);
                return;
            case 3:
                ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setImageResource(R.C2136drawable.print_ip);
                return;
            default:
                return;
        }
    }

    private void setClickListener() {
        copiesMinus.setOnClickListener(this);
        copiesPlus.setOnClickListener(this);
        brightnessMinus.setOnClickListener(this);
        brightnessPlus.setOnClickListener(this);
        contrastMinus.setOnClickListener(this);
        contrastPlus.setOnClickListener(this);
        saturationMinus.setOnClickListener(this);
        saturationPlus.setOnClickListener(this);
        if (this.isDocumentSetting) {
            findViewById(R.id.page_range_setting).setOnClickListener(this);
        }
        findViewById(R.id.printer).setOnClickListener(this);
        findViewById(R.id.paper_size).setOnClickListener(this);
        findViewById(R.id.paper_type).setOnClickListener(this);
        findViewById(R.id.layout).setOnClickListener(this);
        findViewById(R.id.quality).setOnClickListener(this);
        findViewById(R.id.paper_source).setOnClickListener(this);
        findViewById(R.id.color).setOnClickListener(this);
        findViewById(R.id.duplex).setOnClickListener(this);
        findViewById(R.id.feed_direction).setOnClickListener(this);
        findViewById(R.id.printdate).setOnClickListener(this);
    }

    private void loadConfig() {
        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
        if (curPrinter == null || curPrinter.getName() == null) {
            printerName.setText(getString(R.string.str_lbl_title_scan));
        } else {
            printerName.setText(curPrinter.getUserDefName(this));
        }
        printerDeviceId = curPrinter.getName();
        printerId = curPrinter.getPrinterId();
        printerIp = curPrinter.getIp();
        printerSerialNo = curPrinter.getSerialNo();
        printerEmailAddress = curPrinter.getEmailAddress();
        printerLocation = curPrinter.getLocation();
        boolean z = true;
        if (this.printerLocation == 0) {
            printerLocation = 1;
        }
        autoConnectSsid = WiFiDirectManager.getConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_PRINTER);
        PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
        printSetting.loadSettings();
        mLookupTable = new MediaInfo.PaperSize();
        paperSize = printSetting.paperSizeValue;
        paperSizeInfo.setText(getString(mLookupTable.getStringId(this.paperSize)));
        mLookupTable.destructor();
        mLookupTable = new MediaInfo.PaperType();
        paperType = printSetting.paperTypeValue;
        paperTypeInfo.setText(getString(mLookupTable.getStringId(this.paperType)));
        mLookupTable.destructor();
        mPaperSizeType = printSetting.loadPaperSizeTypePear();
        mPaperSizeType.putID(this.paperSize, paperType);
        mLookupTable = new MediaInfo.Layout();
        layout = printSetting.layoutValue;
        layoutInfo.setText(getString(mLookupTable.getStringId(this.layout)));
        mLookupTable.destructor();
        mLookupTable = new MediaInfo.Quality();
        quality = printSetting.qualityValue;
        qualityInfo.setText(getString(mLookupTable.getStringId(this.quality)));
        mLookupTable.destructor();
        mLookupTable = new MediaInfo.PaperSource();
        paperSource = printSetting.paperSourceValue;
        paperSourceInfo.setText(getString(mLookupTable.getStringId(this.paperSource)));
        mLookupTable.destructor();
        mLookupTable = new MediaInfo.Color();
        color = printSetting.colorValue;
        colorInfo.setText(getString(mLookupTable.getStringId(this.color)));
        mLookupTable.destructor();
        copiesValue = printSetting.copiesValue;
        copies.setText(String.valueOf(this.copiesValue));
        copiesMinus.setEnabled(this.copiesValue != 1);
        Button button = copiesPlus;
        if (this.copiesValue == 30) {
            z = false;
        }
        button.setEnabled(z);
        brightnessValue = printSetting.brightnessValue;
        contrastValue = printSetting.contrastValue;
        saturationValue = printSetting.saturationValue;
        mLookupTable = new MediaInfo.Duplex();
        duplex = printSetting.duplexValue;
        duplexInfo.setText(getString(mLookupTable.getStringId(this.duplex)));
        mLookupTable.destructor();
        mLookupTable = new MediaInfo.FeedDirection();
        feedDirection = printSetting.feedDirectionValue;
        feedDirectionInfo.setText(getString(mLookupTable.getStringId(this.feedDirection)));
        mLookupTable.destructor();
        lang = curPrinter.getLang();
        if (this.isDocumentSetting) {
            printAll = printSetting.printAll;
            startValue = printSetting.startValue;
            endValue = printSetting.endValue;
            ((TextView) findViewById(R.id.page_range_value)).setText(this.startValue + ".." + endValue);
            return;
        }
        mLookupTable = new MediaInfo.PrintDate();
        printdate = printSetting.printdate;
        printDateInfo.setText(getString(mLookupTable.getStringId(this.printdate)));
        mLookupTable.destructor();
    }

    private boolean loadSupportedMediaFile() {
        ExternalFileUtils instance = ExternalFileUtils.getInstance(this);
        File savedSupportedMedia = instance.getSavedSupportedMedia();
        File supportedMedia = instance.getSupportedMedia();
        File preSupportedMedia = instance.getPreSupportedMedia();
        EPLog.m313i(TAG, "call loadSupportedMedia");
        try {
            if (!savedSupportedMedia.exists()) {
                EPLog.m318w("loadSupportedMedia", savedSupportedMedia.getName() + " not exist");
                return false;
            }
            Utils.copyFile(savedSupportedMedia, supportedMedia);
            Utils.copyFile(savedSupportedMedia, preSupportedMedia);
            File savedAreaInfo = instance.getSavedAreaInfo();
            File areaInfo = instance.getAreaInfo();
            File preAreaInfo = instance.getPreAreaInfo();
            try {
                if (!savedAreaInfo.exists()) {
                    return true;
                }
                Utils.copyFile(savedAreaInfo, areaInfo);
                Utils.copyFile(savedAreaInfo, preAreaInfo);
                return true;
            } catch (Exception e) {
                EPLog.m318w("loadSupportedMedia", "failure " + e.getMessage());
                return false;
            }
        } catch (Exception e2) {
            EPLog.m318w("loadSupportedMedia", "failure " + e2.getMessage());
            return false;
        }
    }

    private boolean updateSupportedMediaFile(boolean z) {
        ExternalFileUtils instance = ExternalFileUtils.getInstance(this);
        EPLog.m313i(TAG, "call updateSupportedMedia");
        File supportedMedia = instance.getSupportedMedia();
        File preSupportedMedia = instance.getPreSupportedMedia();
        if (z) {
            File file = preSupportedMedia;
            preSupportedMedia = supportedMedia;
            supportedMedia = file;
        }
        try {
            Utils.copyFile(supportedMedia, preSupportedMedia);
            File areaInfo = instance.getAreaInfo();
            File preAreaInfo = instance.getPreAreaInfo();
            if (!z) {
                File file2 = areaInfo;
                areaInfo = preAreaInfo;
                preAreaInfo = file2;
            }
            try {
                if (!preAreaInfo.exists()) {
                    return true;
                }
                Utils.copyFile(preAreaInfo, areaInfo);
                return true;
            } catch (Exception e) {
                if (preAreaInfo != null && preAreaInfo.exists()) {
                    preAreaInfo.delete();
                }
                if (areaInfo != null && areaInfo.exists()) {
                    areaInfo.delete();
                }
                EPLog.m318w("updateSupportedMediaFile", "failure " + e.getMessage());
                return false;
            }
        } catch (Exception e2) {
            if (supportedMedia != null && supportedMedia.exists()) {
                supportedMedia.delete();
            }
            if (preSupportedMedia != null && preSupportedMedia.exists()) {
                preSupportedMedia.delete();
            }
            EPLog.m318w("updateSupportedMediaFile", "failure " + e2.getMessage());
            return false;
        }
    }

    private boolean saveSupportedMediaFile() {
        ExternalFileUtils instance = ExternalFileUtils.getInstance(this);
        EPLog.m313i(TAG, "call saveSupportedMedia");
        File supportedMedia = instance.getSupportedMedia();
        File savedSupportedMedia = instance.getSavedSupportedMedia();
        try {
            if (!supportedMedia.exists()) {
                EPLog.m318w("updateSupportedMediaFile", supportedMedia.getName() + " not exist");
                return false;
            }
            Utils.copyFile(supportedMedia, savedSupportedMedia);
            File areaInfo = instance.getAreaInfo();
            File savedAreaInfo = instance.getSavedAreaInfo();
            int i = printerLocation;
            if (i == 1 || i == 3) {
                try {
                    if (!areaInfo.exists()) {
                        EPLog.m318w("updateSupportedMediaFile", areaInfo.getName() + " not exist");
                        return false;
                    }
                    Utils.copyFile(areaInfo, savedAreaInfo);
                } catch (Exception e) {
                    EPLog.m318w("saveSupportedMediaFile", "failure " + e.getMessage());
                    return false;
                }
            } else {
                EPLog.m313i(TAG, "delete AreaInfo");
                instance.removeAreaInfo();
            }
            return true;
        } catch (Exception e2) {
            EPLog.m318w("saveSupportedMediaFile", "failure " + e2.getMessage());
            return false;
        }
    }

    private void saveChanged() {
        SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
        edit.putInt(Constants.PREFS_INFO_PRINT_SAVE, 1);
        edit.commit();
        MyPrinter myPrinter = new MyPrinter(this.printerDeviceId, printerIp, printerId, printerSerialNo, printerEmailAddress, printerLocation);
        myPrinter.setLang(this.lang);
        myPrinter.setCurPrinter(this);
        PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
        printSetting.paperSizeValue = paperSize;
        printSetting.paperTypeValue = paperType;
        printSetting.layoutValue = layout;
        printSetting.qualityValue = quality;
        printSetting.paperSourceValue = paperSource;
        printSetting.colorValue = color;
        printSetting.duplexValue = duplex;
        printSetting.feedDirectionValue = feedDirection;
        printSetting.copiesValue = copiesValue;
        printSetting.brightnessValue = brightnessValue;
        printSetting.contrastValue = contrastValue;
        printSetting.saturationValue = saturationValue;
        if (this.isDocumentSetting) {
            printSetting.printAll = printAll;
            printSetting.startValue = startValue;
            printSetting.endValue = endValue;
        } else {
            printSetting.printdate = printdate;
        }
        printSetting.saveSettings();
        printSetting.savePaperSizeTypePear((MediaInfo.PaperSizeType) mPaperSizeType);
        saveSupportedMediaFile();
        String str = autoConnectSsid;
        if (str == null || str.length() <= 0) {
            WiFiDirectManager.resetConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_PRINTER);
        } else {
            WiFiDirectManager.setConnectInfo(this, autoConnectSsid, WiFiDirectManager.DEVICE_TYPE_PRINTER, myPrinter.getName());
        }
        EPPrinterManager ePPrinterManager = new EPPrinterManager(mContext);
        ePPrinterManager.commitIPPrinterInfo();
        ePPrinterManager.commitRemotePrinterInfo();
        if (mPrinterSelectDone) {
            new InkRplnRepository(false).savePermanently(this);
        }
    }

    protected void onDestroy() {
        super.onDestroy();
        unbindEpsonService();
        EPLog.m313i("SettingScr", "onDestroy");
        mPaperSizeType.destructor();
    }

    private void bindEpsonService() {
        EPLog.m316v("SettingScr", "bindEpsonService");
        if (mEpsonService == null) {
            bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
        }
    }

    private void unbindEpsonService() {
        EPLog.m316v("SettingScr", "unbindEpsonService");
        IEpsonService iEpsonService = mEpsonService;
        if (iEpsonService != null) {
            try {
                iEpsonService.unregisterCallback(mCallback);
                unbindService(mEpsonConnection);
                mEpsonService = null;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    public void onClick(View view) {
        if (this.progressGetOption.getVisibility() == 8) {
            IEpsonService iEpsonService = mEpsonService;
            if (iEpsonService != null) {
                try {
                    iEpsonService.cancelSearchPrinter();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
            switch (view.getId()) {
                case R.id.brightness_minus_button /*2131230848*/:
                    brightnessValue--;
                    if (this.brightnessValue <= -50) {
                        brightnessValue = -50;
                        brightnessMinus.setEnabled(false);
                    } else {
                        brightnessMinus.setEnabled(true);
                    }
                    brightnessPlus.setEnabled(true);
                    brightness.setText(String.valueOf(this.brightnessValue));
                    return;
                case R.id.brightness_plus_button /*2131230850*/:
                    brightnessValue++;
                    if (this.brightnessValue >= 50) {
                        brightnessValue = 50;
                        brightnessPlus.setEnabled(false);
                    } else {
                        brightnessPlus.setEnabled(true);
                    }
                    brightnessMinus.setEnabled(true);
                    brightness.setText(String.valueOf(this.brightnessValue));
                    return;
                case R.id.color /*2131230930*/:
                    launchDetailScreen(this.color, R.id.color);
                    return;
                case R.id.contrast_minus_button /*2131230942*/:
                    contrastValue--;
                    if (this.contrastValue <= -50) {
                        contrastValue = -50;
                        contrastMinus.setEnabled(false);
                    } else {
                        contrastMinus.setEnabled(true);
                    }
                    contrastPlus.setEnabled(true);
                    contrast.setText(String.valueOf(this.contrastValue));
                    return;
                case R.id.contrast_plus_button /*2131230943*/:
                    contrastValue++;
                    if (this.contrastValue >= 50) {
                        contrastValue = 50;
                        contrastPlus.setEnabled(false);
                    } else {
                        contrastPlus.setEnabled(true);
                    }
                    contrastMinus.setEnabled(true);
                    contrast.setText(String.valueOf(this.contrastValue));
                    return;
                case R.id.copies_minus_button /*2131230945*/:
                    copiesValue--;
                    if (this.copiesValue <= 1) {
                        copiesValue = 1;
                        copiesMinus.setEnabled(false);
                    } else {
                        copiesMinus.setEnabled(true);
                    }
                    copiesPlus.setEnabled(true);
                    copies.setText(String.valueOf(this.copiesValue));
                    return;
                case R.id.copies_plus_button /*2131230946*/:
                    copiesValue++;
                    if (this.copiesValue >= 30) {
                        copiesValue = 30;
                        copiesPlus.setEnabled(false);
                    } else {
                        copiesPlus.setEnabled(true);
                    }
                    copiesMinus.setEnabled(true);
                    copies.setText(String.valueOf(this.copiesValue));
                    return;
                case R.id.duplex /*2131231005*/:
                    launchDetailScreen(this.duplex, R.id.duplex);
                    return;
                case R.id.feed_direction /*2131231037*/:
                    launchDetailScreen(this.feedDirection, R.id.feed_direction);
                    return;
                case R.id.layout /*2131231158*/:
                    launchDetailScreen(this.layout, R.id.layout);
                    return;
                case R.id.page_range_setting /*2131231300*/:
                    Intent intent = new Intent(this, PageRangeSetting.class);
                    intent.putExtra("SHEETS", sheets);
                    intent.putExtra("printAll", printAll);
                    intent.putExtra("startValue", startValue);
                    intent.putExtra("endValue", endValue);
                    startActivityForResult(intent, 2);
                    return;
                case R.id.paper_size /*2131231306*/:
                    launchDetailScreen(this.paperSize, R.id.paper_size);
                    return;
                case R.id.paper_source /*2131231311*/:
                    int i = paperSource;
                    int[] iArr = paper_source_info;
                    if (iArr != null && iArr.length <= 1) {
                        i = 128;
                    }
                    launchDetailScreen(i, R.id.paper_source);
                    return;
                case R.id.paper_type /*2131231314*/:
                    launchDetailScreen(this.paperType, R.id.paper_type);
                    return;
                case R.id.printdate /*2131231355*/:
                    launchDetailScreen(this.printdate, R.id.printdate);
                    return;
                case R.id.printer /*2131231358*/:
                    unbindEpsonService();
                    new AsyncTask<Void, Void, Void>() {
                        protected void onPreExecute() {
                            CameraPrintSettingActivity.this.findViewById(R.id.printer).setClickable(false);
                        }

                        protected Void doInBackground(Void... voidArr) {
                            CameraPrintSettingActivity cameraPrintSettingActivity = CameraPrintSettingActivity.this;
                            WiFiDirectManager.disconnect(cameraPrintSettingActivity, WiFiDirectManager.DEVICE_TYPE_PRINTER, cameraPrintSettingActivity.printerIp);
                            CameraPrintSettingActivity cameraPrintSettingActivity2 = CameraPrintSettingActivity.this;
                            WiFiDirectManager.disconnectSimpleAP(cameraPrintSettingActivity2, cameraPrintSettingActivity2.autoConnectSsid, CameraPrintSettingActivity.this.printerIp);
                            return null;
                        }

                        protected void onPostExecute(Void voidR) {
                            Intent intent = new Intent(CameraPrintSettingActivity.this, SearchPrinterScr.class);
                            Bundle bundle = new Bundle();
                            bundle.putString(Constants.PRINTER_ID, CameraPrintSettingActivity.this.printerId);
                            bundle.putString(Constants.PRINTER_IP, CameraPrintSettingActivity.this.printerIp);
                            bundle.putString(Constants.PRINTER_EMAIL_ADDRESS, CameraPrintSettingActivity.this.printerEmailAddress);
                            bundle.putInt(Constants.PRINTER_LOCATION, CameraPrintSettingActivity.this.printerLocation);
                            bundle.putString(CameraPrintSettingActivity.EXTRA_SIMPLEAP, CameraPrintSettingActivity.this.autoConnectSsid);
                            intent.putExtras(bundle);
                            CameraPrintSettingActivity.this.startActivityForResult(intent, 0);
                            CameraPrintSettingActivity.this.findViewById(R.id.printer).setClickable(true);
                        }
                    }.execute(new Void[0]);
                    return;
                case R.id.quality /*2131231392*/:
                    launchDetailScreen(this.quality, R.id.quality);
                    return;
                case R.id.saturation_minus_button /*2131231425*/:
                    saturationValue--;
                    if (this.saturationValue <= -50) {
                        saturationValue = -50;
                        saturationMinus.setEnabled(false);
                    } else {
                        saturationMinus.setEnabled(true);
                    }
                    saturationPlus.setEnabled(true);
                    saturation.setText(String.valueOf(this.saturationValue));
                    return;
                case R.id.saturation_plus_button /*2131231426*/:
                    saturationValue++;
                    if (this.saturationValue >= 50) {
                        saturationValue = 50;
                        saturationPlus.setEnabled(false);
                    } else {
                        saturationPlus.setEnabled(true);
                    }
                    saturationMinus.setEnabled(true);
                    saturation.setText(String.valueOf(this.saturationValue));
                    return;
                default:
                    return;
            }
        }
    }

    private void launchDetailScreen(int i, int i2) {
        Intent intent = new Intent(this, PrinterInfoDetail.class);
        Bundle bundle = new Bundle();
        bundle.putInt("ID", i2);
        bundle.putInt("sizeIndex", sizeIndex);
        bundle.putInt("typeIndex", typeIndex);
        bundle.putInt("curValue", i);
        bundle.putBoolean("isDocumentSetting", isDocumentSetting);
        switch (i2) {
            case R.id.color /*2131230930*/:
                bundle.putIntArray(Constants.COLOR_INFO, color_info);
                break;
            case R.id.duplex /*2131231005*/:
                bundle.putIntArray(Constants.DUPLEX_INFO, duplex_info);
                break;
            case R.id.layout /*2131231158*/:
                bundle.putIntArray(Constants.LAYOUT_INFO, layout_info);
                break;
            case R.id.paper_size /*2131231306*/:
                bundle.putIntArray(Constants.PAPER_SIZE_INFO, paper_size_info);
                break;
            case R.id.paper_source /*2131231311*/:
                int[] iArr = paper_source_info;
                bundle.putIntArray(Constants.PAPER_SOURCE_INFO, (iArr == null || iArr.length > 1) ? paper_source_info : new int[]{128});
                break;
            case R.id.paper_type /*2131231314*/:
                bundle.putIntArray(Constants.PAPER_TYPE_INFO, paper_type_info);
                break;
            case R.id.quality /*2131231392*/:
                bundle.putIntArray(Constants.PRINT_QUALITY_INFO, quality_info);
                break;
        }
        intent.putExtras(bundle);
        startActivityForResult(intent, 1);
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        String callingPackage = getCallingPackage();
        EPLog.m313i(callingPackage, "requestCode = " + i + " resultCode = " + i2);
        if (i != 0) {
            if (i != 4) {
                if (i != 2) {
                    if (i == 1 && i2 == -1) {
                        int i3 = intent.getExtras().getInt("curValue");
                        switch (intent.getExtras().getInt("ID")) {
                            case R.id.color /*2131230930*/:
                                mLookupTable = new MediaInfo.Color();
                                colorInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                color = i3;
                                break;
                            case R.id.duplex /*2131231005*/:
                                mLookupTable = new MediaInfo.Duplex();
                                duplexInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                duplex = i3;
                                break;
                            case R.id.feed_direction /*2131231037*/:
                                mLookupTable = new MediaInfo.FeedDirection();
                                feedDirectionInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                feedDirection = i3;
                                break;
                            case R.id.layout /*2131231158*/:
                                mLookupTable = new MediaInfo.Layout();
                                layoutInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                layout = i3;
                                undoFlag = false;
                                mHandler.sendEmptyMessage(32);
                                break;
                            case R.id.paper_size /*2131231306*/:
                                sizeIndex = intent.getExtras().getInt("INDEX");
                                mLookupTable = new MediaInfo.PaperSize();
                                paperSizeInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                paperSize = i3;
                                paperType = mPaperSizeType.getID(this.paperSize);
                                undoFlag = false;
                                mHandler.sendEmptyMessage(2);
                                break;
                            case R.id.paper_source /*2131231311*/:
                                mLookupTable = new MediaInfo.PaperSource();
                                paperSourceInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                int[] iArr = paper_source_info;
                                if (iArr != null && iArr.length > 1) {
                                    paperSource = i3;
                                }
                                undoFlag = false;
                                mHandler.sendEmptyMessage(32);
                                break;
                            case R.id.paper_type /*2131231314*/:
                                typeIndex = intent.getExtras().getInt("INDEX");
                                mLookupTable = new MediaInfo.PaperType();
                                paperTypeInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                paperType = i3;
                                mPaperSizeType.putID(this.paperSize, paperType);
                                undoFlag = false;
                                mHandler.sendEmptyMessage(3);
                                break;
                            case R.id.printdate /*2131231355*/:
                                mLookupTable = new MediaInfo.PrintDate();
                                printDateInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                printdate = i3;
                                break;
                            case R.id.quality /*2131231392*/:
                                mLookupTable = new MediaInfo.Quality();
                                qualityInfo.setText(getString(mLookupTable.getStringId(i3)));
                                mLookupTable.destructor();
                                quality = i3;
                                break;
                        }
                    }
                } else if (i2 == -1) {
                    printAll = intent.getExtras().getBoolean("printAll");
                    startValue = intent.getExtras().getInt("startValue");
                    endValue = intent.getExtras().getInt("endValue");
                    mHandler.sendEmptyMessage(64);
                }
            } else {
                endInkReplAndGoProbePrinter();
            }
        } else {
            onPrinterSelectEnd(i2, intent);
        }
        updatePrinterIcon();
    }

    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* JADX WARNING: Code restructure failed: missing block: B:25:0x00ea, code lost:
        if (r7.loadIpPrinterInfo(r6.printerId) == null) goto L_0x00f7;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:0x00f3, code lost:
        if (r7.loadRemotePrinterInfo(r6.printerEmailAddress) == null) goto L_0x00f7;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void onPrinterSelectEnd(int r7, android.content.Intent r8) {
        /*
            r6 = this;
            r0 = 0
            r1 = 1
            r2 = -1
            if (r7 != r2) goto L_0x00d6
            android.os.Bundle r7 = r8.getExtras()
            java.lang.String r2 = "myprinter"
            android.os.Parcelable r7 = r7.getParcelable(r2)
            epson.print.MyPrinter r7 = (epson.print.MyPrinter) r7
            r6.printer = r7
            android.widget.TextView r7 = r6.printerName
            epson.print.MyPrinter r2 = r6.printer
            java.lang.String r2 = r2.getName()
            r7.setText(r2)
            epson.print.MyPrinter r7 = r6.printer
            java.lang.String r7 = r7.getName()
            r6.printerDeviceId = r7
            epson.print.MyPrinter r7 = r6.printer
            java.lang.String r7 = r7.getPrinterId()
            r6.printerId = r7
            epson.print.MyPrinter r7 = r6.printer
            java.lang.String r7 = r7.getIp()
            r6.printerIp = r7
            epson.print.MyPrinter r7 = r6.printer
            java.lang.String r7 = r7.getSerialNo()
            r6.printerSerialNo = r7
            epson.print.MyPrinter r7 = r6.printer
            java.lang.String r7 = r7.getEmailAddress()
            r6.printerEmailAddress = r7
            epson.print.MyPrinter r7 = r6.printer
            int r7 = r7.getLocation()
            r6.printerLocation = r7
            epson.print.EPPrinterManager r7 = new epson.print.EPPrinterManager
            r7.<init>(r6)
            int r2 = r6.printerLocation
            switch(r2) {
                case 2: goto L_0x0075;
                case 3: goto L_0x0059;
                default: goto L_0x0058;
            }
        L_0x0058:
            goto L_0x0090
        L_0x0059:
            java.lang.String r2 = r6.printerId
            epson.print.EPPrinterInfo r7 = r7.loadIpPrinterInfo(r2)
            if (r7 == 0) goto L_0x0090
            java.lang.String r2 = r7.userDefName
            if (r2 == 0) goto L_0x0090
            java.lang.String r2 = r7.userDefName
            int r2 = r2.length()
            if (r2 <= 0) goto L_0x0090
            android.widget.TextView r2 = r6.printerName
            java.lang.String r7 = r7.userDefName
            r2.setText(r7)
            goto L_0x0090
        L_0x0075:
            java.lang.String r2 = r6.printerEmailAddress
            epson.print.EPPrinterInfo r7 = r7.loadRemotePrinterInfo(r2)
            if (r7 == 0) goto L_0x0090
            java.lang.String r2 = r7.userDefName
            if (r2 == 0) goto L_0x0090
            java.lang.String r2 = r7.userDefName
            int r2 = r2.length()
            if (r2 <= 0) goto L_0x0090
            android.widget.TextView r2 = r6.printerName
            java.lang.String r7 = r7.userDefName
            r2.setText(r7)
        L_0x0090:
            android.os.Bundle r7 = r8.getExtras()
            java.lang.String r8 = "simpleap"
            java.lang.String r7 = r7.getString(r8)
            r6.autoConnectSsid = r7
            android.content.Context r7 = r6.getApplicationContext()
            java.lang.String r8 = "PrintSetting"
            java.lang.String r2 = "RE_SEARCH"
            epson.common.Utils.savePref((android.content.Context) r7, (java.lang.String) r8, (java.lang.String) r2, (boolean) r1)
            r6.undoFlag = r0
            r6.mPrinterSelectDone = r1
            r6.mWaiteInkReplenProgress = r1
            android.content.Context r7 = r6.getApplicationContext()
            java.lang.String r8 = r6.printerId
            boolean r7 = epson.print.inkrpln.InkReplnHelper.isSimpleApOrP2p(r7, r8)
            if (r7 != 0) goto L_0x00d2
            epson.print.inkrpln.PrintSettingDependencyBuilder r7 = new epson.print.inkrpln.PrintSettingDependencyBuilder
            java.lang.String r1 = r6.printerId
            java.lang.String r2 = r6.printerIp
            java.lang.String r3 = r6.printerSerialNo
            int r4 = r6.printerLocation
            java.lang.String r5 = r6.printerDeviceId
            r0 = r7
            r0.<init>(r1, r2, r3, r4, r5)
            android.content.Intent r7 = epson.print.inkrpln.InkRplnProgressDialog.getStartIntent2(r6, r7)
            r8 = 4
            r6.startActivityForResult(r7, r8)
            goto L_0x00fc
        L_0x00d2:
            r6.endInkReplAndGoProbePrinter()
            goto L_0x00fc
        L_0x00d6:
            r6.bindEpsonService()
            epson.print.EPPrinterManager r7 = new epson.print.EPPrinterManager
            r7.<init>(r6)
            int r8 = r6.printerLocation
            switch(r8) {
                case 2: goto L_0x00ed;
                case 3: goto L_0x00e4;
                default: goto L_0x00e3;
            }
        L_0x00e3:
            goto L_0x00f6
        L_0x00e4:
            java.lang.String r8 = r6.printerId
            epson.print.EPPrinterInfo r7 = r7.loadIpPrinterInfo(r8)
            if (r7 != 0) goto L_0x00f6
            goto L_0x00f7
        L_0x00ed:
            java.lang.String r8 = r6.printerEmailAddress
            epson.print.EPPrinterInfo r7 = r7.loadRemotePrinterInfo(r8)
            if (r7 != 0) goto L_0x00f6
            goto L_0x00f7
        L_0x00f6:
            r1 = 0
        L_0x00f7:
            if (r1 == 0) goto L_0x00fc
            r6.resetSettings()
        L_0x00fc:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.ui.CameraPrintSettingActivity.onPrinterSelectEnd(int, android.content.Intent):void");
    }

    private void endInkReplAndGoProbePrinter() {
        mWaiteInkReplenProgress = false;
        bindEpsonService();
        mHandler.sendEmptyMessageDelayed(17, 100);
    }

    private void updateSettingView() {
        boolean z = isDocumentSetting;
        setVisibilityPageRange(false);
        int[] iArr = color_info;
        if (iArr == null) {
            ((ImageView) findViewById(R.id.color_next_screen_imv)).setVisibility(8);
        } else if (iArr.length <= 1) {
            ((ImageView) findViewById(R.id.color_next_screen_imv)).setVisibility(8);
        } else {
            ((ImageView) findViewById(R.id.color_next_screen_imv)).setVisibility(0);
        }
        int[] iArr2 = duplex_info;
        findViewById(R.id.duplex_view).setVisibility(8);
        ((LinearLayout) findViewById(R.id.duplex)).setVisibility(8);
        switch (this.lang) {
            case 2:
            case 3:
                findViewById(R.id.feed_direction_view).setVisibility(0);
                findViewById(R.id.feed_direction).setVisibility(0);
                break;
            default:
                findViewById(R.id.feed_direction_view).setVisibility(8);
                findViewById(R.id.feed_direction).setVisibility(8);
                break;
        }
        if (!this.isDocumentSetting) {
            int i = printerLocation;
        }
        findViewById(R.id.printdate).setVisibility(8);
    }

    private int getPrinterLang() {
        int i;
        IEpsonService iEpsonService;
        if (!(this.printerLocation == 2 || (iEpsonService = mEpsonService) == null)) {
            try {
                i = iEpsonService.getLang();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            EPLog.m305d(TAG, "getPrinterLang called : ret = " + i);
            return i;
        }
        i = 1;
        EPLog.m305d(TAG, "getPrinterLang called : ret = " + i);
        return i;
    }

    private void setVisibilityPageRange(boolean z) {
        int i = 0;
        findViewById(R.id.page_range_setting).setVisibility(z ? 0 : 8);
        View findViewById = findViewById(R.id.page_range_separator);
        if (!z) {
            i = 8;
        }
        findViewById.setVisibility(i);
    }

    private void setClickablePageRange(boolean z) {
        findViewById(R.id.page_range_setting).setClickable(z);
        int i = 0;
        findViewById(R.id.page_range_next_screen_imv).setVisibility(z ? 0 : 8);
        View findViewById = findViewById(R.id.page_range_value);
        if (!z) {
            i = 8;
        }
        findViewById.setVisibility(i);
    }

    private void resetSettings() {
        printerDeviceId = null;
        printerId = null;
        printerEmailAddress = null;
        printerIp = null;
        printerLocation = 0;
        info = null;
        paper_source_info = null;
        color_info = null;
        paper_size_info = null;
        paper_type_info = null;
        layout_info = null;
        quality_info = null;
        duplex_info = null;
        autoConnectSsid = "";
        printerName.setText(getString(R.string.str_lbl_title_scan));
        ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setVisibility(8);
        updateSettingView();
        setScreenState(true);
    }

    public void onBackPressed() {
        super.onBackPressed();
        IEpsonService iEpsonService = mEpsonService;
        if (iEpsonService != null) {
            try {
                iEpsonService.cancelSearchPrinter();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
        loadSupportedMediaFile();
        EPPrinterManager ePPrinterManager = new EPPrinterManager(mContext);
        ePPrinterManager.rollbackRemotePrinterInfo();
        ePPrinterManager.rollbackIPPrinterInfo();
        new InkRplnRepository(false).deleteTemporaryData(this);
    }

    private void setScreenState(Boolean bool) {
        if (bool.booleanValue()) {
            progressGetOption.setVisibility(8);
        } else {
            progressGetOption.setVisibility(0);
        }
        findViewById(R.id.printer).setClickable(bool.booleanValue());
        findViewById(R.id.paper_size).setClickable(bool.booleanValue());
        findViewById(R.id.paper_type).setClickable(bool.booleanValue());
        findViewById(R.id.layout).setClickable(bool.booleanValue());
        findViewById(R.id.quality).setClickable(bool.booleanValue());
        findViewById(R.id.paper_source).setClickable(bool.booleanValue());
        findViewById(R.id.color).setClickable(bool.booleanValue());
        findViewById(R.id.duplex).setClickable(bool.booleanValue());
        findViewById(R.id.feed_direction).setClickable(bool.booleanValue());
        findViewById(R.id.printdate).setClickable(bool.booleanValue());
    }

    public void showErrorDialog(String str, String str2) {
        new CustomTitleAlertDialogBuilder(this).setCancelable(false).setTitle(str).setMessage(str2).setNegativeButton(getString(R.string.ok_button), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                CameraPrintSettingActivity.this.setScreenState(true);
                dialogInterface.cancel();
            }
        }).create().show();
        updateSupportedMediaFile(true);
    }

    protected void onResume() {
        super.onResume();
        EPLog.m307e("SettingScr", "onResume()");
        if (this.printerId != null && printerLocation == 1 && isRetryAfterConnectSimpleAp) {
            undoFlag = false;
            if (loadSupportedMediaFile()) {
                mHandler.sendEmptyMessage(1);
            } else {
                mHandler.sendEmptyMessage(17);
            }
        }
    }

    protected void onPause() {
        EPLog.m305d("SettingScr", "onPause");
        super.onPause();
        if (isFinishing()) {
            deleteLongTapMessage();
        }
        WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, printerIp);
        WiFiDirectManager.disconnectSimpleAP(this, autoConnectSsid, printerIp);
    }

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

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != R.id.menuSettingsDone) {
            return super.onOptionsItemSelected(menuItem);
        }
        saveChanged();
        setResult(3, getIntent());
        finish();
        return true;
    }

    protected void deleteLongTapMessage() {
        MotionEvent obtain = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis() + 10, 1, 0.0f, 0.0f, 0);
        copiesMinus.dispatchTouchEvent(obtain);
        copiesPlus.dispatchTouchEvent(obtain);
    }

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