Skip to content

Commit

Permalink
Merge branch 'release/2.8.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Jamet committed Sep 25, 2020
2 parents bcc8226 + aea5493 commit c5cbba5
Show file tree
Hide file tree
Showing 55 changed files with 896 additions and 198 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
KeePassDX(2.8.6)
* Fix Autofill recognition #712
* Keep value after renaming custom field #709
* Prevent random binary bug #713
* Fix dialog background #717
* Better domain recognition for autofill #702
* Write custom data #651
* Fix autolink #720

KeePassDX(2.8.5)
* Fix Base 64 #708

Expand Down
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.2'

defaultConfig {
applicationId "com.kunzisoft.keepass"
minSdkVersion 14
targetSdkVersion 29
versionCode = 41
versionName = "2.8.5"
targetSdkVersion 30
versionCode = 42
versionName = "2.8.6"
multiDexEnabled true

testApplicationId = "com.kunzisoft.keepass.tests"
Expand Down Expand Up @@ -98,13 +98,14 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.cardview:cardview:1.0.0'
// WARNING: Bug with extra field
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.biometric:biometric:1.0.1'
// Lifecycle - LiveData - ViewModel - Coroutines
implementation "androidx.core:core-ktx:1.3.1"
implementation 'androidx.fragment:fragment-ktx:1.2.5'
// To upgrade with style
// WARNING: To upgrade with style, bug in edit text
implementation 'com.google.android.material:material:1.0.0'
// Database
implementation "androidx.room:room-runtime:$room_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -422,7 +423,7 @@ class EntryActivity : LockingActivity() {
}

// Show education views
Handler().post { performedNextEducation(EntryActivityEducation(this), menu) }
Handler(Looper.getMainLooper()).post { performedNextEducation(EntryActivityEducation(this), menu) }

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -63,6 +64,7 @@ import com.kunzisoft.keepass.tasks.AttachmentFileBinderManager
import com.kunzisoft.keepass.timeout.TimeoutHelper
import com.kunzisoft.keepass.utils.MenuUtil
import com.kunzisoft.keepass.utils.UriUtil
import com.kunzisoft.keepass.utils.closeDatabase
import com.kunzisoft.keepass.view.asError
import com.kunzisoft.keepass.view.showActionError
import com.kunzisoft.keepass.view.updateLockPaddingLeft
Expand Down Expand Up @@ -416,7 +418,7 @@ class EntryEditActivity : LockingActivity(),

