From 8baddf379e48a31a0491e17c37f39e23b74b32cd Mon Sep 17 00:00:00 2001 From: Swapnil Tiwari Date: Sat, 9 May 2020 10:44:22 +0530 Subject: [PATCH 1/2] Added Shake animation --- .idea/gradle.xml | 11 +++-- app/build.gradle | 6 +++ .../broooapps/otpedittext/MainActivity.java | 26 ++++++++---- app/src/main/res/layout/activity_main.xml | 41 ++++++++++--------- build.gradle | 4 +- otpedittext2/build.gradle | 6 +++ .../broooapps/otpedittext2/OtpEditText.java | 37 ++++++++++++----- otpedittext2/src/main/res/anim/shake.xml | 8 ++++ readme.md | 13 ++++++ 9 files changed, 108 insertions(+), 44 deletions(-) create mode 100644 otpedittext2/src/main/res/anim/shake.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 2996d53..4d32e50 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,12 +3,17 @@ diff --git a/app/build.gradle b/app/build.gradle index 4dd50ae..ba00a65 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'com.android.application' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' android { compileSdkVersion 28 @@ -28,4 +30,8 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} +repositories { + mavenCentral() } diff --git a/app/src/main/java/com/broooapps/otpedittext/MainActivity.java b/app/src/main/java/com/broooapps/otpedittext/MainActivity.java index 2e9c56d..1fca86b 100644 --- a/app/src/main/java/com/broooapps/otpedittext/MainActivity.java +++ b/app/src/main/java/com/broooapps/otpedittext/MainActivity.java @@ -1,37 +1,45 @@ package com.broooapps.otpedittext; import androidx.appcompat.app.AppCompatActivity; + +import android.annotation.SuppressLint; import android.os.Bundle; import android.view.View; -import android.widget.EditText; import android.widget.TextView; -import android.widget.Toast; import com.broooapps.otpedittext2.OnCompleteListener; import com.broooapps.otpedittext2.OtpEditText; public class MainActivity extends AppCompatActivity { + TextView textDisplay; + OtpEditText otpEditText; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - OtpEditText editText = findViewById(R.id.top); + otpEditText = findViewById(R.id.oev_view); + + textDisplay = findViewById(R.id.text_display); + - editText.setOnCompleteListener(new OnCompleteListener() { + otpEditText.setOnCompleteListener(new OnCompleteListener() { + @SuppressLint("SetTextI18n") @Override public void onComplete(String value) { - Toast.makeText(MainActivity.this, "Completed " + value, Toast.LENGTH_SHORT).show(); + textDisplay.setText("Entered Value: " + value); } }); + } public void displayText(View view) { - - String input = String.valueOf(((EditText) findViewById(R.id.top)).getText()); - ((TextView) findViewById(R.id.textView)).setText(input); - + String otpValue = otpEditText.getOtpValue(); + if (otpValue != null) { + textDisplay.setText("Entered Value: " + otpEditText.getOtpValue()); + } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 473d9c6..b5b9bb2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,20 +4,20 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#444444" tools:context=".MainActivity"> + app:oev_mask_input="true" + app:oev_primary_color="#CCFF00" + app:oev_secondary_color="#DADADA" + app:oev_text_color="#dd1212" + tools:layout_editor_absoluteX="0dp" />