Skip to content

Commit 5293924

Browse files
committed
QuickPass 2.0
- fixes in stats - fixes bottom sheet on key back
1 parent f061669 commit 5293924

File tree

4 files changed

+64
-22
lines changed

4 files changed

+64
-22
lines changed

app/src/main/java/com/mikhailgrigorev/quickpass/AboutActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AboutActivity : AppCompatActivity() {
5757

5858
// My link to Telegram
5959
telegram.setOnClickListener {
60-
val i = Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/mikhail_grigorev"))
60+
val i = Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/grigorevmp"))
6161
startActivity(i)
6262
}
6363

@@ -69,7 +69,7 @@ class AboutActivity : AppCompatActivity() {
6969

7070
// My link to GitHub
7171
gitHub.setOnClickListener {
72-
val i = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/MikhailGrigorevP/QuickPass-Mobile-Password-manager/"))
72+
val i = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/grigorevmp/QuickPass-Mobile-Password-manager/"))
7373
startActivity(i)
7474
}
7575

app/src/main/java/com/mikhailgrigorev/quickpass/AccountActivity.kt

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class AccountActivity : AppCompatActivity() {
169169
pdbHelper.KEY_TAGS,
170170
pdbHelper.KEY_GROUPS,
171171
pdbHelper.KEY_USE_TIME,
172+
pdbHelper.KEY_CIPHER,
172173
pdbHelper.KEY_TIME
173174
),
174175
null, null,
@@ -198,28 +199,36 @@ class AccountActivity : AppCompatActivity() {
198199
val aIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_2FA)
199200
val tIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_USE_TIME)
200201
val timeIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_TIME)
202+
val cIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_CIPHER)
201203
var j = 0
202204
do {
203205
val pass = pCursor.getString(passIndex).toString()
204206
val myPasswordManager = PasswordManager()
205-
var evaluation: Float =
206-
myPasswordManager.evaluatePassword(pass)
207+
val evaluation: Float = myPasswordManager.evaluatePassword(pass)
208+
val dbCipherIndex = pCursor.getString(cIndex).toString()
209+
210+
var qualityNum = when {
211+
evaluation < 0.33 -> "2"
212+
evaluation < 0.66 -> "3"
213+
else -> "1"
214+
}
207215

208216

217+
if (dbCipherIndex == "crypted" )
218+
qualityNum = "6"
219+
209220
val dbTimeIndex = pCursor.getString(timeIndex).toString()
221+
if (myPasswordManager.evaluateDate(dbTimeIndex))
222+
qualityNum = "2"
223+
224+
if (realQuality[j] != "1")
225+
qualityNum = "2"
210226

211-
if((myPasswordManager.evaluateDate(dbTimeIndex)) && (pass.length!= 4))
212-
evaluation = 0F
213227

228+
if (dbCipherIndex != "crypted" && pass.length == 4)
229+
qualityNum = "4"
214230

215-
if(realQuality[j] != "1")
216-
evaluation = 0F
217231
j++
218-
when{
219-
evaluation < 0.33 -> inCorrectNum += 1
220-
evaluation < 0.66 -> midCorrectNum += 1
221-
else -> correctNum += 1
222-
}
223232

224233
val fa = pCursor.getString(aIndex).toString()
225234
val tl= pCursor.getString(tIndex).toString()
@@ -230,6 +239,14 @@ class AccountActivity : AppCompatActivity() {
230239
if(tl == "1")
231240
tlNum += 1
232241

242+
when (qualityNum) {
243+
"1" -> correctNum += 1
244+
"2" -> inCorrectNum += 1
245+
"3" -> midCorrectNum += 1
246+
"4" -> correctNum += 1
247+
"6" -> correctNum += 1
248+
}
249+
233250
} while (pCursor.moveToNext())
234251
}
235252

