Skip to content

Commit 53865df

Browse files
committed
First release of Android Studio examples
Projects can be imported in Android Studio directly. Datalogic SDK v1 and matching API level 23, must be installed in order to compile some of them. Signed-off-by: Guido Davide Dall’Olio <guido.dallolio@datalogic.com>
0 parents  commit 53865df

201 files changed

Lines changed: 5920 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DecodeConfigSampleAPI/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gradle
2+
.idea
3+
.build
4+
local.properties
5+
*.iml
6+
build
7+
.DS_Store
8+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 'Datalogic:Datalogic SDK v1:23'
5+
buildToolsVersion "23.0.3"
6+
7+
defaultConfig {
8+
applicationId "com.datalogic.examples.decodeconfigsampleapi"
9+
minSdkVersion 16
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(include: ['*.jar'], dir: 'libs')
24+
compile 'com.android.support:appcompat-v7:23.4.0'
25+
compile 'com.android.support:design:23.4.0'
26+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.datalogic.examples.decodeconfigsampleapi"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk
8+
android:minSdkVersion="16"
9+
android:targetSdkVersion="23" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@drawable/ic_launcher"
14+
android:label="@string/app_name"
15+
android:theme="@android:style/Theme.DeviceDefault" >
16+
17+
<uses-library
18+
android:name="com.datalogic.device"
19+
android:required="true" />
20+
21+
<activity
22+
android:name="com.datalogic.examples.decodeconfigsampleapi.DecodeConfiguration"
23+
android:label="@string/app_name" >
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
27+
<category android:name="android.intent.category.LAUNCHER" />
28+
</intent-filter>
29+
</activity>
30+
</application>
31+
32+
</manifest>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// ©2016 Datalogic S.p.A. and/or its affiliates. All rights reserved.
2+
3+
package com.datalogic.examples.decodeconfigsampleapi;
4+
5+
import com.datalogic.decode.BarcodeManager;
6+
import com.datalogic.decode.configuration.LengthControlMode;
7+
import com.datalogic.decode.configuration.ScannerProperties;
8+
import com.datalogic.device.configuration.ConfigException;
9+
import com.datalogic.device.ErrorManager;
10+
11+
import android.os.Bundle;
12+
import android.app.Activity;
13+
import android.content.Intent;
14+
import android.util.Log;
15+
import android.view.Menu;
16+
import android.view.MenuItem;
17+
import android.view.View;
18+
19+
public class DecodeConfiguration extends Activity {
20+
21+
// Constant for log messages.
22+
private final String LOGTAG = getClass().getName();
23+
24+
BarcodeManager manager = null;
25+
ScannerProperties configuration = null;
26+
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
setContentView(R.layout.activity_main);
31+
32+
// Create a BarcodeManager.
33+
manager = new BarcodeManager();
34+
35+
// Pass it to ScannerProperties class.
36+
// ScannerProperties cannot be instantiated directly, instead call edit.
37+
configuration = ScannerProperties.edit(manager);
38+
39+
// Now we can change some Scanner/Device configuration parameters.
40+
// These values are not applied, as long as store method is not called.
41+
configuration.code39.enable.set(true);
42+
configuration.code39.enableChecksum.set(false);
43+
configuration.code39.fullAscii.set(true);
44+
configuration.code39.Length1.set(20);
45+
configuration.code39.Length2.set(2);
46+
configuration.code39.lengthMode.set(LengthControlMode.TWO_FIXED);
47+
configuration.code39.sendChecksum.set(false);
48+
configuration.code39.userID.set('x');
49+
50+
configuration.code128.enable.set(true);
51+
configuration.code128.Length1.set(6);
52+
configuration.code128.Length2.set(2);
53+
configuration.code128.lengthMode.set(LengthControlMode.RANGE);
54+
configuration.code128.userID.set('y');
55+
56+
if (configuration.qrCode.isSupported()) {
57+
configuration.qrCode.enable.set(false);
58+
}
59+
60+
// Change IntentWedge action and category to specific ones.
61+
configuration.intentWedge.action.set("com.datalogic.examples.decode_action");
62+
configuration.intentWedge.category.set("com.datalogic.examples.decode_category");
63+
64+
// From here on, we would like to get a return value instead of an exception in case of error.
65+
ErrorManager.enableExceptions(false);
66+
67+
// Now we are ready to store them.
68+
// Second parameter set to true saves configuration in a permanent way.
69+
// After boot settings will be still valid.
70+
int errorCode = configuration.store(manager, true);
71+
72+
// Check return value.
73+
if(errorCode != ConfigException.SUCCESS) {
74+
Log.e(LOGTAG, "Error during store", ErrorManager.getLastError());
75+
}
76+
}
77+
78+
@Override
79+
public boolean onCreateOptionsMenu(Menu menu) {
80+
// Inflate the menu; this adds items to the action bar if it is present.
81+
getMenuInflater().inflate(R.menu.main, menu);
82+
return true;
83+
}
84+
85+
@Override
86+
public boolean onOptionsItemSelected(MenuItem item) {
87+
// Handle menu item selection
88+
switch (item.getItemId()) {
89+
case R.id.action_settings:
90+
startSettingsActivity();
91+
return true;
92+
default:
93+
return super.onOptionsItemSelected(item);
94+
}
95+
}
96+
97+
// Method called by displayed button
98+
public void buttonClicked(View v) {
99+
startSettingsActivity();
100+
}
101+
102+
private void startSettingsActivity() {
103+
// Create and start an intent to pop up Android Settings
104+
Intent dialogIntent = new Intent(android.provider.Settings.ACTION_SETTINGS);
105+
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
106+
startActivity(dialogIntent);
107+
}
108+
}
7.48 KB
Loading
3.69 KB
Loading
12.2 KB
Loading
24.2 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:paddingBottom="@dimen/activity_vertical_margin"
6+
android:paddingLeft="@dimen/activity_horizontal_margin"
7+
android:paddingRight="@dimen/activity_horizontal_margin"
8+
android:paddingTop="@dimen/activity_vertical_margin"
9+
tools:context=".MainActivity" >
10+
11+
<TextView
12+
android:id="@+id/textView1"
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:text="@string/description" />
16+
17+
<Button
18+
android:id="@+id/button1"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_below="@+id/textView1"
22+
android:layout_centerHorizontal="true"
23+
android:layout_marginTop="60dp"
24+
android:onClick="buttonClicked"
25+
android:text="@string/action_settings" />
26+
27+
</RelativeLayout>

0 commit comments

Comments
 (0)