Skip to content

Commit

Permalink
[Upgrade] Convert to Kotlin
Browse files Browse the repository at this point in the history
Signed-off-by: aabhasjindal <aabhas.j@zolostays.com>
  • Loading branch information
aabhasjindal committed Oct 15, 2019
1 parent 4eb7da5 commit c4d418f
Show file tree
Hide file tree
Showing 22 changed files with 596 additions and 664 deletions.
7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
Expand Down Expand Up @@ -29,4 +31,9 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.GrenderG:Toasty:1.4.0'
implementation "androidx.core:core-ktx:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package `in`.aabhasjindal.otpview

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {

}
}
56 changes: 0 additions & 56 deletions app/src/main/java/in/aabhasjindal/otpview/MainActivity.java

This file was deleted.

40 changes: 40 additions & 0 deletions app/src/main/java/in/aabhasjindal/otpview/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package `in`.aabhasjindal.otpview

import `in`.aabhasjindal.otptextview.OTPListener
import `in`.aabhasjindal.otptextview.OtpTextView
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import es.dmoral.toasty.Toasty

class MainActivity : AppCompatActivity() {
private var otpTextView: OtpTextView? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val window = window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = resources.getColor(R.color.black)
}
val errorButton = findViewById<Button>(R.id.button)
val successButton = findViewById<Button>(R.id.button2)
otpTextView = findViewById(R.id.otp_view)
otpTextView?.requestFocusOTP()
otpTextView?.otpListener = object : OTPListener {
override fun onInteractionListener() {

}

override fun onOTPComplete(otp: String) {
Toasty.success(this@MainActivity, "The OTP is $otp", Toast.LENGTH_SHORT).show()
}
}
errorButton.setOnClickListener { otpTextView?.showError() }
successButton.setOnClickListener { otpTextView?.showSuccess() }
}
}
17 changes: 0 additions & 17 deletions app/src/test/java/in/aabhasjindal/otpview/ExampleUnitTest.java

This file was deleted.

16 changes: 16 additions & 0 deletions app/src/test/java/in/aabhasjindal/otpview/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package `in`.aabhasjindal.otpview

import org.junit.Assert.assertEquals
import org.junit.Test

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
class ExampleUnitTest {
@Test
fun additionIsCorrect() {
assertEquals(4, (2 + 2).toLong())
}
}
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

ext.kotlin_version = '1.3.50'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.android.tools.build:gradle:3.2.1'

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
7 changes: 7 additions & 0 deletions otptextview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.aabhasjindal'

Expand Down Expand Up @@ -31,4 +33,9 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api "androidx.core:core-ktx:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package `in`.aabhasjindal.otptextview

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()

assertEquals("in.aabhasjindal.otptextview.test", appContext.getPackageName())
}
}
Loading

0 comments on commit c4d418f

Please sign in to comment.