GithubHelp home page GithubHelp logo

scottai / swipecaptcha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mcxtzhang/swipecaptcha

0.0 1.0 0.0 1.2 MB

Swipe captcha of Android platform. Android 平台的滑动验证码。

Home Page: http://blog.csdn.net/zxt0601/article/details/53315975

Java 100.00%

swipecaptcha's Introduction

-SwipeCaptcha

Swipe captcha of Android platform。 Android 平台的滑动验证码。

在 Android端app上,自定义View,仿一个斗鱼web端滑动验证码。 博文:http://blog.csdn.net/zxt0601/article/details/53315975

我们的Demo,Ac娘镇楼

Usage 用法:

Step 1. Add the JitPack repository to your build file 在项目根build.gradle文件中增加JitPack仓库依赖。

    allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

Step 2. Add the dependency

    dependencies {
	        compile 'com.github.mcxtzhang:SwipeCaptcha:V1.0.0'
	}

Step 3.

    <com.mcxtzhang.captchalib.SwipeCaptchaView
        android:id="@+id/swipeCaptchaView"
        android:layout_width="300dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:scaleType="centerCrop"
        tools:src="@drawable/pic11"
        app:captchaHeight="30dp"
        app:captchaWidth="30dp"/>

    <SeekBar
        android:id="@+id/dragBar"
        android:layout_width="320dp"
        android:layout_height="60dp"
        android:layout_below="@id/swipeCaptchaView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:progressDrawable="@drawable/dragbg"
        android:thumb="@drawable/thumb_bg"/>

那么本控件包含不仅包含以下功能:

  • 随机区域**起点(左上角x,y)**生成一个验证码阴影。
  • 验证码拼图 凹凸图形会随机变换。
  • 验证码区域宽高可自定义。
  • 抠图验证码区域,绘制一个用于联动滑动的验证码滑块。
  • 验证失败,会闪烁几下然后回到原点。
  • 验证成功,会有白光扫过的动画。

分解一下验证码核心实现思路:

  • 控件继承自ImageView。理由: 1 如果放在项目中用,验证码图片希望可以是接口返回。ImageView以及其子类支持花式加载图片。 2 继承自ImageView,绘制图片本身不用我们干预,也不用我们操心scaleType,节省很多工作。
  • onSizeChanged()方法中生成 和 控件宽高相关的属性值: 1 初始化时随机生成验证码区域起点 2 生成验证码区域Path 3 生成滑块Bitmap
  • onDraw()时,依次绘制: 1 验证码阴影 2 滑块

to do list,待完善

  • abstract dragbar(seekbar) interface

  • SwipeCaptcha inside to hold the interface to do something

  • 抽象拖动条接口

  • SwipeCaptcha内部要持有这个接口 做一些事情

swipecaptcha's People

Contributors

mcxtzhang avatar

Watchers

James Cloos 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.