功能分类:工具
成都创新互联公司服务项目包括汤阴网站建设、汤阴网站制作、汤阴网页制作以及汤阴网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,汤阴网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到汤阴省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
支持平台:Android
运行环境:Eclipse
开发语言:Java
开发工具:Eclipse
源码大小:1.06MB
源码下载:http://down.cdcxhl.com/data/1976924
源码简介
我的手势锁方便用户的登录,第一次登入时候输入用户名和密码,设置手势密码;再次登录时,只需要手势密码正确,即可登录成功。
源码运行截图
登录界面
提示创建手势密码
演示创建手势密码
创建手势密码
手势密码解锁
源码片段
- package com.zhangyx.MyGestureLock.gesture;
- import java.util.List;
- import com.lidroid.xutils.ViewUtils;
- import com.lidroid.xutils.view.annotation.ViewInject;
- import com.zhangyx.MyGestureLock.BaseActivity;
- import com.zhangyx.MyGestureLock.LoginActivity;
- import com.zhangyx.MyGestureLock.MainActivity;
- import com.zhangyx.MyGestureLock.R;
- import com.zhangyx.MyGestureLock.app.MyApplication;
- import com.zhangyx.MyGestureLock.util.AnimationUtil;
- import com.zhangyx.MyGestureLock.view.LockPatternUtils;
- import com.zhangyx.MyGestureLock.view.LockPatternView;
- import com.zhangyx.MyGestureLock.view.LockPatternView.Cell;
- import android.annotation.SuppressLint;
- import android.content.Intent;
- import android.graphics.Color;
- import android.os.Bundle;
- import android.os.CountDownTimer;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.widget.Button;
- import android.widget.LinearLayout;
- import android.widget.TextView;
- /***
- * 解锁登录
- *com.zhangyx.MyGestureLock.gesture.UnlockGesturePasswordActivity
- * @author Admin-zhangyx
- *
- * create at 2015-1-16 下午3:09:47
- */
- @SuppressLint("ResourceAsColor")
- public class UnlockGesturePasswordActivity extends BaseActivity {
- private LockPatternView mLockPatternView;
- private int mFailedPatternAttemptsSinceLastTimeout = 0;
- private CountDownTimer mCountdownTimer = null;
- // private Handler mHandler = new Handler();
- private Animation mShakeAnim;
- @ViewInject(R.id.gesturepwd_unlock_text)
- private TextView mHeadTextView;
- @ViewInject(R.id.rootView)
- private LinearLayout rootView;
- @ViewInject(R.id.changeUser)
- private Button changeUser;// 切换用户、清除手势锁
- private MyApplication app;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.gesturepassword_unlock);
- ViewUtils.inject(this);
- app=(MyApplication) getApplication();
- mLockPatternView = (LockPatternView) findViewById(R.id.gesturepwd_unlock_lockview);
- mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
- mLockPatternView.setTactileFeedbackEnabled(true);
- mShakeAnim = AnimationUtils.loadAnimation(this, R.anim.shake_x);
- changeUser.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- // 清除 手势文件
- app.getLockPatternUtils().clearLock();
- toLoginActivity();
- }
- });
- }
- @Override
- protected void onResume() {
- super.onResume();
- // 从未创建过手势时,开始创建---没有记住密码
- if (!app.getLockPatternUtils().savedPatternExists()) {
- toLoginActivity();
- }
- }
- private void toLoginActivity() {
- startActivity(new Intent(UnlockGesturePasswordActivity.this,
- LoginActivity.class));
- AnimationUtil
- .finishActivityAnimation(UnlockGesturePasswordActivity.this);
- }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (mCountdownTimer != null)
- mCountdownTimer.cancel();
- }
- private Runnable mClearPatternRunnable = new Runnable() {
- public void run() {
- mLockPatternView.clearPattern();
- }
- };
- protected LockPatternView.OnPatternListener mChooseNewLockPatternListener = new LockPatternView.OnPatternListener() {
- @Override
- public void onPatternStart() {
- // TODO Auto-generated method stub
- mLockPatternView.removeCallbacks(mClearPatternRunnable);
- patternInProgress();
- }
- public void onPatternDetected(List
pattern) { | - // TODO Auto-generated method stub
- if (pattern == null)
- return;
- if (app.getLockPatternUtils()
- .checkPattern(pattern)) {// 解锁成功
- mLockPatternView
- .setDisplayMode(LockPatternView.DisplayMode.Correct);
- // 解锁成功返回需要用户信息的页面----
- loginSuccessToMainAcrtivity() ;
- } else {// 解锁失败-----重新登录
- mLockPatternView
- .setDisplayMode(LockPatternView.DisplayMode.Wrong);
- if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
- mFailedPatternAttemptsSinceLastTimeout++;
- int retry = LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT
- - mFailedPatternAttemptsSinceLastTimeout;
- if (retry > 0) {
- changeUser.setVisibility(View.VISIBLE);
- if (retry == 0)
- showToast(UnlockGesturePasswordActivity.this
- .getString(R.string.toastlock));
- mHeadTextView.setText("密码错误,还可以再输入" + retry + "次");
- mHeadTextView.setTextColor(Color.RED);
- mHeadTextView.startAnimation(mShakeAnim);
- } else {
- // 打开新的Activity
- // 清除 手势文件
- app.getLockPatternUtils().clearLock();
- toLoginActivity();
- }
- } else {
- showToast("输入长度不够,请重试");
- }
- mLockPatternView.clearPattern();
- }
- }
- @Override
- public void onPatternCleared() {
- // TODO Auto-generated method stub
- mLockPatternView.removeCallbacks(mClearPatternRunnable);
- }
- private void patternInProgress() {
- }
- @Override
- public void onPatternCellAdded(List
pattern) { | - // TODO Auto-generated method stub
- }
- };
- Runnable attemptLockout = new Runnable() {
- @Override
- public void run() {
- mLockPatternView.clearPattern();
- mLockPatternView.setEnabled(false);
- mCountdownTimer = new CountDownTimer(
- LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS + 1, 1000) {
- @Override
- public void onTick(long millisUntilFinished) {
- int secondsRemaining = (int) (millisUntilFinished / 1000) - 1;
- if (secondsRemaining > 0) {
- mHeadTextView.setText(secondsRemaining + " 秒后重试");
- } else {
- mHeadTextView
- .setText(UnlockGesturePasswordActivity.this
- .getString(R.string.gesture_drawPwd));
- mHeadTextView.setTextColor(Color.WHITE);
- }
- }
- @Override
- public void onFinish() {
- mLockPatternView.setEnabled(true);
- mFailedPatternAttemptsSinceLastTimeout = 0;
- }
- }.start();
- }
- };
- // 登录成功
- private void loginSuccessToMainAcrtivity() {
- startActivity(new Intent(UnlockGesturePasswordActivity.this,
- MainActivity.class));
- AnimationUtil
- .finishActivityAnimation(UnlockGesturePasswordActivity.this);
- }
- }
源码下载:http://down.cdcxhl.com/data/1976924
分享题目:Android源码下载:我的手势锁
文章源于:http://www.shufengxianlan.com/qtweb/news31/492631.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联