ActivityViewImageSelect.java 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. package epson.print;
  2. import android.app.Activity;
  3. import android.app.AlertDialog;
  4. import android.content.ComponentName;
  5. import android.content.Context;
  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.database.Cursor;
  13. import android.net.Uri;
  14. import android.os.AsyncTask;
  15. import android.os.Bundle;
  16. import android.os.Handler;
  17. import android.os.IBinder;
  18. import android.os.Message;
  19. import android.os.RemoteException;
  20. import android.view.KeyEvent;
  21. import android.view.Menu;
  22. import android.view.MenuItem;
  23. import android.view.View;
  24. import android.widget.AdapterView;
  25. import android.widget.Button;
  26. import android.widget.Gallery;
  27. import android.widget.ImageButton;
  28. import android.widget.ImageView;
  29. import android.widget.LinearLayout;
  30. import android.widget.TextView;
  31. import android.widget.Toast;
  32. import android.widget.ZoomControls;
  33. import androidx.annotation.MainThread;
  34. import androidx.annotation.NonNull;
  35. import androidx.annotation.Nullable;
  36. import androidx.fragment.app.DialogFragment;
  37. import androidx.fragment.app.FragmentActivity;
  38. import androidx.lifecycle.Observer;
  39. import androidx.lifecycle.ViewModelProviders;
  40. import com.epson.iprint.apf.ApfAdapter;
  41. import com.epson.iprint.apf.ApfPreviewView;
  42. import com.epson.iprint.prtlogger.NewLoggerController;
  43. import com.epson.iprint.prtlogger.PrintLog;
  44. import com.epson.iprint.shared.EpsoniPrintSharedActivity;
  45. import com.epson.iprint.shared.SharedParamPhoto;
  46. import com.epson.mobilephone.common.ReviewInvitationDialog;
  47. import com.epson.mobilephone.common.ReviewInvitationViewModel;
  48. import com.epson.mobilephone.common.escpr.MediaInfo;
  49. import com.epson.mobilephone.common.license.LicenseTopActivity;
  50. import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
  51. import java.io.File;
  52. import java.io.FileNotFoundException;
  53. import java.io.FileOutputStream;
  54. import java.io.IOException;
  55. import java.io.InputStream;
  56. import java.util.ArrayList;
  57. import java.util.Deque;
  58. import java.util.Iterator;
  59. import epson.common.Constants;
  60. import epson.common.DialogProgressViewModel;
  61. import epson.common.ExternalFileUtils;
  62. import epson.common.IprintLicenseInfo;
  63. import epson.common.IprintUserSurveyInfo;
  64. import epson.common.OsAssistant;
  65. import epson.common.Utils;
  66. import epson.print.Util.AsyncTaskExecutor;
  67. import epson.print.Util.EPLog;
  68. import epson.print.imgsel.PhotoImageSelectActivity;
  69. import epson.print.phlayout.PhotoPreview;
  70. import epson.print.phlayout.PhotoPreviewImageList;
  71. import epson.print.screen.PaperSourceInfo;
  72. import epson.print.screen.PaperSourceSetting;
  73. import epson.print.screen.PaperSourceSettingScr;
  74. import epson.print.screen.PrintProgress;
  75. import epson.print.screen.PrintSetting;
  76. import epson.print.screen.SettingScr;
  77. import epson.print.service.EpsonService;
  78. import epson.print.service.IEpsonService;
  79. import epson.print.service.IEpsonServiceCallback;
  80. /**
  81. *
  82. */
  83. public class ActivityViewImageSelect extends ActivityIACommon implements View.OnClickListener, PhotoPreview.ViewSizeChangeListener, ReviewInvitationDialog.OnClickListener {
  84. private static final int ALL_REFRESH_DRAW_END = 4;
  85. private static final String DIALOG_ALL_UPDATE = "dialog_all_update";
  86. private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
  87. private static final String DIALOG_LOAD = "dialog_load";
  88. private static final String DIALOG_PROGRESS = "dialog_progress";
  89. private static final int FROM_EPSON_PHOTO = 0;
  90. private static final int FROM_NOT_PHOTO = 1;
  91. public static final String LIST_ALBUM = "listAlbum";
  92. private static final int LOAD_ALL_IMAGE = 3;
  93. static final int MAX_IMAGE_NUMBER = 30;
  94. private static final int MESSAGE_OUT_OF_MEMORY_ERROR_NOTIFY = 8;
  95. private static final int OUT_OF_MEMORY_ERROR = 7;
  96. public static final String PARAMS_KEY_EPSON_COLOR_MODE = "epson_color_mode";
  97. public static final String PARAMS_KEY_FROM_EPSON = "FROM_EPSON";
  98. public static final String PARAMS_KEY_IMAGE_LIST = "imageList";
  99. public static final String PARAMS_KEY_PRINT_LOG = "print_log";
  100. private static final int PREVIEW_LOAD_DIALOG_DISMISS = 1;
  101. private static final int PREVIEW_LOAD_DIALOG_SHOW = 0;
  102. private static final int REQUEST_CODE_LICENSE_CHECK = 10;
  103. private static final int RESULT_RUNTIMEPERMMISSION = 9;
  104. private static final int START_PRINT = 5;
  105. private static final String TAG = "ActivityViewImageSelect";
  106. private static final int UPDATE_PAPERSIZE_TEXT = 6;
  107. private static final int ZOOM_CONTROL = 2;
  108. private ArrayList<PaperSourceSetting> aPaperSourceSetting;
  109. private ImageButton addButton = null;
  110. boolean bAutoStartPrint = false;
  111. boolean bRequestPermission = false;
  112. private Context context = null;
  113. private int currentColor = 0;
  114. private int currentLayout = 2;
  115. private int currentLayoutMulti = 0;
  116. private int currentPaperSize = 0;
  117. private String currentPrinterName = "";
  118. private Button deleteButton = null;
  119. private boolean enableShowWarning = true;
  120. private Gallery gallery = null;
  121. private GalleryAdapter galleryAdapter = null;
  122. private final PhotoPreviewImageList imageList = new PhotoPreviewImageList();
  123. private int imageNo = 0;
  124. private boolean isCustomAction = false;
  125. private boolean isPaperLandscape = false;
  126. private boolean isPrintedOK = false;
  127. private boolean isRemotePrinter = false;
  128. private boolean mAllReloadTaskDone;
  129. protected final Object mAllReloadTaskLock = new Object();
  130. private volatile boolean mAllReloadTaskRetryRequested;
  131. private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
  132. public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
  133. }
  134. public void onGetInkState() throws RemoteException {
  135. }
  136. public void onGetStatusState() throws RemoteException {
  137. }
  138. public void onNotifyContinueable(int i) throws RemoteException {
  139. }
  140. public void onNotifyEndJob(int i) throws RemoteException {
  141. }
  142. public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
  143. }
  144. public void onNotifyProgress(int i, int i2) throws RemoteException {
  145. }
  146. };
  147. private boolean mEnableEpsonColorDisplay;
  148. private ImageView mEpsonColorImageView;
  149. private ServiceConnection mEpsonConnection = new ServiceConnection() {
  150. public void onServiceDisconnected(ComponentName componentName) {
  151. try {
  152. mEpsonService.unregisterCallback(mCallback);
  153. } catch (RemoteException e) {
  154. e.printStackTrace();
  155. }
  156. IEpsonService unused = mEpsonService = null;
  157. }
  158. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  159. IEpsonService unused = mEpsonService = IEpsonService.Stub.asInterface(iBinder);
  160. if (mEpsonService != null) {
  161. try {
  162. mEpsonService.registerCallback(mCallback);
  163. } catch (RemoteException e) {
  164. e.printStackTrace();
  165. }
  166. }
  167. }
  168. };
  169. private IEpsonService mEpsonService = null;
  170. private boolean mFileCheckEnd;
  171. Handler mHandler = new Handler(new Handler.Callback() {
  172. public boolean handleMessage(Message message) {
  173. if (isFinishing()) {
  174. return true;
  175. }
  176. int i = message.what;
  177. if (i != 100) {
  178. switch (i) {
  179. case 0:
  180. mModelDialog.doShow(DIALOG_LOAD);
  181. break;
  182. case 1:
  183. mModelDialog.doDismiss(DIALOG_LOAD);
  184. break;
  185. case 2:
  186. break;
  187. case 3:
  188. ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
  189. AllReloadTask unused = reloadTask = new AllReloadTask(context);
  190. if (reloadTask != null) {
  191. reloadTask.executeOnExecutor(new Void[0]);
  192. }
  193. mHandler.sendEmptyMessageDelayed(1, 300);
  194. break;
  195. default:
  196. switch (i) {
  197. case 5:
  198. startPrint();
  199. break;
  200. case 6:
  201. papersizeTextView.setText(getString(new MediaInfo.PaperSize().getStringId(currentPaperSize)));
  202. break;
  203. case 7:
  204. if (imageList.size() <= 0) {
  205. deleteButton.setEnabled(false);
  206. printButton.setEnabled(false);
  207. int unused2 = imageNo = 0;
  208. }
  209. TextView access$1900 = pageTextView;
  210. access$1900.setText(imageNo + CommonDefine.SLASH + imageList.size());
  211. updateGallery();
  212. previewImageView.invalidate();
  213. Toast.makeText(context, context.getString(R.string.file_size_notsupport), 1).show();
  214. break;
  215. case 8:
  216. showSimpleDialog(R.string.str_err_msg_out_of_memory_title);
  217. return true;
  218. }
  219. }
  220. } else {
  221. ArrayList unused3 = aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
  222. if (aPaperSourceSetting != null) {
  223. papersizeTextView.setBackgroundColor(getResources().getColor(R.color.epson_blue));
  224. papersizeTextView.setTextColor(getResources().getColor(R.color.all_white));
  225. PrintSetting printSetting = new PrintSetting(ActivityViewImageSelect.this, PrintSetting.Kind.photo);
  226. printSetting.loadSettings();
  227. if (paperSourceInfo.checkPaperMissmatch(printSetting, aPaperSourceSetting)) {
  228. paperMissmath.setVisibility(View.VISIBLE);
  229. } else {
  230. paperMissmath.setVisibility(View.GONE);
  231. }
  232. } else {
  233. papersizeTextView.setBackgroundColor(getResources().getColor(R.color.all_white));
  234. papersizeTextView.setTextColor(getResources().getColor(R.color.epson_blue));
  235. paperMissmath.setVisibility(View.GONE);
  236. }
  237. }
  238. return true;
  239. }
  240. });
  241. private final ArrayList<String> mImageFilenameListFromIntent = new ArrayList<>();
  242. private int mIntentFileType = 0;
  243. protected volatile boolean mIsAllReloadTaskRetryAcceptable;
  244. private boolean mLicenseCheckDone;
  245. private DialogProgressViewModel mModelDialog;
  246. private boolean mOnSizeChangeReceived;
  247. private PrintLog mPrintLog;
  248. private ReviewInvitationViewModel mReviewInvitationViewModel;
  249. private int mStartActivityFromPhoto = 0;
  250. private TextView pageTextView = null;
  251. private ImageView paperMissmath = null;
  252. PaperSourceInfo paperSourceInfo = null;
  253. private TextView papersizeTextView = null;
  254. protected ApfPreviewView previewImageView;
  255. private Button printButton = null;
  256. private String printerId = "";
  257. private AllReloadTask reloadTask = null;
  258. private Button rotateButton = null;
  259. private ZoomControls zoomControls = null;
  260. public void onCreate(Bundle bundle) {
  261. super.onCreate(bundle);
  262. setContentView(R.layout.photo_preview);
  263. context = this;
  264. mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
  265. mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
  266. public void onChanged(@Nullable Boolean bool) {
  267. if (bool.booleanValue()) {
  268. showStoreDialog();
  269. }
  270. }
  271. });
  272. mOnSizeChangeReceived = false;
  273. mLicenseCheckDone = false;
  274. mFileCheckEnd = false;
  275. mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
  276. mModelDialog.getDialogJob().observe(this, new Observer() {
  277. public final void onChanged(Object obj) {
  278. lambda$onCreate$0(ActivityViewImageSelect.this, (Deque) obj);
  279. }
  280. });
  281. NewLoggerController.stopLoggerIfNotAgreed(this);
  282. setActionBar(R.string.photo_btn_label, true);
  283. ExternalFileUtils.getInstance(this).initTempViewDir();
  284. ExternalFileUtils.getInstance(this).initTempCRDir();
  285. ExternalFileUtils.getInstance(this).initPrintDir();
  286. Intent intent = getIntent();
  287. if (intent == null) {
  288. Toast.makeText(this, getString(R.string.no_image), 0).show();
  289. finish();
  290. }
  291. setFieldFromStartIntent(intent);
  292. if (mImageFilenameListFromIntent.size() == 0) {
  293. clearListToastAndFinish();
  294. return;
  295. }
  296. mEnableEpsonColorDisplay = getEpsonColorModeFromIntent(intent);
  297. PhotoPreview photoPreview = (PhotoPreview) findViewById(R.id.previewImageView);
  298. photoPreview.setViewSizeChangeListener(this);
  299. previewImageView = new ApfPreviewView();
  300. previewImageView.init(this, photoPreview);
  301. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  302. if (sharedPreferences != null) {
  303. currentPrinterName = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  304. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  305. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  306. printSetting.loadSettings();
  307. currentPaperSize = printSetting.paperSizeValue;
  308. currentLayout = printSetting.layoutValue;
  309. currentLayoutMulti = printSetting.layoutMultiPageValue;
  310. currentColor = printSetting.colorValue;
  311. previewImageView.setLayout(currentLayout, currentLayoutMulti);
  312. previewImageView.setPaper(currentPaperSize);
  313. previewImageView.setColor(currentColor);
  314. }
  315. previewImageView.setApfLibParams(0, 0, 0);
  316. papersizeTextView = (TextView) findViewById(R.id.btn_paper_size);
  317. papersizeTextView.setText(getPaperSizeName());
  318. papersizeTextView.setOnClickListener(this);
  319. pageTextView = (TextView) findViewById(R.id.btn_photo_count);
  320. Handler handler = mHandler;
  321. if (handler != null) {
  322. handler.sendEmptyMessage(2);
  323. }
  324. rotateButton = (Button) findViewById(R.id.bt_rotate);
  325. rotateButton.setOnClickListener(this);
  326. gallery = (Gallery) findViewById(R.id.gallery);
  327. if (mImageFilenameListFromIntent.size() != 0) {
  328. gallery.setCallbackDuringFling(false);
  329. gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  330. public void onNothingSelected(AdapterView<?> adapterView) {
  331. }
  332. public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
  333. if (imageNo != i) {
  334. int unused = imageNo = i;
  335. gallery.setSelection(imageNo);
  336. new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
  337. }
  338. }
  339. });
  340. }
  341. addButton = (ImageButton) findViewById(R.id.btn_add_photo);
  342. addButton.setOnClickListener(this);
  343. deleteButton = (Button) findViewById(R.id.btn_deselect);
  344. deleteButton.setOnClickListener(this);
  345. if (mImageFilenameListFromIntent.size() == 0) {
  346. deleteButton.setEnabled(false);
  347. }
  348. if (mStartActivityFromPhoto != 0) {
  349. addButton.setVisibility(View.GONE);
  350. deleteButton.setVisibility(View.GONE);
  351. }
  352. printButton = (Button) findViewById(R.id.btn_print);
  353. printButton.setOnClickListener(this);
  354. previewImageView.setZoomControlHandler(mHandler);
  355. paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
  356. mModelDialog.doShow(DIALOG_LOAD);
  357. enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true);
  358. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  359. switch (intent.getIntExtra("from", 0)) {
  360. case 3:
  361. setTitle(getString(R.string.document_btn_label));
  362. ((LinearLayout) findViewById(R.id.linearLayout3)).setVisibility(View.GONE);
  363. break;
  364. case 4:
  365. setTitle(getString(R.string.network_storage_title));
  366. ((LinearLayout) findViewById(R.id.linearLayout3)).setVisibility(View.GONE);
  367. break;
  368. default:
  369. setTitle(getString(R.string.photo_btn_label));
  370. break;
  371. }
  372. mEpsonColorImageView = (ImageView) findViewById(R.id.epsonColorImageView);
  373. updateEpsonColorStatus();
  374. paperSourceInfo = PaperSourceInfo.getInstance(this);
  375. if (mEpsonService == null) {
  376. bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
  377. }
  378. if (bundle == null) {
  379. startLicenseCheckActivity();
  380. } else if (!permissionCheck()) {
  381. finish();
  382. }
  383. }
  384. public static /* synthetic */ void lambda$onCreate$0(ActivityViewImageSelect activityViewImageSelect, Deque deque) {
  385. String[] checkQueue = mModelDialog.checkQueue();
  386. if (checkQueue != null) {
  387. String str = checkQueue[0];
  388. String str2 = checkQueue[1];
  389. if (str2.equals("do_show")) {
  390. showDialog(str);
  391. }
  392. if (str2.equals("do_dismiss")) {
  393. dismissDialog(str);
  394. }
  395. }
  396. }
  397. private void showStoreDialog() {
  398. ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
  399. }
  400. private void observeImageList(PhotoPreviewImageList photoPreviewImageList) {
  401. PhotoImageConvertViewModel photoImageConvertViewModel = (PhotoImageConvertViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(PhotoImageConvertViewModel.class);
  402. photoImageConvertViewModel.getData().observe(this, new Observer<PhotoImageConvertViewModel.Result>() {
  403. public void onChanged(@Nullable PhotoImageConvertViewModel.Result result) {
  404. if (result.epImageWrappers == null) {
  405. clearListToastAndFinish();
  406. } else if (!setPhotoImageList(result.epImageWrappers)) {
  407. clearListToastAndFinish();
  408. } else {
  409. updateImageListDisplay();
  410. boolean unused = mFileCheckEnd = true;
  411. loadImage();
  412. }
  413. }
  414. });
  415. photoImageConvertViewModel.setOriginalImageList(mImageFilenameListFromIntent);
  416. }
  417. private void updateGallery() {
  418. galleryAdapter.setImageList(imageList.getGalleryFileList());
  419. }
  420. private boolean checkExternalStorageReadPermission() {
  421. return ActivityRequestPermissions.checkPermission(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"});
  422. }
  423. private void requestReadExternalStoragePermission() {
  424. ActivityRequestPermissions.requestPermission((Activity) this, new ActivityRequestPermissions.Permission(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}[0], new String[]{getString(R.string.permission_dialog_title), getString(R.string.permission_dialog_title)}, new String[]{ActivityRequestPermissions.DialogParameter.setMessage2((Context) this, getString(R.string.permission_dialog_message_storage)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) this, getString(R.string.permission_dialog_message_storage), getString(R.string.permission_function_storage))}), 9);
  425. bRequestPermission = true;
  426. }
  427. private boolean setPhotoImageList(@Nullable ArrayList<PhotoPreviewImageList.EpImageWrapper> arrayList) {
  428. imageList.clear();
  429. if (arrayList == null) {
  430. return false;
  431. }
  432. Iterator<PhotoPreviewImageList.EpImageWrapper> it = arrayList.iterator();
  433. while (it.hasNext()) {
  434. imageList.add(it.next());
  435. }
  436. if (imageList.size() <= 0) {
  437. return false;
  438. }
  439. return true;
  440. }
  441. private void updateImageListDisplay() {
  442. previewImageView.setImageList(imageList);
  443. TextView textView = pageTextView;
  444. textView.setText("1/" + imageList.size());
  445. if (imageList.size() == 0) {
  446. deleteButton.setEnabled(false);
  447. }
  448. }
  449. private void startLicenseCheckActivity() {
  450. IprintLicenseInfo.beforeLicenseCheck(getApplicationContext());
  451. startActivityForResult(LicenseTopActivity.getStartIntent(getApplicationContext(), new IprintLicenseInfo(), new IprintUserSurveyInfo()), 10);
  452. }
  453. private void setFieldFromStartIntent(@NonNull Intent intent) {
  454. ArrayList<String> arrayFileFullPath;
  455. int i = 0;
  456. isCustomAction = false;
  457. mImageFilenameListFromIntent.clear();
  458. mIntentFileType = 0;
  459. mStartActivityFromPhoto = 1;
  460. try {
  461. mPrintLog = (PrintLog) intent.getSerializableExtra("print_log");
  462. } catch (ClassCastException unused) {
  463. }
  464. if (EpsoniPrintSharedActivity.ACTION_PHOTO_PRINT.equals(intent.getAction())) {
  465. isCustomAction = true;
  466. SharedParamPhoto sharedParamPhoto = (SharedParamPhoto) intent.getSerializableExtra("extParam");
  467. if (sharedParamPhoto != null && (arrayFileFullPath = sharedParamPhoto.getArrayFileFullPath()) != null) {
  468. int i2 = 0;
  469. while (i < arrayFileFullPath.size()) {
  470. if (i2 < 30) {
  471. mImageFilenameListFromIntent.add(arrayFileFullPath.get(i));
  472. i2++;
  473. }
  474. i++;
  475. }
  476. if (sharedParamPhoto.isFileTypeValid()) {
  477. mIntentFileType = sharedParamPhoto.getFile_type();
  478. }
  479. mStartActivityFromPhoto = 1;
  480. } else {
  481. return;
  482. }
  483. } else {
  484. if (intent.getStringArrayListExtra(LIST_ALBUM) == null && intent.getStringArrayListExtra("imageList") == null && -1 == intent.getIntExtra("from", -1)) {
  485. new PrintSetting(this, (PrintSetting.Kind) null).resetPrintSettings();
  486. }
  487. if (intent.getStringArrayListExtra(LIST_ALBUM) != null) {
  488. if (intent.getBooleanExtra(CommonDefine.STYPE, false)) {
  489. mStartActivityFromPhoto = 1;
  490. intent.removeExtra(CommonDefine.STYPE);
  491. }
  492. ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra(LIST_ALBUM);
  493. if (stringArrayListExtra != null) {
  494. while (i < stringArrayListExtra.size()) {
  495. mImageFilenameListFromIntent.add(stringArrayListExtra.get(i));
  496. i++;
  497. }
  498. intent.removeExtra(LIST_ALBUM);
  499. } else {
  500. return;
  501. }
  502. } else if (intent.getBooleanExtra(PARAMS_KEY_FROM_EPSON, false)) {
  503. mStartActivityFromPhoto = 1;
  504. Uri uri = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
  505. if (uri != null) {
  506. String decode = Uri.decode(uri.getPath());
  507. if (decode != null) {
  508. mImageFilenameListFromIntent.add(decode);
  509. } else {
  510. return;
  511. }
  512. } else {
  513. ArrayList<String> stringArrayListExtra2 = intent.getStringArrayListExtra("android.intent.extra.STREAM");
  514. if (stringArrayListExtra2 != null) {
  515. while (i < stringArrayListExtra2.size()) {
  516. mImageFilenameListFromIntent.add(stringArrayListExtra2.get(i));
  517. i++;
  518. }
  519. } else {
  520. return;
  521. }
  522. }
  523. } else if ("android.intent.action.SEND".equals(intent.getAction())) {
  524. mStartActivityFromPhoto = 1;
  525. setPrintLogForExternalApp();
  526. try {
  527. Uri uri2 = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
  528. if (uri2 != null) {
  529. addImageByIntent(intent, uri2);
  530. } else {
  531. return;
  532. }
  533. } catch (Exception unused2) {
  534. return;
  535. }
  536. } else if ("android.intent.action.VIEW".equals(intent.getAction())) {
  537. mStartActivityFromPhoto = 1;
  538. setPrintLogForExternalApp();
  539. try {
  540. addImageByIntent(intent, intent.getData());
  541. } catch (Exception unused3) {
  542. }
  543. } else if ("android.intent.action.SEND_MULTIPLE".equals(intent.getAction())) {
  544. mStartActivityFromPhoto = 1;
  545. setPrintLogForExternalApp();
  546. Bundle extras = intent.getExtras();
  547. if (extras != null) {
  548. if (extras.get("android.intent.extra.STREAM") instanceof ArrayList) {
  549. try {
  550. ArrayList parcelableArrayListExtra = intent.getParcelableArrayListExtra("android.intent.extra.STREAM");
  551. if (parcelableArrayListExtra != null) {
  552. while (i < parcelableArrayListExtra.size() && i < 30) {
  553. try {
  554. addImageByIntent(intent, (Uri) parcelableArrayListExtra.get(i));
  555. i++;
  556. } catch (Exception unused4) {
  557. return;
  558. }
  559. }
  560. }
  561. } catch (Exception unused5) {
  562. return;
  563. }
  564. } else {
  565. try {
  566. addImageByIntent(intent, (Uri) intent.getExtras().getParcelable("android.intent.extra.STREAM"));
  567. } catch (Exception unused6) {
  568. return;
  569. }
  570. }
  571. } else {
  572. return;
  573. }
  574. } else {
  575. mStartActivityFromPhoto = 0;
  576. ArrayList<String> stringArrayListExtra3 = intent.getStringArrayListExtra("imageList");
  577. if (stringArrayListExtra3 != null) {
  578. while (i < stringArrayListExtra3.size()) {
  579. mImageFilenameListFromIntent.add(stringArrayListExtra3.get(i));
  580. i++;
  581. }
  582. } else {
  583. return;
  584. }
  585. }
  586. }
  587. if (mPrintLog == null) {
  588. mPrintLog = new PrintLog();
  589. }
  590. }
  591. private void setPrintLogForExternalApp() {
  592. if (mPrintLog == null) {
  593. mPrintLog = new PrintLog();
  594. }
  595. if (mPrintLog.callerPackage == null) {
  596. mPrintLog.callerPackage = getCallingPackage();
  597. }
  598. if (mPrintLog.uiRoute <= 0) {
  599. mPrintLog.uiRoute = 4097;
  600. }
  601. }
  602. private void requestPermissionOrObserveImageList() {
  603. if (!requestExternalStoragePermissionIfNeeded()) {
  604. observeImageList(imageList);
  605. }
  606. }
  607. private boolean requestExternalStoragePermissionIfNeeded() {
  608. if (!isPermissionRequestRequired(mImageFilenameListFromIntent)) {
  609. return false;
  610. }
  611. requestReadExternalStoragePermission();
  612. return true;
  613. }
  614. private boolean isPermissionRequestRequired(@NonNull ArrayList<String> arrayList) {
  615. if (!ActivityRequestPermissions.isRuntimePermissionSupported() || checkExternalStorageReadPermission()) {
  616. return false;
  617. }
  618. String lowerCase = ExternalFileUtils.getInstance(this).getWorkingDir().toLowerCase();
  619. Iterator<String> it = arrayList.iterator();
  620. while (it.hasNext()) {
  621. if (!it.next().toLowerCase().startsWith(lowerCase)) {
  622. return true;
  623. }
  624. }
  625. return false;
  626. }
  627. private void loadImage() {
  628. if (mFileCheckEnd && mOnSizeChangeReceived && mLicenseCheckDone) {
  629. galleryAdapter = new GalleryAdapter(getApplicationContext(), imageList.getGalleryFileList());
  630. gallery.setAdapter(galleryAdapter);
  631. gallery.setSelection(imageNo);
  632. galleryAdapter.setAlignLeft(gallery);
  633. mHandler.sendEmptyMessage(3);
  634. }
  635. }
  636. private void clearListToastAndFinish() {
  637. Toast.makeText(this, getString(R.string.file_size_notsupport), 1).show();
  638. imageList.clear();
  639. onBackPressed();
  640. }
  641. public static boolean checkBmpNot24Bit(@NonNull EPImage ePImage) {
  642. return Utils.checkMimeType(ePImage.loadImageFileName, CommonDefine.IMAGE_TYPE_BMP) && new EPImageUtil().getBitCount(ePImage.loadImageFileName) != 24;
  643. }
  644. private void addImageByIntent(Intent intent, Uri uri) {
  645. String contentFromCR;
  646. String type = intent.getType();
  647. String uri2 = uri.toString();
  648. if (uri2.startsWith("content://")) {
  649. Cursor cursor = null;
  650. try {
  651. cursor = getContentResolver().query(uri, new String[]{"_data"}, (String) null, (String[]) null, (String) null);
  652. } catch (IllegalArgumentException unused) {
  653. }
  654. if (cursor != null) {
  655. cursor.close();
  656. } else if (uri.toString().startsWith("content://com.android.gallery3d.provider")) {
  657. EPLog.d(TAG, "Actual URI: " + uri.toString());
  658. uri = Uri.parse(uri.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
  659. EPLog.d(TAG, "Effective URI: " + uri.toString());
  660. }
  661. String contentFromCR2 = getContentFromCR(uri, type);
  662. if (contentFromCR2 != null) {
  663. mImageFilenameListFromIntent.add(contentFromCR2);
  664. return;
  665. }
  666. String realPathFromURI = getRealPathFromURI(uri);
  667. if (realPathFromURI != null) {
  668. mImageFilenameListFromIntent.add(realPathFromURI);
  669. EPLog.d(TAG, "addImageByIntent by getRealPathFromURI");
  670. return;
  671. }
  672. } else if (uri2.startsWith("file://")) {
  673. if (type == null || type.length() <= 0 || (contentFromCR = getContentFromCR(uri, type)) == null) {
  674. String path = uri.getPath();
  675. if (path.startsWith("/file:")) {
  676. path = path.substring(6);
  677. }
  678. if (Utils.isPhotoFile(path)) {
  679. mImageFilenameListFromIntent.add(path);
  680. EPLog.d(TAG, "addImageByIntent by isPhotoFile()");
  681. return;
  682. }
  683. } else {
  684. mImageFilenameListFromIntent.add(contentFromCR);
  685. return;
  686. }
  687. }
  688. clearListToastAndFinish();
  689. }
  690. private String getContentFromCR(Uri uri, String str) {
  691. String str2;
  692. File file;
  693. EPLog.d(TAG, "getContentFromCR uri = " + uri + " fType = " + str);
  694. try {
  695. str2 = Utils.makeTempFileName(str);
  696. } catch (FileNotFoundException unused) {
  697. EPLog.w(TAG, "getContentFromCR Unknown fType = " + str);
  698. str2 = String.valueOf(System.currentTimeMillis());
  699. }
  700. try {
  701. InputStream openInputStream = getContentResolver().openInputStream(uri);
  702. File file2 = new File(ExternalFileUtils.getInstance(this).getTempCRDir(), str2);
  703. FileOutputStream fileOutputStream = new FileOutputStream(file2);
  704. byte[] bArr = new byte[1024];
  705. while (true) {
  706. int read = openInputStream.read(bArr);
  707. if (read <= 0) {
  708. break;
  709. }
  710. fileOutputStream.write(bArr, 0, read);
  711. }
  712. fileOutputStream.close();
  713. if (Utils.getExtention(file2.getName()) == null) {
  714. String realMimeType = Utils.getRealMimeType(file2.getAbsolutePath());
  715. String mimeExt = realMimeType != null ? Utils.getMimeExt(realMimeType) : null;
  716. if (mimeExt != null) {
  717. file = new File(file2.getAbsolutePath() + mimeExt);
  718. file2.renameTo(file);
  719. EPLog.d(TAG, "getContentFromCR success");
  720. return file.getAbsolutePath();
  721. }
  722. }
  723. file = file2;
  724. EPLog.d(TAG, "getContentFromCR success");
  725. return file.getAbsolutePath();
  726. } catch (IOException e) {
  727. e.printStackTrace();
  728. return null;
  729. }
  730. }
  731. public String getRealPathFromURI(Uri uri) {
  732. Cursor query = getContentResolver().query(uri, new String[]{"_data"}, (String) null, (String[]) null, (String) null);
  733. String str = null;
  734. if (query == null) {
  735. return null;
  736. }
  737. try {
  738. int columnIndexOrThrow = query.getColumnIndexOrThrow("_data");
  739. query.moveToFirst();
  740. str = query.getString(columnIndexOrThrow);
  741. } catch (Exception e) {
  742. e.printStackTrace();
  743. } catch (Throwable th) {
  744. query.close();
  745. throw th;
  746. }
  747. query.close();
  748. return str;
  749. }
  750. public static boolean checkEPImage(EPImage ePImage) {
  751. return ePImage != null && ePImage.srcWidth > 0 && ePImage.srcHeight > 0;
  752. }
  753. protected boolean getEpsonColorModeFromIntent(Intent intent) {
  754. return intent.getBooleanExtra(PARAMS_KEY_EPSON_COLOR_MODE, false);
  755. }
  756. private String getPaperSizeName() {
  757. MediaInfo.PaperSize paperSize = new MediaInfo.PaperSize();
  758. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  759. printSetting.loadSettings();
  760. return getString(paperSize.getStringId(printSetting.paperSizeValue));
  761. }
  762. private boolean permissionCheck() {
  763. if (!IprintLicenseInfo.isAgreedCurrentVersion(getApplicationContext())) {
  764. return false;
  765. }
  766. mLicenseCheckDone = true;
  767. requestPermissionOrObserveImageList();
  768. return true;
  769. }
  770. protected void onActivityResult(int i, int i2, Intent intent) {
  771. super.onActivityResult(i, i2, intent);
  772. switch (i) {
  773. case 5:
  774. if (i2 == -1) {
  775. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  776. String string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  777. if (!string.equals(currentPrinterName)) {
  778. currentPrinterName = string;
  779. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  780. updateEpsonColorStatus();
  781. bAutoStartPrint = true;
  782. mHandler.sendEmptyMessage(3);
  783. return;
  784. }
  785. onClick(printButton);
  786. EPLog.d(TAG, "onClick(printButton)");
  787. return;
  788. }
  789. return;
  790. case 9:
  791. if (i2 != -1) {
  792. clearListToastAndFinish();
  793. return;
  794. } else {
  795. requestPermissionOrObserveImageList();
  796. return;
  797. }
  798. case 10:
  799. if (!permissionCheck()) {
  800. mModelDialog.doDismiss(DIALOG_LOAD);
  801. finish();
  802. return;
  803. }
  804. return;
  805. case CommonDefine.REQUEST_SETTING /*254*/:
  806. onPrintSettingEnd(i2);
  807. return;
  808. case 255:
  809. unlockScreenRotation();
  810. if (i2 == 0) {
  811. setResult(i2);
  812. if (isCustomAction) {
  813. setResult(0);
  814. finish();
  815. return;
  816. }
  817. } else if (i2 != 4) {
  818. if (i2 == 1000) {
  819. printButton.setEnabled(true);
  820. ExternalFileUtils.getInstance(this).initPrintDir();
  821. return;
  822. }
  823. return;
  824. }
  825. mReviewInvitationViewModel.onPrintEnd(PrintProgress.isPrintSuccess(i2));
  826. if (isCustomAction) {
  827. setResult(-1);
  828. finish();
  829. return;
  830. }
  831. printButton.setEnabled(true);
  832. ExternalFileUtils.getInstance(this).initPrintDir();
  833. return;
  834. default:
  835. return;
  836. }
  837. }
  838. private void onPrintSettingEnd(int i) {
  839. int i2;
  840. boolean z;
  841. int i3;
  842. int i4;
  843. int i5;
  844. int i6;
  845. int i7;
  846. boolean z2;
  847. if (i == 3) {
  848. printButton.setEnabled(true);
  849. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  850. String string = getString(R.string.str_lbl_title_scan);
  851. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  852. int i8 = 2;
  853. if (sharedPreferences != null) {
  854. string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  855. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  856. printSetting.loadSettings();
  857. i7 = printSetting.paperSizeValue;
  858. i8 = printSetting.layoutValue;
  859. i6 = printSetting.layoutMultiPageValue;
  860. i5 = printSetting.colorValue;
  861. i4 = printSetting.photoApfValueForLocalPrinter;
  862. i3 = printSetting.sharpnessForPhoto;
  863. int i9 = printSetting.paperTypeValue;
  864. int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
  865. EPLog.i("KIND = " + printSetting.getKind() + " NEW setteing = " + i9 + " plain = " + code);
  866. i2 = (i9 == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
  867. z = MyPrinter.isRemotePrinter(this);
  868. } else {
  869. i2 = 0;
  870. i7 = 0;
  871. i6 = 0;
  872. i5 = 0;
  873. i4 = 0;
  874. i3 = 0;
  875. z = false;
  876. }
  877. if (!currentPrinterName.equalsIgnoreCase(string)) {
  878. currentPrinterName = string;
  879. z2 = true;
  880. } else {
  881. z2 = false;
  882. }
  883. if (currentLayout != i8) {
  884. currentLayout = i8;
  885. previewImageView.setLayout(currentLayout, currentLayoutMulti);
  886. z2 = true;
  887. }
  888. if (currentLayoutMulti != i6) {
  889. currentLayoutMulti = i6;
  890. previewImageView.setLayout(currentLayout, currentLayoutMulti);
  891. z2 = true;
  892. }
  893. if (currentPaperSize != i7) {
  894. currentPaperSize = i7;
  895. previewImageView.setPaper(i7);
  896. papersizeTextView.setText(getString(new MediaInfo.PaperSize().getStringId(i7)));
  897. z2 = true;
  898. }
  899. if (currentColor != i5) {
  900. currentColor = i5;
  901. previewImageView.setColor(currentColor);
  902. z2 = true;
  903. }
  904. if (imageList.size() == 0) {
  905. printButton.setEnabled(false);
  906. }
  907. if (isRemotePrinter != z) {
  908. isRemotePrinter = z;
  909. z2 = true;
  910. }
  911. if (!z) {
  912. if (previewImageView.getApfMode() != i4) {
  913. z2 = true;
  914. }
  915. if (previewImageView.getSharpnessValue() != i3) {
  916. z2 = true;
  917. }
  918. if (previewImageView.getClearlyVividMode() != i2) {
  919. z2 = true;
  920. }
  921. }
  922. updateEpsonColorStatus();
  923. if (z2) {
  924. mHandler.sendEmptyMessage(3);
  925. }
  926. }
  927. }
  928. private boolean isEpsonColorMode() {
  929. boolean z = false;
  930. if (!mEnableEpsonColorDisplay) {
  931. return false;
  932. }
  933. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  934. printSetting.loadSettings();
  935. int apfValue = getApfValue(printSetting);
  936. int i = printSetting.paperTypeValue;
  937. int i2 = printSetting.colorValue;
  938. if (apfValue == 1) {
  939. z = true;
  940. }
  941. return ApfAdapter.isEpsonColor(this, i, i2, z);
  942. }
  943. private void updateEpsonColorStatus() {
  944. mEpsonColorImageView.setVisibility(isEpsonColorMode() ? 0 : 8);
  945. }
  946. protected void onResume() {
  947. EPLog.d("ActivityImageViewSelect", "onResume");
  948. super.onResume();
  949. NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
  950. paperMissmath.setVisibility(View.GONE);
  951. paperSourceInfo.start(this, mHandler);
  952. }
  953. protected void onNewIntent(Intent intent) {
  954. NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
  955. super.onNewIntent(intent);
  956. String action = intent.getAction();
  957. if (reloadTask != null) {
  958. switch (C211111.$SwitchMap$android$os$AsyncTask$Status[reloadTask.getStatus().ordinal()]) {
  959. case 1:
  960. case 2:
  961. if ("android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
  962. Intent intent2 = new Intent();
  963. intent2.setClass(this, ActivityNfcPrinter.class);
  964. intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
  965. intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
  966. startActivityForResult(intent2, 5);
  967. return;
  968. }
  969. return;
  970. default:
  971. return;
  972. }
  973. }
  974. }
  975. /* renamed from: epson.print.ActivityViewImageSelect$11 */
  976. static /* synthetic */ class C211111 {
  977. static final /* synthetic */ int[] $SwitchMap$android$os$AsyncTask$Status = new int[AsyncTask.Status.values().length];
  978. /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|6) */
  979. /* JADX WARNING: Code restructure failed: missing block: B:7:?, code lost:
  980. return;
  981. */
  982. /* JADX WARNING: Failed to process nested try/catch */
  983. /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
  984. static {
  985. /*
  986. android.os.AsyncTask$Status[] r0 = android.os.AsyncTask.Status.values()
  987. int r0 = r0.length
  988. int[] r0 = new int[r0]
  989. $SwitchMap$android$os$AsyncTask$Status = r0
  990. int[] r0 = $SwitchMap$android$os$AsyncTask$Status // Catch:{ NoSuchFieldError -> 0x0014 }
  991. android.os.AsyncTask$Status r1 = android.os.AsyncTask.Status.PENDING // Catch:{ NoSuchFieldError -> 0x0014 }
  992. int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x0014 }
  993. r2 = 1
  994. r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x0014 }
  995. L_0x0014:
  996. int[] r0 = $SwitchMap$android$os$AsyncTask$Status // Catch:{ NoSuchFieldError -> 0x001f }
  997. android.os.AsyncTask$Status r1 = android.os.AsyncTask.Status.FINISHED // Catch:{ NoSuchFieldError -> 0x001f }
  998. int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x001f }
  999. r2 = 2
  1000. r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x001f }
  1001. L_0x001f:
  1002. return
  1003. */
  1004. throw new UnsupportedOperationException("Method not decompiled: epson.print.C211111.<clinit>():void");
  1005. }
  1006. }
  1007. protected void onDestroy() {
  1008. EPLog.d("ActivityImageViewSelect", "onDestroy");
  1009. super.onDestroy();
  1010. }
  1011. @MainThread
  1012. private void localUnbindService() {
  1013. IEpsonService iEpsonService = mEpsonService;
  1014. if (iEpsonService != null) {
  1015. try {
  1016. iEpsonService.cancelSearchPrinter();
  1017. mEpsonService.unregisterCallback(mCallback);
  1018. unbindService(mEpsonConnection);
  1019. } catch (RemoteException unused) {
  1020. }
  1021. }
  1022. }
  1023. protected void onPause() {
  1024. EPLog.d("ActivityImageViewSelect", "onPause");
  1025. super.onPause();
  1026. NfcTagUtils.disableForegroundDispatch(this);
  1027. paperSourceInfo.stop();
  1028. if (isFinishing()) {
  1029. localUnbindService();
  1030. ApfPreviewView.deleteWorkingDirectory(this);
  1031. PhotoImageConvertViewModel.clearTempDirectory(this);
  1032. }
  1033. }
  1034. protected void onRestart() {
  1035. EPLog.d("ActivityImageViewSelect", "onRestart");
  1036. super.onRestart();
  1037. }
  1038. public void onBackPressed() {
  1039. if (mStartActivityFromPhoto == 0) {
  1040. Intent intent = new Intent();
  1041. intent.putStringArrayListExtra("imageList", imageList.getArgumentFileList());
  1042. setResult(18, intent);
  1043. } else if (isPrintedOK) {
  1044. setResult(-1);
  1045. } else {
  1046. setResult(0);
  1047. }
  1048. finish();
  1049. }
  1050. private void check3GAndStartPrint() {
  1051. mHandler.sendEmptyMessage(5);
  1052. }
  1053. private void showSimpleDialog(int i) {
  1054. SimpleMessageDialogFragment.newInstance(i).show(getSupportFragmentManager(), "simple-dialog");
  1055. }
  1056. private void unlockScreenRotation() {
  1057. setRequestedOrientation(-1);
  1058. }
  1059. private void startPrint() {
  1060. printButton.setEnabled(false);
  1061. OsAssistant.lockScreenRotation(this);
  1062. ExternalFileUtils.getInstance(this).initPrintDir();
  1063. if (isRemotePrinter) {
  1064. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  1065. edit.putInt(epson.common.Constants.SOURCE_TYPE, 2);
  1066. edit.commit();
  1067. }
  1068. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  1069. printSetting.loadSettings();
  1070. EPImageList imageList2 = previewImageView.getImageList();
  1071. imageList2.apfModeInPrinting = getApfValue(printSetting);
  1072. imageList2.setSharpness(getSharpnessValue(printSetting));
  1073. imageList2.setClearlyVivid(getClearlyVividValue(printSetting));
  1074. imageList2.setMultifileMode(true);
  1075. if (mPrintLog == null) {
  1076. mPrintLog = new PrintLog();
  1077. }
  1078. mPrintLog.previewType = 1;
  1079. startActivityForResult(PrintProgress.getPrintIntent(this, imageList2, false, isEpsonColorMode(), mPrintLog), 255);
  1080. }
  1081. private void addPhotos() {
  1082. PhotoImageSelectActivity.startAddImageSelect(this, imageList.getArgumentFileList());
  1083. }
  1084. public void onClick(View view) {
  1085. switch (view.getId()) {
  1086. case R.id.bt_rotate /*2131230858*/:
  1087. if (isPaperLandscape) {
  1088. isPaperLandscape = false;
  1089. } else {
  1090. isPaperLandscape = true;
  1091. }
  1092. if (currentLayout != 4) {
  1093. new PaperDirectionRotateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
  1094. return;
  1095. }
  1096. return;
  1097. case R.id.btn_add_photo /*2131230867*/:
  1098. if (imageList.size() == 30) {
  1099. new AlertDialog.Builder(this).setMessage(getString(R.string.max_image)).setNegativeButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  1100. public void onClick(DialogInterface dialogInterface, int i) {
  1101. }
  1102. }).create().show();
  1103. return;
  1104. }
  1105. addPhotos();
  1106. finish();
  1107. return;
  1108. case R.id.btn_deselect /*2131230869*/:
  1109. removeCurrentImage();
  1110. return;
  1111. case R.id.btn_paper_size /*2131230874*/:
  1112. if (aPaperSourceSetting != null) {
  1113. Intent intent = new Intent();
  1114. intent.setClass(this, PaperSourceSettingScr.class);
  1115. intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, aPaperSourceSetting);
  1116. intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.photo.name());
  1117. startActivityForResult(intent, CommonDefine.REQUEST_SETTING);
  1118. return;
  1119. }
  1120. callPrintSetting();
  1121. return;
  1122. case R.id.btn_print /*2131230877*/:
  1123. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  1124. if (isRemotePrinter && enableShowWarning) {
  1125. AlertDialog.Builder cancelable = new AlertDialog.Builder(context).setCancelable(false);
  1126. 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() {
  1127. public void onClick(DialogInterface dialogInterface, int i) {
  1128. check3GAndStartPrint();
  1129. }
  1130. }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
  1131. public void onClick(DialogInterface dialogInterface, int i) {
  1132. }
  1133. }).show();
  1134. return;
  1135. } else if (currentPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
  1136. new AlertDialog.Builder(context).setCancelable(false).setTitle(R.string.printer_not_select).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  1137. public void onClick(DialogInterface dialogInterface, int i) {
  1138. }
  1139. }).show();
  1140. return;
  1141. } else {
  1142. check3GAndStartPrint();
  1143. return;
  1144. }
  1145. default:
  1146. return;
  1147. }
  1148. }
  1149. protected void adjustImageNo() {
  1150. if (imageNo >= imageList.size()) {
  1151. imageNo = imageList.size() - 1;
  1152. }
  1153. if (imageNo < 0) {
  1154. imageNo = 0;
  1155. }
  1156. }
  1157. protected void removeCurrentImage() {
  1158. previewImageView.invalidateImageNo();
  1159. int i = imageNo;
  1160. if (i >= 0 && i < imageList.size()) {
  1161. imageList.remove(imageNo);
  1162. imageNo--;
  1163. }
  1164. updateGallery();
  1165. adjustImageNo();
  1166. new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
  1167. }
  1168. protected void updateScreen() {
  1169. if (imageList.size() < 30) {
  1170. addButton.setEnabled(true);
  1171. addButton.setImageResource(R.drawable.plus);
  1172. }
  1173. if (imageList.size() > 0) {
  1174. TextView textView = pageTextView;
  1175. textView.setText((imageNo + 1) + CommonDefine.SLASH + imageList.size());
  1176. gallery.setSelection(imageNo);
  1177. } else {
  1178. deleteButton.setEnabled(false);
  1179. printButton.setEnabled(false);
  1180. pageTextView.setText("0/0");
  1181. }
  1182. if (previewImageView.getIsPaperLandscape()) {
  1183. isPaperLandscape = true;
  1184. } else {
  1185. isPaperLandscape = false;
  1186. }
  1187. Handler handler = mHandler;
  1188. if (handler != null) {
  1189. handler.sendEmptyMessage(2);
  1190. }
  1191. }
  1192. public boolean onOptionsItemSelected(MenuItem menuItem) {
  1193. if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) {
  1194. callPrintSetting();
  1195. }
  1196. return super.onOptionsItemSelected(menuItem);
  1197. }
  1198. public boolean onCreateOptionsMenu(Menu menu) {
  1199. super.onCreateOptionsMenu(menu);
  1200. getMenuInflater().inflate(R.menu.print_menu, menu);
  1201. return true;
  1202. }
  1203. public void callPrintSetting() {
  1204. System.gc();
  1205. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  1206. edit.putInt(epson.common.Constants.SOURCE_TYPE, 2);
  1207. edit.commit();
  1208. startActivityForResult(new Intent(this, SettingScr.class), CommonDefine.REQUEST_SETTING);
  1209. }
  1210. public boolean onKeyDown(int i, KeyEvent keyEvent) {
  1211. if (keyEvent.getAction() == 0 && i == 84) {
  1212. EPLog.e("key search", "diable");
  1213. return true;
  1214. } else if (keyEvent.getAction() != 0 || i != 4) {
  1215. return false;
  1216. } else {
  1217. onBackPressed();
  1218. return true;
  1219. }
  1220. }
  1221. public void onConfigurationChanged(Configuration configuration) {
  1222. super.onConfigurationChanged(configuration);
  1223. }
  1224. protected int getApfValue(PrintSetting printSetting) {
  1225. if (!isRemotePrinter) {
  1226. return printSetting.photoApfValueForLocalPrinter;
  1227. }
  1228. return 0;
  1229. }
  1230. protected int getSharpnessValue(PrintSetting printSetting) {
  1231. if (!isRemotePrinter) {
  1232. return printSetting.sharpnessForPhoto;
  1233. }
  1234. return 0;
  1235. }
  1236. protected int getClearlyVividValue(PrintSetting printSetting) {
  1237. if (!isRemotePrinter) {
  1238. int i = printSetting.paperTypeValue;
  1239. int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
  1240. EPLog.i("setteing = " + i + "plain = " + code);
  1241. return (i == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
  1242. }
  1243. }
  1244. public void onViewSizeChanged() {
  1245. EPLog.d(TAG, "onViewSizeChanged()");
  1246. if (isFinishing()) {
  1247. EPLog.d(TAG, "onViewSizeChanged() isFinishing == true");
  1248. return;
  1249. }
  1250. mOnSizeChangeReceived = true;
  1251. loadImage();
  1252. }
  1253. public void invitationDialogClicked(boolean z) {
  1254. mReviewInvitationViewModel.setStartStoreEnd();
  1255. }
  1256. protected boolean executeAllReloadTaskAgain() {
  1257. synchronized (mAllReloadTaskLock) {
  1258. if (!mIsAllReloadTaskRetryAcceptable) {
  1259. return false;
  1260. }
  1261. mAllReloadTaskRetryRequested = true;
  1262. return true;
  1263. }
  1264. }
  1265. protected boolean lastCheckAllReloadTaskRetryRequest() {
  1266. synchronized (mAllReloadTaskLock) {
  1267. if (mAllReloadTaskRetryRequested) {
  1268. return true;
  1269. }
  1270. mIsAllReloadTaskRetryAcceptable = false;
  1271. return false;
  1272. }
  1273. }
  1274. private void showDialog(String r4) {
  1275. throw new UnsupportedOperationException("Method not decompiled: epson.print.showDialog(java.lang.String):void");
  1276. }
  1277. private void dismissDialog(String str) {
  1278. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
  1279. if (dialogFragment != null) {
  1280. dialogFragment.dismiss();
  1281. }
  1282. }
  1283. private class AllReloadTask extends AsyncTaskExecutor<Void, Integer, Boolean> {
  1284. private Context context = null;
  1285. private volatile boolean endRedraw = false;
  1286. private boolean firstDraw = true;
  1287. Handler handler = new Handler(new Handler.Callback() {
  1288. public boolean handleMessage(Message message) {
  1289. if (message.what == 4) {
  1290. EPLog.i(TAG, "handleMessage(): msg.arg1 = " + message.arg1 + ", index = " + AllReloadTask.index);
  1291. if (AllReloadTask.firstDraw) {
  1292. boolean unused = AllReloadTask.firstDraw = false;
  1293. }
  1294. boolean unused2 = AllReloadTask.endRedraw = true;
  1295. }
  1296. return true;
  1297. }
  1298. });
  1299. private int index = 0;
  1300. private boolean mDeletePreview;
  1301. public AllReloadTask(Context context2) {
  1302. context = context2;
  1303. }
  1304. public AsyncTask<Void, Integer, Boolean> executeOnExecutor(Void... voidArr) {
  1305. if (executeAllReloadTaskAgain()) {
  1306. return null;
  1307. }
  1308. mIsAllReloadTaskRetryAcceptable = true;
  1309. return super.executeOnExecutor(voidArr);
  1310. }
  1311. protected void onPreExecute() {
  1312. mModelDialog.doShow(DIALOG_ALL_UPDATE);
  1313. imageList.clearExceptSrcFileName();
  1314. previewImageView.setDrawEndHandler(handler);
  1315. }
  1316. protected Boolean doInBackground(Void... voidArr) {
  1317. System.gc();
  1318. int i = 0;
  1319. do {
  1320. try {
  1321. if (mEpsonService != null) {
  1322. break;
  1323. }
  1324. Thread.sleep(100);
  1325. i++;
  1326. } catch (RemoteException e) {
  1327. e.printStackTrace();
  1328. } catch (InterruptedException e2) {
  1329. e2.printStackTrace();
  1330. }
  1331. } while (i < 100);
  1332. if (mEpsonService != null) {
  1333. if (isRemotePrinter) {
  1334. mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.photo.name());
  1335. } else {
  1336. mEpsonService.updatePrinterSettings(PrintSetting.Kind.photo.name());
  1337. }
  1338. }
  1339. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  1340. printSetting.loadSettings();
  1341. int unused = currentPaperSize = printSetting.paperSizeValue;
  1342. int unused2 = currentLayout = printSetting.layoutValue;
  1343. int unused3 = currentLayoutMulti = printSetting.layoutMultiPageValue;
  1344. int unused4 = currentColor = printSetting.colorValue;
  1345. previewImageView.setLayout(currentLayout, currentLayoutMulti);
  1346. previewImageView.setPaper(currentPaperSize);
  1347. previewImageView.setColor(currentColor);
  1348. previewImageView.setApfLibParams(getApfValue(printSetting), getSharpnessValue(printSetting), getClearlyVividValue(printSetting));
  1349. mHandler.sendEmptyMessage(6);
  1350. do {
  1351. boolean unused5 = mAllReloadTaskRetryRequested = false;
  1352. previewImageView.setPaper(currentPaperSize);
  1353. updatePreviewImage();
  1354. } while (lastCheckAllReloadTaskRetryRequest());
  1355. boolean unused6 = mAllReloadTaskDone = true;
  1356. return true;
  1357. }
  1358. private void updatePreviewImage() {
  1359. previewImageView.invalidateImageNo();
  1360. previewImageView.invalidatePreview();
  1361. index = 0;
  1362. while (index < imageList.size()) {
  1363. EPLog.i(TAG, "doInBack Start -> " + index);
  1364. while (!mAllReloadTaskRetryRequested) {
  1365. try {
  1366. if (previewImageView.setImage(index, 2, this)) {
  1367. endRedraw = false;
  1368. publishProgress(new Integer[]{Integer.valueOf(index + 1)});
  1369. int i = 0;
  1370. while (true) {
  1371. if (endRedraw) {
  1372. break;
  1373. }
  1374. Thread.sleep(100, 0);
  1375. i++;
  1376. if (i >= 50) {
  1377. break;
  1378. }
  1379. }
  1380. EPLog.i(TAG, "doInBack End -> " + index);
  1381. index++;
  1382. } else {
  1383. Thread.sleep(300);
  1384. }
  1385. } catch (InterruptedException e) {
  1386. e.printStackTrace();
  1387. } catch (OutOfMemoryError unused) {
  1388. imageList.remove(index);
  1389. index--;
  1390. mDeletePreview = true;
  1391. if (mAllReloadTaskDone) {
  1392. mHandler.sendEmptyMessage(8);
  1393. int unused2 = imageNo = 0;
  1394. } else {
  1395. mHandler.sendEmptyMessage(7);
  1396. }
  1397. }
  1398. }
  1399. return;
  1400. }
  1401. if (imageList.size() > 0) {
  1402. showCurrentImage();
  1403. return;
  1404. }
  1405. try {
  1406. previewImageView.setImage(0, 2, this);
  1407. } catch (OutOfMemoryError unused3) {
  1408. }
  1409. }
  1410. private void showCurrentImage() {
  1411. boolean z = false;
  1412. while (true) {
  1413. try {
  1414. previewImageView.setImage(imageNo, 0, this);
  1415. return;
  1416. } catch (OutOfMemoryError unused) {
  1417. if (!z) {
  1418. mHandler.sendEmptyMessage(8);
  1419. }
  1420. z = true;
  1421. if (imageList.size() > 0) {
  1422. if (imageNo >= 0 && imageNo < imageList.size()) {
  1423. imageList.remove(imageNo);
  1424. }
  1425. int unused2 = imageNo = 0;
  1426. } else {
  1427. return;
  1428. }
  1429. }
  1430. }
  1431. }
  1432. private boolean testCheckStatus() {
  1433. try {
  1434. Thread.sleep(1000);
  1435. } catch (InterruptedException e) {
  1436. e.printStackTrace();
  1437. }
  1438. return mAllReloadTaskRetryRequested;
  1439. }
  1440. protected void onProgressUpdate(Integer... numArr) {
  1441. previewImageView.invalidate();
  1442. TextView access$1900 = pageTextView;
  1443. access$1900.setText(numArr[0] + CommonDefine.SLASH + imageList.size());
  1444. if (previewImageView.getIsPaperLandscape()) {
  1445. boolean unused = isPaperLandscape = true;
  1446. } else {
  1447. boolean unused2 = isPaperLandscape = false;
  1448. }
  1449. }
  1450. protected void onPostExecute(Boolean bool) {
  1451. if (!isFinishing()) {
  1452. if (mDeletePreview) {
  1453. updateGallery();
  1454. }
  1455. previewImageView.invalidate();
  1456. updateScreen();
  1457. previewImageView.setDrawEndHandler((Handler) null);
  1458. mModelDialog.doDismiss(DIALOG_ALL_UPDATE);
  1459. if (bAutoStartPrint) {
  1460. ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
  1461. onClick(printButton);
  1462. EPLog.d(TAG, "onClick(printButton)");
  1463. bAutoStartPrint = false;
  1464. }
  1465. }
  1466. }
  1467. }
  1468. private class PreviewImageSelectTask extends AsyncTaskExecutor<Void, Void, Void> {
  1469. private boolean mError;
  1470. private PreviewImageSelectTask() {
  1471. }
  1472. protected Void doInBackground(Void... voidArr) {
  1473. boolean z = false;
  1474. while (true) {
  1475. try {
  1476. previewImageView.setImage(imageNo, 0, ActivityViewImageSelect.this);
  1477. return null;
  1478. } catch (OutOfMemoryError unused) {
  1479. mError = true;
  1480. if (!z) {
  1481. mHandler.sendEmptyMessage(8);
  1482. }
  1483. if (imageList.size() <= 0) {
  1484. return null;
  1485. }
  1486. if (imageNo >= 0 && imageNo < imageList.size()) {
  1487. imageList.remove(imageNo);
  1488. }
  1489. int unused2 = imageNo = 0;
  1490. z = true;
  1491. }
  1492. }
  1493. }
  1494. protected void onPreExecute() {
  1495. mModelDialog.doShow(DIALOG_PROGRESS);
  1496. }
  1497. protected void onPostExecute(Void voidR) {
  1498. if (!isFinishing()) {
  1499. if (mError) {
  1500. updateGallery();
  1501. }
  1502. previewImageView.invalidate();
  1503. updateScreen();
  1504. mModelDialog.doDismiss(DIALOG_PROGRESS);
  1505. }
  1506. }
  1507. }
  1508. private class PaperDirectionRotateTask extends AsyncTask<Void, Void, Void> {
  1509. private PaperDirectionRotateTask() {
  1510. }
  1511. protected void onPreExecute() {
  1512. mModelDialog.doShow(DIALOG_PROGRESS);
  1513. }
  1514. protected void onPostExecute(Void voidR) {
  1515. if (!isFinishing()) {
  1516. mModelDialog.doDismiss(DIALOG_PROGRESS);
  1517. }
  1518. }
  1519. protected Void doInBackground(Void... voidArr) {
  1520. previewImageView.setIsPaperLandscape(isPaperLandscape, ActivityViewImageSelect.this);
  1521. return null;
  1522. }
  1523. }
  1524. }