SettingScr.java 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. package epson.print.screen;
  2. import android.content.ComponentName;
  3. import android.content.Context;
  4. import android.content.DialogInterface;
  5. import android.content.Intent;
  6. import android.content.ServiceConnection;
  7. import android.content.SharedPreferences;
  8. import android.content.res.Configuration;
  9. import android.os.AsyncTask;
  10. import android.os.Bundle;
  11. import android.os.Handler;
  12. import android.os.IBinder;
  13. import android.os.RemoteException;
  14. import android.os.SystemClock;
  15. import android.view.Menu;
  16. import android.view.MenuItem;
  17. import android.view.MotionEvent;
  18. import android.view.View;
  19. import android.widget.Button;
  20. import android.widget.ImageView;
  21. import android.widget.LinearLayout;
  22. import android.widget.TextView;
  23. import com.epson.mobilephone.common.escpr.EscprError;
  24. import com.epson.mobilephone.common.escpr.MediaInfo;
  25. import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
  26. import java.io.File;
  27. import epson.common.Constants;
  28. import epson.common.ExternalFileUtils;
  29. import epson.common.Utils;
  30. import epson.print.ActivityIACommon;
  31. import epson.print.EPPrinterManager;
  32. import epson.print.MyPrinter;
  33. import epson.print.R;
  34. import epson.print.Util.EPLog;
  35. import epson.print.inkrpln.InkRplnRepository;
  36. import epson.print.service.EpsonService;
  37. import epson.print.service.IEpsonService;
  38. import epson.print.service.IEpsonServiceCallback;
  39. import epson.print.widgets.CustomTitleAlertDialogBuilder;
  40. import epson.print.widgets.LayoutEx;
  41. import epson.print.widgets.LongTapRepeatAdapter;
  42. public class SettingScr extends ActivityIACommon implements View.OnClickListener {
  43. private static final String EXTRA_PRINTER = "myprinter";
  44. private static final String EXTRA_SIMPLEAP = "simpleap";
  45. private static final int REQUEST_CODE_INFO = 1;
  46. private static final int REQUEST_CODE_INK_REPLENISH_PROGRESS = 4;
  47. private static final int REQUEST_CODE_PAGE_RANGE = 2;
  48. private static final int REQUEST_CODE_PRINTER = 0;
  49. public static final String TAG = "PrintSetting";
  50. private final int COLOR_VALUE_MAX = 50;
  51. private final int COLOR_VALUE_MIN = -50;
  52. private final int COPIES_MAX = 30;
  53. private final int COPIES_MIN = 1;
  54. private final int EPS_ERR_COMM_ERROR = -1100;
  55. private final int EPS_ERR_NONE = 0;
  56. private final int EPS_ERR_OPR_FAIL = -1000;
  57. private final int EPS_ERR_PRINTER_NOT_SET = EscprError.EPS_ERR_PRINTER_NOT_SET;
  58. private final int GET_ADVANCED = 64;
  59. private final int GET_COLOR = 6;
  60. private final int GET_DUPLEX = 32;
  61. private final int GET_LAYOUT = 3;
  62. private final int GET_PAPER_SIZE = 1;
  63. private final int GET_PAPER_SOURCE = 5;
  64. private final int GET_PAPER_TYPE = 2;
  65. private final int GET_QUALITY = 4;
  66. private final int GET_SUPPORTED_MEDIA = 0;
  67. private final int PROBE_PRINTER = 17;
  68. private final int SEARCH_BY_ID = 7;
  69. private final int SEARCH_ERROR = 16;
  70. private final int SETTING_DONE = 3;
  71. private final int SHOW_ERROR_DIALOG = 18;
  72. private TextView apfStateText;
  73. private String autoConnectSsid = null;
  74. private TextView brightness;
  75. private Button brightnessMinus;
  76. private Button brightnessPlus;
  77. private int brightnessValue;
  78. private int color;
  79. private TextView colorInfo;
  80. private int[] color_info = null;
  81. private TextView contrast;
  82. private Button contrastMinus;
  83. private Button contrastPlus;
  84. private int contrastValue;
  85. private TextView copies;
  86. private Button copiesMinus;
  87. private Button copiesPlus;
  88. private int copiesValue;
  89. private boolean disablePrintArea = false;
  90. private int duplex;
  91. private TextView duplexInfo;
  92. private int[] duplex_info = null;
  93. private boolean enableShowPreview = false;
  94. private int endValue;
  95. private int feedDirection;
  96. private TextView feedDirectionInfo;
  97. private int[] info = null;
  98. private boolean isDocumentSetting = true;
  99. boolean isInfoAvai = false;
  100. Boolean isNotLoading = true;
  101. private boolean isRetryAfterConnectSimpleAp = false;
  102. private boolean isTryConnectSimpleAp = false;
  103. private int lang = 1;
  104. private int layout;
  105. private TextView layoutInfo;
  106. private int[] layout_info = null;
  107. private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
  108. public void onGetInkState() throws RemoteException {
  109. }
  110. public void onGetStatusState() throws RemoteException {
  111. }
  112. public void onNotifyEndJob(int i) throws RemoteException {
  113. }
  114. public void onNotifyProgress(int i, int i2) throws RemoteException {
  115. }
  116. public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
  117. String unused = printerIp = str2;
  118. }
  119. public void onNotifyContinueable(int i) throws RemoteException {
  120. if (!mFinishRequested) {
  121. EPLog.i("IEpsonServiceCallback", "onNotifyContinueable code = " + i);
  122. if (i == 0) {
  123. SettingScr settingScr = SettingScr.this;
  124. settingScr.isInfoAvai = true;
  125. int unused = settingScr.lang = settingScr.getPrinterLang();
  126. SettingScr settingScr2 = SettingScr.this;
  127. settingScr2.undoFlag = false;
  128. settingScr2.mHandler.sendEmptyMessage(0);
  129. }
  130. }
  131. }
  132. public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
  133. if (!mFinishRequested) {
  134. EPLog.i("IEpsonServiceCallback", "onNotifyError errorCode = " + i2);
  135. SettingScr settingScr = SettingScr.this;
  136. settingScr.isInfoAvai = true;
  137. int unused = settingScr.lang = settingScr.getPrinterLang();
  138. SettingScr settingScr2 = SettingScr.this;
  139. settingScr2.undoFlag = false;
  140. settingScr2.mHandler.sendEmptyMessage(0);
  141. }
  142. }
  143. };
  144. private Context mContext = null;
  145. private ServiceConnection mEpsonConnection = new ServiceConnection() {
  146. public void onServiceDisconnected(ComponentName componentName) {
  147. EPLog.v("SettingScr", "onServiceDisconnected");
  148. try {
  149. mEpsonService.unregisterCallback (mCallback);
  150. } catch (RemoteException e) {
  151. e.printStackTrace();
  152. }
  153. IEpsonService unused = mEpsonService = null;
  154. }
  155. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  156. IEpsonService unused = mEpsonService = IEpsonService.Stub.asInterface(iBinder);
  157. EPLog.v("SettingScr", "onServiceConnected");
  158. if (mEpsonService != null) {
  159. try {
  160. mEpsonService.registerCallback (mCallback);
  161. } catch (RemoteException e) {
  162. e.printStackTrace();
  163. }
  164. }
  165. }
  166. };
  167. private IEpsonService mEpsonService = null;
  168. private volatile boolean mFinishRequested;
  169. Handler mHandler = new Handler(new Handler.Callback() {
  170. public boolean handleMessage(android.os.Message r15) {
  171. throw new UnsupportedOperationException("Method not decompiled: epson.print.screen.SettingScr.C23643.handleMessage(android.os.Message):boolean");
  172. }
  173. });
  174. private MediaInfo.AbstractInfo mLookupTable;
  175. private MediaInfo.AbstractInfo mPaperSizeType;
  176. private boolean mPrinterSelectDone;
  177. private int mSharpnessValue;
  178. private TextView mSharpnessValueText;
  179. private boolean mWaiteInkReplenProgress;
  180. private int paperSize;
  181. private TextView paperSizeInfo;
  182. private int paperSource;
  183. private TextView paperSourceInfo;
  184. private int paperType;
  185. private TextView paperTypeInfo;
  186. private int[] paper_size_info = null;
  187. private int[] paper_source_info = null;
  188. private int[] paper_type_info = null;
  189. private int photoApfValueForLocalPrinter;
  190. private boolean printAll;
  191. private TextView printDateInfo;
  192. private int printdate;
  193. private MyPrinter printer = null;
  194. private String printerDeviceId;
  195. private String printerEmailAddress;
  196. private String printerId;
  197. private String printerIp;
  198. private int printerLocation;
  199. private TextView printerName;
  200. private String printerSerialNo;
  201. private View progressGetOption;
  202. private int quality;
  203. private TextView qualityInfo;
  204. private int[] quality_info = null;
  205. private TextView saturation;
  206. private Button saturationMinus;
  207. private Button saturationPlus;
  208. private int saturationValue;
  209. private int sheets = 1;
  210. private int sizeIndex = 0;
  211. private int startValue;
  212. private int typeIndex = 0;
  213. boolean undoFlag = true;
  214. static /* synthetic */ int access$1208(SettingScr settingScr) {
  215. int i = settingScr.sizeIndex;
  216. settingScr.sizeIndex = i + 1;
  217. return i;
  218. }
  219. static /* synthetic */ int access$1708(SettingScr settingScr) {
  220. int i = settingScr.typeIndex;
  221. settingScr.typeIndex = i + 1;
  222. return i;
  223. }
  224. protected void onCreate(Bundle bundle) {
  225. super.onCreate(bundle);
  226. setContentView((int) R.layout.setting_layout);
  227. setActionBar((int) R.string.str_btn_printer_settings, true);
  228. bindEpsonService();
  229. mContext = this;
  230. isDocumentSetting = getIntent().getBooleanExtra(PrintProgress.PARAM_DOCUMENT_MODE, false);
  231. if (isDocumentSetting) {
  232. sheets = getIntent().getIntExtra("SHEETS", 1);
  233. disablePrintArea = getIntent().getBooleanExtra("PRINTAREA", false);
  234. }
  235. printerName = (TextView) findViewById(R.id.printer_name);
  236. paperSizeInfo = (TextView) findViewById(R.id.paper_size_info);
  237. paperTypeInfo = (TextView) findViewById(R.id.paper_type_info);
  238. layoutInfo = (TextView) findViewById(R.id.layout_info);
  239. qualityInfo = (TextView) findViewById(R.id.quality_info);
  240. paperSourceInfo = (TextView) findViewById(R.id.paper_source_info);
  241. copies = (TextView) findViewById(R.id.copies);
  242. copiesMinus = (Button) findViewById(R.id.copies_minus_button);
  243. copiesPlus = (Button) findViewById(R.id.copies_plus_button);
  244. LongTapRepeatAdapter.bless(copiesMinus);
  245. LongTapRepeatAdapter.bless(copiesPlus);
  246. colorInfo = (TextView) findViewById(R.id.color_info);
  247. duplexInfo = (TextView) findViewById(R.id.duplex_info);
  248. feedDirectionInfo = (TextView) findViewById(R.id.feed_direction_info);
  249. printDateInfo = (TextView) findViewById(R.id.printdate_info);
  250. apfStateText = (TextView) findViewById(R.id.apf_setting_text);
  251. mSharpnessValueText = (TextView) findViewById(R.id.sharpness_setting_text);
  252. brightness = (TextView) findViewById(R.id.brightness);
  253. brightnessMinus = (Button) findViewById(R.id.brightness_minus_button);
  254. brightnessPlus = (Button) findViewById(R.id.brightness_plus_button);
  255. contrast = (TextView) findViewById(R.id.contrast);
  256. contrastMinus = (Button) findViewById(R.id.contrast_minus_button);
  257. contrastPlus = (Button) findViewById(R.id.contrast_plus_button);
  258. saturation = (TextView) findViewById(R.id.saturation);
  259. saturationMinus = (Button) findViewById(R.id.saturation_minus_button);
  260. saturationPlus = (Button) findViewById(R.id.saturation_plus_button);
  261. progressGetOption = findViewById(R.id.progressGetOption);
  262. enableShowPreview = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
  263. loadConfig();
  264. setClickListener();
  265. updatePrinterIcon();
  266. if (printerId != null) {
  267. undoFlag = false;
  268. if (loadSupportedMediaFile()) {
  269. mHandler.sendEmptyMessage(1);
  270. } else {
  271. mHandler.sendEmptyMessage(17);
  272. }
  273. } else {
  274. mHandler.sendEmptyMessage(1);
  275. }
  276. }
  277. private void updatePrinterIcon() {
  278. if (printerName.getText().equals(getString(R.string.str_lbl_title_scan))) {
  279. ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setVisibility(8);
  280. return;
  281. }
  282. ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setVisibility(0);
  283. switch (printerLocation) {
  284. case 1:
  285. ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setImageResource(R.drawable.print_local);
  286. return;
  287. case 2:
  288. ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setImageResource(R.drawable.print_remote);
  289. return;
  290. case 3:
  291. ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setImageResource(R.drawable.print_ip);
  292. return;
  293. default:
  294. return;
  295. }
  296. }
  297. private void setClickListener() {
  298. copiesMinus.setOnClickListener(this);
  299. copiesPlus.setOnClickListener(this);
  300. brightnessMinus.setOnClickListener(this);
  301. brightnessPlus.setOnClickListener(this);
  302. contrastMinus.setOnClickListener(this);
  303. contrastPlus.setOnClickListener(this);
  304. saturationMinus.setOnClickListener(this);
  305. saturationPlus.setOnClickListener(this);
  306. if (isDocumentSetting) {
  307. findViewById(R.id.page_range_setting).setOnClickListener(this);
  308. }
  309. findViewById(R.id.printer).setOnClickListener(this);
  310. findViewById(R.id.paper_size).setOnClickListener(this);
  311. findViewById(R.id.paper_type).setOnClickListener(this);
  312. findViewById(R.id.layout).setOnClickListener(this);
  313. findViewById(R.id.quality).setOnClickListener(this);
  314. findViewById(R.id.paper_source).setOnClickListener(this);
  315. findViewById(R.id.color).setOnClickListener(this);
  316. findViewById(R.id.duplex).setOnClickListener(this);
  317. findViewById(R.id.feed_direction).setOnClickListener(this);
  318. findViewById(R.id.printdate).setOnClickListener(this);
  319. findViewById(R.id.apf_setting_layout).setOnClickListener(this);
  320. findViewById(R.id.sharpness_setting_layout).setOnClickListener(this);
  321. }
  322. private void loadConfig() {
  323. MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
  324. if (curPrinter == null || curPrinter.getName() == null) {
  325. printerName.setText(getString(R.string.str_lbl_title_scan));
  326. } else {
  327. printerName.setText(curPrinter.getUserDefName(this));
  328. }
  329. printerDeviceId = curPrinter.getName();
  330. printerId = curPrinter.getPrinterId();
  331. printerIp = curPrinter.getIp();
  332. printerSerialNo = curPrinter.getSerialNo();
  333. printerEmailAddress = curPrinter.getEmailAddress();
  334. printerLocation = curPrinter.getLocation();
  335. boolean z = true;
  336. if (printerLocation == 0) {
  337. printerLocation = 1;
  338. }
  339. autoConnectSsid = WiFiDirectManager.getConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_PRINTER);
  340. PrintSetting printSetting = new PrintSetting(this, isDocumentSetting ? PrintSetting.Kind.document : PrintSetting.Kind.photo);
  341. printSetting.loadSettings();
  342. mLookupTable = new MediaInfo.PaperSize();
  343. paperSize = printSetting.paperSizeValue;
  344. paperSizeInfo.setText(getString(mLookupTable.getStringId(paperSize)));
  345. mLookupTable.destructor();
  346. mLookupTable = new MediaInfo.PaperType();
  347. paperType = printSetting.paperTypeValue;
  348. paperTypeInfo.setText(getString(mLookupTable.getStringId(paperType)));
  349. mLookupTable.destructor();
  350. mPaperSizeType = printSetting.loadPaperSizeTypePear();
  351. mPaperSizeType.putID(paperSize, paperType);
  352. mLookupTable = new LayoutEx();
  353. int i = printSetting.layoutMultiPageValue;
  354. if (i != 0) {
  355. layout = i;
  356. } else {
  357. layout = printSetting.layoutValue;
  358. }
  359. layoutInfo.setText(getString(mLookupTable.getStringId(layout)));
  360. mLookupTable.destructor();
  361. mLookupTable = new MediaInfo.Quality();
  362. quality = printSetting.qualityValue;
  363. qualityInfo.setText(getString(mLookupTable.getStringId(quality)));
  364. mLookupTable.destructor();
  365. mLookupTable = new MediaInfo.PaperSource();
  366. paperSource = printSetting.paperSourceValue;
  367. paperSourceInfo.setText(getString(mLookupTable.getStringId(paperSource)));
  368. mLookupTable.destructor();
  369. mLookupTable = new MediaInfo.Color();
  370. color = printSetting.colorValue;
  371. colorInfo.setText(getString(mLookupTable.getStringId(color)));
  372. mLookupTable.destructor();
  373. copiesValue = printSetting.copiesValue;
  374. copies.setText(String.valueOf(copiesValue));
  375. copiesMinus.setEnabled(copiesValue != 1);
  376. Button button = copiesPlus;
  377. if (copiesValue == 30) {
  378. z = false;
  379. }
  380. button.setEnabled(z);
  381. brightnessValue = printSetting.brightnessValue;
  382. contrastValue = printSetting.contrastValue;
  383. saturationValue = printSetting.saturationValue;
  384. mLookupTable = new MediaInfo.Duplex();
  385. duplex = printSetting.duplexValue;
  386. duplexInfo.setText(getString(mLookupTable.getStringId(duplex)));
  387. mLookupTable.destructor();
  388. mLookupTable = new MediaInfo.FeedDirection();
  389. feedDirection = printSetting.feedDirectionValue;
  390. feedDirectionInfo.setText(getString(mLookupTable.getStringId(feedDirection)));
  391. mLookupTable.destructor();
  392. lang = curPrinter.getLang();
  393. if (isDocumentSetting) {
  394. printAll = printSetting.printAll;
  395. startValue = printSetting.startValue;
  396. endValue = printSetting.endValue;
  397. ((TextView) findViewById(R.id.page_range_value)).setText(startValue + ".." + endValue);
  398. return;
  399. }
  400. mLookupTable = new MediaInfo.PrintDate();
  401. printdate = printSetting.printdate;
  402. printDateInfo.setText(getString(mLookupTable.getStringId(printdate)));
  403. mLookupTable.destructor();
  404. photoApfValueForLocalPrinter = printSetting.photoApfValueForLocalPrinter;
  405. displayApfState(photoApfValueForLocalPrinter);
  406. mSharpnessValue = printSetting.sharpnessForPhoto;
  407. displaySharpnessState(mSharpnessValue);
  408. }
  409. private void displayApfState(int i) {
  410. MediaInfo.ApfState apfState = new MediaInfo.ApfState();
  411. apfStateText.setText(apfState.getStringId(i));
  412. apfState.destructor();
  413. }
  414. private void displaySharpnessState(int i) {
  415. MediaInfo.SharpnessState sharpnessState = new MediaInfo.SharpnessState();
  416. mSharpnessValueText.setText(sharpnessState.getStringId(i));
  417. sharpnessState.destructor();
  418. }
  419. private boolean loadSupportedMediaFile() {
  420. ExternalFileUtils instance = ExternalFileUtils.getInstance(this);
  421. File savedSupportedMedia = instance.getSavedSupportedMedia();
  422. File supportedMedia = instance.getSupportedMedia();
  423. File preSupportedMedia = instance.getPreSupportedMedia();
  424. EPLog.i("PrintSetting", "call loadSupportedMedia");
  425. try {
  426. if (!savedSupportedMedia.exists()) {
  427. EPLog.w("loadSupportedMedia", savedSupportedMedia.getName() + " not exist");
  428. return false;
  429. }
  430. Utils.copyFile(savedSupportedMedia, supportedMedia);
  431. Utils.copyFile(savedSupportedMedia, preSupportedMedia);
  432. File savedAreaInfo = instance.getSavedAreaInfo();
  433. File areaInfo = instance.getAreaInfo();
  434. File preAreaInfo = instance.getPreAreaInfo();
  435. try {
  436. if (!savedAreaInfo.exists()) {
  437. return true;
  438. }
  439. Utils.copyFile(savedAreaInfo, areaInfo);
  440. Utils.copyFile(savedAreaInfo, preAreaInfo);
  441. return true;
  442. } catch (Exception e) {
  443. EPLog.w("loadSupportedMedia", "failure " + e.getMessage());
  444. return false;
  445. }
  446. } catch (Exception e2) {
  447. EPLog.w("loadSupportedMedia", "failure " + e2.getMessage());
  448. return false;
  449. }
  450. }
  451. private boolean updateSupportedMediaFile(boolean z) {
  452. ExternalFileUtils instance = ExternalFileUtils.getInstance(this);
  453. EPLog.i("PrintSetting", "call updateSupportedMedia");
  454. File supportedMedia = instance.getSupportedMedia();
  455. File preSupportedMedia = instance.getPreSupportedMedia();
  456. if (z) {
  457. File file = preSupportedMedia;
  458. preSupportedMedia = supportedMedia;
  459. supportedMedia = file;
  460. }
  461. try {
  462. Utils.copyFile(supportedMedia, preSupportedMedia);
  463. File areaInfo = instance.getAreaInfo();
  464. File preAreaInfo = instance.getPreAreaInfo();
  465. if (!z) {
  466. File file2 = areaInfo;
  467. areaInfo = preAreaInfo;
  468. preAreaInfo = file2;
  469. }
  470. try {
  471. if (!preAreaInfo.exists()) {
  472. return true;
  473. }
  474. Utils.copyFile(preAreaInfo, areaInfo);
  475. return true;
  476. } catch (Exception e) {
  477. if (preAreaInfo != null && preAreaInfo.exists()) {
  478. preAreaInfo.delete();
  479. }
  480. if (areaInfo != null && areaInfo.exists()) {
  481. areaInfo.delete();
  482. }
  483. EPLog.w("updateSupportedMediaFile", "failure " + e.getMessage());
  484. return false;
  485. }
  486. } catch (Exception e2) {
  487. if (supportedMedia != null && supportedMedia.exists()) {
  488. supportedMedia.delete();
  489. }
  490. if (preSupportedMedia != null && preSupportedMedia.exists()) {
  491. preSupportedMedia.delete();
  492. }
  493. EPLog.w("updateSupportedMediaFile", "failure " + e2.getMessage());
  494. return false;
  495. }
  496. }
  497. private boolean saveSupportedMediaFile() {
  498. ExternalFileUtils instance = ExternalFileUtils.getInstance(this);
  499. EPLog.i("PrintSetting", "call saveSupportedMedia");
  500. File supportedMedia = instance.getSupportedMedia();
  501. File savedSupportedMedia = instance.getSavedSupportedMedia();
  502. try {
  503. if (!supportedMedia.exists()) {
  504. EPLog.w("updateSupportedMediaFile", supportedMedia.getName() + " not exist");
  505. return false;
  506. }
  507. Utils.copyFile(supportedMedia, savedSupportedMedia);
  508. File areaInfo = instance.getAreaInfo();
  509. File savedAreaInfo = instance.getSavedAreaInfo();
  510. int i = printerLocation;
  511. if (i == 1 || i == 3) {
  512. try {
  513. if (!areaInfo.exists()) {
  514. EPLog.w("updateSupportedMediaFile", areaInfo.getName() + " not exist");
  515. return false;
  516. }
  517. Utils.copyFile(areaInfo, savedAreaInfo);
  518. } catch (Exception e) {
  519. EPLog.w("saveSupportedMediaFile", "failure " + e.getMessage());
  520. return false;
  521. }
  522. } else {
  523. EPLog.i("PrintSetting", "delete AreaInfo");
  524. instance.removeAreaInfo();
  525. }
  526. return true;
  527. } catch (Exception e2) {
  528. EPLog.w("saveSupportedMediaFile", "failure " + e2.getMessage());
  529. return false;
  530. }
  531. }
  532. private void saveChanged() {
  533. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  534. edit.putInt(Constants.PREFS_INFO_PRINT_SAVE, 1);
  535. edit.commit();
  536. MyPrinter myPrinter = new MyPrinter(printerDeviceId, printerIp, printerId, printerSerialNo, printerEmailAddress, printerLocation);
  537. myPrinter.setLang(lang);
  538. myPrinter.setCurPrinter(this);
  539. PrintSetting printSetting = new PrintSetting(this, isDocumentSetting ? PrintSetting.Kind.document : PrintSetting.Kind.photo);
  540. printSetting.paperSizeValue = paperSize;
  541. printSetting.paperTypeValue = paperType;
  542. int i = layout;
  543. if ((-65536 & i) != 0) {
  544. printSetting.layoutValue = 2;
  545. printSetting.layoutMultiPageValue = i;
  546. } else {
  547. printSetting.layoutValue = i;
  548. printSetting.layoutMultiPageValue = 0;
  549. }
  550. printSetting.qualityValue = quality;
  551. printSetting.paperSourceValue = paperSource;
  552. printSetting.colorValue = color;
  553. printSetting.duplexValue = duplex;
  554. printSetting.feedDirectionValue = feedDirection;
  555. printSetting.copiesValue = copiesValue;
  556. printSetting.brightnessValue = brightnessValue;
  557. printSetting.contrastValue = contrastValue;
  558. printSetting.saturationValue = saturationValue;
  559. if (isDocumentSetting) {
  560. printSetting.printAll = printAll;
  561. printSetting.startValue = startValue;
  562. printSetting.endValue = endValue;
  563. } else {
  564. printSetting.printdate = printdate;
  565. printSetting.photoApfValueForLocalPrinter = photoApfValueForLocalPrinter;
  566. printSetting.sharpnessForPhoto = mSharpnessValue;
  567. }
  568. printSetting.saveSettings();
  569. printSetting.savePaperSizeTypePear((MediaInfo.PaperSizeType) mPaperSizeType);
  570. saveSupportedMediaFile();
  571. String str = autoConnectSsid;
  572. if (str == null || str.length() <= 0) {
  573. WiFiDirectManager.resetConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_PRINTER);
  574. } else {
  575. WiFiDirectManager.setConnectInfo(this, autoConnectSsid, WiFiDirectManager.DEVICE_TYPE_PRINTER, myPrinter.getName());
  576. }
  577. EPPrinterManager ePPrinterManager = new EPPrinterManager(mContext);
  578. ePPrinterManager.commitIPPrinterInfo();
  579. ePPrinterManager.commitRemotePrinterInfo();
  580. refreshRemoteServiceRemotePrinter();
  581. if (mPrinterSelectDone) {
  582. new InkRplnRepository(false).savePermanently(this);
  583. }
  584. }
  585. private void refreshRemoteServiceRemotePrinter() {
  586. IEpsonService iEpsonService = mEpsonService;
  587. if (iEpsonService != null) {
  588. try {
  589. iEpsonService.refreshRemotePrinterLogin();
  590. } catch (RemoteException unused) {
  591. }
  592. }
  593. }
  594. protected void onDestroy() {
  595. super.onDestroy();
  596. unbindEpsonService();
  597. EPLog.i("SettingScr", "onDestroy");
  598. mPaperSizeType.destructor();
  599. }
  600. private void bindEpsonService() {
  601. EPLog.v("SettingScr", "bindEpsonService");
  602. if (mEpsonService == null) {
  603. bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
  604. }
  605. }
  606. private void unbindEpsonService() {
  607. EPLog.v("SettingScr", "unbindEpsonService");
  608. IEpsonService iEpsonService = mEpsonService;
  609. if (iEpsonService != null) {
  610. try {
  611. iEpsonService.unregisterCallback(mCallback);
  612. unbindService(mEpsonConnection);
  613. mEpsonService = null;
  614. } catch (RemoteException e) {
  615. e.printStackTrace();
  616. }
  617. }
  618. }
  619. public void onClick(View view) {
  620. if (progressGetOption.getVisibility() == 8) {
  621. IEpsonService iEpsonService = mEpsonService;
  622. if (iEpsonService != null) {
  623. try {
  624. iEpsonService.cancelSearchPrinter();
  625. } catch (RemoteException e) {
  626. e.printStackTrace();
  627. }
  628. }
  629. switch (view.getId()) {
  630. case R.id.apf_setting_layout /*2131230819*/:
  631. launchDetailScreen(photoApfValueForLocalPrinter, R.id.apf_setting_layout);
  632. return;
  633. case R.id.brightness_minus_button /*2131230848*/:
  634. brightnessValue--;
  635. if (brightnessValue <= -50) {
  636. brightnessValue = -50;
  637. brightnessMinus.setEnabled(false);
  638. } else {
  639. brightnessMinus.setEnabled(true);
  640. }
  641. brightnessPlus.setEnabled(true);
  642. brightness.setText(String.valueOf(brightnessValue));
  643. return;
  644. case R.id.brightness_plus_button /*2131230850*/:
  645. brightnessValue++;
  646. if (brightnessValue >= 50) {
  647. brightnessValue = 50;
  648. brightnessPlus.setEnabled(false);
  649. } else {
  650. brightnessPlus.setEnabled(true);
  651. }
  652. brightnessMinus.setEnabled(true);
  653. brightness.setText(String.valueOf(brightnessValue));
  654. return;
  655. case R.id.color /*2131230930*/:
  656. launchDetailScreen(color, R.id.color);
  657. return;
  658. case R.id.contrast_minus_button /*2131230942*/:
  659. contrastValue--;
  660. if (contrastValue <= -50) {
  661. contrastValue = -50;
  662. contrastMinus.setEnabled(false);
  663. } else {
  664. contrastMinus.setEnabled(true);
  665. }
  666. contrastPlus.setEnabled(true);
  667. contrast.setText(String.valueOf(contrastValue));
  668. return;
  669. case R.id.contrast_plus_button /*2131230943*/:
  670. contrastValue++;
  671. if (contrastValue >= 50) {
  672. contrastValue = 50;
  673. contrastPlus.setEnabled(false);
  674. } else {
  675. contrastPlus.setEnabled(true);
  676. }
  677. contrastMinus.setEnabled(true);
  678. contrast.setText(String.valueOf(contrastValue));
  679. return;
  680. case R.id.copies_minus_button /*2131230945*/:
  681. copiesValue--;
  682. if (copiesValue <= 1) {
  683. copiesValue = 1;
  684. copiesMinus.setEnabled(false);
  685. } else {
  686. copiesMinus.setEnabled(true);
  687. }
  688. copiesPlus.setEnabled(true);
  689. copies.setText(String.valueOf(copiesValue));
  690. return;
  691. case R.id.copies_plus_button /*2131230946*/:
  692. copiesValue++;
  693. if (copiesValue >= 30) {
  694. copiesValue = 30;
  695. copiesPlus.setEnabled(false);
  696. } else {
  697. copiesPlus.setEnabled(true);
  698. }
  699. copiesMinus.setEnabled(true);
  700. copies.setText(String.valueOf(copiesValue));
  701. return;
  702. case R.id.duplex /*2131231005*/:
  703. launchDetailScreen(duplex, R.id.duplex);
  704. return;
  705. case R.id.feed_direction /*2131231037*/:
  706. launchDetailScreen(feedDirection, R.id.feed_direction);
  707. return;
  708. case R.id.layout /*2131231158*/:
  709. launchDetailScreen(layout, R.id.layout);
  710. return;
  711. case R.id.page_range_setting /*2131231300*/:
  712. Intent intent = new Intent(this, PageRangeSetting.class);
  713. intent.putExtra("SHEETS", sheets);
  714. intent.putExtra("printAll", printAll);
  715. intent.putExtra("startValue", startValue);
  716. intent.putExtra("endValue", endValue);
  717. startActivityForResult(intent, 2);
  718. return;
  719. case R.id.paper_size /*2131231306*/:
  720. launchDetailScreen(paperSize, R.id.paper_size);
  721. return;
  722. case R.id.paper_source /*2131231311*/:
  723. int i = paperSource;
  724. int[] iArr = paper_source_info;
  725. if (iArr != null && iArr.length <= 1) {
  726. i = 128;
  727. }
  728. launchDetailScreen(i, R.id.paper_source);
  729. return;
  730. case R.id.paper_type /*2131231314*/:
  731. launchDetailScreen(paperType, R.id.paper_type);
  732. return;
  733. case R.id.printdate /*2131231355*/:
  734. launchDetailScreen(printdate, R.id.printdate);
  735. return;
  736. case R.id.printer /*2131231358*/:
  737. unbindEpsonService();
  738. new AsyncTask<Void, Void, Void>() {
  739. protected void onPreExecute() {
  740. findViewById(R.id.printer).setClickable(false);
  741. }
  742. protected Void doInBackground(Void... voidArr) {
  743. SettingScr settingScr = SettingScr.this;
  744. WiFiDirectManager.disconnect(settingScr, WiFiDirectManager.DEVICE_TYPE_PRINTER, settingScr.printerIp);
  745. SettingScr settingScr2 = SettingScr.this;
  746. WiFiDirectManager.disconnectSimpleAP(settingScr2, settingScr2.autoConnectSsid, printerIp);
  747. return null;
  748. }
  749. protected void onPostExecute(Void voidR) {
  750. Intent intent = new Intent(SettingScr.this, SearchPrinterScr.class);
  751. Bundle bundle = new Bundle();
  752. bundle.putString(Constants.PRINTER_ID, printerId);
  753. bundle.putString(Constants.PRINTER_IP, printerIp);
  754. bundle.putString(Constants.PRINTER_EMAIL_ADDRESS, printerEmailAddress);
  755. bundle.putInt(Constants.PRINTER_LOCATION, printerLocation);
  756. bundle.putString(SettingScr.EXTRA_SIMPLEAP, autoConnectSsid);
  757. intent.putExtras(bundle);
  758. startActivityForResult(intent, 0);
  759. findViewById(R.id.printer).setClickable(true);
  760. }
  761. }.execute(new Void[0]);
  762. return;
  763. case R.id.quality /*2131231392*/:
  764. launchDetailScreen(quality, R.id.quality);
  765. return;
  766. case R.id.saturation_minus_button /*2131231425*/:
  767. saturationValue--;
  768. if (saturationValue <= -50) {
  769. saturationValue = -50;
  770. saturationMinus.setEnabled(false);
  771. } else {
  772. saturationMinus.setEnabled(true);
  773. }
  774. saturationPlus.setEnabled(true);
  775. saturation.setText(String.valueOf(saturationValue));
  776. return;
  777. case R.id.saturation_plus_button /*2131231426*/:
  778. saturationValue++;
  779. if (saturationValue >= 50) {
  780. saturationValue = 50;
  781. saturationPlus.setEnabled(false);
  782. } else {
  783. saturationPlus.setEnabled(true);
  784. }
  785. saturationMinus.setEnabled(true);
  786. saturation.setText(String.valueOf(saturationValue));
  787. return;
  788. case R.id.sharpness_setting_layout /*2131231482*/:
  789. launchDetailScreen(mSharpnessValue, R.id.sharpness_setting_layout);
  790. return;
  791. default:
  792. return;
  793. }
  794. }
  795. }
  796. private void launchDetailScreen(int i, int i2) {
  797. Intent intent = new Intent(this, PrinterInfoDetail.class);
  798. Bundle bundle = new Bundle();
  799. bundle.putInt("ID", i2);
  800. bundle.putInt("sizeIndex", sizeIndex);
  801. bundle.putInt("typeIndex", typeIndex);
  802. bundle.putInt("curValue", i);
  803. bundle.putBoolean("isDocumentSetting", isDocumentSetting);
  804. switch (i2) {
  805. case R.id.color /*2131230930*/:
  806. bundle.putIntArray(Constants.COLOR_INFO, color_info);
  807. break;
  808. case R.id.duplex /*2131231005*/:
  809. bundle.putIntArray(Constants.DUPLEX_INFO, duplex_info);
  810. break;
  811. case R.id.layout /*2131231158*/:
  812. bundle.putIntArray(Constants.LAYOUT_INFO, layout_info);
  813. break;
  814. case R.id.paper_size /*2131231306*/:
  815. bundle.putIntArray(Constants.PAPER_SIZE_INFO, paper_size_info);
  816. break;
  817. case R.id.paper_source /*2131231311*/:
  818. int[] iArr = paper_source_info;
  819. bundle.putIntArray(Constants.PAPER_SOURCE_INFO, (iArr == null || iArr.length > 1) ? paper_source_info : new int[]{128});
  820. break;
  821. case R.id.paper_type /*2131231314*/:
  822. bundle.putIntArray(Constants.PAPER_TYPE_INFO, paper_type_info);
  823. break;
  824. case R.id.quality /*2131231392*/:
  825. bundle.putIntArray(Constants.PRINT_QUALITY_INFO, quality_info);
  826. break;
  827. }
  828. intent.putExtras(bundle);
  829. startActivityForResult(intent, 1);
  830. }
  831. protected void onActivityResult(int i, int i2, Intent intent) {
  832. super.onActivityResult(i, i2, intent);
  833. String callingPackage = getCallingPackage();
  834. EPLog.i(callingPackage, "requestCode = " + i + " resultCode = " + i2);
  835. if (i != 0) {
  836. if (i != 4) {
  837. if (i != 2) {
  838. int i3 = 1;
  839. if (i == 1 && i2 == -1) {
  840. int i4 = intent.getExtras().getInt("curValue");
  841. switch (intent.getExtras().getInt("ID")) {
  842. case R.id.apf_setting_layout /*2131230819*/:
  843. if (i4 != 1) {
  844. i3 = 0;
  845. }
  846. photoApfValueForLocalPrinter = i3;
  847. displayApfState(photoApfValueForLocalPrinter);
  848. break;
  849. case R.id.color /*2131230930*/:
  850. mLookupTable = new MediaInfo.Color();
  851. colorInfo.setText(getString(mLookupTable.getStringId(i4)));
  852. mLookupTable.destructor();
  853. color = i4;
  854. break;
  855. case R.id.duplex /*2131231005*/:
  856. mLookupTable = new MediaInfo.Duplex();
  857. duplexInfo.setText(getString(mLookupTable.getStringId(i4)));
  858. mLookupTable.destructor();
  859. duplex = i4;
  860. break;
  861. case R.id.feed_direction /*2131231037*/:
  862. mLookupTable = new MediaInfo.FeedDirection();
  863. feedDirectionInfo.setText(getString(mLookupTable.getStringId(i4)));
  864. mLookupTable.destructor();
  865. feedDirection = i4;
  866. break;
  867. case R.id.layout /*2131231158*/:
  868. mLookupTable = new LayoutEx();
  869. layoutInfo.setText(getString(mLookupTable.getStringId(i4)));
  870. mLookupTable.destructor();
  871. layout = i4;
  872. undoFlag = false;
  873. mHandler.sendEmptyMessage(32);
  874. break;
  875. case R.id.paper_size /*2131231306*/:
  876. sizeIndex = intent.getExtras().getInt("INDEX");
  877. mLookupTable = new MediaInfo.PaperSize();
  878. paperSizeInfo.setText(getString(mLookupTable.getStringId(i4)));
  879. mLookupTable.destructor();
  880. paperSize = i4;
  881. paperType = mPaperSizeType.getID(paperSize);
  882. undoFlag = false;
  883. mHandler.sendEmptyMessage(2);
  884. break;
  885. case R.id.paper_source /*2131231311*/:
  886. mLookupTable = new MediaInfo.PaperSource();
  887. paperSourceInfo.setText(getString(mLookupTable.getStringId(i4)));
  888. mLookupTable.destructor();
  889. int[] iArr = paper_source_info;
  890. if (iArr != null && iArr.length > 1) {
  891. paperSource = i4;
  892. }
  893. undoFlag = false;
  894. mHandler.sendEmptyMessage(32);
  895. break;
  896. case R.id.paper_type /*2131231314*/:
  897. typeIndex = intent.getExtras().getInt("INDEX");
  898. mLookupTable = new MediaInfo.PaperType();
  899. paperTypeInfo.setText(getString(mLookupTable.getStringId(i4)));
  900. mLookupTable.destructor();
  901. paperType = i4;
  902. mPaperSizeType.putID(paperSize, paperType);
  903. undoFlag = false;
  904. mHandler.sendEmptyMessage(3);
  905. break;
  906. case R.id.printdate /*2131231355*/:
  907. mLookupTable = new MediaInfo.PrintDate();
  908. printDateInfo.setText(getString(mLookupTable.getStringId(i4)));
  909. mLookupTable.destructor();
  910. printdate = i4;
  911. break;
  912. case R.id.quality /*2131231392*/:
  913. mLookupTable = new MediaInfo.Quality();
  914. qualityInfo.setText(getString(mLookupTable.getStringId(i4)));
  915. mLookupTable.destructor();
  916. quality = i4;
  917. break;
  918. case R.id.sharpness_setting_layout /*2131231482*/:
  919. if (i4 != 1) {
  920. i3 = 0;
  921. }
  922. mSharpnessValue = i3;
  923. displaySharpnessState(mSharpnessValue);
  924. break;
  925. }
  926. }
  927. } else if (i2 == -1) {
  928. printAll = intent.getExtras().getBoolean("printAll");
  929. startValue = intent.getExtras().getInt("startValue");
  930. endValue = intent.getExtras().getInt("endValue");
  931. mHandler.sendEmptyMessage(64);
  932. }
  933. } else {
  934. endInkReplAndGoProbePrinter();
  935. }
  936. } else {
  937. onPrinterSelectEnd(i2, intent);
  938. }
  939. updatePrinterIcon();
  940. }
  941. /* JADX WARNING: Can't fix incorrect switch cases order */
  942. /* JADX WARNING: Code restructure failed: missing block: B:25:0x00ea, code lost:
  943. if (r7.loadIpPrinterInfo(r6.printerId) == null) goto L_0x00f7;
  944. */
  945. /* JADX WARNING: Code restructure failed: missing block: B:27:0x00f3, code lost:
  946. if (r7.loadRemotePrinterInfo(r6.printerEmailAddress) == null) goto L_0x00f7;
  947. */
  948. /* Code decompiled incorrectly, please refer to instructions dump. */
  949. private void onPrinterSelectEnd(int r7, android.content.Intent r8) {
  950. /*
  951. r6 = this;
  952. r0 = 0
  953. r1 = 1
  954. r2 = -1
  955. if (r7 != r2) goto L_0x00d6
  956. android.os.Bundle r7 = r8.getExtras()
  957. java.lang.String r2 = "myprinter"
  958. android.os.Parcelable r7 = r7.getParcelable(r2)
  959. epson.print.MyPrinter r7 = (epson.print.MyPrinter) r7
  960. r6.printer = r7
  961. android.widget.TextView r7 = r6.printerName
  962. epson.print.MyPrinter r2 = r6.printer
  963. java.lang.String r2 = r2.getName()
  964. r7.setText(r2)
  965. epson.print.MyPrinter r7 = r6.printer
  966. java.lang.String r7 = r7.getName()
  967. r6.printerDeviceId = r7
  968. epson.print.MyPrinter r7 = r6.printer
  969. java.lang.String r7 = r7.getPrinterId()
  970. r6.printerId = r7
  971. epson.print.MyPrinter r7 = r6.printer
  972. java.lang.String r7 = r7.getIp()
  973. r6.printerIp = r7
  974. epson.print.MyPrinter r7 = r6.printer
  975. java.lang.String r7 = r7.getSerialNo()
  976. r6.printerSerialNo = r7
  977. epson.print.MyPrinter r7 = r6.printer
  978. java.lang.String r7 = r7.getEmailAddress()
  979. r6.printerEmailAddress = r7
  980. epson.print.MyPrinter r7 = r6.printer
  981. int r7 = r7.getLocation()
  982. r6.printerLocation = r7
  983. epson.print.EPPrinterManager r7 = new epson.print.EPPrinterManager
  984. r7.<init>(r6)
  985. int r2 = r6.printerLocation
  986. switch(r2) {
  987. case 2: goto L_0x0075;
  988. case 3: goto L_0x0059;
  989. default: goto L_0x0058;
  990. }
  991. L_0x0058:
  992. goto L_0x0090
  993. L_0x0059:
  994. java.lang.String r2 = r6.printerId
  995. epson.print.EPPrinterInfo r7 = r7.loadIpPrinterInfo(r2)
  996. if (r7 == 0) goto L_0x0090
  997. java.lang.String r2 = r7.userDefName
  998. if (r2 == 0) goto L_0x0090
  999. java.lang.String r2 = r7.userDefName
  1000. int r2 = r2.length()
  1001. if (r2 <= 0) goto L_0x0090
  1002. android.widget.TextView r2 = r6.printerName
  1003. java.lang.String r7 = r7.userDefName
  1004. r2.setText(r7)
  1005. goto L_0x0090
  1006. L_0x0075:
  1007. java.lang.String r2 = r6.printerEmailAddress
  1008. epson.print.EPPrinterInfo r7 = r7.loadRemotePrinterInfo(r2)
  1009. if (r7 == 0) goto L_0x0090
  1010. java.lang.String r2 = r7.userDefName
  1011. if (r2 == 0) goto L_0x0090
  1012. java.lang.String r2 = r7.userDefName
  1013. int r2 = r2.length()
  1014. if (r2 <= 0) goto L_0x0090
  1015. android.widget.TextView r2 = r6.printerName
  1016. java.lang.String r7 = r7.userDefName
  1017. r2.setText(r7)
  1018. L_0x0090:
  1019. android.os.Bundle r7 = r8.getExtras()
  1020. java.lang.String r8 = "simpleap"
  1021. java.lang.String r7 = r7.getString(r8)
  1022. r6.autoConnectSsid = r7
  1023. android.content.Context r7 = r6.getApplicationContext()
  1024. java.lang.String r8 = "PrintSetting"
  1025. java.lang.String r2 = "RE_SEARCH"
  1026. epson.common.Utils.savePref((android.content.Context) r7, (java.lang.String) r8, (java.lang.String) r2, (boolean) r1)
  1027. r6.undoFlag = r0
  1028. r6.mPrinterSelectDone = r1
  1029. r6.mWaiteInkReplenProgress = r1
  1030. android.content.Context r7 = r6.getApplicationContext()
  1031. java.lang.String r8 = r6.printerId
  1032. boolean r7 = epson.print.inkrpln.InkReplnHelper.isSimpleApOrP2p(r7, r8)
  1033. if (r7 != 0) goto L_0x00d2
  1034. epson.print.inkrpln.PrintSettingDependencyBuilder r7 = new epson.print.inkrpln.PrintSettingDependencyBuilder
  1035. java.lang.String r1 = r6.printerId
  1036. java.lang.String r2 = r6.printerIp
  1037. java.lang.String r3 = r6.printerSerialNo
  1038. int r4 = r6.printerLocation
  1039. java.lang.String r5 = r6.printerDeviceId
  1040. r0 = r7
  1041. r0.<init>(r1, r2, r3, r4, r5)
  1042. android.content.Intent r7 = epson.print.inkrpln.InkRplnProgressDialog.getStartIntent2(r6, r7)
  1043. r8 = 4
  1044. r6.startActivityForResult(r7, r8)
  1045. goto L_0x00fc
  1046. L_0x00d2:
  1047. r6.endInkReplAndGoProbePrinter()
  1048. goto L_0x00fc
  1049. L_0x00d6:
  1050. r6.bindEpsonService()
  1051. epson.print.EPPrinterManager r7 = new epson.print.EPPrinterManager
  1052. r7.<init>(r6)
  1053. int r8 = r6.printerLocation
  1054. switch(r8) {
  1055. case 2: goto L_0x00ed;
  1056. case 3: goto L_0x00e4;
  1057. default: goto L_0x00e3;
  1058. }
  1059. L_0x00e3:
  1060. goto L_0x00f6
  1061. L_0x00e4:
  1062. java.lang.String r8 = r6.printerId
  1063. epson.print.EPPrinterInfo r7 = r7.loadIpPrinterInfo(r8)
  1064. if (r7 != 0) goto L_0x00f6
  1065. goto L_0x00f7
  1066. L_0x00ed:
  1067. java.lang.String r8 = r6.printerEmailAddress
  1068. epson.print.EPPrinterInfo r7 = r7.loadRemotePrinterInfo(r8)
  1069. if (r7 != 0) goto L_0x00f6
  1070. goto L_0x00f7
  1071. L_0x00f6:
  1072. r1 = 0
  1073. L_0x00f7:
  1074. if (r1 == 0) goto L_0x00fc
  1075. r6.resetSettings()
  1076. L_0x00fc:
  1077. return
  1078. */
  1079. throw new UnsupportedOperationException("Method not decompiled: epson.print.screen.SettingScr.onPrinterSelectEnd(int, android.content.Intent):void");
  1080. }
  1081. private void endInkReplAndGoProbePrinter() {
  1082. mWaiteInkReplenProgress = false;
  1083. bindEpsonService();
  1084. mHandler.sendEmptyMessageDelayed(17, 100);
  1085. }
  1086. private void updateSettingView() {
  1087. int i = 8;
  1088. if (isDocumentSetting) {
  1089. if (printerLocation != 2) {
  1090. setVisibilityPageRange(true);
  1091. setClickablePageRange(true);
  1092. } else if (!enableShowPreview) {
  1093. setVisibilityPageRange(false);
  1094. } else if (disablePrintArea) {
  1095. setVisibilityPageRange(true);
  1096. setClickablePageRange(false);
  1097. } else {
  1098. setVisibilityPageRange(true);
  1099. setClickablePageRange(true);
  1100. }
  1101. if (sheets == 1) {
  1102. ((ImageView) findViewById(R.id.page_range_next_screen_imv)).setVisibility(8);
  1103. } else {
  1104. ((ImageView) findViewById(R.id.page_range_next_screen_imv)).setVisibility(0);
  1105. }
  1106. } else {
  1107. setVisibilityPageRange(false);
  1108. }
  1109. int[] iArr = color_info;
  1110. if (iArr == null) {
  1111. ((ImageView) findViewById(R.id.color_next_screen_imv)).setVisibility(8);
  1112. } else if (iArr.length <= 1) {
  1113. ((ImageView) findViewById(R.id.color_next_screen_imv)).setVisibility(8);
  1114. } else {
  1115. ((ImageView) findViewById(R.id.color_next_screen_imv)).setVisibility(0);
  1116. }
  1117. int[] iArr2 = duplex_info;
  1118. if (iArr2 == null) {
  1119. findViewById(R.id.duplex_view).setVisibility(8);
  1120. ((LinearLayout) findViewById(R.id.duplex)).setVisibility(8);
  1121. } else if (iArr2.length <= 1) {
  1122. findViewById(R.id.duplex_view).setVisibility(8);
  1123. ((LinearLayout) findViewById(R.id.duplex)).setVisibility(8);
  1124. } else {
  1125. findViewById(R.id.duplex_view).setVisibility(0);
  1126. ((LinearLayout) findViewById(R.id.duplex)).setVisibility(0);
  1127. }
  1128. switch (lang) {
  1129. case 2:
  1130. case 3:
  1131. findViewById(R.id.feed_direction_view).setVisibility(0);
  1132. findViewById(R.id.feed_direction).setVisibility(0);
  1133. break;
  1134. default:
  1135. findViewById(R.id.feed_direction_view).setVisibility(8);
  1136. findViewById(R.id.feed_direction).setVisibility(8);
  1137. break;
  1138. }
  1139. if (isDocumentSetting || printerLocation == 2) {
  1140. findViewById(R.id.printdate).setVisibility(8);
  1141. } else {
  1142. findViewById(R.id.printdate).setVisibility(0);
  1143. }
  1144. if (printerLocation != 2 && !this.isDocumentSetting) {
  1145. i = 0;
  1146. }
  1147. findViewById(R.id.viewGroupPhotoEffect).setVisibility(i);
  1148. findViewById(R.id.apf_setting_layout).setVisibility(i);
  1149. findViewById(R.id.sharpness_setting_layout).setVisibility(i);
  1150. }
  1151. private int getPrinterLang() {
  1152. int i;
  1153. IEpsonService iEpsonService;
  1154. if (!(printerLocation == 2 || (iEpsonService = mEpsonService) == null)) {
  1155. try {
  1156. i = iEpsonService.getLang();
  1157. } catch (RemoteException e) {
  1158. e.printStackTrace();
  1159. }
  1160. EPLog.d("PrintSetting", "getPrinterLang called : ret = " + i);
  1161. return i;
  1162. }
  1163. i = 1;
  1164. EPLog.d("PrintSetting", "getPrinterLang called : ret = " + i);
  1165. return i;
  1166. }
  1167. private void setVisibilityPageRange(boolean z) {
  1168. int i = 0;
  1169. findViewById(R.id.page_range_setting).setVisibility(z ? 0 : 8);
  1170. View findViewById = findViewById(R.id.page_range_separator);
  1171. if (!z) {
  1172. i = 8;
  1173. }
  1174. findViewById.setVisibility(i);
  1175. }
  1176. private void setClickablePageRange(boolean z) {
  1177. findViewById(R.id.page_range_setting).setClickable(z);
  1178. int i = 0;
  1179. findViewById(R.id.page_range_next_screen_imv).setVisibility(z ? 0 : 8);
  1180. View findViewById = findViewById(R.id.page_range_value);
  1181. if (!z) {
  1182. i = 8;
  1183. }
  1184. findViewById.setVisibility(i);
  1185. }
  1186. private void resetSettings() {
  1187. printerDeviceId = null;
  1188. printerId = null;
  1189. printerEmailAddress = null;
  1190. printerIp = null;
  1191. printerLocation = 0;
  1192. info = null;
  1193. paper_source_info = null;
  1194. color_info = null;
  1195. paper_size_info = null;
  1196. paper_type_info = null;
  1197. layout_info = null;
  1198. quality_info = null;
  1199. duplex_info = null;
  1200. autoConnectSsid = "";
  1201. printerName.setText(getString(R.string.str_lbl_title_scan));
  1202. ((ImageView) findViewById(R.id.imageViewPrinterLocation)).setVisibility(8);
  1203. updateSettingView();
  1204. setScreenState(true);
  1205. }
  1206. public void onBackPressed() {
  1207. super.onBackPressed();
  1208. mFinishRequested = true;
  1209. IEpsonService iEpsonService = mEpsonService;
  1210. if (iEpsonService != null) {
  1211. try {
  1212. iEpsonService.cancelSearchPrinter();
  1213. } catch (RemoteException e) {
  1214. e.printStackTrace();
  1215. }
  1216. }
  1217. loadSupportedMediaFile();
  1218. EPPrinterManager ePPrinterManager = new EPPrinterManager(mContext);
  1219. ePPrinterManager.rollbackRemotePrinterInfo();
  1220. ePPrinterManager.rollbackIPPrinterInfo();
  1221. new InkRplnRepository(false).deleteTemporaryData(this);
  1222. }
  1223. private void setScreenState(Boolean bool) {
  1224. if (bool.booleanValue()) {
  1225. progressGetOption.setVisibility(8);
  1226. } else {
  1227. progressGetOption.setVisibility(0);
  1228. }
  1229. findViewById(R.id.printer).setClickable(bool.booleanValue());
  1230. findViewById(R.id.paper_size).setClickable(bool.booleanValue());
  1231. findViewById(R.id.paper_type).setClickable(bool.booleanValue());
  1232. findViewById(R.id.layout).setClickable(bool.booleanValue());
  1233. findViewById(R.id.quality).setClickable(bool.booleanValue());
  1234. findViewById(R.id.paper_source).setClickable(bool.booleanValue());
  1235. findViewById(R.id.color).setClickable(bool.booleanValue());
  1236. findViewById(R.id.duplex).setClickable(bool.booleanValue());
  1237. findViewById(R.id.feed_direction).setClickable(bool.booleanValue());
  1238. findViewById(R.id.printdate).setClickable(bool.booleanValue());
  1239. }
  1240. public void showErrorDialog(String str, String str2) {
  1241. new CustomTitleAlertDialogBuilder(this).setCancelable(false).setTitle(str).setMessage(str2).setNegativeButton(getString(R.string.f343ok), new DialogInterface.OnClickListener() {
  1242. public void onClick(DialogInterface dialogInterface, int i) {
  1243. setScreenState(true);
  1244. dialogInterface.cancel();
  1245. }
  1246. }).create().show();
  1247. updateSupportedMediaFile(true);
  1248. }
  1249. protected void onResume() {
  1250. super.onResume();
  1251. EPLog.e("SettingScr", "onResume()");
  1252. if (printerId != null && printerLocation == 1 && isRetryAfterConnectSimpleAp && !this.mWaiteInkReplenProgress) {
  1253. undoFlag = false;
  1254. if (loadSupportedMediaFile()) {
  1255. mHandler.sendEmptyMessage(1);
  1256. } else {
  1257. mHandler.sendEmptyMessage(17);
  1258. }
  1259. }
  1260. }
  1261. protected void onPause() {
  1262. EPLog.d("SettingScr", "onPause");
  1263. super.onPause();
  1264. if (isFinishing()) {
  1265. mFinishRequested = true;
  1266. deleteLongTapMessage();
  1267. }
  1268. WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, printerIp);
  1269. WiFiDirectManager.disconnectSimpleAP(this, autoConnectSsid, printerIp);
  1270. }
  1271. public boolean onCreateOptionsMenu(Menu menu) {
  1272. getMenuInflater().inflate(R.C2138menu.menu_done, menu);
  1273. return super.onCreateOptionsMenu(menu);
  1274. }
  1275. public boolean onOptionsItemSelected(MenuItem menuItem) {
  1276. if (menuItem.getItemId() != R.id.menuSettingsDone) {
  1277. return super.onOptionsItemSelected(menuItem);
  1278. }
  1279. saveChanged();
  1280. setResult(3, getIntent());
  1281. finish();
  1282. return true;
  1283. }
  1284. protected void deleteLongTapMessage() {
  1285. MotionEvent obtain = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis() + 10, 1, 0.0f, 0.0f, 0);
  1286. copiesMinus.dispatchTouchEvent(obtain);
  1287. copiesPlus.dispatchTouchEvent(obtain);
  1288. }
  1289. public void onConfigurationChanged(Configuration configuration) {
  1290. super.onConfigurationChanged(configuration);
  1291. deleteLongTapMessage();
  1292. }
  1293. }