SearchPrinterScr.java 60 KB

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