diff options
Diffstat (limited to 'android')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/RedeemVoucherButton.kt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/RedeemVoucherButton.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/RedeemVoucherButton.kt new file mode 100644 index 0000000000..308eff37df --- /dev/null +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/RedeemVoucherButton.kt @@ -0,0 +1,37 @@ +package net.mullvad.mullvadvpn.ui.widget + +import android.content.Context +import android.support.v4.app.FragmentManager +import android.util.AttributeSet +import net.mullvad.mullvadvpn.ui.RedeemVoucherDialogFragment +import net.mullvad.mullvadvpn.util.JobTracker + +class RedeemVoucherButton : Button { + constructor(context: Context) : super(context) {} + + constructor(context: Context, attributes: AttributeSet) : super(context, attributes) {} + + constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : + super(context, attributes, defaultStyleAttribute) {} + + constructor( + context: Context, + attributes: AttributeSet, + defaultStyleAttribute: Int, + defaultStyleResource: Int + ) : super(context, attributes, defaultStyleAttribute, defaultStyleResource) {} + + fun prepare( + fragmentManager: FragmentManager?, + jobTracker: JobTracker, + jobName: String = "openRedeemVoucherDialog" + ) { + setOnClickAction(jobName, jobTracker) { + fragmentManager?.beginTransaction()?.let { transaction -> + transaction.addToBackStack(null) + + RedeemVoucherDialogFragment().show(transaction, null) + } + } + } +} |
