From 0a21608515296101b4669c0407a77c03c5414cdb Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 11 Jul 2012 13:55:12 +0000 Subject: [PATCH] Android - Implementando container webkit para tela do terminal --- android/res/layout/main.xml | 6 ------ android/res/raw/index.html | 41 +++++++++++++++++++++++++++++++++++++++++ android/res/raw/jsmain.js | 0 android/res/raw/theme.css | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ android/res/values/strings.xml | 4 +--- android/src/br/com/bb/pw3270/PW3270Activity.java | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- 6 files changed, 183 insertions(+), 26 deletions(-) create mode 100644 android/res/raw/index.html create mode 100644 android/res/raw/jsmain.js create mode 100644 android/res/raw/theme.css diff --git a/android/res/layout/main.xml b/android/res/layout/main.xml index 4e27c84..c3ee337 100644 --- a/android/res/layout/main.xml +++ b/android/res/layout/main.xml @@ -23,12 +23,6 @@ android:text="@string/connect" /> - - + + + + + + pw3270 + + + +
+ +   COEM7010       SISBB - Sistema de Informacoes Banco do Brasil       06/07/2012
+   C1103788
                     Correio Eletronico                       15:29:03
+   ----------------------- Indicadores - Ler Matéria ------------------ Pag.:   1
+   Período:
a (Alteravel)   Parte título:
+  
+
  Assunto:(+)
+   Nr.  Título                                                        Data   Hora
+   ---- ------------------------------------------------------------- -----------
+      1
 Rentabilidade fundos BB                                       06/07 00:00
+
     2 Rentabilidade comparada fundos BB                             06/07 00:00
+
     3 Indices Economicos                                            06/07 00:00
+
     4 ACF - ADIANTAMENTO DE CONTRATO DE FORNECIMENTO - 06-07-2012   06/07 00:00
+      5 CDF - CRÉDITO DIRETO AO FORNECEDOR - 06-07-2012               06/07 00:00
+      6 Depositos a Prazo - Taxas Pos Fixadas                         06/07 00:00
+      7 Depositos a Prazo - Entes Publicos - Taxas Negociadas         06/07 00:00
+      8 Depositos a Prazo - Taxas não Negociadas                      06/07 00:00
+      9 Depositos a Prazo - Nivel 2 - Taxas Negociadas                06/07 00:00
+     10 Depositos a Prazo - Nivel 1 - Taxas Negociadas                06/07 00:00
+     11 Depositos a Prazo - Taxas não Negociadas - BB CDB DI PARCERIA 06/07 00:00
+     12 Inadimplemento - Comissão de Permanência - 06/07/2012         06/07 00:00
+   Informe número (Nr.):

+
  ------------------------------------------------------------------------------
+
  F1 Ajuda F9 Origem
+
 SaiSeleciona(+)EncerraImprimePag.AntProx.Pag
