Skip to content

Commit 07f080a

Browse files
committed
First commit of the DeviceIdentifiersWrapper
1 parent 8ecafe1 commit 07f080a

42 files changed

Lines changed: 978 additions & 79 deletions

Some content is hidden

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

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
apply plugin: 'com.android.library'
2+
3+
ext {
4+
PUBLISH_GROUP_ID = 'com.zebra.deviceidentifierswrapper'
5+
PUBLISH_ARTIFACT_ID = 'deviceidentifierswrapper'
6+
PUBLISH_VERSION = '1.2.739'
7+
}
8+
9+
android {
10+
compileSdkVersion 29
11+
12+
defaultConfig {
13+
minSdkVersion 26
14+
targetSdkVersion 29
15+
versionCode 1
16+
versionName "1.3"
17+
18+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
19+
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
29+
}
30+
31+
dependencies {
32+
implementation fileTree(dir: 'libs', include: ['*.jar'])
33+
implementation 'com.android.support:appcompat-v7:28.0.0'
34+
testImplementation 'junit:junit:4.13'
35+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
36+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
37+
compileOnly 'com.symbol:emdk:+'
38+
api 'com.symbol:emdk:7.0.0'
39+
}
40+
41+
def jarName = 'deviceidentifierswrapper.jar'
42+
43+
task clearJarRelease(type: Delete) {
44+
delete "${project.buildDir}/outputs/jar/release/" + jarName
45+
}
46+
47+
task clearJarDebug(type: Delete) {
48+
delete "${project.buildDir}/outputs/jar/debug/" + jarName
49+
}
50+
51+
task makeJarRelease(type: Copy) {
52+
from("${project.buildDir}/intermediates/intermediate-jars/release/")
53+
into("${project.buildDir}/outputs/jar/release")
54+
include('classes.jar')
55+
rename('classes.jar', jarName)
56+
}
57+
58+
task makeJarDebug(type: Copy) {
59+
from("${project.buildDir}/intermediates/intermediate-jars/debug/")
60+
into("${project.buildDir}/outputs/jar/debug")
61+
include('classes.jar')
62+
rename('classes.jar', jarName)
63+
}
64+
65+
task makeAllJar(type: Copy) {}
66+
67+
makeJarRelease.dependsOn(clearJarRelease, build)
68+
makeJarDebug.dependsOn(clearJarDebug, build)
69+
70+
makeAllJar.dependsOn(makeJarDebug,makeJarRelease)
71+
72+
/*
73+
Publish tasks
74+
https://medium.com/@daniellevass/how-to-publish-your-android-studio-library-to-jcenter-5384172c4739
75+
https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle
76+
*/
77+
78+
// ./gradlew clean build generateRelease
79+
apply plugin: 'maven'
80+
81+
def groupId = project.PUBLISH_GROUP_ID
82+
def artifactId = project.PUBLISH_ARTIFACT_ID
83+
def version = project.PUBLISH_VERSION
84+
85+
def localReleaseDest = "${buildDir}/release/${version}"
86+
87+
task androidJavadocs(type: Javadoc) {
88+
failOnError = false
89+
source = android.sourceSets.main.java.srcDirs
90+
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
91+
classpath += files(ext.androidJar)
92+
}
93+
94+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
95+
classifier = 'javadoc'
96+
from androidJavadocs.destinationDir
97+
}
98+
99+
task androidSourcesJar(type: Jar) {
100+
classifier = 'sources'
101+
from android.sourceSets.main.java.srcDirs
102+
}
103+
104+
uploadArchives {
105+
repositories.mavenDeployer {
106+
pom.groupId = groupId
107+
pom.artifactId = artifactId
108+
pom.version = version
109+
// Add other pom properties here if you want (developer details / licenses)
110+
repository(url: "file://${localReleaseDest}")
111+
}
112+
}
113+
114+
task zipRelease(type: Zip) {
115+
from localReleaseDest
116+
destinationDir buildDir
117+
archiveName "release-${version}.zip"
118+
}
119+
120+
task generateRelease {
121+
doLast {
122+
println "Release ${version} can be found at ${localReleaseDest}/"
123+
println "Release ${version} zipped can be found ${buildDir}/release-${version}.zip"
124+
}
125+
}
126+
127+
generateRelease.dependsOn(uploadArchives)
128+
generateRelease.dependsOn(zipRelease)
129+
130+
131+
artifacts {
132+
archives androidSourcesJar
133+
archives androidJavadocsJar
134+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.zebra.deviceidentifierswrapper">
3+
</manifest>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.zebra.deviceidentifierswrapper;
2+
3+
import android.content.Context;
4+
import android.os.Handler;
5+
import android.os.Parcel;
6+
import android.os.ResultReceiver;
7+
8+
/**
9+
* Created by Trudu Laurent on 2020/08/11.
10+
*/
11+
12+
abstract class DICommandBase {
13+
/*
14+
A TAG if we want to log something
15+
*/
16+
protected static String TAG = "DIWrapper";
17+
18+
/*
19+
A context to work with intents
20+
*/
21+
protected Context mContext = null;
22+
23+
protected DICommandBaseSettings mSettings = null;
24+
25+
/*
26+
A handler that will be used by the derived
27+
class to prevent waiting to loong for DW in case
28+
of problem
29+
*/
30+
protected Handler mTimeOutHandler;
31+
32+
/*
33+
What will be done at the end of the TimeOut
34+
*/
35+
protected Runnable mTimeOutRunnable = new Runnable() {
36+
@Override
37+
public void run() {
38+
onTimeOut(mSettings);
39+
}
40+
};
41+
42+
43+
public DICommandBase(Context aContext)
44+
{
45+
mContext = aContext;
46+
mTimeOutHandler = new Handler(mContext.getMainLooper());
47+
}
48+
49+
50+
protected void execute(DICommandBaseSettings settings)
51+
{
52+
mSettings = settings;
53+
/*
54+
Start time out mechanism
55+
Enabled by default in DWProfileBaseSettings
56+
*/
57+
if(settings.mEnableTimeOutMechanism) {
58+
mTimeOutHandler.postDelayed(mTimeOutRunnable,
59+
mSettings.mTimeOutMS);
60+
}
61+
}
62+
63+
protected void onTimeOut(DICommandBaseSettings settings)
64+
{
65+
cleanAll();
66+
}
67+
68+
protected void cleanAll()
69+
{
70+
if(mTimeOutHandler != null)
71+
{
72+
mTimeOutHandler.removeCallbacks(mTimeOutRunnable);
73+
}
74+
}
75+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.zebra.deviceidentifierswrapper;
2+
3+
class DICommandBaseSettings
4+
{
5+
/*
6+
Use this to track the source of the intent
7+
*/
8+
public String mCommandId = "";
9+
10+
/*
11+
Some method return only errors (StartScan, StopScan)
12+
We do not need a time out for them
13+
*/
14+
public boolean mEnableTimeOutMechanism = true;
15+
16+
/*
17+
A time out, in case we don't receive an answer
18+
from PrintConnect
19+
*/
20+
public long mTimeOutMS = 5000;
21+
}

0 commit comments

Comments
 (0)