diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2646e4a --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0cc5753 --- /dev/null +++ b/README.md @@ -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 + + +``` + +##### 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 + + + + + + + + +``` + +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 - <1anuppanwar@gmail.com>