mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-05 05:47:36 +03:00
fix: Remove AndroidX dependency and format code
This commit is contained in:
parent
e1ecebb4a0
commit
81930bf3a1
12 changed files with 88 additions and 69 deletions
|
@ -35,6 +35,7 @@ import com.kunzisoft.keepass.database.ContextualDatabase
|
||||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||||
import com.kunzisoft.keepass.model.GroupInfo
|
import com.kunzisoft.keepass.model.GroupInfo
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
|
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||||
import com.kunzisoft.keepass.utils.UuidUtil
|
import com.kunzisoft.keepass.utils.UuidUtil
|
||||||
import com.kunzisoft.keepass.view.DateTimeFieldView
|
import com.kunzisoft.keepass.view.DateTimeFieldView
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import com.kunzisoft.keepass.model.EntryInfo
|
||||||
import com.kunzisoft.keepass.model.StreamDirection
|
import com.kunzisoft.keepass.model.StreamDirection
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
import com.kunzisoft.keepass.timeout.ClipboardHelper
|
import com.kunzisoft.keepass.timeout.ClipboardHelper
|
||||||
|
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||||
import com.kunzisoft.keepass.utils.UuidUtil
|
import com.kunzisoft.keepass.utils.UuidUtil
|
||||||
import com.kunzisoft.keepass.view.TemplateView
|
import com.kunzisoft.keepass.view.TemplateView
|
||||||
import com.kunzisoft.keepass.view.hideByFading
|
import com.kunzisoft.keepass.view.hideByFading
|
||||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
import com.kunzisoft.keepass.model.EntryInfo
|
import com.kunzisoft.keepass.model.EntryInfo
|
||||||
|
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||||
|
|
||||||
class EntryHistoryAdapter(val context: Context) : RecyclerView.Adapter<EntryHistoryAdapter.EntryHistoryViewHolder>() {
|
class EntryHistoryAdapter(val context: Context) : RecyclerView.Adapter<EntryHistoryAdapter.EntryHistoryViewHolder>() {
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ import com.kunzisoft.keepass.database.element.node.Node
|
||||||
import com.kunzisoft.keepass.database.element.node.NodeId
|
import com.kunzisoft.keepass.database.element.node.NodeId
|
||||||
import com.kunzisoft.keepass.database.element.node.Type
|
import com.kunzisoft.keepass.database.element.node.Type
|
||||||
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
||||||
import com.kunzisoft.keepass.model.ProgressMessage
|
|
||||||
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
||||||
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
|
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
|
||||||
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService.Companion.ACTION_CHALLENGE_RESPONDED
|
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService.Companion.ACTION_CHALLENGE_RESPONDED
|
||||||
|
@ -135,26 +134,34 @@ class DatabaseTaskProvider(private var context: Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
private val actionTaskListener = object: DatabaseTaskNotificationService.ActionTaskListener {
|
private val actionTaskListener = object: DatabaseTaskNotificationService.ActionTaskListener {
|
||||||
override fun onActionStarted(database: ContextualDatabase,
|
override fun onActionStarted(
|
||||||
progressMessage: ProgressMessage) {
|
database: ContextualDatabase,
|
||||||
|
progressMessage: ProgressMessage
|
||||||
|
) {
|
||||||
if (showDialog)
|
if (showDialog)
|
||||||
startDialog(progressMessage)
|
startDialog(progressMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionUpdated(database: ContextualDatabase,
|
override fun onActionUpdated(
|
||||||
progressMessage: ProgressMessage) {
|
database: ContextualDatabase,
|
||||||
|
progressMessage: ProgressMessage
|
||||||
|
) {
|
||||||
if (showDialog)
|
if (showDialog)
|
||||||
updateDialog(progressMessage)
|
updateDialog(progressMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionStopped(database: ContextualDatabase) {
|
override fun onActionStopped(
|
||||||
|
database: ContextualDatabase
|
||||||
|
) {
|
||||||
// Remove the progress task
|
// Remove the progress task
|
||||||
stopDialog()
|
stopDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionFinished(database: ContextualDatabase,
|
override fun onActionFinished(
|
||||||
|
database: ContextualDatabase,
|
||||||
actionTask: String,
|
actionTask: String,
|
||||||
result: ActionRunnable.Result) {
|
result: ActionRunnable.Result
|
||||||
|
) {
|
||||||
onActionFinish?.invoke(database, actionTask, result)
|
onActionFinish?.invoke(database, actionTask, result)
|
||||||
onActionStopped(database)
|
onActionStopped(database)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.kunzisoft.keepass.model
|
package com.kunzisoft.keepass.database.action
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
|
|
@ -47,7 +47,6 @@ import com.kunzisoft.keepass.database.element.node.Type
|
||||||
import com.kunzisoft.keepass.hardware.HardwareKey
|
import com.kunzisoft.keepass.hardware.HardwareKey
|
||||||
import com.kunzisoft.keepass.hardware.HardwareKeyActivity
|
import com.kunzisoft.keepass.hardware.HardwareKeyActivity
|
||||||
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
||||||
import com.kunzisoft.keepass.model.ProgressMessage
|
|
||||||
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
||||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||||
|
@ -138,14 +137,22 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ActionTaskListener {
|
interface ActionTaskListener {
|
||||||
fun onActionStarted(database: ContextualDatabase,
|
fun onActionStarted(
|
||||||
progressMessage: ProgressMessage)
|
database: ContextualDatabase,
|
||||||
fun onActionUpdated(database: ContextualDatabase,
|
progressMessage: ProgressMessage
|
||||||
progressMessage: ProgressMessage)
|
)
|
||||||
fun onActionStopped(database: ContextualDatabase)
|
fun onActionUpdated(
|
||||||
fun onActionFinished(database: ContextualDatabase,
|
database: ContextualDatabase,
|
||||||
|
progressMessage: ProgressMessage
|
||||||
|
)
|
||||||
|
fun onActionStopped(
|
||||||
|
database: ContextualDatabase
|
||||||
|
)
|
||||||
|
fun onActionFinished(
|
||||||
|
database: ContextualDatabase,
|
||||||
actionTask: String,
|
actionTask: String,
|
||||||
result: ActionRunnable.Result)
|
result: ActionRunnable.Result
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkDatabase() {
|
fun checkDatabase() {
|
||||||
|
@ -306,31 +313,18 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
||||||
ACTION_DATABASE_LOAD_TASK -> buildDatabaseLoadActionTask(intent, database)
|
ACTION_DATABASE_LOAD_TASK -> buildDatabaseLoadActionTask(intent, database)
|
||||||
ACTION_DATABASE_MERGE_TASK -> buildDatabaseMergeActionTask(intent, database)
|
ACTION_DATABASE_MERGE_TASK -> buildDatabaseMergeActionTask(intent, database)
|
||||||
ACTION_DATABASE_RELOAD_TASK -> buildDatabaseReloadActionTask(database)
|
ACTION_DATABASE_RELOAD_TASK -> buildDatabaseReloadActionTask(database)
|
||||||
ACTION_DATABASE_ASSIGN_PASSWORD_TASK -> buildDatabaseAssignPasswordActionTask(intent,
|
ACTION_DATABASE_ASSIGN_PASSWORD_TASK -> buildDatabaseAssignPasswordActionTask(intent, database)
|
||||||
database)
|
ACTION_DATABASE_CREATE_GROUP_TASK -> buildDatabaseCreateGroupActionTask(intent, database)
|
||||||
ACTION_DATABASE_CREATE_GROUP_TASK -> buildDatabaseCreateGroupActionTask(intent,
|
ACTION_DATABASE_UPDATE_GROUP_TASK -> buildDatabaseUpdateGroupActionTask(intent, database)
|
||||||
database)
|
ACTION_DATABASE_CREATE_ENTRY_TASK -> buildDatabaseCreateEntryActionTask(intent, database)
|
||||||
ACTION_DATABASE_UPDATE_GROUP_TASK -> buildDatabaseUpdateGroupActionTask(intent,
|
ACTION_DATABASE_UPDATE_ENTRY_TASK -> buildDatabaseUpdateEntryActionTask(intent, database)
|
||||||
database)
|
|
||||||
ACTION_DATABASE_CREATE_ENTRY_TASK -> buildDatabaseCreateEntryActionTask(intent,
|
|
||||||
database)
|
|
||||||
ACTION_DATABASE_UPDATE_ENTRY_TASK -> buildDatabaseUpdateEntryActionTask(intent,
|
|
||||||
database)
|
|
||||||
ACTION_DATABASE_COPY_NODES_TASK -> buildDatabaseCopyNodesActionTask(intent, database)
|
ACTION_DATABASE_COPY_NODES_TASK -> buildDatabaseCopyNodesActionTask(intent, database)
|
||||||
ACTION_DATABASE_MOVE_NODES_TASK -> buildDatabaseMoveNodesActionTask(intent, database)
|
ACTION_DATABASE_MOVE_NODES_TASK -> buildDatabaseMoveNodesActionTask(intent, database)
|
||||||
ACTION_DATABASE_DELETE_NODES_TASK -> buildDatabaseDeleteNodesActionTask(intent,
|
ACTION_DATABASE_DELETE_NODES_TASK -> buildDatabaseDeleteNodesActionTask(intent, database)
|
||||||
database)
|
ACTION_DATABASE_RESTORE_ENTRY_HISTORY -> buildDatabaseRestoreEntryHistoryActionTask(intent, database)
|
||||||
ACTION_DATABASE_RESTORE_ENTRY_HISTORY -> buildDatabaseRestoreEntryHistoryActionTask(
|
ACTION_DATABASE_DELETE_ENTRY_HISTORY -> buildDatabaseDeleteEntryHistoryActionTask(intent, database)
|
||||||
intent,
|
ACTION_DATABASE_UPDATE_COMPRESSION_TASK -> buildDatabaseUpdateCompressionActionTask(intent, database)
|
||||||
database)
|
ACTION_DATABASE_REMOVE_UNLINKED_DATA_TASK -> buildDatabaseRemoveUnlinkedDataActionTask(intent, database)
|
||||||
ACTION_DATABASE_DELETE_ENTRY_HISTORY -> buildDatabaseDeleteEntryHistoryActionTask(intent,
|
|
||||||
database)
|
|
||||||
ACTION_DATABASE_UPDATE_COMPRESSION_TASK -> buildDatabaseUpdateCompressionActionTask(
|
|
||||||
intent,
|
|
||||||
database)
|
|
||||||
ACTION_DATABASE_REMOVE_UNLINKED_DATA_TASK -> buildDatabaseRemoveUnlinkedDataActionTask(
|
|
||||||
intent,
|
|
||||||
database)
|
|
||||||
ACTION_DATABASE_UPDATE_NAME_TASK,
|
ACTION_DATABASE_UPDATE_NAME_TASK,
|
||||||
ACTION_DATABASE_UPDATE_DESCRIPTION_TASK,
|
ACTION_DATABASE_UPDATE_DESCRIPTION_TASK,
|
||||||
ACTION_DATABASE_UPDATE_DEFAULT_USERNAME_TASK,
|
ACTION_DATABASE_UPDATE_DEFAULT_USERNAME_TASK,
|
||||||
|
|
29
app/src/main/java/com/kunzisoft/keepass/utils/TimeUtil.kt
Normal file
29
app/src/main/java/com/kunzisoft/keepass/utils/TimeUtil.kt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package com.kunzisoft.keepass.utils
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import androidx.core.os.ConfigurationCompat
|
||||||
|
import com.kunzisoft.keepass.database.element.DateInstant
|
||||||
|
import java.text.DateFormat
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
object TimeUtil {
|
||||||
|
|
||||||
|
fun DateInstant.getDateTimeString(resources: Resources): String {
|
||||||
|
val locale = ConfigurationCompat.getLocales(resources.configuration)[0] ?: Locale.ROOT
|
||||||
|
return when (type) {
|
||||||
|
DateInstant.Type.DATE -> DateFormat.getDateInstance(
|
||||||
|
DateFormat.MEDIUM,
|
||||||
|
locale)
|
||||||
|
.format(date)
|
||||||
|
DateInstant.Type.TIME -> DateFormat.getTimeInstance(
|
||||||
|
DateFormat.SHORT,
|
||||||
|
locale)
|
||||||
|
.format(date)
|
||||||
|
else -> DateFormat.getDateTimeInstance(
|
||||||
|
DateFormat.MEDIUM,
|
||||||
|
DateFormat.SHORT,
|
||||||
|
locale)
|
||||||
|
.format(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import androidx.core.view.isVisible
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
import com.kunzisoft.keepass.database.element.DateInstant
|
import com.kunzisoft.keepass.database.element.DateInstant
|
||||||
|
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||||
|
|
||||||
class DateTimeEditFieldView @JvmOverloads constructor(context: Context,
|
class DateTimeEditFieldView @JvmOverloads constructor(context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
|
|
|
@ -31,6 +31,7 @@ import android.widget.TextView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
import com.kunzisoft.keepass.database.element.DateInstant
|
import com.kunzisoft.keepass.database.element.DateInstant
|
||||||
|
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||||
|
|
||||||
class DateTimeFieldView @JvmOverloads constructor(context: Context,
|
class DateTimeFieldView @JvmOverloads constructor(context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
|
|
|
@ -32,7 +32,6 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "androidx.core:core-ktx:$android_core_version"
|
|
||||||
// Time
|
// Time
|
||||||
implementation 'joda-time:joda-time:2.10.13'
|
implementation 'joda-time:joda-time:2.10.13'
|
||||||
// Apache Commons
|
// Apache Commons
|
||||||
|
|
|
@ -19,16 +19,20 @@
|
||||||
*/
|
*/
|
||||||
package com.kunzisoft.keepass.database.element
|
package com.kunzisoft.keepass.database.element
|
||||||
|
|
||||||
import android.content.res.Resources
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import androidx.core.os.ConfigurationCompat
|
|
||||||
import com.kunzisoft.keepass.utils.readEnum
|
import com.kunzisoft.keepass.utils.readEnum
|
||||||
import com.kunzisoft.keepass.utils.writeEnum
|
import com.kunzisoft.keepass.utils.writeEnum
|
||||||
import org.joda.time.*
|
import org.joda.time.Duration
|
||||||
import java.text.DateFormat
|
import org.joda.time.Instant
|
||||||
|
import org.joda.time.LocalDate
|
||||||
|
import org.joda.time.LocalDateTime
|
||||||
|
import org.joda.time.LocalTime
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
import java.util.TimeZone
|
||||||
|
|
||||||
class DateInstant : Parcelable {
|
class DateInstant : Parcelable {
|
||||||
|
|
||||||
|
@ -122,25 +126,6 @@ class DateInstant : Parcelable {
|
||||||
dest.writeEnum(mType)
|
dest.writeEnum(mType)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDateTimeString(resources: Resources): String {
|
|
||||||
val locale = ConfigurationCompat.getLocales(resources.configuration)[0] ?: Locale.ROOT
|
|
||||||
return when (mType) {
|
|
||||||
Type.DATE -> DateFormat.getDateInstance(
|
|
||||||
DateFormat.MEDIUM,
|
|
||||||
locale)
|
|
||||||
.format(jDate)
|
|
||||||
Type.TIME -> DateFormat.getTimeInstance(
|
|
||||||
DateFormat.SHORT,
|
|
||||||
locale)
|
|
||||||
.format(jDate)
|
|
||||||
else -> DateFormat.getDateTimeInstance(
|
|
||||||
DateFormat.MEDIUM,
|
|
||||||
DateFormat.SHORT,
|
|
||||||
locale)
|
|
||||||
.format(jDate)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getYearInt(): Int {
|
fun getYearInt(): Int {
|
||||||
val dateFormat = SimpleDateFormat("yyyy", Locale.ENGLISH)
|
val dateFormat = SimpleDateFormat("yyyy", Locale.ENGLISH)
|
||||||
return dateFormat.format(date).toInt()
|
return dateFormat.format(date).toInt()
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
*/
|
*/
|
||||||
package com.kunzisoft.keepass.utils;
|
package com.kunzisoft.keepass.utils;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.kunzisoft.keepass.utils.StreamBytesUtilsKt.uuidTo16Bytes;
|
import static com.kunzisoft.keepass.utils.StreamBytesUtilsKt.uuidTo16Bytes;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class UuidUtil {
|
public class UuidUtil {
|
||||||
|
|
||||||
public static @Nullable String toHexString(@Nullable UUID uuid) {
|
public static @Nullable String toHexString(@Nullable UUID uuid) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue