SearchPrinterScr.java 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. package epson.print.screen;
  2. import android.app.AlertDialog;
  3. import android.app.Dialog;
  4. import android.content.ComponentName;
  5. import android.content.Context;
  6. import android.content.DialogInterface;
  7. import android.content.Intent;
  8. import android.content.ServiceConnection;
  9. import android.net.Uri;
  10. import android.os.Bundle;
  11. import android.os.Handler;
  12. import android.os.IBinder;
  13. import android.os.Message;
  14. import android.os.RemoteException;
  15. import android.view.ContextMenu;
  16. import android.view.MenuItem;
  17. import android.view.View;
  18. import android.view.ViewGroup;
  19. import android.widget.AdapterView;
  20. import android.widget.Button;
  21. import android.widget.ListView;
  22. import android.widget.ProgressBar;
  23. import android.widget.RadioButton;
  24. import android.widget.TextView;
  25. import com.epson.mobilephone.common.EPLog;
  26. import com.epson.mobilephone.common.escpr.MediaInfo;
  27. import com.epson.mobilephone.common.wifidirect.ActivityWiFiDirectStart;
  28. import com.epson.mobilephone.common.wifidirect.ActivityiPrintConnect;
  29. import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
  30. import com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask;
  31. import com.epson.mobilephone.common.wifidirect.WiFiControl;
  32. import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
  33. import com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils;
  34. import com.epson.mobilephone.common.wifidirect.escprLib;
  35. import epson.common.Constants;
  36. import epson.common.Utils;
  37. import epson.maintain.activity.PrinterNotFoundDialogCreator;
  38. import epson.print.ActivityIACommon;
  39. import epson.print.R;
  40. import epson.print.CommonDefine;
  41. import epson.print.CustomLayoutDialogFragment;
  42. import epson.print.CustomTitleDialogFragment;
  43. import epson.print.MyPrinter;
  44. import epson.print.Util.EPLog;
  45. import epson.print.service.EpsonService;
  46. import epson.print.service.IEpsonService;
  47. import epson.print.service.IEpsonServiceCallback;
  48. import epson.print.widgets.AbstractListBuilder;
  49. import epson.print.widgets.CustomTitleAlertDialogBuilder;
  50. import epson.print.widgets.ListControlHelper;
  51. import epson.print.widgets.PrinterInfoBuilder;
  52. import epson.print.widgets.PrinterInfoECBuilder;
  53. import epson.print.widgets.PrinterInfoIpBuilder;
  54. import java.util.ArrayList;
  55. import java.util.Locale;
  56. public class SearchPrinterScr extends ActivityIACommon implements CustomTitleDialogFragment.Callback {
  57. private static final int DELAY = 100;
  58. private static final int DIALOG_ID_PRINTER_NOT_FOUND_WITH_WEB_GUIDANCE = 1;
  59. private static final int DIALOG_INFORM = 0;
  60. private static final String DIALOG_TAG_PRINTER_NOT_FOUND = "printer_not_found_dialog";
  61. private static final String EXTRA_PRINTER = "myprinter";
  62. private static final String EXTRA_SIMPLEAP = "simpleap";
  63. private static final int Menu_Delete = 1;
  64. private static final int Menu_Edit = 2;
  65. private static final String TAG = "SearchPrinterScr";
  66. private static boolean foundPrinter = false;
  67. private static final Object mLock = new Object();
  68. private final int CANCEL_FIND_PRINTER = 2;
  69. private final int CONNECT_SIMPLEAP = 10;
  70. private final int DELETE_PRINTER = 7;
  71. private final int EDIT_IPPRINTER = 11;
  72. private final int EDIT_PRINTER = 8;
  73. private final int FOUND_SIMPLEAP = 9;
  74. private final int INFORM_DIALOG = 5;
  75. private final String PRINTER_COMMON_DEVICENAME = "common_devicename";
  76. private final String PRINTER_ID = "id";
  77. private final String PRINTER_IP = escprLib.PRINTER_IP;
  78. private final String PRINTER_NAME = "name";
  79. private final String PRINTER_SERIAL_NO = escprLib.PRINTER_SERIAL_NO;
  80. private final int PROBE_PRINTER = 12;
  81. private final int SEARCH_PRINTER = 1;
  82. private final int SEARCH_PRINTER_P2P = 14;
  83. private final int SELECT_PRINTER = 4;
  84. private final int SHOW_PRINTER_NOT_FOUND_DIALOG = 13;
  85. private final int UPDATE_PRINTER = 3;
  86. private boolean bCheckWiFiStatus = false;
  87. private String connectionInfo = null;
  88. int curError;
  89. ListControlHelper helper = null;
  90. private boolean isDialogOpen = false;
  91. private volatile boolean isFinishSearchPrinter = true;
  92. private Boolean isFocused = true;
  93. private boolean isJapaneseLocale = false;
  94. private volatile boolean isSearchSimpleAp = false;
  95. private AdapterView.AdapterContextMenuInfo listItemIndex;
  96. View mAboutRemoteButton;
  97. private boolean mActivityForegroundLifetime;
  98. Button mAddButton;
  99. AbstractListBuilder mBuilder;
  100. private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
  101. public void onGetInkState() throws RemoteException {
  102. }
  103. public void onGetStatusState() throws RemoteException {
  104. }
  105. public void onNotifyEndJob(int i) throws RemoteException {
  106. }
  107. public void onNotifyProgress(int i, int i2) throws RemoteException {
  108. }
  109. public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
  110. EPLog.i(str);
  111. int access$200 = SearchPrinterScr.this.printer_location;
  112. if (access$200 == 1) {
  113. Message obtain = Message.obtain();
  114. obtain.what = 3;
  115. Bundle bundle = new Bundle();
  116. bundle.putString("name", str);
  117. bundle.putString(escprLib.PRINTER_IP, str2);
  118. bundle.putString("id", str3);
  119. bundle.putString(escprLib.PRINTER_SERIAL_NO, str4);
  120. bundle.putString("common_devicename", str5);
  121. obtain.setData(bundle);
  122. SearchPrinterScr.this.mHandler.sendMessage(obtain);
  123. } else if (access$200 == 3) {
  124. MyPrinter unused = SearchPrinterScr.this.probedPrinter = new MyPrinter(str, str2, str3, str4);
  125. }
  126. }
  127. public void onNotifyContinueable(int i) throws RemoteException {
  128. if (SearchPrinterScr.this.progress != null && SearchPrinterScr.this.progress.isShowing()) {
  129. SearchPrinterScr.this.progress.dismiss();
  130. }
  131. if (SearchPrinterScr.this.selectedPrinter != null && SearchPrinterScr.this.probedPrinter != null && SearchPrinterScr.this.printer_location == 3) {
  132. if (SearchPrinterScr.this.probedPrinter.getPrinterId().equals(SearchPrinterScr.this.selectedPrinter.getPrinterId())) {
  133. Message obtainMessage = SearchPrinterScr.this.mHandler.obtainMessage();
  134. obtainMessage.what = 4;
  135. obtainMessage.obj = SearchPrinterScr.this.selectedPrinter;
  136. SearchPrinterScr.this.mHandler.sendMessage(obtainMessage);
  137. return;
  138. }
  139. SearchPrinterScr searchPrinterScr = SearchPrinterScr.this;
  140. searchPrinterScr.curError = -500001;
  141. searchPrinterScr.mHandler.sendEmptyMessage(5);
  142. }
  143. }
  144. public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
  145. if (!SearchPrinterScr.this.isSearchSimpleAp) {
  146. synchronized (SearchPrinterScr.mLock) {
  147. boolean unused = SearchPrinterScr.foundPrinter = Utils.getPrefBoolean(SearchPrinterScr.this.getApplicationContext(), "PrintSetting", CommonDefine.RE_SEARCH);
  148. if ((i2 == -1300 || i2 == -1351) && !SearchPrinterScr.foundPrinter) {
  149. i2 = -1100;
  150. } else if ((i2 == -1300 || i2 == -1351 || i2 == -1100) && SearchPrinterScr.foundPrinter) {
  151. i2 = -11001;
  152. }
  153. }
  154. SearchPrinterScr searchPrinterScr = SearchPrinterScr.this;
  155. searchPrinterScr.curError = i2;
  156. searchPrinterScr.mHandler.sendEmptyMessage(13);
  157. if (SearchPrinterScr.this.progress != null && SearchPrinterScr.this.progress.isShowing()) {
  158. SearchPrinterScr.this.progress.dismiss();
  159. }
  160. Boolean unused2 = SearchPrinterScr.this.isFocused = true;
  161. }
  162. }
  163. };
  164. private Context mContext = null;
  165. private int mDeletePos = -1;
  166. private ServiceConnection mEpsonConnection = new ServiceConnection() {
  167. public void onServiceDisconnected(ComponentName componentName) {
  168. try {
  169. SearchPrinterScr.this.mEpsonService.unregisterCallback(SearchPrinterScr.this.mCallback);
  170. } catch (RemoteException e) {
  171. e.printStackTrace();
  172. }
  173. IEpsonService unused = SearchPrinterScr.this.mEpsonService = null;
  174. }
  175. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  176. IEpsonService unused = SearchPrinterScr.this.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
  177. if (SearchPrinterScr.this.mEpsonService != null) {
  178. try {
  179. SearchPrinterScr.this.mEpsonService.registerCallback(SearchPrinterScr.this.mCallback);
  180. } catch (RemoteException e) {
  181. e.printStackTrace();
  182. }
  183. }
  184. }
  185. };
  186. private IEpsonService mEpsonService = null;
  187. Handler mHandler = new Handler(new Handler.Callback() {
  188. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v46, resolved type: java.lang.Object} */
  189. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v22, resolved type: epson.print.MyPrinter} */
  190. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r10v60, resolved type: java.lang.Object} */
  191. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v29, resolved type: epson.print.MyPrinter} */
  192. /* JADX WARNING: Multi-variable type inference failed */
  193. /* Code decompiled incorrectly, please refer to instructions dump. */
  194. public boolean handleMessage(android.os.Message r10) {
  195. /*
  196. r9 = this;
  197. int r0 = r10.what
  198. r1 = 8
  199. r2 = 0
  200. r3 = -1
  201. r4 = 0
  202. r5 = 1
  203. switch(r0) {
  204. case 1: goto L_0x036b;
  205. case 2: goto L_0x0365;
  206. case 3: goto L_0x02c1;
  207. case 4: goto L_0x0247;
  208. case 5: goto L_0x0219;
  209. case 6: goto L_0x000b;
  210. case 7: goto L_0x0166;
  211. case 8: goto L_0x0122;
  212. case 9: goto L_0x00c6;
  213. case 10: goto L_0x000b;
  214. case 11: goto L_0x0080;
  215. case 12: goto L_0x0036;
  216. case 13: goto L_0x002b;
  217. case 14: goto L_0x000d;
  218. default: goto L_0x000b;
  219. }
  220. L_0x000b:
  221. goto L_0x0379
  222. L_0x000d:
  223. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  224. android.os.Handler r0 = r10.mHandler
  225. r1 = 9
  226. r2 = 60
  227. com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.searchWiFiDirectPrinter(r10, r0, r1, r2)
  228. com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask unused = r10.searchWiFiDirectPrinter = r0
  229. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  230. com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r10 = r10.searchWiFiDirectPrinter
  231. if (r10 != 0) goto L_0x0379
  232. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  233. boolean unused = r10.isSearchSimpleAp = r4
  234. goto L_0x0379
  235. L_0x002b:
  236. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  237. android.support.v4.app.DialogFragment r0 = r10.getPrinterNotFoundDialog()
  238. r10.showPrinterNotFoundDialog(r0)
  239. goto L_0x0379
  240. L_0x0036:
  241. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  242. java.lang.Object r10 = r10.obj
  243. epson.print.MyPrinter r10 = (epson.print.MyPrinter) r10
  244. epson.print.MyPrinter unused = r0.selectedPrinter = r10
  245. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  246. epson.print.MyPrinter unused = r10.probedPrinter = r2
  247. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  248. epson.print.screen.WorkingDialog r10 = r10.progress
  249. if (r10 != 0) goto L_0x0053
  250. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  251. epson.print.screen.WorkingDialog r0 = new epson.print.screen.WorkingDialog
  252. r0.<init>(r10)
  253. r10.progress = r0
  254. L_0x0053:
  255. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  256. epson.print.screen.WorkingDialog r10 = r10.progress
  257. r10.show()
  258. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this // Catch:{ RemoteException -> 0x007a }
  259. epson.print.service.IEpsonService r10 = r10.mEpsonService // Catch:{ RemoteException -> 0x007a }
  260. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this // Catch:{ RemoteException -> 0x007a }
  261. epson.print.MyPrinter r0 = r0.selectedPrinter // Catch:{ RemoteException -> 0x007a }
  262. java.lang.String r0 = r0.getPrinterId() // Catch:{ RemoteException -> 0x007a }
  263. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this // Catch:{ RemoteException -> 0x007a }
  264. epson.print.MyPrinter r1 = r1.selectedPrinter // Catch:{ RemoteException -> 0x007a }
  265. java.lang.String r1 = r1.getIp() // Catch:{ RemoteException -> 0x007a }
  266. r2 = 2
  267. r10.searchPrinters(r0, r1, r2) // Catch:{ RemoteException -> 0x007a }
  268. goto L_0x0379
  269. L_0x007a:
  270. r10 = move-exception
  271. r10.printStackTrace()
  272. goto L_0x0379
  273. L_0x0080:
  274. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  275. r0.interruptSearch()
  276. java.lang.Object r0 = r10.obj
  277. if (r0 == 0) goto L_0x008e
  278. java.lang.Object r10 = r10.obj
  279. r2 = r10
  280. epson.print.MyPrinter r2 = (epson.print.MyPrinter) r2
  281. L_0x008e:
  282. android.content.Intent r10 = new android.content.Intent
  283. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  284. java.lang.Class<epson.print.screen.ActivityIpPrinterSetting> r1 = epson.print.screen.ActivityIpPrinterSetting.class
  285. r10.<init>(r0, r1)
  286. android.os.Bundle r0 = new android.os.Bundle
  287. r0.<init>()
  288. if (r2 == 0) goto L_0x00ae
  289. java.lang.String r1 = r2.getIp()
  290. if (r1 == 0) goto L_0x00ae
  291. java.lang.String r1 = "PRINTER_KEY"
  292. java.lang.String r2 = r2.getPrinterId()
  293. r0.putString(r1, r2)
  294. goto L_0x00b5
  295. L_0x00ae:
  296. java.lang.String r1 = "PRINTER_IP"
  297. java.lang.String r2 = ""
  298. r0.putString(r1, r2)
  299. L_0x00b5:
  300. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this
  301. int unused = r1.mDeletePos = r3
  302. r10.putExtras(r0)
  303. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  304. r1 = 11
  305. r0.startActivityForResult(r10, r1)
  306. goto L_0x0379
  307. L_0x00c6:
  308. android.os.Bundle r10 = r10.getData()
  309. if (r10 == 0) goto L_0x00f7
  310. boolean r0 = r10.isEmpty()
  311. if (r0 != 0) goto L_0x00f7
  312. java.lang.String r0 = "ssid"
  313. java.lang.String r0 = r10.getString(r0)
  314. java.lang.String r1 = "name"
  315. java.lang.String r1 = r10.getString(r1)
  316. java.lang.String r2 = "addr_infra"
  317. java.lang.String r10 = r10.getString(r2)
  318. if (r1 != 0) goto L_0x00e7
  319. r1 = r0
  320. L_0x00e7:
  321. epson.print.MyPrinter r2 = new epson.print.MyPrinter
  322. java.lang.String r3 = ""
  323. r2.<init>(r1, r0, r10, r3)
  324. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this
  325. com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r1 = r1.wiFiDirectPrinterListUtils
  326. r1.addPrinter(r2, r4, r0, r10)
  327. goto L_0x0379
  328. L_0x00f7:
  329. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  330. boolean unused = r10.isSearchSimpleAp = r4
  331. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  332. boolean r10 = r10.isFinishSearchPrinter
  333. if (r10 == 0) goto L_0x0379
  334. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  335. r10.displaySearchResult()
  336. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  337. epson.print.widgets.AbstractListBuilder r10 = r10.mBuilder
  338. java.util.Vector r10 = r10.getData()
  339. int r10 = r10.size()
  340. if (r10 != 0) goto L_0x0379
  341. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  342. android.os.Handler r10 = r10.mHandler
  343. r0 = 13
  344. r10.sendEmptyMessage(r0)
  345. goto L_0x0379
  346. L_0x0122:
  347. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  348. r0.interruptSearch()
  349. java.lang.Object r0 = r10.obj
  350. if (r0 == 0) goto L_0x0130
  351. java.lang.Object r10 = r10.obj
  352. r2 = r10
  353. epson.print.MyPrinter r2 = (epson.print.MyPrinter) r2
  354. L_0x0130:
  355. android.content.Intent r10 = new android.content.Intent
  356. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  357. java.lang.Class<epson.print.screen.ActivityPrinterSetting> r5 = epson.print.screen.ActivityPrinterSetting.class
  358. r10.<init>(r0, r5)
  359. android.os.Bundle r0 = new android.os.Bundle
  360. r0.<init>()
  361. if (r2 == 0) goto L_0x0150
  362. java.lang.String r5 = r2.getEmailAddress()
  363. if (r5 == 0) goto L_0x0150
  364. java.lang.String r5 = "PRINTER_EMAIL_ADDRESS"
  365. java.lang.String r2 = r2.getEmailAddress()
  366. r0.putString(r5, r2)
  367. goto L_0x0157
  368. L_0x0150:
  369. java.lang.String r2 = "PRINTER_EMAIL_ADDRESS"
  370. java.lang.String r5 = ""
  371. r0.putString(r2, r5)
  372. L_0x0157:
  373. epson.print.screen.SearchPrinterScr r2 = epson.print.screen.SearchPrinterScr.this
  374. int unused = r2.mDeletePos = r3
  375. r10.putExtras(r0)
  376. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  377. r0.startActivityForResult(r10, r1)
  378. goto L_0x0379
  379. L_0x0166:
  380. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  381. int r10 = r10.mDeletePos
  382. if (r10 < 0) goto L_0x0379
  383. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  384. int r10 = r10.printer_location
  385. switch(r10) {
  386. case 2: goto L_0x01bc;
  387. case 3: goto L_0x0179;
  388. default: goto L_0x0177;
  389. }
  390. L_0x0177:
  391. goto L_0x01fe
  392. L_0x0179:
  393. epson.print.EPPrinterManager r10 = new epson.print.EPPrinterManager
  394. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  395. android.content.Context r0 = r0.mContext
  396. r10.<init>(r0)
  397. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  398. epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
  399. java.util.Vector r0 = r0.getData()
  400. epson.print.screen.SearchPrinterScr r2 = epson.print.screen.SearchPrinterScr.this
  401. int r2 = r2.mDeletePos
  402. java.lang.Object r0 = r0.elementAt(r2)
  403. epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
  404. java.lang.String r0 = r0.getPrinterId()
  405. r10.deleteIpPrinterInfo(r0)
  406. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  407. epson.print.widgets.AbstractListBuilder r10 = r10.mBuilder
  408. android.widget.BaseAdapter r10 = r10.getAdapter()
  409. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  410. epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
  411. java.util.Vector r0 = r0.getData()
  412. epson.print.screen.SearchPrinterScr r2 = epson.print.screen.SearchPrinterScr.this
  413. int r2 = r2.mDeletePos
  414. r0.remove(r2)
  415. r10.notifyDataSetChanged()
  416. goto L_0x01fe
  417. L_0x01bc:
  418. epson.print.EPPrinterManager r10 = new epson.print.EPPrinterManager
  419. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  420. android.content.Context r0 = r0.mContext
  421. r10.<init>(r0)
  422. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  423. epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
  424. java.util.Vector r0 = r0.getData()
  425. epson.print.screen.SearchPrinterScr r2 = epson.print.screen.SearchPrinterScr.this
  426. int r2 = r2.mDeletePos
  427. java.lang.Object r0 = r0.elementAt(r2)
  428. epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
  429. java.lang.String r0 = r0.getEmailAddress()
  430. r10.deleteRemotePrinterInfo(r0)
  431. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  432. epson.print.widgets.AbstractListBuilder r10 = r10.mBuilder
  433. android.widget.BaseAdapter r10 = r10.getAdapter()
  434. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  435. epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
  436. java.util.Vector r0 = r0.getData()
  437. epson.print.screen.SearchPrinterScr r2 = epson.print.screen.SearchPrinterScr.this
  438. int r2 = r2.mDeletePos
  439. r0.remove(r2)
  440. r10.notifyDataSetChanged()
  441. L_0x01fe:
  442. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  443. r10.displaySearchResult()
  444. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  445. int r10 = r10.printer_location
  446. if (r10 == r5) goto L_0x0212
  447. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  448. android.widget.Button r10 = r10.mSearchButton
  449. r10.setVisibility(r1)
  450. L_0x0212:
  451. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  452. int unused = r10.mDeletePos = r3
  453. goto L_0x0379
  454. L_0x0219:
  455. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  456. boolean r10 = r10.isDialogOpen
  457. if (r10 != 0) goto L_0x0379
  458. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  459. boolean unused = r10.isDialogOpen = r5
  460. java.lang.String r10 = "SearchPrinterScr"
  461. java.lang.StringBuilder r0 = new java.lang.StringBuilder
  462. r0.<init>()
  463. java.lang.String r1 = "mHandler curError = "
  464. r0.append(r1)
  465. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this
  466. int r1 = r1.curError
  467. r0.append(r1)
  468. java.lang.String r0 = r0.toString()
  469. epson.print.Util.EPLog.i(r10, r0)
  470. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  471. r10.showDialog(r4)
  472. goto L_0x0379
  473. L_0x0247:
  474. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  475. boolean r0 = r0.isFinishSearchPrinter
  476. if (r0 != 0) goto L_0x0257
  477. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  478. epson.print.service.IEpsonService r0 = r0.mEpsonService
  479. if (r0 != 0) goto L_0x025f
  480. L_0x0257:
  481. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  482. boolean r0 = r0.isSearchSimpleAp
  483. if (r0 == 0) goto L_0x0282
  484. L_0x025f:
  485. java.lang.String r0 = "SearchPrinterScr"
  486. java.lang.String r1 = "cancelSearch for SELECT_PRINTER"
  487. epson.print.Util.EPLog.i(r0, r1)
  488. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  489. r0.interruptSearch()
  490. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  491. android.os.Handler r0 = r0.mHandler
  492. int r1 = r10.what
  493. java.lang.Object r10 = r10.obj
  494. android.os.Message r10 = r0.obtainMessage(r1, r10)
  495. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this
  496. android.os.Handler r0 = r0.mHandler
  497. r1 = 200(0xc8, double:9.9E-322)
  498. r0.sendMessageDelayed(r10, r1)
  499. goto L_0x0379
  500. L_0x0282:
  501. java.lang.Object r10 = r10.obj
  502. epson.print.MyPrinter r10 = (epson.print.MyPrinter) r10
  503. android.content.Intent r0 = new android.content.Intent
  504. r0.<init>()
  505. java.lang.String r1 = "myprinter"
  506. r0.putExtra(r1, r10)
  507. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this
  508. int r1 = r1.printer_location
  509. if (r1 != r5) goto L_0x02ae
  510. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this
  511. java.lang.String r10 = r10.getPrinterId()
  512. java.lang.String r10 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromPrinterId(r10)
  513. java.lang.String r10 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getCurConnectInfo(r1, r10)
  514. if (r10 == 0) goto L_0x02b5
  515. java.lang.String r1 = "simpleap"
  516. r0.putExtra(r1, r10)
  517. goto L_0x02b5
  518. L_0x02ae:
  519. java.lang.String r10 = "simpleap"
  520. java.lang.String r1 = ""
  521. r0.putExtra(r10, r1)
  522. L_0x02b5:
  523. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  524. r10.setResult(r3, r0)
  525. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  526. r10.finish()
  527. goto L_0x0379
  528. L_0x02c1:
  529. android.os.Bundle r10 = r10.getData()
  530. java.lang.String r0 = "name"
  531. java.lang.String r0 = r10.getString(r0)
  532. if (r0 == 0) goto L_0x033f
  533. java.lang.String r1 = "FINISH"
  534. boolean r0 = r0.contentEquals(r1)
  535. if (r0 != 0) goto L_0x033f
  536. java.lang.Object r0 = epson.print.screen.SearchPrinterScr.mLock
  537. monitor-enter(r0)
  538. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this // Catch:{ all -> 0x033c }
  539. java.util.ArrayList r1 = r1.printerList // Catch:{ all -> 0x033c }
  540. java.lang.String r2 = "id"
  541. java.lang.String r2 = r10.getString(r2) // Catch:{ all -> 0x033c }
  542. boolean r1 = r1.contains(r2) // Catch:{ all -> 0x033c }
  543. if (r1 == 0) goto L_0x02ef
  544. monitor-exit(r0) // Catch:{ all -> 0x033c }
  545. goto L_0x0379
  546. L_0x02ef:
  547. epson.print.MyPrinter r1 = new epson.print.MyPrinter // Catch:{ all -> 0x033c }
  548. java.lang.String r2 = "name"
  549. java.lang.String r2 = r10.getString(r2) // Catch:{ all -> 0x033c }
  550. java.lang.String r6 = "ip"
  551. java.lang.String r6 = r10.getString(r6) // Catch:{ all -> 0x033c }
  552. java.lang.String r7 = "id"
  553. java.lang.String r7 = r10.getString(r7) // Catch:{ all -> 0x033c }
  554. java.lang.String r8 = "serial_no"
  555. java.lang.String r8 = r10.getString(r8) // Catch:{ all -> 0x033c }
  556. r1.<init>(r2, r6, r7, r8) // Catch:{ all -> 0x033c }
  557. java.lang.String r2 = "common_devicename"
  558. java.lang.String r2 = r10.getString(r2) // Catch:{ all -> 0x033c }
  559. r1.setCommonDeviceName(r2) // Catch:{ all -> 0x033c }
  560. epson.print.screen.SearchPrinterScr r2 = epson.print.screen.SearchPrinterScr.this // Catch:{ all -> 0x033c }
  561. com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r2 = r2.wiFiDirectPrinterListUtils // Catch:{ all -> 0x033c }
  562. java.lang.String r6 = r1.getIp() // Catch:{ all -> 0x033c }
  563. java.lang.String r7 = r1.getPrinterId() // Catch:{ all -> 0x033c }
  564. java.lang.String r7 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromPrinterId(r7) // Catch:{ all -> 0x033c }
  565. r2.addPrinter(r1, r3, r6, r7) // Catch:{ all -> 0x033c }
  566. epson.print.screen.SearchPrinterScr r1 = epson.print.screen.SearchPrinterScr.this // Catch:{ all -> 0x033c }
  567. java.util.ArrayList r1 = r1.printerList // Catch:{ all -> 0x033c }
  568. java.lang.String r2 = "id"
  569. java.lang.String r10 = r10.getString(r2) // Catch:{ all -> 0x033c }
  570. r1.add(r10) // Catch:{ all -> 0x033c }
  571. boolean unused = epson.print.screen.SearchPrinterScr.foundPrinter = r5 // Catch:{ all -> 0x033c }
  572. monitor-exit(r0) // Catch:{ all -> 0x033c }
  573. goto L_0x0379
  574. L_0x033c:
  575. r10 = move-exception
  576. monitor-exit(r0) // Catch:{ all -> 0x033c }
  577. throw r10
  578. L_0x033f:
  579. java.lang.Object r10 = epson.print.screen.SearchPrinterScr.mLock
  580. monitor-enter(r10)
  581. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this // Catch:{ all -> 0x0362 }
  582. boolean r0 = r0.isFinishSearchPrinter // Catch:{ all -> 0x0362 }
  583. if (r0 == 0) goto L_0x034e
  584. monitor-exit(r10) // Catch:{ all -> 0x0362 }
  585. goto L_0x0379
  586. L_0x034e:
  587. epson.print.screen.SearchPrinterScr r0 = epson.print.screen.SearchPrinterScr.this // Catch:{ all -> 0x0362 }
  588. boolean unused = r0.isFinishSearchPrinter = r5 // Catch:{ all -> 0x0362 }
  589. monitor-exit(r10) // Catch:{ all -> 0x0362 }
  590. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  591. boolean r10 = r10.isSearchSimpleAp
  592. if (r10 != 0) goto L_0x0379
  593. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  594. r10.displaySearchResult()
  595. goto L_0x0379
  596. L_0x0362:
  597. r0 = move-exception
  598. monitor-exit(r10) // Catch:{ all -> 0x0362 }
  599. throw r0
  600. L_0x0365:
  601. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  602. r10.interruptSearch()
  603. goto L_0x0379
  604. L_0x036b:
  605. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  606. int r10 = r10.printer_location
  607. if (r10 == r5) goto L_0x0374
  608. goto L_0x0379
  609. L_0x0374:
  610. epson.print.screen.SearchPrinterScr r10 = epson.print.screen.SearchPrinterScr.this
  611. r10.search()
  612. L_0x0379:
  613. return r4
  614. */
  615. throw new UnsupportedOperationException("Method not decompiled: epson.print.screen.SearchPrinterScr.C234613.handleMessage(android.os.Message):boolean");
  616. }
  617. });
  618. RadioButton mIpButton;
  619. boolean mIsClickSelect = false;
  620. ViewGroup mLayout;
  621. private TextView mListEmptyMessageTextView;
  622. private ListView mListView;
  623. RadioButton mLocalButton;
  624. ProgressBar mProgressBar;
  625. RadioButton mRemoteButton;
  626. Button mSearchButton;
  627. TextView mTextDetail;
  628. View mWiFiSettingButton;
  629. private String printerEmailAddress = "";
  630. private String printerId = "";
  631. private String printerKey = "";
  632. private ArrayList<String> printerList = new ArrayList<>();
  633. private volatile int printer_location = 0;
  634. private MyPrinter probedPrinter = null;
  635. WorkingDialog progress;
  636. private SearchWiFiDirectPrinterTask searchWiFiDirectPrinter = null;
  637. private MyPrinter selectedPrinter = null;
  638. WiFiDirectPrinterListUtils wiFiDirectPrinterListUtils = null;
  639. protected void onCreate(Bundle bundle) {
  640. super.onCreate(bundle);
  641. if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
  642. this.isJapaneseLocale = true;
  643. } else {
  644. this.isJapaneseLocale = false;
  645. }
  646. if (this.mEpsonService == null) {
  647. bindService(new Intent(this, EpsonService.class), this.mEpsonConnection, 1);
  648. }
  649. this.mLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.search_printer_layout, (ViewGroup) null);
  650. addWiFiSetupButton();
  651. addAboutRemoteButton();
  652. this.mListEmptyMessageTextView = (TextView) this.mLayout.findViewById(R.id.list_empty_message);
  653. this.mListView = (ListView) this.mLayout.findViewById(16908298);
  654. Intent intent = getIntent();
  655. this.printer_location = intent.getIntExtra(Constants.PRINTER_LOCATION, 1);
  656. if (this.printer_location == 0) {
  657. this.printer_location = 1;
  658. }
  659. switch (this.printer_location) {
  660. case 2:
  661. this.printerEmailAddress = intent.getStringExtra(Constants.PRINTER_EMAIL_ADDRESS);
  662. break;
  663. case 3:
  664. this.printerKey = intent.getStringExtra(Constants.PRINTER_ID);
  665. break;
  666. default:
  667. this.printerId = intent.getStringExtra(Constants.PRINTER_ID);
  668. this.connectionInfo = intent.getStringExtra(EXTRA_SIMPLEAP);
  669. break;
  670. }
  671. buildElements();
  672. setContentView((View) this.mLayout);
  673. this.mContext = this;
  674. this.mIsClickSelect = false;
  675. if (this.printer_location != 1) {
  676. displaySearchResult();
  677. this.mSearchButton.setVisibility(8);
  678. ((TextView) this.mLayout.findViewById(R.id.empty)).setVisibility(8);
  679. }
  680. setNotFoundPrinterButton();
  681. setBleWifiSetupButton();
  682. setActionBar((int) R.string.title_addprint, true);
  683. }
  684. private void setBleWifiSetupButton() {
  685. this.mLayout.findViewById(R.id.ble_wifi_setting).setVisibility(8);
  686. }
  687. private void setNotFoundPrinterButton() {
  688. this.mLayout.findViewById(R.id.not_found_printer_epsonsn).setOnClickListener(new View.OnClickListener() {
  689. public void onClick(View view) {
  690. SearchPrinterScr searchPrinterScr = SearchPrinterScr.this;
  691. searchPrinterScr.startActivity(PrinterNotFoundDialogCreator.getStartIntent(searchPrinterScr.getApplicationContext()));
  692. }
  693. });
  694. }
  695. private void addWiFiSetupButton() {
  696. this.mWiFiSettingButton = this.mLayout.findViewById(R.id.rlWifiSettings);
  697. if (this.isJapaneseLocale) {
  698. ((TextView) this.mWiFiSettingButton).setText(R.string.str_goto_wifidirect_settings);
  699. } else {
  700. ((TextView) this.mWiFiSettingButton).setText(R.string.str_wifidirect_settings);
  701. }
  702. this.mWiFiSettingButton.setOnClickListener(new View.OnClickListener() {
  703. public void onClick(View view) {
  704. SearchPrinterScr.this.startWifiPrinterSelect();
  705. }
  706. });
  707. }
  708. private void startWifiPrinterSelect() {
  709. startActivityForResult(new Intent(this, ActivityWiFiDirectStart.class), 10);
  710. }
  711. private void addAboutRemoteButton() {
  712. this.mAboutRemoteButton = this.mLayout.findViewById(R.id.AboutRemoteFrame);
  713. this.mAboutRemoteButton.setOnClickListener(new View.OnClickListener() {
  714. public void onClick(View view) {
  715. SearchPrinterScr.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.epsonconnect.com/iguide/")));
  716. }
  717. });
  718. }
  719. private void buildElements() {
  720. this.mSearchButton = (Button) this.mLayout.findViewById(R.id.function_button);
  721. this.mProgressBar = (ProgressBar) this.mLayout.findViewById(R.id.progress_bar);
  722. this.mAddButton = (Button) this.mLayout.findViewById(R.id.edit_button);
  723. this.mTextDetail = (TextView) this.mLayout.findViewById(R.id.detail);
  724. searchButtonSetEnabled(false);
  725. this.mProgressBar.setVisibility(0);
  726. this.mAddButton.setVisibility(8);
  727. this.mTextDetail.setVisibility(0);
  728. this.mWiFiSettingButton.setVisibility(0);
  729. this.mLocalButton = (RadioButton) this.mLayout.findViewById(R.id.btn_local);
  730. this.mIpButton = (RadioButton) this.mLayout.findViewById(R.id.btn_ip);
  731. this.mRemoteButton = (RadioButton) this.mLayout.findViewById(R.id.btn_remote);
  732. Utils.setDrawble2TextView(this, this.mLocalButton, R.drawable.printer_selector_icon_local);
  733. Utils.setDrawble2TextView(this, this.mIpButton, R.drawable.printer_selector_icon_ip);
  734. Utils.setDrawble2TextView(this, this.mRemoteButton, R.drawable.printer_selector_icon_remote);
  735. TextView textView = null;
  736. switch (this.printer_location) {
  737. case 1:
  738. this.mListView.setEmptyView((View) null);
  739. this.mListEmptyMessageTextView.setText((CharSequence) null);
  740. this.mListEmptyMessageTextView.setVisibility(8);
  741. this.mBuilder = new PrinterInfoBuilder(getBaseContext(), this.mLayout, 0);
  742. this.mBuilder.setResource(WiFiDirectPrinterListUtils.getCurPrinterString(this, this.printerId, this.connectionInfo));
  743. this.helper = new ListControlHelper((PrinterInfoBuilder) this.mBuilder);
  744. this.wiFiDirectPrinterListUtils = new WiFiDirectPrinterListUtils(this, this.mBuilder.getData(), this.helper, this.connectionInfo);
  745. this.mLocalButton.setChecked(true);
  746. this.mTextDetail.setText(R.string.str_detailtext_local);
  747. this.mLayout.findViewById(R.id.not_found_printer_epsonsn).setVisibility(0);
  748. break;
  749. case 2:
  750. this.mAddButton.setVisibility(0);
  751. this.mListEmptyMessageTextView.setText(R.string.printer_list_empty_message);
  752. textView = this.mListEmptyMessageTextView;
  753. this.mBuilder = new PrinterInfoECBuilder(getBaseContext(), this.mLayout);
  754. this.mBuilder.setResource(this.printerEmailAddress);
  755. this.mRemoteButton.setChecked(true);
  756. this.mTextDetail.setText(R.string.str_detailtext_remote);
  757. this.mSearchButton.setVisibility(8);
  758. this.mLayout.findViewById(R.id.not_found_printer_epsonsn).setVisibility(8);
  759. this.mWiFiSettingButton.setVisibility(8);
  760. break;
  761. case 3:
  762. this.mAddButton.setVisibility(0);
  763. this.mListEmptyMessageTextView.setText(R.string.printer_list_empty_message);
  764. textView = this.mListEmptyMessageTextView;
  765. this.mBuilder = new PrinterInfoIpBuilder(getBaseContext(), this.mLayout, 0);
  766. this.mBuilder.setResource(this.printerKey);
  767. this.mIpButton.setChecked(true);
  768. this.mTextDetail.setText(R.string.str_detailtext_ip);
  769. this.mSearchButton.setVisibility(8);
  770. this.mLayout.findViewById(R.id.not_found_printer_epsonsn).setVisibility(8);
  771. this.mWiFiSettingButton.setVisibility(8);
  772. break;
  773. }
  774. this.mBuilder.build();
  775. this.mBuilder.refresh();
  776. this.mListView.setEmptyView(textView);
  777. if (this.printer_location == 2) {
  778. this.mAboutRemoteButton.setVisibility(0);
  779. } else {
  780. this.mAboutRemoteButton.setVisibility(8);
  781. }
  782. this.mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  783. public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
  784. if (SearchPrinterScr.this.isFocused.booleanValue()) {
  785. Boolean unused = SearchPrinterScr.this.isFocused = false;
  786. SearchPrinterScr searchPrinterScr = SearchPrinterScr.this;
  787. searchPrinterScr.mIsClickSelect = true;
  788. Message obtainMessage = searchPrinterScr.mHandler.obtainMessage();
  789. obtainMessage.obj = SearchPrinterScr.this.mBuilder.getData().elementAt(i);
  790. int access$200 = SearchPrinterScr.this.printer_location;
  791. if (access$200 == 1) {
  792. String ip = ((MyPrinter) obtainMessage.obj).getIp();
  793. if (!WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(SearchPrinterScr.this, ip))) {
  794. SearchPrinterScr.this.interruptSearch();
  795. WiFiDirectManager.connect(SearchPrinterScr.this, ip, 10);
  796. } else {
  797. obtainMessage.what = 4;
  798. }
  799. } else if (access$200 != 3) {
  800. obtainMessage.what = 4;
  801. } else {
  802. obtainMessage.what = 12;
  803. }
  804. SearchPrinterScr.this.mHandler.sendMessageDelayed(obtainMessage, 100);
  805. }
  806. }
  807. });
  808. this.mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
  809. public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long j) {
  810. if (SearchPrinterScr.this.printer_location == 1) {
  811. return true;
  812. }
  813. int unused = SearchPrinterScr.this.mDeletePos = i;
  814. SearchPrinterScr searchPrinterScr = SearchPrinterScr.this;
  815. searchPrinterScr.registerForContextMenu(searchPrinterScr.mListView);
  816. return false;
  817. }
  818. });
  819. this.mAddButton.setOnClickListener(new View.OnClickListener() {
  820. public void onClick(View view) {
  821. switch (SearchPrinterScr.this.printer_location) {
  822. case 2:
  823. if (SearchPrinterScr.this.mBuilder.getData().size() >= 32) {
  824. new AlertDialog.Builder(SearchPrinterScr.this.mContext).setCancelable(false).setTitle(SearchPrinterScr.this.getString(R.string.epsonconnect_err_regist_remote_printer_max_size_title)).setMessage(SearchPrinterScr.this.getString(R.string.epsonconnect_err_regist_remote_printer_max_size)).setPositiveButton(SearchPrinterScr.this.getString(R.string.str_yes), new DialogInterface.OnClickListener() {
  825. public void onClick(DialogInterface dialogInterface, int i) {
  826. }
  827. }).show();
  828. return;
  829. } else if (SearchPrinterScr.this.getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true)) {
  830. AlertDialog.Builder cancelable = new AlertDialog.Builder(SearchPrinterScr.this.mContext).setCancelable(false);
  831. cancelable.setMessage(SearchPrinterScr.this.getString(R.string.epsonconnect_str_remote_print_warning) + "\n\n" + SearchPrinterScr.this.getString(R.string.epsonconnect_str_remote_print_warning2)).setPositiveButton(SearchPrinterScr.this.getString(R.string.str_yes), new DialogInterface.OnClickListener() {
  832. public void onClick(DialogInterface dialogInterface, int i) {
  833. Message message = new Message();
  834. message.what = 8;
  835. message.obj = null;
  836. SearchPrinterScr.this.mHandler.sendMessage(message);
  837. }
  838. }).setNegativeButton(SearchPrinterScr.this.getString(R.string.str_no), new DialogInterface.OnClickListener() {
  839. public void onClick(DialogInterface dialogInterface, int i) {
  840. }
  841. }).show();
  842. return;
  843. } else {
  844. Message message = new Message();
  845. message.what = 8;
  846. message.obj = null;
  847. SearchPrinterScr.this.mHandler.sendMessage(message);
  848. return;
  849. }
  850. case 3:
  851. if (SearchPrinterScr.this.mBuilder.getData().size() >= 32) {
  852. new AlertDialog.Builder(SearchPrinterScr.this.mContext).setCancelable(false).setTitle(SearchPrinterScr.this.getString(R.string.epsonconnect_err_regist_remote_printer_max_size_title)).setMessage(SearchPrinterScr.this.getString(R.string.epsonconnect_err_regist_remote_printer_max_size)).setPositiveButton(SearchPrinterScr.this.getString(R.string.str_yes), new DialogInterface.OnClickListener() {
  853. public void onClick(DialogInterface dialogInterface, int i) {
  854. }
  855. }).show();
  856. return;
  857. }
  858. Message message2 = new Message();
  859. message2.what = 11;
  860. message2.obj = null;
  861. SearchPrinterScr.this.mHandler.sendMessage(message2);
  862. return;
  863. default:
  864. return;
  865. }
  866. }
  867. });
  868. this.mSearchButton.setOnClickListener(new View.OnClickListener() {
  869. public void onClick(View view) {
  870. if (SearchPrinterScr.this.printer_location == 1) {
  871. SearchPrinterScr.this.mHandler.sendEmptyMessageDelayed(1, 100);
  872. }
  873. }
  874. });
  875. this.mLocalButton.setOnClickListener(new View.OnClickListener() {
  876. public void onClick(View view) {
  877. if (SearchPrinterScr.this.printer_location != 1) {
  878. SearchPrinterScr.this.mAddButton.setVisibility(8);
  879. ((TextView) SearchPrinterScr.this.mLayout.findViewById(R.id.empty)).setVisibility(0);
  880. SearchPrinterScr.this.interruptSearch();
  881. int unused = SearchPrinterScr.this.printer_location = 1;
  882. SearchPrinterScr.this.buildElements();
  883. SearchPrinterScr.this.mHandler.sendEmptyMessageDelayed(1, 100);
  884. }
  885. }
  886. });
  887. this.mRemoteButton.setOnClickListener(new View.OnClickListener() {
  888. public void onClick(View view) {
  889. if (SearchPrinterScr.this.printer_location != 2) {
  890. int unused = SearchPrinterScr.this.printer_location = 2;
  891. SearchPrinterScr.this.interruptSearch();
  892. ((TextView) SearchPrinterScr.this.mLayout.findViewById(R.id.empty)).setVisibility(8);
  893. SearchPrinterScr.this.mBuilder.refresh();
  894. SearchPrinterScr.this.buildElements();
  895. SearchPrinterScr.this.displaySearchResult();
  896. SearchPrinterScr.this.mSearchButton.setVisibility(8);
  897. }
  898. }
  899. });
  900. this.mIpButton.setOnClickListener(new View.OnClickListener() {
  901. public void onClick(View view) {
  902. if (SearchPrinterScr.this.printer_location != 3) {
  903. int unused = SearchPrinterScr.this.printer_location = 3;
  904. SearchPrinterScr.this.interruptSearch();
  905. ((TextView) SearchPrinterScr.this.mLayout.findViewById(R.id.empty)).setVisibility(8);
  906. SearchPrinterScr.this.mBuilder.refresh();
  907. SearchPrinterScr.this.buildElements();
  908. SearchPrinterScr.this.displaySearchResult();
  909. SearchPrinterScr.this.mSearchButton.setVisibility(8);
  910. }
  911. }
  912. });
  913. }
  914. public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
  915. super.onCreateContextMenu(contextMenu, view, contextMenuInfo);
  916. contextMenu.setHeaderTitle(R.string.str_edit_bookmark);
  917. contextMenu.add(0, 1, 0, R.string.str_delete);
  918. contextMenu.add(0, 2, 0, R.string.str_edit_bookmark);
  919. }
  920. public boolean onContextItemSelected(MenuItem menuItem) {
  921. this.listItemIndex = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
  922. if (this.listItemIndex == null) {
  923. return true;
  924. }
  925. switch (menuItem.getItemId()) {
  926. case 1:
  927. new AlertDialog.Builder(this.mContext).setCancelable(false).setTitle(getString(R.string.delete_file)).setIcon(getResources().getDrawable(R.drawable.delete_file)).setNegativeButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  928. public void onClick(DialogInterface dialogInterface, int i) {
  929. Message obtainMessage = SearchPrinterScr.this.mHandler.obtainMessage();
  930. obtainMessage.what = 7;
  931. SearchPrinterScr.this.mHandler.sendMessageDelayed(obtainMessage, 100);
  932. }
  933. }).setPositiveButton(getString(R.string.str_cancel), new DialogInterface.OnClickListener() {
  934. public void onClick(DialogInterface dialogInterface, int i) {
  935. }
  936. }).show();
  937. break;
  938. case 2:
  939. Message message = new Message();
  940. switch (this.printer_location) {
  941. case 2:
  942. message.what = 8;
  943. break;
  944. case 3:
  945. message.what = 11;
  946. break;
  947. }
  948. message.obj = this.mBuilder.getData().elementAt(this.mDeletePos);
  949. this.mHandler.sendMessage(message);
  950. break;
  951. }
  952. return true;
  953. }
  954. protected void onDestroy() {
  955. this.mBuilder.destructor();
  956. super.onDestroy();
  957. unbindEpsonService();
  958. }
  959. public void onBackPressed() {
  960. super.onBackPressed();
  961. interruptSearch();
  962. finish();
  963. }
  964. protected void onResume() {
  965. super.onResume();
  966. EPLog.d(TAG, "onResume()");
  967. this.mActivityForegroundLifetime = true;
  968. dismissPrinterNotFoundDialog();
  969. if (this.printer_location == 1) {
  970. this.mHandler.sendEmptyMessageDelayed(1, 100);
  971. EPLog.d(TAG, "Send CHECK_PRINTER Message.");
  972. }
  973. }
  974. protected void onPause() {
  975. EPLog.d(TAG, "onPause()");
  976. super.onPause();
  977. this.mActivityForegroundLifetime = false;
  978. interruptSearch();
  979. removeAllDialog();
  980. }
  981. protected void onActivityResult(int i, int i2, Intent intent) {
  982. super.onActivityResult(i, i2, intent);
  983. interruptSearch();
  984. switch (i) {
  985. case 8:
  986. if (i2 == -1) {
  987. Intent intent2 = new Intent();
  988. intent2.putExtra(EXTRA_PRINTER, (MyPrinter) intent.getParcelableExtra(ActivityPrinterSetting.KEY_MYPRINTER));
  989. setResult(-1, intent2);
  990. finish();
  991. return;
  992. }
  993. return;
  994. case 10:
  995. if (i2 == -1) {
  996. MyPrinter myPrinter = new MyPrinter(intent.getStringExtra("name"), intent.getStringExtra(escprLib.PRINTER_IP), intent.getStringExtra("id"), intent.getStringExtra(escprLib.PRINTER_SERIAL_NO));
  997. Intent intent3 = new Intent();
  998. intent3.putExtra(EXTRA_PRINTER, myPrinter);
  999. String curConnectInfo = WiFiDirectManager.getCurConnectInfo(this, MacAddrUtils.getMacAddressFromPrinterId(myPrinter.getPrinterId()));
  1000. if (this.printer_location != 1 || curConnectInfo == null) {
  1001. intent3.putExtra(EXTRA_SIMPLEAP, "");
  1002. } else {
  1003. intent3.putExtra(EXTRA_SIMPLEAP, curConnectInfo);
  1004. }
  1005. intent.getBooleanExtra(ActivityiPrintConnect.FINISH_EAYSETUP, false);
  1006. setResult(-1, intent3);
  1007. finish();
  1008. return;
  1009. }
  1010. this.isFocused = true;
  1011. this.mIsClickSelect = false;
  1012. return;
  1013. case 11:
  1014. if (i2 == -1) {
  1015. MyPrinter myPrinter2 = new MyPrinter(intent.getStringExtra(Constants.PRINTER_NAME), intent.getStringExtra(Constants.PRINTER_IP), intent.getStringExtra(Constants.PRINTER_ID), intent.getStringExtra(Constants.PRINTER_SERIAL_NO), "", 3);
  1016. Intent intent4 = new Intent();
  1017. intent4.putExtra(EXTRA_PRINTER, myPrinter2);
  1018. setResult(-1, intent4);
  1019. finish();
  1020. return;
  1021. }
  1022. return;
  1023. default:
  1024. return;
  1025. }
  1026. }
  1027. private void search() {
  1028. interruptSearch();
  1029. synchronized (mLock) {
  1030. this.printerList.clear();
  1031. this.mBuilder.refresh();
  1032. this.wiFiDirectPrinterListUtils.clearPrinterInfoList();
  1033. }
  1034. this.mIsClickSelect = false;
  1035. this.isFinishSearchPrinter = false;
  1036. searchButtonSetEnabled(false);
  1037. this.mProgressBar.setVisibility(0);
  1038. ((TextView) this.mLayout.findViewById(R.id.empty)).setText(getString(R.string.searching_text));
  1039. this.isFocused = true;
  1040. if (WiFiDirectManager.getCurSSID(this) != null) {
  1041. this.mHandler.sendEmptyMessageDelayed(14, 5000);
  1042. this.isSearchSimpleAp = true;
  1043. } else if (WiFiDirectManager.isWifiEnabled(this)) {
  1044. this.mHandler.sendEmptyMessage(14);
  1045. this.isSearchSimpleAp = true;
  1046. } else {
  1047. boolean z = this.bCheckWiFiStatus;
  1048. if (!z && !z) {
  1049. this.bCheckWiFiStatus = true;
  1050. WiFiDirectManager.enableWiFi(this, -1);
  1051. return;
  1052. }
  1053. }
  1054. WiFiDirectManager.setPriorityToSimpleAP(this, true);
  1055. if (this.mEpsonService != null) {
  1056. try {
  1057. synchronized (mLock) {
  1058. this.isFinishSearchPrinter = false;
  1059. }
  1060. this.mEpsonService.searchPrinters((String) null, (String) null, 1);
  1061. } catch (RemoteException e) {
  1062. e.printStackTrace();
  1063. }
  1064. } else {
  1065. this.mHandler.sendEmptyMessageDelayed(1, 100);
  1066. }
  1067. }
  1068. private void interruptSearch() {
  1069. EPLog.d(TAG, "interruptSearch()");
  1070. this.mHandler.removeMessages(1);
  1071. this.mHandler.removeMessages(14);
  1072. this.mHandler.removeMessages(3);
  1073. this.mHandler.removeMessages(9);
  1074. this.mHandler.removeMessages(13);
  1075. SearchWiFiDirectPrinterTask searchWiFiDirectPrinterTask = this.searchWiFiDirectPrinter;
  1076. if (searchWiFiDirectPrinterTask != null) {
  1077. searchWiFiDirectPrinterTask.interrupt();
  1078. this.searchWiFiDirectPrinter = null;
  1079. }
  1080. this.isSearchSimpleAp = false;
  1081. IEpsonService iEpsonService = this.mEpsonService;
  1082. if (iEpsonService != null) {
  1083. try {
  1084. iEpsonService.cancelSearchPrinter();
  1085. } catch (RemoteException e) {
  1086. e.printStackTrace();
  1087. }
  1088. }
  1089. WorkingDialog workingDialog = this.progress;
  1090. if (workingDialog != null && workingDialog.isShowing()) {
  1091. this.progress.dismiss();
  1092. }
  1093. this.isFocused = true;
  1094. }
  1095. public void displaySearchResult() {
  1096. if (!this.mIsClickSelect) {
  1097. if (this.mBuilder.getData().size() <= 0) {
  1098. ((TextView) this.mLayout.findViewById(R.id.empty)).setText(getString(R.string.EPS_PRNERR_COMM_TITLE1));
  1099. } else if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
  1100. ((TextView) this.mLayout.findViewById(R.id.empty)).setText(getString(R.string.numberOfPrintersAvailable));
  1101. } else {
  1102. ((TextView) this.mLayout.findViewById(R.id.empty)).setText(String.format(getString(R.string.numberOfPrintersAvailable), new Object[]{Integer.valueOf(this.mBuilder.getData().size())}));
  1103. }
  1104. }
  1105. this.mBuilder.getAdapter().notifyDataSetChanged();
  1106. this.mProgressBar.setVisibility(8);
  1107. searchButtonSetEnabled(true);
  1108. this.isFinishSearchPrinter = true;
  1109. }
  1110. private DialogFragment getPrinterNotFoundDialog() {
  1111. String str;
  1112. boolean prefBoolean = Utils.getPrefBoolean(getApplicationContext(), "PrintSetting", CommonDefine.RE_SEARCH);
  1113. int i = R.string.EPS_PRNERR_COMM_TITLE4;
  1114. if (prefBoolean) {
  1115. this.curError = -11001;
  1116. String ssid = Utils.getSSID(this);
  1117. if (!Utils.isConnectedWifi(this) || ssid == null) {
  1118. return CustomLayoutDialogFragment.newInstance(1, getString(R.string.EPS_PRNERR_COMM4), (int) R.string.EPS_PRNERR_COMM_TITLE4, 0, (int) R.string.str_btn_close);
  1119. }
  1120. str = String.format(getString(R.string.EPS_ERR_PRINTER_NOT_FOUND_RESEARCH2), new Object[]{ssid});
  1121. } else {
  1122. this.curError = -1100;
  1123. i = R.string.EPS_PRNERR_COMM_TITLE1;
  1124. str = getString(R.string.EPS_PRNERR_COMM1);
  1125. }
  1126. return CustomLayoutDialogFragment.newInstance(1, str + "\n\n" + getString(R.string.confirm_browse_wlan_setup_info), i, (int) R.string.browse_site, (int) R.string.str_btn_close);
  1127. }
  1128. private void showPrinterNotFoundDialog(DialogFragment dialogFragment) {
  1129. if (this.mActivityForegroundLifetime) {
  1130. dialogFragment.show(getSupportFragmentManager(), DIALOG_TAG_PRINTER_NOT_FOUND);
  1131. }
  1132. }
  1133. protected Dialog onCreateDialog(int i) {
  1134. if (i != 0) {
  1135. return null;
  1136. }
  1137. EPLog.i(TAG, "DIALOG_INFORM curError = " + this.curError);
  1138. int i2 = this.curError;
  1139. if (i2 == -1100 || i2 == -11001) {
  1140. if (Utils.getPrefBoolean(getApplicationContext(), "PrintSetting", CommonDefine.RE_SEARCH)) {
  1141. this.curError = -11001;
  1142. } else {
  1143. this.curError = -1100;
  1144. }
  1145. }
  1146. Integer[] stringId = MediaInfo.ErrorTable.getStringId(this.curError);
  1147. if (stringId == null) {
  1148. stringId = new Integer[]{Integer.valueOf(R.string.NOT_IMPLEMENT), Integer.valueOf(R.string.NOT_IMPLEMENT_TITLE)};
  1149. }
  1150. String string = getString(stringId[0].intValue());
  1151. String ssid = Utils.getSSID(this);
  1152. if (Utils.isConnectedWifi(this) && this.curError == -11001 && ssid != null) {
  1153. string = String.format(getString(R.string.EPS_ERR_PRINTER_NOT_FOUND_RESEARCH), new Object[]{ssid});
  1154. }
  1155. return new CustomTitleAlertDialogBuilder(this).setTitle((CharSequence) getString(stringId[1].intValue())).setMessage(string).setCancelable(false).setNegativeButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  1156. public void onClick(DialogInterface dialogInterface, int i) {
  1157. SearchPrinterScr.this.removeDialog(0);
  1158. boolean unused = SearchPrinterScr.this.isDialogOpen = false;
  1159. }
  1160. }).create();
  1161. }
  1162. private void dismissPrinterNotFoundDialog() {
  1163. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_PRINTER_NOT_FOUND);
  1164. if (dialogFragment != null) {
  1165. dialogFragment.dismiss();
  1166. }
  1167. }
  1168. /* access modifiers changed from: package-private */
  1169. /* JADX WARNING: Failed to process nested try/catch */
  1170. /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0004 */
  1171. /* Code decompiled incorrectly, please refer to instructions dump. */
  1172. public void removeAllDialog() {
  1173. /*
  1174. r1 = this;
  1175. r0 = 0
  1176. r1.removeDialog(r0) // Catch:{ IllegalArgumentException -> 0x0004 }
  1177. L_0x0004:
  1178. r1.dismissPrinterNotFoundDialog() // Catch:{ Exception -> 0x0007 }
  1179. L_0x0007:
  1180. return
  1181. */
  1182. throw new UnsupportedOperationException("Method not decompiled: epson.print.screen.SearchPrinterScr.removeAllDialog():void");
  1183. }
  1184. public void searchButtonSetEnabled(boolean z) {
  1185. this.mSearchButton.setVisibility(0);
  1186. if (z) {
  1187. this.mSearchButton.setEnabled(true);
  1188. } else {
  1189. this.mSearchButton.setEnabled(false);
  1190. }
  1191. }
  1192. private void unbindEpsonService() {
  1193. if (this.mEpsonService != null) {
  1194. if (!this.isFinishSearchPrinter) {
  1195. this.mHandler.sendEmptyMessageDelayed(2, 200);
  1196. }
  1197. try {
  1198. this.mEpsonService.unregisterCallback(this.mCallback);
  1199. unbindService(this.mEpsonConnection);
  1200. } catch (RemoteException e) {
  1201. e.printStackTrace();
  1202. }
  1203. }
  1204. }
  1205. public void onLocalPositiveCallback(int i) {
  1206. if (i == 1) {
  1207. startActivity(PrinterNotFoundDialogCreator.getStartIntent(this));
  1208. this.isDialogOpen = false;
  1209. }
  1210. }
  1211. public void onLocalNegativeCallback(int i) {
  1212. this.isDialogOpen = false;
  1213. }
  1214. }