Skip to content

Commit

Permalink
V1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bandit-ibayashi committed Nov 25, 2021
1 parent 1392dff commit 03ff785
Show file tree
Hide file tree
Showing 187 changed files with 10,884 additions and 5,846 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# Change Log

## 1.1.0 (2021/11/19)

* Added TSP100IV support.
* Updated React Native version to 0.66.
* Updated libraries to be used.
* Improved printing speed.
* Added type definition files for TypeScript.
* iOS: Supported for Xcode 13.
* iOS: Added support for the iOS simulator on Apple Silicon Mac.
* Android: Responded to the JCenter shutdown.
* Bug Fix:
* iOS
* Fixed a crash of StarLogger class when exiting the application.
* Fixed an issue where memory usage kept increasing while searching for LAN printers.
* Fixed an issue that the startDiscovery method of the StarDeviceDiscoveryManager class could not detect printers that joined the network after the search started.
* Added a process to exclude simulator binaries from StarIO10 when building for devices.
* Improved internal processing
* Android
* Fixed a crash when leaving the dialog asking for USB access for a few seconds or selecting cancel.
* Fixed an issue that the startDiscovery method of the StarDeviceDiscoveryManager class could not detect printers that joined the network after the search started.
* Support for Android OS specification change when using USB communication.

* example (Android:1.0.1)
* Support for new Bluetooth permission request when targeting Android 12.

## 1.0.0 (2021/05/14)

* example (iOS : 1.0.1)
Expand Down
106 changes: 87 additions & 19 deletions LICENSE

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ This library is included in StarXpand SDK.

## Requirements

| Platform | Version |
| --- | --- |
| iOS | iOS 12.0 or later |
| Android | Android 6.0 or later |
| Windows | Windows 10 1909 or later |
| Platform | Version | Arch |
| --- | --- | --- |
| iOS | iOS 12.0 or later | Device: arm64<br> Simulator: x86_64, arm64 |
| Android | Android 6.0 or later | arm64-v8a, armeabi-v7a, x86, x86_64 |
| Windows | Windows 10 1909 or later | x86, x64 |

## Installation

Expand All @@ -38,20 +38,33 @@ npm install react-native-star-io10 --save

### Android

- No setup needed.
#### In case of setting targetSdkVersion to 31 or later

- Refer to [sample code](../example/samples) and request BLUETOOTH_CONNECT permission before starting to communicate with or search for the printer.

### Windows

- Add Capability in `Package.appxmanifest`.
- Bluetooth
- Internet (Client)
- Private Networks (Client & Server)
- Disable `Compile with .NET Native tool chain`.
- Add "Visual C++ 2015-2019 UWP Desktop Runtime for native apps" to the project "References".

## Documentation

