mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change datetime expiration view
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
package com.kunzisoft.keepass.view
|
||||
|
||||
import android.content.Context
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.style.StrikethroughSpan
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
@@ -54,14 +57,28 @@ class DateTimeFieldView @JvmOverloads constructor(context: Context,
|
||||
}
|
||||
|
||||
private fun assignExpiresDateText() {
|
||||
val isExpires = mDateTime.date.before(Date())
|
||||
|
||||
// Show or not the warning icon
|
||||
expiresImage.isVisible = if (mActivated) {
|
||||
mDateTime.date.before(Date())
|
||||
isExpires
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
// Build the datetime string
|
||||
dateTimeValueView.text = if (mActivated) {
|
||||
mDateTime.getDateTimeString(resources)
|
||||
val dateTimeString = mDateTime.getDateTimeString(resources)
|
||||
if (isExpires) {
|
||||
// Add strike
|
||||
SpannableString(dateTimeString).apply {
|
||||
setSpan(StrikethroughSpan(),
|
||||
0, dateTimeString.length-1,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
} else {
|
||||
dateTimeString
|
||||
}
|
||||
} else {
|
||||
resources.getString(R.string.never)
|
||||
}
|
||||
|
||||
7
app/src/main/res/drawable/ic_warning_white_24dp.xml
Normal file
7
app/src/main/res/drawable/ic_warning_white_24dp.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24"
|
||||
android:width="24dp">
|
||||
<path android:fillColor="#ffffff" android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
|
||||
</vector>
|
||||
@@ -18,9 +18,9 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_info_white_24dp"
|
||||
android:src="@drawable/ic_warning_white_24dp"
|
||||
android:contentDescription="@string/content_description_file_information"
|
||||
android:tint="@color/red"/>
|
||||
android:tint="?android:attr/textColor"/>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/date_time_value"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user