Skip to content

Commit

Permalink
Merge branch 'release/2.5.0.0beta25'
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Jamet committed Nov 30, 2019
2 parents 7149bdb + f5e02ec commit 3d7e248
Show file tree
Hide file tree
Showing 190 changed files with 7,301 additions and 6,034 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
KeepassDX (2.5.0.0beta25)
* Setting for Recycle Bin
* Fix Recycle bin issues
* Fix TOTP
* Fix infinite save
* Fix update group
* Fix OOM

KeepassDX (2.5.0.0beta24)
* Add OTP (HOTP / TOTP)
* Add settings (Color, Security, Master Key)
Expand Down
8 changes: 2 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
ndkVersion "20.1.5948944"

defaultConfig {
applicationId "com.kunzisoft.keepass"
minSdkVersion 14
targetSdkVersion 28
versionCode = 24
versionName = "2.5.0.0beta24"
versionCode = 25
versionName = "2.5.0.0beta25"
multiDexEnabled true

testApplicationId = "com.kunzisoft.keepass.tests"
Expand All @@ -28,7 +27,6 @@ android {
}
}


buildTypes {
release {
minifyEnabled = false
Expand Down Expand Up @@ -109,8 +107,6 @@ dependencies {
implementation 'org.apache.commons:commons-io:1.3.2'
// Apache Commons Codec
implementation 'commons-codec:commons-codec:1.11'
// Base64
implementation 'biz.source_code:base64coder:2010-12-19'
// Icon pack
implementation project(path: ':icon-pack-classic')
implementation project(path: ':icon-pack-material')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import java.util.Random

import junit.framework.TestCase

import com.kunzisoft.keepass.database.element.PwDate
import com.kunzisoft.keepass.stream.LEDataInputStream
import com.kunzisoft.keepass.stream.LEDataOutputStream
import com.kunzisoft.keepass.utils.Types
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils

class TypesTest : TestCase() {
class DatabaseInputOutputUtilsTest : TestCase() {

fun testReadWriteLongZero() {
testReadWriteLong(0.toByte())
Expand Down Expand Up @@ -155,8 +154,8 @@ class TypesTest : TestCase() {

setArray(orig, value, 0, 1)

val one = Types.readUByte(orig, 0)
Types.writeUByte(one, dest, 0)
val one = DatabaseInputOutputUtils.readUByte(orig, 0)
DatabaseInputOutputUtils.writeUByte(one, dest, 0)

assertArrayEquals(orig, dest)

Expand All @@ -168,27 +167,31 @@ class TypesTest : TestCase() {
val expected = Calendar.getInstance()
expected.set(2008, 1, 2, 3, 4, 5)

val buf = PwDate.writeTime(expected.time, cal)
val actual = Calendar.getInstance()
actual.time = PwDate.readTime(buf, 0, cal)
DatabaseInputOutputUtils.writeCDate(expected.time, cal)?.let { buf ->
actual.time = DatabaseInputOutputUtils.readCDate(buf, 0, cal).date
}

assertEquals("Year mismatch: ", 2008, actual.get(Calendar.YEAR))
assertEquals("Month mismatch: ", 1, actual.get(Calendar.MONTH))
assertEquals("Day mismatch: ", 1, actual.get(Calendar.DAY_OF_MONTH))
assertEquals("Day mismatch: ", 2, actual.get(Calendar.DAY_OF_MONTH))
assertEquals("Hour mismatch: ", 3, actual.get(Calendar.HOUR_OF_DAY))
assertEquals("Minute mismatch: ", 4, actual.get(Calendar.MINUTE))
assertEquals("Second mismatch: ", 5, actual.get(Calendar.SECOND))
}

fun testUUID() {
val rnd = Random()
val bUUID = ByteArray(16)
rnd.nextBytes(bUUID)
Random().nextBytes(bUUID)

val uuid = DatabaseInputOutputUtils.bytesToUuid(bUUID)
val eUUID = DatabaseInputOutputUtils.uuidToBytes(uuid)

val uuid = Types.bytestoUUID(bUUID)
val eUUID = Types.UUIDtoBytes(uuid)
val lUUID = LEDataInputStream.readUuid(bUUID, 0)
val leUUID = DatabaseInputOutputUtils.uuidToBytes(lUUID)

assertArrayEquals("UUID match failed", bUUID, eUUID)
assertArrayEquals("UUID match failed", bUUID, leUUID)
}

@Throws(Exception::class)
Expand All @@ -200,7 +203,7 @@ class TypesTest : TestCase() {

val bos = ByteArrayOutputStream()
val leos = LEDataOutputStream(bos)
leos.writeLong(Types.ULONG_MAX_VALUE)
leos.writeLong(DatabaseInputOutputUtils.ULONG_MAX_VALUE)
leos.close()

val uLongMax = bos.toByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ package com.kunzisoft.keepass.tests

import junit.framework.TestCase

import com.kunzisoft.keepass.database.element.PwDate
import com.kunzisoft.keepass.database.element.DateInstant
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
import org.junit.Assert

class PwDateTest : TestCase() {

fun testDate() {
val jDate = PwDate(System.currentTimeMillis())
val intermediate = PwDate(jDate)
val cDate = PwDate(intermediate.byteArrayDate!!, 0)
val jDate = DateInstant(System.currentTimeMillis())
val intermediate = DateInstant(jDate)
val cDate = DatabaseInputOutputUtils.readCDate(DatabaseInputOutputUtils.writeCDate(intermediate.date)!!, 0)

Assert.assertTrue("jDate and intermediate not equal", jDate == intermediate)
Assert.assertTrue("jDate and cDate not equal", cDate == jDate)
Assert.assertTrue("jDate $jDate and cDate $cDate not equal", cDate == jDate)
}
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
android:allowBackup="true"
android:fullBackupContent="@xml/backup"
android:backupAgent="com.kunzisoft.keepass.backup.SettingsBackupAgent"
android:largeHeap="true"
android:theme="@style/KeepassDXStyle.Night">
<!-- TODO backup API Key -->
<meta-data
Expand Down
28 changes: 13 additions & 15 deletions app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
import com.kunzisoft.keepass.activities.lock.LockingHideActivity
import com.kunzisoft.keepass.database.element.Database
import com.kunzisoft.keepass.database.element.EntryVersioned
import com.kunzisoft.keepass.database.element.PwNodeId
import com.kunzisoft.keepass.database.element.Entry
import com.kunzisoft.keepass.database.element.node.NodeId
import com.kunzisoft.keepass.education.EntryActivityEducation
import com.kunzisoft.keepass.icons.assignDatabaseIcon
import com.kunzisoft.keepass.magikeyboard.MagikIME
Expand All @@ -64,7 +64,7 @@ class EntryActivity : LockingHideActivity() {

private var mDatabase: Database? = null

private var mEntry: EntryVersioned? = null
private var mEntry: Entry? = null
private var mIsHistory: Boolean = false

private var mShowPassword: Boolean = false
Expand Down Expand Up @@ -115,7 +115,7 @@ class EntryActivity : LockingHideActivity() {

// Get Entry from UUID
try {
val keyEntry: PwNodeId<UUID> = intent.getParcelableExtra(KEY_ENTRY)
val keyEntry: NodeId<UUID> = intent.getParcelableExtra(KEY_ENTRY)
mEntry = mDatabase?.getEntryById(keyEntry)
} catch (e: ClassCastException) {
Log.e(TAG, "Unable to retrieve the entry key")
Expand Down Expand Up @@ -158,7 +158,7 @@ class EntryActivity : LockingHideActivity() {
firstLaunchOfActivity = false
}

private fun fillEntryDataInContentsView(entry: EntryVersioned) {
private fun fillEntryDataInContentsView(entry: Entry) {

val database = Database.getInstance()
database.startManageEntry(entry)
Expand Down Expand Up @@ -298,6 +298,8 @@ class EntryActivity : LockingHideActivity() {
}

database.stopManageEntry(entry)

entryContentsView?.refreshHistory()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Expand Down Expand Up @@ -327,9 +329,9 @@ class EntryActivity : LockingHideActivity() {
val inflater = menuInflater
MenuUtil.contributionMenuInflater(inflater, menu)
inflater.inflate(R.menu.entry, menu)
inflater.inflate(R.menu.database_lock, menu)

inflater.inflate(R.menu.database, menu)
if (mReadOnly) {
menu.findItem(R.id.menu_save_database)?.isVisible = false
menu.findItem(R.id.menu_edit)?.isVisible = false
}

Expand Down Expand Up @@ -398,21 +400,18 @@ class EntryActivity : LockingHideActivity() {
MenuUtil.onContributionItemSelected(this)
return true
}

R.id.menu_toggle_pass -> {
mShowPassword = !mShowPassword
changeShowPasswordIcon(item)
entryContentsView?.setHiddenPasswordStyle(!mShowPassword)
return true
}

R.id.menu_edit -> {
mEntry?.let {
EntryEditActivity.launch(this@EntryActivity, it)
}
return true
}

R.id.menu_goto_url -> {
var url: String = mEntry?.url ?: ""

Expand All @@ -422,18 +421,17 @@ class EntryActivity : LockingHideActivity() {
}

UriUtil.gotoUrl(this, url)

return true
}

R.id.menu_lock -> {
lockAndExit()
return true
}

R.id.menu_save_database -> {
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
}
android.R.id.home -> finish() // close this activity and return to preview activity (if there is any)
}

return super.onOptionsItemSelected(item)
}

Expand All @@ -455,7 +453,7 @@ class EntryActivity : LockingHideActivity() {
const val KEY_ENTRY = "KEY_ENTRY"
const val KEY_ENTRY_HISTORY_POSITION = "KEY_ENTRY_HISTORY_POSITION"

fun launch(activity: Activity, entry: EntryVersioned, readOnly: Boolean, historyPosition: Int? = null) {
fun launch(activity: Activity, entry: Entry, readOnly: Boolean, historyPosition: Int? = null) {
if (TimeoutHelper.checkTimeAndLockIfTimeout(activity)) {
val intent = Intent(activity, EntryActivity::class.java)
intent.putExtra(KEY_ENTRY, entry.nodeId)
Expand Down
Loading

0 comments on commit 3d7e248

Please sign in to comment.