CopyActivity.java 30 KB

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