PrintPreviewActivity.java 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. package com.epson.cameracopy.p006ui;
  2. import android.app.AlertDialog;
  3. import android.arch.lifecycle.Observer;
  4. import android.arch.lifecycle.ViewModelProviders;
  5. import android.content.ComponentName;
  6. import android.content.DialogInterface;
  7. import android.content.Intent;
  8. import android.content.IntentFilter;
  9. import android.content.ServiceConnection;
  10. import android.content.SharedPreferences;
  11. import android.content.res.Configuration;
  12. import android.graphics.PointF;
  13. import android.os.AsyncTask;
  14. import android.os.Bundle;
  15. import android.os.Handler;
  16. import android.os.IBinder;
  17. import android.os.Message;
  18. import android.os.RemoteException;
  19. import android.support.p000v4.app.DialogFragment;
  20. import android.support.p000v4.app.FragmentActivity;
  21. import android.view.KeyEvent;
  22. import android.view.Menu;
  23. import android.view.MenuItem;
  24. import android.view.View;
  25. import android.widget.Button;
  26. import android.widget.ImageButton;
  27. import android.widget.ImageView;
  28. import android.widget.TextView;
  29. import android.widget.Toast;
  30. import com.epson.cameracopy.printlayout.ImageAndLayout;
  31. import com.epson.cameracopy.printlayout.ManuscriptSize;
  32. import com.epson.cameracopy.printlayout.PreviewView;
  33. import com.epson.mobilephone.common.ReviewInvitationDialog;
  34. import com.epson.mobilephone.common.ReviewInvitationViewModel;
  35. import com.epson.mobilephone.common.escpr.MediaInfo;
  36. import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
  37. import epson.common.Constants;
  38. import epson.common.DialogProgress;
  39. import epson.common.DialogProgressViewModel;
  40. import epson.common.ExternalFileUtils;
  41. import epson.print.ActivityIACommon;
  42. import epson.print.ActivityNfcPrinter;
  43. import epson.print.CommonDefine;
  44. import epson.print.EPImage;
  45. import epson.print.EPImageList;
  46. import epson.print.MyPrinter;
  47. import epson.print.Util.AsyncTaskExecutor;
  48. import epson.print.Util.EPLog;
  49. import epson.print.screen.PaperSourceInfo;
  50. import epson.print.screen.PaperSourceSetting;
  51. import epson.print.screen.PaperSourceSettingScr;
  52. import epson.print.screen.PrintSetting;
  53. import epson.print.service.EpsonService;
  54. import epson.print.service.IEpsonService;
  55. import epson.print.service.IEpsonServiceCallback;
  56. import java.util.ArrayList;
  57. import java.util.Deque;
  58. import java.util.Locale;
  59. /* renamed from: com.epson.cameracopy.ui.PrintPreviewActivity */
  60. public class PrintPreviewActivity extends ActivityIACommon implements CommonDefine, View.OnClickListener, PreviewView.PrttargetScaleChangeListener, ReviewInvitationDialog.OnClickListener {
  61. static final /* synthetic */ boolean $assertionsDisabled = false;
  62. private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
  63. private static final String DIALOG_PROGRESS = "dialog_progress";
  64. private static final String KEY_PREVIEW_VIEW = "preview-view";
  65. private static final int MESSAGE_MANUSCRIPT_SCALE_TEXT_UPDATE = 8;
  66. public static final String PARAM_DISPLAY_SIZE_SET_MESSAGE = "display-sizeset-message";
  67. public static final String PARAM_IMAGE_LIST = "imageList";
  68. private static final int REQUEST_CODE_NFC_PRINTER_CHANGE = 4;
  69. private static final int REQUEST_CODE_ORG_PAPER_SIZE_SELECT = 3;
  70. private static final int REQUEST_CODE_PRINT = 1;
  71. private static final int REQUEST_CODE_SETTING = 2;
  72. private final int LOAD_ALL_IMAGE = 3;
  73. private final int OUT_OF_MEMORY_ERROR = 7;
  74. private final int PREVIEW_LOAD_DIALOG_DISMISS = 1;
  75. private final int PREVIEW_LOAD_DIALOG_SHOW = 0;
  76. private final PrintSetting.Kind PRINT_MODE_CAMERACOPY = PrintSetting.Kind.cameracopy;
  77. private final int START_PRINT = 5;
  78. private final int ZOOM_CONTROL = 2;
  79. private ArrayList<PaperSourceSetting> aPaperSourceSetting;
  80. boolean bAutoStartPrint = false;
  81. private Button backButton = null;
  82. private int currentColor = 0;
  83. private int currentLayout = 2;
  84. private int currentPaperSize = 0;
  85. private String currentPrinterName = "";
  86. private boolean enableShowWarning = true;
  87. private final IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
  88. public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
  89. }
  90. public void onGetInkState() throws RemoteException {
  91. }
  92. public void onGetStatusState() throws RemoteException {
  93. }
  94. public void onNotifyContinueable(int i) throws RemoteException {
  95. }
  96. public void onNotifyEndJob(int i) throws RemoteException {
  97. }
  98. public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
  99. }
  100. public void onNotifyProgress(int i, int i2) throws RemoteException {
  101. }
  102. };
  103. private final ServiceConnection mEpsonConnection = new ServiceConnection() {
  104. public void onServiceDisconnected(ComponentName componentName) {
  105. try {
  106. PrintPreviewActivity.mEpsonService.unregisterCallback(PrintPreviewActivity.mCallback);
  107. } catch (RemoteException e) {
  108. e.printStackTrace();
  109. }
  110. IEpsonService unused = PrintPreviewActivity.mEpsonService = null;
  111. }
  112. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  113. IEpsonService unused = PrintPreviewActivity.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
  114. if (PrintPreviewActivity.mEpsonService != null) {
  115. try {
  116. PrintPreviewActivity.mEpsonService.registerCallback(PrintPreviewActivity.mCallback);
  117. } catch (RemoteException e) {
  118. e.printStackTrace();
  119. }
  120. }
  121. }
  122. };
  123. private IEpsonService mEpsonService = null;
  124. Handler mHandler = new Handler(new Handler.Callback() {
  125. static final /* synthetic */ boolean $assertionsDisabled = false;
  126. static {
  127. Class<PrintPreviewActivity> cls = PrintPreviewActivity.class;
  128. }
  129. public boolean handleMessage(Message message) {
  130. int i = message.what;
  131. if (i == 3) {
  132. PrintPreviewActivity.this.startLoadtask();
  133. } else if (i == 5) {
  134. PrintPreviewActivity.this.disablePrintButton();
  135. PrintPreviewActivity.this.startPrint();
  136. } else if (i != 100) {
  137. switch (i) {
  138. case 0:
  139. PrintPreviewActivity.this.showProgressDialog();
  140. break;
  141. case 1:
  142. PrintPreviewActivity.this.dismissProgressDialog();
  143. break;
  144. default:
  145. switch (i) {
  146. case 7:
  147. if (PrintPreviewActivity.mImageList.size() <= 0) {
  148. PrintPreviewActivity.this.disablePrintButton();
  149. }
  150. PrintPreviewActivity printPreviewActivity = PrintPreviewActivity.this;
  151. Toast.makeText(printPreviewActivity, printPreviewActivity.getString(R.string.file_size_notsupport), 1).show();
  152. break;
  153. case 8:
  154. PrintPreviewActivity.this.updateManuscriptScaleText(((Double) message.obj).doubleValue());
  155. return true;
  156. }
  157. }
  158. } else {
  159. PrintPreviewActivity.this.updatePaperDisplay(message);
  160. }
  161. return true;
  162. }
  163. });
  164. private final EPImageList mImageList = new EPImageList();
  165. private boolean mIsRemotePrinter = false;
  166. ManuscriptSize mManuscriptSize;
  167. private DialogProgressViewModel mModelDialog;
  168. private Button mOriginalImageSizeButton;
  169. private PreviewView mPreviewView = null;
  170. int mPrintTargetPaperSizeId = -2;
  171. private TextView mPrintTargetSizeText;
  172. private ReviewInvitationViewModel mReviewInvitationViewModel;
  173. private TextView mScaleText;
  174. private ImageView paperMissmath = null;
  175. PaperSourceInfo paperSourceInfo = null;
  176. private TextView papersizeTextView = null;
  177. private Button printButton = null;
  178. private String printerId = "";
  179. private ImageButton printsettingButton = null;
  180. private AllReloadTask reloadTask = null;
  181. private Button rotateButton = null;
  182. protected void onCreate(Bundle bundle) {
  183. super.onCreate(bundle);
  184. setContentView((int) R.layout.activity_camera_print_preview);
  185. mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
  186. mModelDialog.getDialogJob().observe(this, new Observer() {
  187. public final void onChanged(Object obj) {
  188. PrintPreviewActivity.lambda$onCreate$0(PrintPreviewActivity.this, (Deque) obj);
  189. }
  190. });
  191. mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
  192. mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
  193. public void onChanged(@Nullable Boolean bool) {
  194. if (bool.booleanValue()) {
  195. PrintPreviewActivity.this.showStoreDialog();
  196. }
  197. }
  198. });
  199. setActionBar((int) R.string.print_title, true);
  200. ExternalFileUtils.getInstance(this).initPrintDir();
  201. getImageListFromIntent();
  202. EPImageList ePImageList = mImageList;
  203. if (ePImageList == null || ePImageList.size() != 1) {
  204. finish();
  205. return;
  206. }
  207. mPreviewView = (PreviewView) findViewById(R.id.previewImageView);
  208. this.papersizeTextView = (TextView) findViewById(R.id.paper_size_text);
  209. this.papersizeTextView.setOnClickListener(this);
  210. mPrintTargetSizeText = (TextView) findViewById(R.id.printtarget_size_text);
  211. mPrintTargetSizeText.setOnClickListener(this);
  212. mScaleText = (TextView) findViewById(R.id.scale_text);
  213. mScaleText.setOnClickListener(this);
  214. this.paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
  215. this.paperMissmath.setOnClickListener(this);
  216. mOriginalImageSizeButton = (Button) findViewById(R.id.paper_size_button);
  217. mOriginalImageSizeButton.setOnClickListener(new View.OnClickListener() {
  218. public void onClick(View view) {
  219. PrintPreviewActivity.this.startOrgImageSizeActivity();
  220. }
  221. });
  222. this.rotateButton = (Button) findViewById(R.id.rotate_button);
  223. this.rotateButton.setOnClickListener(this);
  224. this.printButton = (Button) findViewById(R.id.print_button);
  225. this.printButton.setOnClickListener(this);
  226. mPreviewView.setImage(mImageList.get(0).loadImageFileName);
  227. loadPrinterSettingAndChangeView(true);
  228. updateManuscriptScaleText(1.0d);
  229. mPreviewView.setPrttargetScaleChangeListener(this);
  230. this.enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true);
  231. this.paperSourceInfo = PaperSourceInfo.getInstance(this);
  232. if (mEpsonService == null) {
  233. bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
  234. }
  235. if (bundle == null) {
  236. mHandler.sendEmptyMessageDelayed(3, 300);
  237. checkSizeSetMessage();
  238. }
  239. }
  240. public static /* synthetic */ void lambda$onCreate$0(PrintPreviewActivity printPreviewActivity, Deque deque) {
  241. String[] checkQueue = printPreviewActivity.mModelDialog.checkQueue();
  242. if (checkQueue != null) {
  243. String str = checkQueue[0];
  244. String str2 = checkQueue[1];
  245. if (str2.equals("do_show")) {
  246. printPreviewActivity.showDialog(str);
  247. }
  248. if (str2.equals("do_dismiss")) {
  249. printPreviewActivity.dismissDialog(str);
  250. }
  251. }
  252. }
  253. private void showStoreDialog() {
  254. ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
  255. }
  256. private void checkSizeSetMessage() {
  257. Intent intent = getIntent();
  258. if (intent != null && intent.getBooleanExtra(PARAM_DISPLAY_SIZE_SET_MESSAGE, false)) {
  259. Toast makeText = Toast.makeText(this, getString(R.string.manuscript_size_set_message), 1);
  260. makeText.setGravity(8, 0, 0);
  261. makeText.show();
  262. }
  263. }
  264. protected void startOrgImageSizeActivity() {
  265. startActivityForResult(new Intent(this, DocumentSizeSettingActivity.class), 3);
  266. }
  267. private void getImageListFromIntent() {
  268. mImageList.clear();
  269. Intent intent = getIntent();
  270. if (intent == null) {
  271. finish();
  272. return;
  273. }
  274. ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra("imageList");
  275. if (stringArrayListExtra == null) {
  276. finish();
  277. return;
  278. }
  279. for (int i = 0; i < stringArrayListExtra.size(); i++) {
  280. mImageList.add(stringArrayListExtra.get(i));
  281. }
  282. for (int i2 = 0; i2 < mImageList.size(); i2++) {
  283. if (!checkEPImage(mImageList.get(i2))) {
  284. mImageList.clear();
  285. finish();
  286. return;
  287. }
  288. }
  289. }
  290. private boolean checkEPImage(EPImage ePImage) {
  291. return ePImage != null && ePImage.srcWidth > 0 && ePImage.srcHeight > 0;
  292. }
  293. private void updateParaSizeText() {
  294. String string = getString(new MediaInfo.PaperSize().getStringId(this.currentPaperSize));
  295. TextView textView = this.papersizeTextView;
  296. textView.setText(getString(R.string.paper_size) + ": " + string);
  297. }
  298. private boolean updateManuscriptSize() {
  299. ManuscriptSize manuscriptSize = mManuscriptSize;
  300. mManuscriptSize = ManuscriptSize.load(this, mImageList.get(0).loadImageFileName);
  301. boolean z = manuscriptSize == null || !manuscriptSize.equals(mManuscriptSize);
  302. if (mManuscriptSize.displayLength()) {
  303. PointF documentSize = mManuscriptSize.getDocumentSize(this);
  304. mPrintTargetSizeText.setText(String.format(Locale.US, mManuscriptSize.getUnitType(this) == 2 ? "%s: %s (%.1f x %.1f %s)" : "%s: %s (%.0f x %.0f %s)", new Object[]{getString(R.string.document_size), mManuscriptSize.getSizeName(this), Float.valueOf(documentSize.x), Float.valueOf(documentSize.y), mManuscriptSize.getUnitStr(this)}));
  305. } else {
  306. mPrintTargetSizeText.setText(String.format(Locale.US, "%s: %s", new Object[]{getString(R.string.document_size), mManuscriptSize.getSizeName(this)}));
  307. }
  308. return z;
  309. }
  310. private void updateManuscriptScaleText(double d) {
  311. PointF physicalSize = mManuscriptSize.getPhysicalSize(this);
  312. mScaleText.setText(String.format(Locale.US, mManuscriptSize.getUnitType(this) == 2 ? "%s: %.0f%% (%.1f x %.1f %s)" : "%s: %.0f%% (%.0f x %.0f %s)", new Object[]{getString(R.string.magnification), Double.valueOf(100.0d * d), Double.valueOf(((double) physicalSize.x) * d), Double.valueOf(((double) physicalSize.y) * d), mManuscriptSize.getUnitStr(this)}));
  313. }
  314. private void loadPrinterSettingAndChangeView(boolean z) {
  315. boolean z2;
  316. boolean z3;
  317. PreviewView previewView;
  318. boolean isRemotePrinter = isRemotePrinter();
  319. boolean z4 = false;
  320. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  321. if (sharedPreferences != null) {
  322. String string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  323. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
  324. printSetting.loadSettings();
  325. this.printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  326. boolean z5 = true;
  327. if (z || mIsRemotePrinter != isRemotePrinter) {
  328. mIsRemotePrinter = isRemotePrinter;
  329. z3 = true;
  330. z2 = true;
  331. } else {
  332. z3 = false;
  333. z2 = false;
  334. }
  335. if (z || !this.currentPrinterName.equalsIgnoreCase(string)) {
  336. this.currentPrinterName = string;
  337. z3 = true;
  338. z2 = true;
  339. }
  340. if (z || this.currentPaperSize != printSetting.paperSizeValue) {
  341. this.currentPaperSize = printSetting.paperSizeValue;
  342. PreviewView previewView2 = mPreviewView;
  343. if (previewView2 != null) {
  344. previewView2.setPaperSize(this.currentPaperSize);
  345. }
  346. z3 = true;
  347. z2 = true;
  348. }
  349. if (z || this.currentLayout != printSetting.layoutValue) {
  350. this.currentLayout = printSetting.layoutValue;
  351. if (mPreviewView != null) {
  352. if (this.currentLayout == 1) {
  353. z4 = true;
  354. }
  355. mPreviewView.setBorderless(z4);
  356. }
  357. z3 = true;
  358. z2 = true;
  359. }
  360. if (z || this.currentColor != printSetting.colorValue) {
  361. this.currentColor = printSetting.colorValue;
  362. PreviewView previewView3 = mPreviewView;
  363. if (previewView3 != null) {
  364. previewView3.setColor(this.currentColor);
  365. }
  366. } else {
  367. z5 = z2;
  368. }
  369. if (z3) {
  370. updateManuscriptSize();
  371. PreviewView previewView4 = mPreviewView;
  372. if (previewView4 != null) {
  373. previewView4.printPostionResetRequest();
  374. mPreviewView.setPrintTargetSize(mManuscriptSize.getPixelWidth(), mManuscriptSize.getPixelHeight());
  375. mPreviewView.update();
  376. }
  377. updateParaSizeText();
  378. } else if (z5 && (previewView = mPreviewView) != null) {
  379. previewView.update();
  380. }
  381. } else if (mIsRemotePrinter != isRemotePrinter) {
  382. mIsRemotePrinter = isRemotePrinter;
  383. }
  384. }
  385. private void enablePrintButton() {
  386. this.printButton.setEnabled(true);
  387. }
  388. private void disablePrintButton() {
  389. this.printButton.setEnabled(false);
  390. }
  391. /* JADX WARNING: Code restructure failed: missing block: B:6:0x0014, code lost:
  392. r0 = (r0 = getSharedPreferences("PrintSetting", 0)).getString(epson.common.Constants.PRINTER_NAME, getString(epson.print.R.string.str_lbl_title_scan));
  393. */
  394. /* Code decompiled incorrectly, please refer to instructions dump. */
  395. private boolean isPrinterChanged() {
  396. /*
  397. r5 = this;
  398. boolean r0 = r5.isRemotePrinter()
  399. boolean r1 = r5.mIsRemotePrinter
  400. r2 = 1
  401. if (r1 == r0) goto L_0x000a
  402. return r2
  403. L_0x000a:
  404. java.lang.String r0 = "PrintSetting"
  405. r1 = 0
  406. android.content.SharedPreferences r0 = r5.getSharedPreferences(r0, r1)
  407. if (r0 != 0) goto L_0x0014
  408. return r2
  409. L_0x0014:
  410. java.lang.String r3 = "PRINTER_NAME"
  411. r4 = 2131625174(0x7f0e04d6, float:1.8877549E38)
  412. java.lang.String r4 = r5.getString(r4)
  413. java.lang.String r0 = r0.getString(r3, r4)
  414. if (r0 != 0) goto L_0x0024
  415. return r2
  416. L_0x0024:
  417. java.lang.String r3 = r5.currentPrinterName
  418. boolean r0 = r3.equalsIgnoreCase(r0)
  419. if (r0 != 0) goto L_0x002d
  420. return r2
  421. L_0x002d:
  422. return r1
  423. */
  424. throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.p006ui.PrintPreviewActivity.isPrinterChanged():boolean");
  425. }
  426. protected void onActivityResult(int i, int i2, Intent intent) {
  427. super.onActivityResult(i, i2, intent);
  428. switch (i) {
  429. case 1:
  430. enablePrintButton();
  431. ExternalFileUtils.getInstance(this).initPrintDir();
  432. mReviewInvitationViewModel.onPrintEnd(CameraPrintProgress.isPrintSuccess(i2));
  433. return;
  434. case 2:
  435. if (i2 == 3) {
  436. enablePrintButton();
  437. if (isPrinterChanged()) {
  438. this.aPaperSourceSetting = null;
  439. setPaperSizeDisplayForNoPapaerInfoPrinter();
  440. startLoadtask();
  441. return;
  442. }
  443. loadPrinterSettingAndChangeView(false);
  444. return;
  445. }
  446. return;
  447. case 3:
  448. if (updateManuscriptSize()) {
  449. mPreviewView.setPrintTargetSize(mManuscriptSize.getPixelWidth(), mManuscriptSize.getPixelHeight());
  450. mPreviewView.update();
  451. return;
  452. }
  453. return;
  454. case 4:
  455. if (i2 == -1) {
  456. this.aPaperSourceSetting = null;
  457. setPaperSizeDisplayForNoPapaerInfoPrinter();
  458. this.bAutoStartPrint = true;
  459. startLoadtask();
  460. return;
  461. }
  462. return;
  463. default:
  464. return;
  465. }
  466. }
  467. protected void onRestart() {
  468. super.onRestart();
  469. PreviewView previewView = mPreviewView;
  470. if (previewView != null) {
  471. previewView.restoreBitmap();
  472. }
  473. }
  474. protected void onResume() {
  475. super.onResume();
  476. NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
  477. this.paperMissmath.setVisibility(4);
  478. this.paperSourceInfo.start(this, mHandler);
  479. }
  480. protected void onNewIntent(Intent intent) {
  481. NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
  482. super.onNewIntent(intent);
  483. String action = intent.getAction();
  484. AllReloadTask allReloadTask = this.reloadTask;
  485. if (allReloadTask != null && allReloadTask.getStatus() == AsyncTask.Status.FINISHED && "android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
  486. Intent intent2 = new Intent();
  487. intent2.setClass(this, ActivityNfcPrinter.class);
  488. intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
  489. intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
  490. startActivityForResult(intent2, 4);
  491. }
  492. }
  493. protected void onDestroy() {
  494. EPLog.m316v("ActivityImageViewSelect", "onDestroy");
  495. super.onDestroy();
  496. IEpsonService iEpsonService = mEpsonService;
  497. if (iEpsonService != null) {
  498. try {
  499. iEpsonService.cancelSearchPrinter();
  500. mEpsonService.unregisterCallback(mCallback);
  501. unbindService(mEpsonConnection);
  502. } catch (RemoteException e) {
  503. e.printStackTrace();
  504. }
  505. }
  506. }
  507. protected void onPause() {
  508. EPLog.m305d("ActivityImageViewSelect", "onPause");
  509. super.onPause();
  510. if (isFinishing()) {
  511. AllReloadTask allReloadTask = this.reloadTask;
  512. if (allReloadTask != null) {
  513. allReloadTask.cancel(false);
  514. }
  515. dismissProgressDialog();
  516. mHandler.removeMessages(3);
  517. mHandler.removeMessages(5);
  518. mHandler.removeMessages(0);
  519. mHandler.removeMessages(1);
  520. mHandler.removeMessages(100);
  521. mHandler.removeMessages(8);
  522. mPreviewView.setPrttargetScaleChangeListener((PreviewView.PrttargetScaleChangeListener) null);
  523. mPreviewView = null;
  524. }
  525. NfcTagUtils.disableForegroundDispatch(this);
  526. this.paperSourceInfo.stop();
  527. }
  528. protected void onStop() {
  529. if (isFinishing()) {
  530. new PrintSetting(this, PrintSetting.Kind.cameracopy).resetPrintSettings();
  531. }
  532. super.onStop();
  533. }
  534. private void check3GAndStartPrint() {
  535. mHandler.sendEmptyMessage(5);
  536. }
  537. private void startLoadtask() {
  538. this.reloadTask = new AllReloadTask();
  539. this.reloadTask.executeOnExecutor(new Void[0]);
  540. }
  541. private void showProgressDialog() {
  542. mModelDialog.doShow(DIALOG_PROGRESS);
  543. }
  544. private void dismissProgressDialog() {
  545. mModelDialog.doDismiss(DIALOG_PROGRESS);
  546. }
  547. private void startPrint() {
  548. ExternalFileUtils.getInstance(this).initPrintDir();
  549. ImageAndLayout imageAndLayout = mPreviewView.getImageAndLayout();
  550. imageAndLayout.setOrgFileName(mImageList.get(0).loadImageFileName);
  551. ArrayList arrayList = new ArrayList();
  552. arrayList.add(imageAndLayout);
  553. Intent intent = new Intent(this, CameraPrintProgress.class);
  554. intent.putExtra(CameraPrintProgress.KEY_IMAGE_AND_LAYOUT, arrayList);
  555. startActivityForResult(intent, 1);
  556. }
  557. private void updatePaperDisplay(Message message) {
  558. this.aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
  559. if (this.aPaperSourceSetting != null) {
  560. this.papersizeTextView.setTextColor(getResources().getColor(R.color.epson_blue));
  561. mPrintTargetSizeText.setTextColor(getResources().getColor(R.color.epson_blue));
  562. mScaleText.setTextColor(getResources().getColor(R.color.epson_blue));
  563. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
  564. printSetting.loadSettings();
  565. if (this.paperSourceInfo.checkPaperMissmatch(printSetting, this.aPaperSourceSetting)) {
  566. this.paperMissmath.setVisibility(0);
  567. } else {
  568. this.paperMissmath.setVisibility(4);
  569. }
  570. } else {
  571. setPaperSizeDisplayForNoPapaerInfoPrinter();
  572. }
  573. }
  574. private void setPaperSizeDisplayForNoPapaerInfoPrinter() {
  575. this.papersizeTextView.setTextColor(getResources().getColor(R.color.all_black));
  576. mPrintTargetSizeText.setTextColor(getResources().getColor(R.color.all_black));
  577. mScaleText.setTextColor(getResources().getColor(R.color.all_black));
  578. this.paperMissmath.setVisibility(4);
  579. }
  580. private boolean isRemotePrinter() {
  581. return MyPrinter.isRemotePrinter(this);
  582. }
  583. private void showDialog(String str) {
  584. DialogProgress newInstance = DialogProgress.newInstance(str, 0, getString(R.string.str_load));
  585. newInstance.setCancelable(false);
  586. newInstance.show(getSupportFragmentManager(), str);
  587. }
  588. private void dismissDialog(String str) {
  589. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
  590. if (dialogFragment != null) {
  591. dialogFragment.dismiss();
  592. }
  593. }
  594. public void onClick(View view) {
  595. switch (view.getId()) {
  596. case R.id.icon_papermissmatch /*2131231117*/:
  597. case R.id.paper_size_text /*2131231310*/:
  598. case R.id.printtarget_size_text /*2131231374*/:
  599. if (this.aPaperSourceSetting != null) {
  600. Intent intent = new Intent();
  601. intent.setClass(this, PaperSourceSettingScr.class);
  602. intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, this.aPaperSourceSetting);
  603. intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.cameracopy.name());
  604. startActivityForResult(intent, 2);
  605. return;
  606. }
  607. callPrintSetting();
  608. return;
  609. case R.id.print_button /*2131231336*/:
  610. mIsRemotePrinter = isRemotePrinter();
  611. if (mIsRemotePrinter && this.enableShowWarning) {
  612. AlertDialog.Builder cancelable = new AlertDialog.Builder(this).setCancelable(false);
  613. 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() {
  614. public void onClick(DialogInterface dialogInterface, int i) {
  615. PrintPreviewActivity.this.check3GAndStartPrint();
  616. }
  617. }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
  618. public void onClick(DialogInterface dialogInterface, int i) {
  619. }
  620. }).show();
  621. return;
  622. } else if (this.currentPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
  623. new AlertDialog.Builder(this).setCancelable(false).setTitle(R.string.printer_notselect_title).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  624. public void onClick(DialogInterface dialogInterface, int i) {
  625. }
  626. }).show();
  627. return;
  628. } else {
  629. check3GAndStartPrint();
  630. return;
  631. }
  632. case R.id.rotate_button /*2131231420*/:
  633. mPreviewView.rotateImageR90();
  634. mPreviewView.update();
  635. return;
  636. default:
  637. return;
  638. }
  639. }
  640. public boolean onOptionsItemSelected(MenuItem menuItem) {
  641. if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) {
  642. callPrintSetting();
  643. }
  644. return super.onOptionsItemSelected(menuItem);
  645. }
  646. public boolean onCreateOptionsMenu(Menu menu) {
  647. super.onCreateOptionsMenu(menu);
  648. getMenuInflater().inflate(R.C2138menu.print_menu, menu);
  649. return true;
  650. }
  651. private void setPreferencesDocumentMode() {
  652. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  653. edit.putInt(Constants.SOURCE_TYPE, 1);
  654. edit.commit();
  655. }
  656. public void callPrintSetting() {
  657. System.gc();
  658. Intent intent = new Intent(this, CameraPrintSettingActivity.class);
  659. intent.setAction("android.intent.action.VIEW");
  660. startActivityForResult(intent, 2);
  661. }
  662. public boolean onKeyDown(int i, KeyEvent keyEvent) {
  663. if (keyEvent.getAction() == 0 && i == 84) {
  664. EPLog.m307e("key search", "diable");
  665. return true;
  666. } else if (keyEvent.getAction() != 0 || i != 4) {
  667. return false;
  668. } else {
  669. onBackPressed();
  670. return true;
  671. }
  672. }
  673. public void onConfigurationChanged(Configuration configuration) {
  674. super.onConfigurationChanged(configuration);
  675. }
  676. protected void onRestoreInstanceState(Bundle bundle) {
  677. super.onRestoreInstanceState(bundle);
  678. mPreviewView.restoreInstanceState(bundle, KEY_PREVIEW_VIEW);
  679. }
  680. protected void onSaveInstanceState(Bundle bundle) {
  681. mPreviewView.saveInstanceState(bundle, KEY_PREVIEW_VIEW);
  682. super.onSaveInstanceState(bundle);
  683. }
  684. public void onPrttargetScaleChange(double d) {
  685. mHandler.sendMessage(mHandler.obtainMessage(8, Double.valueOf(d)));
  686. }
  687. public void invitationDialogClicked(boolean z) {
  688. mReviewInvitationViewModel.setStartStoreEnd();
  689. }
  690. /* renamed from: com.epson.cameracopy.ui.PrintPreviewActivity$AllReloadTask */
  691. public class AllReloadTask extends AsyncTaskExecutor<Void, Integer, Boolean> {
  692. public AllReloadTask() {
  693. }
  694. protected void onPreExecute() {
  695. PrintPreviewActivity.this.showProgressDialog();
  696. }
  697. protected Boolean doInBackground(Void... voidArr) {
  698. System.gc();
  699. int i = 0;
  700. do {
  701. try {
  702. if (PrintPreviewActivity.mEpsonService != null) {
  703. break;
  704. } else if (isCancelled()) {
  705. return false;
  706. } else {
  707. Thread.sleep(100);
  708. i++;
  709. }
  710. } catch (RemoteException e) {
  711. e.printStackTrace();
  712. } catch (InterruptedException e2) {
  713. e2.printStackTrace();
  714. }
  715. } while (i < 100);
  716. if (isCancelled()) {
  717. return false;
  718. }
  719. if (PrintPreviewActivity.mEpsonService != null) {
  720. if (PrintPreviewActivity.this.isRemotePrinter()) {
  721. PrintPreviewActivity.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.cameracopy.name());
  722. } else {
  723. PrintPreviewActivity.mEpsonService.updatePrinterSettings(PrintSetting.Kind.cameracopy.name());
  724. }
  725. }
  726. return true;
  727. }
  728. protected void onPostExecute(Boolean bool) {
  729. PrintPreviewActivity.this.loadPrinterSettingAndChangeView(false);
  730. PrintPreviewActivity.this.dismissProgressDialog();
  731. if (PrintPreviewActivity.this.bAutoStartPrint) {
  732. PrintPreviewActivity printPreviewActivity = PrintPreviewActivity.this;
  733. printPreviewActivity.onClick(printPreviewActivity.printButton);
  734. PrintPreviewActivity.this.bAutoStartPrint = false;
  735. }
  736. }
  737. }
  738. }