Commit 0a21608515296101b4669c0407a77c03c5414cdb
1 parent
d9c9f52e
Exists in
master
and in
5 other branches
Android - Implementando container webkit para tela do terminal
Showing
6 changed files
with
183 additions
and
26 deletions
Show diff stats
android/res/layout/main.xml
| @@ -23,12 +23,6 @@ | @@ -23,12 +23,6 @@ | ||
| 23 | android:text="@string/connect" /> | 23 | android:text="@string/connect" /> |
| 24 | 24 | ||
| 25 | </LinearLayout> | 25 | </LinearLayout> |
| 26 | - | ||
| 27 | - <TextView | ||
| 28 | - android:id="@+id/msgbox" | ||
| 29 | - android:layout_width="fill_parent" | ||
| 30 | - android:layout_height="wrap_content" | ||
| 31 | - android:text="@string/hello" /> | ||
| 32 | 26 | ||
| 33 | <WebView | 27 | <WebView |
| 34 | android:id="@+id/view" | 28 | android:id="@+id/view" |
| @@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br" > | ||
| 3 | +<head> | ||
| 4 | + <meta http-equiv="content-type" content="text/html;charset=utf-8"/> | ||
| 5 | + <meta name="author" content="Perry Werneck, perry@werneck.eti.br"> | ||
| 6 | + <link rel="stylesheet" type="text/css" href="file:theme.css" /> | ||
| 7 | + <title>pw3270</title> | ||
| 8 | +</head> | ||
| 9 | + | ||
| 10 | +<body> | ||
| 11 | +<div id="terminal"> | ||
| 12 | + | ||
| 13 | + <span style="color:green;background-color:black"> </span><span style="color:deepSkyBlue;background-color:black"> COEM7010 SISBB - Sistema de Informacoes Banco do Brasil 06/07/2012<br /> | ||
| 14 | + C1103788</span><span style="color:green;background-color:black"> </span><span style="color:white;background-color:black"> Correio Eletronico </span><span style="color:green;background-color:black"> </span><span style="color:deepSkyBlue;background-color:black">15:29:03<br /> | ||
| 15 | + ----------------------- Indicadores - Ler Matéria ------------------ Pag.: 1<br /> | ||
| 16 | + Período:</span><span style="color:green;background-color:black"><input type="text" name="F0251" value="05072012" maxlength="8" class="IW008"></input></span><span style="color:deepSkyBlue;background-color:black">a</span><span style="color:green;background-color:black"><input type="text" name="F0262" value="06072012" maxlength="8" class="IW008"></input> </span><span style="color:white;background-color:black">(Alteravel)</span><span style="color:green;background-color:black"> </span><span style="color:deepSkyBlue;background-color:black"> Parte título:</span><span style="color:green;background-color:black"><input type="text" name="F0300" maxlength="20" class="IW020"></input><br /> | ||
| 17 | + <br /> | ||
| 18 | + </span><span style="color:deepSkyBlue;background-color:black"> Assunto:</span><span style="color:green;background-color:black"><input type="text" name="F0411" maxlength="40" class="IW040"></input></span><span style="color:deepSkyBlue;background-color:black">(+)<br /> | ||
| 19 | + Nr. Título Data Hora<br /> | ||
| 20 | + ---- ------------------------------------------------------------- -----------<br /> | ||
| 21 | + 1</span><span style="color:green;background-color:black"> </span><span style="color:white;background-color:black">Rentabilidade fundos BB 06/07 00:00<br /> | ||
| 22 | + </span><span style="color:green;background-color:black"> </span><span style="color:deepSkyBlue;background-color:black"> 2</span><span style="color:green;background-color:black"> </span><span style="color:white;background-color:black">Rentabilidade comparada fundos BB 06/07 00:00<br /> | ||
| 23 | + </span><span style="color:green;background-color:black"> </span><span style="color:deepSkyBlue;background-color:black"> 3</span><span style="color:green;background-color:black"> </span><span style="color:white;background-color:black">Indices Economicos 06/07 00:00<br /> | ||
| 24 | + </span><span style="color:green;background-color:black"> </span><span style="color:deepSkyBlue;background-color:black"> 4 ACF - ADIANTAMENTO DE CONTRATO DE FORNECIMENTO - 06-07-2012 06/07 00:00<br /> | ||
| 25 | + 5 CDF - CRÉDITO DIRETO AO FORNECEDOR - 06-07-2012 06/07 00:00<br /> | ||
| 26 | + 6 Depositos a Prazo - Taxas Pos Fixadas 06/07 00:00<br /> | ||
| 27 | + 7 Depositos a Prazo - Entes Publicos - Taxas Negociadas 06/07 00:00<br /> | ||
| 28 | + 8 Depositos a Prazo - Taxas não Negociadas 06/07 00:00<br /> | ||
| 29 | + 9 Depositos a Prazo - Nivel 2 - Taxas Negociadas 06/07 00:00<br /> | ||
| 30 | + 10 Depositos a Prazo - Nivel 1 - Taxas Negociadas 06/07 00:00<br /> | ||
| 31 | + 11 Depositos a Prazo - Taxas não Negociadas - BB CDB DI PARCERIA 06/07 00:00<br /> | ||
| 32 | + 12 Inadimplemento - Comissão de Permanência - 06/07/2012 06/07 00:00<br /> | ||
| 33 | + Informe número (Nr.):</span><span style="color:green;background-color:black"><input type="text" name="F1624" maxlength="4" class="IW004"></input><br /> | ||
| 34 | + </span><span style="color:deepSkyBlue;background-color:black"> ------------------------------------------------------------------------------<br /> | ||
| 35 | + </span><span style="color:green;background-color:black"> </span><span style="color:white;background-color:black"> F1 Ajuda F9 Origem<br /> | ||
| 36 | + </span><span style="color:green;background-color:black"> <input type="button" name="PF03" value="F3" maxlength="2" class="IW002"></input></span><span style="color:deepSkyBlue;background-color:black">Sai</span><span style="color:green;background-color:black"><input type="button" name="PF04" value="F4" maxlength="2" class="IW002"></input></span><span style="color:deepSkyBlue;background-color:black">Seleciona(+)</span><span style="color:green;background-color:black"><input type="button" name="PF05" value="F5" maxlength="2" class="IW002"></input></span><span style="color:deepSkyBlue;background-color:black">Encerra</span><span style="color:green;background-color:black"><input type="button" name="PF06" value="F6" maxlength="2" class="IW002"></input></span><span style="color:deepSkyBlue;background-color:black">Imprime</span><span style="color:green;background-color:black"><input type="button" name="PF07" value="F7" maxlength="2" class="IW002"></input></span><span style="color:deepSkyBlue;background-color:black">Pag.Ant</span><span style="color:green;background-color:black"><input type="button" name="PF08" value="F8" maxlength="2" class="IW002"></input></span><span style="color:deepSkyBlue;background-color:black">Prox.Pag<br /> | ||
| 37 | + </span> | ||
| 38 | + | ||
| 39 | +</div> | ||
| 40 | +</body> | ||
| 41 | +</html> |
| @@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
| 1 | + | ||
| 2 | +body | ||
| 3 | +{ | ||
| 4 | + background-color: black; | ||
| 5 | +} | ||
| 6 | + | ||
| 7 | +body, input | ||
| 8 | +{ | ||
| 9 | + font-family: courier; | ||
| 10 | + font-size: 20px; | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +#terminal | ||
| 14 | +{ | ||
| 15 | + width: 49em; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +input | ||
| 19 | +{ | ||
| 20 | + border: none; | ||
| 21 | + padding: 0px; | ||
| 22 | + background-color: black; | ||
| 23 | + color: #00ff00; | ||
| 24 | + margin-left: 0.5em; | ||
| 25 | + margin-right: 0.5em; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +input[type="text"] | ||
| 29 | +{ | ||
| 30 | + border: 1px solid #004000 | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +.IW002 | ||
| 34 | +{ | ||
| 35 | + width: 1.5em; | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +.IW008 | ||
| 39 | +{ | ||
| 40 | + width: 5em; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +.IW004 | ||
| 44 | +{ | ||
| 45 | + width: 2.5em; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +.IW020 | ||
| 49 | +{ | ||
| 50 | + width: 12em; | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +.IW040 | ||
| 54 | +{ | ||
| 55 | + width: 24em; | ||
| 56 | +} | ||
| 57 | + |
android/res/values/strings.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <resources> | 2 | <resources> |
| 3 | - | ||
| 4 | - <string name="hello">Welcome to pw3270</string> | ||
| 5 | <string name="app_name">PW3270</string> | 3 | <string name="app_name">PW3270</string> |
| 6 | <string-array name="program_msg"> | 4 | <string-array name="program_msg"> |
| 7 | <item>LIB3270_MESSAGE_NONE</item> | 5 | <item>LIB3270_MESSAGE_NONE</item> |
| @@ -20,7 +18,7 @@ | @@ -20,7 +18,7 @@ | ||
| 20 | <item>X Resolvendo</item> | 18 | <item>X Resolvendo</item> |
| 21 | <item>X Conectando</item> | 19 | <item>X Conectando</item> |
| 22 | </string-array> | 20 | </string-array> |
| 23 | - <string name="connect">Connect</string> | 21 | + <string name="connect">Connect</string> |
| 24 | 22 | ||
| 25 | 23 | ||
| 26 | </resources> | 24 | </resources> |
| 27 | \ No newline at end of file | 25 | \ No newline at end of file |
android/src/br/com/bb/pw3270/PW3270Activity.java
| @@ -2,37 +2,46 @@ package br.com.bb.pw3270; | @@ -2,37 +2,46 @@ package br.com.bb.pw3270; | ||
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | -import android.widget.TextView; | ||
| 6 | -import android.widget.Button; | ||
| 7 | -import android.widget.EditText; | 5 | +// import android.widget.TextView; |
| 6 | +// import android.widget.Button; | ||
| 7 | +// import android.widget.EditText; | ||
| 8 | import android.util.Log; | 8 | import android.util.Log; |
| 9 | -import android.view.View; | 9 | +// import android.view.View; |
| 10 | import android.content.res.*; | 10 | import android.content.res.*; |
| 11 | import android.app.AlertDialog; | 11 | import android.app.AlertDialog; |
| 12 | import android.webkit.WebView; | 12 | import android.webkit.WebView; |
| 13 | +import android.webkit.WebViewClient; | ||
| 14 | +import android.webkit.WebResourceResponse; | ||
| 15 | +import android.webkit.WebChromeClient; | ||
| 16 | +import java.io.InputStream; | ||
| 17 | + | ||
| 13 | // import android.app.Dialog; | 18 | // import android.app.Dialog; |
| 14 | 19 | ||
| 15 | -public class PW3270Activity extends Activity implements View.OnClickListener | 20 | +public class PW3270Activity extends Activity |
| 16 | { | 21 | { |
| 22 | + private Resources res; | ||
| 23 | + private WebView view; | ||
| 24 | + private terminal host; | ||
| 25 | + private static final String TAG = "pw3270"; | ||
| 26 | + | ||
| 17 | private class terminal extends lib3270 | 27 | private class terminal extends lib3270 |
| 18 | { | 28 | { |
| 19 | - private static final String TAG = "pw3270"; | ||
| 20 | 29 | ||
| 21 | - TextView msgbox; | ||
| 22 | Activity Main; | 30 | Activity Main; |
| 23 | 31 | ||
| 24 | - terminal(TextView msgbox, Activity Main) | 32 | + terminal(Activity Main) |
| 25 | { | 33 | { |
| 26 | - this.msgbox = msgbox; | ||
| 27 | this.Main = Main; | 34 | this.Main = Main; |
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | protected void updateProgramMessage(int id) | 37 | protected void updateProgramMessage(int id) |
| 31 | { | 38 | { |
| 39 | + /* | ||
| 32 | try | 40 | try |
| 33 | { | 41 | { |
| 34 | - this.msgbox.setText(message[id]); | 42 | + // this.msgbox.setText(message[id]); |
| 35 | } catch(Exception e) { this.msgbox.setText("Estado inesperado"); } | 43 | } catch(Exception e) { this.msgbox.setText("Estado inesperado"); } |
| 44 | + */ | ||
| 36 | } | 45 | } |
| 37 | 46 | ||
| 38 | protected void popupMessage(int type, String title, String text, String info) | 47 | protected void popupMessage(int type, String title, String text, String info) |
| @@ -51,29 +60,85 @@ public class PW3270Activity extends Activity implements View.OnClickListener | @@ -51,29 +60,85 @@ public class PW3270Activity extends Activity implements View.OnClickListener | ||
| 51 | try | 60 | try |
| 52 | { | 61 | { |
| 53 | String text = new String(getText(),getEncoding()); | 62 | String text = new String(getText(),getEncoding()); |
| 54 | - Log.i(TAG,text); | 63 | +// Log.i(TAG,text); |
| 55 | } catch(Exception e) { } | 64 | } catch(Exception e) { } |
| 56 | } | 65 | } |
| 57 | 66 | ||
| 58 | 67 | ||
| 59 | }; | 68 | }; |
| 60 | - | 69 | + |
| 70 | + /* | ||
| 61 | private terminal host; | 71 | private terminal host; |
| 62 | private EditText uri; | 72 | private EditText uri; |
| 63 | private Resources res; | 73 | private Resources res; |
| 64 | private String[] message; | 74 | private String[] message; |
| 65 | private WebView view; | 75 | private WebView view; |
| 66 | 76 | ||
| 77 | +*/ | ||
| 78 | + | ||
| 79 | + | ||
| 67 | /** Called when the activity is first created. */ | 80 | /** Called when the activity is first created. */ |
| 68 | @Override | 81 | @Override |
| 69 | public void onCreate(Bundle savedInstanceState) | 82 | public void onCreate(Bundle savedInstanceState) |
| 70 | { | 83 | { |
| 71 | super.onCreate(savedInstanceState); | 84 | super.onCreate(savedInstanceState); |
| 72 | - setContentView(R.layout.main); | ||
| 73 | - | ||
| 74 | - Log.i("pw3270","Activity started"); | 85 | + |
| 86 | + res = getResources(); | ||
| 87 | + | ||
| 88 | + // Reference: | ||
| 89 | + // http://developer.android.com/reference/android/webkit/WebView.html | ||
| 90 | + view = new WebView(this); | ||
| 91 | + | ||
| 92 | + view.setWebChromeClient(new WebChromeClient()); | ||
| 93 | + | ||
| 94 | + view.setWebViewClient(new WebViewClient() | ||
| 95 | + { | ||
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public WebResourceResponse shouldInterceptRequest(WebView view, String url) | ||
| 99 | + { | ||
| 100 | + int id = R.raw.index; | ||
| 101 | + String mime = "text/html"; | ||
| 102 | + | ||
| 103 | + Log.i(TAG,"Loading [" + url + "]"); | ||
| 104 | + | ||
| 105 | + if(url.equalsIgnoreCase("file://jsmain.js")) | ||
| 106 | + { | ||
| 107 | + id = R.raw.jsmain; | ||
| 108 | + } | ||
| 109 | + else if(url.equalsIgnoreCase("file://theme.css")) | ||
| 110 | + { | ||
| 111 | + mime = "text/css"; | ||
| 112 | + id = R.raw.theme; | ||
| 113 | + } | ||
| 75 | 114 | ||
| 76 | - res = getResources(); | 115 | + |
| 116 | + // http://developer.android.com/reference/android/webkit/WebResourceResponse.html | ||
| 117 | + return new WebResourceResponse(mime,"utf-8",getResources().openRawResource(id)); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + }); | ||
| 121 | + | ||
| 122 | + view.getSettings().setJavaScriptEnabled(true); | ||
| 123 | + | ||
| 124 | + setContentView(view); | ||
| 125 | + view.loadUrl("file://index.html"); | ||
| 126 | + | ||
| 127 | + // setContentView(R.layout.main); | ||
| 128 | + | ||
| 129 | +// Log.i("pw3270","Activity started"); | ||
| 130 | + | ||
| 131 | + | ||
| 132 | +// view = (WebView) findViewById(R.id.view); | ||
| 133 | + | ||
| 134 | +// String summary = "<html><body>Welcome to <b>pw3270</b>.</body></html>" ; | ||
| 135 | + | ||
| 136 | + // res.getString(R.string.hello); | ||
| 137 | + | ||
| 138 | + // ; | ||
| 139 | + // view.loadData("<html><body>Welcome to <b>pw3270</b>.</body></html>", "text/html", null); | ||
| 140 | + | ||
| 141 | + /* | ||
| 77 | message = res.getStringArray(R.array.program_msg); | 142 | message = res.getStringArray(R.array.program_msg); |
| 78 | uri = (EditText) findViewById(R.id.hostname); | 143 | uri = (EditText) findViewById(R.id.hostname); |
| 79 | 144 | ||
| @@ -83,14 +148,16 @@ public class PW3270Activity extends Activity implements View.OnClickListener | @@ -83,14 +148,16 @@ public class PW3270Activity extends Activity implements View.OnClickListener | ||
| 83 | 148 | ||
| 84 | host = new terminal((TextView) findViewById(R.id.msgbox),this); | 149 | host = new terminal((TextView) findViewById(R.id.msgbox),this); |
| 85 | 150 | ||
| 86 | - | 151 | + */ |
| 87 | } | 152 | } |
| 88 | 153 | ||
| 154 | + /* | ||
| 89 | public void onClick(View v) | 155 | public void onClick(View v) |
| 90 | { | 156 | { |
| 91 | // Perform action on click | 157 | // Perform action on click |
| 92 | // host.setHost(uri.getText().toString()); | 158 | // host.setHost(uri.getText().toString()); |
| 93 | host.connect(); | 159 | host.connect(); |
| 94 | } | 160 | } |
| 161 | + */ | ||
| 95 | 162 | ||
| 96 | } | 163 | } |
| 97 | \ No newline at end of file | 164 | \ No newline at end of file |