Skip to content

Commit

Permalink
add add freeze duration
Browse files Browse the repository at this point in the history
  • Loading branch information
huangshouguo committed Apr 3, 2019
1 parent d5b66ae commit 59fc8f1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation project(':library')
implementation "com.github.ihsg:PatternLocker:$rootProject.ext.versionName"
implementation project(':library')
// implementation "com.github.ihsg:PatternLocker:$rootProject.ext.versionName"

implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buildscript {

// versions
ext {
versionCode = 13
versionName = '2.4.4'
versionCode = 14
versionName = '2.4.5'

minSdkVersion = 15
targetSdkVersion = 28
Expand All @@ -14,7 +14,7 @@ buildscript {

supportLibraryVersion = '28.0.0'
constraintLayoutVersion = '1.0.2'
kotlinVersion = '1.3.0'
kotlinVersion = '1.3.21'

espressoCoreVersion = '2.2.2'
junitVersion = '4.12'
Expand All @@ -26,7 +26,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal object Config {
private const val DEFAULT_FILL_COLOR = "#FFFFFF"
private const val DEFAULT_LINE_WIDTH = 1

const val defaultDelayTime = 1000//ms
const val defaultFreezeDuration = 1000//ms
const val defaultEnableAutoClean = true
const val defaultEnableHapticFeedback = false
const val defaultCanSkip = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.github.ihsg.patternlocker

import android.util.Log

class Logger {
internal class Logger {
companion object {
var enable = false
fun d(tag: String, msg: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
private var errorColor: Int = 0
@ColorInt
private var fillColor: Int = 0
private var freezeDuration: Int = 0
private var hitSize: Int = 0
private var lineWidth: Float = 0f
private var endX: Float = 0f
private var endY: Float = 0f
private var hitSize: Int = 0
private var isError: Boolean = false
private var enableAutoClean: Boolean = false
private var canSkip: Boolean = false
Expand All @@ -41,8 +42,8 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
private var hitCellView: IHitCellView? = null

private val action = Runnable {
isEnabled = true
clearHitState()
this.isEnabled = true
this.clearHitState()
}

init {
Expand Down Expand Up @@ -149,6 +150,15 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
return this
}

fun setFreezeDuration(freezeDuration: Int): PatternLockerView {
this.freezeDuration = freezeDuration
return this
}

fun getFreezeDuration(): Int {
return this.freezeDuration
}

fun buildWithDefaultStyle() {
this.setNormalCellView(DefaultLockerNormalCellView()
.setNormalColor(this.getNormalColor())
Expand Down Expand Up @@ -228,6 +238,7 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
this.hitColor = ta.getColor(R.styleable.PatternLockerView_plv_hitColor, Config.defaultHitColor)
this.errorColor = ta.getColor(R.styleable.PatternLockerView_plv_errorColor, Config.defaultErrorColor)
this.fillColor = ta.getColor(R.styleable.PatternLockerView_plv_fillColor, Config.defaultFillColor)
this.freezeDuration = ta.getInteger(R.styleable.PatternLockerView_plv_freezeDuration, Config.defaultFreezeDuration)
this.lineWidth = ta.getDimension(R.styleable.PatternLockerView_plv_lineWidth, Config.getDefaultLineWidth(resources))
this.enableAutoClean = ta.getBoolean(R.styleable.PatternLockerView_plv_enableAutoClean, Config.defaultEnableAutoClean)
this.enableHapticFeedback = ta.getBoolean(R.styleable.PatternLockerView_plv_enableHapticFeedback, Config.defaultEnableHapticFeedback)
Expand All @@ -249,7 +260,7 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
}

private fun initCellBeanList() {
if (!this::cellBeanList.isInitialized){
if (!this::cellBeanList.isInitialized) {
val w = this.width - this.paddingLeft - this.paddingRight
val h = this.height - this.paddingTop - this.paddingBottom
this.cellBeanList = CellFactory(w, h).cellBeanList
Expand Down Expand Up @@ -360,8 +371,8 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
}

private fun startTimer() {
isEnabled = false
this.postDelayed(this.action, Config.defaultDelayTime.toLong())
this.isEnabled = false
this.postDelayed(this.action, this.freezeDuration.toLong())
}

private fun hapticFeedback() {
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<attr name="plv_errorColor" format="color|reference" />
<attr name="plv_fillColor" format="color|reference" />
<attr name="plv_lineWidth" format="dimension|reference" />
<attr name="plv_freezeDuration" format="integer|reference" />
<attr name="plv_enableAutoClean" format="boolean|reference" />
<attr name="plv_canSkip" format="boolean|reference" />
<attr name="plv_enableHapticFeedback" format="boolean|reference" />
Expand Down

0 comments on commit 59fc8f1

Please sign in to comment.