Skip to content

Commit 1a5b343

Browse files
committed
Update gradle files to fix jitPack build problem
1 parent 68a2e05 commit 1a5b343

4 files changed

Lines changed: 97 additions & 121 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v3.1.1](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.1)
1+
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v3.1.2](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.2)
22
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33

44
# Android library for ESC/POS Thermal Printer
@@ -60,7 +60,7 @@ To test this library, it's pretty simple !
6060

6161
## Installation
6262

63-
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.1) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
63+
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.2) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
6464

6565
```
6666
allprojects {
@@ -76,7 +76,7 @@ allprojects {
7676
```
7777
dependencies {
7878
...
79-
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:3.1.1'
79+
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:3.1.2'
8080
}
8181
```
8282

build.gradle

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,18 @@ buildscript {
55
}
66
dependencies {
77
classpath 'com.android.tools.build:gradle:3.6.4'
8-
9-
// NOTE: Do not place your application dependencies here; they belong
10-
// in the individual module build.gradle files
118
}
129
}
1310

1411
plugins {
1512
id 'maven-publish'
1613
}
1714

15+
1816
allprojects {
1917
repositories {
2018
google()
2119
mavenCentral()
2220
}
2321
}
2422

25-
task clean(type: Delete) {
26-
delete rootProject.buildDir
27-
}
28-
29-
30-
31-
publishing {
32-
publications {
33-
mavenJava(MavenPublication) {
34-
pom {
35-
groupId = 'com.github.DantSu'
36-
artifactId = 'ESCPOS-ThermalPrinter-Android'
37-
version = '3.1.0'
38-
name = 'ESC/POS Thermal Printer Android'
39-
description = 'Useful library to help Android developers to print with (Bluetooth, TCP, USB) ESC/POS thermal printers.'
40-
url = 'https://github.com/DantSu/ESCPOS-ThermalPrinter-Android'
41-
licenses {
42-
license {
43-
name = 'MIT License'
44-
url = 'https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/blob/master/LICENSE'
45-
}
46-
}
47-
developers {
48-
developer {
49-
id = 'DantSu'
50-
name = 'Franck Alary'
51-
url = 'http://www.dantsu.com/'
52-
}
53-
}
54-
scm {
55-
connection = 'scm:git:https://github.com/DantSu/ESCPOS-ThermalPrinter-Android.git'
56-
developerConnection = 'scm:git:https://github.com/DantSu/ESCPOS-ThermalPrinter-Android.git'
57-
url = 'https://github.com/DantSu/ESCPOS-ThermalPrinter-Android'
58-
}
59-
}
60-
}
61-
}
62-
}
63-

escposprinter/README.md

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v3.1.1](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.1)
1+
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v3.1.2](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.2)
22
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33

44
# Android library for ESC/POS Thermal Printer
@@ -60,7 +60,7 @@ To test this library, it's pretty simple !
6060

6161
## Installation
6262

63-
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.1) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
63+
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.1.2) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
6464

6565
```
6666
allprojects {
@@ -76,7 +76,7 @@ allprojects {
7676
```
7777
dependencies {
7878
...
79-
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:3.1.1'
79+
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:3.1.2'
8080
}
8181
```
8282

@@ -90,16 +90,16 @@ Also, you have to check the bluetooth permission in your app like this :
9090

9191
```java
9292
if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {
93-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH}, MainActivity.PERMISSION_BLUETOOTH);
94-
} else if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) {
95-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_ADMIN}, MainActivity.PERMISSION_BLUETOOTH_ADMIN);
96-
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
97-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, MainActivity.PERMISSION_BLUETOOTH_CONNECT);
98-
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
99-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_SCAN}, MainActivity.PERMISSION_BLUETOOTH_SCAN);
100-
} else {
101-
// Your code HERE
102-
}
93+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH}, MainActivity.PERMISSION_BLUETOOTH);
94+
} else if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) {
95+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_ADMIN}, MainActivity.PERMISSION_BLUETOOTH_ADMIN);
96+
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
97+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, MainActivity.PERMISSION_BLUETOOTH_CONNECT);
98+
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
99+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_SCAN}, MainActivity.PERMISSION_BLUETOOTH_SCAN);
100+
} else {
101+
// Your code HERE
102+
}
103103
```
104104

105105
### Bluetooth code example
@@ -108,8 +108,8 @@ The code below is an example to write in your activity :
108108

109109
```java
110110
EscPosPrinter printer = new EscPosPrinter(BluetoothPrintersConnections.selectFirstPaired(), 203, 48f, 32);
111-
printer
112-
.printFormattedText(
111+
printer
112+
.printFormattedText(
113113
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM))+"</img>\n" +
114114
"[L]\n" +
115115
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
@@ -136,7 +136,7 @@ EscPosPrinter printer = new EscPosPrinter(BluetoothPrintersConnections.selectFir
136136
"[L]\n" +
137137
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
138138
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
139-
);
139+
);
140140
```
141141

142142
Below a picture of the receipt printed with the code above :
@@ -155,43 +155,43 @@ The code below is an example to write in your activity :
155155

156156
```java
157157
new Thread(new Runnable() {
158-
public void run() {
158+
public void run() {
159159
try {
160-
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.3", 9300, 15), 203, 48f, 32);
161-
printer
162-
.printFormattedText(
163-
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
164-
"[L]\n" +
165-
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
166-
"[L]\n" +
167-
"[C]================================\n" +
168-
"[L]\n" +
169-
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
170-
"[L] + Size : S\n" +
171-
"[L]\n" +
172-
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
173-
"[L] + Size : 57/58\n" +
174-
"[L]\n" +
175-
"[C]--------------------------------\n" +
176-
"[R]TOTAL PRICE :[R]34.98e\n" +
177-
"[R]TAX :[R]4.23e\n" +
178-
"[L]\n" +
179-
"[C]================================\n" +
180-
"[L]\n" +
181-
"[L]<font size='tall'>Customer :</font>\n" +
182-
"[L]Raymond DUPONT\n" +
183-
"[L]5 rue des girafes\n" +
184-
"[L]31547 PERPETES\n" +
185-
"[L]Tel : +33801201456\n" +
186-
"[L]\n" +
187-
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
188-
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
189-
);
160+
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.3", 9300, 15), 203, 48f, 32);
161+
printer
162+
.printFormattedText(
163+
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
164+
"[L]\n" +
165+
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
166+
"[L]\n" +
167+
"[C]================================\n" +
168+
"[L]\n" +
169+
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
170+
"[L] + Size : S\n" +
171+
"[L]\n" +
172+
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
173+
"[L] + Size : 57/58\n" +
174+
"[L]\n" +
175+
"[C]--------------------------------\n" +
176+
"[R]TOTAL PRICE :[R]34.98e\n" +
177+
"[R]TAX :[R]4.23e\n" +
178+
"[L]\n" +
179+
"[C]================================\n" +
180+
"[L]\n" +
181+
"[L]<font size='tall'>Customer :</font>\n" +
182+
"[L]Raymond DUPONT\n" +
183+
"[L]5 rue des girafes\n" +
184+
"[L]31547 PERPETES\n" +
185+
"[L]Tel : +33801201456\n" +
186+
"[L]\n" +
187+
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
188+
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
189+
);
190190
} catch (Exception e) {
191-
e.printStackTrace();
191+
e.printStackTrace();
192192
}
193-
}
194-
}).start();
193+
}
194+
}).start();
195195
```
196196

197197
## USB
@@ -205,37 +205,37 @@ You have to check the USB permission in your app like this :
205205
```java
206206
private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
207207
private final BroadcastReceiver usbReceiver = new BroadcastReceiver() {
208-
public void onReceive(Context context, Intent intent) {
208+
public void onReceive(Context context, Intent intent) {
209209
String action = intent.getAction();
210210
if (MainActivity.ACTION_USB_PERMISSION.equals(action)) {
211-
synchronized (this) {
212-
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
213-
UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
214-
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
215-
if (usbManager != null && usbDevice != null) {
216-
// YOUR PRINT CODE HERE
211+
synchronized (this) {
212+
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
213+
UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
214+
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
215+
if (usbManager != null && usbDevice != null) {
216+
// YOUR PRINT CODE HERE
217+
}
218+
}
219+
}
217220
}
218-
}
219-
}
220-
}
221-
}
222-
};
221+
}
222+
};
223223

224224
public void printUsb() {
225-
UsbConnection usbConnection = UsbPrintersConnections.selectFirstConnected(this);
226-
UsbManager usbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
227-
if (usbConnection != null && usbManager != null) {
225+
UsbConnection usbConnection = UsbPrintersConnections.selectFirstConnected(this);
226+
UsbManager usbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
227+
if (usbConnection != null && usbManager != null) {
228228
PendingIntent permissionIntent = PendingIntent.getBroadcast(
229-
this,
230-
0,
231-
new Intent(MainActivity.ACTION_USB_PERMISSION),
232-
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0
229+
this,
230+
0,
231+
new Intent(MainActivity.ACTION_USB_PERMISSION),
232+
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0
233233
);
234234
IntentFilter filter = new IntentFilter(MainActivity.ACTION_USB_PERMISSION);
235235
registerReceiver(this.usbReceiver, filter);
236236
usbManager.requestPermission(usbConnection.getDevice(), permissionIntent);
237-
}
238-
}
237+
}
238+
}
239239
```
240240

241241
### USB code example
@@ -244,8 +244,8 @@ The code below is an example to write in your activity :
244244

245245
```java
246246
EscPosPrinter printer = new EscPosPrinter(new UsbConnection(usbManager, usbDevice), 203, 48f, 32);
247-
printer
248-
.printFormattedText(
247+
printer
248+
.printFormattedText(
249249
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM))+"</img>\n" +
250250
"[L]\n" +
251251
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
@@ -272,7 +272,7 @@ EscPosPrinter printer = new EscPosPrinter(new UsbConnection(usbManager, usbDevic
272272
"[L]\n" +
273273
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
274274
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
275-
);
275+
);
276276
```
277277

278278

escposprinter/build.gradle

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
apply plugin: 'com.android.library'
22

3+
def libraryVersionCode = 3001002
4+
def libraryVersionName = "3.1.2"
5+
36
android {
47
compileSdkVersion 31
58

69
defaultConfig {
710
minSdkVersion 16
811
targetSdkVersion 31
9-
versionCode 1
10-
versionName "1.0"
12+
versionCode libraryVersionCode
13+
versionName libraryVersionName
1114

1215
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1316
consumerProguardFiles 'consumer-rules.pro'
@@ -31,3 +34,17 @@ dependencies {
3134
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
3235
implementation 'com.google.zxing:core:3.4.0'
3336
}
37+
38+
39+
afterEvaluate {
40+
publishing {
41+
publications {
42+
release(MavenPublication) {
43+
from components.release
44+
groupId = 'com.github.DantSu'
45+
artifactId = 'ESCPOS-ThermalPrinter-Android'
46+
version = libraryVersionName
47+
}
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)