@@ -31,7 +31,6 @@ class AccountActivity : AppCompatActivity() {
31
31
private val _keyUsePin = " prefUsePinKey"
32
32
private lateinit var login: String
33
33
private lateinit var passName: String
34
- private lateinit var account: String
35
34
36
35
private val realPass: ArrayList <Pair <String , String >> = ArrayList ()
37
36
private val realQuality: ArrayList <String > = ArrayList ()
@@ -50,6 +49,12 @@ class AccountActivity : AppCompatActivity() {
50
49
" battery" -> AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_AUTO_BATTERY )
51
50
}
52
51
super .onCreate(savedInstanceState)
52
+
53
+ when (resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK ) {
54
+ Configuration .UI_MODE_NIGHT_NO ->
55
+ window.decorView.systemUiVisibility = View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
56
+ }
57
+
53
58
// Finish app after some time
54
59
val handler = Handler ()
55
60
val r = Runnable {
@@ -58,20 +63,23 @@ class AccountActivity : AppCompatActivity() {
58
63
finish()
59
64
}
60
65
handler.postDelayed(r, 600000 )
61
- when (resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK ) {
62
- Configuration .UI_MODE_NIGHT_NO ->
63
- window.decorView.systemUiVisibility = View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
64
- }
66
+
65
67
setContentView(R .layout.activity_account)
66
68
69
+ // Get Extras
67
70
val args: Bundle ? = intent.extras
68
71
val sharedPref = getSharedPreferences(_preferenceFile , Context .MODE_PRIVATE )
69
72
login = args?.get(" login" ).toString()
73
+
74
+ // Set login
70
75
val newLogin = sharedPref.getString(_keyUsername , login)
71
76
if (newLogin != login)
72
77
login = newLogin.toString()
78
+
79
+ // Set pass
73
80
passName = args?.get(" passName" ).toString()
74
- account = args?.get(" activity" ).toString()
81
+
82
+ // Set greeting
75
83
val name: String? = getString(R .string.hi) + " " + login
76
84
helloTextId.text = name
77
85
@@ -82,6 +90,7 @@ class AccountActivity : AppCompatActivity() {
82
90
commit()
83
91
}
84
92
93
+ // Open users database
85
94
val dbHelper = DataBaseHelper (this )
86
95
val database = dbHelper.writableDatabase
87
96
val cursor: Cursor = database.query(
@@ -157,7 +166,9 @@ class AccountActivity : AppCompatActivity() {
157
166
val intent = Intent (this , AboutActivity ::class .java)
158
167
startActivity(intent)
159
168
}
169
+ cursor.close()
160
170
171
+ // Open passwords database
161
172
val pdbHelper = PasswordsDataBaseHelper (this , login)
162
173
val pDatabase = pdbHelper.writableDatabase
163
174
try {
@@ -179,9 +190,11 @@ class AccountActivity : AppCompatActivity() {
179
190
var correctNum = 0
180
191
var inCorrectNum = 0
181
192
var midCorrectNum = 0
193
+ var crNum = 0
182
194
var faNum = 0
183
195
var tlNum = 0
184
196
197
+ // First scan to analyze same passes
185
198
if (pCursor.moveToFirst()) {
186
199
val nameIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_NAME )
187
200
val passIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_PASS )
@@ -194,6 +207,7 @@ class AccountActivity : AppCompatActivity() {
194
207
195
208
analyzeDataBase()
196
209
210
+ // Second scan to set quality
197
211
if (pCursor.moveToFirst()) {
198
212
val passIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_PASS )
199
213
val aIndex: Int = pCursor.getColumnIndex(pdbHelper.KEY_2FA )
@@ -214,8 +228,10 @@ class AccountActivity : AppCompatActivity() {
214
228
}
215
229
216
230
217
- if (dbCipherIndex == " crypted" )
231
+ if (dbCipherIndex == " crypted" ) {
218
232
qualityNum = " 6"
233
+ crNum + = 1
234
+ }
219
235
220
236
val dbTimeIndex = pCursor.getString(timeIndex).toString()
221
237
if (myPasswordManager.evaluateDate(dbTimeIndex))
@@ -268,29 +284,29 @@ class AccountActivity : AppCompatActivity() {
268
284
269
285
afText.text = faNum.toString()
270
286
tlText.text = tlNum.toString()
271
-
287
+ crText.text = crNum.toString()
272
288
allPass.text = (correctNum+ inCorrectNum + midCorrectNum).toString()
273
289
274
290
realPoints.text = ((correctNum.toFloat() + midCorrectNum.toFloat()/ 2 + inCorrectNum.toFloat()* 0 + tlNum.toFloat() + faNum.toFloat())
275
291
/ (7 / 3 * (correctNum.toFloat() + inCorrectNum.toFloat() + midCorrectNum.toFloat())))
276
292
.toString()
277
-
293
+ pCursor.close()
278
294
} catch (e: SQLException ) {
279
295
}
280
296
297
+ // Settings button animation
281
298
val rotation = AnimationUtils .loadAnimation(this , R .anim.rotate)
282
299
rotation.fillAfter = true
283
300
settings.startAnimation(rotation)
284
301
302
+ // Log out button
285
303
logOut.setOnClickListener {
286
304
val builder = AlertDialog .Builder (this , R .style.AlertDialogCustom )
287
305
builder.setTitle(getString(R .string.exit_account))
288
306
builder.setMessage(getString(R .string.accountExitConfirm))
289
-
290
307
builder.setPositiveButton(getString(R .string.yes)){ _, _ ->
291
308
exit(sharedPref)
292
309
}
293
-
294
310
builder.setNegativeButton(getString(R .string.no)){ _, _ ->
295
311
}
296
312
@@ -300,22 +316,24 @@ class AccountActivity : AppCompatActivity() {
300
316
dialog.show()
301
317
}
302
318
319
+
320
+ // Edit button
303
321
editAccount.setOnClickListener {
304
322
val intent = Intent (this , EditAccountActivity ::class .java)
305
323
intent.putExtra(" login" , login)
306
324
intent.putExtra(" passName" , passName)
307
- intent.putExtra(" activity" , account)
308
325
startActivityForResult(intent, 1 )
309
326
}
310
327
328
+ // Settings button
311
329
settings.setOnClickListener {
312
330
val intent = Intent (this , SettingsActivity ::class .java)
313
331
intent.putExtra(" login" , login)
314
332
intent.putExtra(" passName" , passName)
315
- intent.putExtra(" activity" , account)
316
333
startActivityForResult(intent, 1 )
317
334
}
318
335
336
+ // Delete button
319
337
deleteAccount.setOnClickListener {
320
338
val builder = AlertDialog .Builder (this , R .style.AlertDialogCustom )
321
339
builder.setTitle(getString(R .string.accountDelete))
@@ -351,7 +369,6 @@ class AccountActivity : AppCompatActivity() {
351
369
val intent = Intent ()
352
370
intent.putExtra(" login" , login)
353
371
intent.putExtra(" passName" , passName)
354
- intent.putExtra(" activity" , account)
355
372
setResult(1 , intent)
356
373
finish()
357
374
}
@@ -369,7 +386,6 @@ class AccountActivity : AppCompatActivity() {
369
386
val intent = Intent ()
370
387
intent.putExtra(" login" , login)
371
388
intent.putExtra(" passName" , passName)
372
- intent.putExtra(" activity" , account)
373
389
setResult(1 , intent)
374
390
finish()
375
391
}
0 commit comments