Skip to content

Commit c4c6099

Browse files
committed
- "Account" design updated
-- Short statistic of your passwords parameters - "Settings" design update -- Export encoding fixed --- If not -> It's your TableView app problem (It's note a joke) =) -- Import settings feature added -- Warning message added - Resources optimization - New Alert dialogs styles - Passwords with same parts updated -- Add comma to separate -- Left margin added
1 parent bd3d2f4 commit c4c6099

File tree

16 files changed

+154
-59
lines changed

16 files changed

+154
-59
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies {
2828
implementation fileTree(dir: "libs", include: ["*.jar"])
2929
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3030
implementation 'androidx.core:core-ktx:1.3.0'
31+
implementation 'android.arch.work:work-runtime-ktx:1.0.1'
3132
implementation 'androidx.appcompat:appcompat:1.1.0'
3233
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
3334
implementation 'androidx.biometric:biometric:1.0.1'

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGEE" />
77
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
88
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
9+
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
910

1011
<application
1112
android:allowBackup="true"

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ class AccountActivity : AppCompatActivity() {
112112
startActivity(intent)
113113
}
114114

115-
var pdbHelper = PasswordsDataBaseHelper(this, login)
116-
var pDatabase = pdbHelper.writableDatabase
115+
val pdbHelper = PasswordsDataBaseHelper(this, login)
116+
val pDatabase = pdbHelper.writableDatabase
117117
try {
118118
val pCursor: Cursor = pDatabase.query(
119119
pdbHelper.TABLE_USERS, arrayOf(pdbHelper.KEY_NAME, pdbHelper.KEY_PASS,
120-
pdbHelper.KEY_2FA, pdbHelper.KEY_TAGS, pdbHelper.KEY_GROUPS, pdbHelper.KEY_USE_TIME),
120+
pdbHelper.KEY_2FA, pdbHelper.KEY_TAGS, pdbHelper.KEY_GROUPS, pdbHelper.KEY_USE_TIME,
121+
pdbHelper.KEY_TIME),
121122
null, null,
122123
null, null, null
123124
)
@@ -144,12 +145,21 @@ class AccountActivity : AppCompatActivity() {
144145
val passIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_PASS)
145146
val aIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_2FA)
146147
val tIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_USE_TIME)
148+
val timeIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_TIME)
147149
var j = 0
148150
do {
149151
val pass = pCursor.getString(passIndex).toString()
150152
val myPasswordManager = PasswordManager()
151153
var evaluation: Float =
152154
myPasswordManager.evaluatePassword(pass)
155+
156+
157+
val dbTimeIndex = pCursor.getString(timeIndex).toString()
158+
159+
if((myPasswordManager.evaluateDate(dbTimeIndex)) && (pass.length!= 4))
160+
evaluation = 0F
161+
162+
153163
if(realQuality[j] != "1")
154164
evaluation = 0F
155165
j++
@@ -214,7 +224,7 @@ class AccountActivity : AppCompatActivity() {
214224
}
215225

216226
deleteAccount.setOnClickListener {
217-
val builder = AlertDialog.Builder(this)
227+
val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom)
218228
builder.setTitle(getString(R.string.accountDelete))
219229
builder.setMessage(getString(R.string.accountDeleteConfirm))
220230

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class LoginActivity : AppCompatActivity() {
189189
// создание объекта Intent для запуска SecondActivity
190190

191191
if(isAvailable(this)){
192-
val builder = AlertDialog.Builder(this)
192+
val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom)
193193
builder.setTitle(getString(R.string.bio_usage))
194194
builder.setMessage(getString(R.string.fingerUnlock))
195195

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class NewPasswordActivity : AppCompatActivity() {
6666
}
6767
setContentView(R.layout.activity_new_password)
6868

69+
6970
val args: Bundle? = intent.extras
7071
login = args?.get("login").toString()
7172

@@ -377,6 +378,8 @@ class NewPasswordActivity : AppCompatActivity() {
377378
passDataBase.insert(pdbHelper.TABLE_USERS, null, contentValues)
378379
val intent = Intent(this, PassGenActivity::class.java)
379380
intent.putExtra("login", login)
381+
382+
380383
startActivity(intent)
381384
finish()
382385
}
@@ -407,7 +410,8 @@ class NewPasswordActivity : AppCompatActivity() {
407410
return dateFormat.format(date)
408411
}
409412

410-
411413
private fun Context.toast(message:String)=
412414
Toast.makeText(this,message, Toast.LENGTH_SHORT).show()
415+
416+
413417
}

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ class PassGenActivity : AppCompatActivity() {
154154
try {
155155
val pCursor: Cursor = pDatabase.query(
156156
pdbHelper.TABLE_USERS, arrayOf(pdbHelper.KEY_NAME, pdbHelper.KEY_PASS,
157-
pdbHelper.KEY_2FA, pdbHelper.KEY_TAGS, pdbHelper.KEY_GROUPS),
157+
pdbHelper.KEY_TIME, pdbHelper.KEY_2FA,
158+
pdbHelper.KEY_TAGS, pdbHelper.KEY_GROUPS),
158159
null, null,
159160
null, null, null
160161
)
@@ -177,6 +178,7 @@ class PassGenActivity : AppCompatActivity() {
177178
val aIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_2FA)
178179
val tagsIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_TAGS)
179180
val groupIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_GROUPS)
181+
val timeIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_TIME)
180182
var j = 0
181183
do {
182184
val pass = pCursor.getString(passIndex).toString()
@@ -188,6 +190,13 @@ class PassGenActivity : AppCompatActivity() {
188190
evaluation < 0.66 -> "3"
189191
else -> "1"
190192
}
193+
194+
val dbTimeIndex = pCursor.getString(timeIndex).toString()
195+
196+
if((myPasswordManager.evaluateDate(dbTimeIndex)) && (pass.length!= 4))
197+
qualityNum = "2"
198+
199+
191200
if(realQuality[j] != "1")
192201
qualityNum = "2"
193202
j++
@@ -960,10 +969,15 @@ class PassGenActivity : AppCompatActivity() {
960969
intent.putExtra("login", login)
961970
intent.putExtra("passName", passwordsG[position].first)
962971
var str = getString(R.string.sameParts) + " "
972+
var j = 0
963973
if (realMap.containsKey(passwordsG[position].first)){
964974
for(pass in realMap[passwordsG[position].first]!!) {
975+
if (j == 0)
976+
j += 1
977+
else
978+
str += ", "
965979
isPass = true
966-
str += "$pass "
980+
str += pass
967981
}
968982
}
969983
if(isPass)
@@ -1081,7 +1095,7 @@ class PassGenActivity : AppCompatActivity() {
10811095
val position = globalPos
10821096
val pdbHelper = PasswordsDataBaseHelper(this, login)
10831097
val pDatabase = pdbHelper.writableDatabase
1084-
val builder = AlertDialog.Builder(this)
1098+
val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom)
10851099
builder.setTitle(getString(R.string.deletePassword))
10861100
builder.setMessage(getString(R.string.passwordDeleteConfirm))
10871101

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mikhailgrigorev.quickpass
22
import java.security.SecureRandom
3+
import java.util.*
34
import kotlin.math.max
45

56
class PasswordManager {
@@ -36,6 +37,29 @@ class PasswordManager {
3637
return sb.toString()
3738
}
3839

40+
fun evaluateDate(date: String): Boolean{
41+
42+
// YYYY-MM-DD HH:MM:SS
43+
44+
val year = date.substring(0, 4).toInt()
45+
val month = date.substring(5, 7).toInt()
46+
val day = date.substring(8, 10).toInt()
47+
// val hour = date.substring(11, 13).toInt()
48+
// val minute = date.substring(14, 16).toInt()
49+
// val second = date.substring(17, 19).toInt()
50+
51+
val c = Calendar.getInstance()
52+
val yearCurrent = c.get(Calendar.YEAR)
53+
val monthCurrent = c.get(Calendar.MONTH)
54+
val dayCurrent = c.get(Calendar.DAY_OF_MONTH)
55+
56+
return if(yearCurrent > year)
57+
true
58+
else if(monthCurrent > month + 4)
59+
true
60+
else (monthCurrent > month + 3) && (dayCurrent > day)
61+
}
62+
3963
fun evaluatePassword(passwordToTest: String) : Float {
4064

4165
var factor = 0

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

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import android.content.*
55
import android.content.res.Configuration
66
import android.database.Cursor
77
import android.database.SQLException
8-
import androidx.appcompat.app.AppCompatActivity
98
import android.os.Bundle
109
import android.view.KeyEvent
1110
import android.view.View
1211
import android.widget.Toast
1312
import androidx.appcompat.app.AlertDialog
13+
import androidx.appcompat.app.AppCompatActivity
1414
import androidx.appcompat.app.AppCompatDelegate
1515
import androidx.core.content.ContextCompat
1616
import com.google.android.material.chip.Chip
1717
import kotlinx.android.synthetic.main.activity_password_view.*
18-
import java.util.*
1918

2019
class PasswordViewActivity : AppCompatActivity() {
2120

@@ -133,7 +132,21 @@ class PasswordViewActivity : AppCompatActivity() {
133132
dbPassword = pCursor.getString(passIndex).toString()
134133
passViewField.setText(dbPassword)
135134
val myPasswordManager = PasswordManager()
136-
val evaluation: String = myPasswordManager.evaluatePasswordString(dbPassword)
135+
var evaluation: String = myPasswordManager.evaluatePasswordString(dbPassword)
136+
137+
val dbTimeIndex = pCursor.getString(timeIndex).toString()
138+
passwordTime.text = getString(R.string.time_lim) + " " + dbTimeIndex
139+
140+
dbGroup = if(pCursor.getString(groupIndex) == null)
141+
"none"
142+
else
143+
pCursor.getString(groupIndex).toString()
144+
145+
if((myPasswordManager.evaluateDate(dbTimeIndex)) && (dbPassword.length!= 4)){
146+
warnCard.visibility = View.VISIBLE
147+
evaluation = "low"
148+
}
149+
137150
when (evaluation) {
138151
"low" -> passQuality.text = getString(R.string.low)
139152
"high" -> passQuality.text = getString(R.string.high)
@@ -176,26 +189,6 @@ class PasswordViewActivity : AppCompatActivity() {
176189
}
177190

178191

179-
val dbTimeIndex = pCursor.getString(timeIndex).toString()
180-
passwordTime.text = getString(R.string.time_lim) + " " + dbTimeIndex
181-
182-
dbGroup = if(pCursor.getString(groupIndex) == null)
183-
"none"
184-
else
185-
pCursor.getString(groupIndex).toString()
186-
187-
//val year = dbTimeIndex.substring(0, 3).toInt()
188-
val month = dbTimeIndex.substring(5, 7).toInt()
189-
//val day = dbTimeIndex.substring(8, 9).toInt()
190-
//val hour = dbTimeIndex.substring(11, 12).toInt()
191-
//val minute = dbTimeIndex.substring(14, 15).toInt()
192-
//val second = dbTimeIndex.substring(17, 18).toInt()
193-
194-
val c = Calendar.getInstance()
195-
val month2 = c.get(Calendar.MONTH)
196-
if(month2 + 1 - month >= 4){
197-
warnCard.visibility = View.VISIBLE
198-
}
199192

200193

201194
val dbDescIndex = pCursor.getString(descIndex).toString()
@@ -252,7 +245,7 @@ class PasswordViewActivity : AppCompatActivity() {
252245
}
253246

254247
deletePassword.setOnClickListener {
255-
val builder = AlertDialog.Builder(this)
248+
val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom)
256249
builder.setTitle(getString(R.string.deletePassword))
257250
builder.setMessage(getString(R.string.passwordDeleteConfirm))
258251

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<inset xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:insetLeft="20dp"
4+
android:insetTop="40dp"
5+
android:insetRight="20dp"
6+
android:insetBottom="40dp">
7+
<shape
8+
android:insetRight="10dp"
9+
android:insetLeft="10dp">
10+
<solid android:color="@color/white"
11+
android:insetRight="10dp"
12+
android:insetLeft="10dp"/>
13+
<corners android:radius="15dp" />
14+
</shape>
15+
</inset>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@
268268
android:layout_width="match_parent"
269269
android:layout_height="match_parent"
270270
android:layout_gravity="center"
271-
android:layout_margin="10dp"
271+
android:layout_marginStart="10dp"
272+
android:layout_marginEnd="10dp"
273+
android:layout_marginTop="20dp"
272274
android:orientation="horizontal"
273275
tools:ignore="UseCompoundDrawables">
274276

@@ -320,7 +322,9 @@
320322
android:layout_width="match_parent"
321323
android:layout_height="match_parent"
322324
android:layout_gravity="center"
323-
android:layout_margin="10dp"
325+
android:layout_marginStart="10dp"
326+
android:layout_marginEnd="10dp"
327+
android:layout_marginBottom="20dp"
324328
android:orientation="horizontal"
325329
tools:ignore="UseCompoundDrawables">
326330

0 commit comments

Comments
 (0)