CropImageActivity.java 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  1. package com.epson.cameracopy.ui;
  2. import android.annotation.SuppressLint;
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.arch.lifecycle.Observer;
  6. import android.arch.lifecycle.ViewModelProviders;
  7. import android.content.ContentValues;
  8. import android.content.Context;
  9. import android.content.DialogInterface;
  10. import android.content.Intent;
  11. import android.content.res.Configuration;
  12. import android.graphics.Bitmap;
  13. import android.graphics.Color;
  14. import android.graphics.Point;
  15. import android.graphics.PointF;
  16. import android.net.Uri;
  17. import android.os.Bundle;
  18. import android.os.Debug;
  19. import android.os.Environment;
  20. import android.os.Handler;
  21. import android.os.Message;
  22. import android.provider.MediaStore;
  23. import android.support.p000v4.app.DialogFragment;
  24. import android.support.p000v4.app.FragmentActivity;
  25. import android.text.TextUtils;
  26. import android.util.AttributeSet;
  27. import android.util.DisplayMetrics;
  28. import android.util.Log;
  29. import android.view.GestureDetector;
  30. import android.view.MotionEvent;
  31. import android.view.View;
  32. import android.view.ViewGroup;
  33. import android.widget.Button;
  34. import android.widget.FrameLayout;
  35. import android.widget.LinearLayout;
  36. import android.widget.RadioButton;
  37. import android.widget.RadioGroup;
  38. import android.widget.RelativeLayout;
  39. import android.widget.SeekBar;
  40. import android.widget.TextView;
  41. import android.widget.Toast;
  42. import com.epson.cameracopy.alt.UiCommon;
  43. import com.epson.cameracopy.device.CameraPreviewControl;
  44. import com.epson.cameracopy.printlayout.DocumentSizeInfo;
  45. import com.epson.cameracopy.printlayout.RegistedDocumentSizeList;
  46. import com.epson.mobilephone.common.EpLog;
  47. import epson.colorcorrection.ImageCollect;
  48. import epson.common.DialogProgress;
  49. import epson.common.DialogProgressViewModel;
  50. import epson.common.ExternalFileUtils;
  51. import epson.common.Info_paper;
  52. import epson.print.ActivityIACommon;
  53. import epson.print.ActivityRequestPermissions;
  54. import epson.print.CommonDefine;
  55. import java.io.File;
  56. import java.lang.ref.WeakReference;
  57. import java.util.ArrayList;
  58. import java.util.Deque;
  59. import java.util.List;
  60. import java.util.Locale;
  61. import org.opencv.core.Size;
  62. /* renamed from: com.epson.cameracopy.ui.CropImageActivity */
  63. public class CropImageActivity extends ActivityIACommon implements View.OnClickListener, SeekBar.OnSeekBarChangeListener, View.OnTouchListener, GestureDetector.OnDoubleTapListener {
  64. private static final int ACTIVITY_MODE_COLOR_ADJUSTMENT = 2;
  65. private static final int ACTIVITY_MODE_CROP_IMAGE = 0;
  66. private static final int ACTIVITY_MODE_ENHANCE_TEXT = 1;
  67. private static final String DIALOG_PROGRESS = "dialog_progress";
  68. private static final String ICPD_FOLDER_PRINT_DATA = "ic";
  69. public static final String IMAGE_FILE_NAME = "image_file_name";
  70. private static final int MESSAGE_BOX_TYPE_CANCEL = 103;
  71. private static final int MESSAGE_BOX_TYPE_OK = 102;
  72. private static final int MESSAGE_BOX_TYPE_YES_NO = 101;
  73. private static final int MSG_DEBUG_MODE = 390;
  74. private static final int MSG_DEBUG_RESOLUTION_THRESHOLD = 391;
  75. private static final int MSG_DEBUG_SMALL_PREVIEW_RATE = 392;
  76. private static final int MSG_PREVIEW_CROP = 801;
  77. public static final int MSG_PREVIEW_EDGE_DETECTION = 301;
  78. private static final int MSG_PREVIEW_LOAD_DIALOG_DISMISS = 902;
  79. private static final int MSG_PREVIEW_LOAD_DIALOG_SHOW = 901;
  80. private static final int MSG_PREVIEW_LOAD_FINISH = 912;
  81. private static final int MSG_PREVIEW_LOAD_PHOTO = 911;
  82. private static final int MSG_PREVIEW_PRINT_PREVIEW_EXECUTE = 841;
  83. private static final int MSG_PREVIEW_PRINT_PREVIEW_FINISH = 842;
  84. private static final int MSG_PREVIEW_SAVE_EXECUTE = 831;
  85. private static final int MSG_PREVIEW_SAVE_FINISH = 832;
  86. public static final int MSG_PREVIEW_TOUCH_EVENT_ACTION_DOWN = 311;
  87. private static final int MSG_SDIC_BCSC_FIX_CANCEL = 825;
  88. private static final int MSG_SDIC_BCSC_FIX_PROC = 824;
  89. private static final int MSG_SDIC_BCSC_FIX_QUIT = 826;
  90. private static final int MSG_SDIC_BCSC_RESET = 823;
  91. private static final int MSG_SDIC_PWC_EXECUTE = 811;
  92. private static final int MSG_SDIC_PWC_FINISH = 812;
  93. private static final int REQUEST_CODE_ORG_PAPER_SIZE_SELECT = 3;
  94. private static final int REQUEST_RUNTIMEPERMMISSION = 4;
  95. public static final String RESULT_COLLECTED_FILE_NAME = "corrected_file_name";
  96. private static final int SEEK_BAR_STEP = 10;
  97. private static WeakReference<Activity> mActivity;
  98. private static CropImageActivity mCropImageActivity;
  99. private static Handler mHandler = new Handler() {
  100. public void handleMessage(Message message) {
  101. if (CropImageActivity.mCropImageActivity != null) {
  102. CropImageActivity.mCropImageActivity.executeMessage(message);
  103. }
  104. }
  105. };
  106. private int mActivityMode;
  107. private float mBcscBDefault;
  108. private float mBcscBValue;
  109. private float mBcscCDefault;
  110. private float mBcscCValue;
  111. private float mBcscSDefault;
  112. private float mBcscSValue;
  113. private int mBcscSeekBarBDefault;
  114. private int mBcscSeekBarCDefault;
  115. private int mBcscSeekBarSDefault;
  116. private int mBcscType;
  117. private Bitmap mBitmapPreview = null;
  118. private Button mButtonColorAdjustment;
  119. private Button mButtonDocSize;
  120. private Button mButtonExecute;
  121. private Button mButtonReset;
  122. private Button mButtonSave;
  123. private File mCacheFolder = null;
  124. private List<CorrectionParamSet> mCorrectionHistory = null;
  125. private CorrectionParamSet mCorrectionParamSet = null;
  126. private FrameLayout mCropImageFrameLayout = null;
  127. private View mCropImageHeader = null;
  128. boolean mCropImageMessageShow = true;
  129. private int mCurrentPaperId = 0;
  130. Size mCurrentPaperSize = null;
  131. private CustomToast mCustomToast = null;
  132. private DaemonView mDaemonView = null;
  133. private int mDebugID = 0;
  134. private int mDebugMode = 0;
  135. private int mDebugResolutionThreshold = 2;
  136. private int mDebugSmallPreviewRate = 2;
  137. Size mDeviceSize = null;
  138. DocumentSizeInfo mDocumentSizeInfo = null;
  139. private GestureDetector mGestureDetector = null;
  140. private ImageCollect mImageCollect = null;
  141. private LinearLayout mImageCollectAdjustmentBrightness = null;
  142. private SeekBar mImageCollectAdjustmentBrightnessSeekBar = null;
  143. private TextView mImageCollectAdjustmentBrightnessTitle = null;
  144. private LinearLayout mImageCollectAdjustmentContrast = null;
  145. private SeekBar mImageCollectAdjustmentContrastSeekBar = null;
  146. private TextView mImageCollectAdjustmentContrastTitle = null;
  147. private LinearLayout mImageCollectAdjustmentSaturation = null;
  148. private SeekBar mImageCollectAdjustmentSaturationSeekBar = null;
  149. private TextView mImageCollectAdjustmentSaturationTitle = null;
  150. private RadioGroup mImageCollectAdjustmentSwitch = null;
  151. private int mImageCollectAdjustmentSwitchId;
  152. private RadioButton mImageCollectAdjustmentSwitchLeft = null;
  153. private RadioButton mImageCollectAdjustmentSwitchRight = null;
  154. private RelativeLayout mImageCollectLayout = null;
  155. private Button mImageCollectPalletButton = null;
  156. private LinearLayout mImageCollectPalletLayout = null;
  157. private TextView mImageCollectPaperSizeInfo = null;
  158. private LinearLayout mImageCollectPreviewLayout = null;
  159. private RadioGroup mImageCollectSwitch = null;
  160. private int mImageCollectSwitchId;
  161. private LinearLayout mImageCollectSwitchLayout = null;
  162. private RadioButton mImageCollectSwitchLeft = null;
  163. private RadioButton mImageCollectSwitchMiddle = null;
  164. private RadioButton mImageCollectSwitchRight = null;
  165. private ImageCollectView mImageCollectView = null;
  166. private int mImageType = 2;
  167. Info_paper mInfoPaper = null;
  168. private int mMaskType;
  169. private AlertDialog mMessageDialog = null;
  170. private DisplayMetrics mMetrics = null;
  171. private DialogProgressViewModel mModelDialog;
  172. private double mPaperHeight = 0.0d;
  173. private int mPaperId = -999;
  174. Size mPaperSize = null;
  175. private double mPaperWidth = 0.0d;
  176. private PointF[] mPointPreviewCropPoint = null;
  177. private int mPreviewType;
  178. private DialogProgress mProgressDialog = null;
  179. private boolean[] mSaveApprovalTable = null;
  180. private LinearLayout mToolBartLayout = null;
  181. private LinearLayout mToolbarColorAdjustment = null;
  182. private LinearLayout mToolbarCropImage = null;
  183. private LinearLayout mToolbarEnhanceText = null;
  184. private File mUserFolder = null;
  185. private final GestureDetector.SimpleOnGestureListener onGestureDetectorListener = new GestureDetector.SimpleOnGestureListener() {
  186. public void onLongPress(MotionEvent motionEvent) {
  187. if (CropImageActivity.mDebugMode == 4) {
  188. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_DEBUG_MODE);
  189. }
  190. super.onLongPress(motionEvent);
  191. }
  192. };
  193. public boolean onDoubleTapEvent(MotionEvent motionEvent) {
  194. return false;
  195. }
  196. public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
  197. return false;
  198. }
  199. public void onStartTrackingTouch(SeekBar seekBar) {
  200. }
  201. public void onStopTrackingTouch(SeekBar seekBar) {
  202. }
  203. protected void onCreate(Bundle bundle) {
  204. super.onCreate(bundle);
  205. setContentView((int) R.layout.activity_crop_image);
  206. mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
  207. mModelDialog.getDialogJob().observe(this, new Observer() {
  208. public final void onChanged(Object obj) {
  209. CropImageActivity.lambda$onCreate$0(CropImageActivity.this, (Deque) obj);
  210. }
  211. });
  212. setActionBar((int) R.string.crop_image_title, true);
  213. mActivity = new WeakReference<>(this);
  214. mCropImageActivity = (CropImageActivity) mActivity.get();
  215. mModelDialog.doShow(DIALOG_PROGRESS);
  216. mPaperSize = new Size(0.0d, 0.0d);
  217. GetPaperInfo();
  218. mDaemonView = new DaemonView(this);
  219. mCropImageFrameLayout = (FrameLayout) findViewById(R.id.crop_image_frame_layout);
  220. mCropImageFrameLayout.addView(mDaemonView);
  221. mImageCollectLayout = (RelativeLayout) findViewById(R.id.ImageCollectLayout);
  222. mImageCollectPreviewLayout = (LinearLayout) findViewById(R.id.ImageCollectPreviewLayout);
  223. mImageCollectView = (ImageCollectView) mImageCollectPreviewLayout.findViewById(R.id.ImageCollectView);
  224. mImageCollectView.SetHandler(mHandler);
  225. mImageCollectPaperSizeInfo = (TextView) mImageCollectPreviewLayout.findViewById(R.id.ImageCollectPaperSizeInfo);
  226. mImageCollectPaperSizeInfo.setSingleLine(true);
  227. mImageCollectPaperSizeInfo.setEllipsize(TextUtils.TruncateAt.END);
  228. mImageCollectPaperSizeInfo.setText(getDocumentSizeText());
  229. mImageCollectPalletButton = (Button) mImageCollectPreviewLayout.findViewById(R.id.ImageCollectPalletButton);
  230. mImageCollectPalletButton.setOnClickListener(this);
  231. mImageCollectPalletButton.setVisibility(4);
  232. mImageCollectSwitchLayout = (LinearLayout) findViewById(R.id.ImageCollectSwitchLayout);
  233. mImageCollectSwitch = (RadioGroup) findViewById(R.id.ImageCollectSwitch);
  234. mImageCollectSwitchLeft = (RadioButton) findViewById(R.id.ImageCollectSwitchLeft);
  235. mImageCollectSwitchLeft.setOnClickListener(this);
  236. mImageCollectSwitchMiddle = (RadioButton) findViewById(R.id.ImageCollectSwitchMiddle);
  237. mImageCollectSwitchMiddle.setOnClickListener(this);
  238. mImageCollectSwitchRight = (RadioButton) findViewById(R.id.ImageCollectSwitchRight);
  239. mImageCollectSwitchRight.setOnClickListener(this);
  240. mImageCollectPalletLayout = (LinearLayout) findViewById(R.id.ImageCollectPalletLayout);
  241. mImageCollectAdjustmentBrightness = (LinearLayout) findViewById(R.id.ImageCollectAdjustmentBrightness);
  242. mImageCollectAdjustmentBrightnessTitle = (TextView) mImageCollectAdjustmentBrightness.findViewById(R.id.AdjustmentBarTitle);
  243. mImageCollectAdjustmentBrightnessTitle.setText(R.string.brightness);
  244. mImageCollectAdjustmentBrightnessSeekBar = (SeekBar) mImageCollectAdjustmentBrightness.findViewById(R.id.AdjustmentBarSeekBar);
  245. mImageCollectAdjustmentBrightnessSeekBar.setOnSeekBarChangeListener(this);
  246. mImageCollectAdjustmentContrast = (LinearLayout) findViewById(R.id.ImageCollectAdjustmentContrast);
  247. mImageCollectAdjustmentContrastTitle = (TextView) mImageCollectAdjustmentContrast.findViewById(R.id.AdjustmentBarTitle);
  248. mImageCollectAdjustmentContrastTitle.setText(R.string.contrast);
  249. mImageCollectAdjustmentContrastSeekBar = (SeekBar) mImageCollectAdjustmentContrast.findViewById(R.id.AdjustmentBarSeekBar);
  250. mImageCollectAdjustmentContrastSeekBar.setOnSeekBarChangeListener(this);
  251. mImageCollectAdjustmentSaturation = (LinearLayout) findViewById(R.id.ImageCollectAdjustmentSaturation);
  252. mImageCollectAdjustmentSaturationTitle = (TextView) mImageCollectAdjustmentSaturation.findViewById(R.id.AdjustmentBarTitle);
  253. mImageCollectAdjustmentSaturationTitle.setText(R.string.saturation);
  254. mImageCollectAdjustmentSaturationSeekBar = (SeekBar) mImageCollectAdjustmentSaturation.findViewById(R.id.AdjustmentBarSeekBar);
  255. mImageCollectAdjustmentSaturationSeekBar.setOnSeekBarChangeListener(this);
  256. mImageCollectAdjustmentSwitch = (RadioGroup) findViewById(R.id.AdjustmentModeSwitch);
  257. mImageCollectAdjustmentSwitchLeft = (RadioButton) findViewById(R.id.AdjustmentModeSwitchLeft);
  258. mImageCollectAdjustmentSwitchLeft.setOnClickListener(this);
  259. mImageCollectAdjustmentSwitchRight = (RadioButton) findViewById(R.id.AdjustmentModeSwitchRight);
  260. mImageCollectAdjustmentSwitchRight.setOnClickListener(this);
  261. mCropImageHeader = findViewById(R.id.navigation_bar);
  262. mToolBartLayout = (LinearLayout) findViewById(R.id.tool_bar);
  263. mToolbarCropImage = (LinearLayout) mToolBartLayout.findViewById(R.id.ImageCollectToolbarCropImage);
  264. mToolbarEnhanceText = (LinearLayout) mToolBartLayout.findViewById(R.id.ImageCollectToolbarEnhanceText);
  265. mToolbarColorAdjustment = (LinearLayout) mToolBartLayout.findViewById(R.id.ImageCollectToolbarColorAdjustment);
  266. mCropImageHeader.setOnTouchListener(this);
  267. mCropImageHeader.setOnClickListener(this);
  268. mToolbarCropImage.setOnTouchListener(this);
  269. mToolbarCropImage.setOnClickListener(this);
  270. mToolbarEnhanceText.setOnTouchListener(this);
  271. mToolbarEnhanceText.setOnClickListener(this);
  272. mBcscSeekBarBDefault = 5;
  273. mBcscSeekBarCDefault = 0;
  274. mBcscSeekBarSDefault = 5;
  275. mBcscBDefault = 0.0f;
  276. mBcscCDefault = 0.0f;
  277. mBcscSDefault = 0.0f;
  278. InitBCSCParams();
  279. mSaveApprovalTable = new boolean[5];
  280. activityModeChange(0);
  281. String stringExtra = getIntent().getStringExtra(IMAGE_FILE_NAME);
  282. mMetrics = new DisplayMetrics();
  283. getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
  284. mDeviceSize = new Size((double) mMetrics.widthPixels, (double) mMetrics.heightPixels);
  285. mCorrectionParamSet = new CorrectionParamSet();
  286. mCorrectionHistory = new ArrayList();
  287. mUserFolder = GetCacheFolder(false);
  288. mCacheFolder = GetCacheFolder(true);
  289. CameraPreviewControl instance = CameraPreviewControl.getInstance(this);
  290. mCurrentPaperId = 0;
  291. String country = Locale.getDefault().getCountry();
  292. String language = Locale.getDefault().getLanguage();
  293. if ((country.equals(Locale.US.getCountry()) || country.equals(Locale.CANADA.getCountry())) && !language.equals(Locale.FRENCH.getLanguage())) {
  294. mCurrentPaperId = 1;
  295. }
  296. mCurrentPaperSize = new Size(3048.0d, 4321.0d);
  297. Info_paper infoPaper = Info_paper.getInfoPaper(this, mCurrentPaperId);
  298. if (infoPaper != null) {
  299. mCurrentPaperSize.width = (double) infoPaper.getPaper_width();
  300. mCurrentPaperSize.height = (double) infoPaper.getPaper_height();
  301. }
  302. mImageCollect = new ImageCollect(stringExtra, mMetrics.density, mCurrentPaperSize);
  303. mImageCollect.SetPath(mCacheFolder, mUserFolder, instance.getSaveDirecotry());
  304. mPreviewType = -1;
  305. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_PHOTO);
  306. mGestureDetector = new GestureDetector(this, onGestureDetectorListener);
  307. }
  308. public static /* synthetic */ void lambda$onCreate$0(CropImageActivity cropImageActivity, Deque deque) {
  309. String[] checkQueue = cropImageActivity.mModelDialog.checkQueue();
  310. if (checkQueue != null) {
  311. String str = checkQueue[0];
  312. String str2 = checkQueue[1];
  313. if (str2.equals("do_show")) {
  314. cropImageActivity.showDialog(str);
  315. }
  316. if (str2.equals("do_dismiss")) {
  317. cropImageActivity.dismissDialog(str);
  318. EpLog.m69d("dismissDialog");
  319. if (cropImageActivity.mCropImageMessageShow) {
  320. EpLog.m69d("TOAST");
  321. cropImageActivity.mCropImageMessageShow = false;
  322. cropImageActivity.ToastMessage(cropImageActivity.getString(R.string.crop_image_message));
  323. }
  324. }
  325. }
  326. }
  327. public void onRestart() {
  328. super.onRestart();
  329. }
  330. public void onStart() {
  331. super.onStart();
  332. }
  333. public void onResume() {
  334. super.onResume();
  335. }
  336. public void onPause() {
  337. super.onPause();
  338. EpLog.m68d();
  339. CancelToast();
  340. }
  341. public void onStop() {
  342. super.onStop();
  343. EpLog.m68d();
  344. CancelToast();
  345. }
  346. private void CancelToast() {
  347. if (mCustomToast != null) {
  348. EpLog.m69d(" Toast Cancel");
  349. mCustomToast.cancel();
  350. mCustomToast = null;
  351. }
  352. }
  353. protected void onDestroy() {
  354. releaseResource();
  355. super.onDestroy();
  356. }
  357. public void onConfigurationChanged(Configuration configuration) {
  358. super.onConfigurationChanged(configuration);
  359. }
  360. public void onWindowFocusChanged(boolean z) {
  361. super.onWindowFocusChanged(z);
  362. }
  363. public void onBackPressed() {
  364. int i = mActivityMode;
  365. if (i == 0) {
  366. mActivityMode = -1;
  367. mImageCollectView.MessageOff();
  368. CancelToast();
  369. releaseResource();
  370. finish();
  371. } else if (i == 1) {
  372. activityModeChange(0);
  373. PointF[] GetCornerPoints = mImageCollect.GetCornerPoints();
  374. GetPreviewImage(0);
  375. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview, GetCornerPoints);
  376. } else if (i == 2) {
  377. activityModeChange(1);
  378. GetPreviewImage(mImageType);
  379. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  380. }
  381. }
  382. protected void onSaveInstanceState(Bundle bundle) {
  383. super.onSaveInstanceState(bundle);
  384. }
  385. protected void onRestoreInstanceState(Bundle bundle) {
  386. super.onRestoreInstanceState(bundle);
  387. }
  388. protected void onActivityResult(int i, int i2, Intent intent) {
  389. if (i == 3) {
  390. GetPaperInfo();
  391. mImageCollectPaperSizeInfo.setText(getDocumentSizeText());
  392. }
  393. if (i == 4 && i2 == -1) {
  394. savePreviewExecute();
  395. }
  396. }
  397. public void onClick(View view) {
  398. switch (view.getId()) {
  399. case R.id.AdjustmentModeSwitchLeft /*2131230725*/:
  400. if (mImageCollectAdjustmentSwitchId != R.id.AdjustmentModeSwitchLeft) {
  401. mImageCollectAdjustmentSwitchId = R.id.AdjustmentModeSwitchLeft;
  402. AdjustmentModeSwitchALL();
  403. return;
  404. }
  405. return;
  406. case R.id.AdjustmentModeSwitchRight /*2131230726*/:
  407. if (mImageCollectAdjustmentSwitchId != R.id.AdjustmentModeSwitchRight) {
  408. mImageCollectAdjustmentSwitchId = R.id.AdjustmentModeSwitchRight;
  409. AdjustmentModeSwitchPART();
  410. return;
  411. }
  412. return;
  413. case R.id.ImageCollectPalletButton /*2131230737*/:
  414. palletShow();
  415. return;
  416. case R.id.ImageCollectSwitchLeft /*2131230744*/:
  417. if (mImageCollectSwitchId != R.id.ImageCollectSwitchLeft) {
  418. mImageCollectSwitchId = R.id.ImageCollectSwitchLeft;
  419. ImageCollectSwitchPWC(1);
  420. return;
  421. }
  422. return;
  423. case R.id.ImageCollectSwitchMiddle /*2131230745*/:
  424. if (mImageCollectSwitchId != R.id.ImageCollectSwitchMiddle) {
  425. mImageCollectSwitchId = R.id.ImageCollectSwitchMiddle;
  426. ImageCollectSwitchPWC(2);
  427. return;
  428. }
  429. return;
  430. case R.id.ImageCollectSwitchRight /*2131230746*/:
  431. if (mImageCollectSwitchId != R.id.ImageCollectSwitchRight) {
  432. mImageCollectSwitchId = R.id.ImageCollectSwitchRight;
  433. ImageCollectSwitchCROP();
  434. return;
  435. }
  436. return;
  437. case R.id.color_adjustment_button /*2131230932*/:
  438. activityModeChange(2);
  439. InitBCSC();
  440. return;
  441. case R.id.document_size_button /*2131230996*/:
  442. mImageCollectView.MessageOff();
  443. setDocumentSize();
  444. return;
  445. case R.id.execute_button /*2131231032*/:
  446. int i = mActivityMode;
  447. if (i == 0) {
  448. mImageCollectView.MessageOff();
  449. mHandler.sendEmptyMessage(MSG_PREVIEW_CROP);
  450. return;
  451. } else if (i == 1) {
  452. MessageBox(101, -1, R.string.finish_adjustment_message, MSG_PREVIEW_PRINT_PREVIEW_EXECUTE);
  453. return;
  454. } else if (i == 2) {
  455. boolean z = false;
  456. if (!(mBcscBValue == mBcscBDefault && mBcscCValue == mBcscCDefault && mBcscSValue == mBcscSDefault)) {
  457. z = true;
  458. }
  459. if (mCorrectionParamSet.Size() > 0) {
  460. z = true;
  461. }
  462. if (z) {
  463. MessageBox(101, -1, (int) R.string.finish_color_adjustment_message, (int) MSG_SDIC_BCSC_FIX_PROC, (int) MSG_SDIC_BCSC_FIX_CANCEL);
  464. return;
  465. }
  466. activityModeChange(1);
  467. GetPreviewImage(mImageType);
  468. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  469. return;
  470. } else {
  471. return;
  472. }
  473. case R.id.reset_button /*2131231403*/:
  474. MessageBox(101, -1, R.string.reset_color_adjustment_message, MSG_SDIC_BCSC_RESET);
  475. return;
  476. case R.id.save_button /*2131231436*/:
  477. mHandler.sendEmptyMessage(MSG_PREVIEW_SAVE_EXECUTE);
  478. return;
  479. default:
  480. return;
  481. }
  482. }
  483. public boolean onTouch(View view, MotionEvent motionEvent) {
  484. mDebugID = view.getId();
  485. mGestureDetector.onTouchEvent(motionEvent);
  486. return false;
  487. }
  488. public boolean onDoubleTap(MotionEvent motionEvent) {
  489. if (mDebugID == mCropImageHeader.getId()) {
  490. int i = mDebugMode;
  491. if (i == 1) {
  492. mDebugMode = i + 1;
  493. }
  494. int i2 = mDebugMode;
  495. if (i2 == 3) {
  496. mDebugMode = i2 + 1;
  497. mToolbarCropImage.setBackgroundColor(Color.rgb(8, 35, 130));
  498. mToolbarEnhanceText.setBackgroundColor(Color.rgb(8, 35, 130));
  499. mToolbarColorAdjustment.setBackgroundColor(Color.rgb(8, 35, 130));
  500. }
  501. } else if (mDebugID == mToolbarCropImage.getId() || mDebugID == mToolbarEnhanceText.getId()) {
  502. int i3 = mDebugMode;
  503. if (i3 == 0) {
  504. mDebugMode = i3 + 1;
  505. }
  506. int i4 = mDebugMode;
  507. if (i4 == 2) {
  508. mDebugMode = i4 + 1;
  509. }
  510. }
  511. mDebugID = 0;
  512. return false;
  513. }
  514. public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
  515. if (z) {
  516. SeekBarTracking();
  517. }
  518. }
  519. private void executeMessage(Message message) {
  520. String str;
  521. switch (message.what) {
  522. case 301:
  523. ImageCollectView imageCollectView = mImageCollectView;
  524. imageCollectView.SetMaskEdge(mImageCollect.DetectEdge(imageCollectView.GetMaskImage()));
  525. float progress = (float) mImageCollectAdjustmentContrastSeekBar.getProgress();
  526. float progress2 = (float) mImageCollectAdjustmentSaturationSeekBar.getProgress();
  527. UiCommon.setButtonEnabled(mButtonReset, true);
  528. if (((float) mImageCollectAdjustmentBrightnessSeekBar.getProgress()) != ((float) mBcscSeekBarBDefault) || progress != ((float) mBcscSeekBarCDefault) || progress2 != ((float) mBcscSeekBarSDefault)) {
  529. PreviewImageBCSC();
  530. return;
  531. }
  532. return;
  533. case MSG_PREVIEW_TOUCH_EVENT_ACTION_DOWN /*311*/:
  534. CancelToast();
  535. return;
  536. case MSG_DEBUG_MODE /*390*/:
  537. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  538. builder.setTitle("Menu");
  539. builder.setCancelable(false);
  540. builder.setItems(new String[]{"Resolution Threshold", "Small Preview Rate"}, new DialogInterface.OnClickListener() {
  541. public void onClick(DialogInterface dialogInterface, int i) {
  542. switch (i) {
  543. case 0:
  544. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_DEBUG_RESOLUTION_THRESHOLD);
  545. return;
  546. case 1:
  547. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_DEBUG_SMALL_PREVIEW_RATE);
  548. return;
  549. default:
  550. return;
  551. }
  552. }
  553. });
  554. builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
  555. public void onClick(DialogInterface dialogInterface, int i) {
  556. }
  557. });
  558. builder.show();
  559. return;
  560. case MSG_DEBUG_RESOLUTION_THRESHOLD /*391*/:
  561. AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
  562. builder2.setTitle("Resolution Threshold");
  563. builder2.setCancelable(false);
  564. builder2.setSingleChoiceItems(new String[]{"360dpi", "300dpi", "240dpi", "180dpi", "120dpi"}, mDebugResolutionThreshold, new DialogInterface.OnClickListener() {
  565. public void onClick(DialogInterface dialogInterface, int i) {
  566. switch (i) {
  567. case 0:
  568. CropImageActivity.mImageCollect.SetResolutionThreshold(360.0d);
  569. break;
  570. case 1:
  571. CropImageActivity.mImageCollect.SetResolutionThreshold(300.0d);
  572. break;
  573. case 2:
  574. CropImageActivity.mImageCollect.SetResolutionThreshold(240.0d);
  575. break;
  576. case 3:
  577. CropImageActivity.mImageCollect.SetResolutionThreshold(180.0d);
  578. break;
  579. case 4:
  580. CropImageActivity.mImageCollect.SetResolutionThreshold(120.0d);
  581. break;
  582. }
  583. int unused = CropImageActivity.mDebugResolutionThreshold = i;
  584. }
  585. });
  586. builder2.setPositiveButton(CommonDefine.f335OK, new DialogInterface.OnClickListener() {
  587. public void onClick(DialogInterface dialogInterface, int i) {
  588. }
  589. });
  590. builder2.show();
  591. return;
  592. case MSG_DEBUG_SMALL_PREVIEW_RATE /*392*/:
  593. AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
  594. builder3.setTitle("Small Preview Rate");
  595. builder3.setCancelable(false);
  596. builder3.setSingleChoiceItems(new String[]{"1/1.0", "1/1.5", "1/2.0", "1/2.5", "1/3.0", "1/3.5", "1/4.0"}, mDebugSmallPreviewRate, new DialogInterface.OnClickListener() {
  597. public void onClick(DialogInterface dialogInterface, int i) {
  598. switch (i) {
  599. case 0:
  600. CropImageActivity.mImageCollect.SetSmallPreviewRate(1.0f);
  601. break;
  602. case 1:
  603. CropImageActivity.mImageCollect.SetSmallPreviewRate(1.5f);
  604. break;
  605. case 2:
  606. CropImageActivity.mImageCollect.SetSmallPreviewRate(2.0f);
  607. break;
  608. case 3:
  609. CropImageActivity.mImageCollect.SetSmallPreviewRate(2.5f);
  610. break;
  611. case 4:
  612. CropImageActivity.mImageCollect.SetSmallPreviewRate(3.0f);
  613. break;
  614. case 5:
  615. CropImageActivity.mImageCollect.SetSmallPreviewRate(3.5f);
  616. break;
  617. case 6:
  618. CropImageActivity.mImageCollect.SetSmallPreviewRate(4.0f);
  619. break;
  620. }
  621. int unused = CropImageActivity.mDebugSmallPreviewRate = i;
  622. }
  623. });
  624. builder3.setPositiveButton(CommonDefine.f335OK, new DialogInterface.OnClickListener() {
  625. public void onClick(DialogInterface dialogInterface, int i) {
  626. }
  627. });
  628. builder3.show();
  629. return;
  630. case MSG_PREVIEW_CROP /*801*/:
  631. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_SHOW);
  632. new Thread(new Runnable() {
  633. public void run() {
  634. int paperId = CropImageActivity.mDocumentSizeInfo.getPaperId();
  635. double width = CropImageActivity.mDocumentSizeInfo.getWidth();
  636. double height = CropImageActivity.mDocumentSizeInfo.getHeight();
  637. PointF[] GetCropPoint = CropImageActivity.mImageCollectView.GetCropPoint();
  638. boolean z = false;
  639. boolean z2 = true;
  640. if (!(CropImageActivity.mPointPreviewCropPoint == null || GetCropPoint == null || (CropImageActivity.mPointPreviewCropPoint[0].x == GetCropPoint[0].x && CropImageActivity.mPointPreviewCropPoint[0].y == GetCropPoint[0].y && CropImageActivity.mPointPreviewCropPoint[1].x == GetCropPoint[1].x && CropImageActivity.mPointPreviewCropPoint[1].y == GetCropPoint[1].y && CropImageActivity.mPointPreviewCropPoint[2].x == GetCropPoint[2].x && CropImageActivity.mPointPreviewCropPoint[2].y == GetCropPoint[2].y && CropImageActivity.mPointPreviewCropPoint[3].x == GetCropPoint[3].x && CropImageActivity.mPointPreviewCropPoint[3].y == GetCropPoint[3].y))) {
  641. z = true;
  642. }
  643. if (z || (CropImageActivity.mPaperId == -1 || paperId == -1 ? CropImageActivity.mPaperId == paperId : CropImageActivity.mPaperWidth == width && CropImageActivity.mPaperHeight == height)) {
  644. z2 = z;
  645. }
  646. int unused = CropImageActivity.mPaperId = paperId;
  647. double unused2 = CropImageActivity.mPaperWidth = width;
  648. double unused3 = CropImageActivity.mPaperHeight = height;
  649. if (z2) {
  650. PointF[] unused4 = CropImageActivity.mPointPreviewCropPoint = GetCropPoint;
  651. CropImageActivity.mImageCollect.MakePreviewImageCROP(CropImageActivity.mPointPreviewCropPoint, CropImageActivity.mPaperSize, CropImageActivity.mDeviceSize);
  652. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_SDIC_PWC_EXECUTE);
  653. return;
  654. }
  655. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_SDIC_PWC_FINISH);
  656. }
  657. }).start();
  658. return;
  659. case MSG_SDIC_PWC_EXECUTE /*811*/:
  660. new Thread(new Runnable() {
  661. public void run() {
  662. CropImageActivity.mImageCollect.MakePreviewImagePWC(-1);
  663. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_SDIC_PWC_FINISH);
  664. }
  665. }).start();
  666. return;
  667. case MSG_SDIC_PWC_FINISH /*812*/:
  668. mImageCollectSwitchId = R.id.ImageCollectSwitchLeft;
  669. mImageCollectSwitch.check(mImageCollectSwitchId);
  670. mImageType = 2;
  671. activityModeChange(1);
  672. ImageCollectSwitchPWC(1);
  673. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_DISMISS);
  674. return;
  675. case MSG_SDIC_BCSC_RESET /*823*/:
  676. InitBCSC();
  677. UiCommon.setButtonEnabled(mButtonReset, false);
  678. return;
  679. case MSG_SDIC_BCSC_FIX_PROC /*824*/:
  680. AdjustmentModeSwitchEXECUTE();
  681. mSaveApprovalTable[4] = true;
  682. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_SHOW);
  683. mCorrectionParamSet.SetImageType(mImageType);
  684. mCorrectionHistory.add(mCorrectionParamSet.Clone());
  685. new Thread(new Runnable() {
  686. public void run() {
  687. CropImageActivity.mImageCollect.MakePreviewBCSC(CropImageActivity.mCorrectionParamSet);
  688. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_SDIC_BCSC_FIX_QUIT);
  689. }
  690. }).start();
  691. return;
  692. case MSG_SDIC_BCSC_FIX_QUIT /*826*/:
  693. activityModeChange(1);
  694. GetPreviewImage(4);
  695. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  696. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_DISMISS);
  697. return;
  698. case MSG_PREVIEW_SAVE_EXECUTE /*831*/:
  699. if (ActivityRequestPermissions.isRuntimePermissionSupported()) {
  700. String[] strArr = {"android.permission.WRITE_EXTERNAL_STORAGE"};
  701. ActivityRequestPermissions.Permission permission = new ActivityRequestPermissions.Permission(strArr[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))});
  702. if (!ActivityRequestPermissions.checkPermission(this, strArr)) {
  703. ActivityRequestPermissions.requestPermission((Activity) this, permission, 4);
  704. return;
  705. }
  706. }
  707. savePreviewExecute();
  708. return;
  709. case MSG_PREVIEW_SAVE_FINISH /*832*/:
  710. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_DISMISS);
  711. String GetSavePath = mImageCollect.GetSavePath(false);
  712. if (GetSavePath != null) {
  713. str = String.format(getString(R.string.image_save_message), new Object[]{GetSavePath});
  714. } else {
  715. str = getString(R.string.file_save_error_message);
  716. }
  717. MessageBox(102, -1, str, -1, -1);
  718. return;
  719. case MSG_PREVIEW_PRINT_PREVIEW_EXECUTE /*841*/:
  720. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_SHOW);
  721. MakePrintData(true, MSG_PREVIEW_PRINT_PREVIEW_FINISH);
  722. return;
  723. case MSG_PREVIEW_PRINT_PREVIEW_FINISH /*842*/:
  724. startPrintPreviewActivity(mImageCollect.GetSavePath(true));
  725. mActivityMode = -1;
  726. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_DISMISS);
  727. return;
  728. case MSG_PREVIEW_LOAD_DIALOG_SHOW /*901*/:
  729. LoadProgressShow();
  730. return;
  731. case MSG_PREVIEW_LOAD_DIALOG_DISMISS /*902*/:
  732. LoadProgressHide();
  733. return;
  734. case MSG_PREVIEW_LOAD_PHOTO /*911*/:
  735. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_SHOW);
  736. new Thread(new Runnable() {
  737. public void run() {
  738. CropImageActivity.mImageCollect.MakePreviewImageRAW(CropImageActivity.mDeviceSize.width, CropImageActivity.mDeviceSize.height);
  739. CropImageActivity.this.GetPreviewImage(0);
  740. CropImageActivity.mHandler.sendEmptyMessage(CropImageActivity.MSG_PREVIEW_LOAD_FINISH);
  741. }
  742. }).start();
  743. return;
  744. case MSG_PREVIEW_LOAD_FINISH /*912*/:
  745. EpLog.m69d("MSG_PREVIEW_LOAD_FINISH");
  746. if (mBitmapPreview != null) {
  747. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview, mImageCollect.GetCornerPoints());
  748. }
  749. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_DISMISS);
  750. return;
  751. default:
  752. return;
  753. }
  754. }
  755. private void savePreviewExecute() {
  756. SaveButtonDisable();
  757. mHandler.sendEmptyMessage(MSG_PREVIEW_LOAD_DIALOG_SHOW);
  758. MakePrintData(false, MSG_PREVIEW_SAVE_FINISH);
  759. }
  760. private void ImageCollectSwitchPWC(int i) {
  761. GetPreviewImage(i == 1 ? 2 : 3);
  762. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  763. mCorrectionHistory.clear();
  764. }
  765. private void ImageCollectSwitchCROP() {
  766. mImageType = 1;
  767. GetPreviewImage(1);
  768. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  769. mCorrectionHistory.clear();
  770. }
  771. private void AdjustmentModeSwitchALL() {
  772. AdjustmentModeProc(false, true, 0, 2);
  773. }
  774. private void AdjustmentModeSwitchPART() {
  775. AdjustmentModeProc(true, true, R.string.start_adjustment_partly_message, 3);
  776. }
  777. private void AdjustmentModeSwitchEXECUTE() {
  778. if (mImageCollectAdjustmentSwitch.getCheckedRadioButtonId() == R.id.AdjustmentModeSwitchRight) {
  779. AdjustmentModeProc(false, true, 0, 3);
  780. } else {
  781. AdjustmentModeProc(true, true, 0, 2);
  782. }
  783. }
  784. private void AdjustmentModeProc(boolean z, boolean z2, int i, int i2) {
  785. StackBCSCParams(z, z2);
  786. mBcscType = mImageType;
  787. mImageCollect.SiwtchPreviewImageBCSC(mBcscType);
  788. if (i > 0) {
  789. ToastMessage(getString(i));
  790. }
  791. mImageCollectView.SetViewMode(i2);
  792. mImageCollectView.invalidate();
  793. }
  794. private void InitBCSC() {
  795. InitBCSCParams();
  796. mCorrectionParamSet.Reset();
  797. mImageCollect.ResetPreviewImageBCSC();
  798. mBcscType = mImageType;
  799. mImageCollect.MakePreviewImageBCSC_Init(mBcscType, true);
  800. if (mImageCollectAdjustmentSwitch.getCheckedRadioButtonId() == R.id.AdjustmentModeSwitchRight) {
  801. mImageCollectView.SetViewMode(3);
  802. } else {
  803. mImageCollectView.SetViewMode(2);
  804. }
  805. GetPreviewImage(mImageType);
  806. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  807. }
  808. private void InitBCSCParams() {
  809. mImageCollectAdjustmentBrightnessSeekBar.setMax(10);
  810. mImageCollectAdjustmentBrightnessSeekBar.setProgress(mBcscSeekBarBDefault);
  811. mImageCollectAdjustmentContrastSeekBar.setMax(10);
  812. mImageCollectAdjustmentContrastSeekBar.setProgress(mBcscSeekBarCDefault);
  813. mImageCollectAdjustmentSaturationSeekBar.setMax(10);
  814. mImageCollectAdjustmentSaturationSeekBar.setProgress(mBcscSeekBarSDefault);
  815. mBcscBValue = mBcscBDefault;
  816. mBcscCValue = mBcscCDefault;
  817. mBcscSValue = mBcscSDefault;
  818. }
  819. private void StackBCSCParams(boolean z, boolean z2) {
  820. if (mBcscBValue != mBcscBDefault || mBcscCValue != mBcscCDefault || mBcscSValue != mBcscSDefault) {
  821. CorrectionParam correctionParam = new CorrectionParam();
  822. boolean unused = correctionParam.mMaskType = z;
  823. float unused2 = correctionParam.mBcscBValue = mBcscBValue;
  824. float unused3 = correctionParam.mBcscCValue = mBcscCValue;
  825. float unused4 = correctionParam.mBcscSValue = mBcscSValue;
  826. if (!z) {
  827. List unused5 = correctionParam.mPointArray = mImageCollectView.GetBcscPointArray();
  828. float unused6 = correctionParam.mScale = mImageCollectView.GetBcscScale();
  829. float unused7 = correctionParam.mStrokeWidth = mImageCollectView.GetBcscStrokeWidth();
  830. Point unused8 = correctionParam.mPreviewImageSize = mImageCollect.GetMakedPreviewImageSize();
  831. }
  832. mCorrectionParamSet.AddParam(correctionParam);
  833. if (z2) {
  834. InitBCSCParams();
  835. }
  836. }
  837. }
  838. private void SeekBarTracking() {
  839. float progress = (((float) mImageCollectAdjustmentBrightnessSeekBar.getProgress()) * 0.2f) - 1.0f;
  840. float progress2 = ((float) mImageCollectAdjustmentContrastSeekBar.getProgress()) * 0.1f;
  841. float progress3 = (((float) mImageCollectAdjustmentSaturationSeekBar.getProgress()) * 0.2f) - 1.0f;
  842. if (progress != mBcscBValue || progress2 != mBcscCValue || progress3 != mBcscSValue) {
  843. mBcscBValue = progress;
  844. mBcscCValue = progress2;
  845. mBcscSValue = progress3;
  846. PreviewImageBCSC();
  847. UiCommon.setButtonEnabled(mButtonReset, true);
  848. }
  849. }
  850. private void PreviewImageBCSC() {
  851. if (mImageCollectAdjustmentSwitch.getCheckedRadioButtonId() == R.id.AdjustmentModeSwitchLeft) {
  852. mMaskType = 7;
  853. } else {
  854. mMaskType = 8;
  855. }
  856. mImageCollect.MakePreviewImageBCSC_Exec(mMaskType, true, mBcscBValue, mBcscCValue, mBcscSValue, mImageCollectView.GetBcscScale());
  857. GetPreviewImage(6);
  858. mImageCollectView.SetPreviewBitmapAndCropData(mBitmapPreview);
  859. }
  860. private void GetPreviewImage(int i) {
  861. Bitmap GetPreviewImage;
  862. if (i == 1 || i == 2 || i == 3 || i == 4) {
  863. mImageType = i;
  864. SaveButtonState();
  865. }
  866. if ((i == 6 || i == 4 || i != mPreviewType) && (GetPreviewImage = mImageCollect.GetPreviewImage(i)) != null) {
  867. Bitmap bitmap = mBitmapPreview;
  868. if (bitmap != null) {
  869. bitmap.recycle();
  870. }
  871. mBitmapPreview = GetPreviewImage;
  872. mPreviewType = i;
  873. }
  874. }
  875. protected void setDocumentSize() {
  876. startActivityForResult(new Intent(this, DocumentSizeSettingActivity.class), 3);
  877. }
  878. private File GetCacheFolder(boolean z) {
  879. if (!z) {
  880. return Environment.getExternalStorageDirectory();
  881. }
  882. File file = new File(getExternalCacheDir(), ICPD_FOLDER_PRINT_DATA);
  883. ExternalFileUtils.getInstance(this).createTempFolder(file.getPath());
  884. return file;
  885. }
  886. private void MakePrintData(final boolean z, final int i) {
  887. new Thread(new Runnable() {
  888. public void run() {
  889. CropImageActivity.mImageCollect.MakeCropPrintSizeImage(CropImageActivity.mPointPreviewCropPoint, CropImageActivity.mPaperSize, CropImageActivity.mImageType, CropImageActivity.mCorrectionHistory);
  890. if (CropImageActivity.mImageCollect.SaveExecute(z, CropImageActivity.mImageType, CropImageActivity.mPaperSize) && !z) {
  891. Uri fromFile = Uri.fromFile(new File(CropImageActivity.mImageCollect.GetSavePath(true)));
  892. ContentValues contentValues = new ContentValues();
  893. contentValues.put("title", fromFile.getLastPathSegment());
  894. contentValues.put("_display_name", fromFile.getLastPathSegment());
  895. contentValues.put("mime_type", "image/jpeg");
  896. contentValues.put("_data", fromFile.getPath());
  897. contentValues.put("datetaken", Long.valueOf(System.currentTimeMillis()));
  898. CropImageActivity.this.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
  899. }
  900. CropImageActivity.mHandler.sendEmptyMessage(i);
  901. }
  902. }).start();
  903. }
  904. private void GetPaperInfo() {
  905. Size size = mPaperSize;
  906. size.width = 0.0d;
  907. size.height = 0.0d;
  908. mDocumentSizeInfo = RegistedDocumentSizeList.getInstance(this).getCurrentDocumentSize();
  909. int paperId = mDocumentSizeInfo.getPaperId();
  910. int scaleId = mDocumentSizeInfo.getScaleId();
  911. if (paperId > -1) {
  912. mInfoPaper = Info_paper.getInfoPaper(this, mDocumentSizeInfo.getPaperId());
  913. Info_paper info_paper = mInfoPaper;
  914. if (info_paper != null) {
  915. mPaperSize.width = (double) info_paper.getPaper_width();
  916. mPaperSize.height = (double) mInfoPaper.getPaper_height();
  917. }
  918. } else if (paperId < -1) {
  919. double width = mDocumentSizeInfo.getWidth();
  920. double height = mDocumentSizeInfo.getHeight();
  921. if (scaleId == 1) {
  922. Size size2 = mPaperSize;
  923. size2.width = (width / 25.4d) * 360.0d;
  924. size2.height = (height / 25.4d) * 360.0d;
  925. return;
  926. }
  927. Size size3 = mPaperSize;
  928. size3.width = width * 360.0d;
  929. size3.height = height * 360.0d;
  930. }
  931. }
  932. private String getDocumentSizeText() {
  933. new String();
  934. if (mDocumentSizeInfo.getPaperId() != -2) {
  935. return mDocumentSizeInfo.getDocSizeName(this);
  936. }
  937. return String.format(Locale.US, mDocumentSizeInfo.getScaleId() == 2 ? "%s (%.1f x %.1f in)" : "%s (%.0f x %.0f mm)", new Object[]{mDocumentSizeInfo.getDocSizeName(this), Float.valueOf((float) mDocumentSizeInfo.getWidth()), Float.valueOf((float) mDocumentSizeInfo.getHeight())});
  938. }
  939. private void startPrintPreviewActivity(String str) {
  940. releaseResource();
  941. if (str != null) {
  942. Intent intent = new Intent();
  943. intent.putExtra(RESULT_COLLECTED_FILE_NAME, str);
  944. setResult(-1, intent);
  945. } else {
  946. setResult(0);
  947. }
  948. logRecordImageImageProcessingType();
  949. finish();
  950. }
  951. private void logRecordImageImageProcessingType() {
  952. if (!mImageCollectSwitchMiddle.isChecked()) {
  953. mImageCollectSwitchRight.isChecked();
  954. }
  955. }
  956. private void palletShow() {
  957. if (mImageCollectPalletLayout.getVisibility() == 0) {
  958. mImageCollectPalletLayout.setVisibility(8);
  959. mImageCollectPalletButton.setText("▲");
  960. return;
  961. }
  962. mImageCollectPalletLayout.setVisibility(0);
  963. mImageCollectPalletButton.setText("▼");
  964. }
  965. private void LoadProgressShow() {
  966. mModelDialog.doShow(DIALOG_PROGRESS);
  967. }
  968. private void LoadProgressHide() {
  969. mModelDialog.doDismiss(DIALOG_PROGRESS);
  970. }
  971. private void MessageBox(int i, int i2, int i3, int i4) {
  972. MessageBox(i, i2, getString(i3), i4, -1);
  973. }
  974. private void MessageBox(int i, int i2, int i3, int i4, int i5) {
  975. MessageBox(i, i2, getString(i3), i4, i5);
  976. }
  977. private void MessageBox(int i, int i2, String str, final int i3, final int i4) {
  978. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  979. builder.setCancelable(false);
  980. if (i2 != -1) {
  981. builder.setTitle(i2);
  982. }
  983. if (str != null) {
  984. builder.setMessage(str);
  985. }
  986. C086515 r4 = null;
  987. C086414 r5 = i3 != -1 ? new DialogInterface.OnClickListener() {
  988. public void onClick(DialogInterface dialogInterface, int i) {
  989. CropImageActivity.mHandler.sendEmptyMessage(i3);
  990. }
  991. } : null;
  992. if (i4 != -1) {
  993. r4 = new DialogInterface.OnClickListener() {
  994. public void onClick(DialogInterface dialogInterface, int i) {
  995. CropImageActivity.mHandler.sendEmptyMessage(i4);
  996. }
  997. };
  998. }
  999. if (i == 101) {
  1000. builder.setPositiveButton(R.string.str_yes, r5);
  1001. builder.setNegativeButton(R.string.str_no, r4);
  1002. } else if (i == 102) {
  1003. builder.setPositiveButton(R.string.str_ok, r5);
  1004. } else if (i == 103) {
  1005. builder.setNegativeButton(R.string.str_cancel, r4);
  1006. }
  1007. mMessageDialog = builder.create();
  1008. mMessageDialog.show();
  1009. }
  1010. private void releaseResource() {
  1011. ImageCollectView imageCollectView = mImageCollectView;
  1012. if (imageCollectView != null) {
  1013. imageCollectView.ReleaseResource();
  1014. mImageCollectView = null;
  1015. }
  1016. ImageCollect imageCollect = mImageCollect;
  1017. if (imageCollect != null) {
  1018. imageCollect.ReleaseImageCollect();
  1019. mImageCollect = null;
  1020. }
  1021. Bitmap bitmap = mBitmapPreview;
  1022. if (bitmap != null) {
  1023. bitmap.recycle();
  1024. mBitmapPreview = null;
  1025. }
  1026. System.gc();
  1027. }
  1028. private void SaveButtonState() {
  1029. UiCommon.setButtonEnabled(mButtonSave, mSaveApprovalTable[mImageType]);
  1030. }
  1031. private void SaveButtonDisable() {
  1032. boolean[] zArr = mSaveApprovalTable;
  1033. int i = mImageType;
  1034. zArr[i] = false;
  1035. UiCommon.setButtonEnabled(mButtonSave, zArr[i]);
  1036. }
  1037. private void activityModeChange(int i) {
  1038. if (i == 0) {
  1039. mImageCollectPreviewLayout.setVisibility(0);
  1040. mImageCollectPaperSizeInfo.setVisibility(0);
  1041. mImageCollectPalletButton.setVisibility(4);
  1042. mImageCollectSwitchLayout.setVisibility(8);
  1043. mImageCollectPalletLayout.setVisibility(8);
  1044. setTitle(R.string.crop_image_title);
  1045. mToolbarCropImage.setVisibility(0);
  1046. mToolbarEnhanceText.setVisibility(8);
  1047. mToolbarColorAdjustment.setVisibility(8);
  1048. mButtonDocSize = (Button) mToolbarCropImage.findViewById(R.id.document_size_button);
  1049. mButtonDocSize.setOnClickListener(this);
  1050. mButtonExecute = (Button) mToolbarCropImage.findViewById(R.id.execute_button);
  1051. mButtonExecute.setText(R.string.execute_button);
  1052. mButtonExecute.setOnClickListener(this);
  1053. mImageCollectView.SetViewMode(0);
  1054. boolean[] zArr = mSaveApprovalTable;
  1055. zArr[0] = false;
  1056. zArr[1] = true;
  1057. zArr[2] = true;
  1058. zArr[3] = true;
  1059. zArr[4] = true;
  1060. } else if (i == 1) {
  1061. mImageCollectPreviewLayout.setVisibility(0);
  1062. mImageCollectPaperSizeInfo.setVisibility(4);
  1063. mImageCollectPalletButton.setVisibility(4);
  1064. mImageCollectSwitchLayout.setVisibility(0);
  1065. mImageCollectPalletLayout.setVisibility(8);
  1066. setTitle(R.string.enhance_text_title);
  1067. mToolbarCropImage.setVisibility(8);
  1068. mToolbarEnhanceText.setVisibility(0);
  1069. mToolbarColorAdjustment.setVisibility(8);
  1070. mButtonSave = (Button) mToolbarEnhanceText.findViewById(R.id.save_button);
  1071. mButtonSave.setOnClickListener(this);
  1072. mButtonColorAdjustment = (Button) mToolbarEnhanceText.findViewById(R.id.color_adjustment_button);
  1073. mButtonColorAdjustment.setOnClickListener(this);
  1074. mButtonExecute = (Button) mToolbarEnhanceText.findViewById(R.id.execute_button);
  1075. mButtonExecute.setText(R.string.print_preview_button);
  1076. mButtonExecute.setOnClickListener(this);
  1077. mImageCollectView.SetViewMode(1);
  1078. } else if (i == 2) {
  1079. mImageCollectPreviewLayout.setVisibility(0);
  1080. mImageCollectPaperSizeInfo.setVisibility(4);
  1081. mImageCollectPalletButton.setVisibility(0);
  1082. mImageCollectPalletButton.setText("▼");
  1083. mImageCollectSwitchLayout.setVisibility(8);
  1084. mImageCollectPalletLayout.setVisibility(0);
  1085. setTitle(R.string.color_adjustment_title);
  1086. mToolbarCropImage.setVisibility(8);
  1087. mToolbarEnhanceText.setVisibility(8);
  1088. mToolbarColorAdjustment.setVisibility(0);
  1089. mButtonReset = (Button) mToolbarColorAdjustment.findViewById(R.id.reset_button);
  1090. mButtonReset.setOnClickListener(this);
  1091. UiCommon.setButtonEnabled(mButtonReset, false);
  1092. mButtonExecute = (Button) mToolbarColorAdjustment.findViewById(R.id.execute_button);
  1093. mButtonExecute.setText(R.string.execute_button);
  1094. mButtonExecute.setOnClickListener(this);
  1095. mImageCollectAdjustmentSwitchId = R.id.AdjustmentModeSwitchLeft;
  1096. mImageCollectAdjustmentSwitch.check(mImageCollectAdjustmentSwitchId);
  1097. AdjustmentModeSwitchALL();
  1098. mImageCollectView.SetViewMode(2);
  1099. }
  1100. mActivityMode = i;
  1101. }
  1102. private void ToastMessage(CharSequence charSequence) {
  1103. CancelToast();
  1104. mDaemonView.SetHandler(mHandler);
  1105. mCustomToast = new CustomToast();
  1106. mCustomToast.makeText(this, charSequence, 0, (mImageCollectPreviewLayout.getHeight() - mImageCollectLayout.getHeight()) / 2);
  1107. mCustomToast.show();
  1108. }
  1109. private void showDialog(String str) {
  1110. mProgressDialog = DialogProgress.newInstance(str, 0, getString(R.string.processing_image_message));
  1111. mProgressDialog.setCancelable(false);
  1112. mProgressDialog.show(getSupportFragmentManager(), str);
  1113. }
  1114. private void dismissDialog(String str) {
  1115. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
  1116. if (dialogFragment != null) {
  1117. dialogFragment.dismiss();
  1118. }
  1119. }
  1120. @SuppressLint({"ShowToast"})
  1121. /* renamed from: com.epson.cameracopy.ui.CropImageActivity$CustomToast */
  1122. private class CustomToast {
  1123. private boolean mBreak;
  1124. private Toast mToast;
  1125. private CustomToast() {
  1126. mToast = null;
  1127. mBreak = false;
  1128. }
  1129. public void makeText(Context context, CharSequence charSequence, int i, int i2) {
  1130. mBreak = false;
  1131. mToast = Toast.makeText(context, charSequence, 1);
  1132. mToast.setGravity(17, i, i2);
  1133. View view = mToast.getView();
  1134. view.setBackgroundColor(-12303292);
  1135. if (view instanceof ViewGroup) {
  1136. ViewGroup viewGroup = (ViewGroup) view;
  1137. for (int i3 = 0; i3 < viewGroup.getChildCount(); i3++) {
  1138. View childAt = viewGroup.getChildAt(i3);
  1139. if (childAt instanceof TextView) {
  1140. ((TextView) childAt).setTextColor(-1);
  1141. }
  1142. }
  1143. }
  1144. view.setOnTouchListener(new View.OnTouchListener() {
  1145. public boolean onTouch(View view, MotionEvent motionEvent) {
  1146. if (motionEvent.getAction() != 0) {
  1147. return false;
  1148. }
  1149. CustomToast.this.cancel();
  1150. return false;
  1151. }
  1152. });
  1153. }
  1154. public void show() {
  1155. EpLog.m69d("show :");
  1156. if (!mBreak) {
  1157. EpLog.m69d("run:show");
  1158. mToast.show();
  1159. return;
  1160. }
  1161. EpLog.m69d("run:break");
  1162. }
  1163. public void cancel() {
  1164. EpLog.m69d("cancel");
  1165. mBreak = true;
  1166. mToast.cancel();
  1167. }
  1168. }
  1169. /* renamed from: com.epson.cameracopy.ui.CropImageActivity$DaemonView */
  1170. private class DaemonView extends View {
  1171. private Handler mHandlerAvtivity = null;
  1172. public DaemonView(Context context) {
  1173. super(context);
  1174. Init();
  1175. }
  1176. public DaemonView(Context context, AttributeSet attributeSet) {
  1177. super(context, attributeSet);
  1178. Init();
  1179. }
  1180. public DaemonView(Context context, AttributeSet attributeSet, int i) {
  1181. super(context, attributeSet, i);
  1182. Init();
  1183. }
  1184. public void SetHandler(Handler handler) {
  1185. mHandlerAvtivity = handler;
  1186. setVisibility(0);
  1187. }
  1188. private void Init() {
  1189. setVisibility(4);
  1190. setBackgroundColor(Color.argb(0, 0, 0, 0));
  1191. setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
  1192. }
  1193. public boolean onTouchEvent(MotionEvent motionEvent) {
  1194. Handler handler;
  1195. if ((motionEvent.getAction() & 255) != 0 || (handler = mHandlerAvtivity) == null) {
  1196. return false;
  1197. }
  1198. handler.sendEmptyMessage(CropImageActivity.MSG_PREVIEW_TOUCH_EVENT_ACTION_DOWN);
  1199. mHandlerAvtivity = null;
  1200. setVisibility(4);
  1201. return false;
  1202. }
  1203. }
  1204. /* renamed from: com.epson.cameracopy.ui.CropImageActivity$CorrectionParamSet */
  1205. public class CorrectionParamSet {
  1206. private int mAfterPWCtype = 0;
  1207. private int mImageType = 0;
  1208. private List<CorrectionParam> mParamArray = new ArrayList();
  1209. public CorrectionParamSet() {
  1210. }
  1211. public void SetImageType(int i) {
  1212. mImageType = i;
  1213. }
  1214. public int GetImageType() {
  1215. return mImageType;
  1216. }
  1217. public void AddParam(CorrectionParam correctionParam) {
  1218. mParamArray.add(correctionParam);
  1219. }
  1220. public CorrectionParam GetParam(int i) {
  1221. return mParamArray.get(i);
  1222. }
  1223. public void SetAfterPWC(int i) {
  1224. mAfterPWCtype = i;
  1225. }
  1226. public int GetAfterPWC() {
  1227. return mAfterPWCtype;
  1228. }
  1229. public void Reset() {
  1230. mParamArray.clear();
  1231. }
  1232. public int Size() {
  1233. return mParamArray.size();
  1234. }
  1235. public CorrectionParamSet Clone() {
  1236. CorrectionParamSet correctionParamSet = new CorrectionParamSet();
  1237. ArrayList arrayList = new ArrayList();
  1238. for (CorrectionParam Clone : mParamArray) {
  1239. arrayList.add(Clone.Clone());
  1240. }
  1241. correctionParamSet.mParamArray = arrayList;
  1242. correctionParamSet.mImageType = mImageType;
  1243. correctionParamSet.mAfterPWCtype = mAfterPWCtype;
  1244. return correctionParamSet;
  1245. }
  1246. }
  1247. /* renamed from: com.epson.cameracopy.ui.CropImageActivity$CorrectionParam */
  1248. public class CorrectionParam {
  1249. private float mBcscBValue;
  1250. private float mBcscCValue;
  1251. private float mBcscSValue;
  1252. private boolean mMaskType;
  1253. private List<List<PointF>> mPointArray;
  1254. private Point mPreviewImageSize = new Point(0, 0);
  1255. private float mScale;
  1256. private float mStrokeWidth;
  1257. public CorrectionParam() {
  1258. }
  1259. public boolean GetMaskType() {
  1260. return mMaskType;
  1261. }
  1262. public float GetBcscBValue() {
  1263. return mBcscBValue;
  1264. }
  1265. public float GetBcscCValue() {
  1266. return mBcscCValue;
  1267. }
  1268. public float GetBcscSValue() {
  1269. return mBcscSValue;
  1270. }
  1271. public Point GetPreviewImageSize() {
  1272. return mPreviewImageSize;
  1273. }
  1274. public List<List<PointF>> GetPointArray() {
  1275. return mPointArray;
  1276. }
  1277. public float GetScale() {
  1278. return mScale;
  1279. }
  1280. public float GetStrokeWidth() {
  1281. return mStrokeWidth;
  1282. }
  1283. public CorrectionParam Clone() {
  1284. CorrectionParam correctionParam = new CorrectionParam();
  1285. correctionParam.mMaskType = mMaskType;
  1286. correctionParam.mBcscBValue = mBcscBValue;
  1287. correctionParam.mBcscCValue = mBcscCValue;
  1288. correctionParam.mBcscSValue = mBcscSValue;
  1289. correctionParam.mPreviewImageSize = new Point(mPreviewImageSize.x, mPreviewImageSize.y);
  1290. correctionParam.mPointArray = new ArrayList();
  1291. List<List<PointF>> list = mPointArray;
  1292. if (list != null) {
  1293. for (List<PointF> it : list) {
  1294. ArrayList arrayList = new ArrayList();
  1295. for (PointF add : it) {
  1296. arrayList.add(add);
  1297. }
  1298. correctionParam.mPointArray.add(arrayList);
  1299. }
  1300. }
  1301. correctionParam.mScale = mScale;
  1302. correctionParam.mStrokeWidth = mStrokeWidth;
  1303. return correctionParam;
  1304. }
  1305. }
  1306. /* renamed from: com.epson.cameracopy.ui.CropImageActivity$EPxLog */
  1307. static class EPxLog {
  1308. EPxLog() {
  1309. }
  1310. /* renamed from: d */
  1311. public static final void m58d(String str, String str2) {
  1312. Log.d(str, str2);
  1313. }
  1314. /* renamed from: e */
  1315. public static final void m59e(String str, String str2) {
  1316. if (Debug.isDebuggerConnected()) {
  1317. Log.e(str, str2);
  1318. }
  1319. }
  1320. /* renamed from: i */
  1321. public static final void m60i(String str, String str2) {
  1322. if (Debug.isDebuggerConnected()) {
  1323. Log.i(str, str2);
  1324. }
  1325. }
  1326. /* renamed from: v */
  1327. public static final void m61v(String str, String str2) {
  1328. if (Debug.isDebuggerConnected()) {
  1329. Log.v(str, str2);
  1330. }
  1331. }
  1332. /* renamed from: w */
  1333. public static final void m62w(String str, String str2) {
  1334. if (Debug.isDebuggerConnected()) {
  1335. Log.w(str, str2);
  1336. }
  1337. }
  1338. }
  1339. }