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 | 14 | android:dialogMessage="Informe nome do servidor" |
| 15 | 15 | android:defaultValue="" /> |
| 16 | 16 | |
| 17 | - | |
| 18 | 17 | <EditTextPreference |
| 19 | 18 | android:key="port" |
| 20 | 19 | android:title="Porta a conectar" |
| ... | ... | @@ -29,7 +28,14 @@ |
| 29 | 28 | android:title="Conexão segura" |
| 30 | 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 | 39 | </PreferenceCategory> |
| 34 | 40 | |
| 35 | 41 | </PreferenceScreen> | ... | ... |
android/src/br/com/bb/pw3270/PW3270Activity.java
| ... | ... | @@ -177,7 +177,7 @@ public class PW3270Activity extends Activity |
| 177 | 177 | setContentView(view); |
| 178 | 178 | view.loadUrl("file:index.html"); |
| 179 | 179 | |
| 180 | - if(settings.getString("hostname","") != "") | |
| 180 | + if(settings.getString("hostname","") != "" && settings.getBoolean("reconnect",false)) | |
| 181 | 181 | host.connect(); |
| 182 | 182 | |
| 183 | 183 | } | ... | ... |
android/src/br/com/bb/pw3270/lib3270.java
| ... | ... | @@ -199,7 +199,7 @@ public class lib3270 |
| 199 | 199 | msg = e.toString(); |
| 200 | 200 | |
| 201 | 201 | if (msg == null) |
| 202 | - msg = "Erro indefinido"; | |
| 202 | + msg = ""; | |
| 203 | 203 | |
| 204 | 204 | Log.i(TAG, "Erro ao enviar dados: " + msg); |
| 205 | 205 | |
| ... | ... | @@ -253,11 +253,11 @@ public class lib3270 |
| 253 | 253 | msg = e.toString(); |
| 254 | 254 | |
| 255 | 255 | if (msg == null) |
| 256 | - msg = "Erro indefinido"; | |
| 256 | + msg = ""; | |
| 257 | 257 | |
| 258 | 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 | 262 | postMessage(0, 0, 0); |
| 263 | 263 | |
| ... | ... | @@ -291,25 +291,19 @@ public class lib3270 |
| 291 | 291 | |
| 292 | 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 | 297 | connected = false; |
| 296 | 298 | sz = -1; |
| 297 | 299 | } |
| 298 | 300 | |
| 299 | 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 | 309 | Log.v(TAG, "Exiting communication thread"); |
| ... | ... | @@ -329,8 +323,6 @@ public class lib3270 |
| 329 | 323 | mainloop = null; |
| 330 | 324 | info(TAG, "Network thread stopped"); |
| 331 | 325 | |
| 332 | - postPopup(0,"","Desconectado",""); | |
| 333 | - | |
| 334 | 326 | } |
| 335 | 327 | |
| 336 | 328 | } | ... | ... |