Skip to content

Commit

Permalink
Merge branch 'release/3.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Jamet committed Jun 2, 2022
2 parents 1c0f1a0 + 6d15a24 commit 0ef574d
Show file tree
Hide file tree
Showing 32 changed files with 438 additions and 203 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
KeePassDX(3.4.5)
* Fix custom data in group (fix KeeShare) #1335
* Fix device credential unlocking #1344
* New clipboard manager #1343
* Keep screen on by default when viewing an entry
* Change the order of the search filters
* Fix searchable selection

KeePassDX(3.4.4)
* Fix crash in New Android 13 #1321
* Better backstack management for selection mode
Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
compileSdkVersion 32
buildToolsVersion "32.0.0"
ndkVersion "21.4.7075529"

defaultConfig {
applicationId "com.kunzisoft.keepass"
minSdkVersion 15
targetSdkVersion 31
versionCode = 113
versionName = "3.4.4"
targetSdkVersion 32
versionCode = 114
versionName = "3.4.5"
multiDexEnabled true

testApplicationId = "com.kunzisoft.keepass.tests"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ class EntryEditActivity : DatabaseLockActivity(),
}
}
}

// Keep the screen on
if (PreferencesUtil.isKeepScreenOnEnabled(this)) {
window.addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.kunzisoft.keepass.view.TemplateView
import com.kunzisoft.keepass.view.hideByFading
import com.kunzisoft.keepass.view.showByFading
import com.kunzisoft.keepass.viewmodels.EntryViewModel
import java.util.*

class EntryFragment: DatabaseFragment() {

Expand Down Expand Up @@ -158,11 +157,9 @@ class EntryFragment: DatabaseFragment() {

setOnCopyActionClickListener { field ->
mClipboardHelper?.timeoutCopyToClipboard(
TemplateField.getLocalizedName(context, field.name),
field.protectedValue.stringValue,
getString(
R.string.copy_field,
TemplateField.getLocalizedName(context, field.name)
)
field.protectedValue.isProtected
)
}
}
Expand Down Expand Up @@ -251,8 +248,7 @@ class EntryFragment: DatabaseFragment() {

fun launchEntryCopyEducationAction() {
val appNameString = getString(R.string.app_name)
mClipboardHelper?.timeoutCopyToClipboard(appNameString,
getString(R.string.copy_field, appNameString))
mClipboardHelper?.timeoutCopyToClipboard(appNameString, appNameString)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ class PassphraseGeneratorFragment : DatabaseFragment() {
View.VISIBLE else View.GONE
val clipboardHelper = ClipboardHelper(context)
passphraseCopyView?.setOnClickListener {
clipboardHelper.timeoutCopyToClipboard(passKeyView.passwordString,
getString(R.string.copy_field,
getString(R.string.entry_password)))
clipboardHelper.timeoutCopyToClipboard(
getString(R.string.passphrase),
passKeyView.passwordString,
true
)
}

wordCaseAdapter = ArrayAdapter(context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ class PasswordGeneratorFragment : DatabaseFragment() {
View.VISIBLE else View.GONE
val clipboardHelper = ClipboardHelper(context)
passwordCopyView?.setOnClickListener {
clipboardHelper.timeoutCopyToClipboard(passKeyView.passwordString,
getString(R.string.copy_field,
getString(R.string.entry_password)))
clipboardHelper.timeoutCopyToClipboard(
getString(R.string.password),
passKeyView.passwordString,
true
)
}
}

Expand Down
17 changes: 9 additions & 8 deletions app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ package com.kunzisoft.keepass.adapters

import android.content.Context
import android.graphics.Color
import android.util.Log
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.ColorInt
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SortedList
Expand Down Expand Up @@ -521,13 +521,14 @@ class NodesAdapter (private val context: Context,
}
holder?.otpContainer?.setOnClickListener {
otpElement?.token?.let { token ->
Toast.makeText(
context,
context.getString(R.string.copy_field,
TemplateField.getLocalizedName(context, TemplateField.LABEL_TOKEN)),
Toast.LENGTH_LONG
).show()
mClipboardHelper.copyToClipboard(token)
try {
mClipboardHelper.copyToClipboard(
TemplateField.getLocalizedName(context, TemplateField.LABEL_TOKEN),
token
)
} catch (e: Exception) {
Log.e(TAG, "Unable to copy the OTP token", e)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,11 @@ class AdvancedUnlockManager(private var retrieveContext: () -> FragmentActivity)
}
}

@RequiresApi(api = Build.VERSION_CODES.M)
fun isDeviceSecure(context: Context): Boolean {
val keyguardManager = ContextCompat.getSystemService(context, KeyguardManager::class.java)
return keyguardManager?.isDeviceSecure ?: false
return ContextCompat.getSystemService(context, KeyguardManager::class.java)
?.isDeviceSecure ?: false
}

@RequiresApi(api = Build.VERSION_CODES.M)
fun biometricUnlockSupported(context: Context): Boolean {
val biometricCanAuthenticate = try {
BiometricManager.from(context).canAuthenticate(BIOMETRIC_STRONG)
Expand All @@ -430,28 +428,23 @@ class AdvancedUnlockManager(private var retrieveContext: () -> FragmentActivity)
)
}

@RequiresApi(api = Build.VERSION_CODES.M)
fun deviceCredentialUnlockSupported(context: Context): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val biometricCanAuthenticate = BiometricManager.from(context).canAuthenticate(DEVICE_CREDENTIAL)
return (biometricCanAuthenticate == BiometricManager.BIOMETRIC_SUCCESS
(biometricCanAuthenticate == BiometricManager.BIOMETRIC_SUCCESS
|| biometricCanAuthenticate == BiometricManager.BIOMETRIC_STATUS_UNKNOWN
|| biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE
|| biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED
|| biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED
)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ContextCompat.getSystemService(context, KeyguardManager::class.java)?.apply {
return isDeviceSecure
}
} else {
true
}
return false
}

/**
* Remove entry key in keystore
*/
@RequiresApi(api = Build.VERSION_CODES.M)
fun deleteEntryKeyInKeystoreForBiometric(fragmentActivity: FragmentActivity,
advancedCallback: AdvancedUnlockErrorCallback) {
AdvancedUnlockManager{ fragmentActivity }.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,6 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
mFieldReferenceEngine.clear()
}

fun containsPublicCustomData(): Boolean {
return publicCustomData.size() > 0
}

fun buildNewBinaryAttachment(smallSize: Boolean,
compression: Boolean,
protection: Boolean,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ constructor(private val databaseKDBX: DatabaseKDBX,
writeHeaderField(DatabaseHeaderKDBX.PwDbHeaderV4Fields.InnerRandomStreamID, uIntTo4Bytes(header.innerRandomStream!!.id))
}

if (databaseKDBX.containsPublicCustomData()) {
if (databaseKDBX.publicCustomData.size() > 0) {
val bos = ByteArrayOutputStream()
VariantDictionary.serialize(databaseKDBX.publicCustomData, bos)
writeHeaderField(DatabaseHeaderKDBX.PwDbHeaderV4Fields.PublicCustomData, bos.toByteArray())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class DatabaseOutputKDBX(private val mDatabaseKDBX: DatabaseKDBX,
writeBoolean(DatabaseKDBXXML.ElemEnableAutoType, group.enableAutoType)
writeBoolean(DatabaseKDBXXML.ElemEnableSearching, group.enableSearching)
writeUuid(DatabaseKDBXXML.ElemLastTopVisibleEntry, group.lastTopVisibleEntry)
writeCustomData(group.customData)
}

@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class ClipboardEntryNotificationField : Parcelable {

private var id: NotificationFieldId = NotificationFieldId.UNKNOWN
var label: String = ""
val isSensitive: Boolean
get() {
return id == NotificationFieldId.PASSWORD
}

val actionKey: String
get() = getActionKey(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.timeout.ClipboardHelper
import com.kunzisoft.keepass.timeout.TimeoutHelper.NEVER
import com.kunzisoft.keepass.utils.LOCK_ACTION
import java.util.*

class ClipboardEntryNotificationService : LockNotificationService() {

Expand Down Expand Up @@ -75,7 +74,7 @@ class ClipboardEntryNotificationService : LockNotificationService() {
}
ACTION_CLEAN_CLIPBOARD == intent.action -> {
mTimerJob?.cancel()
cleanClipboard()
clipboardHelper?.cleanClipboard()
stopNotificationAndSendLockIfNeeded()
}
else -> for (actionKey in ClipboardEntryNotificationField.allActionKeys) {
Expand Down Expand Up @@ -153,7 +152,11 @@ class ClipboardEntryNotificationService : LockNotificationService() {

try {
var generatedValue = fieldToCopy.getGeneratedValue(mEntryInfo)
clipboardHelper?.copyToClipboard(fieldToCopy.label, generatedValue)
clipboardHelper?.copyToClipboard(
fieldToCopy.label,
generatedValue,
fieldToCopy.isSensitive
)

val builder = buildNewNotification()
.setSmallIcon(R.drawable.notification_ic_clipboard_key_24dp)
Expand Down Expand Up @@ -186,13 +189,17 @@ class ClipboardEntryNotificationService : LockNotificationService() {
// New auto generated value
if (generatedValue != newGeneratedValue) {
generatedValue = newGeneratedValue
clipboardHelper?.copyToClipboard(fieldToCopy.label, generatedValue)
clipboardHelper?.copyToClipboard(
fieldToCopy.label,
generatedValue,
fieldToCopy.isSensitive
)
}
}) {
stopNotificationAndSendLockIfNeeded()
// Clean password only if no next field
if (nextFields.size <= 0)
cleanClipboard()
clipboardHelper?.cleanClipboard()
}
} else {
// No timer
Expand All @@ -202,25 +209,15 @@ class ClipboardEntryNotificationService : LockNotificationService() {
} catch (e: Exception) {
Log.e(TAG, "Clipboard can't be populate", e)
}

}

private fun cleanClipboard() {
try {
clipboardHelper?.cleanClipboard()
} catch (e: Exception) {
Log.e(TAG, "Clipboard can't be cleaned", e)
}
}

override fun onTaskRemoved(rootIntent: Intent?) {
cleanClipboard()

clipboardHelper?.cleanClipboard()
super.onTaskRemoved(rootIntent)
}

override fun onDestroy() {
cleanClipboard()
clipboardHelper?.cleanClipboard()
super.onDestroy()
}

Expand Down
Loading

0 comments on commit 0ef574d

Please sign in to comment.