├── .github
└── FUNDING.yml
├── .gitignore
├── .idea
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── android-ticketView.iml
├── art
├── Screenshot_1.png
├── Screenshot_2.png
├── Screenshot_3.png
├── Screenshot_4.png
├── Screenshot_5.png
└── google_play.png
├── build.gradle
├── example
├── build.gradle
├── example.iml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── passid
│ │ └── android
│ │ └── ticketview
│ │ └── example
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── circle_full_background.xml
│ └── ic_launcher_background.xml
│ ├── layout
│ ├── activity_horiz.xml
│ ├── activity_main.xml
│ └── activity_vertical.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── vipulasri
│ │ └── ticketview
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ │ └── com
│ │ │ └── vipulasri
│ │ │ └── ticketview
│ │ │ └── sample
│ │ │ ├── BaseActivity.kt
│ │ │ ├── ExampleActivity.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── Utils.java
│ │ │ └── ViewExtentions.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── bg_oval_border_black.xml
│ │ ├── bg_oval_white.xml
│ │ ├── ic_expand_less_black_24dp.xml
│ │ ├── ic_expand_more_black_24dp.xml
│ │ ├── ic_launcher_background.xml
│ │ └── ic_qr_code.xml
│ │ ├── layout
│ │ ├── activity_example.xml
│ │ ├── activity_main.xml
│ │ ├── bottomsheet_ticket_attributes.xml
│ │ ├── content_main.xml
│ │ ├── item_background_options.xml
│ │ ├── item_border_options.xml
│ │ ├── item_corner_options.xml
│ │ ├── item_divider_options.xml
│ │ └── item_scallop_options.xml
│ │ ├── menu
│ │ └── menu_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
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── vipulasri
│ └── ticketview
│ └── sample
│ └── ExampleUnitTest.java
├── settings.gradle
└── ticketview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── src
├── androidTest
│ └── java
│ │ └── com
│ │ └── vipulasri
│ │ └── ticketview
│ │ └── ExampleInstrumentedTest.java
├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ ├── passid
│ │ │ └── android
│ │ │ │ └── ticketview
│ │ │ │ ├── TicketView.java
│ │ │ │ └── Utils.java
│ │ │ └── vipulasri
│ │ │ └── ticketview
│ │ │ ├── TicketView.java
│ │ │ └── Utils.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
└── test
│ └── java
│ └── com
│ └── vipulasri
│ └── ticketview
│ └── ExampleUnitTest.java
└── ticketview.iml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ['https://www.paypal.me/vipulasri']
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/libraries
40 | .idea/gradle.xml
41 | .idea/misc.xml
42 | .idea/caches/
43 | .idea/codeStyles/
44 |
45 | # Keystore files
46 | *.jks
47 |
48 | # External native build folder generated in Android Studio 2.2 and later
49 | .externalNativeBuild
50 |
51 | #Android Studio
52 | projectFilesBackup/
53 |
54 | #DS_STORE
55 | .DS_Store
56 | ._.DS_Store
57 | **/.DS_Store
58 | **/._.DS_Store
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android-TicketView
2 |
3 | An Android Library used to implement TicketView based on [vipulasri/TicketView Library](https://github.com/vipulasri/TicketView) in android with normal, rounded and scallop corners + some extra exciting features.
4 |
5 | ### Specs
6 | [](https://android-arsenal.com/api?level=19)
7 | [](http://www.methodscount.com/?lib=com.vipulasri%3Aticketview%3A1.0.2)
8 | [](https://github.com/vipulasri/Timeline-View/blob/master/LICENSE)
9 |
10 | ### Badges/Featured In
11 | [](https://android-arsenal.com/details/1/6521)
12 | [](https://www.androiddevdigest.com/digest-171/)
13 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | ## Sample Project
29 |
30 | For information : checkout [Sample App Code](https://github.com/passid-services/Android-TicketView/tree/master/example) in repository.
31 |
32 | ## Quick Setup
33 |
34 | ### 1. Include library
35 |
36 | **Using Gradle**
37 |
38 | ``` gradle
39 | dependencies {
40 | implementation 'com.passid.android:ticketview:1.0.0'
41 | }
42 | ```
43 |
44 | **Using Maven**
45 |
46 | ``` maven
47 |
48 | com.passid.android
49 | ticketview
50 | 1.0.0
51 | pom
52 |
53 | ```
54 |
55 | ### 2. Usage
56 | * In XML Layout :
57 |
58 | ``` java
59 |
83 |
84 |
88 |
89 |
99 |
100 |
108 |
109 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | ```
128 |
129 | * Configure using xml attributes or setters in code:
130 |
131 |
132 | Attribute Name
133 | Default Value
134 | Description
135 |
136 | app:ticketOrientation="vertical"
137 | horizontal
138 | sets orientation of divider and scallop
139 |
140 |
141 | app:ticketBackgroundColor="@android:color/black"
142 | white
143 | sets background color
144 |
145 |
146 | app:ticketScallopRadius="10dp"
147 | 20dp
148 | sets scallop radius
149 |
150 |
151 | app:ticketShowBorder="false"
152 | false
153 | shows border if `true`
154 |
155 |
156 | app:ticketBorderWidth="4dp"
157 | 2dp
158 | sets border width
159 |
160 |
161 | app:ticketBorderColor="@color/grey"
162 | black
163 | sets border color
164 |
165 |
166 | app:ticketShowDivider="true"
167 | false
168 | shows divider if `true`
169 |
170 |
171 | app:ticketDividerType="dash"
172 | normal
173 | sets type of divider ie `normal` or `dash`
174 |
175 |
176 | app:ticketDividerDesign="punch"
177 | 0dp
178 | sets the design of the designer either `color` or `punch` (punch will show as cut through displaying the background behind the ticketView.
179 |
180 |
181 | app:ticketDividerColor="@color/colorAccent"
182 | dark gray
183 | sets divider color
184 |
185 |
186 | app:ticketDividerWidth="2dp"
187 | 2dp
188 | sets divider width
189 |
190 |
191 | app:ticketDividerPadding="0dp"
192 | 10dp
193 | sets divider padding
194 |
195 |
196 | app:ticketDividerDashGap="4dp"
197 | 4dp
198 | sets divider dash gap
199 |
200 |
201 | app:ticketDividerDashLength="8dp"
202 | 8dp
203 | sets divider dash length
204 |
205 |
206 | app:ticketCornerType="rounded"
207 | normal
208 | sets type of corner ie `normal` or `rounded` or `scallop`
209 |
210 |
211 | app:ticketCornerRadius="15dp"
212 | 4dp
213 | sets corner radius if corner rounder or scallop
214 |
215 |
216 | app:ticketElevation="14dp"
217 | 0dp
218 | sets elevation to ticket view on android jellybean and above
219 |
220 |
221 | app:ticketDividerLocation="none|left|right|top|bottom"
222 | none
223 | sets the location of the divider and scallops with regards to the anchored view app:view
224 |
225 |
226 | app:view="@id/anchoredViewId"
227 | @null
228 | sets the view id in which the divider will be anchored to based on flags of app:ticketDividerLocation and ticketOrientation
229 |
230 |
231 | app:ticketPunchLocation="none|left|right|top|bottom"
232 | none
233 | Set the location where a punch through holes will be drawn on the sides of the ticket
234 |
235 |
236 | app:ticketPunchRadius="12dp"
237 | 0dp
238 | sets the radius of the punch through holes.
239 |
240 |
241 |
242 |
243 | ## License
244 |
245 |
246 | Copyright 2017 Vipul Asri
247 |
248 | Licensed under the Apache License, Version 2.0 (the "License");
249 | you may not use this file except in compliance with the License.
250 | You may obtain a copy of the License at
251 |
252 | http://www.apache.org/licenses/LICENSE-2.0
253 |
254 | Unless required by applicable law or agreed to in writing, software
255 | distributed under the License is distributed on an "AS IS" BASIS,
256 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
257 | See the License for the specific language governing permissions and
258 | limitations under the License.
259 |
--------------------------------------------------------------------------------
/android-ticketView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/art/Screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/art/Screenshot_1.png
--------------------------------------------------------------------------------
/art/Screenshot_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/art/Screenshot_2.png
--------------------------------------------------------------------------------
/art/Screenshot_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/art/Screenshot_3.png
--------------------------------------------------------------------------------
/art/Screenshot_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/art/Screenshot_4.png
--------------------------------------------------------------------------------
/art/Screenshot_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/art/Screenshot_5.png
--------------------------------------------------------------------------------
/art/google_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/art/google_play.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/example/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.passid.android.ticketview.example"
7 | minSdkVersion 19
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'androidx.appcompat:appcompat:1.1.0'
24 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'androidx.test:runner:1.2.0'
27 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
28 |
29 | implementation project(':ticketview')
30 | }
31 |
--------------------------------------------------------------------------------
/example/example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
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 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
--------------------------------------------------------------------------------
/example/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 |
--------------------------------------------------------------------------------
/example/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example/src/main/java/com/passid/android/ticketview/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.passid.android.ticketview.example;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_horiz);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/example/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/example/src/main/res/drawable/circle_full_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/example/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/example/src/main/res/layout/activity_horiz.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
33 |
34 |
41 |
42 |
57 |
58 |
68 |
69 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
110 |
111 |
118 |
119 |
134 |
135 |
145 |
146 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
187 |
188 |
195 |
196 |
211 |
212 |
222 |
223 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
264 |
265 |
272 |
273 |
288 |
289 |
299 |
300 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
341 |
342 |
349 |
350 |
365 |
366 |
377 |
378 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
--------------------------------------------------------------------------------
/example/src/main/res/layout/activity_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
34 |
35 |
42 |
43 |
58 |
59 |
69 |
70 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #D81B60
4 | #D81B60
5 | #D81B60
6 |
7 | #000
8 | #FFFFFF
9 | #C45AAA
10 | #CF3DAA
11 | #B76E9E
12 | #D5B3C4
13 | #111111
14 | #D2181818
15 | #77181818
16 | #00000000
17 | #3397EE
18 | #333333
19 | #1D1D1D
20 | #0F0F0F
21 | #242427
22 | #F1C14C
23 | #FFD55D
24 | #FFC107
25 | #393949
26 |
27 | @color/white
28 | @color/yellows
29 | @color/niyts_purple
30 | #91EC93
31 | #EC9191
32 | #686868
33 | #A2878787
34 | #07000000
35 |
36 |
--------------------------------------------------------------------------------
/example/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android-TicketView
3 |
4 |
--------------------------------------------------------------------------------
/example/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/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 | # 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 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Feb 08 12:10:31 EET 2020
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-5.1.1-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 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Sat Feb 08 12:10:33 EET 2020
8 | ndk.dir=/Users/MoAdel/Library/Android/sdk/ndk-bundle
9 | sdk.dir=/Users/MoAdel/Library/Android/sdk
10 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion versions.compileSdk
8 | buildToolsVersion versions.buildTools
9 | defaultConfig {
10 | applicationId "com.vipulasri.ticketview.sample"
11 | minSdkVersion versions.minSdk
12 | targetSdkVersion versions.targetSdk
13 | versionCode 4
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | vectorDrawables.useSupportLibrary = true
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | testImplementation 'junit:junit:4.12'
29 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
31 |
32 | //kotlin
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin.stdlib}"
34 |
35 | //support
36 | implementation "com.android.support:appcompat-v7:$versions.supportLibrary"
37 | implementation "com.android.support.constraint:constraint-layout:1.1.3"
38 | implementation "com.android.support:design:$versions.supportLibrary"
39 |
40 | //misc
41 | implementation 'com.dmitrymalkovich.android:material-design-dimens:1.4'
42 | implementation ('com.thebluealliance:spectrum:0.7.1') {
43 | exclude group: 'com.android.support'
44 | exclude module: 'appcompat-v7'
45 | exclude module: 'support-v4'
46 | }
47 | implementation ('org.adw.library:discrete-seekbar:1.0.1') {
48 | exclude group: 'com.android.support'
49 | exclude module: 'appcompat-v7'
50 | exclude module: 'support-v4'
51 | }
52 | implementation project(":ticketview")
53 | //implementation 'com.vipulasri:ticketview:1.0.3'
54 | }
55 | repositories {
56 | mavenCentral()
57 | }
58 |
--------------------------------------------------------------------------------
/sample/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 |
--------------------------------------------------------------------------------
/sample/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":3,"versionName":"1.0","enabled":true,"outputFile":"sample-release.apk","fullName":"release","baseName":"release"},"path":"sample-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/sample/src/androidTest/java/com/vipulasri/ticketview/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample;
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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.vipulasri.ticketview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/sample/src/main/java/com/vipulasri/ticketview/sample/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample
2 |
3 | import android.graphics.drawable.Drawable
4 | import android.support.v7.app.AppCompatActivity
5 | import android.support.v7.widget.Toolbar
6 | import android.view.MenuItem
7 |
8 | open class BaseActivity : AppCompatActivity() {
9 |
10 | var toolbar: Toolbar? = null
11 |
12 | //If back button is displayed in action bar, return false
13 | protected var isDisplayHomeAsUpEnabled: Boolean
14 | get() = false
15 | set(value) {
16 | whenNotNull(supportActionBar) {
17 | it.setDisplayHomeAsUpEnabled(value)
18 | }
19 |
20 | }
21 |
22 | override fun setContentView(layoutResID: Int) {
23 | super.setContentView(layoutResID)
24 |
25 | injectViews()
26 |
27 | //Displaying the back button in the action bar
28 | if (isDisplayHomeAsUpEnabled) {
29 | whenNotNull(supportActionBar) {
30 | it.setDisplayHomeAsUpEnabled(true)
31 | }
32 | }
33 | }
34 |
35 | protected fun injectViews() {
36 | toolbar = findViewById(R.id.toolbar)
37 | setupToolbar()
38 | }
39 |
40 | fun setContentViewWithoutInject(layoutResId: Int) {
41 | super.setContentView(layoutResId)
42 | }
43 |
44 | protected fun setupToolbar() {
45 | whenNotNull(toolbar) {
46 | setSupportActionBar(it)
47 | }
48 | }
49 |
50 | fun setActivityTitle(title: Int) {
51 | whenNotNull(supportActionBar) {
52 | it.setTitle(title)
53 | }
54 | }
55 |
56 | fun setActivityTitle(title: String) {
57 | whenNotNull(supportActionBar) {
58 | it.setTitle(title)
59 | }
60 | }
61 |
62 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
63 | //Menu
64 | when (item.itemId) {
65 | //When home is clicked
66 | android.R.id.home -> {
67 | onActionBarHomeIconClicked()
68 | return true
69 | }
70 | }
71 | return super.onOptionsItemSelected(item)
72 | }
73 |
74 | fun setHomeAsUpIndicator(drawable: Drawable) {
75 | whenNotNull(supportActionBar) {
76 | it.setHomeAsUpIndicator(drawable)
77 | }
78 | }
79 |
80 | //Method for when home button is clicked
81 | private fun onActionBarHomeIconClicked() {
82 | if (isDisplayHomeAsUpEnabled) {
83 | onBackPressed()
84 | } else {
85 | finish()
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/vipulasri/ticketview/sample/ExampleActivity.kt:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 |
7 |
8 | class ExampleActivity : BaseActivity() {
9 |
10 | fun launchActivity(startingActivity: Context) {
11 | val intent = Intent(startingActivity, ExampleActivity::class.java)
12 | startingActivity.startActivity(intent)
13 | }
14 |
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | setContentView(R.layout.activity_example)
18 | isDisplayHomeAsUpEnabled = true
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/vipulasri/ticketview/sample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.support.design.widget.BottomSheetBehavior
6 | import android.view.View
7 | import com.vipulasri.ticketview.TicketView
8 |
9 | import kotlinx.android.synthetic.main.content_main.*
10 | import com.thebluealliance.spectrum.SpectrumDialog
11 | import android.graphics.PorterDuff
12 | import android.support.annotation.NonNull
13 | import android.util.Log
14 | import android.view.Menu
15 | import android.view.MenuItem
16 | import android.widget.AdapterView
17 | import android.widget.ImageView
18 | import kotlinx.android.synthetic.main.item_background_options.*
19 | import kotlinx.android.synthetic.main.item_border_options.*
20 | import kotlinx.android.synthetic.main.item_divider_options.*
21 | import android.widget.RadioGroup
22 | import kotlinx.android.synthetic.main.item_scallop_options.*
23 | import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
24 | import android.widget.AdapterView.OnItemSelectedListener
25 | import android.widget.CompoundButton
26 | import kotlinx.android.synthetic.main.bottomsheet_ticket_attributes.*
27 | import kotlinx.android.synthetic.main.item_corner_options.*
28 |
29 |
30 | class MainActivity : BaseActivity() {
31 |
32 | private lateinit var mBottomSheetBehavior: BottomSheetBehavior
33 |
34 | override fun onCreate(savedInstanceState: Bundle?) {
35 | super.onCreate(savedInstanceState)
36 | setContentView(R.layout.activity_main)
37 |
38 | initOptionsBottomSheet()
39 | }
40 |
41 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
42 | menuInflater.inflate(R.menu.menu_main, menu)
43 | return true
44 | }
45 |
46 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
47 | when (item.itemId) {
48 |
49 | R.id.action_example -> {
50 | startActivity(Intent(this, ExampleActivity::class.java))
51 | return true
52 | }
53 | }
54 | return super.onOptionsItemSelected(item)
55 | }
56 |
57 |
58 | private fun initOptionsBottomSheet() {
59 | mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet)
60 |
61 | view_options_header.setOnClickListener {
62 | if (mBottomSheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
63 | mBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
64 | } else {
65 | mBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
66 | }
67 | }
68 |
69 | mBottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
70 | override fun onStateChanged(@NonNull bottomSheet: View, newState: Int) {
71 | when(newState) {
72 | BottomSheetBehavior.STATE_COLLAPSED -> image_toggle.setImageResource(R.drawable.ic_expand_less_black_24dp)
73 | BottomSheetBehavior.STATE_EXPANDED -> image_toggle.setImageResource(R.drawable.ic_expand_more_black_24dp)
74 | else -> {
75 | image_toggle.setImageResource(R.drawable.ic_expand_less_black_24dp)
76 | }
77 | }
78 | }
79 |
80 | override fun onSlide(@NonNull bottomSheet: View, slideOffset: Float) {
81 |
82 | }
83 | })
84 |
85 | image_background_color.background.setColorFilter(ticketView.backgroundColor, PorterDuff.Mode.SRC_ATOP)
86 | image_border_color.background.setColorFilter(ticketView.borderColor, PorterDuff.Mode.SRC_ATOP)
87 | image_divider_color.background.setColorFilter(ticketView.dividerColor, PorterDuff.Mode.SRC_ATOP)
88 |
89 | when(ticketView.orientation) {
90 | TicketView.Orientation.HORIZONTAL -> radioButton_horizontal.isChecked = true
91 | TicketView.Orientation.VERTICAL -> radioButton_vertical.isChecked = true
92 | }
93 |
94 | radioGroup_orientation.setOnCheckedChangeListener { group, checkedId ->
95 | when(checkedId) {
96 | R.id.radioButton_horizontal -> ticketView.orientation = TicketView.Orientation.HORIZONTAL
97 | R.id.radioButton_vertical -> ticketView.orientation = TicketView.Orientation.VERTICAL
98 | else -> {
99 | ticketView.orientation = TicketView.Orientation.HORIZONTAL
100 | }
101 | }
102 | }
103 |
104 | //background properties
105 |
106 | image_background_color.setOnClickListener {
107 | showColorPicker(ticketView.backgroundColor, image_background_color)
108 | }
109 |
110 | seekBar_elevation.setOnProgressChangeListener(progressChangeListener)
111 |
112 | //scallop properties
113 |
114 | seekBar_scallop_radius.progress = Utils.pxToDp(ticketView.scallopRadius.toFloat(), this)
115 | seekBar_scallop_radius.setOnProgressChangeListener(progressChangeListener)
116 |
117 | spinner_scallop_position.setSelection(4)
118 | spinner_scallop_position.onItemSelectedListener = object : OnItemSelectedListener {
119 | override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
120 | val selectedItem = parent.getItemAtPosition(position).toString()
121 | ticketView.scallopPositionPercent = selectedItem.toFloat()
122 | }
123 |
124 | override fun onNothingSelected(parent: AdapterView<*>) {
125 |
126 | }
127 | }
128 |
129 | //border properties
130 |
131 | ticketView.isShowBorder = false
132 | checkbox_show_border.isChecked = false
133 | checkbox_show_border.setOnCheckedChangeListener { compoundButton, checked ->
134 | ticketView.isShowBorder = checked
135 | }
136 |
137 | seekBar_border_width.progress = Utils.pxToDp(ticketView.borderWidth.toFloat(), this)
138 | seekBar_border_width.setOnProgressChangeListener(progressChangeListener)
139 |
140 | image_border_color.setOnClickListener {
141 | showColorPicker(ticketView.borderColor, image_border_color)
142 | }
143 |
144 | //divider properties
145 |
146 | ticketView.isShowDivider = true
147 | checkbox_show_divider.isChecked = true
148 | checkbox_show_divider.setOnCheckedChangeListener { compoundButton, checked ->
149 | ticketView.isShowDivider = checked
150 | }
151 |
152 | image_divider_color.setOnClickListener {
153 | showColorPicker(ticketView.dividerColor, image_divider_color)
154 | }
155 |
156 | spinner_divider_type.setSelection(1)
157 | spinner_divider_type.onItemSelectedListener = object : OnItemSelectedListener {
158 | override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
159 | val selectedItem = parent.getItemAtPosition(position).toString()
160 | when (selectedItem) {
161 | "Normal" -> ticketView.dividerType = TicketView.DividerType.NORMAL
162 | "Dashed" -> ticketView.dividerType = TicketView.DividerType.DASH
163 | else -> {
164 | ticketView.dividerType = TicketView.DividerType.NORMAL
165 | }
166 | }
167 | }
168 |
169 | override fun onNothingSelected(parent: AdapterView<*>) {
170 |
171 | }
172 | }
173 |
174 | seekBar_divider_width.progress = Utils.pxToDp(ticketView.dividerWidth.toFloat(), this)
175 | seekBar_divider_width.setOnProgressChangeListener(progressChangeListener)
176 |
177 | seekBar_divider_padding.progress = Utils.pxToDp(ticketView.dividerPadding.toFloat(), this)
178 | seekBar_divider_padding.setOnProgressChangeListener(progressChangeListener)
179 |
180 | seekBar_divider_dash_length.progress = Utils.pxToDp(ticketView.dividerDashLength.toFloat(), this)
181 | seekBar_divider_dash_length.setOnProgressChangeListener(progressChangeListener)
182 |
183 | seekBar_divider_dash_gap.progress = Utils.pxToDp(ticketView.dividerDashGap.toFloat(), this)
184 | seekBar_divider_dash_gap.setOnProgressChangeListener(progressChangeListener)
185 |
186 | //corner properties
187 |
188 | spinner_corner_type.setSelection(0)
189 | spinner_corner_type.onItemSelectedListener = object : OnItemSelectedListener {
190 | override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
191 | val selectedItem = parent.getItemAtPosition(position).toString()
192 | when (selectedItem) {
193 | "Normal" -> ticketView.cornerType = TicketView.CornerType.NORMAL
194 | "Rounded" -> ticketView.cornerType = TicketView.CornerType.ROUNDED
195 | "Scallop" -> ticketView.cornerType = TicketView.CornerType.SCALLOP
196 | else -> {
197 | ticketView.cornerType = TicketView.CornerType.NORMAL
198 | }
199 | }
200 | }
201 |
202 | override fun onNothingSelected(parent: AdapterView<*>) {
203 |
204 | }
205 | }
206 |
207 | seekBar_corner_radius.progress = Utils.pxToDp(ticketView.cornerRadius.toFloat(), this)
208 | seekBar_corner_radius.setOnProgressChangeListener(progressChangeListener)
209 |
210 | }
211 |
212 | private fun showColorPicker(selectedColor : Int, colorView: ImageView) {
213 | SpectrumDialog.Builder(this)
214 | .setColors(R.array.colors)
215 | .setSelectedColor(selectedColor)
216 | .setDismissOnColorSelected(true)
217 | .setOutlineWidth(1)
218 | .setOnColorSelectedListener { positiveResult, color ->
219 | if (positiveResult) {
220 | colorView.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
221 |
222 | when(colorView.id) {
223 | R.id.image_border_color -> ticketView.borderColor = color
224 | R.id.image_divider_color -> ticketView.dividerColor = color
225 | R.id.image_background_color -> ticketView.backgroundColor = color
226 | else -> {
227 | //do nothing
228 | }
229 | }
230 |
231 | }
232 | }.build().show(supportFragmentManager, "ColorPicker")
233 | }
234 |
235 | private var progressChangeListener: DiscreteSeekBar.OnProgressChangeListener = object : DiscreteSeekBar.OnProgressChangeListener {
236 |
237 | override fun onProgressChanged(discreteSeekBar: DiscreteSeekBar, value: Int, b: Boolean) {
238 |
239 | val valueInDp = Utils.dpToPx(value.toFloat(), this@MainActivity)
240 | Log.d("TAG", "->"+discreteSeekBar.id)
241 | when(discreteSeekBar.id) {
242 | R.id.seekBar_elevation -> ticketView.setTicketElevation(valueInDp.toFloat())
243 | R.id.seekBar_border_width -> ticketView.borderWidth = valueInDp
244 | R.id.seekBar_scallop_radius -> ticketView.scallopRadius = valueInDp
245 | R.id.seekBar_divider_width -> ticketView.dividerWidth = valueInDp
246 | R.id.seekBar_divider_padding -> ticketView.dividerPadding = valueInDp
247 | R.id.seekBar_divider_dash_length -> ticketView.dividerDashLength = valueInDp
248 | R.id.seekBar_divider_dash_gap -> ticketView.dividerDashGap = valueInDp
249 | R.id.seekBar_corner_radius -> ticketView.cornerRadius = valueInDp
250 | }
251 | }
252 |
253 | override fun onStartTrackingTouch(discreteSeekBar: DiscreteSeekBar) {
254 |
255 | }
256 |
257 | override fun onStopTrackingTouch(discreteSeekBar: DiscreteSeekBar) {
258 |
259 | }
260 | }
261 |
262 | override fun onBackPressed() {
263 | if(mBottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
264 | mBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
265 | } else {
266 | super.onBackPressed()
267 | }
268 | }
269 | }
270 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/vipulasri/ticketview/sample/Utils.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.TypedValue;
6 |
7 | public class Utils {
8 |
9 | public static int dpToPx(float dp, Context context) {
10 | return dpToPx(dp, context.getResources());
11 | }
12 |
13 | public static int dpToPx(float dp, Resources resources) {
14 | float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
15 | return (int) px;
16 | }
17 |
18 | public static int pxToDp(float px, Context context) {
19 | float dp = px / context.getResources().getDisplayMetrics().density;
20 | return (int) dp;
21 | }
22 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/vipulasri/ticketview/sample/ViewExtentions.kt:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample
2 |
3 | import android.support.annotation.LayoutRes
4 | import android.view.*
5 |
6 | fun inflateView(@LayoutRes layoutResId: Int, parent: ViewGroup, attachToRoot: Boolean): View {
7 | return LayoutInflater.from(parent.context).inflate(layoutResId, parent, attachToRoot)
8 | }
9 |
10 | inline fun whenNotNull(input: T?, callback: (T)->R): R? {
11 | return input?.let(callback)
12 | }
13 |
14 | infix fun Boolean.then(param: T): T? = if(this) param else null
15 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/bg_oval_border_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/bg_oval_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_expand_less_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_expand_more_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_qr_code.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_example.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
32 |
33 |
48 |
49 |
55 |
56 |
65 |
66 |
75 |
76 |
83 |
84 |
85 |
86 |
96 |
97 |
103 |
104 |
110 |
111 |
117 |
118 |
123 |
124 |
130 |
131 |
137 |
138 |
144 |
145 |
146 |
147 |
153 |
154 |
160 |
161 |
167 |
168 |
174 |
175 |
176 |
177 |
183 |
184 |
190 |
191 |
197 |
198 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/bottomsheet_ticket_attributes.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
44 |
51 |
52 |
55 |
56 |
63 |
64 |
70 |
71 |
78 |
79 |
80 |
81 |
84 |
85 |
86 |
87 |
90 |
91 |
92 |
93 |
96 |
97 |
98 |
99 |
102 |
103 |
104 |
105 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_background_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
18 |
19 |
22 |
23 |
29 |
30 |
31 |
32 |
38 |
39 |
44 |
45 |
51 |
52 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_border_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
17 |
18 |
23 |
24 |
28 |
29 |
30 |
31 |
37 |
38 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
65 |
66 |
72 |
73 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_corner_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
18 |
19 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
44 |
45 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_divider_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
17 |
18 |
23 |
24 |
28 |
29 |
30 |
31 |
37 |
38 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
65 |
66 |
72 |
73 |
74 |
75 |
81 |
82 |
87 |
88 |
94 |
95 |
100 |
101 |
102 |
103 |
104 |
105 |
111 |
112 |
117 |
118 |
124 |
125 |
126 |
127 |
133 |
134 |
139 |
140 |
146 |
147 |
148 |
149 |
155 |
156 |
161 |
162 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_scallop_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
18 |
19 |
22 |
23 |
29 |
30 |
31 |
32 |
38 |
39 |
42 |
43 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/passid-services/Android-TicketView/44e93bb9a02e8a26e438b30b93bacda14a247131/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #E71844
4 | #DE1B42
5 | #FFC857
6 |
7 | #1FE71844
8 |
9 |
10 | - @color/material_red_500
11 | - @color/material_pink_500
12 | - @color/material_purple_500
13 | - @color/material_deep_purple_500
14 | - @color/material_indigo_500
15 | - @color/material_blue_500
16 | - @color/material_light_blue_500
17 | - @color/material_cyan_500
18 | - @color/material_teal_500
19 | - @color/material_green_500
20 | - @color/material_light_green_500
21 | - @color/material_lime_500
22 | - @color/material_yellow_500
23 | - @color/material_amber_500
24 | - @color/material_orange_500
25 | - @color/material_deep_orange_500
26 | - @color/material_brown_500
27 | - @color/material_grey_500
28 | - @color/material_blue_grey_500
29 | - @color/material_light_white
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #E71844
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Ticket View
3 | Settings
4 | Options
5 | Orientation
6 | Horizontal
7 | Vertical
8 | Scallop
9 | Background Color
10 | Ticket Options
11 | Border
12 | Divider
13 | Radius
14 | Elevation
15 | Position(in %)
16 | Color
17 | Width
18 | Padding
19 | Enable
20 | Type
21 | Dash Length
22 | Dash Gap
23 | Ticket Attributes
24 |
25 | 2h 13min
26 | Adventure, Fantasy, Action
27 | 400–2000–2020
28 | Date
29 | 01–03–2017
30 | Time
31 | 23:30
32 | Seat
33 | C5-C8
34 | Corners
35 | Example
36 | Background
37 |
38 |
39 | - Normal
40 | - Dashed
41 |
42 |
43 |
44 | - 10
45 | - 20
46 | - 30
47 | - 40
48 | - 50
49 | - 60
50 | - 70
51 | - 80
52 | - 90
53 | - 100
54 |
55 |
56 |
57 | - Normal
58 | - Rounded
59 | - Scallop
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
25 |
29 |
30 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/sample/src/test/java/com/vipulasri/ticketview/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview.sample;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':example', ':ticketview'
2 |
--------------------------------------------------------------------------------
/ticketview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ticketview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayRepoName = 'TicketView'
6 |
7 | groupId = 'com.passid.android'
8 | libraryName = 'TicketView'
9 | artifact = 'ticketview'
10 | libraryVersion = '1.0.0'
11 | libraryDescription = 'A TicketView for android. By PASSiD'
12 |
13 | siteUrl = 'https://github.com/passid-services/Android-TicketView'
14 | gitUrl = 'https://github.com/passid-services/Android-TicketView.git'
15 |
16 | developerId = 'passid'
17 | developerName = 'PASSiD'
18 | developerEmail = 'hello@getpassid.com'
19 |
20 | licenseName = 'The Apache Software License, Version 2.0'
21 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
22 | licenses = ["Apache-2.0"]
23 | }
24 |
25 | android {
26 | compileSdkVersion 28
27 |
28 |
29 | defaultConfig {
30 | minSdkVersion 19
31 | targetSdkVersion 28
32 | versionCode 1
33 | versionName "1.0"
34 |
35 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
36 |
37 | }
38 |
39 | buildTypes {
40 | release {
41 | minifyEnabled false
42 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
43 | }
44 | }
45 |
46 | }
47 |
48 | dependencies {
49 | implementation fileTree(dir: 'libs', include: ['*.jar'])
50 |
51 | implementation 'androidx.appcompat:appcompat:1.1.0'
52 | testImplementation 'junit:junit:4.12'
53 | androidTestImplementation 'androidx.test:runner:1.2.0'
54 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
55 | }
56 |
--------------------------------------------------------------------------------
/ticketview/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 |
--------------------------------------------------------------------------------
/ticketview/src/androidTest/java/com/vipulasri/ticketview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview;
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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.vipulasri.ticketview.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ticketview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/ticketview/src/main/java/com/passid/android/ticketview/Utils.java:
--------------------------------------------------------------------------------
1 | package com.passid.android.ticketview;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.TypedValue;
6 |
7 | public class Utils {
8 |
9 | public static int dpToPx(float dp, Context context) {
10 | return dpToPx(dp, context.getResources());
11 | }
12 |
13 | public static int dpToPx(float dp, Resources resources) {
14 | float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
15 | return (int) px;
16 | }
17 | }
--------------------------------------------------------------------------------
/ticketview/src/main/java/com/vipulasri/ticketview/TicketView.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 | import android.graphics.DashPathEffect;
8 | import android.graphics.Paint;
9 | import android.graphics.Path;
10 | import android.graphics.PathEffect;
11 | import android.graphics.PorterDuffColorFilter;
12 | import android.graphics.RectF;
13 | import android.renderscript.Allocation;
14 | import android.renderscript.Element;
15 | import android.renderscript.RenderScript;
16 | import android.renderscript.ScriptIntrinsicBlur;
17 | import android.support.annotation.IntDef;
18 | import android.util.AttributeSet;
19 | import android.util.Log;
20 | import android.view.View;
21 |
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 |
25 | import static android.graphics.Bitmap.Config.ALPHA_8;
26 | import static android.graphics.Color.BLACK;
27 | import static android.graphics.Color.TRANSPARENT;
28 | import static android.graphics.Paint.ANTI_ALIAS_FLAG;
29 | import static android.graphics.PorterDuff.Mode.SRC_IN;
30 |
31 | /**
32 | * Created by Vipul Asri on 31/10/17.
33 | */
34 |
35 | public class TicketView extends View {
36 |
37 | public static final String TAG = TicketView.class.getSimpleName();
38 |
39 | @Retention(RetentionPolicy.SOURCE)
40 | @IntDef({Orientation.HORIZONTAL, Orientation.VERTICAL})
41 | public @interface Orientation {
42 | int HORIZONTAL = 0;
43 | int VERTICAL = 1;
44 | }
45 |
46 | @Retention(RetentionPolicy.SOURCE)
47 | @IntDef({DividerType.NORMAL, DividerType.DASH})
48 | public @interface DividerType {
49 | int NORMAL = 0;
50 | int DASH = 1;
51 | }
52 |
53 | @Retention(RetentionPolicy.SOURCE)
54 | @IntDef({CornerType.NORMAL, CornerType.ROUNDED})
55 | public @interface CornerType {
56 | int NORMAL = 0;
57 | int ROUNDED = 1;
58 | int SCALLOP = 2;
59 | }
60 |
61 | private Paint mBackgroundPaint = new Paint();
62 | private Paint mBorderPaint = new Paint();
63 | private Paint mDividerPaint = new Paint();
64 | private int mOrientation;
65 | private Path mPath = new Path();
66 | private boolean mDirty = true;
67 | private float mDividerStartX, mDividerStartY, mDividerStopX, mDividerStopY;
68 | private RectF mRect = new RectF();
69 | private RectF mRoundedCornerArc = new RectF();
70 | private RectF mScallopCornerArc = new RectF();
71 | private int mScallopHeight;
72 | private float mScallopPosition;
73 | private float mScallopPositionPercent;
74 | private int mBackgroundColor;
75 | private boolean mShowBorder;
76 | private int mBorderWidth;
77 | private int mBorderColor;
78 | private boolean mShowDivider;
79 | private int mScallopRadius;
80 | private int mDividerDashLength;
81 | private int mDividerDashGap;
82 | private int mDividerType;
83 | private int mDividerWidth;
84 | private int mDividerColor;
85 | private int mCornerType;
86 | private int mCornerRadius;
87 | private int mDividerPadding;
88 | private Bitmap mShadow;
89 | private final Paint mShadowPaint = new Paint(ANTI_ALIAS_FLAG);
90 | private float mShadowBlurRadius = 0f;
91 |
92 | public TicketView(Context context) {
93 | super(context);
94 | init(null);
95 | }
96 |
97 | public TicketView(Context context, AttributeSet attrs) {
98 | super(context, attrs);
99 | init(attrs);
100 | }
101 |
102 | public TicketView(Context context, AttributeSet attrs, int defStyleAttr) {
103 | super(context, attrs, defStyleAttr);
104 | init(attrs);
105 | }
106 |
107 | @Override
108 | protected void onDraw(Canvas canvas) {
109 | super.onDraw(canvas);
110 | if (mDirty) {
111 | doLayout();
112 | }
113 | if (mShadowBlurRadius > 0f && !isInEditMode()) {
114 | canvas.drawBitmap(mShadow, 0f, mShadowBlurRadius / 2f, null);
115 | }
116 | canvas.drawPath(mPath, mBackgroundPaint);
117 | if (mShowBorder) {
118 | canvas.drawPath(mPath, mBorderPaint);
119 | }
120 | if (mShowDivider) {
121 | canvas.drawLine(mDividerStartX, mDividerStartY, mDividerStopX, mDividerStopY, mDividerPaint);
122 | }
123 | }
124 |
125 | private void doLayout() {
126 | float offset;
127 | float left = getPaddingLeft() + mShadowBlurRadius;
128 | float right = getWidth() - getPaddingRight() - mShadowBlurRadius;
129 | float top = getPaddingTop() + (mShadowBlurRadius / 2);
130 | float bottom = getHeight() - getPaddingBottom() - mShadowBlurRadius - (mShadowBlurRadius / 2);
131 | mPath.reset();
132 |
133 | if (mOrientation == Orientation.HORIZONTAL) {
134 | offset = ((top + bottom) / mScallopPosition) - mScallopRadius;
135 |
136 | if (mCornerType == CornerType.ROUNDED) {
137 | mPath.arcTo(getTopLeftCornerRoundedArc(top, left), 180.0f, 90.0f, false);
138 | mPath.lineTo(left + mCornerRadius, top);
139 |
140 | mPath.lineTo(right - mCornerRadius, top);
141 | mPath.arcTo(getTopRightCornerRoundedArc(top, right), -90.0f, 90.0f, false);
142 |
143 | } else if (mCornerType == CornerType.SCALLOP) {
144 | mPath.arcTo(getTopLeftCornerScallopArc(top, left), 90.0f, -90.0f, false);
145 | mPath.lineTo(left + mCornerRadius, top);
146 |
147 | mPath.lineTo(right - mCornerRadius, top);
148 | mPath.arcTo(getTopRightCornerScallopArc(top, right), 180.0f, -90.0f, false);
149 |
150 | } else {
151 | mPath.moveTo(left, top);
152 | mPath.lineTo(right, top);
153 | }
154 |
155 | mRect.set(right - mScallopRadius, top + offset, right + mScallopRadius, mScallopHeight + offset + top);
156 | mPath.arcTo(mRect, 270, -180.0f, false);
157 |
158 | if (mCornerType == CornerType.ROUNDED) {
159 |
160 | mPath.arcTo(getBottomRightCornerRoundedArc(bottom, right), 0.0f, 90.0f, false);
161 | mPath.lineTo(right - mCornerRadius, bottom);
162 |
163 | mPath.lineTo(left + mCornerRadius, bottom);
164 | mPath.arcTo(getBottomLeftCornerRoundedArc(left, bottom), 90.0f, 90.0f, false);
165 |
166 | } else if (mCornerType == CornerType.SCALLOP) {
167 |
168 | mPath.arcTo(getBottomRightCornerScallopArc(bottom, right), 270.0f, -90.0f, false);
169 | mPath.lineTo(right - mCornerRadius, bottom);
170 |
171 | mPath.lineTo(left + mCornerRadius, bottom);
172 | mPath.arcTo(getBottomLeftCornerScallopArc(left, bottom), 0.0f, -90.0f, false);
173 |
174 | } else {
175 | mPath.lineTo(right, bottom);
176 | mPath.lineTo(left, bottom);
177 | }
178 |
179 | mRect.set(left - mScallopRadius, top + offset, left + mScallopRadius, mScallopHeight + offset + top);
180 | mPath.arcTo(mRect, 90.0f, -180.0f, false);
181 | mPath.close();
182 |
183 | } else {
184 | offset = (((right + left) / mScallopPosition) - mScallopRadius);
185 |
186 | if (mCornerType == CornerType.ROUNDED) {
187 | mPath.arcTo(getTopLeftCornerRoundedArc(top, left), 180.0f, 90.0f, false);
188 | mPath.lineTo(left + mCornerRadius, top);
189 |
190 | } else if (mCornerType == CornerType.SCALLOP) {
191 |
192 | mPath.arcTo(getTopLeftCornerScallopArc(top, left), 90.0f, -90.0f, false);
193 | mPath.lineTo(left + mCornerRadius, top);
194 |
195 | } else {
196 | mPath.moveTo(left, top);
197 | }
198 |
199 | mRect.set(left + offset, top - mScallopRadius, mScallopHeight + offset + left, top + mScallopRadius);
200 | mPath.arcTo(mRect, 180.0f, -180.0f, false);
201 |
202 | if (mCornerType == CornerType.ROUNDED) {
203 |
204 | mPath.lineTo(right - mCornerRadius, top);
205 | mPath.arcTo(getTopRightCornerRoundedArc(top, right), -90.0f, 90.0f, false);
206 |
207 | mPath.arcTo(getBottomRightCornerRoundedArc(bottom, right), 0.0f, 90.0f, false);
208 | mPath.lineTo(right - mCornerRadius, bottom);
209 |
210 | } else if (mCornerType == CornerType.SCALLOP) {
211 |
212 | mPath.lineTo(right - mCornerRadius, top);
213 | mPath.arcTo(getTopRightCornerScallopArc(top, right), 180.0f, -90.0f, false);
214 |
215 | mPath.arcTo(getBottomRightCornerScallopArc(bottom, right), 270.0f, -90.0f, false);
216 | mPath.lineTo(right - mCornerRadius, bottom);
217 |
218 | } else {
219 | mPath.lineTo(right, top);
220 | mPath.lineTo(right, bottom);
221 | }
222 |
223 | mRect.set(left + offset, bottom - mScallopRadius, mScallopHeight + offset + left, bottom + mScallopRadius);
224 | mPath.arcTo(mRect, 0.0f, -180.0f, false);
225 |
226 | if (mCornerType == CornerType.ROUNDED) {
227 |
228 | mPath.arcTo(getBottomLeftCornerRoundedArc(left, bottom), 90.0f, 90.0f, false);
229 | mPath.lineTo(left, bottom - mCornerRadius);
230 |
231 | } else if (mCornerType == CornerType.SCALLOP) {
232 |
233 | mPath.arcTo(getBottomLeftCornerScallopArc(left, bottom), 0.0f, -90.0f, false);
234 | mPath.lineTo(left, bottom - mCornerRadius);
235 |
236 | } else {
237 | mPath.lineTo(left, bottom);
238 | }
239 | mPath.close();
240 | }
241 |
242 | // divider
243 | if (mOrientation == Orientation.HORIZONTAL) {
244 | mDividerStartX = left + mScallopRadius + mDividerPadding;
245 | mDividerStartY = mScallopRadius + top + offset;
246 | mDividerStopX = right - mScallopRadius - mDividerPadding;
247 | mDividerStopY = mScallopRadius + top + offset;
248 | } else {
249 | mDividerStartX = mScallopRadius + left + offset;
250 | mDividerStartY = top + mScallopRadius + mDividerPadding;
251 | mDividerStopX = mScallopRadius + left + offset;
252 | mDividerStopY = bottom - mScallopRadius - mDividerPadding;
253 | }
254 |
255 | generateShadow();
256 | mDirty = false;
257 | }
258 |
259 | private void generateShadow() {
260 | if (isJellyBeanAndAbove() && !isInEditMode()) {
261 | if (mShadowBlurRadius == 0f) return;
262 |
263 | if (mShadow == null) {
264 | mShadow = Bitmap.createBitmap(getWidth(), getHeight(), ALPHA_8);
265 | } else {
266 | mShadow.eraseColor(TRANSPARENT);
267 | }
268 | Canvas c = new Canvas(mShadow);
269 | c.drawPath(mPath, mShadowPaint);
270 | if (mShowBorder) {
271 | c.drawPath(mPath, mShadowPaint);
272 | }
273 | RenderScript rs = RenderScript.create(getContext());
274 | ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8(rs));
275 | Allocation input = Allocation.createFromBitmap(rs, mShadow);
276 | Allocation output = Allocation.createTyped(rs, input.getType());
277 | blur.setRadius(mShadowBlurRadius);
278 | blur.setInput(input);
279 | blur.forEach(output);
280 | output.copyTo(mShadow);
281 | input.destroy();
282 | output.destroy();
283 | blur.destroy();
284 | }
285 | }
286 |
287 | private void init(AttributeSet attrs) {
288 | if (attrs != null) {
289 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.TicketView);
290 | mOrientation = typedArray.getInt(R.styleable.TicketView_ticketOrientation, Orientation.HORIZONTAL);
291 | mBackgroundColor = typedArray.getColor(R.styleable.TicketView_ticketBackgroundColor, getResources().getColor(android.R.color.white));
292 | mScallopRadius = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketScallopRadius, Utils.dpToPx(20f, getContext()));
293 | mScallopPositionPercent = typedArray.getFloat(R.styleable.TicketView_ticketScallopPositionPercent, 50);
294 | mShowBorder = typedArray.getBoolean(R.styleable.TicketView_ticketShowBorder, false);
295 | mBorderWidth = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketBorderWidth, Utils.dpToPx(2f, getContext()));
296 | mBorderColor = typedArray.getColor(R.styleable.TicketView_ticketBorderColor, getResources().getColor(android.R.color.black));
297 | mShowDivider = typedArray.getBoolean(R.styleable.TicketView_ticketShowDivider, false);
298 | mDividerType = typedArray.getInt(R.styleable.TicketView_ticketDividerType, DividerType.NORMAL);
299 | mDividerWidth = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerWidth, Utils.dpToPx(2f, getContext()));
300 | mDividerColor = typedArray.getColor(R.styleable.TicketView_ticketDividerColor, getResources().getColor(android.R.color.darker_gray));
301 | mDividerDashLength = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerDashLength, Utils.dpToPx(8f, getContext()));
302 | mDividerDashGap = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerDashGap, Utils.dpToPx(4f, getContext()));
303 | mCornerType = typedArray.getInt(R.styleable.TicketView_ticketCornerType, CornerType.NORMAL);
304 | mCornerRadius = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketCornerRadius, Utils.dpToPx(4f, getContext()));
305 | mDividerPadding = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerPadding, Utils.dpToPx(10f, getContext()));
306 | float elevation = 0f;
307 | if (typedArray.hasValue(R.styleable.TicketView_ticketElevation)) {
308 | elevation = typedArray.getDimension(R.styleable.TicketView_ticketElevation, elevation);
309 | } else if (typedArray.hasValue(R.styleable.TicketView_android_elevation)) {
310 | elevation = typedArray.getDimension(R.styleable.TicketView_android_elevation, elevation);
311 | }
312 | if (elevation > 0f) {
313 | setShadowBlurRadius(elevation);
314 | }
315 |
316 | typedArray.recycle();
317 | }
318 |
319 | mShadowPaint.setColorFilter(new PorterDuffColorFilter(BLACK, SRC_IN));
320 | mShadowPaint.setAlpha(51); // 20%
321 |
322 | initElements();
323 |
324 | setLayerType(View.LAYER_TYPE_SOFTWARE, null);
325 | }
326 |
327 | private void initElements() {
328 |
329 | if (mDividerWidth > mScallopRadius) {
330 | mDividerWidth = mScallopRadius;
331 | Log.w(TAG, "You cannot apply divider width greater than scallop radius. Applying divider width to scallop radius.");
332 | }
333 |
334 | mScallopPosition = 100 / mScallopPositionPercent;
335 | mScallopHeight = mScallopRadius * 2;
336 |
337 | setBackgroundPaint();
338 | setBorderPaint();
339 | setDividerPaint();
340 |
341 | mDirty = true;
342 | invalidate();
343 | }
344 |
345 | private void setBackgroundPaint() {
346 | mBackgroundPaint.setAlpha(0);
347 | mBackgroundPaint.setAntiAlias(true);
348 | mBackgroundPaint.setColor(mBackgroundColor);
349 | mBackgroundPaint.setStyle(Paint.Style.FILL);
350 | }
351 |
352 | private void setBorderPaint() {
353 | mBorderPaint.setAlpha(0);
354 | mBorderPaint.setAntiAlias(true);
355 | mBorderPaint.setColor(mBorderColor);
356 | mBorderPaint.setStrokeWidth(mBorderWidth);
357 | mBorderPaint.setStyle(Paint.Style.STROKE);
358 | }
359 |
360 | private void setDividerPaint() {
361 | mDividerPaint.setAlpha(0);
362 | mDividerPaint.setAntiAlias(true);
363 | mDividerPaint.setColor(mDividerColor);
364 | mDividerPaint.setStrokeWidth(mDividerWidth);
365 |
366 | if (mDividerType == DividerType.DASH)
367 | mDividerPaint.setPathEffect(new DashPathEffect(new float[]{(float) mDividerDashLength, (float) mDividerDashGap}, 0.0f));
368 | else
369 | mDividerPaint.setPathEffect(new PathEffect());
370 | }
371 |
372 | private RectF getTopLeftCornerRoundedArc(float top, float left) {
373 | mRoundedCornerArc.set(left, top, left + mCornerRadius * 2, top + mCornerRadius * 2);
374 | return mRoundedCornerArc;
375 | }
376 |
377 | private RectF getTopRightCornerRoundedArc(float top, float right) {
378 | mRoundedCornerArc.set(right - mCornerRadius * 2, top, right, top + mCornerRadius * 2);
379 | return mRoundedCornerArc;
380 | }
381 |
382 | private RectF getBottomLeftCornerRoundedArc(float left, float bottom) {
383 | mRoundedCornerArc.set(left, bottom - mCornerRadius * 2, left + mCornerRadius * 2, bottom);
384 | return mRoundedCornerArc;
385 | }
386 |
387 | private RectF getBottomRightCornerRoundedArc(float bottom, float right) {
388 | mRoundedCornerArc.set(right - mCornerRadius * 2, bottom - mCornerRadius * 2, right, bottom);
389 | return mRoundedCornerArc;
390 | }
391 |
392 | private RectF getTopLeftCornerScallopArc(float top, float left) {
393 | mScallopCornerArc.set(left - mCornerRadius, top - mCornerRadius, left + mCornerRadius, top + mCornerRadius);
394 | return mScallopCornerArc;
395 | }
396 |
397 | private RectF getTopRightCornerScallopArc(float top, float right) {
398 | mScallopCornerArc.set(right - mCornerRadius, top - mCornerRadius, right + mCornerRadius, top + mCornerRadius);
399 | return mScallopCornerArc;
400 | }
401 |
402 | private RectF getBottomLeftCornerScallopArc(float left, float bottom) {
403 | mScallopCornerArc.set(left - mCornerRadius, bottom - mCornerRadius, left + mCornerRadius, bottom + mCornerRadius);
404 | return mScallopCornerArc;
405 | }
406 |
407 | private RectF getBottomRightCornerScallopArc(float bottom, float right) {
408 | mScallopCornerArc.set(right - mCornerRadius, bottom - mCornerRadius, right + mCornerRadius, bottom + mCornerRadius);
409 | return mScallopCornerArc;
410 | }
411 |
412 | public int getOrientation() {
413 | return mOrientation;
414 | }
415 |
416 | public void setOrientation(int orientation) {
417 | this.mOrientation = orientation;
418 | initElements();
419 | }
420 |
421 | public float getScallopPositionPercent() {
422 | return mScallopPositionPercent;
423 | }
424 |
425 | public void setScallopPositionPercent(float scallopPositionPercent) {
426 | this.mScallopPositionPercent = scallopPositionPercent;
427 | initElements();
428 | }
429 |
430 | public int getBackgroundColor() {
431 | return mBackgroundColor;
432 | }
433 |
434 | public void setBackgroundColor(int backgroundColor) {
435 | this.mBackgroundColor = backgroundColor;
436 | initElements();
437 | }
438 |
439 | public boolean isShowBorder() {
440 | return mShowBorder;
441 | }
442 |
443 | public void setShowBorder(boolean showBorder) {
444 | this.mShowBorder = showBorder;
445 | initElements();
446 | }
447 |
448 | public int getBorderWidth() {
449 | return mBorderWidth;
450 | }
451 |
452 | public void setBorderWidth(int borderWidth) {
453 | this.mBorderWidth = borderWidth;
454 | initElements();
455 | }
456 |
457 | public int getBorderColor() {
458 | return mBorderColor;
459 | }
460 |
461 | public void setBorderColor(int borderColor) {
462 | this.mBorderColor = borderColor;
463 | initElements();
464 | }
465 |
466 | public boolean isShowDivider() {
467 | return mShowDivider;
468 | }
469 |
470 | public void setShowDivider(boolean showDivider) {
471 | this.mShowDivider = showDivider;
472 | initElements();
473 | }
474 |
475 | public int getScallopRadius() {
476 | return mScallopRadius;
477 | }
478 |
479 | public void setScallopRadius(int scallopRadius) {
480 | this.mScallopRadius = scallopRadius;
481 | initElements();
482 | }
483 |
484 | public int getDividerDashLength() {
485 | return mDividerDashLength;
486 | }
487 |
488 | public void setDividerDashLength(int dividerDashLength) {
489 | this.mDividerDashLength = dividerDashLength;
490 | initElements();
491 | }
492 |
493 | public int getDividerDashGap() {
494 | return mDividerDashGap;
495 | }
496 |
497 | public void setDividerDashGap(int dividerDashGap) {
498 | this.mDividerDashGap = dividerDashGap;
499 | initElements();
500 | }
501 |
502 | public int getDividerType() {
503 | return mDividerType;
504 | }
505 |
506 | public void setDividerType(int dividerType) {
507 | this.mDividerType = dividerType;
508 | initElements();
509 | }
510 |
511 | public int getDividerWidth() {
512 | return mDividerWidth;
513 | }
514 |
515 | public void setDividerWidth(int dividerWidth) {
516 | this.mDividerWidth = dividerWidth;
517 | initElements();
518 | }
519 |
520 | public int getDividerPadding() {
521 | return mDividerPadding;
522 | }
523 |
524 | public void setDividerPadding(int mDividerPadding) {
525 | this.mDividerPadding = mDividerPadding;
526 | initElements();
527 | }
528 |
529 | public int getDividerColor() {
530 | return mDividerColor;
531 | }
532 |
533 | public void setDividerColor(int dividerColor) {
534 | this.mDividerColor = dividerColor;
535 | initElements();
536 | }
537 |
538 | public int getCornerType() {
539 | return mCornerType;
540 | }
541 |
542 | public void setCornerType(int cornerType) {
543 | this.mCornerType = cornerType;
544 | initElements();
545 | }
546 |
547 | public int getCornerRadius() {
548 | return mCornerRadius;
549 | }
550 |
551 | public void setCornerRadius(int cornerRadius) {
552 | this.mCornerRadius = cornerRadius;
553 | initElements();
554 | }
555 |
556 | public void setTicketElevation(float elevation) {
557 | if (!isJellyBeanAndAbove()) {
558 | Log.w(TAG, "Ticket elevation only works with Android Jelly Bean and above");
559 | return;
560 | }
561 | setShadowBlurRadius(elevation);
562 | initElements();
563 | }
564 |
565 | private void setShadowBlurRadius(float elevation) {
566 | if (!isJellyBeanAndAbove()) {
567 | Log.w(TAG, "Ticket elevation only works with Android Jelly Bean and above");
568 | return;
569 | }
570 | float maxElevation = Utils.dpToPx(24f, getContext());
571 | mShadowBlurRadius = Math.min(25f * (elevation / maxElevation), 25f);
572 | }
573 |
574 | private boolean isJellyBeanAndAbove() {
575 | return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
576 | }
577 | }
578 |
--------------------------------------------------------------------------------
/ticketview/src/main/java/com/vipulasri/ticketview/Utils.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.TypedValue;
6 |
7 | public class Utils {
8 |
9 | public static int dpToPx(float dp, Context context) {
10 | return dpToPx(dp, context.getResources());
11 | }
12 |
13 | public static int dpToPx(float dp, Resources resources) {
14 | float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
15 | return (int) px;
16 | }
17 | }
--------------------------------------------------------------------------------
/ticketview/src/main/res/values/attrs.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 |
--------------------------------------------------------------------------------
/ticketview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android-TicketView
3 |
4 |
--------------------------------------------------------------------------------
/ticketview/src/test/java/com/vipulasri/ticketview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.vipulasri.ticketview;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/ticketview/ticketview.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
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 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------