+
+ +
+ + diff --git a/android/res/raw/jsmain.js b/android/res/raw/jsmain.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/android/res/raw/jsmain.js diff --git a/android/res/raw/theme.css b/android/res/raw/theme.css new file mode 100644 index 0000000..f8069f3 --- /dev/null +++ b/android/res/raw/theme.css @@ -0,0 +1,57 @@ + +body +{ + background-color: black; +} + +body, input +{ + font-family: courier; + font-size: 20px; +} + +#terminal +{ + width: 49em; +} + +input +{ + border: none; + padding: 0px; + background-color: black; + color: #00ff00; + margin-left: 0.5em; + margin-right: 0.5em; +} + +input[type="text"] +{ + border: 1px solid #004000 +} + +.IW002 +{ + width: 1.5em; +} + +.IW008 +{ + width: 5em; +} + +.IW004 +{ + width: 2.5em; +} + +.IW020 +{ + width: 12em; +} + +.IW040 +{ + width: 24em; +} + diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index e24868d..fc674bc 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -1,7 +1,5 @@ - - Welcome to pw3270 PW3270 LIB3270_MESSAGE_NONE @@ -20,7 +18,7 @@ X Resolvendo X Conectando - Connect + Connect \ No newline at end of file diff --git a/android/src/br/com/bb/pw3270/PW3270Activity.java b/android/src/br/com/bb/pw3270/PW3270Activity.java index fbe7783..51c22fd 100644 --- a/android/src/br/com/bb/pw3270/PW3270Activity.java +++ b/android/src/br/com/bb/pw3270/PW3270Activity.java @@ -2,37 +2,46 @@ package br.com.bb.pw3270; import android.app.Activity; import android.os.Bundle; -import android.widget.TextView; -import android.widget.Button; -import android.widget.EditText; +// import android.widget.TextView; +// import android.widget.Button; +// import android.widget.EditText; import android.util.Log; -import android.view.View; +// import android.view.View; import android.content.res.*; import android.app.AlertDialog; import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.webkit.WebResourceResponse; +import android.webkit.WebChromeClient; +import java.io.InputStream; + // import android.app.Dialog; -public class PW3270Activity extends Activity implements View.OnClickListener +public class PW3270Activity extends Activity { + private Resources res; + private WebView view; + private terminal host; + private static final String TAG = "pw3270"; + private class terminal extends lib3270 { - private static final String TAG = "pw3270"; - TextView msgbox; Activity Main; - terminal(TextView msgbox, Activity Main) + terminal(Activity Main) { - this.msgbox = msgbox; this.Main = Main; } protected void updateProgramMessage(int id) { + /* try { - this.msgbox.setText(message[id]); + // this.msgbox.setText(message[id]); } catch(Exception e) { this.msgbox.setText("Estado inesperado"); } + */ } protected void popupMessage(int type, String title, String text, String info) @@ -51,29 +60,85 @@ public class PW3270Activity extends Activity implements View.OnClickListener try { String text = new String(getText(),getEncoding()); - Log.i(TAG,text); +// Log.i(TAG,text); } catch(Exception e) { } } }; - + + /* private terminal host; private EditText uri; private Resources res; private String[] message; private WebView view; +*/ + + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - Log.i("pw3270","Activity started"); + + res = getResources(); + + // Reference: + // http://developer.android.com/reference/android/webkit/WebView.html + view = new WebView(this); + + view.setWebChromeClient(new WebChromeClient()); + + view.setWebViewClient(new WebViewClient() + { + + @Override + public WebResourceResponse shouldInterceptRequest(WebView view, String url) + { + int id = R.raw.index; + String mime = "text/html"; + + Log.i(TAG,"Loading [" + url + "]"); + + if(url.equalsIgnoreCase("file://jsmain.js")) + { + id = R.raw.jsmain; + } + else if(url.equalsIgnoreCase("file://theme.css")) + { + mime = "text/css"; + id = R.raw.theme; + } - res = getResources(); + + // http://developer.android.com/reference/android/webkit/WebResourceResponse.html + return new WebResourceResponse(mime,"utf-8",getResources().openRawResource(id)); + } + + }); + + view.getSettings().setJavaScriptEnabled(true); + + setContentView(view); + view.loadUrl("file://index.html"); + + // setContentView(R.layout.main); + +// Log.i("pw3270","Activity started"); + + +// view = (WebView) findViewById(R.id.view); + +// String summary = "Welcome to pw3270." ; + + // res.getString(R.string.hello); + + // ; + // view.loadData("Welcome to pw3270.", "text/html", null); + + /* message = res.getStringArray(R.array.program_msg); uri = (EditText) findViewById(R.id.hostname); @@ -83,14 +148,16 @@ public class PW3270Activity extends Activity implements View.OnClickListener host = new terminal((TextView) findViewById(R.id.msgbox),this); - + */ } + /* public void onClick(View v) { // Perform action on click // host.setHost(uri.getText().toString()); host.connect(); } + */ } \ No newline at end of file -- libgit2 0.21.2