Skip to content

migrated to AndroidX #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 28

defaultConfig {
applicationId "com.andrognito.pinlockviewapp"
minSdkVersion 11
targetSdkVersion 25
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -19,9 +20,23 @@ android {
}
}

allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile project(':pinlockview')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':pinlockview')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.core:core-ktx:1.0.1"
}
repositories {
mavenCentral()
}

This file was deleted.

103 changes: 103 additions & 0 deletions app/src/main/java/com/andrognito/pinlockviewapp/SampleActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.andrognito.pinlockviewapp

import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.Window
import android.view.WindowManager
import android.view.animation.AnimationUtils
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.andrognito.pinlockview.IndicatorDots
import com.andrognito.pinlockview.PinLockListener
import com.andrognito.pinlockview.PinLockView

class SampleActivity : AppCompatActivity() {

private var mPinLockView: PinLockView? = null
private var mIndicatorDotsFirst: IndicatorDots? = null
private var mIndicatorDotsSecond: IndicatorDots? = null

private val mPinLockFirstListener = object : PinLockListener {
override fun onComplete(pin: String) {
Log.d(TAG, "Pin complete: $pin")
val shake = AnimationUtils.loadAnimation(this@SampleActivity, R.anim.shake_wrong)
if (pin == "1111") {
mIndicatorDotsFirst!!.setSuccessDots()
} else {
mIndicatorDotsFirst!!.setErrorDots()
mIndicatorDotsFirst!!.startAnimation(shake)
}
Handler().postDelayed({
mIndicatorDotsFirst!!.setDefaultDots()
mPinLockView!!.resetPinLockView()

// mPinLockView.attachIndicatorDots(mIndicatorDotsSecond);
}, 1000)
}

override fun onEmpty() {
Log.d(TAG, "Pin empty")
}

override fun onPinChange(pinLength: Int, intermediatePin: String) {
Log.d(TAG, "Pin changed, new length $pinLength with intermediate pin $intermediatePin")
}
}

private val mPinLockSecondListener = object : PinLockListener {
override fun onComplete(pin: String) {
Log.d(TAG, "Pin complete: $pin")
val shake = AnimationUtils.loadAnimation(this@SampleActivity, R.anim.shake_wrong)
mIndicatorDotsFirst!!.startAnimation(shake)
// mIndicatorDotsFirst.setErrorDots();
if (pin == "1111") {
mIndicatorDotsFirst!!.setSuccessDots()
} else {
mIndicatorDotsFirst!!.setErrorDots()
}
Handler().postDelayed({
mIndicatorDotsFirst!!.setDefaultDots()
mPinLockView!!.resetPinLockView()

// mPinLockView.attachIndicatorDots(mIndicatorDotsSecond);
}, 1000)
}

override fun onEmpty() {
Log.d(TAG, "Pin empty")
}

override fun onPinChange(pinLength: Int, intermediatePin: String) {
Log.d(TAG, "Pin changed, new length $pinLength with intermediate pin $intermediatePin")
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestWindowFeature(Window.FEATURE_NO_TITLE)
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN)
setContentView(R.layout.activity_sample)

mPinLockView = findViewById(R.id.pin_lock_view)
mIndicatorDotsFirst = findViewById(R.id.indicator_dots_first)
mIndicatorDotsSecond = findViewById(R.id.indicator_dots_second)


mPinLockView!!.attachIndicatorDots(mIndicatorDotsFirst!!)
mPinLockView!!.setPinLockListener(mPinLockFirstListener)
//mPinLockView.setCustomKeySet(new int[]{2, 3, 1, 5, 9, 6, 7, 0, 8, 4});
//mPinLockView.enableLayoutShuffling();

mPinLockView!!.pinLength = 4
mPinLockView!!.textColor = ContextCompat.getColor(this, R.color.white)

mIndicatorDotsFirst!!.indicatorType = IndicatorDots.IndicatorType.FIXED
}

companion object {

val TAG = "PinLockView"
}
}
24 changes: 16 additions & 8 deletions app/src/main/res/layout/activity_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
android:background="@color/mine_shaft"
tools:context="com.andrognito.pinlockviewapp.SampleActivity">

<ImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/profile_image"
android:layout_width="84dp"
android:layout_height="84dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="104dp"
android:layout_marginTop="86dp"
android:src="@drawable/img_no_avatar" />

<TextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/profile_name"
android:layout_width="256dp"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:layout_marginTop="30dp"
android:fontFamily="sans-serif-thin"
android:gravity="center"
android:maxLines="1"
Expand All @@ -30,20 +30,28 @@
android:textSize="34sp" />

<com.andrognito.pinlockview.IndicatorDots
android:id="@+id/indicator_dots"
android:id="@+id/indicator_dots_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/profile_name"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp" />
android:layout_marginTop="32dp" />

<com.andrognito.pinlockview.IndicatorDots
android:id="@+id/indicator_dots_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/indicator_dots_first"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp" />

<com.andrognito.pinlockview.PinLockView
android:id="@+id/pin_lock_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/indicator_dots"
android:layout_below="@id/indicator_dots_second"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:layout_marginTop="24dp"
app:keypadButtonSize="72dp"
app:keypadShowDeleteButton="true"
app:keypadTextColor="@color/white"
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.30'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.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 All @@ -16,6 +19,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Mar 10 00:08:20 IST 2017
#Tue Apr 23 17:01:55 MSK 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
34 changes: 24 additions & 10 deletions pinlockview/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'

ext {
bintrayRepo = 'maven'
Expand Down Expand Up @@ -26,12 +28,11 @@ ext {


android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 28

defaultConfig {
minSdkVersion 11
targetSdkVersion 25
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "2.1.0"
}
Expand All @@ -43,12 +44,25 @@ android {
}
}

allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.core:core-ktx:1.0.1"
testImplementation 'junit:junit:4.12'
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
repositories {
mavenCentral()
}
Loading