{"id":13786850,"url":"https://github.com/aabhasr1/OtpView","last_synced_at":"2025-05-12T00:30:32.734Z","repository":{"id":40636952,"uuid":"165002565","full_name":"aabhasr1/OtpView","owner":"aabhasr1","description":"A custom view to enter otp/pin of different sizes used usually in cases of authentication.","archived":false,"fork":false,"pushed_at":"2023-04-29T17:22:06.000Z","size":2516,"stargazers_count":389,"open_issues_count":36,"forks_count":98,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T21:36:52.725Z","etag":null,"topics":["android","android-application","android-library","java","java-8","library","otp","pinview","pinview-library","xml"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aabhasr1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-01-10T06:20:47.000Z","updated_at":"2025-03-12T09:45:16.000Z","dependencies_parsed_at":"2024-01-31T16:36:39.249Z","dependency_job_id":"38ef631d-3d08-4810-af49-02ad56c9e1bc","html_url":"https://github.com/aabhasr1/OtpView","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabhasr1%2FOtpView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabhasr1%2FOtpView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabhasr1%2FOtpView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabhasr1%2FOtpView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aabhasr1","download_url":"https://codeload.github.com/aabhasr1/OtpView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655746,"owners_count":21943067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-application","android-library","java","java-8","library","otp","pinview","pinview-library","xml"],"created_at":"2024-08-03T20:00:19.735Z","updated_at":"2025-05-12T00:30:31.974Z","avatar_url":"https://github.com/aabhasr1.png","language":"Kotlin","readme":"\u003ch1 align=\"center\"\u003eOtpView\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  Note: Help Needed in Maintainance. Please raise PR if you think some changes are needed and i will merge them.\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.codacy.com/app/aabhasr1/OtpView?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=aabhasr1/OtpView\u0026amp;utm_campaign=Badge_Grade\"\u003e\u003cimg src=\"https://api.codacy.com/project/badge/Grade/17a91c73a65e42de8cf4b0b2a3e64aa6\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/aabhasr1/OtpView\"\u003e\u003cimg src=\"https://travis-ci.com/aabhasr1/OtpView.svg?branch=master\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://jitpack.io/#aabhasr1/OtpView\"\u003e\u003cimg src=\"https://jitpack.io/v/aabhasr1/OtpView.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://jitpack.io/#aabhasr1/OtpView\"\u003e\u003cimg src=\"https://jitpack.io/v/aabhasr1/OtpView/month.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://android-arsenal.com/details/1/7514\"\u003e\u003cimg src=\"https://img.shields.io/badge/Android%20Arsenal-OtpView-green.svg?style=flat\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cp align=\"center\"\u003e\n   An OTP Box implementation for case when a single digit should be entered Individually.\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"screenshots/otp_view_1.gif\" width=\"270\" height=\"500\" /\u003e \u0026nbsp;\u0026nbsp;\n\u003cimg src=\"screenshots/otp_view_2.gif\" width=\"270\" height=\"500\" /\u003e \u0026nbsp;\u0026nbsp;\n\u003cbr\u003e\u003cbr\u003e\n\u003cimg src=\"screenshots/otp_view_3.gif\" width=\"270\" height=\"500\" /\u003e \u0026nbsp;\u0026nbsp;\n\u003cimg src=\"screenshots/otp_view_4.gif\" width=\"270\" height=\"500\" /\u003e \u0026nbsp;\u0026nbsp;\n\u003c/p\u003e\n\n\n## Installation in your Project\n\nStep 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:\n\n```java\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\n\nStep 2. Add the dependency\n\n```java\ndependencies {\n        implementation 'com.github.aabhasr1:OtpView:v1.1.2-ktx' // kotlin\n}\n```\n\n  or\n\n```java\ndependencies {\n        implementation 'com.github.aabhasr1:OtpView:v1.1.2'\n}\n```\n\n## How to use the library?\n\nJust add the following to your **xml** design to show the otpview\n\n```xml\n.....\n\u003cin.aabhasjindal.otptextview.OtpTextView\n\tandroid:id=\"@+id/otp_view\"\n\tandroid:layout_width=\"wrap_content\"\n\tandroid:layout_height=\"wrap_content\"\n\tandroid:textColor=\"#ffffff\"\n\tapp:height=\"40dp\"\n\tapp:width=\"40dp\"\n\tapp:bar_enabled=\"true\"\n\tapp:bar_height=\"2dp\"\n\tapp:length=\"4\"\n\tapp:otp=\"1234\"\n\tapp:otp_text_size=\"24dp\"/\u003e\n.....\n```\n\nTo get a callback when the user enters the otp make use of `OTPListener` Interface\n\n```java\nprivate OtpTextView otpTextView;\notpTextView = findViewById(R.id.otp_view);\notpTextView.setOtpListener(new OTPListener() {\n\t@Override\n\tpublic void onInteractionListener() {\n\t// fired when user types something in the Otpbox\n\t}\n\t@Override\n\tpublic void onOTPComplete(String otp) {\n\t// fired when user has entered the OTP fully.\n\t    Toast.makeText(MainActivity.this, \"The OTP is \" + otp,  Toast.LENGTH_SHORT).show();\n    }\n});\n```\n\nyou also get some additional methods like :\n\n```java\notpTextView.getOtpListener();  // retrieves the current OTPListener (null if nothing is set)\notpTextView.requestFocusOTP();\t//sets the focus to OTP box (does not open the keyboard)\notpTextView.setOTP(otpString);\t// sets the entered otpString in the Otp box (for case when otp is retreived from SMS)\notpTextView.getOTP();\t// retrieves the OTP entered by user (works for partial otp input too)\notpTextView.showSuccess();\t// shows the success state to the user (can be set a bar color or drawable)\notpTextView.showError();\t// shows the success state to the user (can be set a bar color or drawable)\notpTextView.resetState();\t// brings the views back to default state (the state it was at input)\n```\n\nThats all for now but new additions will be made frequently.\n\n## OtpView Attributes\n\n| Attribute                       | Use                                                          |\n| ------------------------------- | ------------------------------------------------------------ |\n| android:textColor               | sets the color of the otp text                               |\n| app:otp                         | sets the otp in the otp view                                 |\n| app:length                      | sets the no of otp box in the otp view                       |\n| app:otp_text_size               | sets the otp text size in the otp view                       |\n| app:text_typeface               | sets the otp text typeface in the otp view                   |\n| app:hide_otp                    | sets if the otp entered is to be shown to the user           |\n| app:hide_otp_drawable           | replaces the pin bullet which is shown to the user when hide_otp is enabled |\n| app:height                      | sets the height of each box inside the otp view              |\n| app:width                       | sets the width of each box inside the otp view               |\n| app:box_margin                  | sets the space between each box in otp view                  |\n| app:box_margin_left             | sets the left space between each box in otp view             |\n| app:box_margin_right            | sets the right space between each box in otp view            |\n| app:box_margin_top              | sets the top space of each box in otp view                   |\n| app:box_margin_bottom           | sets the bottom space of each box in otp view                |\n| app:bar_enabled                 | shows a bar below each otp box to the user                   |\n| app:bar_height                  | sets the bar height                                          |\n| app:bar_margin                  | sets the bar margin within each box in otp view              |\n| app:bar_margin_left             | sets the bar left margin within each box in otp view         |\n| app:bar_margin_right            | sets the bar right margin within each box in otp view        |\n| app:bar_margin_top              | sets the bar top margin within each box in otp view          |\n| app:bar_margin_bottom           | sets the bar bottom margin within each box in otp view       |\n| app:bar_active_color            | sets the bar color when the cursor is on the box in otp view |\n| app:bar_inactive_color          | sets the bar color when the cursor is not on the box in otp view |\n| app:bar_error_color             | sets the bar color for error state in otp view               |\n| app:bar_success_color           | sets the bar color for success state in otp view             |\n| app:otp_box_background          | sets the box background in otp view                          |\n| app:otp_box_background_active   | sets the box background when the cursor is on the box in otp view |\n| app:otp_box_background_inactive | sets the box background when the cursor is not on the box in otp view |\n| app:otp_box_background_error    | sets the box background for error state in otp view          |\n| app:otp_box_background_success  | sets the box background for success state in otp view        |\n\n## Author\n\nMaintained by  [Aabhas Jindal](https://github.com/aabhasr1)\n\n## Contribution\n\n-   Bug reports and pull requests are welcome.\n-   Make sure you use  [square/java-code-styles](https://github.com/square/java-code-styles)  to format your code.\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2019 Aabhas Jindal\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":["Library"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabhasr1%2FOtpView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faabhasr1%2FOtpView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabhasr1%2FOtpView/lists"}