├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── fonts
│ │ ├── James-Almacen.ttf
│ │ ├── Xolonium-Bold.otf
│ │ ├── good-times.ttf
│ │ └── lhandw.ttf
│ ├── ic_launcher-web.png
│ ├── java
│ └── com
│ │ └── github
│ │ └── anastr
│ │ └── speedviewapp
│ │ ├── AboutActivity.kt
│ │ ├── AwesomeSpeedometerActivity.kt
│ │ ├── ControlActivity.kt
│ │ ├── CreateProgrammatically.kt
│ │ ├── DeluxeSpeedActivity.kt
│ │ ├── FulcrumActivity.kt
│ │ ├── ImageSpeedometerActivity.kt
│ │ ├── MainActivity.kt
│ │ ├── MarksActivity.kt
│ │ ├── PointerActivity.kt
│ │ ├── RayActivity.kt
│ │ ├── RecyclerActivity.kt
│ │ ├── SectionActivity.kt
│ │ ├── SpeedTextPositionActivity.kt
│ │ ├── SpeedViewActivity.kt
│ │ ├── StartEndDegreeActivity.kt
│ │ ├── TickActivity.kt
│ │ ├── TubeSpeedometerActivity.kt
│ │ ├── WorkWithIndicatorActivity.kt
│ │ ├── WorkWithModesActivity.kt
│ │ ├── WorkWithNoteActivity.kt
│ │ └── lineargauge
│ │ ├── ImageLinearGaugeActivity.kt
│ │ └── ProgressiveGaugeActivity.kt
│ └── res
│ ├── drawable
│ ├── fire.png
│ ├── for_image_speedometer.png
│ ├── github.png
│ ├── image_indicator1.png
│ ├── linkedin.png
│ └── user.png
│ ├── layout
│ ├── activity_about.xml
│ ├── activity_awesome_speedometer.xml
│ ├── activity_control.xml
│ ├── activity_create_programmatically.xml
│ ├── activity_deluxe_speed.xml
│ ├── activity_fulcrum.xml
│ ├── activity_image_linear_gauge.xml
│ ├── activity_image_speedometer.xml
│ ├── activity_main.xml
│ ├── activity_marks.xml
│ ├── activity_pointer.xml
│ ├── activity_progressive_gauge.xml
│ ├── activity_ray.xml
│ ├── activity_recycler.xml
│ ├── activity_section.xml
│ ├── activity_speed_text_position.xml
│ ├── activity_speed_view.xml
│ ├── activity_start_end_degree.xml
│ ├── activity_tick.xml
│ ├── activity_tube_speedometer.xml
│ ├── activity_work_with_indicator.xml
│ ├── activity_work_with_modes.xml
│ ├── activity_work_with_note.xml
│ └── card_view.xml
│ ├── menu
│ └── menu.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
├── AwesomeSpeedometer.gif
├── AwesomeSpeedometer.png
├── AwesomeSpeedometer_preview.png
├── DeluxeSpeedView.gif
├── DeluxeSpeedView1.png
├── DeluxeSpeedView2.png
├── ImageLinearGauge.gif
├── ImageLinearGauge.png
├── ImageSpeedometer.gif
├── ImageSpeedometer.png
├── Jetpack-Compose.png
├── PointerSpeedometer.gif
├── PointerSpeedometer.png
├── ProgressiveGauge.gif
├── ProgressiveGauge.png
├── RaySpeedometer.gif
├── RaySpeedometer.png
├── SpeedView.gif
├── SpeedView1.png
├── SpeedView2.png
├── SpeedView3.png
├── SpeedView4.png
├── TubeSpeedometer.gif
├── TubeSpeedometer.png
├── new2.png
├── new3.png
└── usage
│ ├── LightEffect.gif
│ ├── LowMediumPercent.png
│ ├── RightToLeft.png
│ ├── StartEndDegree.png
│ ├── WorkWithNote.gif
│ ├── indicators
│ ├── HalfLineIndicator.png
│ ├── KiteIndicator.png
│ ├── LineIndicator.png
│ ├── NeedleIndicator.png
│ ├── NormalIndicator.png
│ ├── NormalSmallIndicator.png
│ ├── QuarterLineIndicator.png
│ ├── SpindleIndicator.png
│ └── TriangleIndicator.png
│ ├── modes.png
│ ├── speedTextPosition.png
│ ├── ticks.png
│ ├── unitSideSpeedText.png
│ └── unitUnderSpeedText.png
├── settings.gradle
└── speedviewlib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
└── main
├── AndroidManifest.xml
├── java
└── com
│ └── github
│ └── anastr
│ └── speedviewlib
│ ├── AwesomeSpeedometer.kt
│ ├── DeluxeSpeedView.kt
│ ├── Gauge.kt
│ ├── ImageLinearGauge.kt
│ ├── ImageSpeedometer.kt
│ ├── LinearGauge.kt
│ ├── PointerSpeedometer.kt
│ ├── ProgressiveGauge.kt
│ ├── RaySpeedometer.kt
│ ├── SpeedView.kt
│ ├── Speedometer.kt
│ ├── TubeSpeedometer.kt
│ ├── components
│ ├── Section.kt
│ ├── Style.kt
│ ├── indicators
│ │ ├── ImageIndicator.kt
│ │ ├── Indicator.kt
│ │ ├── KiteIndicator.kt
│ │ ├── LineIndicator.kt
│ │ ├── NeedleIndicator.kt
│ │ ├── NoIndicator.kt
│ │ ├── NormalIndicator.kt
│ │ ├── NormalSmallIndicator.kt
│ │ ├── SpindleIndicator.kt
│ │ └── TriangleIndicator.kt
│ └── note
│ │ ├── ImageNote.kt
│ │ ├── Note.kt
│ │ └── TextNote.kt
│ └── util
│ └── Utils.kt
└── res
└── values
├── attrs.xml
└── strings.xml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [anastr]
4 | custom: ['https://www.paypal.com/donate/?hosted_button_id=VQ9DDY2KSQLJW']
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: Bug report
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **XML & code**
21 | short and clean code.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Smartphone (Optional):**
27 | - OS: [e.g. Android 10]
28 | - Version [e.g. 1.5.0]
29 |
30 | **Additional context**
31 | Add any other context about the problem here.
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is.
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | local.properties
5 | .idea
6 | .DS_Store
7 | /build
8 | /release
9 | /captures
10 | *.aab
11 | *.apk
12 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
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 GitHub
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.
155 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 33
6 | buildToolsVersion '31.0.0'
7 |
8 | defaultConfig {
9 | applicationId 'com.github.anastr.speedviewapp'
10 | minSdkVersion 21
11 | targetSdkVersion 33
12 | versionCode 3
13 | versionName "1.6.0"
14 | }
15 |
16 | flavorDimensions "default"
17 | productFlavors {
18 | develop {
19 | applicationIdSuffix ".develop"
20 | resValue "string", "app_name", "SpeedView Test"
21 | }
22 | product {
23 | resValue "string", "app_name", "SpeedView"
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled true
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 | lintOptions {
34 | abortOnError false
35 | }
36 | }
37 |
38 | dependencies {
39 | implementation 'androidx.appcompat:appcompat:1.6.1'
40 | implementation 'androidx.cardview:cardview:1.0.0'
41 | implementation 'androidx.recyclerview:recyclerview:1.3.0'
42 | implementation project(':speedviewlib')
43 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
44 | }
45 | repositories {
46 | mavenCentral()
47 | }
48 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
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 |
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/James-Almacen.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anastr/SpeedView/c921ad40cfef3fde471ab1d088aaae819881f9a5/app/src/main/assets/fonts/James-Almacen.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Xolonium-Bold.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anastr/SpeedView/c921ad40cfef3fde471ab1d088aaae819881f9a5/app/src/main/assets/fonts/Xolonium-Bold.otf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/good-times.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anastr/SpeedView/c921ad40cfef3fde471ab1d088aaae819881f9a5/app/src/main/assets/fonts/good-times.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/lhandw.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anastr/SpeedView/c921ad40cfef3fde471ab1d088aaae819881f9a5/app/src/main/assets/fonts/lhandw.ttf
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anastr/SpeedView/c921ad40cfef3fde471ab1d088aaae819881f9a5/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/com/github/anastr/speedviewapp/AboutActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.anastr.speedviewapp
2 |
3 | import android.content.Intent
4 | import android.net.Uri
5 | import android.os.Bundle
6 | import android.widget.Button
7 | import androidx.appcompat.app.AppCompatActivity
8 |
9 | class AboutActivity : AppCompatActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.activity_about)
14 |
15 | findViewById