Days searching and found no solution.
I'm not a programmer but I'm trying to create a android application that does a search only using a barcode reader.
An app that replaces those expensive check price machines. Just use a tablet and a barcode scanner, copy the file generated by the stock software (usually a plain text file with txt extension) into a microSD card (not sure if I can send the file directly to the card via network).
This is the html page with javascript code (quite wrong and horrible but working as well).
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="refresh" content="10">
<title>CONSULTA DE PREÇO</title>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="timestamp">
<script language="JavaScript" type="text/javascript">
var TRange = null;
function Procurar(str) {
if (parseInt(navigator.appVersion) < 4) return;
var Resultado;
if (window.find) {
Resultado=self.find(str);
if (Resultado && self.getSelection && !self.getSelection().anchorNode) {
Resultado=self.find(str)
}
if (!Resultado) {
Resultado=self.find(str,0,1)
while (self.find(str,0,1)) continue
}
}
else if (navigator.appName.indexOf("Microsoft")!=-1) {
if (TRange!=null) {
TRange.collapse(false)
Resultado=TRange.findText(str)
if (Resultado) TRange.select()
}
if (TRange==null || Resultado==0) {
TRange=self.document.body.createTextRange()
Resultado=TRange.findText(str)
if (Resultado) TRange.select()
}
}
if (!Resultado) alert ("PRODUTO SEM CADASTRO - PROCURE O VENDEDOR")
return;
}
</script>
<style type="text/css">
body {
background-color:blue;
font-family:sans-serif;
overflow-y: hidden
}
body,div,form,.campo {
margin:0;
padding:0;
border:0
}
*:focus {outline: none;}
.cabeca, .barra {
background-color:blue;
color:white;
text-align:center
}
.resultado,#busca,.botao,.campo {
background-color:yellow
}
#busca,.botao {
color:yellow;border:0
}
.campo {
margin-left:5px;
overflow: hidden;
font-weight:bold;
font-size:15px;
font-family:monospace;
color:#000000;
text-transform:uppercase
}
h1 {
font-size: 40px
}
h5 {
font-size: 15px
}
h6 {
font-size: 13px
}
</style>
</head>
<body onload="document.getElementById('busca').focus();">
<div class="cabeca">
<br>
<h1><i>BUSCA PREÇO</i></h1>
<h5><marquee behavior="alternate">PASSE O CÓDIGO DE BARRAS DO PRODUTO SOB O FEIXE DE LUZ</marquee></h5>
</div>
<div class="resultado">
<form id="f1" action="" onsubmit="if(this.t1.value!=null && this.t1.value!='') Procurar(this.t1.value);return false" name="f1"><input type="text" id="busca" name="t1" value="" size="20"> <input class="botao" type="submit" name="b1" value="Q"></form>
<form action="">
<textarea class="campo" name="mytextarea" cols="87" rows="3" readonly>
<!-- TXT CONTENT HERE -->
</textarea></form>
<br>
</div>
<div class="barra">
<h6>AGUARDE A CONSULTA ANTERIOR APAGAR ANTES DE REALIZAR OUTRA</h6>
</div>
</body>
</html>
This is my java:
package br.com.strabelli.qc.quantocusta;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Tela extends Activity {
WebView mwebview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tela);
mwebview = (WebView) findViewById(R.id.webview);
mwebview.loadUrl("file:///android_asset/index.html");
WebSettings webSettings = mwebview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(false);
mwebview.setWebViewClient(new WebViewClient());
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mwebview.canGoBack()) {
mwebview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
The html file is correctly located in the asset directory, the application is running and the search works, but the problem is that I need to inject the contents of the txt file (which should be located in sdcard) inside the tag.
The content of txt is like this
1000177935227|Figuras de Ontem e de Hoje|39,00| 1000177935333|Poeira Dourada|40,00| 1000177935371|Rui - Pequena Historia de Uma Grande Vida|15,00| 9788575183755|Dicionario Barsa da Lingua Portuguesa|60,00| 9788571644694|Uma Historia da Guerra|17,00|
I tried iframe and object but the search does not work inside this tags. I tried to find some solution with javascript but did not get anywhere.
It would be possible to generate the webview in pieces? Kind like this: html (...)textarea + terminal.txt + /textarea (...) /html
Thanks for any help, sorry my bad english.
0 comments:
Post a Comment