package epson.print.copy; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import epson.common.Constants; import epson.print.ActivityIACommon; import epson.print.CommonDefine; import epson.print.R; import epson.print.Util.EPLog; import epson.print.copy.Component.ecopycomponent.ECopyComponent; import epson.print.copy.Component.ecopycomponent.ECopyOptionContext; import epson.print.copy.Component.ecopycomponent.ECopyOptionItem; import epson.print.copy.Component.eremoteoperation.ERemoteOperation; import epson.print.screen.WorkingDialog; import epson.print.widgets.CustomTitleAlertDialogBuilder; class ActivityBase extends ActivityIACommon { static final String Title = "Title"; static String printerId; static String printerIp; static final HashMap strings = new HashMap<>(); private String TAG = "ActivityBase"; ECopyComponent copyComponent = ECopyComponent.sharedComponent(); ECopyComponent.ECopyType copyType = ECopyComponent.ECopyType.Standard; boolean isKeepSimpleAPConnection = false; boolean isTryConnectSimpleAp = false; WorkingDialog loading; ECopyOptionContext optionContext; HashMap optionValueMap = new HashMap<>(); public interface CancelRequestCallback { void onCancelRequest(); } enum ClickButton { Ok, Cancel, ClearError } enum DialogButtons { Ok, Cancel, ClearErrorCancel } interface IClose { void onClose(ClickButton clickButton); } interface INextPageClose { void onClose(ECopyComponent.ICopyResumeRequest.ResumeState resumeState); } interface OptionItemChangedListener { void onOptionItemChanged(ECopyOptionItem eCopyOptionItem); } private void buildCopyOptions(ArrayList arrayList) { } ActivityBase() { } class WheelDialog extends Dialog { Button cancelButton; CancelRequestCallback cancelCallback; Dialog cancelDialog; TextView messageText = ((TextView) findViewById(R.id.messageText)); private Dialog createCancelDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setMessage(getString(R.string.str_msg_scan_cancel)); builder.setCancelable(false); builder.setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { cancelButton.setEnabled(false); cancelCallback.onCancelRequest(); dialogInterface.cancel(); } }); builder.setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { cancelButton.setEnabled(true); dialogInterface.cancel(); } }); return builder.create(); } public WheelDialog(Context context) { super(context, R.style.AppTheme_Translucent_Gray); setContentView(R.layout.wheel_dialog); setCancelable(false); } private void show(String str, CancelRequestCallback cancelRequestCallback) { cancelCallback = cancelRequestCallback; messageText.setText(str); messageText.setVisibility(0); cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { WheelDialog wheelDialog = WheelDialog.this; wheelDialog.cancelDialog = wheelDialog.createCancelDialog(); cancelDialog.show(); } }); cancelButton.setVisibility(0); show(); } private void setText(String str) { messageText.setText(str); } private void hideCancelButton() { cancelButton.setVisibility(4); } private void dissmiss() { super.dismiss(); Dialog dialog = cancelDialog; if (dialog != null) { dialog.dismiss(); } } } public void onCreate(Bundle bundle) { super.onCreate(bundle); loading = new WorkingDialog(this); DisplayUtil.setMap(this, strings); } public class errorDialog { public static final int MESSAGE = 1; public static final int TITLE = 0; Context context; Dialog dialog; public errorDialog(Context context2) { context = context2; } private void showErrorDialog(String str, String str2) { showErrorDialog(str, str2, DialogButtons.Ok, (IClose) null); } private void showErrorDialog(int i) { showErrorDialog((String) null, getString(i)); } private void showErrorDialog(String str, String str2, final DialogButtons dialogButtons, final IClose iClose) { String str3; CustomTitleAlertDialogBuilder customTitleAlertDialogBuilder = new CustomTitleAlertDialogBuilder(context); String str4 = null; switch (dialogButtons) { case Ok: str4 = getString(R.string.str_ok); str3 = null; break; case Cancel: str3 = getString(R.string.str_cancel); break; case ClearErrorCancel: str4 = getString(R.string.str_continue); str3 = getString(R.string.str_cancel); break; default: str3 = null; break; } if (str != null) { customTitleAlertDialogBuilder.setTitle(str); } customTitleAlertDialogBuilder.setMessage(str2); customTitleAlertDialogBuilder.setCancelable(false); if (str4 != null) { customTitleAlertDialogBuilder.setPositiveButton(str4, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); IClose iClose = iClose; if (iClose != null) { iClose.onClose(dialogButtons == DialogButtons.Ok ? ClickButton.Ok : ClickButton.ClearError); } } }); } if (str3 != null) { customTitleAlertDialogBuilder.setNegativeButton(str3, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); IClose iClose = iClose; if (iClose != null) { iClose.onClose(ClickButton.Cancel); } } }); } dialog = customTitleAlertDialogBuilder.create(); dialog.show(); } private void Cancel() { Dialog dialog2 = dialog; if (dialog2 != null) { dialog2.cancel(); } } public String[] getReasonText(ECopyComponent.ICopyStatusListener.CopyTaskResult copyTaskResult) { String[] strArr = new String[2]; switch (copyTaskResult) { case ErrorCommunication: strArr[0] = getString(R.string.EPS_PRNERR_COMM_TITLE); strArr[1] = getString(R.string.CopyCommErrorText); break; case Busy: strArr[0] = getString(R.string.EPS_PRNST_BUSY_TITLE); strArr[1] = getString(R.string.EPS_PRNST_BUSY_MSG); break; case RemoveAdfPaper: strArr[0] = getString(R.string.CopyTaskResultRemoveAdfPaperTitle); strArr[1] = getString(R.string.CopyTaskResultRemoveAdfPaper); break; case ErrorOther: strArr[0] = getString(R.string.EPS_PRNERR_GENERAL_ERR); strArr[1] = getString(R.string.CopyTaskResultErrorOtherText); break; } return strArr; } public String[] getReasonText(ECopyComponent.ICopyOptionContextListener.ContextCreationError contextCreationError) { String[] strArr = new String[2]; switch (contextCreationError) { case ErrorCommunication: strArr[0] = getString(R.string.EPS_PRNERR_COMM_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_COMM5); break; case ErrorNotCopySupported: case Error: strArr[0] = getString(R.string.EPS_PRNERR_GENERAL_ERR); strArr[1] = getString(R.string.CopyTaskResultErrorOtherText); break; } return strArr; } public String[] getReasonText(ECopyComponent.ICopyOptionListener.CopyOptionChangedError copyOptionChangedError) { String[] strArr = new String[2]; switch (copyOptionChangedError) { case ErrorCommunication: strArr[0] = getString(R.string.EPS_PRNERR_COMM_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_COMM5); break; case ErrorInvalidOption: case Error: strArr[0] = getString(R.string.EPS_PRNERR_GENERAL_ERR); strArr[1] = getString(R.string.CopyTaskResultErrorOtherText); break; } return strArr; } public String[] getReasonText(ECopyComponent.ICopyResumeRequest.StopReason stopReason) { String[] strArr = new String[2]; switch (stopReason) { case PrinterMarkerSupplyEmptyError: strArr[0] = getString(R.string.EPS_PRNERR_INKOUT_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_INKOUT_MSG); break; case PrinterMarkerWasteFullError: strArr[0] = getString(R.string.EPS_PRNERR_WEB_REMOTE_MAINTENANCE_BOX_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_WEB_REMOTE_MAINTENANCE_BOX_MSG); break; case PrinterMediaJamError: strArr[0] = getString(R.string.EPS_PRNERR_PAPERJAM_TITLE); strArr[1] = getString(R.string.CopyPaperJamErrorText); break; case PrinterMediaEmptyError: strArr[0] = getString(R.string.EPS_PRNERR_PAPEROUT_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_PAPEROUT_MSG); break; case ManualfeedGuide: strArr[0] = getString(R.string.EPS_PRNERR_MANUALFEED_SET_PAPER_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_MANUALFEED_SET_PAPER_MSG); break; case PrinterCoverOpenError: strArr[0] = getString(R.string.EPS_PRNERR_COVEROPEN_TITLE); strArr[1] = getString(R.string.EPS_PRNERR_COVEROPEN_MSG); break; case PrinterOutputAreaFullError: strArr[0] = getString(R.string.EPS_PRNERR_CDRGUIDEOPEN_TITLE); strArr[1] = getString(R.string.CopyCDdiscErrorText); break; case PrinterOtherError: strArr[0] = getString(R.string.EPS_PRNERR_GENERAL_ERR); strArr[1] = getString(R.string.CopyTaskResultErrorOtherText); break; case ScannerOtherError: strArr[0] = getString(R.string.str_err_msg_scan_generic_internal_title); strArr[1] = getString(R.string.str_err_msg_scan_generic_internal); break; } return strArr; } } private void showNextPageDialog(final INextPageClose iNextPageClose) { C21591 r0 = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { ECopyComponent.ICopyResumeRequest.ResumeState resumeState; dialogInterface.cancel(); if (i == -1) { resumeState = ECopyComponent.ICopyResumeRequest.ResumeState.NextPageReady; } else if (i == -3) { resumeState = ECopyComponent.ICopyResumeRequest.ResumeState.NextPageNotExist; } else { resumeState = ECopyComponent.ICopyResumeRequest.ResumeState.Cancel; } iNextPageClose.onClose(resumeState); } }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.waiting_2nd_page); builder.setCancelable(true); builder.setPositiveButton(getString(R.string.next_page_ready), r0); builder.setNeutralButton(R.string.next_page_not_exist, r0); builder.setNegativeButton(getString(R.string.str_cancel), r0); builder.create().show(); } abstract class OptionValue { OptionItemChangedListener changedListener; ECopyOptionItem optionItem; OptionValue() { } private void setOptionValueChangedListener(OptionItemChangedListener optionItemChangedListener) { changedListener = optionItemChangedListener; } private String getChoiceString(ECopyOptionItem.ECopyOptionItemChoice eCopyOptionItemChoice) { return string(eCopyOptionItemChoice.name()); } } class ListOptionValue extends OptionValue { List choices; ECopyOptionItem.ECopyOptionItemChoice selected; ListOptionValue() { super(); } private void bindOption(ECopyOptionItem eCopyOptionItem) { optionItem = eCopyOptionItem; choices = eCopyOptionItem.getSelectableChoices(); selected = eCopyOptionItem.getSelectedChoice(); } private String[] getKeyArray() { String[] strArr = new String[this.choices.size()]; for (int i = 0; i < choices.size(); i++) { strArr[i] = string(choices.get(i).name()); } return strArr; } } class NumberOptionValue extends OptionValue { Button countDown; Button countUp; TextView editText; int value; NumberOptionValue() { super(); } private void updateWithAddition(int i) { try { value = Integer.valueOf(editText.getText().toString()).intValue(); value = Math.min(Math.max(optionItem.getMinimumValue(), value + i), optionItem.getMaximumValue()); optionItem.selectValue(value); if (changedListener != null) { changedListener.onOptionItemChanged(optionItem); } } catch (NumberFormatException unused) { } } class Counter implements View.OnClickListener { int amount; public Counter(int i) { amount = i; } public void onClick(View view) { updateWithAddition(amount); } } private void bindOption(ECopyOptionItem eCopyOptionItem) { optionItem = eCopyOptionItem; value = eCopyOptionItem.getSelectedValue(); } private void bindOption(int i, ECopyOptionItem eCopyOptionItem) { optionItem = eCopyOptionItem; editText = (TextView) findViewById(i); value = eCopyOptionItem.getSelectedValue(); editText.setText(String.valueOf(value)); editText.setEnabled(eCopyOptionItem.isEnabled()); } private void bindCountUp(int i) { countUp = (Button) findViewById(i); countUp.setOnClickListener(new Counter(1)); if (value == optionItem.getMaximumValue()) { countUp.setEnabled(false); } else { countUp.setEnabled(true); } } private void bindCountDown(int i) { countDown = (Button) findViewById(i); countDown.setOnClickListener(new Counter(-1)); if (value == optionItem.getMinimumValue()) { countDown.setEnabled(false); } else { countDown.setEnabled(true); } } } class CopyMagnificationValue extends NumberOptionValue { public CopyMagnificationValue(ECopyOptionItem eCopyOptionItem) { super(); bindOption(eCopyOptionItem); } } private String string(String str) { return (String) (strings.containsKey(str) ? strings.get(str) : strings.get("Unknown")); } class settingPreference { SharedPreferences.Editor editer; SharedPreferences presettings; settingPreference() { } private String loadPrePrinter() { presettings = getSharedPreferences(CommonDefine.PREFS_INFO_COPY, 0); return presettings.getString(Constants.PRINTER_ID, (String) null); } private void savePrePrinter() { presettings = getSharedPreferences(CommonDefine.PREFS_INFO_COPY, 0); editer = presettings.edit(); editer.putString(Constants.PRINTER_ID, ActivityBase.printerId); editer.commit(); } private void setCopyOptions(ArrayList arrayList) { ECopyOptionContext bindedCopyOptionContext = copyComponent.getBindedCopyOptionContext(); Iterator it = arrayList.iterator(); while (it.hasNext()) { ECopyOptionItem next = it.next(); ECopyOptionItem.ECopyOptionItemKey key = next.getKey(); if (!key.equals(ECopyOptionItem.ECopyOptionItemKey.Copies)) { setOption(key, next); bindedCopyOptionContext.replace(next); } } Iterator it2 = arrayList.iterator(); while (it2.hasNext()) { copyComponent.setCopyOptionItem(it2.next()); } } private void setOption(ECopyOptionItem.ECopyOptionItemKey eCopyOptionItemKey, ECopyOptionItem eCopyOptionItem) { presettings = getSharedPreferences(CommonDefine.PREFS_INFO_COPY, 0); if (eCopyOptionItem.getChoiceType() == ECopyOptionItem.ECopyOptionItemChoiceType.ChoiceArray) { eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.valueOf(eCopyOptionItemKey, ERemoteOperation.ERemoteParam.stringOf(presettings.getString(eCopyOptionItemKey.name(), eCopyOptionItem.getDefaultChoice().getParam().toString())))); return; } eCopyOptionItem.selectValue(presettings.getInt(eCopyOptionItemKey.name(), eCopyOptionItem.getDefaultValue())); if (eCopyOptionItemKey.equals(ECopyOptionItem.ECopyOptionItemKey.CopyMagnification)) { optionValueMap.put(eCopyOptionItemKey, new CopyMagnificationValue(eCopyOptionItem)); } } private void saveCopyOptions(ArrayList arrayList) { savePrePrinter(); Iterator it = arrayList.iterator(); while (it.hasNext()) { ECopyOptionItem next = it.next(); ECopyOptionItem.ECopyOptionItemKey key = next.getKey(); if (!key.equals(ECopyOptionItem.ECopyOptionItemKey.Copies)) { saveOption(key, next); } } } private void saveOption(ECopyOptionItem.ECopyOptionItemKey eCopyOptionItemKey, ECopyOptionItem eCopyOptionItem) { presettings = getSharedPreferences(CommonDefine.PREFS_INFO_COPY, 0); if (eCopyOptionItem.getChoiceType() == ECopyOptionItem.ECopyOptionItemChoiceType.ChoiceArray) { String access$000 = TAG; EPLog.i(access$000, "cursetting:" + eCopyOptionItem.getSelectedChoice().name()); editer = presettings.edit(); editer.putString(eCopyOptionItemKey.name(), eCopyOptionItem.getSelectedChoice().getParam().toString()); editer.commit(); return; } String access$0002 = TAG; EPLog.i(access$0002, "cursetting:" + String.valueOf(eCopyOptionItem.getSelectedValue())); editer = presettings.edit(); editer.putInt(eCopyOptionItemKey.name(), eCopyOptionItem.getSelectedValue()); editer.commit(); } } }