mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Remove unused credit card fragment
This commit is contained in:
@@ -85,7 +85,6 @@ import kotlin.collections.ArrayList
|
|||||||
class EntryEditActivity : LockingActivity(),
|
class EntryEditActivity : LockingActivity(),
|
||||||
EntryCustomFieldDialogFragment.EntryCustomFieldListener,
|
EntryCustomFieldDialogFragment.EntryCustomFieldListener,
|
||||||
GeneratePasswordDialogFragment.GeneratePasswordListener,
|
GeneratePasswordDialogFragment.GeneratePasswordListener,
|
||||||
CreditCardDetailsDialogFragment.EntryCCFieldListener,
|
|
||||||
SetOTPDialogFragment.CreateOtpListener,
|
SetOTPDialogFragment.CreateOtpListener,
|
||||||
DatePickerDialog.OnDateSetListener,
|
DatePickerDialog.OnDateSetListener,
|
||||||
TimePickerDialog.OnTimeSetListener,
|
TimePickerDialog.OnTimeSetListener,
|
||||||
@@ -435,29 +434,6 @@ class EntryEditActivity : LockingActivity(),
|
|||||||
GeneratePasswordDialogFragment().show(supportFragmentManager, "PasswordGeneratorFragment")
|
GeneratePasswordDialogFragment().show(supportFragmentManager, "PasswordGeneratorFragment")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addNewCreditCard() {
|
|
||||||
var cardholder: String? = null
|
|
||||||
var number: String? = null
|
|
||||||
var expiration: String? = null
|
|
||||||
var cvv: String? = null
|
|
||||||
|
|
||||||
entryEditFragment?.getCustomFields()?.forEach { field ->
|
|
||||||
when (field.name) {
|
|
||||||
TemplatesCustomFields.CC_CARDHOLDER_FIELD_NAME ->
|
|
||||||
cardholder = field.protectedValue.stringValue
|
|
||||||
TemplatesCustomFields.CC_NUMBER_FIELD_NAME ->
|
|
||||||
number = field.protectedValue.stringValue
|
|
||||||
TemplatesCustomFields.CC_EXP_FIELD_NAME ->
|
|
||||||
expiration = field.protectedValue.stringValue
|
|
||||||
TemplatesCustomFields.CC_CVV_FIELD_NAME ->
|
|
||||||
cvv = field.protectedValue.stringValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val cc = CreditCard(cardholder, number, expiration, cvv)
|
|
||||||
CreditCardDetailsDialogFragment.build(cc).show(supportFragmentManager, "CreditCardDialog")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new customized field
|
* Add a new customized field
|
||||||
*/
|
*/
|
||||||
@@ -490,10 +466,6 @@ class EntryEditActivity : LockingActivity(),
|
|||||||
entryEditFragment?.removeCustomField(oldField)
|
entryEditFragment?.removeCustomField(oldField)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewCCFieldsApproved(ccFields: ArrayList<Field>) {
|
|
||||||
// TODO Remove
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new attachment
|
* Add a new attachment
|
||||||
*/
|
*/
|
||||||
@@ -655,11 +627,6 @@ class EntryEditActivity : LockingActivity(),
|
|||||||
isVisible = allowCustomField
|
isVisible = allowCustomField
|
||||||
}
|
}
|
||||||
|
|
||||||
menu?.findItem(R.id.menu_add_credit_card)?.apply {
|
|
||||||
isEnabled = allowCustomField
|
|
||||||
isVisible = allowCustomField
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attachment not compatible below KitKat
|
// Attachment not compatible below KitKat
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||||
menu?.findItem(R.id.menu_add_attachment)?.isVisible = false
|
menu?.findItem(R.id.menu_add_attachment)?.isVisible = false
|
||||||
@@ -727,10 +694,6 @@ class EntryEditActivity : LockingActivity(),
|
|||||||
addNewCustomField()
|
addNewCustomField()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.menu_add_credit_card -> {
|
|
||||||
addNewCreditCard()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
R.id.menu_add_attachment -> {
|
R.id.menu_add_attachment -> {
|
||||||
addNewAttachment()
|
addNewAttachment()
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
package com.kunzisoft.keepass.activities.dialogs
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.WindowManager
|
|
||||||
import android.widget.ArrayAdapter
|
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.Spinner
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import com.kunzisoft.keepass.R
|
|
||||||
import com.kunzisoft.keepass.model.CreditCard
|
|
||||||
import com.kunzisoft.keepass.model.TemplatesCustomFields.buildAllFields
|
|
||||||
import com.kunzisoft.keepass.model.Field
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class CreditCardDetailsDialogFragment : DialogFragment() {
|
|
||||||
private var mCreditCard: CreditCard? = null
|
|
||||||
private var entryCCFieldListener: EntryCCFieldListener? = null
|
|
||||||
|
|
||||||
private var mCcCardholderName: EditText? = null
|
|
||||||
private var mCcCardNumber: EditText? = null
|
|
||||||
private var mCcSecurityCode: EditText? = null
|
|
||||||
|
|
||||||
private var mCcExpirationMonthSpinner: Spinner? = null
|
|
||||||
private var mCcExpirationYearSpinner: Spinner? = null
|
|
||||||
|
|
||||||
private var mPositiveButton: Button? = null
|
|
||||||
|
|
||||||
override fun onAttach(context: Context) {
|
|
||||||
super.onAttach(context)
|
|
||||||
try {
|
|
||||||
entryCCFieldListener = context as EntryCCFieldListener
|
|
||||||
} catch (e: ClassCastException) {
|
|
||||||
// The activity doesn't implement the interface, throw exception
|
|
||||||
throw ClassCastException(context.toString()
|
|
||||||
+ " must implement " + EntryCCFieldListener::class.java.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetach() {
|
|
||||||
entryCCFieldListener = null
|
|
||||||
super.onDetach()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
|
|
||||||
// To prevent auto dismiss
|
|
||||||
val d = dialog as AlertDialog?
|
|
||||||
if (d != null) {
|
|
||||||
mPositiveButton = d.getButton(Dialog.BUTTON_POSITIVE) as Button
|
|
||||||
mPositiveButton?.run {
|
|
||||||
setOnClickListener {
|
|
||||||
submitDialog()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
|
||||||
super.onSaveInstanceState(outState)
|
|
||||||
outState.putParcelable(KEY_CREDIT_CARD, mCreditCard)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun submitDialog() {
|
|
||||||
val ccNumber = mCcCardNumber?.text?.toString() ?: ""
|
|
||||||
|
|
||||||
val month = mCcExpirationMonthSpinner?.selectedItem?.toString() ?: ""
|
|
||||||
val year = mCcExpirationYearSpinner?.selectedItem?.toString()?.substring(2,4) ?: ""
|
|
||||||
|
|
||||||
val cvv = mCcSecurityCode?.text?.toString() ?: ""
|
|
||||||
val ccName = mCcCardholderName?.text?.toString() ?: ""
|
|
||||||
|
|
||||||
entryCCFieldListener?.onNewCCFieldsApproved(buildAllFields(ccName, ccNumber, month + year, cvv))
|
|
||||||
|
|
||||||
(dialog as AlertDialog?)?.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EntryCCFieldListener {
|
|
||||||
fun onNewCCFieldsApproved(ccFields: ArrayList<Field>)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
// Retrieve credit card details if available
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
if (savedInstanceState.containsKey(KEY_CREDIT_CARD)) {
|
|
||||||
mCreditCard = savedInstanceState.getParcelable(KEY_CREDIT_CARD)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
arguments?.apply {
|
|
||||||
if (containsKey(KEY_CREDIT_CARD)) {
|
|
||||||
mCreditCard = getParcelable(KEY_CREDIT_CARD)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activity?.let { activity ->
|
|
||||||
val root = activity.layoutInflater.inflate(R.layout.entry_cc_details_dialog, null)
|
|
||||||
|
|
||||||
root?.run {
|
|
||||||
mCcCardholderName = findViewById(R.id.creditCardholderNameField)
|
|
||||||
mCcCardNumber = findViewById(R.id.creditCardNumberField)
|
|
||||||
mCcSecurityCode = findViewById(R.id.creditCardSecurityCode)
|
|
||||||
mCcExpirationMonthSpinner = findViewById(R.id.expirationMonth)
|
|
||||||
mCcExpirationYearSpinner = findViewById(R.id.expirationYear)
|
|
||||||
|
|
||||||
mCreditCard?.cardholder?.let {
|
|
||||||
mCcCardholderName?.setText(it)
|
|
||||||
}
|
|
||||||
mCreditCard?.number?.let {
|
|
||||||
mCcCardNumber?.setText(it)
|
|
||||||
}
|
|
||||||
mCreditCard?.cvv?.let {
|
|
||||||
mCcSecurityCode?.setText(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val months = arrayOf("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12")
|
|
||||||
mCcExpirationMonthSpinner?.let { spinner ->
|
|
||||||
spinner.adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, months)
|
|
||||||
mCreditCard?.let { cc ->
|
|
||||||
spinner.setSelection(getIndex(spinner, cc.getExpirationMonth()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val years = arrayOfNulls<String>(5)
|
|
||||||
val year = Calendar.getInstance()[Calendar.YEAR]
|
|
||||||
for (i in years.indices) {
|
|
||||||
years[i] = (year + i).toString()
|
|
||||||
}
|
|
||||||
mCcExpirationYearSpinner?.let { spinner ->
|
|
||||||
spinner.adapter = ArrayAdapter<String>(requireContext(), android.R.layout.simple_spinner_item, years)
|
|
||||||
mCreditCard?.let { cc ->
|
|
||||||
spinner.setSelection(getIndex(spinner, "20" + cc.getExpirationYear()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(activity)
|
|
||||||
|
|
||||||
builder.setView(root).setTitle(R.string.entry_setup_credit_card)
|
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
|
||||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
|
||||||
|
|
||||||
val dialogCreated = builder.create()
|
|
||||||
|
|
||||||
dialogCreated.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
|
|
||||||
|
|
||||||
return dialogCreated
|
|
||||||
}
|
|
||||||
return super.onCreateDialog(savedInstanceState)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getIndex(spinner: Spinner, value: String?): Int {
|
|
||||||
for (i in 0 until spinner.count) {
|
|
||||||
if (spinner.getItemAtPosition(i).toString() == value) {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val KEY_CREDIT_CARD = "KEY_CREDIT_CARD"
|
|
||||||
|
|
||||||
fun build(creditCard: CreditCard? = null): CreditCardDetailsDialogFragment {
|
|
||||||
return CreditCardDetailsDialogFragment().apply {
|
|
||||||
if (creditCard != null) {
|
|
||||||
arguments = Bundle().apply {
|
|
||||||
putParcelable(KEY_CREDIT_CARD, creditCard)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#ffffff"
|
|
||||||
android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18v-6h16v6zM20,8L4,8L4,6h16v2z"/>
|
|
||||||
</vector>
|
|
||||||
@@ -33,12 +33,6 @@
|
|||||||
android:orderInCategory="93"
|
android:orderInCategory="93"
|
||||||
app:iconTint="?attr/colorControlNormal"
|
app:iconTint="?attr/colorControlNormal"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
<item android:id="@+id/menu_add_credit_card"
|
|
||||||
android:icon="@drawable/ic_credit_card_white_24dp"
|
|
||||||
android:title="@string/entry_setup_credit_card"
|
|
||||||
android:orderInCategory="94"
|
|
||||||
app:iconTint="?attr/colorControlNormal"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
<item android:id="@+id/menu_add_field"
|
<item android:id="@+id/menu_add_field"
|
||||||
android:icon="@drawable/ic_new_field_white_24dp"
|
android:icon="@drawable/ic_new_field_white_24dp"
|
||||||
android:title="@string/entry_add_field"
|
android:title="@string/entry_add_field"
|
||||||
|
|||||||
@@ -363,7 +363,6 @@
|
|||||||
<string name="security">Sicherheit</string>
|
<string name="security">Sicherheit</string>
|
||||||
<string name="entry_history">Verlauf</string>
|
<string name="entry_history">Verlauf</string>
|
||||||
<string name="entry_setup_otp">Einmalpasswort einrichten</string>
|
<string name="entry_setup_otp">Einmalpasswort einrichten</string>
|
||||||
<string name="entry_setup_credit_card">Kreditkarte hinzufügen</string>
|
|
||||||
<string name="otp_type">OTP-Typ</string>
|
<string name="otp_type">OTP-Typ</string>
|
||||||
<string name="otp_secret">Geheimnis</string>
|
<string name="otp_secret">Geheimnis</string>
|
||||||
<string name="otp_period">Zeitraum (Sekunden)</string>
|
<string name="otp_period">Zeitraum (Sekunden)</string>
|
||||||
|
|||||||
@@ -93,7 +93,6 @@
|
|||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
<string name="entry_title">Title</string>
|
<string name="entry_title">Title</string>
|
||||||
<string name="entry_setup_otp">Set up one-time password</string>
|
<string name="entry_setup_otp">Set up one-time password</string>
|
||||||
<string name="entry_setup_credit_card">Edit credit card details</string>
|
|
||||||
<string name="otp_type">OTP type</string>
|
<string name="otp_type">OTP type</string>
|
||||||
<string name="otp_secret">Secret</string>
|
<string name="otp_secret">Secret</string>
|
||||||
<string name="otp_period">Period (seconds)</string>
|
<string name="otp_period">Period (seconds)</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user