Skip to content

Commit 520e4c4

Browse files
authored
Merge pull request #4 from st1vms/v0.1.4
V0.1.4 [stable]
2 parents 301a8f6 + 06cc1c1 commit 520e4c4

Some content is hidden

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

52 files changed

+3614
-64
lines changed

binds/Android/JDBits/.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
/.idea/caches
6+
/.idea/libraries
7+
/.idea/modules.xml
8+
/.idea/workspace.xml
9+
/.idea/navEditor.xml
10+
/.idea/assetWizardSettings.xml
11+
.DS_Store
12+
/build
13+
/captures
14+
.externalNativeBuild
15+
.cxx
16+
local.properties

binds/Android/JDBits/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

binds/Android/JDBits/app/build.gradle

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'com.android.library'
3+
}
4+
5+
android {
6+
namespace 'com.st1vms.android.jdbits'
7+
compileSdk 33
8+
9+
defaultConfig {
10+
minSdk 19
11+
targetSdk 33
12+
versionName '0.1.4'
13+
14+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
debug {
23+
jniDebuggable true
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_11
28+
targetCompatibility JavaVersion.VERSION_11
29+
}
30+
buildToolsVersion '33.0.1'
31+
ndkVersion '25.1.8937393'
32+
}
33+
34+
dependencies {
35+
36+
implementation project(path: ':jdbits')
37+
testImplementation 'junit:junit:4.13.2'
38+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
39+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
40+
}
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
package com.st1vms.android.jdbits.app;
2+
3+
import android.util.Log;
4+
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
11+
import com.st1vms.android.jdbits.DBits;
12+
import com.st1vms.android.jdbits.DPacket;
13+
import com.st1vms.android.jdbits.DTypes;
14+
import com.st1vms.android.jdbits.dtypes.BooleanType;
15+
import com.st1vms.android.jdbits.dtypes.DSerializable;
16+
import com.st1vms.android.jdbits.dtypes.DoubleType;
17+
import com.st1vms.android.jdbits.dtypes.Int16Type;
18+
import com.st1vms.android.jdbits.dtypes.Int32Type;
19+
import com.st1vms.android.jdbits.dtypes.Int64Type;
20+
import com.st1vms.android.jdbits.dtypes.Int8Type;
21+
import com.st1vms.android.jdbits.dtypes.UInt16Type;
22+
import com.st1vms.android.jdbits.dtypes.UInt32Type;
23+
import com.st1vms.android.jdbits.dtypes.UInt64Type;
24+
import com.st1vms.android.jdbits.dtypes.UInt8Type;
25+
import com.st1vms.android.jdbits.dtypes.UTF8StringType;
26+
27+
import java.io.UnsupportedEncodingException;
28+
import java.util.ArrayList;
29+
import java.util.Locale;
30+
31+
/**
32+
* Instrumented test, which will execute on an Android device.
33+
*
34+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
35+
*/
36+
@RunWith(AndroidJUnit4.class)
37+
public class ExampleInstrumentedTest {
38+
@Test
39+
public void useAppContext() throws UnsupportedEncodingException {
40+
// Context of the app under test.
41+
DTypes[] template = new DTypes[]{
42+
DTypes.UINT8_TYPE,
43+
DTypes.UINT16_TYPE,
44+
DTypes.UINT32_TYPE,
45+
DTypes.UINT64_TYPE,
46+
DTypes.INT8_TYPE,
47+
DTypes.INT16_TYPE,
48+
DTypes.INT32_TYPE,
49+
DTypes.INT64_TYPE,
50+
DTypes.BOOLEAN_TYPE,
51+
DTypes.DOUBLE_TYPE,
52+
DTypes.UTF8_STRING_TYPE
53+
};
54+
55+
if(!DBits.RegisterPacket(0, template)){
56+
return;
57+
}
58+
59+
60+
DPacket packet = new DPacket(0, new ArrayList<>(){
61+
{
62+
add(new UInt8Type((short) 42));
63+
add(new UInt16Type((short) 160));
64+
add(new UInt32Type(4002));
65+
add(new UInt64Type(41812));
66+
add(new Int8Type((byte) -42));
67+
add(new Int16Type((short) -160));
68+
add(new Int32Type(-4002));
69+
add(new Int64Type(-41812));
70+
add(new BooleanType(false));
71+
add(new DoubleType(160.051));
72+
add(new UTF8StringType("I do desire we may be better strangers"));
73+
}
74+
});
75+
76+
final byte[] buf = DBits.SerializeDPacket(packet);
77+
if(buf != null){
78+
79+
StringBuilder s = new StringBuilder();
80+
for(byte b: buf){
81+
s.append(String.format(Locale.getDefault(), "0x%02x ", b));
82+
}
83+
Log.d("TAG",String.format(Locale.getDefault(),
84+
"\nSerialized to %d bytes: %s", buf.length, s));
85+
86+
try {
87+
DPacket p = DBits.DeserializeBuffer(buf, buf.length);
88+
if(p == null){
89+
Log.d("TAG","Deserialize Error!");
90+
return;
91+
}
92+
UInt8Type u8 = (UInt8Type) p.getField(0);
93+
Log.d("TAG",String.format(Locale.getDefault(), "U8 -> %d",u8.getShortValue()));
94+
95+
UInt16Type u16 = (UInt16Type) p.getField(1);
96+
Log.d("TAG",String.format(Locale.getDefault(), "U16 -> %d",u16.getIntValue()));
97+
98+
UInt32Type u32 = (UInt32Type) p.getField(2);
99+
Log.d("TAG",String.format(Locale.getDefault(), "U32 -> %d",u32.getIntValue()));
100+
101+
UInt64Type u64 = (UInt64Type) p.getField(3);
102+
Log.d("TAG",String.format(Locale.getDefault(), "U64 -> %d",u64.getLongValue()));
103+
104+
Int8Type i8 = (Int8Type) p.getField(4);
105+
Log.d("TAG",String.format(Locale.getDefault(), "I8 -> %d",i8.getByteValue()));
106+
107+
Int16Type i16 = (Int16Type) p.getField(5);
108+
Log.d("TAG",String.format(Locale.getDefault(), "I16 -> %d",i16.getShortValue()));
109+
110+
Int32Type i32 = (Int32Type) p.getField(6);
111+
Log.d("TAG",String.format(Locale.getDefault(), "I32 -> %d",i32.getIntValue()));
112+
113+
Int64Type i64 = (Int64Type) p.getField(7);
114+
Log.d("TAG",String.format(Locale.getDefault(), "I64 -> %d",i64.getLongValue()));
115+
116+
BooleanType b = (BooleanType) p.getField(8);
117+
Log.d("TAG",String.format(Locale.getDefault(), "B -> %b",b.getBoolValue()));
118+
119+
DoubleType d = (DoubleType) p.getField(9);
120+
Log.d("TAG",String.format(Locale.getDefault(), "D -> %f",d.getDoubleValue()));
121+
122+
UTF8StringType str = (UTF8StringType) p.getField(10);
123+
Log.d("TAG",String.format(Locale.getDefault(), "UTF8 -> %s",str.getUTF8StringValue()));
124+
125+
}catch (Exception e){
126+
e.printStackTrace();
127+
}
128+
129+
}else{
130+
Log.d("TAG","Buffer is null");
131+
}
132+
}
133+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest>
3+
4+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.st1vms.android.jdbits.app;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11+
*/
12+
public class ExampleUnitTest {
13+
@Test
14+
public void addition_isCorrect() {
15+
assertEquals(4, 2 + 2);
16+
}
17+
}

binds/Android/JDBits/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
plugins {
3+
id 'com.android.library' version '7.4.1' apply false
4+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Project-wide Gradle settings.
2+
# IDE (e.g. Android Studio) users:
3+
# Gradle settings configured through the IDE *will override*
4+
# any settings specified in this file.
5+
# For more details on how to configure your build environment visit
6+
# http://www.gradle.org/docs/current/userguide/build_environment.html
7+
# Specifies the JVM arguments used for the daemon process.
8+
# The setting is particularly useful for tweaking memory settings.
9+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10+
# When configured, Gradle will run in incubating parallel mode.
11+
# This option should only be used with decoupled projects. More details, visit
12+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13+
# org.gradle.parallel=true
14+
# AndroidX package structure to make it clearer which packages are bundled with the
15+
# Android operating system, and which are packaged with your app's APK
16+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
17+
android.useAndroidX=true
18+
# Enables namespacing of each library's R class so that its R class includes only the
19+
# resources declared in the library itself and none from the library's dependencies,
20+
# thereby reducing the size of the R class for that library
21+
android.nonTransitiveRClass=true
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Feb 09 11:34:28 CET 2023
2+
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4+
distributionPath=wrapper/dists
5+
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)