[Please refer here.](https://www.star-m.jp/react-native-stario10-oml.html)

## Limitations

### When using Android device, an image specified by URL is sometimes printed in a low resolution

In Android, when an image file size is large, and its URL is specified as the source of the ImageParameter which is the argument of the actionPrintImage method, the image may be printed in low resolution.

This can be solved by either of the following methods:

- Reduce a file size of an image by lowering the resolution beforehand.
- Download an image in the app and specify the image file directly as the source.

## Examples

### Discover devices
Expand Down
6 changes: 4 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ buildscript {

repositories {
google()
jcenter()}
mavenCentral()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.2.2'
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down
4 changes: 2 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
StarIO10Module_kotlinVersion=1.4.10
StarIO10Module_compileSdkVersion=30
StarIO10Module_compileSdkVersion=31
StarIO10Module_buildToolsVersion=30.0.2
StarIO10Module_targetSdkVersion=30
StarIO10Module_targetSdkVersion=31

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Sep 14 09:06:54 JST 2020
#Fri Nov 05 19:02:49 JST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Empty file modified android/gradlew
100644 → 100755
Empty file.
Binary file modified android/src/lib/stario10.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ class StarDeviceDiscoveryManagerWrapper internal constructor(context: ReactAppli
promise.resolve(0)
}

@ReactMethod
fun addListener(eventName: String) {
// Set up any upstream listeners or background tasks as necessary
}

@ReactMethod
fun removeListeners(count: Int) {
// Remove upstream listeners, stop unnecessary background tasks
}

@ReactMethod
fun startDiscovery(identifier: String, discoveryTime: Int, promise: Promise) {
val manager = InstanceManager.get(identifier)
Expand All @@ -45,7 +55,7 @@ class StarDeviceDiscoveryManagerWrapper internal constructor(context: ReactAppli
manager.discoveryTime = discoveryTime

try {
manager.startDiscovery(object : StarDeviceDiscoveryManager.Callback {
manager.callback = object: StarDeviceDiscoveryManager.Callback {
override fun onPrinterFound(printer: StarPrinter) {
val params = Arguments.createMap()
params.putString(EventParameter.KEY_IDENTIFIER, identifier)
Expand All @@ -64,7 +74,9 @@ class StarDeviceDiscoveryManagerWrapper internal constructor(context: ReactAppli

sendEvent(EventParameter.NAME_DISCOVERY_FINISHED, params)
}
})
}

manager.startDiscovery()

promise.resolve(0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ class StarIO10ValueConverter {
"TSP650II" to StarPrinterModel.TSP650II,
"TSP700II" to StarPrinterModel.TSP700II,
"TSP800II" to StarPrinterModel.TSP800II,
"TSP100IIU_Plus" to StarPrinterModel.TSP100IIU_Plus,
"TSP100IIIW" to StarPrinterModel.TSP100IIIW,
"TSP100IIILAN" to StarPrinterModel.TSP100IIILAN,
"TSP100IIIBI" to StarPrinterModel.TSP100IIIBI,
"TSP100IIIU" to StarPrinterModel.TSP100IIIU,
"TSP100IV" to StarPrinterModel.TSP100IV,
"mPOP" to StarPrinterModel.mPOP,
"mC_Print2" to StarPrinterModel.mC_Print2,
"mC_Print3" to StarPrinterModel.mC_Print3,
Expand Down Expand Up @@ -677,7 +679,7 @@ class StarIO10ValueConverter {
finish = true
}

override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>?) {
override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>) {
finish = true
}
}, executor)
Expand Down Expand Up @@ -726,9 +728,9 @@ class StarIO10ValueConverter {
val client = OkHttpClient()
val request = Request.Builder().url(uri).build()
val response = client.newCall(request).execute()
response.body()?.bytes()?.let { responseBytes ->
response.body?.bytes()?.let { responseBytes ->
bytes = responseBytes.toList()
response.body()?.close()
response.body?.close()
}
} catch (e: Exception){}

Expand Down
10 changes: 10 additions & 0 deletions android/src/main/java/com/stario10module/StarPrinterWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class StarPrinterWrapper internal constructor(context: ReactApplicationContext)
promise.resolve(identifier)
}

@ReactMethod
fun addListener(eventName: String) {
// Set up any upstream listeners or background tasks as necessary
}

@ReactMethod
fun removeListeners(count: Int) {
// Remove upstream listeners, stop unnecessary background tasks
}

@ReactMethod
fun activatePrinterDelegate(identifier: String, promise: Promise) {
val printer = InstanceManager.get(identifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class StarXpandCommandBuilderWrapper internal constructor(context: ReactApplicat
val builder = InstanceManager.get(identifier)

if (builder is StarXpandCommandBuilder) {
promise.resolve(builder.getCommand())
promise.resolve(builder.getCommands())
}
else {
promise.reject(ReactNoCrashSoftException("Not found native instance"))
Expand Down
25 changes: 25 additions & 0 deletions docs/CHANGELOG_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# 変更点

## 1.1.0 (2021/11/19)

* TSP100IV に対応
* React Native のバージョンを0.66に更新
* 使用するライブラリの更新
* 印刷速度の高速化
* TypeScript用の型定義ファイルを追加
* iOS: Xcode 13 に対応
* iOS: Apple Silicon Mac上のiOSシミュレーターに対応
* Android: JCenter廃止への対応
* 不具合修正
* iOS
* アプリ終了時にStarLoggerクラスがクラッシュする問題を修正
* LANプリンター検索中にメモリ使用量が増加し続ける問題を修正
* StarDeviceDiscoveryManagerクラスのstartDiscoveryメソッドが、検索開始後にネットワークに参加したプリンターを検出できない問題を修正
* 実機ビルド時、StarIO10からシミュレータ用バイナリを除外する処理を追加
* 内部処理改善
* Android
* USBアクセスを求めるダイアログにて、数秒間放置するかキャンセルを選択するとクラッシュする問題を修正
* StarDeviceDiscoveryManagerクラスのstartDiscoveryメソッドが、検索開始後にネットワークに参加したプリンターを検出できない問題を修正
* Android 12にてUSB通信をする際のAndroid OS仕様変更に対応

* example (Android:1.0.1)
* Android 12をターゲットとする場合の新しいBluetooth権限に対応

## 1.0.0 (2021/05/14)

* example (iOS:1.0.1)
Expand Down
31 changes: 22 additions & 9 deletions docs/README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

## 動作環境

| Platform | Version |
| --- | --- |
| iOS | iOS 12.0 以降 |
| Android | Android 6.0 以降 |
| Windows | Windows 10 1909 以降 |
| Platform | OS Version | Arch |
| --- | --- | --- |
| iOS | iOS 12.0 以降 | 実機: arm64<br> シミュレータ: x86_64, arm64 |
| Android | Android 6.0 以降 | arm64-v8a, armeabi-v7a, x86, x86_64 |
| Windows | Windows 10 1909 以降 | x86, x64 |

## 導入

Expand All @@ -38,20 +38,33 @@ npm install react-native-star-io10 --save

### Android

- 設定不要です.
#### targetSdkVersionを31以降に設定する場合

- [サンプルコード](../example/samples)を参考にして、プリンターとの通信や検索を開始する前に、BLUETOOTH_CONNECTパーミッションを要求してください。

### Windows

- 機能を`Package.appxmanifest`に追加してください。
- Bluetooth
- Internet (Client)
- Private Networks (Client & Server)
- `.NETネイティブツールチェーンでコンパイルする`を無効にしてください
- インターネット(クライアント)
- プライベート ネットワーク (クライアントとサーバー)
- プロジェクトの「参照」に"Visual C++ 2015-2019 UWP Desktop Runtime for native apps"を追加してください

## ドキュメント

[ここを参照ください。](https://www.star-m.jp/react-native-stario10-oml.html)

## 制限事項

### Android端末を使用する場合、URLで指定した画像が低い解像度で印字されることがある

actionPrintImageメソッドの引数ImageParameterのsourceにある程度サイズが大きい画像ファイルのURLを指定した場合、Android端末から印刷データが送付されると、画像が粗く印字されることがあります。

下記いずれかの方法により回避することができます。

- あらかじめ画像の解像度を下げるなどして画像のデータ量を下げる
- アプリ内で画像をダウンロードし、sourceには画像ファイルを直接指定する

## Examples

### Discover devices
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ build/
.gradle
local.properties
*.iml
*.hprof

# Visual Studio Code
#
Expand Down
36 changes: 35 additions & 1 deletion example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
Text,
Button,
TextInput,
Image
PermissionsAndroid,
Platform
} from 'react-native';

import {
Expand Down Expand Up @@ -34,6 +35,20 @@ class App extends React.Component<AppProps, AppState> {
settings.identifier = this.state.identifier;
// settings.autoSwitchInterface = true;

// If you are using Android 12 and targetSdkVersion is 31 or later,
// you have to request Bluetooth permission (Nearby devices permission) to use the Bluetooth printer.
// https://developer.android.com/about/versions/12/features/bluetooth-permissions
if (Platform.OS == 'android' && 31 <= Platform.Version) {
if (this.state.interfaceType == InterfaceType.Bluetooth || settings.autoSwitchInterface == true) {
var hasPermission = await this._confirmBluetoothPermission();

if (!hasPermission) {
console.log(`PERMISSION ERROR: You have to allow Nearby devices to use the Bluetooth printer`);
return;
}
}
}

var printer = new StarPrinter(settings);

try {
Expand Down Expand Up @@ -117,6 +132,25 @@ class App extends React.Component<AppProps, AppState> {
}
}

private async _confirmBluetoothPermission(): Promise<boolean> {
var hasPermission = false;

try {
hasPermission = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT);

if (!hasPermission) {
const status = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT);

hasPermission = status == PermissionsAndroid.RESULTS.GRANTED;
}
}
catch (err) {
console.warn(err);
}

return hasPermission;
}

constructor(props: any) {
super(props);

Expand Down
Loading

0 comments on commit 03ff785

Please sign in to comment.