Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
a.artemov committed Sep 26, 2018
2 parents a3cace4 + 925d2d4 commit f4df802
Show file tree
Hide file tree
Showing 21 changed files with 653 additions and 707 deletions.
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions .idea/kotlinc.xml

This file was deleted.

22 changes: 14 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 28

defaultConfig {
applicationId "com.goldenpie.devs.pincodeview"
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -20,10 +22,14 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.pes.materialcolorpicker:library:1.1.+'

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.pes.materialcolorpicker:library:1.2.4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

compile project(':library')
implementation project(':library')
}

androidExtensions {
experimental = true
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.goldenpie.devs.pincodeview.example

import android.app.Activity
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.widget.SeekBar
import android.widget.Toast
import com.goldenpie.devs.pincodeview.core.Listeners
import com.goldenpie.devs.pincodeview.core.LockType
import com.pes.androidmaterialcolorpickerdialog.ColorPicker
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity(), Listeners.PinEnteredListener, Listeners.PinReEnterListener, Listeners.PinMismatchListener, View.OnClickListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

initView()

listOf(pinCodeView, drawablePinCodeView).onEach {
it.setLockType(LockType.ENTER_PIN)
it.setPinEnteredListener(this)
it.setPinReEnterListener(this)
it.setPinMismatchListener(this)
}
}

private fun initView() {
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setPinLength(progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar) {

}

override fun onStopTrackingTouch(seekBar: SeekBar) {

}
})

alphaSeekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setInnerAlpha(progress.div(10f))
}
}

override fun onStartTrackingTouch(seekBar: SeekBar) {

}

override fun onStopTrackingTouch(seekBar: SeekBar) {

}
})

listOf(innerColor, outerColor, errorColor).onEach {
it.setOnClickListener(this)
}

switchCompat.setOnCheckedChangeListener { _, isChecked ->
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setLockType(if (isChecked) LockType.ENTER_PIN else LockType.UNLOCK)
}
}

innerTintSwitch.setOnCheckedChangeListener { _, isChecked ->
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setTintInner(isChecked)
}
}

outerTintSwitch.setOnCheckedChangeListener { _, isChecked ->
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setTintOuter(isChecked)
}
}
}

override fun onPinEntered(pinCode: String?) {
toast(pinCode)
}

override fun onPinReEnterStarted() {
toast("Pin re-enter started")
}

override fun onPinMismatch() {
toast("Pin mismatch")
}

override fun onClick(v: View) {
val cp = ColorPicker(this@MainActivity)
.apply {
show()
}

when (v) {
innerColor -> {
cp.setCallback { color ->
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setInnerCircleColor(color)
}
cp.dismiss()
}
}
outerColor -> {
cp.setCallback { color ->
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setOuterCircleColor(color)
}
cp.dismiss()
}
}
errorColor -> {
cp.setCallback { color ->
listOf(pinCodeView, drawablePinCodeView).onEach {
it.setErrorColor(color)
}
cp.dismiss()
}
}
}
}

private fun Activity.toast(string: String?) =
Toast.makeText(this, string, Toast.LENGTH_SHORT).show()

}
Loading

0 comments on commit f4df802

Please sign in to comment.