• Stars
    star
    668
  • Rank 65,970 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An EditText that looks like a pin entry field. It is highly customisable and even animated text.

Build Status

PinEntryEditText for Android

This repository contains PinEntryEditText which extends the behaviour of EditText and implement features that are otherwise not available.

PinEntryEditText

Features

PinEntryEditText

  • Number of pin characters is configurable. You can use the maxLength property to define however long you want your pin to be.
  • PinEntryEditText which supports text animating in.
  • Lets you specify any unicode character to be used as a mask for input.
  • Specify drawable as the foreground/background.

Usage

Below is a fast guide to getting started. However, if you need to read about these widgets in details. Read more about PinEntryEditText.

NOTE: Make sure jcenter() is one of the repositories mentioned in your build.gradle. This used to be the default repository for Android but since then has changed the google() This needs to be set in your top level build.gradle: <project root>/build.gradle

buildscript {
    repositories {
        jcenter()
        ...
    }
    ...
}

STEP-1

Gradle

Jetpack support in version 2.0 Download:

dependencies {
    implementation ('com.alimuzaffar.lib:pinentryedittext:2.0.6') {
        // Exclude is only needed if you already have
        // androidx.appcompat as a dependency in your app.
        exclude group: 'androidx.appcompat', module: 'appcompat'
    }
}

If you don't use Jetpack, use version 1.3.X Download

dependencies {
    implementation ('com.alimuzaffar.lib:pinentryedittext:1.3.10') {
        // Exclude is only needed if you already have
        // any of the following as a dependency in your project.
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'support-v13'
    }
}

Note: You don't need to exclude all the support groups. However, it's a good idea to do this as your code is likely to use a different version from the library.

STEP-2

Setup PinEntryEditText in your layout

<com.alimuzaffar.lib.pin.PinEntryEditText
    android:id="@+id/txt_pin_entry"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:cursorVisible="false" //recommended
    android:digits="1234567890"
    android:inputType="number"
    android:maxLength="4" //required
    android:textIsSelectable="false" //recommended
    android:textSize="20sp"
    app:pinBackgroundDrawable="@drawable/bg_pin" //optional, use your own pin char background
    app:pinAnimationType="popIn|fromBottom|none" //optional, default popIn
	app:pinCharacterMask="*" //optional, default bullet
	app:pinSingleCharHint="#" //optional, hint for each characters
	app:pinTextBottomPadding="@dimen/space" //optional, space between character and bottom line.
	app:pinLineStroke="2dp" //the stroke (height) of the bottom line by default.
	app:pinLineStrokeSelected="4dp" //the stroke (height) of the bottom line when field is focused.
	app:pinBackgroundIsSquare="true|false" //optional, if you want the background drawable to be a square or circle width of each digit will be set to match the height of the widget.
    app:pinLineColors="@color/pin_line_colors" //optional
    android:layoutDirection="ltr|rtl"
    />

Listen for pin entry

