diff --git a/.idea/misc.xml b/.idea/misc.xml index fa10773..76af1c2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,7 @@ diff --git a/app/build.gradle b/app/build.gradle index 98fb560..645c562 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" @@ -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' diff --git a/app/src/main/java/com/ihaydin/passwordmeter/MainActivity.kt b/app/src/main/java/com/ihaydin/passwordmeter/MainActivity.kt index fcffc92..2762a0b 100644 --- a/app/src/main/java/com/ihaydin/passwordmeter/MainActivity.kt +++ b/app/src/main/java/com/ihaydin/passwordmeter/MainActivity.kt @@ -12,7 +12,6 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - val strengthView = findViewById(R.id.cvPasswordMeter) val etContent = findViewById(R.id.etContent) @@ -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 { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a1a4244..61ac14c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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" /> + app:layout_constraintEnd_toEndOf="@id/etContent" + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 75b61d6..f912ffb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ PasswordMeter + Your Input \ No newline at end of file diff --git a/build.gradle b/build.gradle index 59a783a..028ec27 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 75933b0..4810b74 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/passwordmeter/build.gradle b/passwordmeter/build.gradle index 1fba23b..73f1794 100644 --- a/passwordmeter/build.gradle +++ b/passwordmeter/build.gradle @@ -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" @@ -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' } \ No newline at end of file diff --git a/passwordmeter/src/main/AndroidManifest.xml b/passwordmeter/src/main/AndroidManifest.xml index 1bc587b..d069afb 100644 --- a/passwordmeter/src/main/AndroidManifest.xml +++ b/passwordmeter/src/main/AndroidManifest.xml @@ -1,5 +1,2 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/passwordmeter/src/main/java/com/ihaydin/passwordmeter/PasswordMeterView.kt b/passwordmeter/src/main/java/com/ihaydin/passwordmeter/PasswordMeterView.kt index f40ad52..ab7f367 100644 --- a/passwordmeter/src/main/java/com/ihaydin/passwordmeter/PasswordMeterView.kt +++ b/passwordmeter/src/main/java/com/ihaydin/passwordmeter/PasswordMeterView.kt @@ -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) } @@ -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 { @@ -71,7 +71,6 @@ class PasswordMeterView : View { ) } } - requestLayout() super.onDraw(canvas) } @@ -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) @@ -139,12 +139,14 @@ 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() @@ -152,7 +154,7 @@ class PasswordMeterView : View { private fun getMaxTextHeight(): Int { var maxHeight = 0 - list.forEachIndexed { index, state -> + list.forEachIndexed { index, _ -> val bounds = Rect() paint?.getTextBounds( list[index].text, @@ -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, @@ -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 } @@ -225,5 +227,4 @@ class PasswordMeterView : View { fun setTextHeight(value: Int) { textHeight = value } - } \ No newline at end of file