-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b37b49b
Showing
33 changed files
with
688 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Android Barcode Scanner | ||
======================= | ||
|
||
This project shows how to make use on the ZXing library to read barcodes on an Android device. | ||
|
||
It is recommended that you use Android Studio 0.4.2 or above when building the project. | ||
|
||
Note that a physical device is required to use the barcode scanner, the emulator is not sufficient. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apply plugin: 'android' | ||
|
||
android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "19.0.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 8 | ||
targetSdkVersion 19 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
runProguard false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:+' | ||
|
||
compile 'com.google.code.gson:gson:2.2.4' | ||
compile 'com.google.zxing:zxing-parent:2.3.0' | ||
compile 'com.google.zxing:android-integration:2.3.0' | ||
compile 'com.google.zxing:core:2.3.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.singingbush.barcodescanner" > | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
|
||
<activity | ||
android:name="com.singingbush.barcodescanner.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> | ||
|
||
<activity | ||
android:name=".AboutActivity" | ||
android:label="@string/about_title" | ||
android:theme="@android:style/Theme.Dialog" | ||
android:screenOrientation="portrait" /> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
barcodescanner/src/main/java/com/singingbush/barcodescanner/AboutActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.singingbush.barcodescanner; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
|
||
/** | ||
* Created by samael on 12/01/14. | ||
*/ | ||
public class AboutActivity extends Activity { | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.about); | ||
} | ||
|
||
} |
127 changes: 127 additions & 0 deletions
127
barcodescanner/src/main/java/com/singingbush/barcodescanner/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package com.singingbush.barcodescanner; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.support.v7.app.ActionBar; | ||
import android.support.v4.app.Fragment; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
|
||
import com.google.zxing.integration.android.IntentIntegrator; | ||
import com.google.zxing.integration.android.IntentResult; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
public class MainActivity extends ActionBarActivity { | ||
|
||
private static final String TAG = MainActivity.class.getSimpleName(); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
Log.v(TAG, "starting " + TAG); | ||
|
||
setContentView(R.layout.activity_main); | ||
|
||
if (savedInstanceState == null) { | ||
getSupportFragmentManager().beginTransaction() | ||
.add(R.id.container, new PlaceholderFragment()) | ||
.commit(); | ||
} | ||
|
||
} | ||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
|
||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.main, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
public void onActivityResult(int requestCode, int resultCode, Intent intent) { | ||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); | ||
if (scanResult != null) { | ||
Log.d(TAG, "scan result: " + scanResult); | ||
} else { | ||
Log.d(TAG, "scan result was NULL"); | ||
} | ||
} | ||
|
||
/** | ||
* A placeholder fragment containing a simple view. | ||
*/ | ||
public static class PlaceholderFragment extends Fragment implements View.OnClickListener { | ||
|
||
public PlaceholderFragment() { | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
View rootView = inflater.inflate(R.layout.fragment_main, container, false); | ||
|
||
Button scanButton = (Button)rootView.findViewById(R.id.scan_button); | ||
scanButton.setOnClickListener(this); | ||
|
||
Button aboutButton = (Button)rootView.findViewById(R.id.about_button); | ||
aboutButton.setOnClickListener(this); | ||
|
||
Button exitButton = (Button)rootView.findViewById(R.id.exit_button); | ||
exitButton.setOnClickListener(this); | ||
|
||
return rootView; | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch(view.getId()) { | ||
case R.id.scan_button: | ||
Log.v(TAG, "scan barcode button clicked"); | ||
scanBarcode(); | ||
break; | ||
case R.id.about_button: | ||
Log.v(TAG, "about button clicked"); | ||
Intent intent = new Intent(getActivity(), AboutActivity.class); | ||
getActivity().startActivity(intent); | ||
break; | ||
case R.id.exit_button: | ||
Log.v(TAG, "exit button clicked"); | ||
getActivity().finish(); | ||
break; | ||
} | ||
} | ||
|
||
private void scanBarcode() { | ||
IntentIntegrator integrator = new IntentIntegrator(getActivity()); | ||
// possible barcode types are: | ||
// "UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", | ||
// "CODE_93", "CODE_128", "ITF", "RSS_14", "RSS_EXPANDED" | ||
Collection<String> BARCODE_TYPES = | ||
Collections.unmodifiableCollection(Arrays.asList("UPC_A", "UPC_E", "EAN_8", "EAN_13")); | ||
integrator.initiateScan(BARCODE_TYPES); | ||
} | ||
|
||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
barcodescanner/src/main/res/drawable/beveled_corner_shape.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<solid android:color="@color/White_Transparent" /> | ||
|
||
<stroke | ||
android:width="3dp" | ||
android:color="#ff000000" | ||
/> | ||
|
||
<padding | ||
android:top="5dp" | ||
android:left="4dp" | ||
android:right="4dp" | ||
android:bottom="5dp" | ||
/> | ||
|
||
<corners | ||
android:bottomRightRadius="7dp" | ||
android:bottomLeftRadius="7dp" | ||
android:topLeftRadius="7dp" | ||
android:topRightRadius="7dp" /> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:src="@drawable/wooden_background" | ||
android:tileMode="repeat" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:padding="10dip" > | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/about_text" | ||
android:id="@+id/about_view" | ||
/> | ||
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.singingbush.barcodescanner.MainActivity" | ||
tools:ignore="MergeRootFrame" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
tools:context="com.singingbush.barcodescanner.MainActivity$PlaceholderFragment"> | ||
|
||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/scan_button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="@string/scan_button_label" /> | ||
|
||
<Button | ||
android:id="@+id/about_button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="@string/about_button_label" /> | ||
|
||
<Button | ||
android:id="@+id/exit_button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="@string/exit_button_label" /> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context="com.singingbush.barcodescanner.MainActivity" > | ||
|
||
<item android:id="@+id/action_settings" | ||
android:title="@string/action_settings" | ||
android:orderInCategory="100" | ||
app:showAsAction="never" /> | ||
</menu> |
14 changes: 14 additions & 0 deletions
14
barcodescanner/src/main/res/menu/productlist_contextmenu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<item | ||
android:id="@+id/contextmenu_edit" | ||
android:title="@string/productList_contextmenu_edit" | ||
/> | ||
|
||
<item | ||
android:id="@+id/contextmenu_delete" | ||
android:title="@string/productList_contextmenu_delete" | ||
/>" | ||
|
||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<color name="DarkGrey">#222222</color> | ||
|
||
<color name="Brown">#9A5C0C</color> | ||
<color name="White">#FFF6EB</color> | ||
<color name="White_Transparent">#70FFF6EB</color> | ||
|
||
<color name="Red">#F0021A</color> | ||
<color name="Amber">#FFA617</color> | ||
<color name="Green">#23BA2D</color> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
|
||
</resources> |
Oops, something went wrong.