Skip to content
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
1 change: 1 addition & 0 deletions .idea/misc.xml

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

14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 31
compileSdk 32

defaultConfig {
applicationId "com.ihaydin.passwordmeter"
minSdk 21
targetSdk 31
targetSdk 32
versionCode 1
versionName "1.0"

Expand All @@ -33,11 +33,11 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.+'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

Expand Down
8 changes: 2 additions & 6 deletions app/src/main/java/com/ihaydin/passwordmeter/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)


val strengthView = findViewById<PasswordMeterView>(R.id.cvPasswordMeter)
val etContent = findViewById<EditText>(R.id.etContent)

Expand Down Expand Up @@ -49,12 +48,9 @@ class MainActivity : AppCompatActivity() {
strengthView.setList(states)

etContent.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {

}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}

override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}

override fun afterTextChanged(value: Editable?) {
value.let {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
android:id="@+id/etContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Your Input"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif"
app:layout_constraintStart_toStartOf="parent"
android:hint="@string/your_input"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cvPasswordMeter" />

<com.ihaydin.passwordmeter.PasswordMeterView
android:id="@+id/cvPasswordMeter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="@id/etContent"/>
app:layout_constraintEnd_toEndOf="@id/etContent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">PasswordMeter</string>
<string name="your_input">Your Input</string>
</resources>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Sep 13 18:30:06 TRT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
14 changes: 6 additions & 8 deletions passwordmeter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ plugins {
}

android {
compileSdk 31
compileSdk 32

defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
targetSdk 32

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -33,10 +31,10 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
5 changes: 1 addition & 4 deletions passwordmeter/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ihaydin.passwordmeter">

</manifest>
<manifest package="com.ihaydin.passwordmeter" />
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PasswordMeterView : View {

private val density = resources.displayMetrics.density

constructor(context: Context?) : super(context) {}
constructor(context: Context?) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
init(context, attrs)
}
Expand All @@ -44,7 +44,7 @@ class PasswordMeterView : View {

for (i in 0 until barCountSize) {
paint?.textSize = TEXT_HEIGHT
paint?.setTypeface(Typeface.createFromAsset(context.assets, textFontStyle))
paint?.typeface = Typeface.createFromAsset(context.assets, textFontStyle)
if (i < list[selectedIndex].tintSize) {
paint?.color = list[selectedIndex].color
} else {
Expand All @@ -71,7 +71,6 @@ class PasswordMeterView : View {
)
}
}

requestLayout()
super.onDraw(canvas)
}
Expand All @@ -89,6 +88,7 @@ class PasswordMeterView : View {
}


@SuppressLint("DrawAllocation")
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
Expand Down Expand Up @@ -139,20 +139,22 @@ class PasswordMeterView : View {
val values =
context.theme.obtainStyledAttributes(attrs, R.styleable.StrengthPasswordView, 0, 0)

barCountSize = values.getInt(R.styleable.StrengthPasswordView_cv_strength_count_size,5)
barCountSize = values.getInt(R.styleable.StrengthPasswordView_cv_strength_count_size, 5)
barRadius = values.getInt(R.styleable.StrengthPasswordView_cv_strength_bar_radius, 20)
barWidth = values.getInt(R.styleable.StrengthPasswordView_cv_strength_bar_width, 10)
barSpace = values.getInt(R.styleable.StrengthPasswordView_cv_strength_bar_spacer_size, 6)
textHeight = values.getInt(R.styleable.StrengthPasswordView_cv_strength_text_height_value, 14)
textPaddingStart = values.getFloat(R.styleable.StrengthPasswordView_cv_strength_text_start_padding, 8f)
textHeight =
values.getInt(R.styleable.StrengthPasswordView_cv_strength_text_height_value, 14)
textPaddingStart =
values.getFloat(R.styleable.StrengthPasswordView_cv_strength_text_start_padding, 8f)
barHeight = values.getFloat(R.styleable.StrengthPasswordView_cv_strength_bar_height, 3f)

values.recycle()
}

private fun getMaxTextHeight(): Int {
var maxHeight = 0
list.forEachIndexed { index, state ->
list.forEachIndexed { index, _ ->
val bounds = Rect()
paint?.getTextBounds(
list[index].text,
Expand All @@ -168,7 +170,7 @@ class PasswordMeterView : View {
var maxWidth = 0
private fun getMaxTextWidth(): Int {

list.forEachIndexed { index, state ->
list.forEachIndexed { index, _ ->
val bounds = Rect()
paint?.getTextBounds(
list[index].text,
Expand All @@ -186,15 +188,15 @@ class PasswordMeterView : View {
requestLayout()
}

fun setTextFontStyle(font: String){
fun setTextFontStyle(font: String) {
textFontStyle = font
}

fun setBarHeight(value: Float){
fun setBarHeight(value: Float) {
barHeight = value;
}

fun setBarRadius(radius: Int){
fun setBarRadius(radius: Int) {
barRadius = radius
}

Expand Down Expand Up @@ -225,5 +227,4 @@ class PasswordMeterView : View {
fun setTextHeight(value: Int) {
textHeight = value
}

}