Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
can-miki committed Nov 13, 2023
1 parent 66ef329 commit d2d8fb6
Show file tree
Hide file tree
Showing 115 changed files with 3,541 additions and 7,746 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

# Change Log

## 1.5.0 (2023/10/27)

* Added MCP31CI/CBI support.
* Faster print data generation.
* iOS/Android: Added a sample to generate receipt images from text data.

* Bug Fix:
* iOS/Windows: Fixed to be able to print to printers on different segment networks by specifying IP address.
* Fixed an issue where decorations (methods starting with `style`) set with `DocumentBuilder.addPrinter()` were not reset when the method ended.

## 1.4.0 (2023/09/08)

* Added TSP100IV SK support.
Expand Down
30 changes: 13 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,17 @@ To read our latest Software License Agreement, please visit the following URL.
https://www.star-m.jp/wp-content/uploads/SoftwareLicenseAgreement_web.pdf

Copyright (c) 2013-2021 Niels Lohmann
Released under the MIT license
https://opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright (c) .NET Foundation and Contributors
Released under the MIT license
https://opensource.org/licenses/mit-license.php

Copyright (c) 2015-present, Facebook, Inc.
Released under the MIT license
https://opensource.org/licenses/mit-license.php

Copyright (c) 2022 Iddan Aaronsohn
Released under the MIT license
https://opensource.org/licenses/mit-license.php
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ StarXpand SDK includes an [example](example) application that can be used in com

#### 2. [Create printing data](https://star-m.jp/products/s_print/sdk/react-native-star-io10/manual/en/basic-step1.html)

Printing samples of labels (sample code and print results) for each type of business that you can use for your print layouts are [also available](example/samples/printing_samples/PrintingSamples.md).
The sample code and printed result images are also [available here](example/samples/printing_samples/PrintingSamples.md).

- Sample to create print layouts for labels for each type of business
- Sample to generate receipt images from text data (iOS/Android)

> :warning: Some printer models may not be able to print some samples. Please adjust the layout accordingly when using this samples.
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
minSdkVersion 28
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
versionCode 1
versionName "1.4.0"
versionName "1.5.0"
}

buildTypes {
Expand Down Expand Up @@ -127,7 +127,7 @@ dependencies {
api 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation files('src/lib/stario10.aar')
def coroutines_version = '1.3.7' // Version of the library for Kotlin coroutines (async, await)
def coroutines_version = '1.6.4' // Version of the library for Kotlin coroutines (async, await)
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" // Library for Kotlin coroutines (async, await)
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
StarIO10Module_kotlinVersion=1.6.10
StarIO10Module_kotlinVersion=1.7.21
StarIO10Module_compileSdkVersion=33
StarIO10Module_buildToolsVersion=33.0.0
StarIO10Module_targetSdkVersion=33
Expand Down
Binary file modified android/src/lib/stario10.aar
Binary file not shown.

This file was deleted.

39 changes: 0 additions & 39 deletions android/src/main/java/com/stario10module/BuzzerBuilderWrapper.kt

This file was deleted.

190 changes: 39 additions & 151 deletions android/src/main/java/com/stario10module/DisplayBuilderWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,163 +2,51 @@ package com.stario10module

import com.facebook.react.bridge.*
import com.starmicronics.stario10.StarIO10ArgumentException
import com.starmicronics.stario10.starxpandcommand.DisplayBuilder
import com.starmicronics.stario10.starxpandcommand.PrinterBuilder
import com.starmicronics.stario10.starxpandcommand.*
import org.json.JSONObject

class DisplayBuilderWrapper internal constructor(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
class DisplayBuilderWrapper internal constructor(context: ReactApplicationContext) :
ReactContextBaseJavaModule(context) {
override fun getName(): String {
return "DisplayBuilderWrapper"
}

@ReactMethod
fun init(promise: Promise) {
val builder = DisplayBuilder()
val identifier = InstanceManager.set(builder)

promise.resolve(identifier)
}

@ReactMethod
fun dispose(identifier: String, promise: Promise) {
InstanceManager.remove(identifier)
promise.resolve(0)
}

@ReactMethod
fun styleInternationalCharacter(identifier: String, type: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.styleInternationalCharacter(StarIO10ValueConverter.toDisplayInternationalCharacterType(type))
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun styleCharacterEncoding(identifier: String, type: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.styleCharacterEncoding(StarIO10ValueConverter.toDisplayCharacterEncodingType(type))
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun styleCursorPositionTo(identifier: String, x: Int, y: Int, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.styleCursorPositionTo(StarIO10ValueConverter.toDisplayPositionParameter(x, y))
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionClearLine(identifier: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.actionClearLine()
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionClearAll(identifier: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.actionClearAll()
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionSetBackLightState(identifier: String, on: Boolean, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.actionSetBackLightState(on)
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionSetCursorState(identifier: String, state: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.actionSetCursorState(StarIO10ValueConverter.toDisplayCursorState(state))
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionSetContrast(identifier: String, value: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.actionSetContrast(StarIO10ValueConverter.toDisplayContrast(value))
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionShowText(identifier: String, content: String, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
builder.actionShowText(content)
promise.resolve(0)
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
}
}

@ReactMethod
fun actionShowImage(identifier: String, source: String, effectDiffusion: Boolean, threshold: Int, promise: Promise) {
val builder = InstanceManager.get(identifier)

if (builder is DisplayBuilder) {
try {
val parameter = StarIO10ValueConverter.toDisplayImageParameter(source, effectDiffusion, threshold, reactApplicationContext)
builder.actionShowImage(parameter)
promise.resolve(0)
}
catch (e: Exception) {
val exception = StarIO10ArgumentException("Invalid source.")
val exceptionIdentifier = InstanceManager.set(exception)
promise.reject(exceptionIdentifier, exception)
}
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
fun actionShowImage(
source: String,
effectDiffusion: Boolean,
threshold: Int,
promise: Promise
) {
try {
val parameter = StarIO10ValueConverter.toDisplayImageParameter(
source,
effectDiffusion,
threshold,
reactApplicationContext
)

val builder = StarXpandCommandBuilder()

builder.addDocument(
DocumentBuilder()
.addDisplay(
DisplayBuilder().actionShowImage(parameter)
)
)

val jsonObject = JSONObject(builder.getCommands())

val contents = jsonObject
.getJSONArray("contents").getJSONObject(0)
.getJSONArray("contents").getJSONObject(0)
.getJSONArray("contents").getJSONObject(0)

promise.resolve(contents.toString())
} catch (e: Exception) {
val exception = StarIO10ArgumentException("Invalid source.")
val exceptionIdentifier = InstanceManager.set(exception)
promise.reject(exceptionIdentifier, exception)
}
}
}
Loading

0 comments on commit d2d8fb6

Please sign in to comment.