├── .github
└── workflows
│ └── android.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── art
└── demoScratchCardLayout.gif
├── build.gradle
├── demoscratchcardlayout
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── dev
│ │ └── skymansandy
│ │ └── scratchcardlayoutexample
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── dev
│ │ │ └── skymansandy
│ │ │ └── scratchcardlayoutexample
│ │ │ ├── ui
│ │ │ ├── activity
│ │ │ │ └── main
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── fragment
│ │ │ │ ├── aboutdev
│ │ │ │ └── AboutDevFragment.kt
│ │ │ │ ├── demoscreen
│ │ │ │ └── DemoFragment.kt
│ │ │ │ └── webpagescreen
│ │ │ │ ├── WebPageContent.kt
│ │ │ │ └── WebPageFragment.kt
│ │ │ └── util
│ │ │ ├── AppConstants.kt
│ │ │ └── AppUtils.kt
│ └── res
│ │ ├── drawable
│ │ ├── ic_menu_about_library.png
│ │ ├── ic_menu_about_me.png
│ │ ├── ic_menu_donate_beer.png
│ │ ├── ic_menu_github_source.png
│ │ ├── ic_menu_home.png
│ │ ├── ic_menu_issues_and_feedback.png
│ │ ├── ic_menu_rate_app.png
│ │ ├── ic_menu_share.png
│ │ ├── scratch.png
│ │ └── trophy.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── fragment_about_dev.xml
│ │ ├── fragment_demo.xml
│ │ ├── fragment_webpage.xml
│ │ └── nav_header.xml
│ │ ├── menu
│ │ └── menu_nav_drawer.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-ldpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── dev
│ └── skymansandy
│ └── scratchcardlayoutexample
│ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── index.html
├── javadoc
├── allclasses-frame.html
├── allclasses-noframe.html
├── constant-values.html
├── deprecated-list.html
├── help-doc.html
├── in
│ └── codeshuffle
│ │ └── scratchcardlayout
│ │ ├── listener
│ │ ├── ScratchListener.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ └── package-tree.html
│ │ ├── ui
│ │ ├── ScratchCardLayout.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ └── package-tree.html
│ │ └── util
│ │ ├── ScratchCardUtils.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ └── package-tree.html
├── index-files
│ ├── index-1.html
│ ├── index-2.html
│ ├── index-3.html
│ ├── index-4.html
│ └── index-5.html
├── index.html
├── overview-frame.html
├── overview-summary.html
├── overview-tree.html
├── package-list
├── script.js
└── stylesheet.css
├── scratchcardlayout
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── dev
│ │ └── skymansandy
│ │ └── scratchcardlayout
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── dev
│ │ │ └── skymansandy
│ │ │ └── scratchcardlayout
│ │ │ ├── listener
│ │ │ └── ScratchListener.kt
│ │ │ ├── ui
│ │ │ ├── ScratchCard.kt
│ │ │ └── ScratchCardLayout.kt
│ │ │ └── util
│ │ │ └── ScratchCardUtils.kt
│ └── res
│ │ ├── layout
│ │ └── default_scratch_view.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── dev
│ └── skymansandy
│ └── scratchcardlayout
│ └── ExampleUnitTest.kt
└── settings.gradle
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: set up JDK 1.8
17 | uses: actions/setup-java@v1
18 | with:
19 | java-version: 1.8
20 | - name: Build with Gradle
21 | run: ./gradlew build
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .idea/
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | android:
4 | components:
5 | - tools
6 | - platform-tools
7 | - build-tools-28.0.3
8 | - android-28
9 | - extra-android-m2repository
10 | - extra-android-support
11 |
12 | before_script:
13 | - touch local.properties
14 |
15 | script:
16 | - ./gradlew build
17 |
18 | before_install:
19 | - chmod +x gradlew
20 | - mkdir "$ANDROID_HOME/licenses" || true
21 | - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
22 | - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
23 |
--------------------------------------------------------------------------------
/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 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ScratchCardLayout
2 |
3 | [](https://www.apache.org/licenses/LICENSE-2.0)
4 | [](https://android-arsenal.com/api?level=14)
5 | [](https://android-arsenal.com/details/1/7597)
6 | [ ](https://bintray.com/skymansandy/ScratchCard/ScratchCardLayout/_latestVersion)
7 |
8 | ## A simple Android library for scratch card reveal kind of effect
9 |
10 |
11 | ## Features:
12 |
13 | - Scratch card effect to ANY view.
14 | - Just wrap your existing complex Layout with ScratchCardLayout.
15 | - CardView based library. So All styling of CardView is available.
16 | - Set scratch brush width.
17 | - Enable/Disable scratching effect
18 | - Set Drawable to be scratched (color / image).
19 | - Set the percentage of scratch when you should be revealing full layout.
20 | - Get callbacks when scratching starts, progresses (with a percentage) and when stops..
21 |
22 |
23 | # Demonstration
24 | |Demo scratchCardLayout|
25 | |:---:|
26 | ||
27 |
28 |
29 | # Usage
30 | ## Dependency:
31 |
32 |
33 | ```
34 | dependencies {
35 | implementation 'in.codeshuffle.scratchcardlayout:ScratchCardLayout:1.0.8'
36 | }
37 | ```
38 |
39 | ## XML Usage
40 | ```xml
41 |
50 |
51 |
52 |
53 | ```
54 |
55 | ## Java Usage
56 | ```java
57 | //Get view reference
58 | ScratchCardLayout scratchCardLayout = findViewById(R.id.scratchCard);
59 |
60 | //Set the drawable (programmatically)
61 | scratchCardLayout.setScratchDrawable(getResources().getDrawable(R.drawable.car));
62 |
63 | //Set scratch brush width
64 | scratchCardLayout.setScratchWidth(30f);
65 |
66 | //Reveal full layout when some percent of the view is scratched
67 | scratchCardLayout.setRevealFullAtPercent(40);
68 |
69 | //Scratching enable/disable
70 | scratchCardLayout.setScratchEnabled(true);
71 |
72 | //Remove all scratch made till now
73 | scratchCardLayout.resetScratch();
74 |
75 | //Reveal scratch card (Shows the layout underneath the scratch)
76 | scratchCardLayout.revealScratch();
77 | ```
78 |
79 | ### Listeners available
80 |
81 | Implement the given interface and override these stuff:
82 |
83 | ```java
84 |
85 | //Implement this to your class
86 | yourClass extends someBaseClass implements ScratchListener
87 |
88 | //Set the listener
89 | scratchCardLayout.setScratchListener(this);
90 |
91 | //You'll have three main callback methods as scratch listeners
92 | //Scratch started
93 | void onScratchStarted();
94 |
95 | //Scracth progress (NOTE: not guaranteed to be exact percent. consider it like atleast this much percent has been scratched)
96 | void onScratchProgress(ScratchCardLayout scratchCardLayout, int atLeastScratchedPercent);
97 |
98 | //Scratch completed
99 | void onScratchComplete();
100 | ```
101 |
102 | ## PlayStore app
103 |
104 | https://play.google.com/store/apps/details?id=in.codeshuffle.scratchcardlayoutexample
105 |
106 | ## Note
107 | ```
108 | - The progress is the value guaranteeing that the mentioned percent is atleast scratched. NOT THE EXACT PERCENTAGE (for performance reasaons)
109 | ```
110 |
111 | License
112 | -------
113 |
114 | Copyright 2019 SkyManSandy
115 |
116 | Licensed under the Apache License, Version 2.0 (the "License");
117 | you may not use this file except in compliance with the License.
118 | You may obtain a copy of the License at
119 |
120 | http://www.apache.org/licenses/LICENSE-2.0
121 |
122 | Unless required by applicable law or agreed to in writing, software
123 | distributed under the License is distributed on an "AS IS" BASIS,
124 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125 | See the License for the specific language governing permissions and
126 | limitations under the License.
127 |
--------------------------------------------------------------------------------
/art/demoScratchCardLayout.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/art/demoScratchCardLayout.gif
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.71'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.6.3'
9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
10 |
11 | classpath 'com.novoda:bintray-release:0.9.1'
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | defaultConfig {
8 | applicationId "in.codeshuffle.scratchcardview"
9 | minSdkVersion 19
10 | targetSdkVersion 29
11 | versionCode 3
12 | versionName "1.1"
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | compileOptions {
22 | sourceCompatibility JavaVersion.VERSION_1_8
23 | targetCompatibility JavaVersion.VERSION_1_8
24 | }
25 | viewBinding {
26 | enabled = true
27 | }
28 | }
29 |
30 | dependencies {
31 | testImplementation 'junit:junit:4.13'
32 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
34 |
35 | implementation fileTree(dir: 'libs', include: ['*.jar'])
36 | implementation 'com.google.android.material:material:1.1.0'
37 | implementation 'androidx.appcompat:appcompat:1.1.0'
38 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
39 |
40 | //Glide
41 | implementation 'com.github.bumptech.glide:glide:4.11.0'
42 | annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
43 |
44 | //Circular image view
45 | implementation 'de.hdodenhof:circleimageview:3.1.0'
46 |
47 | //Scratch card view
48 | implementation project(':scratchcardlayout')
49 | }
50 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/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 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"demoscratchcardlayout-release.apk","fullName":"release","baseName":"release"},"path":"demoscratchcardlayout-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/androidTest/java/dev/skymansandy/scratchcardlayoutexample/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample
2 |
3 | import android.content.Context
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 | import androidx.test.platform.app.InstrumentationRegistry
6 | import org.junit.Assert
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 |
10 | /**
11 | * Instrumented test, which will execute on an Android device.
12 | *
13 | * @see [Testing documentation](http://d.android.com/tools/testing)
14 | */
15 | @RunWith(AndroidJUnit4::class)
16 | class ExampleInstrumentedTest {
17 | @Test
18 | fun useAppContext() {
19 | // Context of the app under test.
20 | val appContext: Context = InstrumentationRegistry.getTargetContext()
21 | Assert.assertEquals("in.codeshuffle.scratchcardview", appContext.packageName)
22 | }
23 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/ui/activity/main/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.ui.activity.main
2 |
3 | import dev.skymansandy.scratchcardlayoutexample.ui.fragment.aboutdev.AboutDevFragment
4 | import dev.skymansandy.scratchcardlayoutexample.ui.fragment.demoscreen.DemoFragment
5 | import dev.skymansandy.scratchcardlayoutexample.ui.fragment.webpagescreen.WebPageContent
6 | import dev.skymansandy.scratchcardlayoutexample.ui.fragment.webpagescreen.WebPageFragment
7 | import dev.skymansandy.scratchcardlayoutexample.util.AppUtils
8 | import dev.skymansandy.scratchcardviewexample.R
9 | import dev.skymansandy.scratchcardviewexample.databinding.ActivityMainBinding
10 | import android.os.Bundle
11 | import android.os.Handler
12 | import android.view.MenuItem
13 | import androidx.appcompat.app.ActionBarDrawerToggle
14 | import androidx.appcompat.app.AppCompatActivity
15 | import androidx.core.view.GravityCompat
16 | import androidx.fragment.app.Fragment
17 | import com.google.android.material.navigation.NavigationView
18 |
19 | class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
20 |
21 | private val demoFragment by lazy { DemoFragment.getInstance() }
22 | private val aboutLibraryFragment by lazy { WebPageFragment.getInstance(WebPageContent.PAGE_VIEW_ABOUT_LIBRARY) }
23 | private val githubFragment by lazy { WebPageFragment.getInstance(WebPageContent.PAGE_VIEW_IN_GITHUB) }
24 | private val issueFeedBackFragment by lazy { WebPageFragment.getInstance(WebPageContent.PAGE_ISSUE_AND_FEEDBACK) }
25 | private val donateBeerFragment by lazy { WebPageFragment.getInstance(WebPageContent.PAGE_DONATE_BEER) }
26 |
27 | private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
28 |
29 | private var doubleBackToExitPressedOnce = false
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | super.onCreate(savedInstanceState)
33 | setContentView(binding.root)
34 |
35 | replaceFragment(demoFragment)
36 |
37 | setupNavDrawer()
38 | setupActionbarWithToggle()
39 | }
40 |
41 | private fun setupActionbarWithToggle() {
42 | setSupportActionBar(binding.toolbar)
43 | binding.toolbar.title = getString(R.string.app_name)
44 | supportActionBar?.let {
45 | val mDrawerToggle = ActionBarDrawerToggle(
46 | this, binding.drawerLayout, binding.toolbar,
47 | R.string.navigation_drawer_open, R.string.navigation_drawer_close
48 | )
49 | binding.drawerLayout.setDrawerListener(mDrawerToggle)
50 | it.setDisplayHomeAsUpEnabled(true)
51 | it.setHomeButtonEnabled(true)
52 | mDrawerToggle.syncState()
53 | }
54 | }
55 |
56 | private fun setupNavDrawer() {
57 | binding.navView.setNavigationItemSelectedListener(this)
58 | }
59 |
60 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
61 | if (item.itemId == R.id.home) {
62 | binding.drawerLayout.openDrawer(GravityCompat.START)
63 | return true
64 | }
65 | return super.onOptionsItemSelected(item)
66 | }
67 |
68 | override fun onNavigationItemSelected(menuItem: MenuItem): Boolean {
69 | when (menuItem.itemId) {
70 | R.id.navMenuHome -> {
71 | replaceFragment(demoFragment)
72 | binding.toolbar.title = getString(R.string.app_name)
73 | menuItem.isChecked = true
74 | }
75 | R.id.navMenuAboutLibrary -> {
76 | replaceFragment(aboutLibraryFragment)
77 | binding.toolbar.title = getString(R.string.about_library)
78 | menuItem.isChecked = true
79 | }
80 | R.id.navMenuGithub -> {
81 | replaceFragment(githubFragment)
82 | binding.toolbar.title = getString(R.string.source_code)
83 | menuItem.isChecked = true
84 | }
85 | R.id.navMenuIssueFeedback -> {
86 | replaceFragment(issueFeedBackFragment)
87 | binding.toolbar.title = getString(R.string.issues_and_feedback)
88 | menuItem.isChecked = true
89 | }
90 | R.id.navMenuDonateBeer -> {
91 | replaceFragment(donateBeerFragment)
92 | binding.toolbar.title = getString(R.string.thanks_for_the_beer)
93 | AppUtils.showShortToast(this,
94 | getString(R.string.thats_so_nice_of_you))
95 | }
96 | R.id.navMenuAbout -> {
97 | val aboutDevFragment: AboutDevFragment = AboutDevFragment.getInstance()
98 | aboutDevFragment.show(supportFragmentManager, aboutDevFragment.tag)
99 | }
100 | R.id.navMenuRateApp -> {
101 | AppUtils.openPlayStoreForApp(this)
102 | AppUtils.showShortToast(this,
103 | getString(R.string.thanks_for_the_support))
104 | }
105 | R.id.navMenuShareApp -> AppUtils.shareLibraryApp(this)
106 | }
107 | binding.drawerLayout.closeDrawers()
108 | return true
109 | }
110 |
111 | override fun onBackPressed() {
112 | if (doubleBackToExitPressedOnce) {
113 | super.onBackPressed()
114 | return
115 | }
116 | doubleBackToExitPressedOnce = true
117 | AppUtils.showShortToast(this, getString(R.string.press_back_to_exit))
118 | Handler().postDelayed({ doubleBackToExitPressedOnce = false }, 2000)
119 | }
120 |
121 | private fun replaceFragment(instance: Fragment) {
122 | val fragmentTransaction = supportFragmentManager.beginTransaction()
123 | fragmentTransaction.replace(R.id.container, instance)
124 | fragmentTransaction.commit()
125 | }
126 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/ui/fragment/aboutdev/AboutDevFragment.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.ui.fragment.aboutdev
2 |
3 | import dev.skymansandy.scratchcardviewexample.databinding.FragmentAboutDevBinding
4 | import android.os.Bundle
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.fragment.app.DialogFragment
9 |
10 | class AboutDevFragment : DialogFragment() {
11 |
12 | companion object {
13 | fun getInstance(): AboutDevFragment {
14 | val bundle = Bundle()
15 | val aboutDevFragment = AboutDevFragment()
16 | aboutDevFragment.arguments = bundle
17 | return aboutDevFragment
18 | }
19 | }
20 |
21 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
22 | return FragmentAboutDevBinding.inflate(inflater).root
23 | }
24 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/ui/fragment/demoscreen/DemoFragment.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.ui.fragment.demoscreen
2 |
3 | import dev.skymansandy.scratchcardlayout.listener.ScratchListener
4 | import dev.skymansandy.scratchcardlayout.ui.ScratchCardLayout
5 | import dev.skymansandy.scratchcardlayout.util.ScratchCardUtils
6 | import dev.skymansandy.scratchcardlayoutexample.util.AppUtils
7 | import dev.skymansandy.scratchcardviewexample.R
8 | import dev.skymansandy.scratchcardviewexample.databinding.FragmentDemoBinding
9 | import android.os.Bundle
10 | import android.util.Log
11 | import android.view.LayoutInflater
12 | import android.view.View
13 | import android.view.ViewGroup
14 | import android.widget.CompoundButton
15 | import android.widget.SeekBar
16 | import android.widget.SeekBar.OnSeekBarChangeListener
17 | import androidx.fragment.app.DialogFragment
18 |
19 | class DemoFragment : DialogFragment(), ScratchListener {
20 |
21 | companion object {
22 | private val TAG: String? = DemoFragment::class.java.simpleName
23 |
24 | fun getInstance(): DemoFragment {
25 | val bundle = Bundle()
26 | val demoFragment = DemoFragment()
27 | demoFragment.arguments = bundle
28 | return demoFragment
29 | }
30 | }
31 |
32 | private lateinit var binding: FragmentDemoBinding
33 |
34 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
35 | binding = FragmentDemoBinding.inflate(inflater)
36 | return binding.root
37 | }
38 |
39 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
40 | super.onViewCreated(view, savedInstanceState)
41 | resetLibraryView()
42 | resetControlPanelView()
43 | setControlPanelListeners()
44 | }
45 |
46 | private fun resetLibraryView() {
47 | binding.scratchCard.setScratchListener(this)
48 |
49 | binding.reveal.setOnClickListener { binding.scratchCard.revealScratch() }
50 | binding.reset.setOnClickListener {
51 | binding.scratchCard.resetScratch()
52 | resetControlPanelView()
53 | }
54 | }
55 |
56 | private fun resetControlPanelView() {
57 | binding.brushSizeSeekBar.progress = 40
58 | binding.revealFullAtSeekBar.progress = 40
59 | binding.scratchEffectToggle.isChecked = true
60 | binding.scratchEffectToggle.text = getString(R.string.enabled)
61 | }
62 |
63 | private fun setControlPanelListeners() {
64 | //Scratch Brush size config
65 | binding.brushSizeSeekBar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
66 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {}
67 | override fun onStartTrackingTouch(seekBar: SeekBar?) {}
68 | override fun onStopTrackingTouch(seekBar: SeekBar?) {
69 | context?.let {
70 | binding.scratchCard.setScratchWidthDip(ScratchCardUtils.dipToPx(it, seekBar!!.progress.toFloat()))
71 | }
72 | }
73 | })
74 |
75 | //Scratch effect config
76 | binding.scratchEffectToggle.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
77 | binding.scratchCard.setScratchEnabled(isChecked)
78 | binding.scratchEffectToggle.text = getString(if (isChecked) R.string.enabled else R.string.disabled)
79 | }
80 |
81 | //Scratch reveal at percent
82 | binding.revealFullAtSeekBar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
83 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {}
84 | override fun onStartTrackingTouch(seekBar: SeekBar?) {}
85 | override fun onStopTrackingTouch(seekBar: SeekBar?) {
86 | AppUtils.showShortToast(activity, getString(R.string.resetting_view_since_reveal_percent_was_changed))
87 | binding.scratchCard.setRevealFullAtPercent(seekBar!!.progress)
88 | binding.scratchCard.resetScratch()
89 | }
90 | })
91 | }
92 |
93 | override fun onScratchStarted() {
94 | Log.d(TAG, "Scratch started")
95 | }
96 |
97 | override fun onScratchProgress(scratchCardLayout: ScratchCardLayout, atLeastScratchedPercent: Int) {
98 | Log.d(TAG, "Progress = $atLeastScratchedPercent")
99 | }
100 |
101 | override fun onScratchComplete() {
102 | Log.d(TAG, "Scratch ended")
103 | }
104 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/ui/fragment/webpagescreen/WebPageContent.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.ui.fragment.webpagescreen
2 |
3 | enum class WebPageContent {
4 | PAGE_VIEW_ABOUT_LIBRARY,
5 | PAGE_VIEW_IN_GITHUB,
6 | PAGE_ISSUE_AND_FEEDBACK,
7 | PAGE_DONATE_BEER
8 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/ui/fragment/webpagescreen/WebPageFragment.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.ui.fragment.webpagescreen
2 |
3 | import dev.skymansandy.scratchcardlayoutexample.util.AppConstants.URLs
4 | import dev.skymansandy.scratchcardviewexample.databinding.FragmentWebpageBinding
5 | import android.annotation.SuppressLint
6 | import android.graphics.Bitmap
7 | import android.os.Bundle
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.webkit.WebChromeClient
12 | import android.webkit.WebView
13 | import android.webkit.WebViewClient
14 | import androidx.fragment.app.DialogFragment
15 |
16 | class WebPageFragment : DialogFragment() {
17 |
18 | companion object {
19 | private val CONTENT_TYPE: String? = "contentType"
20 |
21 | fun getInstance(content: WebPageContent): WebPageFragment {
22 | val bundle = Bundle()
23 | val webPageFragment = WebPageFragment()
24 | bundle.putSerializable(CONTENT_TYPE, content)
25 | webPageFragment.arguments = bundle
26 | return webPageFragment
27 | }
28 | }
29 |
30 | private lateinit var binding: FragmentWebpageBinding
31 |
32 | private val mChromeClient: WebChromeClient? = object : WebChromeClient() {
33 | override fun onProgressChanged(view: WebView?, newProgress: Int) {
34 | super.onProgressChanged(view, newProgress)
35 | if (!isAdded) return
36 | binding.progressBar.progress = newProgress
37 | }
38 | }
39 |
40 | private val mWebClient: WebViewClient? = object : WebViewClient() {
41 | override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
42 | super.onPageStarted(view, url, favicon)
43 | if (!isAdded) return
44 | binding.progressBar.visibility = View.VISIBLE
45 | }
46 |
47 | override fun onPageFinished(view: WebView?, url: String?) {
48 | super.onPageFinished(view, url)
49 | if (!isAdded) return
50 | binding.progressBar.visibility = View.GONE
51 | }
52 | }
53 |
54 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
55 | binding = FragmentWebpageBinding.inflate(inflater)
56 | return binding.root
57 | }
58 |
59 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
60 | super.onViewCreated(view, savedInstanceState)
61 | if (savedInstanceState == null) {
62 | setupWebViewDefaults()
63 | val bundle = arguments
64 | if (bundle != null) {
65 | val content = bundle.getSerializable(CONTENT_TYPE) as? WebPageContent
66 | ?: WebPageContent.PAGE_VIEW_IN_GITHUB
67 | when (content) {
68 | WebPageContent.PAGE_VIEW_ABOUT_LIBRARY -> binding.webView.loadUrl(URLs.VIEW_READ_ME)
69 | WebPageContent.PAGE_VIEW_IN_GITHUB -> binding.webView.loadUrl(URLs.GITHUB_REPO_URL)
70 | WebPageContent.PAGE_ISSUE_AND_FEEDBACK -> binding.webView.loadUrl(URLs.ISSUE_FEEDBACK_URL)
71 | WebPageContent.PAGE_DONATE_BEER -> binding.webView.loadUrl(URLs.DONATE_BEER_URL)
72 | }
73 | }
74 | }
75 | }
76 |
77 | @SuppressLint("SetJavaScriptEnabled")
78 | private fun setupWebViewDefaults() {
79 | binding.webView.apply {
80 | webChromeClient = mChromeClient
81 | webViewClient = mWebClient
82 |
83 | settings.displayZoomControls = false
84 | settings.setSupportZoom(false)
85 | settings.builtInZoomControls = false
86 | settings.javaScriptEnabled = true
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/util/AppConstants.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.util
2 |
3 | object AppConstants {
4 | object URLs {
5 | val GITHUB_REPO_URL: String? = "https://github.com/skymansandy/scratchCardLayout"
6 | val ISSUE_FEEDBACK_URL: String? = "https://github.com/skymansandy/scratchCardLayout/issues"
7 | val DONATE_BEER_URL: String? = "https://beerpay.io/skymansandy/scratchCardLayout"
8 | val VIEW_READ_ME: String? = "https://github.com/skymansandy/scratchCardLayout/blob/master/README.md"
9 | }
10 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayoutexample/util/AppUtils.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample.util
2 |
3 | import dev.skymansandy.scratchcardviewexample.R
4 | import android.content.ActivityNotFoundException
5 | import android.content.Context
6 | import android.content.Intent
7 | import android.net.Uri
8 | import android.widget.Toast
9 | import java.text.MessageFormat
10 |
11 | object AppUtils {
12 | fun openPlayStoreForApp(context: Context?) {
13 | context?.let {
14 | val appPackageName = it.packageName
15 | try {
16 | it.startActivity(Intent(Intent.ACTION_VIEW,
17 | Uri.parse(it.resources.getString(R.string.app_market_link) + appPackageName)))
18 | } catch (e: ActivityNotFoundException) {
19 | it.startActivity(Intent(Intent.ACTION_VIEW,
20 | Uri.parse(it.resources.getString(R.string.app_google_play_store_link) + appPackageName)))
21 | }
22 | }
23 | }
24 |
25 | fun shareLibraryApp(context: Context?) {
26 | context?.let {
27 | try {
28 | val shareBody = MessageFormat.format("{0}: {1}\n\n{2}",
29 | it.getString(R.string.here_is_an_interesting_library),
30 | it.getString(R.string.library_app_name),
31 | it.getString(R.string.library_app_description))
32 | val sharingIntent = Intent(Intent.ACTION_SEND)
33 | sharingIntent.type = "text/plain"
34 | sharingIntent.putExtra(Intent.EXTRA_SUBJECT, it.getString(R.string.library_app_name))
35 | sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody)
36 | it.startActivity(Intent.createChooser(sharingIntent, it.resources.getString(R.string.share_using)))
37 | } catch (e: Exception) {
38 | e.printStackTrace()
39 | showShortToast(it, "Something went wrong!")
40 | }
41 | }
42 | }
43 |
44 | fun showShortToast(context: Context?, message: String?) {
45 | Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
46 | }
47 | }
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_about_library.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_about_library.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_about_me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_about_me.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_donate_beer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_donate_beer.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_github_source.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_github_source.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_home.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_issues_and_feedback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_issues_and_feedback.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_rate_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_rate_app.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/ic_menu_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/ic_menu_share.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/scratch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/scratch.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/drawable/trophy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/drawable/trophy.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
27 |
28 |
29 |
30 |
38 |
39 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/layout/fragment_about_dev.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
19 |
20 |
21 |
28 |
29 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/layout/fragment_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
24 |
25 |
26 |
31 |
32 |
41 |
42 |
48 |
49 |
50 |
51 |
52 |
53 |
57 |
58 |
63 |
64 |
70 |
71 |
76 |
77 |
82 |
83 |
89 |
90 |
91 |
92 |
93 |
94 |
100 |
101 |
107 |
108 |
113 |
114 |
120 |
121 |
122 |
123 |
124 |
130 |
131 |
136 |
137 |
142 |
143 |
144 |
150 |
151 |
152 |
153 |
154 |
160 |
161 |
167 |
168 |
169 |
175 |
176 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/layout/fragment_webpage.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
18 |
19 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/layout/nav_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
22 |
23 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/menu/menu_nav_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
13 |
17 |
21 |
22 |
27 |
28 | -
29 |
30 |
31 |
35 |
39 |
40 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/mipmap-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/mipmap-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/demoscratchcardlayout/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #147913
4 | #10570F
5 | #58C732
6 |
7 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ScratchCardLayout Demo
3 | App description
4 | View source
5 | About dev
6 | Donate a beer!
7 | Issues and Feedback
8 | Home
9 | Navigation drawer open
10 | Navigation drawer close
11 | Rate app
12 | Share this library
13 | Off topic
14 | Source code
15 | Issues and feedback
16 | Thanks for the beer :)
17 | P Sandesh Baliga
18 | http://skymansandy.github.io/
19 | About library
20 | About library
21 |
22 |
23 | "https://play.google.com/store/apps/details?id="
24 | "market://details?id="
25 | Here is an interesting library I came across
26 | Share using
27 | Press again to exit
28 | Thanks for the support
29 | That\'s so nice of you :D
30 |
31 |
32 | Trophy icon
33 | You haven\'t won
34 | ₹10
35 | Control panel
36 | Scratch effect
37 | Scratch brush size
38 | Reveal full layout at %
39 | Logs
40 | Percentage
41 | Reset
42 | Reveal
43 | Clear
44 | Enabled
45 | Disabled
46 | Restting view since reveal percent setting was changed
47 |
48 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/demoscratchcardlayout/src/test/java/dev/skymansandy/scratchcardlayoutexample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayoutexample
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * @see [Testing documentation](http://d.android.com/tools/testing)
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | Assert.assertEquals(4, 2 + 2.toLong())
15 | }
16 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536m
2 |
3 | android.enableJetifier=true
4 | android.useAndroidX=true
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skymansandy/scratchCardLayout/f0d346e3e717e5d4ff29bea803c7c9b4de7f4bd2/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Feb 27 17:16:56 IST 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.6.4-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 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ScratchCardLayout
7 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | JavaScript is disabled on your browser.
70 |
71 | Frame Alert
72 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version .
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/javadoc/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 |
12 | All Classes
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/javadoc/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 |
12 | All Classes
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/javadoc/constant-values.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Constant Field Values
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/javadoc/deprecated-list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Deprecated List
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/javadoc/help-doc.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Help
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
75 |
76 |
77 |
78 | Overview
79 | The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
80 |
81 |
82 | Package
83 | Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
84 |
85 | Interfaces (italic)
86 | Classes
87 | Enums
88 | Exceptions
89 | Errors
90 | Annotation Types
91 |
92 |
93 |
94 | Class/Interface
95 | Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
96 |
97 | Class inheritance diagram
98 | Direct Subclasses
99 | All Known Subinterfaces
100 | All Known Implementing Classes
101 | Class/interface declaration
102 | Class/interface description
103 |
104 |
105 | Nested Class Summary
106 | Field Summary
107 | Constructor Summary
108 | Method Summary
109 |
110 |
111 | Field Detail
112 | Constructor Detail
113 | Method Detail
114 |
115 | Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
116 |
117 |
118 | Annotation Type
119 | Each annotation type has its own separate page with the following sections:
120 |
121 | Annotation Type declaration
122 | Annotation Type description
123 | Required Element Summary
124 | Optional Element Summary
125 | Element Detail
126 |
127 |
128 |
129 | Enum
130 | Each enum has its own separate page with the following sections:
131 |
132 | Enum declaration
133 | Enum description
134 | Enum Constant Summary
135 | Enum Constant Detail
136 |
137 |
138 |
139 | Tree (Class Hierarchy)
140 | There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
141 |
142 | When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
143 | When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
144 |
145 |
146 |
147 | Deprecated API
148 | The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
149 |
150 |
151 | Index
152 | The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
153 |
154 |
155 | Prev/Next
156 | These links take you to the next or previous class, interface, package, or related page.
157 |
158 |
159 | Frames/No Frames
160 | These links show and hide the HTML frames. All pages are available with or without frames.
161 |
162 |
163 | All Classes
164 | The All Classes link shows all classes and interfaces except non-static nested types.
165 |
166 |
167 | Serialized Form
168 | Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
169 |
170 |
171 | Constant Field Values
172 | The Constant Field Values page lists the static final fields and their values.
173 |
174 |
175 |
This help file applies to API documentation generated using the standard doclet.
176 |
177 |
194 |
195 |
196 | Prev
197 | Next
198 |
199 |
203 |
206 |
207 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/listener/ScratchListener.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ScratchListener
7 |
8 |
9 |
10 |
11 |
12 |
28 |
29 | JavaScript is disabled on your browser.
30 |
31 |
32 |
49 |
50 |
51 | Prev Class
52 | Next Class
53 |
54 |
58 |
61 |
62 |
72 |
73 |
74 |
75 | Summary:
76 | Nested |
77 | Field |
78 | Constr |
79 | Method
80 |
81 |
82 | Detail:
83 | Field |
84 | Constr |
85 | Method
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
97 |
98 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | Method Summary
117 |
118 | All Methods Instance Methods Abstract Methods
119 |
120 | Modifier and Type
121 | Method and Description
122 |
123 |
124 | void
125 | onScratchComplete ()
126 | Callback indicating Scratch stopped/interrupted in the UI
127 |
128 |
129 |
130 | void
131 | onScratchProgress (ScratchCardLayout scratchCardLayout,
132 | int atLeastScratchedPercent)
133 | Callback indicating progress percentage of scratch
134 |
135 |
136 |
137 | void
138 | onScratchStarted ()
139 | Callback indicating Scratch started in the UI
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 | Method Detail
157 |
158 |
159 |
160 |
167 |
168 |
169 |
170 |
171 |
172 | onScratchProgress
173 | void onScratchProgress(ScratchCardLayout scratchCardLayout,
174 | int atLeastScratchedPercent)
175 | Callback indicating progress percentage of scratch
176 |
177 | Parameters:
178 | scratchCardLayout
- the scratch card layout itself
179 | atLeastScratchedPercent
- percentage that's at least scratched at this point
180 | (not providing accurate values in real-time due to performance reasons)
181 |
182 |
183 |
184 |
185 |
186 |
187 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
219 |
220 |
221 | Prev Class
222 | Next Class
223 |
224 |
228 |
231 |
232 |
242 |
243 |
244 |
245 | Summary:
246 | Nested |
247 | Field |
248 | Constr |
249 | Method
250 |
251 |
252 | Detail:
253 | Field |
254 | Constr |
255 | Method
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/listener/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.listener
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Interfaces
15 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/listener/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.listener
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 |
75 |
76 |
77 |
78 | Interface Summary
79 |
80 | Interface
81 | Description
82 |
83 |
84 |
85 | ScratchListener
86 |
87 | Interface to receive scratch related callbacks
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
113 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/listener/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.listener Class Hierarchy
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
78 |
79 |
Interface Hierarchy
80 |
83 |
84 |
85 |
102 |
103 |
104 | Prev
105 | Next
106 |
107 |
111 |
114 |
115 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/ui/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.ui
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/ui/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.ui
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 |
75 |
76 |
77 |
78 | Class Summary
79 |
80 | Class
81 | Description
82 |
83 |
84 |
85 | ScratchCardLayout
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
111 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/ui/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.ui Class Hierarchy
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
78 |
79 |
Class Hierarchy
80 |
81 | java.lang.Object
82 |
83 | android.view.View (implements android.view.accessibility.AccessibilityEventSource, android.graphics.drawable.Drawable.Callback, android.view.KeyEvent.Callback)
84 |
85 | android.view.ViewGroup (implements android.view.ViewManager, android.view.ViewParent)
86 |
87 | android.widget.FrameLayout
88 |
89 | android.support.v7.widget.CardView
90 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
122 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/util/ScratchCardUtils.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ScratchCardUtils
7 |
8 |
9 |
10 |
11 |
12 |
28 |
29 | JavaScript is disabled on your browser.
30 |
31 |
32 |
49 |
50 |
51 | Prev Class
52 | Next Class
53 |
54 |
58 |
61 |
62 |
72 |
73 |
74 |
75 | Summary:
76 | Nested |
77 | Field |
78 | Constr |
79 | Method
80 |
81 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
97 |
98 |
99 | java.lang.Object
100 |
101 |
102 | dev.skymansandy.scratchcardlayout.util.ScratchCardUtils
103 |
104 |
105 |
106 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | Constructor Summary
126 |
127 | Constructors
128 |
129 | Constructor and Description
130 |
131 |
132 | ScratchCardUtils ()
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 | Method Summary
143 |
144 | All Methods Static Methods Concrete Methods
145 |
146 | Modifier and Type
147 | Method and Description
148 |
149 |
150 | static float
151 | dipToPx (android.content.Context context,
152 | float dipValue)
153 | Utility method to convert density independent pixel to actual screen pixel value
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | Methods inherited from class java.lang.Object
162 | equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
189 |
190 |
191 |
192 |
193 |
194 | Method Detail
195 |
196 |
197 |
198 |
199 |
200 | dipToPx
201 | public static float dipToPx(android.content.Context context,
202 | float dipValue)
203 | Utility method to convert density independent pixel to actual screen pixel value
204 |
205 | Parameters:
206 | context
- context of the display environment
207 | dipValue
- dip value which is to be converted to px
208 | Returns:
209 | pixel value corresponding to provided dipValue
for the current screen density
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
238 |
239 |
240 | Prev Class
241 | Next Class
242 |
243 |
247 |
250 |
251 |
261 |
262 |
263 |
264 | Summary:
265 | Nested |
266 | Field |
267 | Constr |
268 | Method
269 |
270 |
271 | Detail:
272 | Field |
273 | Constr |
274 | Method
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/util/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.util
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/util/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.util
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
74 |
75 |
76 |
77 |
78 | Class Summary
79 |
80 | Class
81 | Description
82 |
83 |
84 |
85 | ScratchCardUtils
86 |
87 | Utility methods for scratch card library needs
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
113 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/javadoc/in/codeshuffle/scratchcardlayout/util/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | dev.skymansandy.scratchcardlayout.util Class Hierarchy
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
78 |
79 |
Class Hierarchy
80 |
81 | java.lang.Object
82 |
85 |
86 |
87 |
88 |
89 |
106 |
107 |
108 | Prev
109 | Next
110 |
111 |
115 |
118 |
119 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/javadoc/index-files/index-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | D-Index
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 | D I O R S
72 |
73 |
74 |
D
75 |
76 | dipToPx(Context, float) - Static method in class in.codeshuffle.scratchcardlayout.util.ScratchCardUtils
77 |
78 | Utility method to convert density independent pixel to actual screen pixel value
79 |
80 |
81 |
D I O R S
82 |
83 |
100 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/javadoc/index-files/index-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | I-Index
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 | D I O R S
72 |
73 |
74 |
I
75 |
76 | dev.skymansandy.scratchcardlayout.listener - package in.codeshuffle.scratchcardlayout.listener
77 |
78 | dev.skymansandy.scratchcardlayout.ui - package in.codeshuffle.scratchcardlayout.ui
79 |
80 | dev.skymansandy.scratchcardlayout.util - package in.codeshuffle.scratchcardlayout.util
81 |
82 |
83 |
D I O R S
84 |
85 |
102 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/javadoc/index-files/index-3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | O-Index
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 | D I O R S
72 |
73 |
74 |
O
75 |
76 | onFullReveal() - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
77 |
78 | onScratchComplete() - Method in interface in.codeshuffle.scratchcardlayout.listener.ScratchListener
79 |
80 | Callback indicating Scratch stopped/interrupted in the UI
81 |
82 | onScratchProgress(ScratchCardLayout, int) - Method in interface in.codeshuffle.scratchcardlayout.listener.ScratchListener
83 |
84 | Callback indicating progress percentage of scratch
85 |
86 | onScratchStarted() - Method in interface in.codeshuffle.scratchcardlayout.listener.ScratchListener
87 |
88 | Callback indicating Scratch started in the UI
89 |
90 |
91 |
D I O R S
92 |
93 |
110 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/javadoc/index-files/index-4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | R-Index
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 | D I O R S
72 |
73 |
74 |
R
75 |
76 | resetScratch() - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
77 |
78 | Reset scratch.
79 |
80 |
81 |
D I O R S
82 |
83 |
100 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/javadoc/index-files/index-5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | S-Index
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 | D I O R S
72 |
73 |
74 |
S
75 |
76 | ScratchCardLayout - Class in dev.skymansandy.scratchcardlayout.ui
77 |
78 | ScratchCardLayout(Context) - Constructor for class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
79 |
80 | ScratchCardLayout(Context, AttributeSet) - Constructor for class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
81 |
82 | ScratchCardLayout(Context, AttributeSet, int) - Constructor for class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
83 |
84 | ScratchCardUtils - Class in dev.skymansandy.scratchcardlayout.util
85 |
86 | Utility methods for scratch card library needs
87 |
88 | ScratchCardUtils() - Constructor for class in.codeshuffle.scratchcardlayout.util.ScratchCardUtils
89 |
90 | ScratchListener - Interface in dev.skymansandy.scratchcardlayout.listener
91 |
92 | Interface to receive scratch related callbacks
93 |
94 | setRevealFullAtPercent(int) - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
95 |
96 | Reveal full layout when some threshold percent is scratched
97 |
98 | setScratchDrawable(Drawable) - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
99 |
100 | Set the layout resource id of image to show as overlay for scratching
101 | (Drawable
image or ColorDrawable
)
102 |
103 | setScratchEnabled(boolean) - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
104 |
105 | Enable/Disable scratch effect
106 |
107 | setScratchListener(ScratchListener) - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
108 |
109 | Scratch listener
110 |
111 | setScratchWidthDip(float) - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
112 |
113 | Set the scratch brush width
114 |
115 | stopScratching() - Method in class in.codeshuffle.scratchcardlayout.ui.ScratchCardLayout
116 |
117 | Stop or Interrupt scratch effect
118 |
119 |
120 |
D I O R S
121 |
122 |
139 |
166 |
167 |
168 |
169 |
--------------------------------------------------------------------------------
/javadoc/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Generated Documentation (Untitled)
7 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | JavaScript is disabled on your browser.
70 |
71 | Frame Alert
72 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version .
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/javadoc/overview-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Overview List
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/javadoc/overview-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Overview
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
94 |
95 |
112 |
113 |
114 | Prev
115 | Next
116 |
117 |
121 |
124 |
125 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/javadoc/overview-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Class Hierarchy
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 | JavaScript is disabled on your browser.
24 |
25 |
26 |
43 |
70 |
71 |
80 |
81 |
Class Hierarchy
82 |
83 | java.lang.Object
84 |
85 | in.codeshuffle.scratchcardlayout.util.ScratchCardUtils
86 | android.view.View (implements android.view.accessibility.AccessibilityEventSource, android.graphics.drawable.Drawable.Callback, android.view.KeyEvent.Callback)
87 |
88 | android.view.ViewGroup (implements android.view.ViewManager, android.view.ViewParent)
89 |
90 | android.widget.FrameLayout
91 |
92 | android.support.v7.widget.CardView
93 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
Interface Hierarchy
107 |
110 |
111 |
112 |
129 |
130 |
131 | Prev
132 | Next
133 |
134 |
138 |
141 |
142 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
--------------------------------------------------------------------------------
/javadoc/package-list:
--------------------------------------------------------------------------------
1 | in.codeshuffle.scratchcardlayout.listener
2 | in.codeshuffle.scratchcardlayout.ui
3 | in.codeshuffle.scratchcardlayout.util
4 |
--------------------------------------------------------------------------------
/javadoc/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + " ";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/scratchcardlayout/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/scratchcardlayout/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.novoda.bintray-release'
2 | apply plugin: 'com.android.library'
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-android-extensions'
5 |
6 | publish {
7 | def groupProjectID = 'in.codeshuffle.scratchcardlayout'
8 | def artifactProjectID = 'ScratchCardLayout'
9 | def publishVersionID = '1.0.8'
10 |
11 | userOrg = 'skymansandy'
12 | repoName = 'ScratchCard'
13 | groupId = groupProjectID
14 | artifactId = artifactProjectID
15 | publishVersion = publishVersionID
16 | desc = 'A simple Android library for scratch card reveal kind of effect'
17 | website = 'https://github.com/skymansandy/scratchCardLayout'
18 | }
19 |
20 | android {
21 | compileSdkVersion 29
22 |
23 | defaultConfig {
24 | minSdkVersion 14
25 | targetSdkVersion 29
26 | versionCode 3
27 | versionName "1.0.9"
28 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29 | }
30 |
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 | }
38 |
39 | dependencies {
40 | implementation fileTree(dir: 'libs', include: ['*.jar'])
41 |
42 | testImplementation 'junit:junit:4.13'
43 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
44 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
45 |
46 | implementation 'androidx.appcompat:appcompat:1.1.0'
47 | implementation 'androidx.cardview:cardview:1.0.0'
48 | }
49 |
50 | /**
51 | *
52 | Steps to upload to bintray
53 |
54 | $ export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_252`
55 |
56 | $ export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
57 |
58 | $ ./gradlew clean build bintrayUpload -PbintrayUser=user -PbintrayKey=apikey -PdryRun=false
59 |
60 | */
61 |
--------------------------------------------------------------------------------
/scratchcardlayout/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 |
--------------------------------------------------------------------------------
/scratchcardlayout/src/androidTest/java/dev/skymansandy/scratchcardlayout/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayout
2 |
3 | import android.content.Context
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 | import androidx.test.platform.app.InstrumentationRegistry
6 | import org.junit.Assert
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 |
10 | /**
11 | * Instrumented test, which will execute on an Android device.
12 | *
13 | * @see [Testing documentation](http://d.android.com/tools/testing)
14 | */
15 | @RunWith(AndroidJUnit4::class)
16 | class ExampleInstrumentedTest {
17 | @Test
18 | fun useAppContext() {
19 | // Context of the app under test.
20 | val appContext: Context = InstrumentationRegistry.getTargetContext()
21 | Assert.assertEquals("in.codeshuffle.scratchcardview2.test", appContext.packageName)
22 | }
23 | }
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayout/listener/ScratchListener.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayout.listener
2 |
3 | import dev.skymansandy.scratchcardlayout.ui.ScratchCardLayout
4 |
5 | /**
6 | * Interface to receive scratch related callbacks
7 | */
8 | interface ScratchListener {
9 | /**
10 | * Callback indicating Scratch started in the UI
11 | */
12 | fun onScratchStarted()
13 |
14 | /**
15 | * Callback indicating progress percentage of scratch
16 | * @param scratchCardLayout the scratch card layout itself
17 | * @param atLeastScratchedPercent percentage that's at least scratched at this point
18 | * (not providing accurate values in real-time due to performance reasons)
19 | */
20 | fun onScratchProgress(scratchCardLayout: ScratchCardLayout, atLeastScratchedPercent: Int)
21 |
22 | /**
23 | * Callback indicating Scratch stopped/interrupted in the UI
24 | */
25 | fun onScratchComplete()
26 | }
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayout/ui/ScratchCard.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayout.ui
2 |
3 | import dev.skymansandy.scratchcardlayout.R
4 | import dev.skymansandy.scratchcardlayout.listener.ScratchListener
5 | import dev.skymansandy.scratchcardlayout.util.ScratchCardUtils
6 | import android.annotation.SuppressLint
7 | import android.content.Context
8 | import android.graphics.*
9 | import android.graphics.drawable.Drawable
10 | import android.util.AttributeSet
11 | import android.view.MotionEvent
12 | import android.view.View
13 | import kotlin.math.abs
14 |
15 | internal class ScratchCard(context: Context, attrs: AttributeSet?, defStyle: Int) : View(context, attrs, defStyle) {
16 |
17 | private var mPath: Path? = null
18 | private var mInnerPaint: Paint? = null
19 | private var mOuterPaint: Paint? = null
20 | private var mBitmap: Bitmap? = null
21 | private var mCanvas: Canvas? = null
22 | private var mScratchDrawable: Drawable? = null
23 | private var mListener: ScratchListener? = null
24 | private var mScratchWidth = 0f
25 | private var mLastTouchX = 0f
26 | private var mLastTouchY = 0f
27 | private var mRevealFullAtPercent = 0
28 | private var mRevealListener: ScratchCardInterface? = null
29 | private var mEnableScratching = false
30 |
31 | init {
32 | init(context, attrs)
33 | }
34 |
35 | private fun init(context: Context, attrs: AttributeSet?) {
36 | @SuppressLint("CustomViewStyleable") val a = context.obtainStyledAttributes(attrs, R.styleable.ScratchCardLayout)
37 | mScratchDrawable = a.getDrawable(R.styleable.ScratchCardLayout_scratchDrawable)
38 | mScratchWidth = a.getDimension(R.styleable.ScratchCardLayout_scratchWidth, ScratchCardUtils.dipToPx(context, 30f))
39 | mRevealFullAtPercent = a.getInteger(R.styleable.ScratchCardLayout_scratchRevealFullAtPercent, 100)
40 | mEnableScratching = a.getBoolean(R.styleable.ScratchCardLayout_scratchEnabled, true)
41 | a.recycle()
42 | }
43 |
44 | override fun onSizeChanged(w: Int, h: Int, oldWidth: Int, oldHeight: Int) {
45 | super.onSizeChanged(w, h, oldWidth, oldHeight)
46 | setupScratchDrawableOnView()
47 | if (mPath == null) {
48 | mPath = Path()
49 | }
50 | if (mInnerPaint == null) {
51 | mInnerPaint = Paint()
52 | mInnerPaint!!.isAntiAlias = true
53 | mInnerPaint!!.isDither = true
54 | mInnerPaint!!.style = Paint.Style.STROKE
55 | mInnerPaint!!.isFilterBitmap = true
56 | mInnerPaint!!.strokeJoin = Paint.Join.ROUND
57 | mInnerPaint!!.strokeCap = Paint.Cap.ROUND
58 | mInnerPaint!!.strokeWidth = mScratchWidth
59 | mInnerPaint!!.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
60 | }
61 | if (mOuterPaint == null) {
62 | mOuterPaint = Paint()
63 | }
64 | }
65 |
66 | @SuppressLint("ClickableViewAccessibility")
67 | override fun onTouchEvent(event: MotionEvent): Boolean {
68 | if (!mEnableScratching) return true
69 | val currentTouchX = event.x
70 | val currentTouchY = event.y
71 | when (event.action) {
72 | MotionEvent.ACTION_DOWN -> {
73 | mPath?.reset()
74 | mPath?.moveTo(event.x, event.y)
75 | }
76 | MotionEvent.ACTION_UP -> mPath?.lineTo(currentTouchX, currentTouchY)
77 | MotionEvent.ACTION_MOVE -> {
78 | val dx = abs(currentTouchX - mLastTouchX)
79 | val dy = abs(currentTouchY - mLastTouchY)
80 | if (dx >= 4 || dy >= 4) {
81 | val x1 = mLastTouchX
82 | val y1 = mLastTouchY
83 | val x2 = (currentTouchX + mLastTouchX) / 2
84 | val y2 = (currentTouchY + mLastTouchY) / 2
85 | mPath?.quadTo(x1, y1, x2, y2)
86 | }
87 | if (mListener != null) {
88 | val width = mBitmap?.width
89 | val height = mBitmap?.height
90 | val total = width!! * height!!
91 | var count = 0
92 | var i = 0
93 | while (i < width) {
94 | var j = 0
95 | while (j < height) {
96 | if (mBitmap?.getPixel(i, j) == 0x00000000) count++
97 | j += 3
98 | }
99 | i += 3
100 | }
101 | val percentCompleted = (count.toFloat() / total * 9 * 100).toInt()
102 | when {
103 | percentCompleted == 0 -> mListener?.onScratchStarted()
104 | percentCompleted == 100 -> stopScratchingAndRevealFull()
105 | percentCompleted >= mRevealFullAtPercent -> stopScratchingAndRevealFull()
106 | else -> mListener?.onScratchProgress(parent as ScratchCardLayout, percentCompleted)
107 | }
108 | }
109 | }
110 | }
111 | mCanvas?.drawPath(mPath!!, mInnerPaint!!)
112 | mLastTouchX = currentTouchX
113 | mLastTouchY = currentTouchY
114 | invalidate()
115 | return true
116 | }
117 |
118 | private fun stopScratchingAndRevealFull() {
119 | if (mListener != null) {
120 | if (mRevealListener != null) {
121 | mRevealListener?.onFullReveal()
122 | }
123 | mListener?.onScratchComplete()
124 | }
125 | }
126 |
127 | override fun onDraw(canvas: Canvas?) {
128 | canvas?.drawBitmap(mBitmap!!, 0f, 0f, mOuterPaint)
129 | super.onDraw(canvas)
130 | }
131 |
132 | override fun onDetachedFromWindow() {
133 | super.onDetachedFromWindow()
134 | if (mBitmap != null) {
135 | mBitmap?.recycle()
136 | mBitmap = null
137 | }
138 | }
139 |
140 | fun setScratchDrawable(mScratchDrawable: Drawable?) {
141 | this.mScratchDrawable = mScratchDrawable
142 | }
143 |
144 | fun setScratchWidthDip(mScratchWidth: Float) {
145 | this.mScratchWidth = mScratchWidth
146 | if (mInnerPaint != null) {
147 | mInnerPaint?.strokeWidth = mScratchWidth
148 | }
149 | }
150 |
151 | fun setListener(mListener: ScratchListener?) {
152 | this.mListener = mListener
153 | }
154 |
155 | fun setRevealFullAtPercent(mRevealFullAtPercent: Int) {
156 | this.mRevealFullAtPercent = mRevealFullAtPercent
157 | }
158 |
159 | fun setRevealListener(scratchCardLayout: ScratchCardLayout?) {
160 | mRevealListener = scratchCardLayout
161 | }
162 |
163 | fun setScratchEnabled(enableScratching: Boolean) {
164 | mEnableScratching = enableScratching
165 | }
166 |
167 | fun resetScratch() {
168 | if (width != 0 && height != 0) {
169 | visibility = VISIBLE
170 | setupScratchDrawableOnView()
171 | invalidate()
172 | }
173 | }
174 |
175 | fun revealScratch() {
176 | stopScratchingAndRevealFull()
177 | }
178 |
179 | private fun setupScratchDrawableOnView() {
180 | if (mBitmap != null) mBitmap!!.recycle()
181 | mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
182 | mCanvas = Canvas(mBitmap!!)
183 | if (mScratchDrawable != null) {
184 | mScratchDrawable?.setBounds(0, 0, mBitmap!!.width, mBitmap!!.height)
185 | mScratchDrawable?.draw(mCanvas!!)
186 | } else {
187 | mCanvas!!.drawColor(-0x3f3f40)
188 | }
189 | }
190 |
191 | internal interface ScratchCardInterface {
192 | fun onFullReveal()
193 | }
194 | }
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayout/ui/ScratchCardLayout.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayout.ui
2 |
3 | import dev.skymansandy.scratchcardlayout.listener.ScratchListener
4 | import android.content.Context
5 | import android.graphics.drawable.Drawable
6 | import android.util.AttributeSet
7 | import android.view.View
8 | import android.view.ViewGroup
9 | import androidx.cardview.widget.CardView
10 |
11 | class ScratchCardLayout : CardView, ScratchCard.ScratchCardInterface {
12 | private lateinit var scratchCard: ScratchCard
13 |
14 | constructor(context: Context) : super(context) {
15 | init(context, null, 0)
16 | }
17 |
18 | constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
19 | init(context, attrs, 0)
20 | }
21 |
22 | constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
23 | init(context, attrs, defStyleAttr)
24 | }
25 |
26 | private fun init(context: Context, attrs: AttributeSet?, defStyleAttr: Int) {
27 | scratchCard = ScratchCard(context, attrs, defStyleAttr)
28 | scratchCard.setRevealListener(this)
29 | setupScratchView()
30 | resetScratch()
31 | }
32 |
33 | /**
34 | * Set the scratch brush width
35 | *
36 | * @param mScratchWidthDip width in dp (Use Utility method `ScratchCardUtils.dipToPx` for conversion)
37 | */
38 | fun setScratchWidthDip(mScratchWidthDip: Float) {
39 | scratchCard.setScratchWidthDip(mScratchWidthDip)
40 | }
41 |
42 | /**
43 | * Set the layout resource id of image to show as overlay for scratching
44 | * (`Drawable` image or `ColorDrawable`)
45 | *
46 | * @param mScratchDrawable layout resource id
47 | */
48 | fun setScratchDrawable(mScratchDrawable: Drawable?) {
49 | scratchCard.setScratchDrawable(mScratchDrawable)
50 | }
51 |
52 | /**
53 | * Scratch listener
54 | *
55 | * @param mListener listener object
56 | * (implement the interface in the type of the instance passed in which to listen to callbacks)
57 | */
58 | fun setScratchListener(mListener: ScratchListener) {
59 | scratchCard.setListener(mListener)
60 | }
61 |
62 | /**
63 | * Adding the scratch card to layout
64 | */
65 | private fun setupScratchView() {
66 | scratchCard.layoutParams = LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
67 | ViewGroup.LayoutParams.MATCH_PARENT)
68 | post { addView(scratchCard) }
69 | }
70 |
71 | /**
72 | * Stop or Interrupt scratch effect
73 | */
74 | private fun stopScratching() {
75 | scratchCard.visibility = View.GONE
76 | }
77 |
78 | /**
79 | * Reveal full layout when some threshold percent is scratched
80 | *
81 | * @param revealFullAtPercent threshold percent
82 | */
83 | fun setRevealFullAtPercent(revealFullAtPercent: Int) {
84 | scratchCard.setRevealFullAtPercent(revealFullAtPercent)
85 | }
86 |
87 | override fun onFullReveal() {
88 | stopScratching()
89 | }
90 |
91 | /**
92 | * Enable/Disable scratch effect
93 | * @param enableScratching true/false based on your choice
94 | */
95 | fun setScratchEnabled(enableScratching: Boolean) {
96 | scratchCard.setScratchEnabled(enableScratching)
97 | }
98 |
99 | /**
100 | * Reset scratch. (As if its a whole new scratch session
101 | */
102 | fun resetScratch() {
103 | setScratchEnabled(true)
104 | scratchCard.resetScratch()
105 | }
106 |
107 | /**
108 | * Reveal scratch. (Reveal whats underneath the scratch view)
109 | */
110 | fun revealScratch(){
111 | scratchCard.revealScratch()
112 | }
113 | }
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/java/dev/skymansandy/scratchcardlayout/util/ScratchCardUtils.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayout.util
2 |
3 | import android.content.Context
4 |
5 | /**
6 | * Utility methods for scratch card library needs
7 | */
8 | object ScratchCardUtils {
9 | /**
10 | * Utility method to convert density independent pixel to actual screen pixel value
11 | * @param context context of the display environment
12 | * @param dipValue dip value which is to be converted to px
13 | * @return pixel value corresponding to provided `dipValue` for the current screen density
14 | */
15 | fun dipToPx(context: Context, dipValue: Float): Float {
16 | val density = context.resources.displayMetrics.density
17 | return dipValue * density
18 | }
19 | }
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/res/layout/default_scratch_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1A33A7
4 |
--------------------------------------------------------------------------------
/scratchcardlayout/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | scratchCardView
3 |
4 |
--------------------------------------------------------------------------------
/scratchcardlayout/src/test/java/dev/skymansandy/scratchcardlayout/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package dev.skymansandy.scratchcardlayout
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * @see [Testing documentation](http://d.android.com/tools/testing)
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | Assert.assertEquals(4, 2 + 2.toLong())
15 | }
16 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':demoscratchcardlayout', ':scratchcardlayout'
2 |
--------------------------------------------------------------------------------