Skip to content

Commit 59fc8f1

Browse files
author
huangshouguo
committed
add add freeze duration
1 parent d5b66ae commit 59fc8f1

7 files changed

Lines changed: 27 additions & 15 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ android {
3535

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

4141
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
4242
implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ buildscript {
44

55
// versions
66
ext {
7-
versionCode = 13
8-
versionName = '2.4.4'
7+
versionCode = 14
8+
versionName = '2.4.5'
99

1010
minSdkVersion = 15
1111
targetSdkVersion = 28
@@ -14,7 +14,7 @@ buildscript {
1414

1515
supportLibraryVersion = '28.0.0'
1616
constraintLayoutVersion = '1.0.2'
17-
kotlinVersion = '1.3.0'
17+
kotlinVersion = '1.3.21'
1818

1919
espressoCoreVersion = '2.2.2'
2020
junitVersion = '4.12'
@@ -26,7 +26,7 @@ buildscript {
2626
}
2727

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

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

library/src/main/java/com/github/ihsg/patternlocker/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal object Config {
1616
private const val DEFAULT_FILL_COLOR = "#FFFFFF"
1717
private const val DEFAULT_LINE_WIDTH = 1
1818

19-
const val defaultDelayTime = 1000//ms
19+
const val defaultFreezeDuration = 1000//ms
2020
const val defaultEnableAutoClean = true
2121
const val defaultEnableHapticFeedback = false
2222
const val defaultCanSkip = false

library/src/main/java/com/github/ihsg/patternlocker/Logger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.github.ihsg.patternlocker
22

33
import android.util.Log
44

5-
class Logger {
5+
internal class Logger {
66
companion object {
77
var enable = false
88
fun d(tag: String, msg: String) {

library/src/main/java/com/github/ihsg/patternlocker/PatternLockerView.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
2323
private var errorColor: Int = 0
2424
@ColorInt
2525
private var fillColor: Int = 0
26+
private var freezeDuration: Int = 0
27+
private var hitSize: Int = 0
2628
private var lineWidth: Float = 0f
2729
private var endX: Float = 0f
2830
private var endY: Float = 0f
29-
private var hitSize: Int = 0
3031
private var isError: Boolean = false
3132
private var enableAutoClean: Boolean = false
3233
private var canSkip: Boolean = false
@@ -41,8 +42,8 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
4142
private var hitCellView: IHitCellView? = null
4243

4344
private val action = Runnable {
44-
isEnabled = true
45-
clearHitState()
45+
this.isEnabled = true
46+
this.clearHitState()
4647
}
4748

4849
init {
@@ -149,6 +150,15 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
149150
return this
150151
}
151152

153+
fun setFreezeDuration(freezeDuration: Int): PatternLockerView {
154+
this.freezeDuration = freezeDuration
155+
return this
156+
}
157+
158+
fun getFreezeDuration(): Int {
159+
return this.freezeDuration
160+
}
161+
152162
fun buildWithDefaultStyle() {
153163
this.setNormalCellView(DefaultLockerNormalCellView()
154164
.setNormalColor(this.getNormalColor())
@@ -228,6 +238,7 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
228238
this.hitColor = ta.getColor(R.styleable.PatternLockerView_plv_hitColor, Config.defaultHitColor)
229239
this.errorColor = ta.getColor(R.styleable.PatternLockerView_plv_errorColor, Config.defaultErrorColor)
230240
this.fillColor = ta.getColor(R.styleable.PatternLockerView_plv_fillColor, Config.defaultFillColor)
241+
this.freezeDuration = ta.getInteger(R.styleable.PatternLockerView_plv_freezeDuration, Config.defaultFreezeDuration)
231242
this.lineWidth = ta.getDimension(R.styleable.PatternLockerView_plv_lineWidth, Config.getDefaultLineWidth(resources))
232243
this.enableAutoClean = ta.getBoolean(R.styleable.PatternLockerView_plv_enableAutoClean, Config.defaultEnableAutoClean)
233244
this.enableHapticFeedback = ta.getBoolean(R.styleable.PatternLockerView_plv_enableHapticFeedback, Config.defaultEnableHapticFeedback)
@@ -249,7 +260,7 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
249260
}
250261

251262
private fun initCellBeanList() {
252-
if (!this::cellBeanList.isInitialized){
263+
if (!this::cellBeanList.isInitialized) {
253264
val w = this.width - this.paddingLeft - this.paddingRight
254265
val h = this.height - this.paddingTop - this.paddingBottom
255266
this.cellBeanList = CellFactory(w, h).cellBeanList
@@ -360,8 +371,8 @@ class PatternLockerView @JvmOverloads constructor(context: Context, attrs: Attri
360371
}
361372

362373
private fun startTimer() {
363-
isEnabled = false
364-
this.postDelayed(this.action, Config.defaultDelayTime.toLong())
374+
this.isEnabled = false
375+
this.postDelayed(this.action, this.freezeDuration.toLong())
365376
}
366377

367378
private fun hapticFeedback() {

library/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<attr name="plv_errorColor" format="color|reference" />
1515
<attr name="plv_fillColor" format="color|reference" />
1616
<attr name="plv_lineWidth" format="dimension|reference" />
17+
<attr name="plv_freezeDuration" format="integer|reference" />
1718
<attr name="plv_enableAutoClean" format="boolean|reference" />
1819
<attr name="plv_canSkip" format="boolean|reference" />
1920
<attr name="plv_enableHapticFeedback" format="boolean|reference" />

0 commit comments

Comments
 (0)