GithubHelp home page GithubHelp logo

renansdias / emailchecker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wordpress-mobile/emailchecker

0.0 2.0 0.0 289 KB

Email checking library for Android and iOS

License: GNU General Public License v2.0

emailchecker's Introduction

Email Checker for Android and iOS

Introduction

This library helps to catch simple email domain typos. Its intended to be used as a hint when a user have to enter an email address.

The library is written in C++ and is inspired by the algorithm described here: http://norvig.com/spell-correct.html (Warning, it's not the exact same algo).

How to use it in an Android project

Currently gradle doesn't support NDK, so we used a trick to make it work: it generates a temporary .jar file containing .so, this file is used as a jar dependency for the final .aar file.

If you want to use it in your Android project, your can add it as a library in your build.gradle file, don't forget to add the wordpress-mobile maven repository. For instance:

repositories {
    maven { url 'http://wordpress-mobile.github.io/WordPress-Android' }
}

dependencies {
    // use the latest 0.x version
    compile 'org.wordpress:emailchecker:0.+'
}

Sample usage:

String emailToCheck = "[email protected]";
String suggest = (new EmailChecker()).suggestDomainCorrection(email);
if (suggest.compareTo(email) != 0) {
    Log.v("FIXME", "did you mean: " + suggest + " ?");
}

How to use it in an iOS project

If you use CocoaPods, you just have to add the following pod to your dependency list:

pod 'EmailChecker', :podspec => 'https://raw.github.com/wordpress-mobile/EmailChecker/master/ios/EmailChecker.podspec'

Sample usage:

NSString *emailToCheck = @"[email protected]";
NSString *suggestedEmail = [EmailChecker suggestDomainCorrection: @"[email protected]"];
if (![suggestedEmail isEqualToString:emailToCheck]) {
    NSLog(@"Did you mean: %@", suggestedEmail);
}

Hack it

Directory structure

|-- common                  # common C++ native code
|-- android
|   |-- jni                 # android specific C++ native code
|   `-- src                 # android specific Java code
`-- ios
    |-- EmailChecker        # iOS specific Obj-C++ code
    `-- EmailCheckerTests   # Obj-C++ tests (testing C++ code in common/)

The steps to add a new public method

  1. Create the public method in common/
  2. Wrap it as a Java jni method in android/jni and android/java
  3. Wrap it as a Obj-C++ method in ios/EmailChecker/

Build

  • For Android

    $ cd android && gradle build
    
  • For iOS

    $ cd ios && xcodebuild
    

Apps that use this library

Screenshot from WordPress Android

Screenshot from WordPress Android

LICENSE

This library is dual licensed unded MIT and GPL v2.

CHANGELOG

0.2

  • Failback to the identity function when native libraries can't be loaded (weird Android ROMs).
  • Update to gradle-android 0.8 and use gradle to build jni code

0.1

  • Initial release

emailchecker's People

Contributors

maxme avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.