-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathScanCardIntent.java
More file actions
102 lines (76 loc) · 3.32 KB
/
ScanCardIntent.java
File metadata and controls
102 lines (76 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package cards.pay.paycardsrecognizer.sdk;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.IntDef;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import cards.pay.paycardsrecognizer.sdk.ui.ScanCardActivity;
import cards.pay.paycardsrecognizer.sdk.ui.ScanCardRequest;
import static cards.pay.paycardsrecognizer.sdk.ui.ScanCardRequest.DEFAULT_ENABLE_SOUND;
import static cards.pay.paycardsrecognizer.sdk.ui.ScanCardRequest.DEFAULT_GRAB_CARD_IMAGE;
import static cards.pay.paycardsrecognizer.sdk.ui.ScanCardRequest.DEFAULT_SCAN_CARD_HOLDER;
import static cards.pay.paycardsrecognizer.sdk.ui.ScanCardRequest.DEFAULT_SCAN_EXPIRATION_DATE;
public final class ScanCardIntent {
public static final int RESULT_CODE_ERROR = Activity.RESULT_FIRST_USER;
public static final String RESULT_PAYCARDS_CARD = "RESULT_PAYCARDS_CARD";
public static final String RESULT_CARD_IMAGE = "RESULT_CARD_IMAGE";
public static final String RESULT_CANCEL_REASON = "RESULT_CANCEL_REASON";
public static final int BACK_PRESSED = 1;
public static final int ADD_MANUALLY_PRESSED = 2;
@Retention(RetentionPolicy.SOURCE)
@IntDef(value = {BACK_PRESSED, ADD_MANUALLY_PRESSED})
public @interface CancelReason {}
@RestrictTo(RestrictTo.Scope.LIBRARY)
public static final String KEY_SCAN_CARD_REQUEST = "cards.pay.paycardsrecognizer.sdk.ui.ScanCardActivity.SCAN_CARD_REQUEST";
private ScanCardIntent() {
}
public final static class Builder {
private final Context mContext;
private boolean mEnableSound = DEFAULT_ENABLE_SOUND;
private boolean mScanExpirationDate = DEFAULT_SCAN_EXPIRATION_DATE;
private boolean mScanCardHolder = DEFAULT_SCAN_CARD_HOLDER;
private boolean mGrabCardImage = DEFAULT_GRAB_CARD_IMAGE;
public Builder(Context context) {
mContext = context;
}
/**
* Scan expiration date. Default: <b>true</b>
*/
public Builder setScanExpirationDate(boolean scanExpirationDate) {
mScanExpirationDate = scanExpirationDate;
return this;
}
/**
* Scan expiration date. Default: <b>true</b>
*/
public Builder setScanCardHolder(boolean scanCardHolder) {
mScanCardHolder = scanCardHolder;
return this;
}
/**
* Enables or disables sounds in the library.<Br>
* Default: <b>enabled</b>
*/
public Builder setSoundEnabled(boolean enableSound) {
mEnableSound = enableSound;
return this;
}
/**
* Defines if the card image will be captured.
* @param enable Defines if the card image will be captured. Default: <b>false</b>
*/
public Builder setSaveCard(boolean enable) {
mGrabCardImage = enable;
return this;
}
public Intent build() {
Intent intent = new Intent(mContext, ScanCardActivity.class);
ScanCardRequest request = new ScanCardRequest(mEnableSound, mScanExpirationDate,
mScanCardHolder, mGrabCardImage);
intent.putExtra(KEY_SCAN_CARD_REQUEST, request);
return intent;
}
}
}