PhotoCopyImageSelectActivity.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. package com.epson.memcardacc;
  2. import android.content.Context;
  3. import android.content.Intent;
  4. import android.os.Build;
  5. import android.os.Bundle;
  6. import androidx.annotation.NonNull;
  7. import androidx.annotation.Nullable;
  8. import androidx.fragment.app.FragmentActivity;
  9. import androidx.lifecycle.Observer;
  10. import java.util.ArrayList;
  11. import epson.print.R;
  12. import epson.print.imgsel.ImageFinder;
  13. import epson.print.imgsel.ImageSelectActivity;
  14. import epson.print.imgsel.JpegHeifImageFinder;
  15. import epson.print.imgsel.JpegImageFinder;
  16. public class PhotoCopyImageSelectActivity extends ImageSelectActivity implements AltAlertDialogFragment.DialogCallback {
  17. public static final String DIALOG_FRAGMENT_TAG_PROGRESS = "progress";
  18. private static final int REQUEST_CODE_EXEC_MEMCARD_WRITE = 106;
  19. private static final String SAVED_INSTANCE_STATE_KEY_WAITING_FOR_TRANSFER_END = "WaitingForTransferEnd";
  20. private DialogType mDialogType;
  21. private final Observer<FileConvertViewModel.FileConvertStatus> mFileConvertStateObserver = new Observer<FileConvertViewModel.FileConvertStatus>() {
  22. public void onChanged(@Nullable FileConvertViewModel.FileConvertStatus fileConvertStatus) {
  23. onStateChanged(fileConvertStatus);
  24. }
  25. };
  26. private FileConvertViewModel mFileConvertViewModel;
  27. private boolean mWaitingForTransferEnd;
  28. public int getMessageType() {
  29. return 1;
  30. }
  31. public void onPositiveCallback() {
  32. }
  33. public boolean singleImageMode() {
  34. return true;
  35. }
  36. private void onStateChanged(@Nullable FileConvertViewModel.FileConvertStatus fileConvertStatus) {
  37. if (fileConvertStatus == null) {
  38. hideProgress();
  39. return;
  40. }
  41. switch (fileConvertStatus.getConvertStatus()) {
  42. case TASK_RUNNING:
  43. showProgress();
  44. return;
  45. case TASK_END:
  46. hideProgress();
  47. onConvertEnd(fileConvertStatus.getErrorType(), fileConvertStatus.getConvertFileList());
  48. return;
  49. default:
  50. hideProgress();
  51. return;
  52. }
  53. }
  54. public ImageFinder getImageFinder() {
  55. if (Build.VERSION.SDK_INT >= 28) {
  56. return new JpegHeifImageFinder();
  57. }
  58. return new JpegImageFinder();
  59. }
  60. protected void onCreate(Bundle bundle) {
  61. super.onCreate(bundle);
  62. mWaitingForTransferEnd = false;
  63. if (bundle != null) {
  64. mWaitingForTransferEnd = bundle.getBoolean(SAVED_INSTANCE_STATE_KEY_WAITING_FOR_TRANSFER_END);
  65. }
  66. mFileConvertViewModel = (FileConvertViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(FileConvertViewModel.class);
  67. mFileConvertViewModel.getData().observe(this, mFileConvertStateObserver);
  68. }
  69. protected void onActivityResult(int i, int i2, Intent intent) {
  70. super.onActivityResult(i, i2, intent);
  71. if (i == 106) {
  72. mWaitingForTransferEnd = false;
  73. FileConvertTask.initTempDirectory();
  74. if (i2 == -2) {
  75. finish();
  76. } else if (i2 != 0) {
  77. mDialogType = new DialogType(112);
  78. if (intent != null) {
  79. mDialogType.mErrorCode = intent.getIntExtra(MemcardWriteProgress.RESULT_KEY_CIFS_ERROR_CODE, 0);
  80. } else {
  81. mDialogType.mErrorCode = 0;
  82. }
  83. clearSelectFile();
  84. } else {
  85. clearSelectFile();
  86. }
  87. }
  88. }
  89. protected void onPostResume() {
  90. super.onPostResume();
  91. DialogType dialogType = mDialogType;
  92. if (dialogType != null) {
  93. localShowDialog(dialogType);
  94. mDialogType = null;
  95. }
  96. }
  97. protected void localShowDialog(DialogType dialogType) {
  98. dialogType.getDialogFragment(this).show(getSupportFragmentManager(), "dialog");
  99. }
  100. protected void onSaveInstanceState(Bundle bundle) {
  101. super.onSaveInstanceState(bundle);
  102. bundle.putBoolean(SAVED_INSTANCE_STATE_KEY_WAITING_FOR_TRANSFER_END, mWaitingForTransferEnd);
  103. }
  104. protected void clearSelectFile() {
  105. refreshSelector(new ArrayList());
  106. }
  107. protected void goNext() {
  108. ArrayList<String> fileArrayList = getImageSelector().getFileArrayList();
  109. if (fileArrayList.size() > 0) {
  110. mFileConvertViewModel.startConvert(fileArrayList);
  111. }
  112. }
  113. private void startWriteProgressActivity(@NonNull ArrayList<String> arrayList) {
  114. Intent intent = new Intent(this, PhotoCopyWriteProgress.class);
  115. intent.putStringArrayListExtra("imageList", arrayList);
  116. intent.putExtra("target_folder_name", "");
  117. intent.putExtra(MemcardWriteProgress.KEY_CIFS_STORAGE_TYPE, 2);
  118. intent.putExtra(MemcardWriteProgress.KEY_CHECK_WIFI_DIRECT, true);
  119. ArrayList arrayList2 = new ArrayList();
  120. arrayList2.add(MemcardConfig.PHOTO_COPY_WRITE_FILE_NAME);
  121. intent.putStringArrayListExtra(MemcardWriteProgress.KEY_WRITE_FILE_LIST, arrayList2);
  122. startActivityForResult(intent, 106);
  123. }
  124. private static class DialogType {
  125. public static final int DIALOG_COPY_RESULT_CANCELED = 111;
  126. public static final int DIALOG_FILE_SIZE_OVER = 113;
  127. public static final int DIALOG_GENERIC_ERROR = 112;
  128. public static final int DIALOG_NO_DIALOG = 0;
  129. private int mDialogCode;
  130. public int mErrorCode;
  131. public DialogType(int i) {
  132. mDialogCode = i;
  133. }
  134. public AltAlertDialogFragment getDialogFragment(Context context) {
  135. String str = "";
  136. String str2 = null;
  137. switch (mDialogCode) {
  138. case 111:
  139. str = context.getString(R.string.memcard_file_read_error_message);
  140. break;
  141. case 112:
  142. int i = mErrorCode;
  143. if (i == 5) {
  144. str2 = context.getString(R.string.memcard_capacity_shortage_error_title);
  145. str = context.getString(R.string.mcphotocopy_capacity_shortage_error_message);
  146. break;
  147. } else {
  148. switch (i) {
  149. case 1:
  150. str2 = context.getString(R.string.memcard_comm_error_title);
  151. str = context.getString(R.string.memcard_comm_error_message);
  152. break;
  153. case 2:
  154. str2 = context.getString(R.string.EPS_PRNST_BUSY_TITLE);
  155. str = context.getString(R.string.EPS_PRNST_BUSY_MSG);
  156. break;
  157. case 3:
  158. str2 = context.getString(R.string.mcphotocopy_media_not_found_title);
  159. str = context.getString(R.string.mcphotocopy_media_not_found_message);
  160. break;
  161. default:
  162. str2 = context.getString(R.string.memcard_file_write_error_title);
  163. str = context.getString(R.string.mcphotocopy_file_write_error_message);
  164. break;
  165. }
  166. }
  167. case 113:
  168. str = context.getString(R.string.mcphotocopy_file_size_over_message);
  169. break;
  170. }
  171. return AltAlertDialogFragment.newInstance(str2, str);
  172. }
  173. }
  174. @Nullable
  175. private LocalProgressDialogFragment getProgressDialog() {
  176. return (LocalProgressDialogFragment) getSupportFragmentManager().findFragmentByTag("progress");
  177. }
  178. private void showProgress() {
  179. LocalProgressDialogFragment progressDialog = getProgressDialog();
  180. if (progressDialog != null) {
  181. progressDialog.dismiss();
  182. }
  183. LocalProgressDialogFragment.newInstance(R.string.convert_google_docs_convert).show(getSupportFragmentManager(), "progress");
  184. }
  185. private void hideProgress() {
  186. LocalProgressDialogFragment progressDialog = getProgressDialog();
  187. if (progressDialog != null) {
  188. progressDialog.dismiss();
  189. }
  190. }
  191. private void onConvertEnd(@NonNull FileConvertTask.ErrorType errorType, @Nullable ArrayList<String> arrayList) {
  192. if (errorType != FileConvertTask.ErrorType.NO_ERROR) {
  193. localShowDialog(new DialogType(getErrorDialogType(errorType)));
  194. clearSelectFile();
  195. } else if (arrayList != null) {
  196. mWaitingForTransferEnd = true;
  197. startWriteProgressActivity(arrayList);
  198. }
  199. }
  200. /* renamed from: com.epson.memcardacc.PhotoCopyImageSelectActivity$2 */
  201. static /* synthetic */ class C10012 {
  202. static final /* synthetic */ int[] $SwitchMap$com$epson$memcardacc$FileConvertTask$ErrorType = new int[FileConvertTask.ErrorType.values().length];
  203. /* JADX WARNING: Failed to process nested try/catch */
  204. /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x0027 */
  205. static {
  206. /*
  207. com.epson.memcardacc.FileConvertTask$ErrorType[] r0 = com.epson.memcardacc.FileConvertTask.ErrorType.values()
  208. int r0 = r0.length
  209. int[] r0 = new int[r0]
  210. $SwitchMap$com$epson$memcardacc$FileConvertTask$ErrorType = r0
  211. r0 = 1
  212. int[] r1 = $SwitchMap$com$epson$memcardacc$FileConvertTask$ErrorType // Catch:{ NoSuchFieldError -> 0x0014 }
  213. com.epson.memcardacc.FileConvertTask$ErrorType r2 = com.epson.memcardacc.FileConvertTask.ErrorType.FILE_SIZE_ERROR // Catch:{ NoSuchFieldError -> 0x0014 }
  214. int r2 = r2.ordinal() // Catch:{ NoSuchFieldError -> 0x0014 }
  215. r1[r2] = r0 // Catch:{ NoSuchFieldError -> 0x0014 }
  216. L_0x0014:
  217. com.epson.memcardacc.FileConvertViewModel$ConvertStatus[] r1 = com.epson.memcardacc.FileConvertViewModel.ConvertStatus.values()
  218. int r1 = r1.length
  219. int[] r1 = new int[r1]
  220. f142x5e194216 = r1
  221. int[] r1 = f142x5e194216 // Catch:{ NoSuchFieldError -> 0x0027 }
  222. com.epson.memcardacc.FileConvertViewModel$ConvertStatus r2 = com.epson.memcardacc.FileConvertViewModel.ConvertStatus.TASK_RUNNING // Catch:{ NoSuchFieldError -> 0x0027 }
  223. int r2 = r2.ordinal() // Catch:{ NoSuchFieldError -> 0x0027 }
  224. r1[r2] = r0 // Catch:{ NoSuchFieldError -> 0x0027 }
  225. L_0x0027:
  226. int[] r0 = f142x5e194216 // Catch:{ NoSuchFieldError -> 0x0032 }
  227. com.epson.memcardacc.FileConvertViewModel$ConvertStatus r1 = com.epson.memcardacc.FileConvertViewModel.ConvertStatus.TASK_END // Catch:{ NoSuchFieldError -> 0x0032 }
  228. int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x0032 }
  229. r2 = 2
  230. r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x0032 }
  231. L_0x0032:
  232. return
  233. */
  234. throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.PhotoCopyImageSelectActivity.C10012.<clinit>():void");
  235. }
  236. }
  237. private int getErrorDialogType(FileConvertTask.ErrorType errorType) {
  238. return C10012.$SwitchMap$com$epson$memcardacc$FileConvertTask$ErrorType[errorType.ordinal()] != 1 ? 112 : 113;
  239. }
  240. }