app/src/main/java/com/mikhailgrigorev/quickpass/PassGenActivity.kt

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import android.os.Handler
1616
import android.text.Editable
1717
import android.text.TextWatcher
1818
import android.view.Gravity
19+
import android.view.KeyEvent
1920
import android.view.LayoutInflater
2021
import android.view.View
2122
import android.view.animation.AccelerateDecelerateInterpolator
@@ -216,12 +217,9 @@ class PassGenActivity : AppCompatActivity() {
216217
if (pCursor.moveToFirst()) {
217218
val nameIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_NAME)
218219
val passIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_PASS)
219-
val cIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_CIPHER)
220220
do {
221221
val pass = pCursor.getString(passIndex).toString()
222222
val login = pCursor.getString(nameIndex).toString()
223-
val dbCipherIndex = pCursor.getString(cIndex).toString()
224-
realPass.add(Pair(login, pass))
225223
realPass.add(Pair(login, pass))
226224
} while (pCursor.moveToNext())
227225
}
@@ -310,9 +308,11 @@ class PassGenActivity : AppCompatActivity() {
310308
"1" -> safePass += 1
311309
"2" -> unsafePass += 1
312310
"3" -> fixPass += 1
311+
"4" -> safePass += 1
312+
"6" -> safePass += 1
313313
}
314314

315-
allPass.text = (safePass+ unsafePass + fixPass).toString()
315+
allPass.text = (safePass + unsafePass + fixPass).toString()
316316
afText.text = faNum.toString()
317317
tlText.text = tlNum.toString()
318318

@@ -1455,6 +1455,8 @@ class PassGenActivity : AppCompatActivity() {
14551455
"1" -> safePass += 1
14561456
"2" -> unsafePass += 1
14571457
"3" -> fixPass += 1
1458+
"4" -> safePass += 1
1459+
"6" -> safePass += 1
14581460
}
14591461
allPass.text = (safePass+ unsafePass + fixPass).toString()
14601462
afText.text = faNum.toString()
@@ -1590,6 +1592,8 @@ class PassGenActivity : AppCompatActivity() {
15901592
"1" -> safePass += 1
15911593
"2" -> unsafePass += 1
15921594
"3" -> fixPass += 1
1595+
"4" -> safePass += 1
1596+
"6" -> safePass += 1
15931597
}
15941598
allPass.text = (safePass+ unsafePass + fixPass).toString()
15951599
afText.text = faNum.toString()
@@ -1668,6 +1672,27 @@ class PassGenActivity : AppCompatActivity() {
16681672

16691673
}
16701674

1675+
1676+
1677+
override fun onKeyUp(keyCode: Int, msg: KeyEvent?): Boolean {
1678+
when (keyCode) {
1679+
KeyEvent.KEYCODE_BACK -> {
1680+
val llBottomSheet = allPassword
1681+
1682+
1683+
val bottomSheetBehavior = BottomSheetBehavior.from(llBottomSheet)
1684+
1685+
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED)
1686+
finish()
1687+
else
1688+
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
1689+
}
1690+
}
1691+
return false
1692+
}
1693+
1694+
1695+
16711696
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
16721697
super.onActivityResult(requestCode, resultCode, data)
16731698
if (requestCode == 1) {

app/src/main/res/layout/activity_account.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@
291291
android:layout_marginStart="20dp"
292292
android:layout_marginTop="20dp"
293293
android:layout_marginEnd="20dp"
294+
android:clickable="true"
295+
android:focusable="true"
296+
android:foreground="?android:attr/selectableItemBackground"
297+
294298
app:cardBackgroundColor="@color/white"
295299
app:cardCornerRadius="15dp"
296300
app:cardElevation="20dp"
297-
298-
android:foreground="?android:attr/selectableItemBackground"
299-
android:clickable="true"
300-
android:focusable="true"
301301
app:layout_constraintEnd_toEndOf="parent"
302302
app:layout_constraintStart_toStartOf="parent"
303303
app:layout_constraintTop_toBottomOf="@+id/totalPoints">
@@ -312,8 +312,8 @@
312312
android:layout_height="match_parent"
313313
android:layout_gravity="center"
314314
android:layout_marginStart="10dp"
315-
android:layout_marginEnd="10dp"
316315
android:layout_marginTop="20dp"
316+
android:layout_marginEnd="10dp"
317317
android:orientation="horizontal"
318318
tools:ignore="UseCompoundDrawables">
319319

0 commit comments

Comments
 (0)