Commit 5c783f96fdb777bce54ac186fffc73d1d18f4384
1 parent
02b1c4d4
Exists in
master
and in
5 other branches
Android - Implementando diálogo de configuração
Showing
3 changed files
with
18 additions
and
20 deletions
Show diff stats
android/res/xml/preferences.xml
@@ -14,7 +14,6 @@ | @@ -14,7 +14,6 @@ | ||
14 | android:dialogMessage="Informe nome do servidor" | 14 | android:dialogMessage="Informe nome do servidor" |
15 | android:defaultValue="" /> | 15 | android:defaultValue="" /> |
16 | 16 | ||
17 | - | ||
18 | <EditTextPreference | 17 | <EditTextPreference |
19 | android:key="port" | 18 | android:key="port" |
20 | android:title="Porta a conectar" | 19 | android:title="Porta a conectar" |
@@ -29,7 +28,14 @@ | @@ -29,7 +28,14 @@ | ||
29 | android:title="Conexão segura" | 28 | android:title="Conexão segura" |
30 | android:defaultValue="false" | 29 | android:defaultValue="false" |
31 | /> | 30 | /> |
32 | - | 31 | + |
32 | + <CheckBoxPreference | ||
33 | + android:key="reconnect" | ||
34 | + android:summary="Conectar automaticamente" | ||
35 | + android:title="Conexão automática" | ||
36 | + android:defaultValue="true" | ||
37 | + /> | ||
38 | + | ||
33 | </PreferenceCategory> | 39 | </PreferenceCategory> |
34 | 40 | ||
35 | </PreferenceScreen> | 41 | </PreferenceScreen> |
android/src/br/com/bb/pw3270/PW3270Activity.java
@@ -177,7 +177,7 @@ public class PW3270Activity extends Activity | @@ -177,7 +177,7 @@ public class PW3270Activity extends Activity | ||
177 | setContentView(view); | 177 | setContentView(view); |
178 | view.loadUrl("file:index.html"); | 178 | view.loadUrl("file:index.html"); |
179 | 179 | ||
180 | - if(settings.getString("hostname","") != "") | 180 | + if(settings.getString("hostname","") != "" && settings.getBoolean("reconnect",false)) |
181 | host.connect(); | 181 | host.connect(); |
182 | 182 | ||
183 | } | 183 | } |
android/src/br/com/bb/pw3270/lib3270.java
@@ -199,7 +199,7 @@ public class lib3270 | @@ -199,7 +199,7 @@ public class lib3270 | ||
199 | msg = e.toString(); | 199 | msg = e.toString(); |
200 | 200 | ||
201 | if (msg == null) | 201 | if (msg == null) |
202 | - msg = "Erro indefinido"; | 202 | + msg = ""; |
203 | 203 | ||
204 | Log.i(TAG, "Erro ao enviar dados: " + msg); | 204 | Log.i(TAG, "Erro ao enviar dados: " + msg); |
205 | 205 | ||
@@ -253,11 +253,11 @@ public class lib3270 | @@ -253,11 +253,11 @@ public class lib3270 | ||
253 | msg = e.toString(); | 253 | msg = e.toString(); |
254 | 254 | ||
255 | if (msg == null) | 255 | if (msg == null) |
256 | - msg = "Erro indefinido"; | 256 | + msg = ""; |
257 | 257 | ||
258 | Log.i(TAG, "Erro ao conectar: " + msg); | 258 | Log.i(TAG, "Erro ao conectar: " + msg); |
259 | 259 | ||
260 | - postPopup(0, "Erro na conexão", "Não foi possível conectar", msg); | 260 | + postPopup(0, "Erro na conexão", msg, ""); |
261 | 261 | ||
262 | postMessage(0, 0, 0); | 262 | postMessage(0, 0, 0); |
263 | 263 | ||
@@ -291,25 +291,19 @@ public class lib3270 | @@ -291,25 +291,19 @@ public class lib3270 | ||
291 | 291 | ||
292 | } catch (Exception e) | 292 | } catch (Exception e) |
293 | { | 293 | { |
294 | - Log.i(TAG, "Erro ao receber dados do host: " + e.getLocalizedMessage()); | 294 | + String msg = e.getLocalizedMessage(); |
295 | + Log.i(TAG, "Erro ao receber dados do host: " + msg); | ||
296 | + postPopup(0, "Erro na comunicação", "Erro ao receber dados", msg); | ||
295 | connected = false; | 297 | connected = false; |
296 | sz = -1; | 298 | sz = -1; |
297 | } | 299 | } |
298 | 300 | ||
299 | if (sz > 0) | 301 | if (sz > 0) |
300 | - { | ||
301 | - try | ||
302 | - { | ||
303 | - Log.i(TAG, Integer.toString(sz) + " bytes recebidos"); | ||
304 | - procRecvdata(in,sz); | ||
305 | - } catch (Exception e) | ||
306 | - { | ||
307 | - Log.i(TAG, "Erro ao processar dados recebidos: " + e.getLocalizedMessage()); | ||
308 | - connected = false; | ||
309 | - } | ||
310 | - } | 302 | + procRecvdata(in,sz); |
311 | 303 | ||
312 | } | 304 | } |
305 | + // postPopup(0,"","Desconectado",""); | ||
306 | + | ||
313 | } | 307 | } |
314 | 308 | ||
315 | Log.v(TAG, "Exiting communication thread"); | 309 | Log.v(TAG, "Exiting communication thread"); |
@@ -329,8 +323,6 @@ public class lib3270 | @@ -329,8 +323,6 @@ public class lib3270 | ||
329 | mainloop = null; | 323 | mainloop = null; |
330 | info(TAG, "Network thread stopped"); | 324 | info(TAG, "Network thread stopped"); |
331 | 325 | ||
332 | - postPopup(0,"","Desconectado",""); | ||
333 | - | ||
334 | } | 326 | } |
335 | 327 | ||
336 | } | 328 | } |