package epson.print; import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import android.view.Display; 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.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import com.epson.iprint.prtlogger.PrintLog; import com.epson.mobilephone.common.escpr.MediaInfo; import com.epson.mobilephone.common.wifidirect.NfcTagUtils; import org.opencv.videoio.Videoio; import java.util.ArrayList; import epson.common.Constants; import epson.common.ExternalFileUtils; import epson.common.Info_paper; import epson.print.Util.AsyncTaskExecutor; import epson.print.Util.EPLog; import epson.print.Util.Photo; import epson.print.screen.PaperSourceInfo; import epson.print.screen.PaperSourceSetting; import epson.print.screen.PaperSourceSettingScr; import epson.print.screen.PrintProgress; import epson.print.screen.PrintSetting; import epson.print.screen.SettingScr; import epson.print.screen.WorkingDialog; import epson.print.service.EpsonService; import epson.print.service.IEpsonService; import epson.print.service.IEpsonServiceCallback; public class ActivityPrintWeb extends ActivityIACommon implements CommonDefine, View.OnClickListener, ReviewInvitationDialog.OnClickListener { private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog"; public static final String PARAMS_KEY_WEB_PRINT_LOG = "print_log"; public static final String PREFS_NAME = "PrintSetting"; public static final boolean REFRESH = false; private static final String TAG = "ActivityPrintWeb"; private final int ERROR_IMAGE_CODE = 1; private final int ERROR_PRINT_SETTING = 2; private final int INIT = 5; private final int REDRAW_PREVIEW = 6; private RelativeLayout.LayoutParams Relative_para; private final int START_PRINT = 4; private ArrayList aPaperSourceSetting; private ArrayList addImageView = new ArrayList<>(); boolean bAutoStartPrint = false; /* renamed from: bm */ private Bitmap f334bm = null; private boolean enableShowWarning = true; private String fileName2User; private int fromActivity = 2; private EPImageList imageList = new EPImageList(); private boolean isCustomAction = false; private boolean isRemotePrinter = false; private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() { public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException { } public void onGetInkState() throws RemoteException { } public void onGetStatusState() throws RemoteException { } public void onNotifyContinueable(int i) throws RemoteException { } public void onNotifyEndJob(int i) throws RemoteException { } public void onNotifyError(int i, int i2, boolean z) throws RemoteException { } public void onNotifyProgress(int i, int i2) throws RemoteException { } }; private int mColorMode; private Context mContext = null; private int mCurrentPage; private Display mDisplay; private int mEndPage; private ServiceConnection mEpsonConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName componentName) { try { ActivityPrintWeb.mEpsonService.unregisterCallback(ActivityPrintWeb.mCallback); } catch (RemoteException e) { e.printStackTrace(); } IEpsonService unused = ActivityPrintWeb.mEpsonService = null; } public void onServiceConnected(ComponentName componentName, IBinder iBinder) { IEpsonService unused = ActivityPrintWeb.mEpsonService = IEpsonService.Stub.asInterface(iBinder); if (ActivityPrintWeb.mEpsonService != null) { try { ActivityPrintWeb.mEpsonService.registerCallback(ActivityPrintWeb.mCallback); } catch (RemoteException e) { e.printStackTrace(); } } } }; private IEpsonService mEpsonService = null; private int mFileTotalPages; private ImageView mImageView; private boolean mIsPortrait; private int mLayout; private int mLayoutMulti; private LinearLayout mLn_zoomview; private float mMoveX; private Button mNext; private TextView mPageNum; private Info_paper mPaperSize; private Button mPre; private boolean mPreviewPaperAreaLandscape; private Button mPrint; private EPImageList mPrintImageList; private PrintLog mPrintLog; private ReviewInvitationViewModel mReviewInvitationViewModel; private RelativeLayout mRl_zoomview; private TextView mSizeInfo; private int mStartPage; private float mStartX; Handler mUiHandler = new Handler() { public void handleMessage(Message message) { int i = message.what; if (i != 100) { switch (i) { case 1: Toast.makeText(ActivityPrintWeb.mContext, getString(R.string.str_err_msg_out_of_memory_title), 1).show(); return; case 2: Toast.makeText(ActivityPrintWeb.mContext, getString(R.string.EPS_PRNERR_COMM_TITLE3), 1).show(); return; default: switch (i) { case 4: ActivityPrintWeb.mPrint.setEnabled(false); SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0); printWeb.clear(); EPImageList ePImageList = new EPImageList(); for (int access$1400 = ActivityPrintWeb.mStartPage; access$1400 <= ActivityPrintWeb.mEndPage; access$1400++) { int i2 = access$1400 - 1; EPImage ePImage = imageList.get(i2); ePImage.previewPaperRectLeft = ActivityPrintWeb.mLn_zoomview.getLeft() + ActivityPrintWeb.mLn_zoomview.getPaddingLeft(); ePImage.previewPaperRectTop = ActivityPrintWeb.mLn_zoomview.getTop() + ActivityPrintWeb.mLn_zoomview.getPaddingTop(); ePImage.previewPaperRectRight = ActivityPrintWeb.mLn_zoomview.getRight() - ActivityPrintWeb.mLn_zoomview.getPaddingRight(); ePImage.previewPaperRectBottom = ActivityPrintWeb.mLn_zoomview.getBottom() - ActivityPrintWeb.mLn_zoomview.getPaddingBottom(); ePImage.previewImageRectLeft = (float) (ActivityPrintWeb.mLn_zoomview.getLeft() + ActivityPrintWeb.mImageView.getLeft()); ePImage.previewImageRectTop = (float) (ActivityPrintWeb.mLn_zoomview.getTop() + ActivityPrintWeb.mImageView.getTop()); ePImage.previewImageRectRight = (float) (ActivityPrintWeb.mLn_zoomview.getLeft() + ActivityPrintWeb.mImageView.getRight()); ePImage.previewImageRectBottom = (float) (ActivityPrintWeb.mLn_zoomview.getTop() + ActivityPrintWeb.mImageView.getBottom()); ePImage.previewWidth = (ePImage.previewImageRectRight - ePImage.previewImageRectLeft); ePImage.previewHeight = (ePImage.previewImageRectBottom - ePImage.previewImageRectTop); if (ePImage.previewPaperRectRight - ePImage.previewPaperRectLeft > ePImage.previewPaperRectBottom - ePImage.previewPaperRectTop) { ePImage.isPaperLandScape = true; } else { ePImage.isPaperLandScape = false; } ePImage.isPaperLandScape = ActivityPrintWeb.mPreviewPaperAreaLandscape; EPImage ePImage2 = imageList.get(i2); if (fromActivity == 1) { ePImage2.setType(4098); } else { ePImage2.setType(4097); } ePImageList.add(ePImage2); } sharedPreferences.edit(); if (isRemotePrinter) { SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit(); edit.putInt(Constants.SOURCE_TYPE, 3); edit.commit(); } EPImageList unused = ActivityPrintWeb.mPrintImageList = ePImageList; check3GAndStartPrint(); return; case 5: EPLog.v(ActivityPrintWeb.TAG, "INIT"); if (ActivityPrintWeb.mEpsonService == null) { sendEmptyMessageDelayed(5, 100); return; } else { new AsyncTaskExecutor() { WorkingDialog progress = new WorkingDialog(ActivityPrintWeb.this); protected void onPreExecute() { super.onPreExecute(); progress.show(); } protected Void doInBackground(Void... voidArr) { try { if (ActivityPrintWeb.mEpsonService == null) { return null; } if (isRemotePrinter) { ActivityPrintWeb.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.document.name()); return null; } ActivityPrintWeb.mEpsonService.updatePrinterSettings(PrintSetting.Kind.document.name()); return null; } catch (RemoteException e) { e.printStackTrace(); return null; } } protected void onPostExecute(Void voidR) { super.onPostExecute(voidR); setOrentationView(ActivityPrintWeb.mIsPortrait); ActivityPrintWeb.mLn_zoomview.setVisibility(View.VISIBLE); if (progress.isShowing()) { progress.dismiss(); } if (bAutoStartPrint) { onClick(ActivityPrintWeb.mPrint); EPLog.d(ActivityPrintWeb.TAG, "onClick(mPrint)"); bAutoStartPrint = false; } } }.executeOnExecutor(new Void[0]); return; } case 6: ActivityPrintWeb.mLn_zoomview.invalidate(); ActivityPrintWeb.mRl_zoomview.invalidate(); return; default: return; } } } else { ArrayList unused2 = aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO); if (aPaperSourceSetting != null) { ActivityPrintWeb.mSizeInfo.setBackgroundColor (getResources().getColor(R.color.epson_blue)); ActivityPrintWeb.mSizeInfo.setTextColor (getResources().getColor(R.color.all_white)); PrintSetting printSetting = new PrintSetting(ActivityPrintWeb.this, PrintSetting.Kind.document); printSetting.loadSettings(); if (paperSourceInfo.checkPaperMissmatch(printSetting, aPaperSourceSetting)) { paperMissmath.setVisibility(View.VISIBLE); } else { paperMissmath.setVisibility(View.GONE); } } else { ActivityPrintWeb.mSizeInfo.setBackground (getResources().getDrawable(R.drawable.text_view_boder)); ActivityPrintWeb.mSizeInfo.setTextColor (getResources().getColor(R.color.epson_blue)); paperMissmath.setVisibility(View.GONE); } } } }; private ImageView paperMissmath = null; private int paperSize; PaperSourceInfo paperSourceInfo = null; ArrayList printWeb = new ArrayList<>(); private String printerId; protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.print_web); mContext = this; setActionBar(R.string.web_btn_label, true); mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class); mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer() { public void onChanged(@Nullable Boolean bool) { if (bool.booleanValue()) { showStoreDialog(); } } }); Intent intent = getIntent(); if (intent == null) { EPLog.w(TAG, "intent == null"); finish(); return; } fromActivity = intent.getIntExtra("from", 2); addImageView = intent.getStringArrayListExtra("print_web"); if (addImageView == null) { EPLog.w(TAG, "intent.getStringArrayListExtra(\"print_web\") returns null. action " + intent.getAction()); finish(); return; } String stringExtra = intent.getStringExtra("print_url"); isCustomAction = intent.getBooleanExtra("from_customaction", false); try { mPrintLog = (PrintLog) intent.getSerializableExtra("print_log"); } catch (ClassCastException unused) { } for (int i = 0; i < addImageView.size(); i++) { EPImage ePImage = new EPImage(addImageView.get(i), i); ePImage.webUrl = stringExtra; imageList.add(ePImage); } mLn_zoomview = (LinearLayout) findViewById(R.id.ln_web_zoomview); mRl_zoomview = (RelativeLayout) findViewById(R.id.rl_web_zoomview); mPrint = (Button) findViewById(R.id.btn_web_print); mImageView = (ImageView) findViewById(R.id.web_zoomview); mIsPortrait = true; mSizeInfo = (TextView) findViewById(R.id.tv_web_page_size); mPrint.setOnClickListener(this); mSizeInfo.setOnClickListener(this); paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch); mPageNum = (TextView) findViewById(R.id.tv_page_num); mNext = (Button) findViewById(R.id.btn_web_next); mPre = (Button) findViewById(R.id.btn_web_pre); mFileTotalPages = addImageView.size(); updateButton(); mPre.setOnClickListener(this); mPre.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case 0: ActivityPrintWeb.mPre.setBackgroundResource(R.drawable.bt_left_hover); return false; case 1: ActivityPrintWeb.mPre.setBackgroundResource(R.drawable.bt_left); return false; default: return false; } } }); mNext.setOnClickListener(this); mNext.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case 0: ActivityPrintWeb.mNext.setBackgroundResource(R.drawable.bt_right_hover); return false; case 1: ActivityPrintWeb.mNext.setBackgroundResource(R.drawable.bt_right_1); return false; default: return false; } } }); savePageRange2Pre(); loadConfig(); mImageView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { Display defaultDisplay = getWindowManager().getDefaultDisplay(); Point point = new Point(); defaultDisplay.getSize(point); float f = (float) point.y; float f2 = (float) point.x; if (f > f2) { f = f2; } switch (motionEvent.getAction()) { case 0: float unused = ActivityPrintWeb.mStartX = motionEvent.getX(); float unused2 = ActivityPrintWeb.mMoveX = 0.0f; break; case 1: ActivityPrintWeb activityPrintWeb = ActivityPrintWeb.this; float unused3 = activityPrintWeb.mMoveX = activityPrintWeb.mStartX - motionEvent.getX(); break; } float f3 = f / 10.0f; if (ActivityPrintWeb.mMoveX > f3) { nextPage(); return true; } else if (ActivityPrintWeb.mMoveX >= f3 * -1.0f) { return true; } else { prevPage(); return true; } } }); int i2 = fromActivity; if (i2 == 1) { setTitle(getString(R.string.str_scan)); } else if (i2 != 4) { setTitle(getString(R.string.web_btn_label)); } else { setTitle(getString(R.string.network_storage_title)); } mPrint.setEnabled(true); mCurrentPage = 1; mLn_zoomview.setVisibility(View.GONE); updateTextView(); enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true); isRemotePrinter = MyPrinter.isRemotePrinter(this); paperSourceInfo = PaperSourceInfo.getInstance(this); if (mEpsonService == null) { bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1); mUiHandler.sendEmptyMessage(5); } } private void showStoreDialog() { ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG); } public void onClick(View view) { int id = view.getId(); if (id != R.id.tv_web_page_size) { switch (id) { case R.id.btn_web_next /*2131230880*/: nextPage(); return; case R.id.btn_web_pre /*2131230881*/: prevPage(); return; case R.id.btn_web_print /*2131230882*/: isRemotePrinter = MyPrinter.isRemotePrinter(this); if (isRemotePrinter && enableShowWarning) { AlertDialog.Builder cancelable = new AlertDialog.Builder(mContext).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) { ActivityPrintWeb.mUiHandler.sendEmptyMessage(4); } }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }).show(); return; } else if (fileName2User.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) { new AlertDialog.Builder(mContext).setCancelable(false).setTitle(R.string.printer_not_select).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }).show(); return; } else { mUiHandler.sendEmptyMessage(4); return; } default: return; } } else if (aPaperSourceSetting != null) { Intent intent = new Intent(); intent.setClass(this, PaperSourceSettingScr.class); intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.document.name()); intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, aPaperSourceSetting); startActivityForResult(intent, 6); } else { callPrintSetting(); } } private void nextPage() { int i = mCurrentPage; if (i < mFileTotalPages) { mCurrentPage = i + 1; setNewImageView(mCurrentPage - 1); updateTextView(); updateButton(); } } private void prevPage() { int i = mCurrentPage; if (1 < i) { mCurrentPage = i - 1; setNewImageView(mCurrentPage - 1); updateTextView(); updateButton(); } } private void updateButton() { int i = mFileTotalPages; if (i > 1) { if (mCurrentPage == i) { mNext.setVisibility(View.GONE); } else { mNext.setVisibility(View.VISIBLE); } int i2 = mCurrentPage; if (i2 == 1 || i2 == 0) { mPre.setVisibility(View.GONE); } else { mPre.setVisibility(View.VISIBLE); } } else { mNext.setVisibility(View.GONE); mPre.setVisibility(View.GONE); } } public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.print_menu, menu); return true; } public boolean onOptionsItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) { callPrintSetting(); } return super.onOptionsItemSelected(menuItem); } private void check3GAndStartPrint() { startPrint(); } private void startPrint() { if (mPrintLog == null) { mPrintLog = new PrintLog(); } PrintLog printLog = mPrintLog; printLog.previewType = 3; startActivityForResult(PrintProgress.getPrintIntent(this, mPrintImageList, true, false, printLog), 255); } public void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); setOrentationView(mIsPortrait); } public void setOrentationView(boolean z) { int i; int i2; try { loadConfig(); mDisplay = getWindowManager().getDefaultDisplay(); int paper_width = mPaperSize.getPaper_width(); int paper_height = mPaperSize.getPaper_height(); if (mLayoutMulti != 0) { int i3 = mLayoutMulti; if (i3 == 65536) { Rect paperSize_2in1 = mPaperSize.getPaperSize_2in1(); paper_height = paperSize_2in1.width(); paper_width = paperSize_2in1.height(); Rect printingArea_2in1 = mPaperSize.getPrintingArea_2in1(); i = printingArea_2in1.width(); i2 = printingArea_2in1.height(); } else if (i3 == 131072 || i3 == 262144) { Rect paperSize_4in1 = mPaperSize.getPaperSize_4in1(); paper_height = paperSize_4in1.width(); paper_width = paperSize_4in1.height(); Rect printingArea_4in1 = mPaperSize.getPrintingArea_4in1(); i = printingArea_4in1.width(); i2 = printingArea_4in1.height(); } else { i2 = 0; i = 0; int i4 = paper_height; paper_height = paper_width; paper_width = i4; } if (paper_height > paper_width) { int i5 = paper_height; paper_height = paper_width; paper_width = i5; int i6 = i; i = i2; i2 = i6; } } else if (paper_width > paper_height) { i2 = 0; i = 0; } else { i2 = 0; i = 0; int i7 = paper_height; paper_height = paper_width; paper_width = i7; } mPreviewPaperAreaLandscape = !z; Point point = new Point(); mDisplay.getSize(point); if (z) { int height = point.y - (mPrint.getHeight() * 4); double d = paper_width; double d2 = paper_height; int i8 = (((height) / d) * d2); if (i8 > (point.x * 4) / 5) { i8 = (point.x * 4) / 5; height = (((i8) / d2) * d); } Relative_para = new RelativeLayout.LayoutParams(i8, height); } else { int i9 = (point.x * 4) / 5; double d3 = paper_width; double d4 = paper_height; int i10 = (((i9) / d3) * d4); if (i10 > point.y - (mPrint.getHeight() * 4)) { i10 = point.y - (mPrint.getHeight() * 4); i9 = (((i10) / d4) * d3); } Relative_para = new RelativeLayout.LayoutParams(i9, i10); } Relative_para.addRule(13); mLn_zoomview.setLayoutParams(Relative_para); setNewImageView(0); mCurrentPage = 1; updateTextView(); updateButton(); if (mLayout == 2) { if (mLayoutMulti == 0) { if (z) { float f = ((float) Relative_para.width) / ((float) paper_height); mLn_zoomview.setPadding((((float) mPaperSize.getLeftMargin_border()) * f), (((float) mPaperSize.getTopMargin_border()) * f), (((float) mPaperSize.getRightMargin_border()) * f), (((float) mPaperSize.getBottomMargin_border()) * f)); } else { float f2 = ((float) Relative_para.width) / ((float) paper_width); mLn_zoomview.setPadding((((float) mPaperSize.getTopMargin_border()) * f2), (((float) mPaperSize.getRightMargin_border()) * f2), (((float) mPaperSize.getBottomMargin_border()) * f2), (((float) mPaperSize.getLeftMargin_border()) * f2)); } } else if (z) { float f3 = ((float) Relative_para.width) / ((float) paper_height); int i11 = paper_height - i; int i12 = paper_width - i2; mLn_zoomview.setPadding((((float) (i11 / 2)) * f3), (((float) (i12 / 2)) * f3), (((float) (i11 / 2)) * f3), (((float) (i12 / 2)) * f3)); } else { float f4 = ((float) Relative_para.width) / ((float) paper_width); int i13 = paper_width - i2; int i14 = paper_height - i; mLn_zoomview.setPadding((((float) (i13 / 2)) * f4), (((float) (i14 / 2)) * f4), (((float) (i13 / 2)) * f4), (((float) (i14 / 2)) * f4)); } } mUiHandler.sendEmptyMessageDelayed(6, 200); } catch (Exception e) { e.printStackTrace(); finish(); } } private void setNewImageView(int i) { EPLog.i("Current page :", String.valueOf(i)); try { f334bm = Photo.createBitmapWithUri(addImageView.get(i), 1024, Videoio.CAP_PVAPI, false); if (f334bm != null && mImageView != null) { if (mColorMode == 1) { f334bm = Photo.createBitmapWithUri(addImageView.get(i), 1024, Videoio.CAP_PVAPI, true); } mImageView.setImageBitmap(f334bm); System.gc(); } } catch (Exception e) { e.printStackTrace(); mUiHandler.sendEmptyMessage(1); } } public void callPrintSetting() { try { SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit(); edit.putInt(Constants.SOURCE_TYPE, 3); edit.commit(); Intent intent = new Intent(this, SettingScr.class); intent.putExtra(PrintProgress.PARAM_DOCUMENT_MODE, true); intent.putExtra("SHEETS", mFileTotalPages); intent.setAction("android.intent.action.VIEW"); SharedPreferences.Editor edit2 = getSharedPreferences("PrintSetting", 0).edit(); edit2.putInt(Constants.SOURCE_TYPE, 1); edit2.commit(); startActivityForResult(intent, 6); } catch (UnsatisfiedLinkError e) { e.printStackTrace(); mUiHandler.sendEmptyMessage(2); } } protected void onResume() { EPLog.v(TAG, "onResume()"); super.onResume(); NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null); paperMissmath.setVisibility(View.GONE); paperSourceInfo.start(this, mUiHandler); } protected void onPause() { super.onPause(); NfcTagUtils.disableForegroundDispatch(this); paperSourceInfo.stop(); } protected void onNewIntent(Intent intent) { NfcTagUtils.EpsonNfcConnectInfo parseNECTag; super.onNewIntent(intent); if ("android.nfc.action.NDEF_DISCOVERED".equals(intent.getAction()) && (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, 5); } } protected void onDestroy() { super.onDestroy(); IEpsonService iEpsonService = mEpsonService; if (iEpsonService != null) { try { iEpsonService.cancelSearchPrinter(); mEpsonService.unregisterCallback(mCallback); unbindService(mEpsonConnection); mEpsonService = null; } catch (RemoteException e) { e.printStackTrace(); } } } protected void onActivityResult(int i, int i2, Intent intent) { EPLog.v(TAG, "onActivityResult requestCode = " + i); if (i != 255) { switch (i) { case 5: if (i2 == -1) { isRemotePrinter = MyPrinter.isRemotePrinter(this); bAutoStartPrint = true; mUiHandler.sendEmptyMessage(5); return; } return; case 6: if (i2 == 3) { isRemotePrinter = MyPrinter.isRemotePrinter(this); setOrentationView(mIsPortrait); return; } return; default: return; } } else { EPLog.v(TAG, "onActivityResult resultCode = " + i2); if (i2 == 0) { EPLog.v(TAG, "finish print = RESULT_CANCELED"); if (isCustomAction) { setResult(0); finish(); return; } } else if (i2 != 4) { if (i2 == 1000) { EPLog.v(TAG, "finish print = RESULT_ERROR"); } mPrint.setEnabled(true); } EPLog.v(TAG, "finish print = END_PRINT"); mReviewInvitationViewModel.onPrintEnd(PrintProgress.isPrintSuccess(i2)); if (isCustomAction) { EPLog.v(TAG, "*****isCustomAction"); setResult(-1); finish(); return; } mPrint.setEnabled(true); } } private void loadConfig() { SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0); PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.document); printSetting.loadSettings(); paperSize = printSetting.paperSizeValue; mColorMode = printSetting.colorValue; mLayout = printSetting.layoutValue; mLayoutMulti = printSetting.layoutMultiPageValue; mPaperSize = Info_paper.getInfoPaper(this, paperSize); MediaInfo.PaperSize paperSize2 = new MediaInfo.PaperSize(); mSizeInfo.setText(getString(paperSize2.getStringId(paperSize))); paperSize2.destructor(); fileName2User = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan)); printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null); mStartPage = printSetting.startValue; mEndPage = printSetting.endValue; } public void updateTextView() { mPageNum.setText(mCurrentPage + CommonDefine.SLASH + mFileTotalPages); } public void savePageRange2Pre() { new PrintSetting(this, (PrintSetting.Kind) null).resetPageRange(1, mFileTotalPages); mStartPage = 1; mEndPage = mFileTotalPages; EPLog.i("OldStartPage", String.valueOf(mStartPage)); EPLog.i("OldEndPage", String.valueOf(mEndPage)); } public void onBackPressed() { super.onBackPressed(); ExternalFileUtils.getInstance(this).initTempViewDir(); if (isCustomAction) { setResult(0); } } public void invitationDialogClicked(boolean z) { mReviewInvitationViewModel.setStartStoreEnd(); } }