GithubHelp home page GithubHelp logo

githubwbb123 / handlibrary Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 137 KB

这是一个手势密码库,可直接依赖,替换MainActivity和strings文件,里面有相关字符,也可以自定义进入手势页面,通过onActivityResult返回主界面。

Java 100.00%

handlibrary's Introduction

HandLibrary

这是一个手势密码库,可直接依赖,替换MainActivity和strings文件,里面有相关字符,也可以自定义进入手势页面,通过onActivityResult返回主界面。

步骤如下:

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

2.implementation 'com.github.GitHubwbb123:HandLibrary:v1.0.0'

3.MainActivity.java

package com.wxb.包名;

import android.content.Intent; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast;

import com.wxb.handlibrary.PatternLockActivity;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.patternlock_setting).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent=new Intent(MainActivity.this,PatternLockActivity.class);
            intent.putExtra("type","setting");
            startActivityForResult(intent,100);//设置的回调,目标活动只能有一个请求码,请求码是活动的标志
        }
    });
    findViewById(R.id.patternlock_open).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent=new Intent(MainActivity.this,PatternLockActivity.class);
            intent.putExtra("type","open");
            startActivityForResult(intent,100);//验证回调
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    switch (requestCode){
        case 100://PatternLockActivity界面数据返回,result=2,设置成功。result=1,验证成功。
            if(resultCode==RESULT_OK){
                Integer result=data.getIntExtra("result",-1);
                if(result==1)
                {
                    Toast.makeText(MainActivity.this,result.toString(),Toast.LENGTH_SHORT).show();
                }
                else if(result==2)
                {
                    Toast.makeText(MainActivity.this,result.toString(),Toast.LENGTH_SHORT).show();
                }
            }
            break;

    }
}

} 4.activity_main.xml

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.wxb.包名.MainActivity">

<TextView
    android:id="@+id/patternlock_setting"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="20dp"
    android:text="@string/setting"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintVertical_bias="0.0"
    android:layout_marginTop="8dp"
    app:layout_constraintHorizontal_bias="0.0" />
<TextView
    android:id="@+id/patternlock_open"
    android:layout_width="0dp"
    android:layout_height="57dp"
    android:gravity="center"
    android:padding="20dp"
    android:text="@string/open"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintVertical_bias="0.0"
    app:layout_constraintHorizontal_bias="0.0"
    android:layout_marginTop="0dp"
    app:layout_constraintTop_toBottomOf="@+id/patternlock_setting" />

</android.support.constraint.ConstraintLayout> 5.strings.xml HandLock 设置 解锁 搞定!!!

注意修改包名!!切记

handlibrary's People

Contributors

githubwbb123 avatar

Watchers

 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.