mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-30 22:02:57 -08:00
Add date string for PwDate and new list view entry history
This commit is contained in:
1 parent
a8ccb67a87
commit
f5dc94bfec
11 files changed
+109
-52
No files matched your search
@@ -238,18 +238,11 @@ class EntryActivity : LockingHideActivity() {
|
||||
entryContentsView?.setHiddenPasswordStyle(!mShowPassword)
|
||||
|
||||
// Assign dates
|
||||
entry.creationTime.date?.let {
|
||||
entryContentsView?.assignCreationDate(it)
|
||||
}
|
||||
entry.lastModificationTime.date?.let {
|
||||
entryContentsView?.assignModificationDate(it)
|
||||
}
|
||||
entry.lastAccessTime.date?.let {
|
||||
entryContentsView?.assignLastAccessDate(it)
|
||||
}
|
||||
val expires = entry.expiryTime.date
|
||||
if (entry.isExpires && expires != null) {
|
||||
entryContentsView?.assignExpiresDate(expires)
|
||||
entryContentsView?.assignCreationDate(entry.creationTime)
|
||||
entryContentsView?.assignModificationDate(entry.lastModificationTime)
|
||||
entryContentsView?.assignLastAccessDate(entry.lastAccessTime)
|
||||
if (entry.isExpires) {
|
||||
entryContentsView?.assignExpiresDate(entry.expiryTime)
|
||||
} else {
|
||||
entryContentsView?.assignExpiresDate(getString(R.string.never))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.EntryVersioned
|
||||
|
||||
class EntryHistoryAdapter(context: Context) : RecyclerView.Adapter<EntryHistoryAdapter.EntryHistoryViewHolder>() {
|
||||
class EntryHistoryAdapter(val context: Context) : RecyclerView.Adapter<EntryHistoryAdapter.EntryHistoryViewHolder>() {
|
||||
|
||||
private val inflater: LayoutInflater = LayoutInflater.from(context)
|
||||
var entryHistoryList: MutableList<EntryVersioned> = ArrayList()
|
||||
@@ -22,7 +22,7 @@ class EntryHistoryAdapter(context: Context) : RecyclerView.Adapter<EntryHistoryA
|
||||
override fun onBindViewHolder(holder: EntryHistoryViewHolder, position: Int) {
|
||||
val entryHistory = entryHistoryList[position]
|
||||
|
||||
holder.lastModifiedView.text = entryHistory.lastModificationTime.date.toString()
|
||||
holder.lastModifiedView.text = entryHistory.lastModificationTime.getDateTimeString(context.resources)
|
||||
holder.titleView.text = entryHistory.title
|
||||
holder.usernameView.text = entryHistory.username
|
||||
holder.urlView.text = entryHistory.url
|
||||
|
||||
@@ -140,7 +140,7 @@ enum class SortNodeEnum {
|
||||
|
||||
override fun compareBySpecificOrder(object1: NodeVersioned, object2: NodeVersioned): Int {
|
||||
return object1.creationTime.date
|
||||
?.compareTo(object2.creationTime.date) ?: 0
|
||||
.compareTo(object2.creationTime.date)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ enum class SortNodeEnum {
|
||||
|
||||
override fun compareBySpecificOrder(object1: NodeVersioned, object2: NodeVersioned): Int {
|
||||
return object1.lastModificationTime.date
|
||||
?.compareTo(object2.lastModificationTime.date) ?: 0
|
||||
.compareTo(object2.lastModificationTime.date)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ enum class SortNodeEnum {
|
||||
|
||||
override fun compareBySpecificOrder(object1: NodeVersioned, object2: NodeVersioned): Int {
|
||||
return object1.lastAccessTime.date
|
||||
?.compareTo(object2.lastAccessTime.date) ?: 0
|
||||
.compareTo(object2.lastAccessTime.date)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,9 +360,7 @@ class PwDatabaseV4 : PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
}
|
||||
addGroupTo(recycleBinGroup, rootGroup)
|
||||
recycleBinUUID = recycleBinGroup.id
|
||||
recycleBinGroup.lastModificationTime.date?.let {
|
||||
recycleBinChanged = it
|
||||
}
|
||||
recycleBinChanged = recycleBinGroup.lastModificationTime.date
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.element
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
import androidx.core.os.ConfigurationCompat
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
|
||||
import java.util.Arrays
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Converting from the C Date format to the Java data format is
|
||||
@@ -34,14 +32,14 @@ import java.util.Date
|
||||
*/
|
||||
class PwDate : Parcelable {
|
||||
|
||||
private var jDate: Date? = null
|
||||
private var jDate: Date = Date()
|
||||
private var jDateBuilt = false
|
||||
@Transient
|
||||
private var cDate: ByteArray? = null
|
||||
@Transient
|
||||
private var cDateBuilt = false
|
||||
|
||||
val date: Date?
|
||||
val date: Date
|
||||
get() {
|
||||
if (!jDateBuilt) {
|
||||
jDate = readTime(cDate, 0, calendar)
|
||||
@@ -68,9 +66,7 @@ class PwDate : Parcelable {
|
||||
}
|
||||
|
||||
constructor(source: PwDate) {
|
||||
if (source.jDate != null) {
|
||||
this.jDate = Date(source.jDate!!.time)
|
||||
}
|
||||
this.jDate = Date(source.jDate.time)
|
||||
this.jDateBuilt = source.jDateBuilt
|
||||
|
||||
if (source.cDate != null) {
|
||||
@@ -106,6 +102,10 @@ class PwDate : Parcelable {
|
||||
return 0
|
||||
}
|
||||
|
||||
fun getDateTimeString(resources: Resources): String {
|
||||
return Companion.getDateTimeString(resources, this.date)
|
||||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeSerializable(date)
|
||||
dest.writeByte((if (jDateBuilt) 1 else 0).toByte())
|
||||
@@ -135,7 +135,7 @@ class PwDate : Parcelable {
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = jDate?.hashCode() ?: 0
|
||||
var result = jDate.hashCode()
|
||||
result = 31 * result + jDateBuilt.hashCode()
|
||||
result = 31 * result + (cDate?.contentHashCode() ?: 0)
|
||||
result = 31 * result + cDateBuilt.hashCode()
|
||||
@@ -280,5 +280,13 @@ class PwDate : Parcelable {
|
||||
cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND)
|
||||
|
||||
}
|
||||
|
||||
fun getDateTimeString(resources: Resources, date: Date): String {
|
||||
return java.text.DateFormat.getDateTimeInstance(
|
||||
java.text.DateFormat.MEDIUM,
|
||||
java.text.DateFormat.MEDIUM,
|
||||
ConfigurationCompat.getLocales(resources.configuration)[0])
|
||||
.format(date)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ class PwEntryV4 : PwEntry<PwGroupV4, PwEntryV4>, PwNodeV4Interface {
|
||||
for (i in history.indices) {
|
||||
val entry = history[i]
|
||||
val lastMod = entry.lastModificationTime.date
|
||||
if (min == null || lastMod == null || lastMod.before(min)) {
|
||||
if (min == null || lastMod.before(min)) {
|
||||
index = i
|
||||
min = lastMod
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ abstract class PwNode<IdType, Parent : PwGroupInterface<Parent, Entry>, Entry :
|
||||
final override var isExpires: Boolean
|
||||
// If expireDate is before NEVER_EXPIRE date less 1 month (to be sure)
|
||||
get() = expiryTime.date
|
||||
?.before(LocalDate.fromDateFields(PwDate.NEVER_EXPIRE).minusMonths(1).toDate()) ?: true
|
||||
.before(LocalDate.fromDateFields(PwDate.NEVER_EXPIRE).minusMonths(1).toDate())
|
||||
set(value) {
|
||||
if (!value) {
|
||||
expiryTime = PwDate.PW_NEVER_EXPIRE
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.kunzisoft.keepass.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
@@ -29,13 +28,14 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.adapters.EntryHistoryAdapter
|
||||
import com.kunzisoft.keepass.database.element.EntryVersioned
|
||||
import com.kunzisoft.keepass.database.element.PwDate
|
||||
import com.kunzisoft.keepass.database.element.security.ProtectedString
|
||||
import java.text.DateFormat
|
||||
import java.util.*
|
||||
|
||||
class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
@@ -63,9 +63,6 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
private val extrasContainerView: View
|
||||
private val extrasView: ViewGroup
|
||||
|
||||
private val dateFormat: DateFormat = android.text.format.DateFormat.getDateFormat(context)
|
||||
private val timeFormat: DateFormat = android.text.format.DateFormat.getTimeFormat(context)
|
||||
|
||||
private val creationDateView: TextView
|
||||
private val modificationDateView: TextView
|
||||
private val lastAccessDateView: TextView
|
||||
@@ -243,24 +240,20 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
extrasContainerView.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun getDateTime(date: Date): String {
|
||||
return dateFormat.format(date) + " " + timeFormat.format(date)
|
||||
fun assignCreationDate(date: PwDate) {
|
||||
creationDateView.text = date.getDateTimeString(resources)
|
||||
}
|
||||
|
||||
fun assignCreationDate(date: Date) {
|
||||
creationDateView.text = getDateTime(date)
|
||||
fun assignModificationDate(date: PwDate) {
|
||||
modificationDateView.text = date.getDateTimeString(resources)
|
||||
}
|
||||
|
||||
fun assignModificationDate(date: Date) {
|
||||
modificationDateView.text = getDateTime(date)
|
||||
fun assignLastAccessDate(date: PwDate) {
|
||||
lastAccessDateView.text = date.getDateTimeString(resources)
|
||||
}
|
||||
|
||||
fun assignLastAccessDate(date: Date) {
|
||||
lastAccessDateView.text = getDateTime(date)
|
||||
}
|
||||
|
||||
fun assignExpiresDate(date: Date) {
|
||||
expiresDateView.text = getDateTime(date)
|
||||
fun assignExpiresDate(date: PwDate) {
|
||||
expiresDateView.text = date.getDateTimeString(resources)
|
||||
}
|
||||
|
||||
fun assignExpiresDate(constString: String) {
|
||||
|
||||
Reference in new issue
Block a user