@@ -93,7 +93,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
93
93
setContentView(R .layout.encrypt_layout)
94
94
95
95
generate_password?.setOnClickListener {
96
- pwgenDialogFragment().show(fragmentManager , " generator" )
96
+ pwgenDialogFragment().show(supportFragmentManager , " generator" )
97
97
}
98
98
99
99
title = getString(R .string.new_password_title)
@@ -149,7 +149,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
149
149
* Shows a simple toast message
150
150
*/
151
151
private fun showToast (message : String ) {
152
- runOnUiThread( { Toast .makeText(this , message, Toast .LENGTH_SHORT ).show() })
152
+ runOnUiThread { Toast .makeText(this , message, Toast .LENGTH_SHORT ).show() }
153
153
}
154
154
155
155
/* *
@@ -193,7 +193,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
193
193
api = api ? : OpenPgpApi (this , mServiceConnection?.service)
194
194
}
195
195
196
- private fun decryptAndVerify (receivedIntent : Intent ? = null): Unit {
196
+ private fun decryptAndVerify (receivedIntent : Intent ? = null) {
197
197
val data = receivedIntent ? : Intent ()
198
198
data.action = ACTION_DECRYPT_VERIFY
199
199
@@ -293,26 +293,26 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
293
293
dialogBuilder.setView(checkLayout)
294
294
dialogBuilder.setMessage(R .string.dialog_update_body)
295
295
.setCancelable(false )
296
- .setPositiveButton(R .string.dialog_update_positive, DialogInterface . OnClickListener { dialog, id ->
296
+ .setPositiveButton(R .string.dialog_update_positive) { _, _ ->
297
297
run {
298
298
calculateAndCommitHotp(entry)
299
- if (rememberCheck.isChecked() ) {
299
+ if (rememberCheck.isChecked) {
300
300
val editor = settings.edit()
301
301
editor.putBoolean(" hotp_remember_check" , true )
302
302
editor.putBoolean(" hotp_remember_choice" , true )
303
303
editor.commit()
304
304
}
305
305
}
306
- })
307
- .setNegativeButton(R .string.dialog_update_negative, DialogInterface . OnClickListener { dialog, id ->
308
- run {
309
- calculateHotp(entry)
310
- val editor = settings.edit()
311
- editor.putBoolean(" hotp_remember_check" , true )
312
- editor.putBoolean(" hotp_remember_choice" , false )
313
- editor.commit()
314
- }
315
- })
306
+ }
307
+ .setNegativeButton(R .string.dialog_update_negative) { _, _ ->
308
+ run {
309
+ calculateHotp(entry)
310
+ val editor = settings.edit()
311
+ editor.putBoolean(" hotp_remember_check" , true )
312
+ editor.putBoolean(" hotp_remember_choice" , false )
313
+ editor.commit()
314
+ }
315
+ }
316
316
val updateDialog = dialogBuilder.create()
317
317
updateDialog.setTitle(R .string.dialog_update_title)
318
318
updateDialog.show()
@@ -378,34 +378,33 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
378
378
379
379
val path = if (intent.getBooleanExtra(" fromDecrypt" , false )) fullPath else " $fullPath /$editName .gpg"
380
380
381
- api?.executeApiAsync(data, iStream, oStream, { result: Intent ? -> when (result?.getIntExtra(OpenPgpApi .RESULT_CODE , OpenPgpApi .RESULT_CODE_ERROR )) {
382
- OpenPgpApi .RESULT_CODE_SUCCESS -> {
383
- try {
384
- // TODO This might fail, we should check that the write is successful
385
- val outputStream = FileUtils .openOutputStream(File (path))
386
- outputStream.write(oStream.toByteArray())
387
- outputStream.close()
388
-
389
- val returnIntent = Intent ()
390
- returnIntent.putExtra(" CREATED_FILE" , path)
391
- returnIntent.putExtra(" NAME" , editName)
392
-
393
- // if coming from decrypt screen->edit button
394
- if (intent.getBooleanExtra(" fromDecrypt" , false )) {
395
- returnIntent.putExtra(" OPERATION" , " EDIT" )
396
- returnIntent.putExtra(" needCommit" , true )
397
- }
398
- setResult(RESULT_OK , returnIntent)
399
- finish()
400
-
401
- } catch (e: Exception ) {
402
- Log .e(TAG , " An Exception occurred" , e)
381
+ api?.executeApiAsync(data, iStream, oStream) { result: Intent ? -> when (result?.getIntExtra(OpenPgpApi .RESULT_CODE , OpenPgpApi .RESULT_CODE_ERROR )) {
382
+ OpenPgpApi .RESULT_CODE_SUCCESS -> {
383
+ try {
384
+ // TODO This might fail, we should check that the write is successful
385
+ val outputStream = FileUtils .openOutputStream(File (path))
386
+ outputStream.write(oStream.toByteArray())
387
+ outputStream.close()
388
+
389
+ val returnIntent = Intent ()
390
+ returnIntent.putExtra(" CREATED_FILE" , path)
391
+ returnIntent.putExtra(" NAME" , editName)
392
+
393
+ // if coming from decrypt screen->edit button
394
+ if (intent.getBooleanExtra(" fromDecrypt" , false )) {
395
+ returnIntent.putExtra(" OPERATION" , " EDIT" )
396
+ returnIntent.putExtra(" needCommit" , true )
403
397
}
398
+ setResult(RESULT_OK , returnIntent)
399
+ finish()
400
+ } catch (e: Exception ) {
401
+ Log .e(TAG , " An Exception occurred" , e)
404
402
}
405
- OpenPgpApi .RESULT_CODE_ERROR -> handleError(result)
406
403
}
404
+ OpenPgpApi .RESULT_CODE_ERROR -> handleError(result)
405
+ }
407
406
408
- })
407
+ }
409
408
}
410
409
411
410
@@ -415,7 +414,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
415
414
private fun editPassword () {
416
415
setContentView(R .layout.encrypt_layout)
417
416
generate_password?.setOnClickListener {
418
- pwgenDialogFragment().show(fragmentManager , " generator" )
417
+ pwgenDialogFragment().show(supportFragmentManager , " generator" )
419
418
}
420
419
421
420
title = getString(R .string.edit_password_title)
@@ -482,7 +481,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
482
481
private fun getKeyIds (receivedIntent : Intent ? = null) {
483
482
val data = receivedIntent ? : Intent ()
484
483
data.action = OpenPgpApi .ACTION_GET_KEY_IDS
485
- api?.executeApiAsync(data, null , null , { result: Intent ? ->
484
+ api?.executeApiAsync(data, null , null ) { result: Intent ? ->
486
485
when (result?.getIntExtra(OpenPgpApi .RESULT_CODE , OpenPgpApi .RESULT_CODE_ERROR )) {
487
486
OpenPgpApi .RESULT_CODE_SUCCESS -> {
488
487
try {
@@ -503,7 +502,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
503
502
RESULT_CODE_USER_INTERACTION_REQUIRED -> handleUserInteractionRequest(result, REQUEST_KEY_ID )
504
503
OpenPgpApi .RESULT_CODE_ERROR -> handleError(result)
505
504
}
506
- })
505
+ }
507
506
}
508
507
509
508
override fun onError (e : Exception ? ) {}
@@ -737,11 +736,11 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
737
736
}
738
737
739
738
companion object {
740
- val OPEN_PGP_BOUND = 101
741
- val REQUEST_DECRYPT = 202
742
- val REQUEST_KEY_ID = 203
739
+ const val OPEN_PGP_BOUND = 101
740
+ const val REQUEST_DECRYPT = 202
741
+ const val REQUEST_KEY_ID = 203
743
742
744
- val TAG = " PgpActivity"
743
+ const val TAG = " PgpActivity"
745
744
746
745
private var delayTask: DelayShow ? = null
747
746
0 commit comments