ActivityPrintWeb.java 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. package epson.print;
  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.Context;
  7. import android.content.DialogInterface;
  8. import android.content.Intent;
  9. import android.content.IntentFilter;
  10. import android.content.ServiceConnection;
  11. import android.content.SharedPreferences;
  12. import android.content.res.Configuration;
  13. import android.graphics.Bitmap;
  14. import android.graphics.Point;
  15. import android.graphics.Rect;
  16. import android.os.Bundle;
  17. import android.os.Handler;
  18. import android.os.IBinder;
  19. import android.os.Message;
  20. import android.os.RemoteException;
  21. import android.support.p000v4.app.FragmentActivity;
  22. import android.view.Display;
  23. import android.view.Menu;
  24. import android.view.MenuItem;
  25. import android.view.MotionEvent;
  26. import android.view.View;
  27. import android.widget.Button;
  28. import android.widget.ImageView;
  29. import android.widget.LinearLayout;
  30. import android.widget.RelativeLayout;
  31. import android.widget.TextView;
  32. import android.widget.Toast;
  33. import com.epson.iprint.prtlogger.PrintLog;
  34. import com.epson.mobilephone.common.ReviewInvitationDialog;
  35. import com.epson.mobilephone.common.ReviewInvitationViewModel;
  36. import com.epson.mobilephone.common.escpr.MediaInfo;
  37. import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
  38. import org.opencv.videoio.Videoio;
  39. import java.util.ArrayList;
  40. import epson.common.Constants;
  41. import epson.common.ExternalFileUtils;
  42. import epson.common.Info_paper;
  43. import epson.print.Util.AsyncTaskExecutor;
  44. import epson.print.Util.EPLog;
  45. import epson.print.Util.Photo;
  46. import epson.print.screen.PaperSourceInfo;
  47. import epson.print.screen.PaperSourceSetting;
  48. import epson.print.screen.PaperSourceSettingScr;
  49. import epson.print.screen.PrintProgress;
  50. import epson.print.screen.PrintSetting;
  51. import epson.print.screen.SettingScr;
  52. import epson.print.screen.WorkingDialog;
  53. import epson.print.service.EpsonService;
  54. import epson.print.service.IEpsonService;
  55. import epson.print.service.IEpsonServiceCallback;
  56. public class ActivityPrintWeb extends ActivityIACommon implements CommonDefine, View.OnClickListener, ReviewInvitationDialog.OnClickListener {
  57. private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
  58. public static final String PARAMS_KEY_WEB_PRINT_LOG = "print_log";
  59. public static final String PREFS_NAME = "PrintSetting";
  60. public static final boolean REFRESH = false;
  61. private static final String TAG = "ActivityPrintWeb";
  62. private final int ERROR_IMAGE_CODE = 1;
  63. private final int ERROR_PRINT_SETTING = 2;
  64. private final int INIT = 5;
  65. private final int REDRAW_PREVIEW = 6;
  66. private RelativeLayout.LayoutParams Relative_para;
  67. private final int START_PRINT = 4;
  68. private ArrayList<PaperSourceSetting> aPaperSourceSetting;
  69. private ArrayList<String> addImageView = new ArrayList<>();
  70. boolean bAutoStartPrint = false;
  71. /* renamed from: bm */
  72. private Bitmap f334bm = null;
  73. private boolean enableShowWarning = true;
  74. private String fileName2User;
  75. private int fromActivity = 2;
  76. private EPImageList imageList = new EPImageList();
  77. private boolean isCustomAction = false;
  78. private boolean isRemotePrinter = false;
  79. private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
  80. public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
  81. }
  82. public void onGetInkState() throws RemoteException {
  83. }
  84. public void onGetStatusState() throws RemoteException {
  85. }
  86. public void onNotifyContinueable(int i) throws RemoteException {
  87. }
  88. public void onNotifyEndJob(int i) throws RemoteException {
  89. }
  90. public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
  91. }
  92. public void onNotifyProgress(int i, int i2) throws RemoteException {
  93. }
  94. };
  95. private int mColorMode;
  96. private Context mContext = null;
  97. private int mCurrentPage;
  98. private Display mDisplay;
  99. private int mEndPage;
  100. private ServiceConnection mEpsonConnection = new ServiceConnection() {
  101. public void onServiceDisconnected(ComponentName componentName) {
  102. try {
  103. ActivityPrintWeb.mEpsonService.unregisterCallback(ActivityPrintWeb.mCallback);
  104. } catch (RemoteException e) {
  105. e.printStackTrace();
  106. }
  107. IEpsonService unused = ActivityPrintWeb.mEpsonService = null;
  108. }
  109. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  110. IEpsonService unused = ActivityPrintWeb.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
  111. if (ActivityPrintWeb.mEpsonService != null) {
  112. try {
  113. ActivityPrintWeb.mEpsonService.registerCallback(ActivityPrintWeb.mCallback);
  114. } catch (RemoteException e) {
  115. e.printStackTrace();
  116. }
  117. }
  118. }
  119. };
  120. private IEpsonService mEpsonService = null;
  121. private int mFileTotalPages;
  122. private ImageView mImageView;
  123. private boolean mIsPortrait;
  124. private int mLayout;
  125. private int mLayoutMulti;
  126. private LinearLayout mLn_zoomview;
  127. private float mMoveX;
  128. private Button mNext;
  129. private TextView mPageNum;
  130. private Info_paper mPaperSize;
  131. private Button mPre;
  132. private boolean mPreviewPaperAreaLandscape;
  133. private Button mPrint;
  134. private EPImageList mPrintImageList;
  135. private PrintLog mPrintLog;
  136. private ReviewInvitationViewModel mReviewInvitationViewModel;
  137. private RelativeLayout mRl_zoomview;
  138. private TextView mSizeInfo;
  139. private int mStartPage;
  140. private float mStartX;
  141. Handler mUiHandler = new Handler() {
  142. public void handleMessage(Message message) {
  143. int i = message.what;
  144. if (i != 100) {
  145. switch (i) {
  146. case 1:
  147. Toast.makeText(ActivityPrintWeb.mContext, ActivityPrintWeb.this.getString(R.string.str_err_msg_out_of_memory_title), 1).show();
  148. return;
  149. case 2:
  150. Toast.makeText(ActivityPrintWeb.mContext, ActivityPrintWeb.this.getString(R.string.EPS_PRNERR_COMM_TITLE3), 1).show();
  151. return;
  152. default:
  153. switch (i) {
  154. case 4:
  155. ActivityPrintWeb.mPrint.setEnabled(false);
  156. SharedPreferences sharedPreferences = ActivityPrintWeb.this.getSharedPreferences("PrintSetting", 0);
  157. ActivityPrintWeb.this.printWeb.clear();
  158. EPImageList ePImageList = new EPImageList();
  159. for (int access$1400 = ActivityPrintWeb.mStartPage; access$1400 <= ActivityPrintWeb.mEndPage; access$1400++) {
  160. int i2 = access$1400 - 1;
  161. EPImage ePImage = ActivityPrintWeb.this.imageList.get(i2);
  162. ePImage.previewPaperRectLeft = ActivityPrintWeb.mLn_zoomview.getLeft() + ActivityPrintWeb.mLn_zoomview.getPaddingLeft();
  163. ePImage.previewPaperRectTop = ActivityPrintWeb.mLn_zoomview.getTop() + ActivityPrintWeb.mLn_zoomview.getPaddingTop();
  164. ePImage.previewPaperRectRight = ActivityPrintWeb.mLn_zoomview.getRight() - ActivityPrintWeb.mLn_zoomview.getPaddingRight();
  165. ePImage.previewPaperRectBottom = ActivityPrintWeb.mLn_zoomview.getBottom() - ActivityPrintWeb.mLn_zoomview.getPaddingBottom();
  166. ePImage.previewImageRectLeft = (float) (ActivityPrintWeb.mLn_zoomview.getLeft() + ActivityPrintWeb.mImageView.getLeft());
  167. ePImage.previewImageRectTop = (float) (ActivityPrintWeb.mLn_zoomview.getTop() + ActivityPrintWeb.mImageView.getTop());
  168. ePImage.previewImageRectRight = (float) (ActivityPrintWeb.mLn_zoomview.getLeft() + ActivityPrintWeb.mImageView.getRight());
  169. ePImage.previewImageRectBottom = (float) (ActivityPrintWeb.mLn_zoomview.getTop() + ActivityPrintWeb.mImageView.getBottom());
  170. ePImage.previewWidth = (int) (ePImage.previewImageRectRight - ePImage.previewImageRectLeft);
  171. ePImage.previewHeight = (int) (ePImage.previewImageRectBottom - ePImage.previewImageRectTop);
  172. if (ePImage.previewPaperRectRight - ePImage.previewPaperRectLeft > ePImage.previewPaperRectBottom - ePImage.previewPaperRectTop) {
  173. ePImage.isPaperLandScape = true;
  174. } else {
  175. ePImage.isPaperLandScape = false;
  176. }
  177. ePImage.isPaperLandScape = ActivityPrintWeb.mPreviewPaperAreaLandscape;
  178. EPImage ePImage2 = ActivityPrintWeb.this.imageList.get(i2);
  179. if (ActivityPrintWeb.this.fromActivity == 1) {
  180. ePImage2.setType(4098);
  181. } else {
  182. ePImage2.setType(4097);
  183. }
  184. ePImageList.add(ePImage2);
  185. }
  186. sharedPreferences.edit();
  187. if (ActivityPrintWeb.this.isRemotePrinter) {
  188. SharedPreferences.Editor edit = ActivityPrintWeb.this.getSharedPreferences("PrintSetting", 0).edit();
  189. edit.putInt(Constants.SOURCE_TYPE, 3);
  190. edit.commit();
  191. }
  192. EPImageList unused = ActivityPrintWeb.mPrintImageList = ePImageList;
  193. ActivityPrintWeb.this.check3GAndStartPrint();
  194. return;
  195. case 5:
  196. EPLog.m316v(ActivityPrintWeb.TAG, "INIT");
  197. if (ActivityPrintWeb.mEpsonService == null) {
  198. sendEmptyMessageDelayed(5, 100);
  199. return;
  200. } else {
  201. new AsyncTaskExecutor<Void, Void, Void>() {
  202. WorkingDialog progress = new WorkingDialog(ActivityPrintWeb.this);
  203. protected void onPreExecute() {
  204. super.onPreExecute();
  205. progress.show();
  206. }
  207. protected Void doInBackground(Void... voidArr) {
  208. try {
  209. if (ActivityPrintWeb.mEpsonService == null) {
  210. return null;
  211. }
  212. if (ActivityPrintWeb.this.isRemotePrinter) {
  213. ActivityPrintWeb.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.document.name());
  214. return null;
  215. }
  216. ActivityPrintWeb.mEpsonService.updatePrinterSettings(PrintSetting.Kind.document.name());
  217. return null;
  218. } catch (RemoteException e) {
  219. e.printStackTrace();
  220. return null;
  221. }
  222. }
  223. protected void onPostExecute(Void voidR) {
  224. super.onPostExecute(voidR);
  225. ActivityPrintWeb.this.setOrentationView(ActivityPrintWeb.mIsPortrait);
  226. ActivityPrintWeb.mLn_zoomview.setVisibility(0);
  227. if (this.progress.isShowing()) {
  228. progress.dismiss();
  229. }
  230. if (ActivityPrintWeb.this.bAutoStartPrint) {
  231. ActivityPrintWeb.this.onClick(ActivityPrintWeb.mPrint);
  232. EPLog.m305d(ActivityPrintWeb.TAG, "onClick(mPrint)");
  233. ActivityPrintWeb.this.bAutoStartPrint = false;
  234. }
  235. }
  236. }.executeOnExecutor(new Void[0]);
  237. return;
  238. }
  239. case 6:
  240. ActivityPrintWeb.mLn_zoomview.invalidate();
  241. ActivityPrintWeb.mRl_zoomview.invalidate();
  242. return;
  243. default:
  244. return;
  245. }
  246. }
  247. } else {
  248. ArrayList unused2 = ActivityPrintWeb.this.aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
  249. if (ActivityPrintWeb.this.aPaperSourceSetting != null) {
  250. ActivityPrintWeb.mSizeInfo.setBackgroundColor(ActivityPrintWeb.this.getResources().getColor(R.color.epson_blue));
  251. ActivityPrintWeb.mSizeInfo.setTextColor(ActivityPrintWeb.this.getResources().getColor(R.color.all_white));
  252. PrintSetting printSetting = new PrintSetting(ActivityPrintWeb.this, PrintSetting.Kind.document);
  253. printSetting.loadSettings();
  254. if (ActivityPrintWeb.this.paperSourceInfo.checkPaperMissmatch(printSetting, ActivityPrintWeb.this.aPaperSourceSetting)) {
  255. ActivityPrintWeb.this.paperMissmath.setVisibility(0);
  256. } else {
  257. ActivityPrintWeb.this.paperMissmath.setVisibility(8);
  258. }
  259. } else {
  260. ActivityPrintWeb.mSizeInfo.setBackground(ActivityPrintWeb.this.getResources().getDrawable(R.C2136drawable.text_view_boder));
  261. ActivityPrintWeb.mSizeInfo.setTextColor(ActivityPrintWeb.this.getResources().getColor(R.color.epson_blue));
  262. ActivityPrintWeb.this.paperMissmath.setVisibility(8);
  263. }
  264. }
  265. }
  266. };
  267. private ImageView paperMissmath = null;
  268. private int paperSize;
  269. PaperSourceInfo paperSourceInfo = null;
  270. ArrayList<String> printWeb = new ArrayList<>();
  271. private String printerId;
  272. protected void onCreate(Bundle bundle) {
  273. super.onCreate(bundle);
  274. setContentView((int) R.layout.print_web);
  275. mContext = this;
  276. setActionBar((int) R.string.web_btn_label, true);
  277. mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
  278. mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
  279. public void onChanged(@Nullable Boolean bool) {
  280. if (bool.booleanValue()) {
  281. ActivityPrintWeb.this.showStoreDialog();
  282. }
  283. }
  284. });
  285. Intent intent = getIntent();
  286. if (intent == null) {
  287. EPLog.m318w(TAG, "intent == null");
  288. finish();
  289. return;
  290. }
  291. fromActivity = intent.getIntExtra("from", 2);
  292. addImageView = intent.getStringArrayListExtra("print_web");
  293. if (this.addImageView == null) {
  294. EPLog.m318w(TAG, "intent.getStringArrayListExtra(\"print_web\") returns null. action " + intent.getAction());
  295. finish();
  296. return;
  297. }
  298. String stringExtra = intent.getStringExtra("print_url");
  299. isCustomAction = intent.getBooleanExtra("from_customaction", false);
  300. try {
  301. mPrintLog = (PrintLog) intent.getSerializableExtra("print_log");
  302. } catch (ClassCastException unused) {
  303. }
  304. for (int i = 0; i < addImageView.size(); i++) {
  305. EPImage ePImage = new EPImage(this.addImageView.get(i), i);
  306. ePImage.webUrl = stringExtra;
  307. imageList.add(ePImage);
  308. }
  309. mLn_zoomview = (LinearLayout) findViewById(R.id.ln_web_zoomview);
  310. mRl_zoomview = (RelativeLayout) findViewById(R.id.rl_web_zoomview);
  311. mPrint = (Button) findViewById(R.id.btn_web_print);
  312. mImageView = (ImageView) findViewById(R.id.web_zoomview);
  313. mIsPortrait = true;
  314. mSizeInfo = (TextView) findViewById(R.id.tv_web_page_size);
  315. mPrint.setOnClickListener(this);
  316. mSizeInfo.setOnClickListener(this);
  317. paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
  318. mPageNum = (TextView) findViewById(R.id.tv_page_num);
  319. mNext = (Button) findViewById(R.id.btn_web_next);
  320. mPre = (Button) findViewById(R.id.btn_web_pre);
  321. mFileTotalPages = addImageView.size();
  322. updateButton();
  323. mPre.setOnClickListener(this);
  324. mPre.setOnTouchListener(new View.OnTouchListener() {
  325. public boolean onTouch(View view, MotionEvent motionEvent) {
  326. switch (motionEvent.getAction()) {
  327. case 0:
  328. ActivityPrintWeb.mPre.setBackgroundResource(R.C2136drawable.bt_left_hover);
  329. return false;
  330. case 1:
  331. ActivityPrintWeb.mPre.setBackgroundResource(R.C2136drawable.bt_left);
  332. return false;
  333. default:
  334. return false;
  335. }
  336. }
  337. });
  338. mNext.setOnClickListener(this);
  339. mNext.setOnTouchListener(new View.OnTouchListener() {
  340. public boolean onTouch(View view, MotionEvent motionEvent) {
  341. switch (motionEvent.getAction()) {
  342. case 0:
  343. ActivityPrintWeb.mNext.setBackgroundResource(R.C2136drawable.bt_right_hover);
  344. return false;
  345. case 1:
  346. ActivityPrintWeb.mNext.setBackgroundResource(R.C2136drawable.bt_right_1);
  347. return false;
  348. default:
  349. return false;
  350. }
  351. }
  352. });
  353. savePageRange2Pre();
  354. loadConfig();
  355. mImageView.setOnTouchListener(new View.OnTouchListener() {
  356. public boolean onTouch(View view, MotionEvent motionEvent) {
  357. Display defaultDisplay = ActivityPrintWeb.this.getWindowManager().getDefaultDisplay();
  358. Point point = new Point();
  359. defaultDisplay.getSize(point);
  360. float f = (float) point.y;
  361. float f2 = (float) point.x;
  362. if (f > f2) {
  363. f = f2;
  364. }
  365. switch (motionEvent.getAction()) {
  366. case 0:
  367. float unused = ActivityPrintWeb.mStartX = motionEvent.getX();
  368. float unused2 = ActivityPrintWeb.mMoveX = 0.0f;
  369. break;
  370. case 1:
  371. ActivityPrintWeb activityPrintWeb = ActivityPrintWeb.this;
  372. float unused3 = activityPrintWeb.mMoveX = activityPrintWeb.mStartX - motionEvent.getX();
  373. break;
  374. }
  375. float f3 = f / 10.0f;
  376. if (ActivityPrintWeb.mMoveX > f3) {
  377. ActivityPrintWeb.this.nextPage();
  378. return true;
  379. } else if (ActivityPrintWeb.mMoveX >= f3 * -1.0f) {
  380. return true;
  381. } else {
  382. ActivityPrintWeb.this.prevPage();
  383. return true;
  384. }
  385. }
  386. });
  387. int i2 = fromActivity;
  388. if (i2 == 1) {
  389. setTitle(getString(R.string.str_scan));
  390. } else if (i2 != 4) {
  391. setTitle(getString(R.string.web_btn_label));
  392. } else {
  393. setTitle(getString(R.string.network_storage_title));
  394. }
  395. mPrint.setEnabled(true);
  396. mCurrentPage = 1;
  397. mLn_zoomview.setVisibility(8);
  398. updateTextView();
  399. enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true);
  400. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  401. paperSourceInfo = PaperSourceInfo.getInstance(this);
  402. if (mEpsonService == null) {
  403. bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
  404. mUiHandler.sendEmptyMessage(5);
  405. }
  406. }
  407. private void showStoreDialog() {
  408. ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
  409. }
  410. public void onClick(View view) {
  411. int id = view.getId();
  412. if (id != R.id.tv_web_page_size) {
  413. switch (id) {
  414. case R.id.btn_web_next /*2131230880*/:
  415. nextPage();
  416. return;
  417. case R.id.btn_web_pre /*2131230881*/:
  418. prevPage();
  419. return;
  420. case R.id.btn_web_print /*2131230882*/:
  421. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  422. if (this.isRemotePrinter && enableShowWarning) {
  423. AlertDialog.Builder cancelable = new AlertDialog.Builder(mContext).setCancelable(false);
  424. 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() {
  425. public void onClick(DialogInterface dialogInterface, int i) {
  426. ActivityPrintWeb.mUiHandler.sendEmptyMessage(4);
  427. }
  428. }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
  429. public void onClick(DialogInterface dialogInterface, int i) {
  430. }
  431. }).show();
  432. return;
  433. } else if (this.fileName2User.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
  434. 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() {
  435. public void onClick(DialogInterface dialogInterface, int i) {
  436. }
  437. }).show();
  438. return;
  439. } else {
  440. mUiHandler.sendEmptyMessage(4);
  441. return;
  442. }
  443. default:
  444. return;
  445. }
  446. } else if (this.aPaperSourceSetting != null) {
  447. Intent intent = new Intent();
  448. intent.setClass(this, PaperSourceSettingScr.class);
  449. intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.document.name());
  450. intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, aPaperSourceSetting);
  451. startActivityForResult(intent, 6);
  452. } else {
  453. callPrintSetting();
  454. }
  455. }
  456. private void nextPage() {
  457. int i = mCurrentPage;
  458. if (i < mFileTotalPages) {
  459. mCurrentPage = i + 1;
  460. setNewImageView(mCurrentPage - 1);
  461. updateTextView();
  462. updateButton();
  463. }
  464. }
  465. private void prevPage() {
  466. int i = mCurrentPage;
  467. if (1 < i) {
  468. mCurrentPage = i - 1;
  469. setNewImageView(mCurrentPage - 1);
  470. updateTextView();
  471. updateButton();
  472. }
  473. }
  474. private void updateButton() {
  475. int i = mFileTotalPages;
  476. if (i > 1) {
  477. if (mCurrentPage == i) {
  478. mNext.setVisibility(8);
  479. } else {
  480. mNext.setVisibility(0);
  481. }
  482. int i2 = mCurrentPage;
  483. if (i2 == 1 || i2 == 0) {
  484. mPre.setVisibility(8);
  485. } else {
  486. mPre.setVisibility(0);
  487. }
  488. } else {
  489. mNext.setVisibility(8);
  490. mPre.setVisibility(8);
  491. }
  492. }
  493. public boolean onCreateOptionsMenu(Menu menu) {
  494. super.onCreateOptionsMenu(menu);
  495. getMenuInflater().inflate(R.menu.print_menu, menu);
  496. return true;
  497. }
  498. public boolean onOptionsItemSelected(MenuItem menuItem) {
  499. if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) {
  500. callPrintSetting();
  501. }
  502. return super.onOptionsItemSelected(menuItem);
  503. }
  504. private void check3GAndStartPrint() {
  505. startPrint();
  506. }
  507. private void startPrint() {
  508. if (mPrintLog == null) {
  509. mPrintLog = new PrintLog();
  510. }
  511. PrintLog printLog = mPrintLog;
  512. printLog.previewType = 3;
  513. startActivityForResult(PrintProgress.getPrintIntent(this, mPrintImageList, true, false, printLog), 255);
  514. }
  515. public void onConfigurationChanged(Configuration configuration) {
  516. super.onConfigurationChanged(configuration);
  517. setOrentationView(mIsPortrait);
  518. }
  519. public void setOrentationView(boolean z) {
  520. int i;
  521. int i2;
  522. try {
  523. loadConfig();
  524. mDisplay = getWindowManager().getDefaultDisplay();
  525. int paper_width = mPaperSize.getPaper_width();
  526. int paper_height = mPaperSize.getPaper_height();
  527. if (mLayoutMulti != 0) {
  528. int i3 = mLayoutMulti;
  529. if (i3 == 65536) {
  530. Rect paperSize_2in1 = mPaperSize.getPaperSize_2in1();
  531. paper_height = paperSize_2in1.width();
  532. paper_width = paperSize_2in1.height();
  533. Rect printingArea_2in1 = mPaperSize.getPrintingArea_2in1();
  534. i = printingArea_2in1.width();
  535. i2 = printingArea_2in1.height();
  536. } else if (i3 == 131072 || i3 == 262144) {
  537. Rect paperSize_4in1 = mPaperSize.getPaperSize_4in1();
  538. paper_height = paperSize_4in1.width();
  539. paper_width = paperSize_4in1.height();
  540. Rect printingArea_4in1 = mPaperSize.getPrintingArea_4in1();
  541. i = printingArea_4in1.width();
  542. i2 = printingArea_4in1.height();
  543. } else {
  544. i2 = 0;
  545. i = 0;
  546. int i4 = paper_height;
  547. paper_height = paper_width;
  548. paper_width = i4;
  549. }
  550. if (paper_height > paper_width) {
  551. int i5 = paper_height;
  552. paper_height = paper_width;
  553. paper_width = i5;
  554. int i6 = i;
  555. i = i2;
  556. i2 = i6;
  557. }
  558. } else if (paper_width > paper_height) {
  559. i2 = 0;
  560. i = 0;
  561. } else {
  562. i2 = 0;
  563. i = 0;
  564. int i7 = paper_height;
  565. paper_height = paper_width;
  566. paper_width = i7;
  567. }
  568. mPreviewPaperAreaLandscape = !z;
  569. Point point = new Point();
  570. mDisplay.getSize(point);
  571. if (z) {
  572. int height = point.y - (mPrint.getHeight() * 4);
  573. double d = (double) paper_width;
  574. double d2 = (double) paper_height;
  575. int i8 = (int) ((((double) height) / d) * d2);
  576. if (i8 > (point.x * 4) / 5) {
  577. i8 = (point.x * 4) / 5;
  578. height = (int) ((((double) i8) / d2) * d);
  579. }
  580. Relative_para = new RelativeLayout.LayoutParams(i8, height);
  581. } else {
  582. int i9 = (point.x * 4) / 5;
  583. double d3 = (double) paper_width;
  584. double d4 = (double) paper_height;
  585. int i10 = (int) ((((double) i9) / d3) * d4);
  586. if (i10 > point.y - (mPrint.getHeight() * 4)) {
  587. i10 = point.y - (mPrint.getHeight() * 4);
  588. i9 = (int) ((((double) i10) / d4) * d3);
  589. }
  590. Relative_para = new RelativeLayout.LayoutParams(i9, i10);
  591. }
  592. Relative_para.addRule(13);
  593. mLn_zoomview.setLayoutParams(this.Relative_para);
  594. setNewImageView(0);
  595. mCurrentPage = 1;
  596. updateTextView();
  597. updateButton();
  598. if (mLayout == 2) {
  599. if (mLayoutMulti == 0) {
  600. if (z) {
  601. float f = ((float) Relative_para.width) / ((float) paper_height);
  602. mLn_zoomview.setPadding((int) (((float) mPaperSize.getLeftMargin_border()) * f), (int) (((float) mPaperSize.getTopMargin_border()) * f), (int) (((float) mPaperSize.getRightMargin_border()) * f), (int) (((float) mPaperSize.getBottomMargin_border()) * f));
  603. } else {
  604. float f2 = ((float) Relative_para.width) / ((float) paper_width);
  605. mLn_zoomview.setPadding((int) (((float) mPaperSize.getTopMargin_border()) * f2), (int) (((float) mPaperSize.getRightMargin_border()) * f2), (int) (((float) mPaperSize.getBottomMargin_border()) * f2), (int) (((float) mPaperSize.getLeftMargin_border()) * f2));
  606. }
  607. } else if (z) {
  608. float f3 = ((float) Relative_para.width) / ((float) paper_height);
  609. int i11 = paper_height - i;
  610. int i12 = paper_width - i2;
  611. mLn_zoomview.setPadding((int) (((float) (i11 / 2)) * f3), (int) (((float) (i12 / 2)) * f3), (int) (((float) (i11 / 2)) * f3), (int) (((float) (i12 / 2)) * f3));
  612. } else {
  613. float f4 = ((float) Relative_para.width) / ((float) paper_width);
  614. int i13 = paper_width - i2;
  615. int i14 = paper_height - i;
  616. mLn_zoomview.setPadding((int) (((float) (i13 / 2)) * f4), (int) (((float) (i14 / 2)) * f4), (int) (((float) (i13 / 2)) * f4), (int) (((float) (i14 / 2)) * f4));
  617. }
  618. }
  619. mUiHandler.sendEmptyMessageDelayed(6, 200);
  620. } catch (Exception e) {
  621. e.printStackTrace();
  622. finish();
  623. }
  624. }
  625. private void setNewImageView(int i) {
  626. EPLog.m313i("Current page :", String.valueOf(i));
  627. try {
  628. f334bm = Photo.createBitmapWithUri(this.addImageView.get(i), 1024, Videoio.CAP_PVAPI, false);
  629. if (this.f334bm != null && mImageView != null) {
  630. if (mColorMode == 1) {
  631. f334bm = Photo.createBitmapWithUri(this.addImageView.get(i), 1024, Videoio.CAP_PVAPI, true);
  632. }
  633. mImageView.setImageBitmap(this.f334bm);
  634. System.gc();
  635. }
  636. } catch (Exception e) {
  637. e.printStackTrace();
  638. mUiHandler.sendEmptyMessage(1);
  639. }
  640. }
  641. public void callPrintSetting() {
  642. try {
  643. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  644. edit.putInt(Constants.SOURCE_TYPE, 3);
  645. edit.commit();
  646. Intent intent = new Intent(this, SettingScr.class);
  647. intent.putExtra(PrintProgress.PARAM_DOCUMENT_MODE, true);
  648. intent.putExtra("SHEETS", mFileTotalPages);
  649. intent.setAction("android.intent.action.VIEW");
  650. SharedPreferences.Editor edit2 = getSharedPreferences("PrintSetting", 0).edit();
  651. edit2.putInt(Constants.SOURCE_TYPE, 1);
  652. edit2.commit();
  653. startActivityForResult(intent, 6);
  654. } catch (UnsatisfiedLinkError e) {
  655. e.printStackTrace();
  656. mUiHandler.sendEmptyMessage(2);
  657. }
  658. }
  659. protected void onResume() {
  660. EPLog.m316v(TAG, "onResume()");
  661. super.onResume();
  662. NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
  663. paperMissmath.setVisibility(8);
  664. paperSourceInfo.start(this, mUiHandler);
  665. }
  666. protected void onPause() {
  667. super.onPause();
  668. NfcTagUtils.disableForegroundDispatch(this);
  669. paperSourceInfo.stop();
  670. }
  671. protected void onNewIntent(Intent intent) {
  672. NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
  673. super.onNewIntent(intent);
  674. if ("android.nfc.action.NDEF_DISCOVERED".equals(intent.getAction()) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
  675. Intent intent2 = new Intent();
  676. intent2.setClass(this, ActivityNfcPrinter.class);
  677. intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
  678. intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
  679. startActivityForResult(intent2, 5);
  680. }
  681. }
  682. protected void onDestroy() {
  683. super.onDestroy();
  684. IEpsonService iEpsonService = mEpsonService;
  685. if (iEpsonService != null) {
  686. try {
  687. iEpsonService.cancelSearchPrinter();
  688. mEpsonService.unregisterCallback(mCallback);
  689. unbindService(mEpsonConnection);
  690. mEpsonService = null;
  691. } catch (RemoteException e) {
  692. e.printStackTrace();
  693. }
  694. }
  695. }
  696. protected void onActivityResult(int i, int i2, Intent intent) {
  697. EPLog.m316v(TAG, "onActivityResult requestCode = " + i);
  698. if (i != 255) {
  699. switch (i) {
  700. case 5:
  701. if (i2 == -1) {
  702. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  703. bAutoStartPrint = true;
  704. mUiHandler.sendEmptyMessage(5);
  705. return;
  706. }
  707. return;
  708. case 6:
  709. if (i2 == 3) {
  710. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  711. setOrentationView(mIsPortrait);
  712. return;
  713. }
  714. return;
  715. default:
  716. return;
  717. }
  718. } else {
  719. EPLog.m316v(TAG, "onActivityResult resultCode = " + i2);
  720. if (i2 == 0) {
  721. EPLog.m316v(TAG, "finish print = RESULT_CANCELED");
  722. if (this.isCustomAction) {
  723. setResult(0);
  724. finish();
  725. return;
  726. }
  727. } else if (i2 != 4) {
  728. if (i2 == 1000) {
  729. EPLog.m316v(TAG, "finish print = RESULT_ERROR");
  730. }
  731. mPrint.setEnabled(true);
  732. }
  733. EPLog.m316v(TAG, "finish print = END_PRINT");
  734. mReviewInvitationViewModel.onPrintEnd(PrintProgress.isPrintSuccess(i2));
  735. if (this.isCustomAction) {
  736. EPLog.m316v(TAG, "*****isCustomAction");
  737. setResult(-1);
  738. finish();
  739. return;
  740. }
  741. mPrint.setEnabled(true);
  742. }
  743. }
  744. private void loadConfig() {
  745. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  746. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.document);
  747. printSetting.loadSettings();
  748. paperSize = printSetting.paperSizeValue;
  749. mColorMode = printSetting.colorValue;
  750. mLayout = printSetting.layoutValue;
  751. mLayoutMulti = printSetting.layoutMultiPageValue;
  752. mPaperSize = Info_paper.getInfoPaper(this, paperSize);
  753. MediaInfo.PaperSize paperSize2 = new MediaInfo.PaperSize();
  754. mSizeInfo.setText(getString(paperSize2.getStringId(this.paperSize)));
  755. paperSize2.destructor();
  756. fileName2User = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  757. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  758. mStartPage = printSetting.startValue;
  759. mEndPage = printSetting.endValue;
  760. }
  761. public void updateTextView() {
  762. mPageNum.setText(mCurrentPage + CommonDefine.SLASH + mFileTotalPages);
  763. }
  764. public void savePageRange2Pre() {
  765. new PrintSetting(this, (PrintSetting.Kind) null).resetPageRange(1, mFileTotalPages);
  766. mStartPage = 1;
  767. mEndPage = mFileTotalPages;
  768. EPLog.m313i("OldStartPage", String.valueOf(mStartPage));
  769. EPLog.m313i("OldEndPage", String.valueOf(mEndPage));
  770. }
  771. public void onBackPressed() {
  772. super.onBackPressed();
  773. ExternalFileUtils.getInstance(this).initTempViewDir();
  774. if (this.isCustomAction) {
  775. setResult(0);
  776. }
  777. }
  778. public void invitationDialogClicked(boolean z) {
  779. mReviewInvitationViewModel.setStartStoreEnd();
  780. }
  781. }