Code Monkey home page Code Monkey logo

pinview-android's Introduction

PinView-Android

Gradle Dependency

Add the following in your root build.gradle at the end of repositories:

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

Add this in your module's build.gradle

dependencies {
        implementation 'com.github.darshan-miskin:PinView-Android:v1.1.8'
}

Features

  • Supports Paste via clipboard flawlessly.
  • Password toggle to hide/show text on the go.
  • Easy getText() and setText() methods like a regular EditText.
  • Listener to detect when the pin is completely entered.
  • Customizable pin background, textsize and pinsize.
  • Customizable toggle tint/color and size.
  • Flag to set password input type.

Usage

XML:

<com.gne.www.lib.PinView
    android:id="@+id/pinview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:textColor="@color/colorAccent"
    app:pinCount="5"
    app:inputType="number"
    app:isPassword="false"
    app:showPasswordToggle="true"
    app:pinBackground="@drawable/pin_background"
    app:pinSize="30dp"
    app:passwordToggleSize="26dp"
    app:passwordToggleColor="@color/colorAccent"
    app:pinText="Hello"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/>

Java:

    PinView pinView=findViewById(R.id.pinview);
    
    pinView.setPinCount(6);                      //set total number of pins
    pinView.setText("helllooo");                 //set text for the pinview
    pinView.setPinBackground(getResources().getDrawable(R.drawable.pin_background));  //pin style
    pinView.setPassword(false);                  //password flag. If true dotted format will be visible
    pinView.getText();                           //get text from pinview
    pinView.setPinSize(40);                      //set size of pin in dp
    pinView.setInputType(InputType.TYPE_TEXT);   // or InputType.TYPE_NUMBER
    pinView.setShowPasswordToggle(true);         //make the password toggle visible
    pinView.requestPinFocus();                   //request focus at zeroth position pin
    pinView.requestPinFocus(4);                  //request focus on pin at 4th index, defaults to zeroth if invalid index
    pinView.setPasswordToggleColor(getResources().getColor(R.color.colorPrimary)); //set toggle drawable tint/color
    pinView.setPinTextSize(23);                  //set pin text size in sp
    pinView.setPasswordToggleSize(20);           //set password toggle size in dp
    pinView.setTextColor(getResources().getColor(R.color.colorPrimary));  
    
    pinView.setOnPinCompletionListener(new OnPinCompletedListener() {
        @Override
        public void onPinCompleted(String entirePin) {
            Toast.makeText(MainActivity.this,"Text Entered",Toast.LENGTH_LONG).show();
        }
    });

License

MIT License

Copyright (c) 2019 Darshan Miskin

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.

pinview-android's People

Contributors

darshan-miskin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ravindu1024

pinview-android's Issues

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.