-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 005da0a
Showing
100 changed files
with
2,553 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Version 1.0.0-beta1 *(2019-08-26)* | ||
---------------------------- | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Winfooz | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# WinValidation | ||
A light-weight android library that can be quickly integrated into any app to use user input validations. | ||
|
||
- Annotations based. | ||
- Auto validation handling. | ||
- Auto find view by id. | ||
- Support custom annotations. | ||
- Support custom confirmation annotations e.g (Password and Confirm password). | ||
- Support auto validation while typing. | ||
- Support multi module projects. | ||
- Support Androidx. | ||
- Support auto validation for custom views. | ||
|
||
## Setup | ||
[ ![Download](https://api.bintray.com/packages/mnayef95/WinValidation/validation/images/download.svg) ](https://bintray.com/mnayef95/WinValidation/validation/_latestVersion) | ||
|
||
```yaml | ||
repositories { | ||
maven { | ||
url "https://dl.bintray.com/mnayef95/WinValidation" | ||
} | ||
} | ||
``` | ||
|
||
<details open> | ||
<summary>Kotlin</summary> | ||
|
||
```yaml | ||
implementation 'com.winfooz:validation:{latest-version}' | ||
kapt 'com.winfooz:validation-compiler:{latest-version}' | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary>Java</summary> | ||
|
||
```yaml | ||
implementation 'com.winfooz:validation:{latest-version}' | ||
annotationProcessing 'com.winfooz:validation-compiler:{latest-version}' | ||
``` | ||
</details> | ||
|
||
# How to use | ||
```kotlin | ||
@Validations | ||
class TestActivity : Activity() { | ||
|
||
@NotEmpty(R.id.username, messageResId = R.string.err_username_validation) | ||
var editTextUsername: TextInputEditText? = null | ||
|
||
@Password(R.id.password, messageResId = R.string.err_password_validation) | ||
var editTextPassword: TextInputEditText? = null | ||
|
||
@ConfirmPassword(R.id.confirm_password, messageResId = R.string.err_confirm_password_validation) | ||
var editTextConfirmPassword: TextInputEditText? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_test) | ||
|
||
// Don't forget to bind your activity, fragment or view | ||
Validator.bind(this) | ||
} | ||
|
||
@ValidateOnClick(R.id.buttonActivityMainSubmit) | ||
fun onSubmitClicked() { | ||
Toast.makeText(this, "Validation succeeded", Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
``` | ||
|
||
# Auto validate while typing | ||
```kotlin | ||
@Validations | ||
class TestActivity : Activity() { | ||
|
||
@AutoValidate | ||
@NotEmpty(R.id.username, messageResId = R.string.err_username_validation) | ||
var editTextUsername: TextInputEditText? = null | ||
|
||
.... | ||
} | ||
``` | ||
## Library Projects | ||
For library projects add [Butterknife's gradle plugin](https://github.com/JakeWharton/butterknife#library-projects) to your `buildscript`. | ||
|
||
```yaml | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0' | ||
} | ||
} | ||
``` | ||
|
||
and then apply it in your module: | ||
```yaml | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.jakewharton.butterknife' | ||
``` | ||
Now make sure you use R2 instead of R inside all WinValidation annotations. | ||
```kotlin | ||
@Validations | ||
class TestActivity : Activity() { | ||
|
||
@AutoValidate | ||
@NotEmpty(R2.id.username, messageResId = R2.string.err_username_validation) | ||
var editTextUsername: TextInputEditText? = null | ||
|
||
.... | ||
} | ||
``` | ||
## License | ||
WinValidation is released under the MIT license. [See LICENSE](https://github.com/Winfooz/WinValidation/blob/master/LICENSE) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apply plugin: 'java-library' | ||
apply plugin: 'kotlin' | ||
apply plugin: 'com.novoda.bintray-release' | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation "androidx.annotation:annotation:1.1.0" | ||
} | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
publish { | ||
userOrg = 'mnayef95' | ||
repoName = "WinValidation" | ||
groupId = "com.winfooz" | ||
artifactId = POM_ARTIFACT_ID | ||
publishVersion = POM_VERSION | ||
desc = POM_DESCRIPTION | ||
website = 'https://github.com/Winfooz/WinValidation' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POM_DESCRIPTION=Annotations for use in your project | ||
POM_ARTIFACT_ID=validation-annotations | ||
POM_VERSION=1.0.0-beta |
9 changes: 9 additions & 0 deletions
9
annotations/src/main/java/com/winfooz/AnnotationsAutoValidate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.winfooz | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
interface AnnotationsAutoValidate |
9 changes: 9 additions & 0 deletions
9
annotations/src/main/java/com/winfooz/AnnotationsErrorHandlingAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.winfooz | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
interface AnnotationsErrorHandlingAdapter |
9 changes: 9 additions & 0 deletions
9
annotations/src/main/java/com/winfooz/AnnotationsValidateAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.winfooz | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
interface AnnotationsValidateAdapter |
9 changes: 9 additions & 0 deletions
9
annotations/src/main/java/com/winfooz/AnnotationsValidationRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.winfooz | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
interface AnnotationsValidationRule |
14 changes: 14 additions & 0 deletions
14
annotations/src/main/java/com/winfooz/annotations/Adapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.winfooz.annotations | ||
|
||
import com.winfooz.AnnotationsValidateAdapter | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Adapter(val value: KClass<out AnnotationsValidateAdapter>) |
11 changes: 11 additions & 0 deletions
11
annotations/src/main/java/com/winfooz/annotations/AutoValidate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.winfooz.annotations | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class AutoValidate |
14 changes: 14 additions & 0 deletions
14
annotations/src/main/java/com/winfooz/annotations/AutoValidateWith.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.winfooz.annotations | ||
|
||
import com.winfooz.AnnotationsAutoValidate | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.ANNOTATION_CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class AutoValidateWith(val value: KClass<out AnnotationsAutoValidate>) |
13 changes: 13 additions & 0 deletions
13
annotations/src/main/java/com/winfooz/annotations/ConfirmWith.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.winfooz.annotations | ||
|
||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.ANNOTATION_CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class ConfirmWith(val value: KClass<out Annotation>) |
14 changes: 14 additions & 0 deletions
14
annotations/src/main/java/com/winfooz/annotations/ErrorHandling.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.winfooz.annotations | ||
|
||
import com.winfooz.AnnotationsErrorHandlingAdapter | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.ANNOTATION_CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class ErrorHandling(val value: KClass<out AnnotationsErrorHandlingAdapter>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.winfooz.annotations | ||
|
||
import com.winfooz.AnnotationsValidationRule | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.ANNOTATION_CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Rule(val value: KClass<out AnnotationsValidationRule>) |
13 changes: 13 additions & 0 deletions
13
annotations/src/main/java/com/winfooz/annotations/ValidateOnClick.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.winfooz.annotations | ||
|
||
import androidx.annotation.IdRes | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 10, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class ValidateOnClick(@IdRes val value: Int) |
11 changes: 11 additions & 0 deletions
11
annotations/src/main/java/com/winfooz/annotations/Validations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.winfooz.annotations | ||
|
||
/** | ||
* Project: WinValidation | ||
* Created: Aug 12, 2019 | ||
* | ||
* @author Mohamed Hamdan | ||
*/ | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Validations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-kapt' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.winfooz.validation.sample" | ||
|
||
minSdkVersion 21 | ||
targetSdkVersion 29 | ||
|
||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
|
||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.0.2' | ||
implementation 'androidx.core:core-ktx:1.0.2' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation "com.google.android.material:material:1.1.0-alpha09" | ||
|
||
implementation project(':module1') | ||
implementation project(":validation") | ||
kapt project(":compiler") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Oops, something went wrong.