mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-04 21:37:37 +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.model.GroupInfo
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
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.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.timeout.ClipboardHelper
|
||||
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
import com.kunzisoft.keepass.view.TemplateView
|
||||
import com.kunzisoft.keepass.view.hideByFading
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.TextView
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||
|
||||
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.Type
|
||||
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
||||
import com.kunzisoft.keepass.model.ProgressMessage
|
||||
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
||||
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
|
||||
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 {
|
||||
override fun onActionStarted(database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage) {
|
||||
override fun onActionStarted(
|
||||
database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage
|
||||
) {
|
||||
if (showDialog)
|
||||
startDialog(progressMessage)
|
||||
}
|
||||
|
||||
override fun onActionUpdated(database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage) {
|
||||
override fun onActionUpdated(
|
||||
database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage
|
||||
) {
|
||||
if (showDialog)
|
||||
updateDialog(progressMessage)
|
||||
}
|
||||
|
||||
override fun onActionStopped(database: ContextualDatabase) {
|
||||
override fun onActionStopped(
|
||||
database: ContextualDatabase
|
||||
) {
|
||||
// Remove the progress task
|
||||
stopDialog()
|
||||
}
|
||||
|
||||
override fun onActionFinished(database: ContextualDatabase,
|
||||
actionTask: String,
|
||||
result: ActionRunnable.Result) {
|
||||
override fun onActionFinished(
|
||||
database: ContextualDatabase,
|
||||
actionTask: String,
|
||||
result: ActionRunnable.Result
|
||||
) {
|
||||
onActionFinish?.invoke(database, actionTask, result)
|
||||
onActionStopped(database)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.kunzisoft.keepass.model
|
||||
package com.kunzisoft.keepass.database.action
|
||||
|
||||
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.HardwareKeyActivity
|
||||
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
||||
import com.kunzisoft.keepass.model.ProgressMessage
|
||||
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||
|
@ -138,14 +137,22 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||
}
|
||||
|
||||
interface ActionTaskListener {
|
||||
fun onActionStarted(database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage)
|
||||
fun onActionUpdated(database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage)
|
||||
fun onActionStopped(database: ContextualDatabase)
|
||||
fun onActionFinished(database: ContextualDatabase,
|
||||
actionTask: String,
|
||||
result: ActionRunnable.Result)
|
||||
fun onActionStarted(
|
||||
database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage
|
||||
)
|
||||
fun onActionUpdated(
|
||||
database: ContextualDatabase,
|
||||
progressMessage: ProgressMessage
|
||||
)
|
||||
fun onActionStopped(
|
||||
database: ContextualDatabase
|
||||
)
|
||||
fun onActionFinished(
|
||||
database: ContextualDatabase,
|
||||
actionTask: String,
|
||||
result: ActionRunnable.Result
|
||||
)
|
||||
}
|
||||
|
||||
fun checkDatabase() {
|
||||
|
@ -306,31 +313,18 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||
ACTION_DATABASE_LOAD_TASK -> buildDatabaseLoadActionTask(intent, database)
|
||||
ACTION_DATABASE_MERGE_TASK -> buildDatabaseMergeActionTask(intent, database)
|
||||
ACTION_DATABASE_RELOAD_TASK -> buildDatabaseReloadActionTask(database)
|
||||
ACTION_DATABASE_ASSIGN_PASSWORD_TASK -> buildDatabaseAssignPasswordActionTask(intent,
|
||||
database)
|
||||
ACTION_DATABASE_CREATE_GROUP_TASK -> buildDatabaseCreateGroupActionTask(intent,
|
||||
database)
|
||||
ACTION_DATABASE_UPDATE_GROUP_TASK -> buildDatabaseUpdateGroupActionTask(intent,
|
||||
database)
|
||||
ACTION_DATABASE_CREATE_ENTRY_TASK -> buildDatabaseCreateEntryActionTask(intent,
|
||||
database)
|
||||
ACTION_DATABASE_UPDATE_ENTRY_TASK -> buildDatabaseUpdateEntryActionTask(intent,
|
||||
database)
|
||||
ACTION_DATABASE_ASSIGN_PASSWORD_TASK -> buildDatabaseAssignPasswordActionTask(intent, database)
|
||||
ACTION_DATABASE_CREATE_GROUP_TASK -> buildDatabaseCreateGroupActionTask(intent, database)
|
||||
ACTION_DATABASE_UPDATE_GROUP_TASK -> buildDatabaseUpdateGroupActionTask(intent, 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_MOVE_NODES_TASK -> buildDatabaseMoveNodesActionTask(intent, database)
|
||||
ACTION_DATABASE_DELETE_NODES_TASK -> buildDatabaseDeleteNodesActionTask(intent,
|
||||
database)
|
||||
ACTION_DATABASE_RESTORE_ENTRY_HISTORY -> buildDatabaseRestoreEntryHistoryActionTask(
|
||||
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_DELETE_NODES_TASK -> buildDatabaseDeleteNodesActionTask(intent, database)
|
||||
ACTION_DATABASE_RESTORE_ENTRY_HISTORY -> buildDatabaseRestoreEntryHistoryActionTask(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_DESCRIPTION_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.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||
|
||||
class DateTimeEditFieldView @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.widget.TextView
|
|||
import androidx.core.view.isVisible
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.DateInstant
|
||||
import com.kunzisoft.keepass.utils.TimeUtil.getDateTimeString
|
||||
|
||||
class DateTimeFieldView @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
|
|
|
@ -32,7 +32,6 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation "androidx.core:core-ktx:$android_core_version"
|
||||
// Time
|
||||
implementation 'joda-time:joda-time:2.10.13'
|
||||
// Apache Commons
|
||||
|
|
|
@ -19,16 +19,20 @@
|
|||
*/
|
||||
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.readEnum
|
||||
import com.kunzisoft.keepass.utils.writeEnum
|
||||
import org.joda.time.*
|
||||
import java.text.DateFormat
|
||||
import org.joda.time.Duration
|
||||
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.util.*
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class DateInstant : Parcelable {
|
||||
|
||||
|
@ -122,25 +126,6 @@ class DateInstant : Parcelable {
|
|||
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 {
|
||||
val dateFormat = SimpleDateFormat("yyyy", Locale.ENGLISH)
|
||||
return dateFormat.format(date).toInt()
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
*/
|
||||
package com.kunzisoft.keepass.utils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.kunzisoft.keepass.utils.StreamBytesUtilsKt.uuidTo16Bytes;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class UuidUtil {
|
||||
|
||||
public static @Nullable String toHexString(@Nullable UUID uuid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue