Commit 9ba1f408d94499187114e05ce3c84324bb9b664b
1 parent
f9e40aeb
Exists in
master
and in
5 other branches
Android - Removendo referências ao código gerado automaticamente na lib3270.java…
… para facilitar o empacotamento
Showing
3 changed files
with
66 additions
and
46 deletions
Show diff stats
android/Makefile
android/src/br/com/bb/pw3270/PW3270Activity.java
| ... | ... | @@ -36,7 +36,9 @@ import android.os.Bundle; |
| 36 | 36 | import android.util.Log; |
| 37 | 37 | import android.content.Intent; |
| 38 | 38 | import android.content.res.*; |
| 39 | +import android.webkit.WebResourceResponse; | |
| 39 | 40 | import android.webkit.WebView; |
| 41 | +import android.webkit.WebViewClient; | |
| 40 | 42 | import android.app.ProgressDialog; |
| 41 | 43 | import android.view.Menu; |
| 42 | 44 | import android.view.MenuInflater; |
| ... | ... | @@ -69,9 +71,27 @@ public class PW3270Activity extends Activity |
| 69 | 71 | protected void initUI() |
| 70 | 72 | { |
| 71 | 73 | if(host == null) |
| 72 | - host = new lib3270(this); | |
| 74 | + { | |
| 75 | + host = new lib3270(this) | |
| 76 | + { | |
| 77 | + public String getProgramMessageText(int id) | |
| 78 | + { | |
| 79 | + String message[] = res.getStringArray(R.array.program_msg); | |
| 80 | + try | |
| 81 | + { | |
| 82 | + return message[id]; | |
| 83 | + } catch(Exception e) | |
| 84 | + { | |
| 85 | + return e.getLocalizedMessage(); | |
| 86 | + } | |
| 87 | + | |
| 88 | + } | |
| 89 | + }; | |
| 90 | + } | |
| 73 | 91 | else |
| 92 | + { | |
| 74 | 93 | host.setActivity(this); |
| 94 | + } | |
| 75 | 95 | |
| 76 | 96 | Log.d(TAG, "Initializing UI"); |
| 77 | 97 | |
| ... | ... | @@ -81,9 +101,39 @@ public class PW3270Activity extends Activity |
| 81 | 101 | |
| 82 | 102 | // Reference: |
| 83 | 103 | // http://developer.android.com/reference/android/webkit/WebView.html |
| 84 | - Log.d(TAG, "Creating Webview"); | |
| 85 | - setContentView(host.setView(new WebView(this))); | |
| 86 | - | |
| 104 | + host.setView(new WebView(this)).setWebViewClient(new WebViewClient() | |
| 105 | + { | |
| 106 | + | |
| 107 | + @Override | |
| 108 | + public WebResourceResponse shouldInterceptRequest(WebView view, String url) | |
| 109 | + { | |
| 110 | + int id = R.raw.index; | |
| 111 | + String mime = "text/html"; | |
| 112 | + int pos = url.lastIndexOf("/"); | |
| 113 | + | |
| 114 | + if(pos >=0 ) | |
| 115 | + url = url.substring(pos+1); | |
| 116 | + | |
| 117 | + Log.i(TAG,"Loading [" + url + "]"); | |
| 118 | + | |
| 119 | + if(url.equalsIgnoreCase("jsmain.js")) | |
| 120 | + { | |
| 121 | + id = R.raw.jsmain; | |
| 122 | + } | |
| 123 | + else if(url.equalsIgnoreCase("theme.css")) | |
| 124 | + { | |
| 125 | + mime = "text/css"; | |
| 126 | + id = R.raw.theme; | |
| 127 | + } | |
| 128 | + | |
| 129 | + // http://developer.android.com/reference/android/webkit/WebResourceResponse.html | |
| 130 | + return new WebResourceResponse(mime,"utf-8",host.mainact.getResources().openRawResource(id)); | |
| 131 | + } | |
| 132 | + | |
| 133 | + }); | |
| 134 | + | |
| 135 | + setContentView(host.view); | |
| 136 | + | |
| 87 | 137 | host.view.loadUrl("file:index.html"); |
| 88 | 138 | host.initialize(); |
| 89 | 139 | } | ... | ... |
android/src/br/com/bb/pw3270/lib3270.java
| ... | ... | @@ -41,9 +41,9 @@ import android.os.CountDownTimer; |
| 41 | 41 | import android.preference.PreferenceManager; |
| 42 | 42 | import android.util.Log; |
| 43 | 43 | import android.webkit.WebChromeClient; |
| 44 | -import android.webkit.WebResourceResponse; | |
| 44 | +// import android.webkit.WebResourceResponse; | |
| 45 | 45 | import android.webkit.WebView; |
| 46 | -import android.webkit.WebViewClient; | |
| 46 | +// import android.webkit.WebViewClient; | |
| 47 | 47 | import javax.net.SocketFactory; |
| 48 | 48 | import java.net.Socket; |
| 49 | 49 | import javax.net.ssl.SSLSocketFactory; |
| ... | ... | @@ -52,7 +52,7 @@ import java.io.DataOutputStream; |
| 52 | 52 | |
| 53 | 53 | // import java.util.Vector; |
| 54 | 54 | |
| 55 | -public class lib3270 | |
| 55 | +public abstract class lib3270 | |
| 56 | 56 | { |
| 57 | 57 | private static final String TAG = "lib3270"; |
| 58 | 58 | |
| ... | ... | @@ -389,41 +389,17 @@ public class lib3270 |
| 389 | 389 | view.getSettings().setLoadWithOverviewMode(true); |
| 390 | 390 | view.getSettings().setJavaScriptEnabled(true); |
| 391 | 391 | |
| 392 | - view.setWebViewClient(new WebViewClient() | |
| 393 | - { | |
| 394 | - | |
| 395 | - @Override | |
| 396 | - public WebResourceResponse shouldInterceptRequest(WebView view, String url) | |
| 397 | - { | |
| 398 | - int id = R.raw.index; | |
| 399 | - String mime = "text/html"; | |
| 400 | - int pos = url.lastIndexOf("/"); | |
| 401 | - | |
| 402 | - if(pos >=0 ) | |
| 403 | - url = url.substring(pos+1); | |
| 404 | - | |
| 405 | - Log.i(TAG,"Loading [" + url + "]"); | |
| 406 | - | |
| 407 | - if(url.equalsIgnoreCase("jsmain.js")) | |
| 408 | - { | |
| 409 | - id = R.raw.jsmain; | |
| 410 | - } | |
| 411 | - else if(url.equalsIgnoreCase("theme.css")) | |
| 412 | - { | |
| 413 | - mime = "text/css"; | |
| 414 | - id = R.raw.theme; | |
| 415 | - } | |
| 416 | - | |
| 417 | - // http://developer.android.com/reference/android/webkit/WebResourceResponse.html | |
| 418 | - return new WebResourceResponse(mime,"utf-8",mainact.getResources().openRawResource(id)); | |
| 419 | - } | |
| 420 | - | |
| 421 | - }); | |
| 422 | - | |
| 423 | 392 | return view; |
| 424 | 393 | |
| 425 | 394 | } |
| 426 | 395 | |
| 396 | + public abstract String getProgramMessageText(int id); | |
| 397 | + /* | |
| 398 | + { | |
| 399 | + return "Message " + Integer.toString(id); | |
| 400 | + } | |
| 401 | + */ | |
| 402 | + | |
| 427 | 403 | /*---[ Signal methods ]--------------------------------------------------*/ |
| 428 | 404 | |
| 429 | 405 | protected void showProgramMessage(int id) |
| ... | ... | @@ -464,14 +440,7 @@ public class lib3270 |
| 464 | 440 | // 14 LIB3270_MESSAGE_CONNECTING |
| 465 | 441 | |
| 466 | 442 | default: |
| 467 | - String message[] = res.getStringArray(R.array.program_msg); | |
| 468 | - try | |
| 469 | - { | |
| 470 | - dlgSysMessage.setMessage(message[id]); | |
| 471 | - } catch(Exception e) | |
| 472 | - { | |
| 473 | - dlgSysMessage.setMessage(e.getLocalizedMessage()); | |
| 474 | - } | |
| 443 | + dlgSysMessage.setMessage(getProgramMessageText(id)); | |
| 475 | 444 | dlgSysMessage.show(); |
| 476 | 445 | } |
| 477 | 446 | } | ... | ... |