final PinEntryEditText pinEntry = (PinEntryEditText) findViewById(R.id.txt_pin_entry);
if (pinEntry != null) {
    pinEntry.setOnPinEnteredListener(new PinEntryEditText.OnPinEnteredListener() {
        @Override
        public void onPinEntered(CharSequence str) {
            if (str.toString().equals("1234")) {
                Toast.makeText(AnimatedEditTextWidgetsActivity.this, "SUCCESS", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(AnimatedEditTextWidgetsActivity.this, "FAIL", Toast.LENGTH_SHORT).show();
                pinEntry.setText(null);
            }
        }
    });
}

Use your own Drawable as a pin character background

You can use your own drawable for the pin entry background by specifying the app:pinBackgroundDrawable attribute in the xml. If you want to specify the empty and filled states using your background drawable you can set the textColor to transparent and setup your drawable as follows:

<!--
    Please look at the sample app's bg_pin.xml
    or bg_pin_round.xml for all available options
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Space contains text -->
    <item android:state_focused="true" android:state_checked="true">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/holo_green_light"/>
        </shape>
    </item>
    <!--Space is the next space for character input -->
    <item android:state_focused="true" android:state_selected="true">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/holo_blue_bright"/>
        </shape>
    </item>
    <!-- PinEntryEditText is focused -->
    <item android:state_focused="true">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
        </shape>
    </item>
    <!-- PinEntryEditText is not focused -->
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/darker_gray"/>
        </shape>
    </item>
</selector>

Note that in this setup, the size of the drawable will be determined by the textSize and and the pinTextBottomPadding which is the space between the character and the line below (or the bottom of the pinBackgroundDrawable). For good measure, set pinAnimationType to none as well.

Effects :

  1. PopIn (default)
  2. Bottom Up

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

AnimatedEditText

Androids EditText that animates the typed text. EditText is extended to create AnimatedEditText and a PinEntryEditText.
Java
442
star
2

android-widget-ticktock

Count down, count up, tick... tock...
Java
201
star
3

android-widget-fanmenu

Android fan menu
Java
197
star
4

android-widget-connectpattern

Draw a pattern to confirm the action, unlock the screen etc.
Java
135
star
5

android-MVVM-DataBinding-RecyclerViewExample

A demo of how to use Jetpack architecture and lifecycle component to implement a RecyclerView. The example has async image loading and item click handling.
Java
101
star
6

ThreadPoolWithCameraPreview

Demo of using threadpools to improve performance on Android
Java
88
star
7

LoopingViewPagerDemo

A demo app for trying to implement a looping ViewPager with a page indicator
Java
65
star
8

PrayTime-Android

Android app for calculating Muslim prayer times and setting and alarm for the prayer times.
Java
64
star
9

android-MVVM-DataBinding-FormExample

A demo of how to use Jetpack architecture and lifecycle component to implement a form. This includes validation and submit.
Java
63
star
10

KotlinFullstackSample

A sample project using Kotlin for backend and front-end (JavaScript)
Kotlin
54
star
11

android-gestures-tutorial

How to detect multiple gestures on Android. Most applications tend to only listen for a simple touch gesture, perhaps the odd app with listen for a swipe or fling... what if you had an application that in a single view had to handle a LOT of Gestures and Taps.
Java
47
star
12

FrostyBackgroundTestApp

An android app demonstrating how to create a blurred and frosted background effect.
Java
39
star
13

RxAndroidDemo

Sample app using RxJava and RxAndroid
Java
31
star
14

android-widget-dotsprogressindicator

Indeterminate progress indicator for android that shows a dots bouncing animation for the progress indicator.
Kotlin
25
star
15

RatioImageView

An Android ImageView that increases the height of the image view automatically so that the image loaded in it retains it's aspect ratio
Java
25
star
16

ReflowTextExample

How to perform shared element activity transition on text while changing text size and color.
Java
14
star
17

Group-Deal-Clone

A Java clone for sites such as GroupOn. This uses Spring 3, Hibernate 4, Apache Tiles and Maven.
Java
10
star
18

sun-status-app

An Android app to calculate the sunrise and sunset times and to allow you to set alerts for sunrise or sunset.
Java
6
star
19

reactjs-webpack-bundle-not-working-demo

This project shows how to reproduce and fix an issue with react projects where webpack-dev-server does not automatically bundle files after changes.
JavaScript
5
star
20

GitHubReleasesDownloader

A quick and dirty application that allows you to download APKs from your GitHub releases. After the file downloads, an install is automatically triggered. This can be useful for testers and small teams to distribute builds internally. It also really helps if you build APKs on Travis and push the APKs to GitHub releases.
Java
5
star
21

android-app-bootstrap-kotlin

An Android app (kotlin) that is pre-configured Dagger, Retrofit, Room and Jetpack
Kotlin
4
star
22

android-child-lock

In development - a way to lock apps and protect access to them using a pin
Java
4
star
23

GPRC-Gateway-Example

A simple example of using GoLang with GRPC and GRPC Gateway to create a RESTful API that connects to MySql.
Go
3
star
24

android-ics-query-calendar

Example on how to query android's local calendar.
Java
2
star
25

GoogleVolleyWithApache4

Google Volley built using Apache 4 (Currently 4.4.1.2)
Java
2
star
26

WeatheringHeights

Weather app based off OpenWeather API
Java
2
star
27

yo-android-app

A Yeoman generator for an android app that uses Dagger, Retrofit, Room, Jetpack and Glide.
Java
2
star
28

lotto-picker-in-c

A lotto picker that has been written in C. Guaranteed to pick winning numbers randomly! (Note: winning numbers may not be for lotteries of past decade)
C
2
star
29

jQuery-Checkbox-Search-Plugin

jQuery Checkbox Search plugin lets you search all checkboxes in a page and select them from within a input field (text)
1
star
30

GDPR-for-developers

A quick write-up on what developers need to know about GDPR.
1
star
31

c-hard-way-learning-exercises

The exercises I did from Zed Shaw's learn C the hard way. http://c.learncodingthehardway.org
C
1
star
32

wallstreet-test-graphql

JavaScript
1
star
33

sypht-android-sample

Preview bills that have been emailed to you by using Sypht API
Kotlin
1
star
34

java-datastructures-algorithms

Java implementation of some common datastructures and algorithms
Java
1
star
35

power-nap-widget

Power nap widget is a simple Android widget that displays 4 buttons and displaying time intervals and lets the user select how long they want to nap for. After the selected period of time an alarm is sound.
Java
1
star