private fun buildNewAttachment(attachmentToUploadUri: Uri, fileName: String) {
val compression = mDatabase?.compressionForNewEntry() ?: false
mDatabase?.buildNewBinary(applicationContext.filesDir, false, compression)?.let { binaryAttachment ->
mDatabase?.buildNewBinary(UriUtil.getBinaryDir(this), compression)?.let { binaryAttachment ->
val entryAttachment = Attachment(fileName, binaryAttachment)
// Ask to replace the current attachment
if ((mDatabase?.allowMultipleAttachments != true && entryEditFragment?.containsAttachment() == true) ||
Expand Down Expand Up @@ -525,7 +527,7 @@ class EntryEditActivity : LockingActivity(),

override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
entryEditActivityEducation?.let {
Handler().post { performedNextEducation(it) }
Handler(Looper.getMainLooper()).post { performedNextEducation(it) }
}
return super.onPrepareOptionsMenu(menu)
}
Expand Down Expand Up @@ -662,7 +664,7 @@ class EntryEditActivity : LockingActivity(),
}

entryEditActivityEducation?.let {
Handler().post { performedNextEducation(it) }
Handler(Looper.getMainLooper()).post { performedNextEducation(it) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class EntryEditFragment: StylishFragment() {
}

/**
* Update an extra field or create a new one if doesn't exists
* Update an extra field or create a new one if doesn't exists, the old value is lost
*/
fun putExtraField(extraField: Field) {
extraFieldsContainerView.visibility = View.VISIBLE
Expand All @@ -434,13 +434,24 @@ class EntryEditFragment: StylishFragment() {
}
}

/**
* Update an extra field and keep the old value
*/
fun replaceExtraField(oldExtraField: Field, newExtraField: Field) {
extraFieldsContainerView.visibility = View.VISIBLE
val index = mExtraFieldsList.indexOf(oldExtraField)
val oldValueEditText: EditText = extraFieldsListView.getChildAt(index)
.findViewWithTag("FIELD_VALUE_TAG")
val oldValue = oldValueEditText.text.toString()
val newExtraFieldWithOldValue = Field(newExtraField).apply {
this.protectedValue.stringValue = oldValue
}
mExtraFieldsList.removeAt(index)
mExtraFieldsList.add(index, newExtraField)
mExtraFieldsList.add(index, newExtraFieldWithOldValue)
extraFieldsListView.removeViewAt(index)
extraFieldsListView.addView(buildViewFromField(newExtraField), index)
val newView = buildViewFromField(newExtraFieldWithOldValue)
extraFieldsListView.addView(newView, index)
newView?.requestFocus()
}

fun removeExtraField(oldExtraField: Field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -209,7 +210,6 @@ class FileDatabaseSelectActivity : SpecialModeActivity(),
/**
* Create a new file by calling the content provider
*/
@SuppressLint("InlinedApi")
private fun createNewFile() {
createDocument(this, getString(R.string.database_file_name_default) +
getString(R.string.database_file_extension_default), "application/x-keepass")
Expand Down Expand Up @@ -412,7 +412,7 @@ class FileDatabaseSelectActivity : SpecialModeActivity(),
MenuUtil.defaultMenuInflater(menuInflater, menu)
}

Handler().post { performedNextEducation(FileDatabaseSelectActivityEducation(this)) }
Handler(Looper.getMainLooper()).post { performedNextEducation(FileDatabaseSelectActivityEducation(this)) }

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -776,7 +777,7 @@ class GroupActivity : LockingActivity(),
super.onCreateOptionsMenu(menu)

// Launch education screen
Handler().post { performedNextEducation(GroupActivityEducation(this), menu) }
Handler(Looper.getMainLooper()).post { performedNextEducation(GroupActivityEducation(this), menu) }

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
Expand Down Expand Up @@ -67,6 +68,7 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.BACK_PREVIOUS_KEYBOARD_ACTION
import com.kunzisoft.keepass.utils.MenuUtil
import com.kunzisoft.keepass.utils.UriUtil
import com.kunzisoft.keepass.utils.closeDatabase
import com.kunzisoft.keepass.view.AdvancedUnlockInfoView
import com.kunzisoft.keepass.view.KeyFileSelectionView
import com.kunzisoft.keepass.view.asError
Expand Down Expand Up @@ -662,7 +664,7 @@ open class PasswordActivity : SpecialModeActivity() {
if (!performedEductionInProgress) {
performedEductionInProgress = true
// Show education views
Handler().post { performedNextEducation(PasswordActivityEducation(this), menu) }
Handler(Looper.getMainLooper()).post { performedNextEducation(PasswordActivityEducation(this), menu) }
}
}

Expand Down Expand Up @@ -763,7 +765,7 @@ open class PasswordActivity : SpecialModeActivity() {
when (resultCode) {
LockingActivity.RESULT_EXIT_LOCK -> {
clearCredentialsViews()
Database.getInstance().closeAndClear(applicationContext.filesDir)
Database.getInstance().closeAndClear(UriUtil.getBinaryDir(this))
}
Activity.RESULT_CANCELED -> {
clearCredentialsViews()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class DeleteNodesDialogFragment : DialogFragment() {
val builder = AlertDialog.Builder(activity)

builder.setMessage(getString(R.string.warning_permanently_delete_nodes))
builder.setPositiveButton(android.R.string.yes) { _, _ ->
builder.setPositiveButton(android.R.string.ok) { _, _ ->
mListener?.permanentlyDeleteNodes(mNodesToDelete)
}
builder.setNegativeButton(android.R.string.no) { _, _ -> dismiss() }
builder.setNegativeButton(android.R.string.cancel) { _, _ -> dismiss() }
// Create the AlertDialog object and return it
return builder.create()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ class FileTooBigDialogFragment : DialogFragment() {
append("\n\n")
append(getString(R.string.warning_sure_add_file))
})
builder.setPositiveButton(android.R.string.yes) { _, _ ->
builder.setPositiveButton(android.R.string.ok) { _, _ ->
mActionChooseListener?.onValidateUploadFileTooBig(
arguments?.getParcelable(KEY_FILE_URI),
arguments?.getString(KEY_FILE_NAME))
}
builder.setNegativeButton(android.R.string.no) { _, _ ->
builder.setNegativeButton(android.R.string.cancel) { _, _ ->
dismiss()
}
// Create the AlertDialog object and return it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ class ReplaceFileDialogFragment : DialogFragment() {
append("\n\n")
append(getString(R.string.warning_sure_add_file))
})
builder.setPositiveButton(android.R.string.yes) { _, _ ->
builder.setPositiveButton(android.R.string.ok) { _, _ ->
mActionChooseListener?.onValidateReplaceFile(
arguments?.getParcelable(KEY_FILE_URI),
arguments?.getParcelable(KEY_ENTRY_ATTACHMENT))
}
builder.setNegativeButton(android.R.string.no) { _, _ ->
builder.setNegativeButton(android.R.string.cancel) { _, _ ->
dismiss()
}
// Create the AlertDialog object and return it
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/kunzisoft/keepass/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package com.kunzisoft.keepass.app
import androidx.multidex.MultiDexApplication
import com.kunzisoft.keepass.activities.stylish.Stylish
import com.kunzisoft.keepass.database.element.Database
import com.kunzisoft.keepass.utils.UriUtil

class App : MultiDexApplication() {

Expand All @@ -33,7 +34,7 @@ class App : MultiDexApplication() {
}

override fun onTerminate() {
Database.getInstance().closeAndClear(applicationContext.filesDir)
Database.getInstance().closeAndClear(UriUtil.getBinaryDir(this))
super.onTerminate()
}
}
23 changes: 10 additions & 13 deletions app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ internal class StructureParser(private val structure: AssistStructure) {

private fun parseViewNode(node: AssistStructure.ViewNode): Boolean {
// Get the domain of a web app
node.webDomain?.let {
result?.domain = it
Log.d(TAG, "Autofill domain: $it")
node.webDomain?.let { webDomain ->
if (webDomain.isNotEmpty()) {
result?.domain = webDomain
Log.d(TAG, "Autofill domain: $webDomain")
}
}

// Only parse visible nodes
Expand Down Expand Up @@ -100,19 +102,14 @@ internal class StructureParser(private val structure: AssistStructure) {
val autofillId = node.autofillId
node.autofillHints?.forEach {
when {
it.equals(View.AUTOFILL_HINT_USERNAME, true)
|| it.equals(View.AUTOFILL_HINT_EMAIL_ADDRESS, true)
|| it.equals("email", true)
|| it.equals(View.AUTOFILL_HINT_PHONE, true)
|| it.contains("OrUsername", true)
|| it.contains("OrEmailAddress", true)
|| it.contains("OrEmail", true)
|| it.contains("OrPhone", true)-> {
it.contains(View.AUTOFILL_HINT_USERNAME, true)
|| it.contains(View.AUTOFILL_HINT_EMAIL_ADDRESS, true)
|| it.contains("email", true)
|| it.contains(View.AUTOFILL_HINT_PHONE, true)-> {
result?.usernameId = autofillId
Log.d(TAG, "Autofill username hint")
}
it.equals(View.AUTOFILL_HINT_PASSWORD, true)
|| it.contains("password", true) -> {
it.contains(View.AUTOFILL_HINT_PASSWORD, true) -> {
result?.passwordId = autofillId
Log.d(TAG, "Autofill password hint")
// Username not needed in this case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@
*/
package com.kunzisoft.keepass.crypto.keyDerivation

import com.kunzisoft.keepass.stream.LittleEndianDataInputStream
import com.kunzisoft.keepass.stream.LittleEndianDataOutputStream
import com.kunzisoft.keepass.stream.bytes16ToUuid
import com.kunzisoft.keepass.stream.uuidTo16Bytes
import com.kunzisoft.keepass.utils.VariantDictionary
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.util.*

class KdfParameters(val uuid: UUID) : VariantDictionary() {
class KdfParameters: VariantDictionary {

val uuid: UUID

constructor(uuid: UUID): super() {
this.uuid = uuid
}

constructor(uuid: UUID, d: VariantDictionary): super(d) {
this.uuid = uuid
}

fun setParamUUID() {
setByteArray(PARAM_UUID, uuidTo16Bytes(uuid))
Expand All @@ -41,25 +47,17 @@ class KdfParameters(val uuid: UUID) : VariantDictionary() {

@Throws(IOException::class)
fun deserialize(data: ByteArray): KdfParameters? {
val inputStream = LittleEndianDataInputStream(ByteArrayInputStream(data))
val dictionary = deserialize(inputStream)
val dictionary = VariantDictionary.deserialize(data)

val uuidBytes = dictionary.getByteArray(PARAM_UUID) ?: return null
val uuid = bytes16ToUuid(uuidBytes)

val kdfParameters = KdfParameters(uuid)
kdfParameters.copyTo(dictionary)
return kdfParameters
return KdfParameters(uuid, dictionary)
}

@Throws(IOException::class)
fun serialize(kdfParameters: KdfParameters): ByteArray {
val byteArrayOutputStream = ByteArrayOutputStream()
val outputStream = LittleEndianDataOutputStream(byteArrayOutputStream)

serialize(kdfParameters, outputStream)

return byteArrayOutputStream.toByteArray()
return VariantDictionary.serialize(kdfParameters)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import android.util.Log
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
import com.kunzisoft.keepass.database.element.Database
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.UriUtil
import com.kunzisoft.keepass.utils.closeDatabase

class CreateDatabaseRunnable(context: Context,
private val mDatabase: Database,
Expand All @@ -45,7 +47,7 @@ class CreateDatabaseRunnable(context: Context,
createData(mDatabaseUri, databaseName, rootName)
}
} catch (e: Exception) {
mDatabase.closeAndClear(context.applicationContext.filesDir)
mDatabase.closeAndClear(UriUtil.getBinaryDir(context))
setError(e)
}

Expand Down
Loading

0 comments on commit c5cbba5

Please sign in to comment.