├── CustomGauge ├── .gitignore ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ ├── strings.xml │ │ │ └── attrs.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── pl │ │ └── pawelkleczkowski │ │ └── customgauge │ │ └── CustomGauge.java ├── proguard-rules.pro └── build.gradle ├── CustomGaugeExample ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── material_colors.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 │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── pl │ │ │ └── pawelkleczkowski │ │ │ └── customgaugeexample │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── pl │ │ │ └── pawelkleczkowski │ │ │ └── customgauge │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── pl │ │ └── pawelkleczkowski │ │ └── customgauge │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── example.png ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /CustomGauge/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /CustomGaugeExample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':CustomGaugeExample', ':CustomGauge' -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/example.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/ 4 | /.idea/ 5 | .DS_Store 6 | build/ 7 | *.iml -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /CustomGauge/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CustomGauge 3 | 4 | -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CustomGauge 3 | 4 | -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/CustomGaugeExample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/CustomGaugeExample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/CustomGaugeExample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/CustomGaugeExample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkleczko/CustomGauge/HEAD/CustomGaugeExample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 10 15:46:48 EET 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /CustomGauge/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CustomGaugeExample/src/test/java/pl/pawelkleczkowski/customgauge/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package pl.pawelkleczkowski.customgauge; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /CustomGaugeExample/src/androidTest/java/pl/pawelkleczkowski/customgauge/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package pl.pawelkleczkowski.customgauge; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /CustomGauge/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:\Program Files\Android SDK\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 | -------------------------------------------------------------------------------- /CustomGaugeExample/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:\Program Files\Android SDK\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 | -------------------------------------------------------------------------------- /CustomGaugeExample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | applicationId "pl.pawelkleczkowskicustomgauge" 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 4 11 | versionName "1.0.4" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation project(':CustomGauge') 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | testImplementation 'junit:junit:4.12' 25 | implementation 'com.android.support:appcompat-v7:28.0.0' 26 | } 27 | -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /CustomGauge/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CustomGauge/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | bintrayRepo = 'maven' 5 | bintrayName = 'CustomGauge' 6 | 7 | publishedGroupId = 'pl.pawelkleczkowski.customgauge' 8 | libraryName = 'CustomGauge' 9 | artifact = 'CustomGauge' 10 | 11 | libraryDescription = 'A simple gauge view for Android applications' 12 | 13 | siteUrl = 'https://github.com/pkleczko/CustomGauge' 14 | gitUrl = 'https://github.com/pkleczko/CustomGauge.git' 15 | 16 | libraryVersion = '1.0.3' 17 | 18 | developerId = 'pkleczko' 19 | developerName = 'Pawel Kleczkowski' 20 | developerEmail = 'contact@pawelkleczkowski.pl' 21 | 22 | licenseName = 'Apache License 2.0' 23 | licenseUrl = 'https://github.com/pkleczko/CustomGauge/blob/master/LICENSE' 24 | allLicenses = ["APACHE-2.0"] 25 | } 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | defaultConfig { 31 | minSdkVersion 15 32 | targetSdkVersion 28 33 | versionCode 4 34 | versionName "1.0.4" 35 | } 36 | buildTypes { 37 | release { 38 | minifyEnabled false 39 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 40 | } 41 | } 42 | } 43 | 44 | dependencies { 45 | implementation fileTree(dir: 'libs', include: ['*.jar']) 46 | implementation 'com.android.support:appcompat-v7:28.0.0' 47 | } 48 | 49 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' 50 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' 51 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/java/pl/pawelkleczkowski/customgaugeexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package pl.pawelkleczkowski.customgaugeexample; 2 | 3 | import java.util.Locale; 4 | 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.Toolbar; 8 | import android.view.View; 9 | import android.view.View.OnClickListener; 10 | import android.widget.Button; 11 | import android.widget.TextView; 12 | 13 | import pl.pawelkleczkowski.customgauge.CustomGauge; 14 | 15 | 16 | public class MainActivity extends AppCompatActivity { 17 | 18 | private CustomGauge gauge1; 19 | private CustomGauge gauge2; 20 | private CustomGauge gauge3; 21 | 22 | int i; 23 | private TextView text1; 24 | private TextView text2; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | 31 | Toolbar toolbar = findViewById(R.id.toolbar); 32 | toolbar.setTitle(getString(R.string.app_name)); 33 | setSupportActionBar(toolbar); 34 | 35 | Button button = findViewById(R.id.button); 36 | gauge1 = findViewById(R.id.gauge1); 37 | gauge2 = findViewById(R.id.gauge2); 38 | gauge3 = findViewById(R.id.gauge3); 39 | 40 | text1 = findViewById(R.id.textView1); 41 | text2 = findViewById(R.id.textView2); 42 | text1.setText(String.valueOf(gauge1.getValue())); 43 | text2.setText(String.valueOf(gauge2.getValue())); 44 | text2.setText(String.valueOf(gauge2.getValue())); 45 | 46 | button.setOnClickListener(new OnClickListener() { 47 | 48 | @Override 49 | public void onClick(View v) { 50 | gauge2.setEndValue(800); 51 | gauge2.setValue(200); 52 | text2.setText(String.format(Locale.getDefault(), "%1d/%2d", gauge2.getValue(), gauge2.getEndValue())); 53 | new Thread() { 54 | public void run() { 55 | for (i=0;i<100;i++) { 56 | if (i == 50) { 57 | gauge2.setEndValue(1200); 58 | } 59 | try { 60 | runOnUiThread(new Runnable() { 61 | @Override 62 | public void run() { 63 | gauge1.setValue(i*10); 64 | gauge2.setValue(200 + i*5); 65 | gauge3.setValue(i); 66 | text1.setText(String.valueOf(gauge1.getValue())); 67 | text2.setText(String.format(Locale.getDefault(), "%1d/%2d", gauge2.getValue(), gauge2.getEndValue())); 68 | } 69 | }); 70 | Thread.sleep(50); 71 | } catch (InterruptedException e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | } 76 | }.start(); 77 | } 78 | }); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CustomGauge 2 | =========== 3 | 4 | Simple gauge view 5 | 6 | 7 | 8 | 9 |   10 | 11 | ### Installation 12 | 13 | * Add the following to your build.gradle: 14 | 15 | 16 |
repositories {
17 |     jcenter()
18 | }
19 | 
20 | dependencies {
21 |     compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.4'
22 | }
23 | * Add "pl.pawelkleczkowski.customgauge.CustomGauge" view in your layout (example below) 24 | * Find CustomGauge view in your activity and use methods "setValue()" and "getValue()" to manage view 25 | 26 | ### Attributes 27 | 28 | Available view attributes: 29 | 30 | * startAngel (left start angel in degrees) - please be informed that gauge is drawn as an arc from startAngel (where to start) with sweepAngel (how many degrees arc is); what is more it's clockwise (right - 0, bottom - 90, left - 180, top - 270 degrees); if for example you want full circle start on 90 with 360 sweepAngel 31 | * sweepAngel - as described above 32 | * startValue - scale start value 33 | * endValue - scale end value 34 | * strokeWidth - stroke width 35 | * strokeColor - resource color (cannot be selector) 36 | * strokeCap - style of circle stroke (BUTT - straight, ROUND - rounded) 37 | * pointSize - defined for pointer drawn on current value (first example) - tells how wide pointer should be; if not set pointer is drawn from start value to current value (like second example) 38 | * pointStartColor - used for gradient pointer (second example) 39 | * pointEndColor - used for gradient pointer (second example) 40 | * dividerSize - size of divider related to values; if declared dividers will be drawn(!); e.g. if your start value is 50 and end value is 120 dividerSize set to 2 means that divider will have 1/35 of gauge total width - in other words it will have size of 2 points of gauge scale 41 | * dividerStep - tells how often dividers will be drawn; it's in percentage values(!); e.g. if you want to have dividers drawn each 20% of scale just set it to 20 and you will have 6 dividers drawn (with first and last) 42 | * dividerColor - color of divider 43 | * dividerDrawFirst - whether to draw first divider or no 44 | * dividerDrawLast - whether to draw last divider or no 45 | 46 | 47 | 48 | ### Example 49 | 50 | 51 | 71 | 72 | 91 | 92 |   93 | 94 | ### License 95 | 96 | GNU General Public License, version 2 -------------------------------------------------------------------------------- /CustomGaugeExample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 15 | 16 |