diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2022-07-15 00:53:48 +0530 |
|---|---|---|
| committer | Harsh Shandilya <me@msfjarvis.dev> | 2022-07-15 01:13:47 +0530 |
| commit | 549ee790d3e52bc62565ddf92e6a556e98b5195e (patch) | |
| tree | d5758e5eb80093704e683c8da926838e18182588 /app/src/main/java/dev/msfjarvis/aps/data/password | |
| parent | 010c6e227c9cc27f4d01bc912311f977b2aeb3a7 (diff) | |
| download | HardenedPass-549ee790d3e52bc62565ddf92e6a556e98b5195e.tar.gz HardenedPass-549ee790d3e52bc62565ddf92e6a556e98b5195e.zip | |
all: re-do package structure yet again
Diffstat (limited to 'app/src/main/java/dev/msfjarvis/aps/data/password')
| -rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/data/password/FieldItem.kt | 43 | ||||
| -rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/data/password/PasswordItem.kt | 77 |
2 files changed, 0 insertions, 120 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/data/password/FieldItem.kt b/app/src/main/java/dev/msfjarvis/aps/data/password/FieldItem.kt deleted file mode 100644 index e7c88ef1..00000000 --- a/app/src/main/java/dev/msfjarvis/aps/data/password/FieldItem.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ - -package dev.msfjarvis.aps.data.password - -import dev.msfjarvis.aps.data.passfile.Totp -import kotlin.time.ExperimentalTime - -@OptIn(ExperimentalTime::class) -class FieldItem(val key: String, val value: String, val action: ActionType) { - enum class ActionType { - COPY, - HIDE - } - - enum class ItemType(val type: String, val label: String) { - USERNAME("Username", "Username"), - PASSWORD("Password", "Password"), - OTP("OTP", "OTP (expires in %ds)"), - } - - companion object { - - // Extra helper methods - fun createOtpField(totp: Totp): FieldItem { - return FieldItem( - ItemType.OTP.label.format(totp.remainingTime.inWholeSeconds), - totp.value, - ActionType.COPY, - ) - } - - fun createPasswordField(password: String): FieldItem { - return FieldItem(ItemType.PASSWORD.label, password, ActionType.HIDE) - } - - fun createUsernameField(username: String): FieldItem { - return FieldItem(ItemType.USERNAME.label, username, ActionType.COPY) - } - } -} diff --git a/app/src/main/java/dev/msfjarvis/aps/data/password/PasswordItem.kt b/app/src/main/java/dev/msfjarvis/aps/data/password/PasswordItem.kt deleted file mode 100644 index 82b0dc35..00000000 --- a/app/src/main/java/dev/msfjarvis/aps/data/password/PasswordItem.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ -package dev.msfjarvis.aps.data.password - -import android.content.Context -import android.content.Intent -import dev.msfjarvis.aps.data.repo.PasswordRepository -import dev.msfjarvis.aps.ui.crypto.BasePgpActivity -import dev.msfjarvis.aps.ui.main.LaunchActivity -import java.io.File - -data class PasswordItem( - val name: String, - val parent: PasswordItem? = null, - val type: Char, - val file: File, - val rootDir: File -) : Comparable<PasswordItem> { - - val fullPathToParent = file.absolutePath.replace(rootDir.absolutePath, "").replace(file.name, "") - - val longName = BasePgpActivity.getLongName(fullPathToParent, rootDir.absolutePath, toString()) - - override fun equals(other: Any?): Boolean { - return (other is PasswordItem) && (other.file == file) - } - - override fun compareTo(other: PasswordItem): Int { - return (type + name).compareTo(other.type + other.name, ignoreCase = true) - } - - override fun toString(): String { - return name.replace("\\.gpg$".toRegex(), "") - } - - override fun hashCode(): Int { - return 0 - } - - /** Creates an [Intent] to launch this [PasswordItem] through the authentication process. */ - fun createAuthEnabledIntent(context: Context): Intent { - val intent = Intent(context, LaunchActivity::class.java) - intent.putExtra("NAME", toString()) - intent.putExtra("FILE_PATH", file.absolutePath) - intent.putExtra("REPO_PATH", PasswordRepository.getRepositoryDirectory().absolutePath) - intent.action = LaunchActivity.ACTION_DECRYPT_PASS - return intent - } - - companion object { - - const val TYPE_CATEGORY = 'c' - const val TYPE_PASSWORD = 'p' - - @JvmStatic - fun newCategory(name: String, file: File, parent: PasswordItem, rootDir: File): PasswordItem { - return PasswordItem(name, parent, TYPE_CATEGORY, file, rootDir) - } - - @JvmStatic - fun newCategory(name: String, file: File, rootDir: File): PasswordItem { - return PasswordItem(name, null, TYPE_CATEGORY, file, rootDir) - } - - @JvmStatic - fun newPassword(name: String, file: File, parent: PasswordItem, rootDir: File): PasswordItem { - return PasswordItem(name, parent, TYPE_PASSWORD, file, rootDir) - } - - @JvmStatic - fun newPassword(name: String, file: File, rootDir: File): PasswordItem { - return PasswordItem(name, null, TYPE_PASSWORD, file, rootDir) - } - } -} |
