PhotoCopyImageSelectActivity.java 12 KB

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