PrintPreviewActivity.java 31 KB

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