CopyActivity.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. package epson.print.copy;
  2. import android.content.Intent;
  3. import android.content.res.Configuration;
  4. import android.content.res.TypedArray;
  5. import android.os.AsyncTask;
  6. import android.os.Bundle;
  7. import android.os.Handler;
  8. import android.os.Message;
  9. import android.os.SystemClock;
  10. import android.view.MotionEvent;
  11. import android.view.View;
  12. import android.view.ViewGroup;
  13. import android.widget.Button;
  14. import android.widget.CompoundButton;
  15. import android.widget.ImageView;
  16. import android.widget.RadioButton;
  17. import android.widget.RadioGroup;
  18. import android.widget.TextView;
  19. import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
  20. import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
  21. import epson.common.Utils;
  22. import epson.print.R;
  23. import epson.print.MyPrinter;
  24. import epson.print.Util.EPLog;
  25. import epson.print.WebviewActivity;
  26. import epson.print.copy.ActivityBase;
  27. import epson.print.copy.Component.ecopycomponent.ECopyComponent;
  28. import epson.print.copy.Component.ecopycomponent.ECopyOptionContext;
  29. import epson.print.copy.Component.ecopycomponent.ECopyOptionItem;
  30. import epson.print.copy.Component.eremoteoperation.ERemoteDevice;
  31. import epson.print.copy.Component.eremoteoperation.ERemoteOperation;
  32. import epson.print.widgets.LongTapRepeatAdapter;
  33. import java.util.ArrayList;
  34. import java.util.Iterator;
  35. import java.util.Locale;
  36. public class CopyActivity extends ActivityBase implements View.OnClickListener {
  37. private static final int CONNECTION_TIMEOUT = 30000;
  38. private static final int EPS_COMM_BID = 2;
  39. private static final int REQUEST_CODE_REPEAT_COPY = 12;
  40. private final int COMM_ERROR = 1;
  41. private final int PROBE_PRINTER = 0;
  42. private String TAG = "CopyActivty";
  43. private final int UPDATE_SETTING = 2;
  44. boolean bProbedPrinter = false;
  45. private int clearindex = 0;
  46. CopyProcess copyProcess;
  47. private boolean doClear = false;
  48. private ActivityBase.errorDialog errordialog;
  49. private String ipAdress;
  50. private RadioGroup mCopyTypeGroup;
  51. Handler mHandler = new Handler(new Handler.Callback() {
  52. public boolean handleMessage(Message message) {
  53. EPLog.i(TAG, "HandlerCallback");
  54. switch (message.what) {
  55. case 0:
  56. EPLog.i(TAG, "PROBE_PRINTER");
  57. CopyActivity copyActivity = CopyActivity.this;
  58. ProbePrinter unused = copyActivity.task = new ProbePrinter();
  59. task.execute(new Void[0]);
  60. return true;
  61. case 1:
  62. EPLog.i(TAG, "COMM_ERROR");
  63. CopyActivity copyActivity2 = CopyActivity.this;
  64. ActivityBase.errorDialog unused2 = copyActivity2.errordialog = new ActivityBase.errorDialog(copyActivity2);
  65. errordialog.showErrorDialog(getString(R.string.EPS_PRNERR_COMM_TITLE), getString(R.string.EPS_PRNERR_COMM5), ActivityBase.DialogButtons.Ok, new ActivityBase.IClose() {
  66. public void onClose(ActivityBase.ClickButton clickButton) {
  67. finish();
  68. }
  69. });
  70. return true;
  71. case 2:
  72. EPLog.i(TAG, "UPDATE_SETTING");
  73. if (optionContext == null) {
  74. fetchCopyOptionContext();
  75. return true;
  76. }
  77. CopyActivity copyActivity3 = CopyActivity.this;
  78. copyActivity3.optionContext = copyActivity3.copyComponent.getBindedCopyOptionContext();
  79. copyComponent.bindCopyOptionContext(optionContext, optionListener);
  80. CopyActivity copyActivity4 = CopyActivity.this;
  81. copyActivity4.buildCopyOptions(copyActivity4.copyComponent.getCopyOptionItems());
  82. return true;
  83. default:
  84. return true;
  85. }
  86. }
  87. });
  88. private ViewGroup mLayout;
  89. private RadioButton mNormalCopyButton;
  90. private MaintainPrinter2 mPrinter;
  91. private RadioButton mRepeatCopyButton;
  92. ECopyComponent.ICopyOptionListener optionListener;
  93. ActivityBase.OptionItemChangedListener optionValueChangedListener;
  94. private ActivityBase.settingPreference presettings = new ActivityBase.settingPreference();
  95. private int printerLocation;
  96. ECopyComponent.ICopySystemSettings systemSettings;
  97. private ProbePrinter task;
  98. public void onCreate(Bundle bundle) {
  99. super.onCreate(bundle);
  100. copyComponent.getRemoteOperationUUID(this);
  101. optionContext = null;
  102. mLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.copy, (ViewGroup) null);
  103. setContentView((View) mLayout);
  104. setupUi();
  105. setActionBar((int) R.string.FunctionName_iPrint_Copy, true);
  106. if (mPrinter == null) {
  107. mPrinter = MaintainPrinter2.getInstance();
  108. }
  109. optionValueChangedListener = new ActivityBase.OptionItemChangedListener() {
  110. public void onOptionItemChanged(ECopyOptionItem eCopyOptionItem) {
  111. copyComponent.setCopyOptionItem(eCopyOptionItem);
  112. }
  113. };
  114. optionListener = new ECopyComponent.ICopyOptionListener() {
  115. public void onCopyOptionChanged(ECopyOptionItem eCopyOptionItem, ArrayList<ECopyOptionItem> arrayList, ECopyComponent.ICopyOptionListener.CopyOptionChangedError copyOptionChangedError) {
  116. if (copyOptionChangedError != null) {
  117. loading.dismiss();
  118. CopyActivity copyActivity = CopyActivity.this;
  119. ActivityBase.errorDialog errordialog = new ActivityBase.errorDialog(copyActivity);
  120. String[] reasonText = errordialog.getReasonText(copyOptionChangedError);
  121. errordialog.showErrorDialog(reasonText[0], reasonText[1]);
  122. return;
  123. }
  124. ArrayList arrayList2 = new ArrayList();
  125. if (doClear) {
  126. if (clearindex != copyComponent.getCopyOptionItems().size()) {
  127. allClear();
  128. return;
  129. }
  130. boolean unused = doClear = false;
  131. int unused2 = clearindex = 0;
  132. arrayList2.addAll(copyComponent.getCopyOptionItems());
  133. }
  134. arrayList2.add(eCopyOptionItem);
  135. if (arrayList != null) {
  136. arrayList2.addAll(arrayList);
  137. }
  138. buildCopyOptions(arrayList2);
  139. }
  140. };
  141. }
  142. public void onResume() {
  143. EPLog.v(TAG, "onResume()");
  144. super.onResume();
  145. isKeepSimpleAPConnection = false;
  146. getPrinterInfo();
  147. CopyProcess copyProcess2 = copyProcess;
  148. if (copyProcess2 == null || !copyProcess2.isProccessing()) {
  149. if (!WiFiDirectManager.isNeedConnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER)) {
  150. isTryConnectSimpleAp = false;
  151. } else if (!isTryConnectSimpleAp) {
  152. isTryConnectSimpleAp = true;
  153. if (WiFiDirectManager.reconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, -1)) {
  154. isKeepSimpleAPConnection = true;
  155. bProbedPrinter = false;
  156. return;
  157. }
  158. }
  159. loading.show();
  160. if (!bProbedPrinter) {
  161. mHandler.sendEmptyMessage(0);
  162. } else {
  163. mHandler.sendEmptyMessage(2);
  164. }
  165. } else {
  166. copyProcess.setDisconnectWifi(false);
  167. }
  168. }
  169. public void onPause() {
  170. EPLog.v(TAG, "onPause()");
  171. super.onPause();
  172. int i = printerLocation;
  173. if (i == 1 || i == 3) {
  174. ProbePrinter probePrinter = task;
  175. if (probePrinter != null) {
  176. probePrinter.cancel(true);
  177. }
  178. CopyProcess copyProcess2 = copyProcess;
  179. if (copyProcess2 != null && copyProcess2.isProccessing()) {
  180. copyProcess.setDisconnectWifi(true);
  181. } else if (!isKeepSimpleAPConnection) {
  182. WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, ActivityBase.printerIp);
  183. }
  184. }
  185. if (isFinishing()) {
  186. deleteLongTapMessage();
  187. }
  188. }
  189. protected void onDestroy() {
  190. super.onDestroy();
  191. }
  192. protected void onActivityResult(int i, int i2, Intent intent) {
  193. if (i == 12) {
  194. if (i2 == -1) {
  195. finish();
  196. } else {
  197. mNormalCopyButton.setChecked(true);
  198. }
  199. }
  200. }
  201. private void setupUi() {
  202. findViewById(R.id.color).setOnClickListener(this);
  203. findViewById(R.id.scale).setOnClickListener(this);
  204. findViewById(R.id.paper_size).setOnClickListener(this);
  205. findViewById(R.id.paper_type).setOnClickListener(this);
  206. findViewById(R.id.paper_source).setOnClickListener(this);
  207. findViewById(R.id.document_type).setOnClickListener(this);
  208. findViewById(R.id.quality).setOnClickListener(this);
  209. findViewById(R.id.copy_setting_clear_all).setOnClickListener(this);
  210. findViewById(R.id.copy_button).setOnClickListener(this);
  211. LongTapRepeatAdapter.bless(findViewById(R.id.SettingButonCopiesCountUp));
  212. LongTapRepeatAdapter.bless(findViewById(R.id.SettingButonCopiesCountDown));
  213. LongTapRepeatAdapter.bless(findViewById(R.id.SettingButonXDensityCountUp));
  214. LongTapRepeatAdapter.bless(findViewById(R.id.SettingButonXDensityCountDown));
  215. mCopyTypeGroup = (RadioGroup) findViewById(R.id.copy_type_group);
  216. mNormalCopyButton = (RadioButton) findViewById(R.id.normal_copy_tab);
  217. mNormalCopyButton.setChecked(true);
  218. mNormalCopyButton.setEnabled(false);
  219. mNormalCopyButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  220. public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
  221. }
  222. });
  223. mRepeatCopyButton = (RadioButton) findViewById(R.id.repeat_copy_tab);
  224. mRepeatCopyButton.setChecked(false);
  225. mNormalCopyButton.setEnabled(false);
  226. mRepeatCopyButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  227. public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
  228. if (z) {
  229. switchToRepeatCopy();
  230. }
  231. }
  232. });
  233. }
  234. private void switchToRepeatCopy() {
  235. isKeepSimpleAPConnection = true;
  236. startActivityForResult(new Intent(this, epson.print.rpcopy.CopyActivity.class), 12);
  237. }
  238. public void onClick(View view) {
  239. Intent intent = new Intent();
  240. switch (view.getId()) {
  241. case R.id.color /*2131230930*/:
  242. intent.setClass(getBaseContext(), CopySettingActivity.class);
  243. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.ColorEffectsType.name());
  244. startActivityAndKeepSimpleAp(intent);
  245. return;
  246. case R.id.copy_button /*2131230948*/:
  247. String str = TAG;
  248. EPLog.i(str, "NOW_PRINTER:" + printerId);
  249. presettings.saveCopyOptions(copyComponent.getCopyOptionItems());
  250. copyProcess = new CopyProcess(this);
  251. copyProcess.startCopy(getApplicationContext());
  252. return;
  253. case R.id.copy_setting_clear_all /*2131230967*/:
  254. allClear();
  255. return;
  256. case R.id.document_type /*2131231000*/:
  257. intent.setClass(getBaseContext(), CopySettingActivity.class);
  258. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.ScanContentType.name());
  259. startActivityAndKeepSimpleAp(intent);
  260. return;
  261. case R.id.paper_size /*2131231306*/:
  262. intent.setClass(getBaseContext(), CopySettingActivity.class);
  263. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.PrintMediaSize.name());
  264. startActivityAndKeepSimpleAp(intent);
  265. return;
  266. case R.id.paper_source /*2131231311*/:
  267. intent.setClass(getBaseContext(), CopySettingActivity.class);
  268. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.PrintMediaSource.name());
  269. startActivityAndKeepSimpleAp(intent);
  270. return;
  271. case R.id.paper_type /*2131231314*/:
  272. intent.setClass(getBaseContext(), CopySettingActivity.class);
  273. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.PrintMediaType.name());
  274. startActivityAndKeepSimpleAp(intent);
  275. return;
  276. case R.id.quality /*2131231392*/:
  277. intent.setClass(getBaseContext(), CopySettingActivity.class);
  278. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.PrintQuality.name());
  279. startActivityAndKeepSimpleAp(intent);
  280. return;
  281. case R.id.scale /*2131231441*/:
  282. intent.setClass(getBaseContext(), CopyScaleActivity.class);
  283. intent.putExtra("Key", ECopyOptionItem.ECopyOptionItemKey.XScale.name());
  284. startActivityAndKeepSimpleAp(intent);
  285. return;
  286. default:
  287. return;
  288. }
  289. }
  290. private void startActivityAndKeepSimpleAp(Intent intent) {
  291. isKeepSimpleAPConnection = true;
  292. startActivity(intent);
  293. }
  294. private void allClear() {
  295. doClear = true;
  296. loading.show();
  297. ArrayList<ECopyOptionItem> copyOptionItems = copyComponent.getCopyOptionItems();
  298. int i = clearindex;
  299. clearindex = i + 1;
  300. ECopyOptionItem eCopyOptionItem = copyOptionItems.get(i);
  301. switch (eCopyOptionItem.getKey()) {
  302. case ColorEffectsType:
  303. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.ColorEffectsType_Color);
  304. break;
  305. case ScanContentType:
  306. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.ScanContentType_Mixed);
  307. break;
  308. case PrintMediaType:
  309. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.PrintMediaType_Stationery);
  310. break;
  311. case PrintMediaSize:
  312. if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.US.getLanguage()) && eCopyOptionItem.getSelectableChoices().contains(ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_Letter)) {
  313. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_Letter);
  314. break;
  315. } else {
  316. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSize_A4);
  317. break;
  318. }
  319. break;
  320. case PrintMediaSource:
  321. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSource_Bottom);
  322. break;
  323. case PrintQuality:
  324. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.PrintQuality_Normal);
  325. break;
  326. case XScale:
  327. eCopyOptionItem.selectChoice(ECopyOptionItem.ECopyOptionItemChoice.XScale_Autofit);
  328. break;
  329. case XDensity:
  330. case CopyMagnification:
  331. case Copies:
  332. eCopyOptionItem.selectValue(eCopyOptionItem.getDefaultValue());
  333. break;
  334. }
  335. copyComponent.setCopyOptionItem(eCopyOptionItem);
  336. }
  337. private void fetchCopyOptionContext() {
  338. copyComponent.createCopyOptionContext(copyType, new ECopyComponent.ICopyOptionContextListener() {
  339. public void onCopyOptionContextCreated(ECopyComponent.ECopyType eCopyType, ECopyOptionContext eCopyOptionContext, ECopyComponent.ICopyOptionContextListener.ContextCreationError contextCreationError) {
  340. CopyActivity copyActivity = CopyActivity.this;
  341. copyActivity.optionContext = eCopyOptionContext;
  342. if (contextCreationError == null) {
  343. copyActivity.copyComponent.bindCopyOptionContext(optionContext, optionListener);
  344. ArrayList<ECopyOptionItem> copyOptionItems = copyComponent.getCopyOptionItems();
  345. if (ActivityBase.printerId.equalsIgnoreCase(presettings.loadPrePrinter())) {
  346. presettings.setCopyOptions(copyOptionItems);
  347. } else {
  348. buildCopyOptions(copyOptionItems);
  349. }
  350. } else {
  351. ActivityBase.errorDialog unused = copyActivity.errordialog = new ActivityBase.errorDialog(copyActivity);
  352. String[] reasonText = errordialog.getReasonText(contextCreationError);
  353. errordialog.showErrorDialog(reasonText[0], reasonText[1], ActivityBase.DialogButtons.Ok, new ActivityBase.IClose() {
  354. public void onClose(ActivityBase.ClickButton clickButton) {
  355. finish();
  356. }
  357. });
  358. }
  359. }
  360. });
  361. }
  362. private void buildCopyOptions(ArrayList<ECopyOptionItem> arrayList) {
  363. Iterator<ECopyOptionItem> it = arrayList.iterator();
  364. while (it.hasNext()) {
  365. ECopyOptionItem next = it.next();
  366. ECopyOptionItem.ECopyOptionItemKey key = next.getKey();
  367. switch (key) {
  368. case ColorEffectsType:
  369. String str = TAG;
  370. EPLog.i(str, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  371. updateSetting(R.id.copy_color_info, next);
  372. break;
  373. case ScanContentType:
  374. String str2 = TAG;
  375. EPLog.i(str2, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  376. updateSetting(R.id.copy_document_type_info, next);
  377. break;
  378. case PrintMediaType:
  379. String str3 = TAG;
  380. EPLog.i(str3, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  381. updateSetting(R.id.copy_paper_type_info, next);
  382. break;
  383. case PrintMediaSize:
  384. String str4 = TAG;
  385. EPLog.i(str4, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  386. updateSetting(R.id.copy_paper_size_info, next);
  387. break;
  388. case PrintMediaSource:
  389. String str5 = TAG;
  390. EPLog.i(str5, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  391. updateSetting(R.id.copy_paper_source_info, next);
  392. break;
  393. case PrintQuality:
  394. String str6 = TAG;
  395. EPLog.i(str6, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  396. updateSetting(R.id.copy_quality_info, next);
  397. break;
  398. case XScale:
  399. String str7 = TAG;
  400. EPLog.i(str7, "show " + key.name() + ":" + next.getSelectedChoice() + " setting");
  401. updateSetting(R.id.copy_scale_info, next);
  402. break;
  403. case XDensity:
  404. optionValueMap.put(key, new XDensityValue(next));
  405. break;
  406. case CopyMagnification:
  407. optionValueMap.put(key, new ActivityBase.CopyMagnificationValue(next));
  408. break;
  409. case Copies:
  410. optionValueMap.put(key, new CopiesValue(next));
  411. break;
  412. }
  413. loading.dismiss();
  414. }
  415. }
  416. private void updateSetting(int i, ECopyOptionItem eCopyOptionItem) {
  417. TextView textView = (TextView) mLayout.findViewById(i);
  418. if (eCopyOptionItem.getSelectedChoice() == ECopyOptionItem.ECopyOptionItemChoice.XScale_Custom) {
  419. textView.setText(getString(R.string.XScale_CustomSetting) + String.valueOf(((ActivityBase.NumberOptionValue) optionValueMap.get(ECopyOptionItem.ECopyOptionItemKey.CopyMagnification)).value) + " %");
  420. return;
  421. }
  422. textView.setText(string(eCopyOptionItem.getSelectedChoice().name()));
  423. }
  424. class CopiesValue extends ActivityBase.NumberOptionValue {
  425. public CopiesValue(ECopyOptionItem eCopyOptionItem) {
  426. super();
  427. bindOption(R.id.SettingEditCopies, eCopyOptionItem);
  428. bindCountUp(R.id.SettingButonCopiesCountUp);
  429. bindCountDown(R.id.SettingButonCopiesCountDown);
  430. setOptionValueChangedListener(optionValueChangedListener);
  431. }
  432. }
  433. class XDensityValue extends ActivityBase.NumberOptionValue {
  434. ImageView image;
  435. TypedArray images = getResources().obtainTypedArray(R.array.density_images);
  436. public XDensityValue(ECopyOptionItem eCopyOptionItem) {
  437. super();
  438. bindOption(R.id.density_image, eCopyOptionItem);
  439. bindCountUp(R.id.SettingButonXDensityCountUp);
  440. bindCountDown(R.id.SettingButonXDensityCountDown);
  441. setOptionValueChangedListener(optionValueChangedListener);
  442. }
  443. private void bindOption(int i, ECopyOptionItem eCopyOptionItem) {
  444. optionItem = eCopyOptionItem;
  445. value = eCopyOptionItem.getSelectedValue();
  446. image = (ImageView) findViewById(i);
  447. image.setImageDrawable(images.getDrawable(value + 4));
  448. image.setEnabled(eCopyOptionItem.isEnabled());
  449. }
  450. private void bindCountUp(int i) {
  451. countUp = (Button) findViewById(i);
  452. countUp.setOnClickListener(new CounterImage(1));
  453. if (value == optionItem.getMaximumValue()) {
  454. countUp.setEnabled(false);
  455. } else {
  456. countUp.setEnabled(true);
  457. }
  458. }
  459. private void bindCountDown(int i) {
  460. countDown = (Button) findViewById(i);
  461. countDown.setOnClickListener(new CounterImage(-1));
  462. if (value == optionItem.getMinimumValue()) {
  463. countDown.setEnabled(false);
  464. } else {
  465. countDown.setEnabled(true);
  466. }
  467. }
  468. class CounterImage extends ActivityBase.NumberOptionValue.Counter implements View.OnClickListener {
  469. public CounterImage(int i) {
  470. super(i);
  471. }
  472. private void updateImage(int i) {
  473. XDensityValue.value += i;
  474. XDensityValue.optionItem.selectValue(XDensityValue.value);
  475. if (XDensityValue.changedListener != null) {
  476. XDensityValue.changedListener.onOptionItemChanged(XDensityValue.optionItem);
  477. }
  478. }
  479. public void onClick(View view) {
  480. updateImage(amount);
  481. }
  482. }
  483. }
  484. private void getPrinterInfo() {
  485. MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
  486. printerId = curPrinter.getPrinterId();
  487. printerIp = curPrinter.getIp();
  488. printerLocation = curPrinter.getLocation();
  489. }
  490. private class ProbePrinter extends AsyncTask<Void, Void, Boolean> {
  491. private volatile boolean mRepeatCopyAvailable;
  492. protected void onPreExecute() {
  493. }
  494. private ProbePrinter() {
  495. }
  496. protected Boolean doInBackground(Void... voidArr) {
  497. EPLog.i(TAG, "ProbePrinter doInBackground");
  498. mRepeatCopyAvailable = false;
  499. if ((printerLocation != 1 && printerLocation != 3) || ActivityBase.printerId == null) {
  500. return false;
  501. }
  502. mPrinter.doInitDriver(CopyActivity.this, 2);
  503. if (mPrinter.doProbePrinter(60, ActivityBase.printerId, ActivityBase.printerIp, printerLocation) != 0) {
  504. return false;
  505. }
  506. int doSetPrinter = mPrinter.doSetPrinter();
  507. String access$200 = TAG;
  508. EPLog.i(access$200, "Set Printer result: " + doSetPrinter);
  509. if (doSetPrinter != 0) {
  510. return false;
  511. }
  512. CopyActivity copyActivity = CopyActivity.this;
  513. String unused = copyActivity.ipAdress = copyActivity.mPrinter.doGetIp();
  514. String access$2002 = TAG;
  515. EPLog.i(access$2002, "IPAdress : " + ipAdress);
  516. CopyActivity copyActivity2 = CopyActivity.this;
  517. copyActivity2.bProbedPrinter = true;
  518. copyActivity2.systemSettings = new ECopyComponent.ICopySystemSettings() {
  519. public int getThickPaper() {
  520. return 0;
  521. }
  522. public String getPrinterIPAddress() {
  523. String access$200 = TAG;
  524. EPLog.i(access$200, "getPrinterIPAddress : " + ipAdress);
  525. return ipAdress;
  526. }
  527. };
  528. ECopyComponent sharedComponent = ECopyComponent.sharedComponent();
  529. sharedComponent.setSystemSettings(systemSettings);
  530. sharedComponent.setProperty(ECopyComponent.Property.RequestConnectionTimeout, CopyActivity.CONNECTION_TIMEOUT);
  531. mRepeatCopyAvailable = checkRepeatCopyFunction();
  532. return true;
  533. }
  534. protected void onCancelled() {
  535. EPLog.i(TAG, "ProbePrinter onCancelled");
  536. super.onCancelled();
  537. mPrinter.doCancelFindPrinter();
  538. }
  539. protected void onPostExecute(Boolean bool) {
  540. EPLog.i(TAG, "ProbePrinter onPostExecute");
  541. changeRepeatCopyButtonState(mRepeatCopyAvailable);
  542. if (bool.booleanValue()) {
  543. mHandler.sendEmptyMessage(2);
  544. } else {
  545. mHandler.sendEmptyMessage(1);
  546. }
  547. }
  548. }
  549. private boolean checkRepeatCopyFunction() {
  550. ERemoteDevice eRemoteDevice = new ERemoteDevice();
  551. eRemoteDevice.setHostIP(ipAdress);
  552. eRemoteDevice.setRequestConnectionTimeout(CONNECTION_TIMEOUT);
  553. ERemoteDevice.ERemoteDeviceFunctionsResult executeGetFunctionsCommand = eRemoteDevice.executeGetFunctionsCommand(Utils.getRemoteOperationUUID(getApplicationContext()));
  554. return executeGetFunctionsCommand.success() && executeGetFunctionsCommand.functions().contains(ERemoteOperation.ERemoteParam.repeat_copy);
  555. }
  556. private void changeRepeatCopyButtonState(boolean z) {
  557. int i;
  558. boolean z2 = false;
  559. if (z) {
  560. i = 0;
  561. z2 = true;
  562. } else {
  563. i = 8;
  564. }
  565. mCopyTypeGroup.setVisibility(i);
  566. mRepeatCopyButton.setEnabled(z2);
  567. }
  568. protected void deleteLongTapMessage() {
  569. MotionEvent obtain = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis() + 10, 1, 0.0f, 0.0f, 0);
  570. findViewById(R.id.SettingButonCopiesCountUp).dispatchTouchEvent(obtain);
  571. findViewById(R.id.SettingButonCopiesCountDown).dispatchTouchEvent(obtain);
  572. findViewById(R.id.SettingButonXDensityCountUp).dispatchTouchEvent(obtain);
  573. findViewById(R.id.SettingButonXDensityCountDown).dispatchTouchEvent(obtain);
  574. }
  575. public void onConfigurationChanged(Configuration configuration) {
  576. super.onConfigurationChanged(configuration);
  577. deleteLongTapMessage();
  578. }
  579. }