Commit f33fd8a4 by Tuukka Kivilahti

moar of bacroce

1 parent cfaf2f9f
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
android:targetSdkVersion="10" /> android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fi.codecrew.androidbarcode"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="fi.codecrew.androidbarcode.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
# cache for current jar dependency. DO NOT EDIT.
# format is <lastModified> <length> <SHA-1> <path>
# Encoding is UTF-8
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" > tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/readBarcode"
android:onClick="readBarcode"
/>
<TextView <TextView
android:id="@+id/textView1" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:text="@string/readedCode" android:text="@string/readedCode"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText <EditText
android:id="@+id/readedCode" android:id="@+id/readedCode"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:ems="10" android:ems="10"
android:focusable="false" android:focusable="true"
android:focusableInTouchMode="false" android:focusableInTouchMode="true"
android:inputType="text" /> android:inputType="text" />
<TextView <TextView
android:id="@+id/textView2" android:id="@+id/success_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/readedCode" android:text="@string/success"
android:layout_below="@+id/readedCode" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="71dp" android:textColor="#00AA00" />
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:text="@string/readerName" android:text="@string/readerName"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:id="@+id/textView3" android:id="@+id/textView3"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:text="@string/seenInMoya" android:text="@string/seenInMoya"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText <EditText
android:id="@+id/readerName" android:id="@+id/readerName"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="14dp"
android:ems="10" android:ems="10"
android:inputType="text" > android:inputType="text" >
<requestFocus />
</EditText> </EditText>
</RelativeLayout> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/change"
android:onClick="changeReaderName"
/>
</LinearLayout>
</ScrollView>
...@@ -9,5 +9,7 @@ ...@@ -9,5 +9,7 @@
<string name="readerName">Reader Name</string> <string name="readerName">Reader Name</string>
<string name="seenInMoya">(as seen in Moya)</string> <string name="seenInMoya">(as seen in Moya)</string>
<string name="shared_pref_readername">readername</string> <string name="shared_pref_readername">readername</string>
<string name="change">Change</string>
<string name="success">Success</string>
</resources> </resources>
...@@ -13,10 +13,12 @@ import android.content.SharedPreferences; ...@@ -13,10 +13,12 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity { public class MainActivity extends Activity {
private static String URL = "http://demo.codecrew.fi/MoyaWeb/"; private static String URL = "http://demo.codecrew.fi/MoyaWeb/shop/rfidListener.jsf";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -24,9 +26,14 @@ public class MainActivity extends Activity { ...@@ -24,9 +26,14 @@ public class MainActivity extends Activity {
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
EditText readedCode = (EditText) findViewById(R.id.readedCode);
readedCode.requestFocus();
EditText readerName = (EditText) findViewById(R.id.readerName); EditText readerName = (EditText) findViewById(R.id.readerName);
readerName.setText(getReaderName()); readerName.setText(getReaderName());
TextView successText = (TextView) findViewById(R.id.success_text);
successText.setVisibility(View.INVISIBLE);
} }
...@@ -38,7 +45,8 @@ public class MainActivity extends Activity { ...@@ -38,7 +45,8 @@ public class MainActivity extends Activity {
} }
public void readBarcode(View view) { public void readBarcode(View view) {
TextView successText = (TextView) findViewById(R.id.success_text);
successText.setVisibility(View.INVISIBLE);
Intent intent = new Intent("com.google.zxing.client.android.SCAN"); Intent intent = new Intent("com.google.zxing.client.android.SCAN");
// intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", // intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE",
// "QR_CODE_MODE"); // "QR_CODE_MODE");
...@@ -57,6 +65,9 @@ public class MainActivity extends Activity { ...@@ -57,6 +65,9 @@ public class MainActivity extends Activity {
editor.putString(getString(R.string.shared_pref_readername), readerName.getText().toString()); editor.putString(getString(R.string.shared_pref_readername), readerName.getText().toString());
editor.commit(); editor.commit();
readerName.clearFocus();
EditText readedCode = (EditText) findViewById(R.id.readedCode);
readedCode.requestFocus();
} }
private String getReaderName() { private String getReaderName() {
...@@ -67,15 +78,24 @@ public class MainActivity extends Activity { ...@@ -67,15 +78,24 @@ public class MainActivity extends Activity {
public void onActivityResult(int requestCode, int resultCode, Intent intent) { public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) { if (requestCode == 0) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT"); String contents = intent.getStringExtra("SCAN_RESULT");
EditText readedCode = (EditText) findViewById(R.id.readedCode); EditText readedCode = (EditText) findViewById(R.id.readedCode);
readedCode.requestFocus();
readedCode.setText(contents); readedCode.setText(contents);
TextView successText = (TextView) findViewById(R.id.success_text);
if(sendBarcode(contents)) { if(sendBarcode(contents)) {
successText.setVisibility(View.VISIBLE);
} }
Button readBcode = (Button) findViewById(R.id.button1);
readBcode.requestFocus();
} else if (resultCode == RESULT_CANCELED) { } else if (resultCode == RESULT_CANCELED) {
...@@ -86,9 +106,9 @@ public class MainActivity extends Activity { ...@@ -86,9 +106,9 @@ public class MainActivity extends Activity {
private boolean sendBarcode(String barcode) { private boolean sendBarcode(String barcode) {
try { try {
HttpClient client = new DefaultHttpClient(); HttpClient client = new DefaultHttpClient();
String getUrl = this.URL + "?barcode="+barcode+"&reader="+getReaderName(); String getUrl = URL + "?tag="+barcode+"&reader="+getReaderName();
HttpGet get = new HttpGet(getURL); HttpGet get = new HttpGet(getUrl);
HttpResponse responseGet = client.execute(get); HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity(); HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) { if (resEntityGet != null) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!