Commit 20980a6e21ee9923ace6faa9f9a9cd3c5d610fc2
1 parent
eb180443
Exists in
master
and in
5 other branches
Iniciando a implementação da caixa de diálogo modal durante comunicação com o host
Showing
5 changed files
with
82 additions
and
55 deletions
Show diff stats
android/jni/main.cpp
... | ... | @@ -127,6 +127,12 @@ static void ctlr_done(H3270 *session) |
127 | 127 | post_message(4); |
128 | 128 | } |
129 | 129 | |
130 | +void update_status(H3270 *session, LIB3270_MESSAGE id) | |
131 | +{ | |
132 | + __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "Status changed to %d",(int) id); | |
133 | + post_message(1,(int) id); | |
134 | +} | |
135 | + | |
130 | 136 | static int write_buffer(H3270 *session, unsigned const char *buf, int len) |
131 | 137 | { |
132 | 138 | int rc = -1; |
... | ... | @@ -276,6 +282,7 @@ JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jclass ob |
276 | 282 | session->changed = changed; |
277 | 283 | session->erase = erase; |
278 | 284 | session->ctlr_done = ctlr_done; |
285 | + session->update_status = update_status; | |
279 | 286 | |
280 | 287 | PW3270_JNI_END |
281 | 288 | ... | ... |
android/res/values/strings.xml
android/src/br/com/bb/pw3270/PW3270Activity.java
... | ... | @@ -14,22 +14,24 @@ import android.webkit.WebView; |
14 | 14 | import android.webkit.WebViewClient; |
15 | 15 | import android.webkit.WebResourceResponse; |
16 | 16 | import android.webkit.WebChromeClient; |
17 | +import android.app.ProgressDialog; | |
17 | 18 | // import java.io.InputStream; |
18 | 19 | |
19 | 20 | // import android.app.Dialog; |
20 | 21 | |
21 | -public class PW3270Activity extends Activity | |
22 | +public class PW3270Activity extends Activity | |
22 | 23 | { |
23 | 24 | private static final String TAG = "pw3270"; |
24 | 25 | |
25 | - private Resources res; | |
26 | - private WebView view; | |
27 | - private terminal host; | |
28 | - private Activity mainact; | |
29 | - | |
26 | + private Resources res; | |
27 | + private WebView view; | |
28 | + private terminal host; | |
29 | + private Activity mainact; | |
30 | + private ProgressDialog dlgProgress; | |
31 | + | |
30 | 32 | private class terminal extends lib3270 |
31 | 33 | { |
32 | - | |
34 | + | |
33 | 35 | terminal() |
34 | 36 | { |
35 | 37 | SharedPreferences settings = getSharedPreferences(TAG, 0); |
... | ... | @@ -43,20 +45,47 @@ public class PW3270Activity extends Activity |
43 | 45 | |
44 | 46 | } |
45 | 47 | |
48 | + public void hideProgressDialog() | |
49 | + { | |
50 | + dlgProgress.hide(); | |
51 | + } | |
52 | + | |
53 | + public void showProgressDialog(String msg) | |
54 | + { | |
55 | + dlgProgress.setMessage(msg); | |
56 | + Log.v(TAG,msg); | |
57 | + dlgProgress.show(); | |
58 | + } | |
59 | + | |
46 | 60 | protected void updateProgramMessage(int id) |
47 | 61 | { |
48 | - /* | |
49 | - try | |
62 | + if(id == 0) | |
50 | 63 | { |
51 | - // this.msgbox.setText(message[id]); | |
52 | - } catch(Exception e) { this.msgbox.setText("Estado inesperado"); } | |
53 | - */ | |
64 | + if(changed) | |
65 | + { | |
66 | + dlgProgress.setMessage("Aguarde..."); | |
67 | + changed = false; | |
68 | + view.reload(); | |
69 | + hideProgressDialog(); | |
70 | + } | |
71 | + } | |
72 | + else | |
73 | + { | |
74 | + String message[] = res.getStringArray(R.array.program_msg); | |
75 | + try | |
76 | + { | |
77 | + showProgressDialog(message[id]); | |
78 | + } catch(Exception e) | |
79 | + { | |
80 | + showProgressDialog("Aguarde..."); | |
81 | + } | |
82 | + } | |
54 | 83 | } |
55 | 84 | |
56 | 85 | protected void popupMessage(int type, String title, String text, String info) |
57 | 86 | { |
58 | 87 | AlertDialog d = new AlertDialog.Builder(mainact).create(); |
59 | - | |
88 | + | |
60 | 89 | d.setTitle(title); |
61 | 90 | d.setMessage(text); |
62 | 91 | |
... | ... | @@ -67,58 +96,56 @@ public class PW3270Activity extends Activity |
67 | 96 | public String getscreencontents() |
68 | 97 | { |
69 | 98 | String text; |
70 | - | |
99 | + | |
71 | 100 | try |
72 | 101 | { |
73 | 102 | text = new String(getHTML(),getEncoding()); |
74 | 103 | } catch(Exception e) { text = ""; } |
75 | - | |
104 | + | |
76 | 105 | return text; |
77 | 106 | } |
78 | - | |
79 | - protected void redraw() | |
80 | - { | |
81 | - view.reload(); | |
82 | - } | |
83 | - | |
107 | + | |
84 | 108 | }; |
85 | 109 | |
86 | - | |
87 | - | |
88 | 110 | /** Called when the activity is first created. */ |
89 | 111 | @Override |
90 | - public void onCreate(Bundle savedInstanceState) | |
112 | + public void onCreate(Bundle savedInstanceState) | |
91 | 113 | { |
92 | 114 | super.onCreate(savedInstanceState); |
93 | - | |
115 | + | |
94 | 116 | res = getResources(); |
95 | 117 | |
118 | + dlgProgress = new ProgressDialog(this); | |
119 | + dlgProgress.setMessage("Aguarde..."); | |
120 | + dlgProgress.setCancelable(false); | |
121 | +// dlgProgress.show(); | |
122 | + | |
96 | 123 | // Reference: |
97 | 124 | // http://developer.android.com/reference/android/webkit/WebView.html |
98 | 125 | view = new WebView(this); |
99 | - | |
126 | + | |
100 | 127 | view.setWebChromeClient(new WebChromeClient()); |
101 | 128 | |
102 | 129 | view.getSettings().setBuiltInZoomControls(true); |
103 | - view.getSettings().setSupportZoom(true); | |
130 | + view.getSettings().setSupportZoom(true); | |
104 | 131 | view.getSettings().setUseWideViewPort(true); |
105 | - view.getSettings().setLoadWithOverviewMode(true); | |
106 | - | |
107 | - view.setWebViewClient(new WebViewClient() | |
132 | + view.getSettings().setLoadWithOverviewMode(true); | |
133 | + | |
134 | + view.setWebViewClient(new WebViewClient() | |
108 | 135 | { |
109 | - | |
136 | + | |
110 | 137 | @Override |
111 | 138 | public WebResourceResponse shouldInterceptRequest(WebView view, String url) |
112 | 139 | { |
113 | 140 | int id = R.raw.index; |
114 | 141 | String mime = "text/html"; |
115 | 142 | int pos = url.lastIndexOf("/"); |
116 | - | |
143 | + | |
117 | 144 | if(pos >=0 ) |
118 | 145 | url = url.substring(pos+1); |
119 | - | |
146 | + | |
120 | 147 | Log.i(TAG,"Loading [" + url + "]"); |
121 | - | |
148 | + | |
122 | 149 | if(url.equalsIgnoreCase("jsmain.js")) |
123 | 150 | { |
124 | 151 | id = R.raw.jsmain; |
... | ... | @@ -129,23 +156,23 @@ public class PW3270Activity extends Activity |
129 | 156 | id = R.raw.theme; |
130 | 157 | } |
131 | 158 | |
132 | - | |
159 | + | |
133 | 160 | // http://developer.android.com/reference/android/webkit/WebResourceResponse.html |
134 | 161 | return new WebResourceResponse(mime,"utf-8",getResources().openRawResource(id)); |
135 | 162 | } |
136 | - | |
163 | + | |
137 | 164 | }); |
138 | - | |
165 | + | |
139 | 166 | view.getSettings().setJavaScriptEnabled(true); |
140 | 167 | |
141 | 168 | setContentView(view); |
142 | 169 | view.loadUrl("file:index.html"); |
143 | - | |
170 | + | |
144 | 171 | host = new terminal(); |
145 | 172 | view.addJavascriptInterface(host, "pw3270"); |
146 | 173 | host.connect(); |
147 | - | |
174 | + | |
148 | 175 | |
149 | 176 | } |
150 | 177 | |
151 | -} | |
152 | 178 | \ No newline at end of file |
179 | +} | ... | ... |
android/src/br/com/bb/pw3270/lib3270.java
... | ... | @@ -17,7 +17,7 @@ public class lib3270 |
17 | 17 | private NetworkThread mainloop; |
18 | 18 | private static final String TAG = "lib3270"; |
19 | 19 | |
20 | - private boolean changed; | |
20 | + protected boolean changed; | |
21 | 21 | private boolean connected = false; |
22 | 22 | private boolean refresh = true; |
23 | 23 | |
... | ... | @@ -147,10 +147,10 @@ public class lib3270 |
147 | 147 | { |
148 | 148 | // Connecta no host |
149 | 149 | SocketFactory socketFactory; |
150 | - | |
150 | + | |
151 | 151 | if(hostname == "") |
152 | 152 | return false; |
153 | - | |
153 | + | |
154 | 154 | if(ssl) |
155 | 155 | { |
156 | 156 | // Host é SSL |
... | ... | @@ -295,8 +295,6 @@ public class lib3270 |
295 | 295 | case 2: // Screen changed |
296 | 296 | Log.d(TAG,"Screen changed"); |
297 | 297 | changed = true; |
298 | - if(refresh) | |
299 | - redraw(); | |
300 | 298 | break; |
301 | 299 | |
302 | 300 | case 3: // Popup |
... | ... | @@ -311,11 +309,6 @@ public class lib3270 |
311 | 309 | |
312 | 310 | case 5: // ctlr_done |
313 | 311 | Log.d(TAG,"ctlr_done"); |
314 | - if(changed) | |
315 | - { | |
316 | - changed = false; | |
317 | - redraw(); | |
318 | - } | |
319 | 312 | break; |
320 | 313 | |
321 | 314 | case 6: // recv_data |
... | ... | @@ -350,10 +343,6 @@ public class lib3270 |
350 | 343 | Log.i(TAG,"Erase screen"); |
351 | 344 | } |
352 | 345 | |
353 | - protected void redraw() | |
354 | - { | |
355 | - } | |
356 | - | |
357 | 346 | public void pfkey(int id) |
358 | 347 | { |
359 | 348 | Log.d(TAG,"PF"+id); | ... | ... |
src/lib3270/html.c
... | ... | @@ -386,9 +386,11 @@ |
386 | 386 | else |
387 | 387 | { |
388 | 388 | append_element(&info,HTML_ELEMENT_LINE_BREAK); |
389 | +/* | |
389 | 390 | #if defined(DEBUG) || defined(ANDROID) |
390 | 391 | append_string(&info,"\n"); |
391 | 392 | #endif // DEBUG |
393 | +*/ | |
392 | 394 | } |
393 | 395 | |
394 | 396 | } |
... | ... | @@ -420,6 +422,7 @@ |
420 | 422 | |
421 | 423 | info.text = lib3270_realloc(info.text,strlen(info.text)+2); |
422 | 424 | |
425 | +/* | |
423 | 426 | #if defined(DEBUG) || defined(ANDROID) |
424 | 427 | { |
425 | 428 | char *text = strdup(info.text); |
... | ... | @@ -434,6 +437,7 @@ |
434 | 437 | free(text); |
435 | 438 | } |
436 | 439 | #endif // DEBUG |
440 | +*/ | |
437 | 441 | |
438 | 442 | return info.text; |
439 | 443 | } | ... | ... |