CopyActivity.java 28 KB

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