Skip to content

Commit 5584403

Browse files
authored
Create CONTRIBUTING.md
1 parent 0cf94b8 commit 5584403

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

CONTRIBUTING.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
if you want to contribute to this library, _Please_ take look at these **rules**.
2+
3+
_**First:**_ you must read [Get Starting](https://github.com/anastr/SpeedView/wiki/0.-Get-Started) and [Advanced Usage](https://github.com/anastr/SpeedView/wiki/Usage).
4+
5+
before you start, you have to know what you want to do:
6+
* [Fix Bugs](#fix-bugs).
7+
* [improve the Library](#improve-the-Library).
8+
* [Create New Speedometer](#create-new-speedometer).
9+
* [Build New Component](#build-new-component).
10+
11+
## Fix Bugs
12+
report abut the bug with explain and Screenshots _if it possible_, and we will discuss about it to solve it as fast as possible.
13+
14+
## improve the Library
15+
add some `methods, classes, interfaces.....` anywhere, **please** Post a _description_ of each new method and variable, use simple english language to explain.
16+
17+
## Create New Speedometer
18+
keep these in your mind when you want to create new Speedometer
19+
* extends `Speedometer` class.
20+
* implement abstract methods.
21+
* Override `onSizeChanged(int w, int h, int oldW, int oldH)` method.
22+
* Override `onDraw(Canvas canvas)` method.
23+
* add default Gauge values in `defaultValues()` method by call super for each, like so:
24+
```java
25+
super.setBackgroundCircleColor(Color.TRANSPARENT);
26+
```
27+
* add default Speedometer values in `defaultSpeedometerValues()` method by call super for each, like so:
28+
```java
29+
super.setSpeedometerColor(Color.RED);
30+
super.setSpeedometerWidth(dpTOpx(40f));
31+
```
32+
* call `updateBackgroundBitmap();` at end of `onSizeChanged` method.
33+
* call `drawTicks(canvas);` inside `updateBackgroundBitmap()` method.
34+
* call `drawSpeedUnitText(canvas);` inside `onDraw` method.
35+
* call `drawIndicator(canvas);` inside `onDraw` method.
36+
* call `drawNotes(canvas);` at end of `onDraw` method.
37+
* add this lines at first of `updateBackgroundBitmap` method:
38+
```java
39+
Canvas c = createBackgroundBitmapCanvas();
40+
// draw on c canvas all drawing that doesn't change when speed update.
41+
```
42+
43+
_so_, **your CustomSpeedometer class must be like this**:
44+
```java
45+
/**
46+
* this Library build By Anas Altair, and this Speedometer added by YOUR_NAME.
47+
* see it on <a href="https://github.com/anastr/SpeedView">GitHub</a>
48+
*/
49+
public class CustomSpeedometer extends Speedometer {
50+
51+
// add your Variables Here.
52+
53+
public CustomSpeedometer(Context context) {
54+
this(context, null);
55+
}
56+
57+
public CustomSpeedometer(Context context, AttributeSet attrs) {
58+
this(context, attrs, 0);
59+
}
60+
61+
public CustomSpeedometer(Context context, AttributeSet attrs, int defStyleAttr) {
62+
super(context, attrs, defStyleAttr);
63+
}
64+
65+
@Override
66+
protected void defaultValues() {
67+
// add default Gauge's values by call super.method like
68+
// super.setBackgroundCircleColor(Color.TRANSPARENT);
69+
}
70+
71+
@Override
72+
protected void defaultSpeedometerValues() {
73+
// add default Speedometer's values by call super.method like
74+
// super.setStartEndDegree(135, 135 + 320);
75+
76+
// by default there is No Indicator, add indicator by:
77+
// super.setIndicator(new TriangleIndicator(getContext())
78+
// .setIndicatorWidth(dpTOpx(25f))
79+
// .setIndicatorColor(0xff00e6e6));
80+
}
81+
82+
@Override
83+
protected void onSizeChanged(int w, int h, int oldW, int oldH) {
84+
super.onSizeChanged(w, h, oldW, oldH);
85+
86+
// update your speedometer here if it depend on size.
87+
88+
// don't remove this line, and don't move up.
89+
updateBackgroundBitmap();
90+
}
91+
92+
@Override
93+
protected void onDraw(Canvas canvas) {
94+
super.onDraw(canvas);
95+
// backgroundBitmap is Already painted.
96+
97+
// you can draw what do you want here.
98+
99+
// you must call this method to draw speed-unit Text.
100+
// this method must call before drawIndicator(canvas) method.
101+
drawSpeedUnitText(canvas);
102+
// you must call this method to draw the indicator.
103+
// put it wherever you want inside this method.
104+
drawIndicator(canvas);
105+
106+
// you can draw what do you want here.
107+
108+
// don't remove this line, and don't move up.
109+
drawNotes(canvas);
110+
}
111+
112+
@Override
113+
protected void updateBackgroundBitmap() {
114+
// don't remove these lines.
115+
Canvas c = createBackgroundBitmapCanvas();
116+
117+
// you must call drawTicks(c), but if you wont to draw
118+
// min and max speed value use this.
119+
if (getTickNumber() > 0)
120+
drawTicks(c);
121+
else
122+
drawDefMinMaxSpeedPosition(c);
123+
}
124+
125+
// add your custom methods here.
126+
}
127+
```
128+
these methods/varibles can help you in your custom Speedometer:
129+
130+
method/varible | description
131+
--- | ---
132+
getSpeedText() | get correct speed as string to **Draw**.
133+
getUnit() | get unit string to **Draw**.
134+
getSize() | return width of SpeedometerRect.
135+
getSizePa() | return width of SpeedometerRect without padding.
136+
getWidthPa() | return View width without padding.
137+
getHeightPa() | return View height without padding.
138+
isSpeedometerTextRightToLeft() | if `true` you should draw unit string to the left of speed Text.
139+
getPadding() | use just this method to get padding.
140+
getDegree() | return correct degree of indicator.
141+
getStartDegree() | start degree where indicator and speedometer start.
142+
getEndDegree() | the end of speedometer, where indicator and speedometer must stop.
143+
getLowSpeedOffset() | return [0f, 1f], where `LowSpeedSection` must stop between **startDegree** and **endDegree** [what is this?](https://github.com/anastr/SpeedView/wiki/Usage#control-division-of-the-speedometer).
144+
getMediumSpeedOffset() | return [0f, 1f], where `MediumSpeedSection` must stop between **startDegree** and **endDegree** [what is this?](https://github.com/anastr/SpeedView/wiki/Usage#control-division-of-the-speedometer).
145+
drawDefMinMaxSpeedPosition (canvas) | use this method in `updateBackgroundBitmap()` method if you want to draw **Min** and **Max** speed text in default position.
146+
drawTicks (canvas) | use this method in `updateBackgroundBitmap()` method to draw [Ticks](https://github.com/anastr/SpeedView/wiki/Usage#ticks).
147+
unitTextPaint | you must use this paint to draw unit text.
148+
149+
and also : `getSpeedometerWidth()`, `getMarkColor()`, `getIndicatorColor()`, `getCenterCircleColor()`, `getLowSpeedColor()`, `getMediumSpeedColor()`, `getHighSpeedColor()`, `getTextColor()`, `getBackgroundCircleColor()`, `getIndicatorWidth()`.
150+
151+
## Build New Component
152+
_**components:**_ are small objects can be drawn on speedometer.
153+
154+
just like [Indicators](https://github.com/anastr/SpeedView/wiki/Indicators) and [Notes](https://github.com/anastr/SpeedView/wiki/Notes), your component must have `draw()` method with `Canvas` parameter.

0 commit comments

Comments
 (0)