ActivityViewImageSelect.java 65 KB

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