Skip to content

Commit fe4ade4

Browse files
added LICENSE & README.md
1 parent 5f640e5 commit fe4ade4

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Anup Kumar Panwar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# ScratchView
2+
3+
[![](https://jitpack.io/v/AnupKumarPanwar/ScratchView.svg)](https://jitpack.io/#AnupKumarPanwar/ScratchView)
4+
5+
6+
This repo is build over https://github.com/sharish/ScratchView
7+
8+
9+
Demo Screen
10+
------
11+
12+
![](https://raw.githubusercontent.com/AnupKumarPanwar/ScratchView/master/Screenshots/ScratchView.gif)
13+
14+
15+
### Methods
16+
17+
* ```isRevealed()``` - tells whether the view has been revealed.
18+
* ```reveal()``` - reveals the view if not revealed yet.
19+
* ```mask()``` - masks the view again and removes the existing scratches.
20+
* ```setRevealListener(IRevealListener)``` - a callback listener interface which gets called back when user reveals the view
21+
through onReveal() method.
22+
23+
24+
Usage
25+
--------
26+
27+
ScratchView acts as an overlay over other views. Scratching the view makes it transparent so that the views below it are visible. Wrap all the layers in a RelativeLayout and put ScratchView above it.
28+
29+
30+
##### XML
31+
32+
```xml
33+
<com.anupkumarpanwar.scratchview.ScratchView
34+
android:id="@+id/scratch_view"
35+
android:layout_width="300dp"
36+
android:layout_height="300dp"
37+
app:overlay_image="@drawable/scratch_card"
38+
app:tile_mode="CLAMP"
39+
app:overlay_width="300dp"
40+
app:overlay_height="300dp"
41+
/>
42+
43+
```
44+
45+
##### JAVA
46+
47+
```java
48+
ScratchView scratchView = findViewById(R.id.scratch_view);
49+
scratchView.setRevealListener(new ScratchView.IRevealListener() {
50+
@Override
51+
public void onRevealed(ScratchView scratchView) {
52+
Toast.makeText(getApplicationContext(), "Reveled", Toast.LENGTH_LONG).show();;
53+
}
54+
55+
@Override
56+
public void onRevealPercentChangedListener(ScratchView scratchView, float percent) {
57+
if (percent>=0.5) {
58+
Log.d("Reveal Percentage", "onRevealPercentChangedListener: " + String.valueOf(percent));
59+
}
60+
}
61+
});
62+
```
63+
64+
65+
Example
66+
--------
67+
68+
```xml
69+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
70+
xmlns:app="http://schemas.android.com/apk/res-auto"
71+
xmlns:tools="http://schemas.android.com/tools"
72+
android:layout_width="match_parent"
73+
android:layout_height="match_parent"
74+
android:gravity="center"
75+
tools:context=".MainActivity">
76+
77+
<ImageView
78+
android:gravity="center"
79+
android:layout_width="300dp"
80+
android:layout_height="300dp"
81+
android:src="@drawable/anup"/>
82+
83+
<com.anupkumarpanwar.scratchview.ScratchView
84+
android:id="@+id/scratch_view"
85+
android:layout_width="300dp"
86+
android:layout_height="300dp"
87+
app:overlay_image="@drawable/scratch_card"
88+
app:tile_mode="CLAMP"
89+
app:overlay_width="300dp"
90+
app:overlay_height="300dp"
91+
/>
92+
93+
</RelativeLayout>
94+
95+
```
96+
97+
Attributes
98+
--------
99+
| Attribute | Description | Values |
100+
| ---------------------------- | ----------------------------- | ----------------------------- |
101+
| `app:overlay_image` | The pattern or image to cover the view. | @drawable/scratch_card |
102+
| `app:tile_mode` | https://developer.android.com/reference/android/graphics/Shader.TileMode | CLAMP / MIRROR / REPEAT|
103+
| `app:overlay_width` | Width of the overlay pattern | 300dp |
104+
| `app:overlay_height` | Height of the overlay pattern | 300dp |
105+
106+
107+
Installation
108+
------------------------
109+
110+
- Add the following configuration in your build.gradle file.
111+
112+
```gradle
113+
repositories {
114+
jcenter()
115+
maven { url "https://jitpack.io" }
116+
}
117+
118+
dependencies {
119+
implementation 'com.github.AnupKumarPanwar:ScratchView:1.3'
120+
}
121+
```
122+
123+
Developed By
124+
------------
125+
126+
* Anup Kumar Panwar - <[email protected]>

0 commit comments

Comments
 (0)