Skip to content

Commit 8b6f75d

Browse files
committed
Editing README.md
1 parent 79be72d commit 8b6f75d

3 files changed

Lines changed: 128 additions & 1 deletion

File tree

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,128 @@
11
# LinearGraphView
2+
3+
[![](https://jitpack.io/v/swapnil1104/LinearGraphView.svg)](https://jitpack.io/#swapnil1104/LinearGraphView)
4+
5+
A custom view to display information in a Linear Graph with smooth animations!
6+
7+
A customised EditText view serving the purpose of taking numeric **One Time Password** from a user.
8+
With stunning animation, and high customizability.
9+
10+
![Demo with underline](images/demo.gif)
11+
12+
## Packed with features
13+
- Add custom character limit.
14+
- Use your own color scheme.
15+
- Do not allow user changing cursor position for smooth functioning.
16+
17+
18+
## How to integrate the library in your app?
19+
Step 1: Add it in your root build.gradle at the end of repositories:
20+
21+
```
22+
allprojects {
23+
repositories {
24+
maven { url "https://jitpack.io" }
25+
}
26+
}
27+
```
28+
Step 2. Add the dependency
29+
30+
```
31+
dependencies {
32+
implementation 'com.github.swapnil1104:OtpEditText:{current_lib_ver}'
33+
}
34+
```
35+
Step 3. Add OtpEditText to your layout file
36+
37+
```
38+
<com.broooapps.otpedittext2.OtpEditText
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:clickable="false"
42+
android:cursorVisible="false"
43+
android:digits="0123456789"
44+
android:inputType="number"
45+
android:maxLength="6"
46+
android:padding="8dp"
47+
android:textSize="30sp"
48+
app:oev_primary_color="@color/red"
49+
app:oev_secondary_color="@color/light_gray"
50+
/>
51+
```
52+
53+
## How to customize the view.
54+
### Setting desired length for the OTP(One time password code)
55+
56+
To set custom length of the OtpEditText, use
57+
58+
```android:maxLength="{your length}"```
59+
60+
This will automatically generate the right amount of boxes for user to input the code in.
61+
62+
### Setting primary custom color
63+
The primary color signifies the boundary of the box that requires input from user.
64+
To change that use,
65+
66+
```app:oev_primary_color="@color/{your_color}"```
67+
68+
69+
### Setting secondary custom color
70+
The secondary color signifies the boundary of the boxes that do not require input from user.
71+
To change that use,
72+
73+
```app:oev_secondary_color="@color/{your_color}"```
74+
75+
### Using multiple style options.
76+
There are 4 style options that are available within the library for now.
77+
- rounded box
78+
- square box
79+
- underline
80+
- rounded underline
81+
82+
To use any of these styles, please add ```app:oev_box_style="@string\{box_style_input}"```
83+
attribue.
84+
I have provided string resources for simpler usage.
85+
```
86+
<string name="style_square">square_box</string>
87+
<string name="style_rounded">rounded_box</string>
88+
<string name="style_underline">underline</string>
89+
<string name="style_rounded_underline">rounded_underline</string>
90+
```
91+
Suppose you want the rounded underline option to be displayed. Then, please add:
92+
`app:oev_box_style="@string/style_rounded_underline" ` in the OtpEditText xml code.
93+
94+
### Masking input characters with Asterisk.
95+
Functionality to mask the input with any special character has been introduced.
96+
To mask the input;
97+
```
98+
app:oev_mask_input="true"
99+
```
100+
xml property must be introduced in the XML layout file.
101+
102+
#### Masking with any other special character.
103+
To mask input with any character other than `*` you can do the following;
104+
```
105+
app:oev_mask_character="ø"
106+
```
107+
108+
P.S. Please note that, in case of masking with a special character other than `*`, specify string with length one, otherwise the input string will be truncated to length 1.
109+
110+
### OnComplete callback for the View
111+
To implement an OnComplete callback, use `setOnCompleteListener` setter method and pass on an interface implementation.
112+
eg:
113+
```
114+
editText.setOnCompleteListener(new OnCompleteListener() {
115+
@Override
116+
public void onComplete(String value) {
117+
Toast.makeText(MainActivity.this, "Completed " + value, Toast.LENGTH_SHORT).show();
118+
}
119+
});
120+
```
121+
122+
This callback will be triggered when the number of characters is equal to the `android:maxLength` value.
123+
124+
## For optimum usage; Please note.
125+
* Specify `android:textSize` according to your needs.
126+
* Specify `android:padding` according to your needs, there are no paddings drawn by default.
127+
* Specify `android:layout_height` according to the `textSize` you've provided. The view will try to center the text with a vertical biasing of `0.6f`.
128+

app/src/main/java/com/broooapps/lineargraphview/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected void onCreate(Bundle savedInstanceState) {
2424
dm.add(new DataModel("One", "#123123", 200));
2525
dm.add(new DataModel("two", "#abcdef", 200));
2626
dm.add(new DataModel("three", "#cdebad", 200));
27-
dm.add(new DataModel("four", "#abbcde", 200));
27+
dm.add(new DataModel("four", "#abbcde", 200));
2828

2929
lgv.setData(dm, 999);
3030
}

images/demo.gif

18.9 KB
Loading

0 commit comments

Comments
 (0)