├── .gitignore
├── .idea
├── assetWizardSettings.xml
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ └── Project.xml
├── compiler.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── jarRepositories.xml
├── markdown-navigator-enh.xml
├── markdown-navigator.xml
├── misc.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── ru
│ │ └── a402d
│ │ └── texttoprint
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── html.html
│ ├── ic_launcher-web.png
│ ├── java
│ │ └── ru
│ │ │ └── a402d
│ │ │ └── texttoprint
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-hdpi
│ │ └── print.png
│ │ ├── drawable-ldpi
│ │ └── print.png
│ │ ├── drawable-mdpi
│ │ └── print.png
│ │ ├── drawable-xhdpi
│ │ └── print.png
│ │ ├── drawable-xxhdpi
│ │ └── print.png
│ │ ├── drawable-xxxhdpi
│ │ └── print.png
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── ru
│ └── a402d
│ └── texttoprint
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | xmlns:android
32 |
33 | ^$
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | xmlns:.*
43 |
44 | ^$
45 |
46 |
47 | BY_NAME
48 |
49 |
50 |
51 |
52 |
53 |
54 | .*:id
55 |
56 | http://schemas.android.com/apk/res/android
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | .*:name
66 |
67 | http://schemas.android.com/apk/res/android
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | name
77 |
78 | ^$
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | style
88 |
89 | ^$
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | .*
99 |
100 | ^$
101 |
102 |
103 | BY_NAME
104 |
105 |
106 |
107 |
108 |
109 |
110 | .*
111 |
112 | http://schemas.android.com/apk/res/android
113 |
114 |
115 | ANDROID_ATTRIBUTE_ORDER
116 |
117 |
118 |
119 |
120 |
121 |
122 | .*
123 |
124 | .*
125 |
126 |
127 | BY_NAME
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator-enh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TextToPrint
2 | ### Demo how print use PrintDocumentAdapter for WebView
3 |
4 | Since other software developers are too lazy to implement printing,
5 | I did it for them.
6 |
7 | The application is the simplest. One screen. WebView and print button.
8 | Gets text through the processing of Intent.View and Intent.SEND ("Open with" and "Share"). Having received the text makes it the simplest html.
9 |
10 | **see** [createWebPrintJob()](https://github.com/402d/TextToPrint/blob/master/app/src/main/java/ru/a402d/texttoprint/MainActivity.java#L375)
11 |
12 | In the settings 4 font sizes.
13 | Font A and Font B are suitable for printing on a thermal printer (58mm roll of cash tape)
14 | Font D - the smallest (80 characters per line on A4 printer)
15 |
16 | The application DOES NOT PRINT yourself. By the print button, a standard PrintDocumentAdapter for WebView is created.
17 |
18 | ## How to use the example of the clipboard.
19 | Select text -> Share -> TextToPrint -> Printer Icon -> Standard Print Preview Dialog.
20 |
21 | ## TextToPrint on Google Play
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 35
5 | defaultConfig {
6 | applicationId "ru.a402d.texttoprint"
7 | minSdkVersion 21
8 | targetSdkVersion 35
9 | versionCode 9
10 | versionName "1.7"
11 | multiDexEnabled = true
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled true
17 | shrinkResources true
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | compileOptions {
22 | sourceCompatibility JavaVersion.VERSION_1_8
23 | targetCompatibility JavaVersion.VERSION_1_8
24 | }
25 | namespace 'ru.a402d.texttoprint'
26 | }
27 |
28 | dependencies {
29 | implementation 'androidx.appcompat:appcompat:1.7.0'
30 | implementation 'com.google.android.material:material:1.12.0'
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 | testImplementation 'junit:junit:4.13.2'
33 | androidTestImplementation 'androidx.test:runner:1.6.2'
34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35 | }
36 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
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
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/ru/a402d/texttoprint/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package ru.a402d.texttoprint;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("ru.a402d.texttoprint", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
16 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/assets/html.html:
--------------------------------------------------------------------------------
1 | Text To Print
2 | It is very simple app.
3 |
4 | Receive Intent.SEND or Intent.VIEW with text/plain
5 | Place text into WebVIEW
6 | Create print document adapter
7 |
8 | Font A (32 chars on 58mm Roll)
9 | 123456789 123456789 123456789 12
10 | Font B (42 chars on 58mm Roll)
11 | 123456789 123456789 123456789 123456789 12
12 | Font C (65 chars in line on A4)
13 | 123456789 123456789 123456789 123456789 123456789 123456789 12345
14 | Font D (80 chars in line on A4)
15 | 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567890
16 |
17 |
18 | APP SOURCE CODE
19 | https://github.com/402d/TextToPrint
20 | Copyright 2018-2020, 402d
21 | The Unlicense
22 | http://unlicense.org
23 |
24 |
25 | USED OPEN SOURCE LIBRARY
26 | Android In-App Billing v3 Library
27 | https://github.com/anjlab/android-inapp-billing-v3
28 | Copyright 2014 AnjLab
29 | Apache License, 2.0
30 | http://www.apache.org/licenses/LICENSE-2.0
31 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/ru/a402d/texttoprint/MainActivity.java:
--------------------------------------------------------------------------------
1 | package ru.a402d.texttoprint;
2 |
3 | import android.Manifest;
4 | import android.annotation.SuppressLint;
5 | import android.content.ClipData;
6 | import android.content.ClipboardManager;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.SharedPreferences;
10 | import android.content.pm.PackageManager;
11 | import android.net.Uri;
12 | import android.os.Build;
13 | import android.os.Bundle;
14 | import android.os.CancellationSignal;
15 | import android.os.ParcelFileDescriptor;
16 | import android.print.PageRange;
17 | import android.print.PrintAttributes;
18 | import android.print.PrintDocumentAdapter;
19 | import android.print.PrintManager;
20 | import android.util.Log;
21 | import android.view.Menu;
22 | import android.view.MenuItem;
23 | import android.webkit.WebView;
24 | import java.io.BufferedReader;
25 | import java.io.IOException;
26 | import java.io.InputStream;
27 | import java.io.InputStreamReader;
28 | import java.nio.charset.StandardCharsets;
29 | import java.util.Locale;
30 | import java.util.Objects;
31 |
32 | import androidx.annotation.NonNull;
33 | import androidx.appcompat.app.AppCompatActivity;
34 | import androidx.appcompat.widget.Toolbar;
35 | import androidx.core.view.MenuCompat;
36 |
37 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
38 |
39 | public class MainActivity extends AppCompatActivity {
40 | private final static String TAG = "Antson";
41 | private double fontSize = 17;
42 | private double printFontSize = 26;
43 | private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 777;
44 |
45 | SharedPreferences sPref;
46 | final String SAVED_SIZE = "saved_size";
47 |
48 | final String htmlHead = "" +
49 | "" +
50 | "" +
57 | "" +
58 | "";
59 | String htmlBody = "";
60 | final String htmlFooter = "";
61 |
62 | WebView webView;
63 |
64 |
65 |
66 | FloatingActionButton fab;
67 |
68 | @Override
69 | protected void onCreate(Bundle savedInstanceState) {
70 | super.onCreate(savedInstanceState);
71 | setContentView(R.layout.activity_main);
72 | Toolbar toolbar = findViewById(R.id.toolbar);
73 | setSupportActionBar(toolbar);
74 |
75 | fab = findViewById(R.id.fab);
76 | fab.setOnClickListener(view -> createWebPrintJob(webView));
77 |
78 |
79 | webView = findViewById(R.id.wview);
80 |
81 | htmlBody = readAssets("html.html");
82 |
83 | sPref = getPreferences(MODE_PRIVATE);
84 | int savedSize = sPref.getInt(SAVED_SIZE, 1);
85 | setFont(savedSize);
86 |
87 | }
88 |
89 | @Override
90 | protected void onResume() {
91 | super.onResume();
92 | fab.setEnabled(true);
93 | }
94 |
95 | // read html body from assets
96 | private String readAssets(@SuppressWarnings("SameParameterValue") String fileName) {
97 | try {
98 | StringBuilder buf = new StringBuilder();
99 | InputStream inputStream = getAssets().open(fileName);
100 | BufferedReader in =
101 | new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
102 | String str;
103 |
104 | while ((str = in.readLine()) != null) {
105 | buf.append(str);
106 | }
107 | in.close();
108 | return buf.toString();
109 | } catch (Exception e) {
110 | return "";
111 | }
112 |
113 | }
114 |
115 | private void parseIntent(Intent intent) {
116 |
117 |
118 | String action = intent.getAction();
119 | if (action == null || action.equals(Intent.ACTION_MAIN)) {
120 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + htmlBody + htmlFooter, "text/html; charset=utf-8", "utf-8");
121 | return;
122 | }
123 | if (action.equals(Intent.ACTION_VIEW)) {
124 | fileBePrinted(intent.getData());
125 | return;
126 | }
127 |
128 | Bundle extras;
129 |
130 | if (action.equals(Intent.ACTION_SEND)) {
131 | extras = intent.getExtras();
132 | if (extras == null) {
133 | htmlBody = "Error ACTION_SEND no Extras
";
134 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + htmlBody + htmlFooter, "text/html; charset=utf-8", "utf-8");
135 | return;
136 | }
137 | Uri uri = extras.getParcelable(Intent.EXTRA_STREAM);
138 | String stringText = extras.getString(Intent.EXTRA_TEXT);
139 | if (uri != null) {
140 | fileBePrinted(uri);
141 | return;
142 | }
143 | if (stringText == null || stringText.trim().length() == 0) {
144 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + htmlBody + htmlFooter, "text/html; charset=utf-8", "utf-8");
145 | return;
146 | }
147 | stringBePrinted(stringText);
148 | }
149 |
150 | }
151 |
152 | private void stringBePrinted(String s) {
153 | String[] separated = s.split("\n");
154 | StringBuilder ss = new StringBuilder();
155 | for (String v : separated) {
156 | ss.append(v);
157 | ss.append(" ");
158 | }
159 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + ss.toString() + htmlFooter, "text/html; charset=utf-8", "utf-8");
160 | // createWebPrintJob(webView);
161 | }
162 |
163 | private void fileBePrinted(Uri uri) {
164 | BufferedReader br = null;
165 | StringBuilder sb = new StringBuilder();
166 | String line;
167 | try {
168 | InputStream inputStream = getContentResolver().openInputStream(uri);
169 | br = new BufferedReader(new InputStreamReader(Objects.requireNonNull(inputStream)));
170 | while ((line = br.readLine()) != null) {
171 | sb.append(line).append(" ");
172 | }
173 |
174 | } catch (Exception e) {
175 | sb.append(e.getMessage());
176 | } finally {
177 | if (br != null) {
178 | try {
179 | br.close();
180 | } catch (IOException e) {
181 | e.printStackTrace();
182 | }
183 | }
184 | }
185 |
186 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + sb.toString() + htmlFooter, "text/html; charset=utf-8", "utf-8");
187 | // createWebPrintJob(webView);
188 | }
189 |
190 |
191 | public boolean onCreateOptionsMenu(@NonNull Menu menu) {
192 | MenuCompat.setGroupDividerEnabled(menu, true);
193 |
194 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
195 | menu.add(0, 1, 1, "Grant READ");
196 | }
197 | menu.add(1, 7, 2, "Demo text");
198 | menu.add(1, 9, 4, "Insert clipboard");
199 | menu.add(2, 2, 6, "Font A");
200 | menu.add(2, 3, 7, "Font B");
201 | menu.add(2, 4, 8, "Font C");
202 | menu.add(2, 5, 9, "Font D");
203 | return super.onCreateOptionsMenu(menu);
204 | }
205 |
206 | @Override
207 | public boolean onOptionsItemSelected(MenuItem item) {
208 | int id = item.getItemId();
209 | if (id == android.R.id.home) {
210 | finish();
211 | } else if (id == 1) {
212 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
213 | if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
214 | != PackageManager.PERMISSION_GRANTED) {
215 |
216 | requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
217 | MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
218 |
219 | }
220 | }
221 | } else if (id == 2) {
222 | saveFont(1);
223 | setFont(1);
224 | } else if (id == 3) {
225 | saveFont(2);
226 | setFont(2);
227 | } else if (id == 4) {
228 | saveFont(3);
229 | setFont(3);
230 | } else if (id == 5) {
231 | saveFont(4);
232 | setFont(4);
233 | } else if (id == 7) {
234 | htmlBody = readAssets("html.html");
235 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + htmlBody + htmlFooter, "text/html; charset=utf-8", "utf-8");
236 |
237 | } else if (id == 9) {
238 | try {
239 | ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
240 | ClipData buf = Objects.requireNonNull(clipboard.getPrimaryClip());
241 | stringBePrinted(buf.getItemAt(0).coerceToText(this).toString());
242 | } catch (Exception e) {
243 | e.getStackTrace();
244 | }
245 |
246 | }
247 | return super.onOptionsItemSelected(item);
248 | }
249 |
250 | @SuppressLint("ApplySharedPref")
251 | private void saveFont(int i) {
252 | sPref = getPreferences(MODE_PRIVATE);
253 | SharedPreferences.Editor ed = sPref.edit();
254 | ed.putInt(SAVED_SIZE, i);
255 | ed.commit();
256 | }
257 |
258 | private void setFont(int s) {
259 | switch (s) {
260 | case 1:
261 | fontSize = 17;
262 | printFontSize = 26;
263 | break;
264 | case 2:
265 | fontSize = 13;
266 | printFontSize = 20;
267 | break;
268 | case 3:
269 | fontSize = 8.5;
270 | printFontSize = 17;
271 | break;
272 | case 4:
273 | fontSize = 8.5;
274 | printFontSize = 14;
275 | break;
276 | }
277 |
278 | parseIntent(getIntent());
279 | }
280 |
281 | @Override
282 | public void onRequestPermissionsResult(int requestCode,
283 | @NonNull String[] permissions, @NonNull int[] grantResults) {
284 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
285 | if (requestCode == MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE) {
286 | if (grantResults.length > 0
287 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
288 | parseIntent(getIntent());
289 | }
290 | }
291 | }
292 |
293 |
294 |
295 | public static class PrintDocumentAdapterWrapper extends PrintDocumentAdapter {
296 |
297 | private final PrintDocumentAdapter delegate;
298 |
299 | PrintDocumentAdapterWrapper(PrintDocumentAdapter adapter) {
300 | super();
301 | this.delegate = adapter;
302 | }
303 |
304 | @Override
305 | public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) {
306 | delegate.onLayout(oldAttributes, newAttributes, cancellationSignal, callback, extras);
307 | Log.d(TAG, "onLayout");
308 | }
309 |
310 | @Override
311 | public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) {
312 | delegate.onWrite(pages, destination, cancellationSignal, callback);
313 | Log.d(TAG, "onWrite");
314 | }
315 |
316 | public void onFinish() {
317 | delegate.onFinish();
318 | Log.d(TAG, "onFinish");
319 | }
320 |
321 | }
322 |
323 | //create a function to create the print job
324 | private void createWebPrintJob(WebView webView) {
325 | fab.setEnabled(false);
326 | //create object of print manager in your device
327 | PrintManager printManager = (PrintManager) this.getSystemService(Context.PRINT_SERVICE);
328 |
329 | //create object of print adapter
330 | PrintDocumentAdapterWrapper printAdapter = new PrintDocumentAdapterWrapper(webView.createPrintDocumentAdapter());
331 |
332 | //provide name to your newly generated pdf file
333 | String jobName = "Text2Print";
334 |
335 | //open print dialog
336 | if (printManager != null) {
337 | printManager.print(jobName, printAdapter, new PrintAttributes.Builder().setMinMargins(new PrintAttributes.Margins(0, 0, 0, 0)).build());
338 | } else {
339 | webView.loadData(String.format(Locale.US, htmlHead, fontSize, printFontSize) + "PrintManager is null" + htmlFooter, "text/html; charset=utf-8", "utf-8");
340 |
341 | }
342 | }
343 |
344 | }
345 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/drawable-hdpi/print.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/drawable-ldpi/print.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/drawable-mdpi/print.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/drawable-xhdpi/print.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/drawable-xxhdpi/print.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/drawable-xxxhdpi/print.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TextToPrint
3 | TextToPrint
4 | Billing not available
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/ru/a402d/texttoprint/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package ru.a402d.texttoprint;
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 Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | mavenCentral()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:8.7.3'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | mavenCentral()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
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=-Xmx1536m
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 | android.useAndroidX=true
15 | android.defaults.buildfeatures.buildconfig=true
16 | android.nonTransitiveRClass=false
17 | android.nonFinalResIds=false
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/402d/TextToPrint/e6c44917de681c6c5600150865bd41ffbad8237a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 15 12:40:08 MSK 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------