Skip to content

Commit

Permalink
added LICENSE & README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AnupKumarPanwar committed Nov 14, 2021
1 parent 5f640e5 commit fe4ade4
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Anup Kumar Panwar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# ScratchView

[![](https://jitpack.io/v/AnupKumarPanwar/ScratchView.svg)](https://jitpack.io/#AnupKumarPanwar/ScratchView)


This repo is build over https://github.com/sharish/ScratchView


Demo Screen
------

![](https://raw.githubusercontent.com/AnupKumarPanwar/ScratchView/master/Screenshots/ScratchView.gif)


### Methods

* ```isRevealed()``` - tells whether the view has been revealed.
* ```reveal()``` - reveals the view if not revealed yet.
* ```mask()``` - masks the view again and removes the existing scratches.
* ```setRevealListener(IRevealListener)``` - a callback listener interface which gets called back when user reveals the view
through onReveal() method.


Usage
--------

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.


##### XML

```xml
<com.anupkumarpanwar.scratchview.ScratchView
android:id="@+id/scratch_view"
android:layout_width="300dp"
android:layout_height="300dp"
app:overlay_image="@drawable/scratch_card"
app:tile_mode="CLAMP"
app:overlay_width="300dp"
app:overlay_height="300dp"
/>

```

##### JAVA

```java
ScratchView scratchView = findViewById(R.id.scratch_view);
scratchView.setRevealListener(new ScratchView.IRevealListener() {
@Override
public void onRevealed(ScratchView scratchView) {
Toast.makeText(getApplicationContext(), "Reveled", Toast.LENGTH_LONG).show();;
}

@Override
public void onRevealPercentChangedListener(ScratchView scratchView, float percent) {
if (percent>=0.5) {
Log.d("Reveal Percentage", "onRevealPercentChangedListener: " + String.valueOf(percent));
}
}
});
```


Example
--------

```xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context=".MainActivity">

<ImageView
android:gravity="center"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/anup"/>

<com.anupkumarpanwar.scratchview.ScratchView
android:id="@+id/scratch_view"
android:layout_width="300dp"
android:layout_height="300dp"
app:overlay_image="@drawable/scratch_card"
app:tile_mode="CLAMP"
app:overlay_width="300dp"
app:overlay_height="300dp"
/>

</RelativeLayout>

```

Attributes
--------
| Attribute | Description | Values |
| ---------------------------- | ----------------------------- | ----------------------------- |
| `app:overlay_image` | The pattern or image to cover the view. | @drawable/scratch_card |
| `app:tile_mode` | https://developer.android.com/reference/android/graphics/Shader.TileMode | CLAMP / MIRROR / REPEAT|
| `app:overlay_width` | Width of the overlay pattern | 300dp |
| `app:overlay_height` | Height of the overlay pattern | 300dp |


Installation
------------------------

- Add the following configuration in your build.gradle file.

```gradle
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
implementation 'com.github.AnupKumarPanwar:ScratchView:1.3'
}
```

Developed By
------------

* Anup Kumar Panwar - <[email protected]>

0 comments on commit fe4ade4

Please sign in to comment.