Skip to content

Commit 563af08

Browse files
committed
Editing README.md _1
1 parent 8b6f75d commit 563af08

6 files changed

Lines changed: 39 additions & 102 deletions

File tree

README.md

Lines changed: 24 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@
44

55
A custom view to display information in a Linear Graph with smooth animations!
66

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-
107
![Demo with underline](images/demo.gif)
118

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-
189
## How to integrate the library in your app?
1910
Step 1: Add it in your root build.gradle at the end of repositories:
2011

@@ -29,100 +20,46 @@ Step 2. Add the dependency
2920

3021
```
3122
dependencies {
32-
implementation 'com.github.swapnil1104:OtpEditText:{current_lib_ver}'
23+
implementation 'com.github.swapnil1104:LinearGraphView:{current_lib_ver}'
3324
}
3425
```
3526
Step 3. Add OtpEditText to your layout file
3627

3728
```
38-
<com.broooapps.otpedittext2.OtpEditText
29+
<com.broooapps.lineargraphview2.LinearGraphView
30+
android:id="@+id/linear_graph_view"
3931
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-
/>
32+
android:layout_height="wrap_content" />
5133
```
5234

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-
35+
Step 4. Refer this View in your activity file, create a List<DataModel> and populate it with your values, use this list and invoke `setData(List<DataModel> dataModel, int range)`.
6836

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,
37+
The second param is the entire span graph view, and `value` param in each DataModel object will occupy a percent length.
38+
Width of each item is calculated by `model.value / range * viewWidth`.
39+
```
40+
LinearGraphView lgv = findViewById(R.id.linear_graph_view);
7241
73-
```app:oev_secondary_color="@color/{your_color}"```
42+
List<DataModel> dataList = new ArrayList<>();
7443
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
44+
dm.add(new DataModel("One", "#00ffff", 100));
45+
dm.add(new DataModel("Two", "#74EEA1", 250));
46+
dm.add(new DataModel("Three", "#f2002f", 100));
47+
dm.add(new DataModel("four", "#B61CB3", 180));
8148
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.
49+
lgv.setData(dm, 999);
10150
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="ø"
10651
```
52+
The above code will result in this:
53+
![Demo with underline](images/demo2.gif)
10754

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.
55+
## How to customize the view.
56+
### Setting custom border color
10957

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-
```
58+
To use a custom color for the border of LinearGraphView, use
12159

122-
This callback will be triggered when the number of characters is equal to the `android:maxLength` value.
60+
```app:lgv_border_color="@color/colorAccent"```
12361

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`.
62+
### Setting border animation duration
63+
To change the animation duration of the initial border transition, use
12864

65+
```app:lgv_border_anim_duration="{TIME_IN_MS}"```

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ protected void onCreate(Bundle savedInstanceState) {
2121

2222
List<DataModel> dm = new ArrayList<>();
2323

24-
dm.add(new DataModel("One", "#123123", 200));
25-
dm.add(new DataModel("two", "#abcdef", 200));
26-
dm.add(new DataModel("three", "#cdebad", 200));
27-
dm.add(new DataModel("four", "#abbcde", 200));
24+
dm.add(new DataModel("One", "#00ffff", 100));
25+
dm.add(new DataModel("Two", "#74EEA1", 250));
26+
dm.add(new DataModel("Three", "#f2002f", 100));
27+
dm.add(new DataModel("four", "#B61CB3", 180));
2828

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

images/demo2.gif

16.2 KB
Loading

lineargraphview2/src/main/java/com/broooapps/lineargraphview2/DataModel.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class DataModel {
77

8-
int data;
8+
int value;
99

1010
@ColorInt
1111
int colorInt;
@@ -15,24 +15,24 @@ public class DataModel {
1515
@Nullable
1616
String title;
1717

18-
public DataModel(String title, int colorInt, int data) {
19-
this.data = data;
18+
public DataModel(String title, int colorInt, int value) {
19+
this.value = value;
2020
this.title = title;
2121
this.colorInt = colorInt;
2222
}
2323

24-
public DataModel(String title, String colorRes, int data) {
25-
this.data = data;
24+
public DataModel(String title, String colorRes, int value) {
25+
this.value = value;
2626
this.title = title;
2727
this.colorRes = colorRes;
2828
}
2929

30-
public int getData() {
31-
return data;
30+
public int getValue() {
31+
return value;
3232
}
3333

34-
public void setData(int data) {
35-
this.data = data;
34+
public void setValue(int value) {
35+
this.value = value;
3636
}
3737

3838
public String getColorRes() {

lineargraphview2/src/main/java/com/broooapps/lineargraphview2/LinearGraphView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void startAnim() {
214214
paint.setColor(Color.parseColor(model.colorRes));
215215
dataPaintList.add(paint);
216216

217-
float curWidth = model.data / totalValue * width;
217+
float curWidth = model.value / totalValue * width;
218218
if (curWidth < cornerRadius) {
219219
curWidth = cornerRadius * 1.5F;
220220
}

lineargraphview2/src/main/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<resources>
33

44
<color name="linear_graph_border">#000</color>
5-
<color name="linear_graph_bg">#f2f2f2</color>
5+
<color name="linear_graph_bg">#B61CB3</color>
66

77
</resources>

0 commit comments

Comments
 (0)